diff --git a/.gitignore b/.gitignore index bbbef0357..71251cf8a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,9 @@ _infrastructure/tests/build #rx.js !rx.js +#zip.js +!zip.js + node_modules .sublimets diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a8032eaab..88905c88a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -25,7 +25,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](angular-translate/angular-translate.d.ts) [Angular Translate (pascalprecht.translate module)](https://github.com/PascalPrecht/angular-translate) by [Michel Salib](https://github.com/michelsalib) * [:link:](angular-ui-bootstrap/angular-ui-bootstrap.d.ts) [Angular UI Bootstrap](https://github.com/angular-ui/bootstrap) by [Brian Surowiec](https://github.com/xt0rted) * [:link:](angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts) [angular-bootstrap-lightbox](https://github.com/compact/angular-bootstrap-lightbox) by [Roland Zwaga](https://github.com/rolandzwaga) -* [:link:](angular-hotkeys/angular-hotkeys.d.ts) [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys) by [Jason Zhao](https://github.com/jlz27) +* [:link:](angular-hotkeys/angular-hotkeys.d.ts) [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys) by [Jason Zhao](https://github.com/jlz27), [Stefan Steinhart](https://github.com/reppners) * [:link:](angular-http-auth/angular-http-auth.d.ts) [angular-http-auth](https://github.com/witoldsz/angular-http-auth) by [vvakame](https://github.com/vvakame) * [:link:](angular-local-storage/angular-local-storage.d.ts) [angular-local-storage](https://github.com/grevory/angular-local-storage) by [Ken Fukuyama](https://github.com/kenfdev) * [:link:](angular-notify/angular-notify.d.ts) [angular-notify](https://github.com/cgross/angular-notify) by [Suwato](https://github.com/Suwato/DefinitelyTyped) @@ -41,6 +41,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](cordova/cordova.d.ts) [Apache Cordova](http://cordova.apache.org) by [Microsoft Open Technologies Inc.](http://msopentech.com) * [:link:](appframework/appframework.d.ts) [AppFramework](http://app-framework-software.intel.com) by [kyo_ago](https://github.com/kyo-ago) * [:link:](arbiter/Arbiter.d.ts) [Arbiter.js](http://arbiterjs.com) by [Arash Shakery](https://github.com/arash16) +* [:link:](archy/archy.d.ts) [archy](https://github.com/substack/node-archy) by [vvakame](https://github.com/vvakame) * [:link:](asciify/asciify.d.ts) [asciify](https://www.npmjs.org/package/asciify) by [Alan Norbauer](http://alan.norbauer.com) * [:link:](aspnet-identity-pw/aspnet-identity-pw.d.ts) [aspnet-identity-pw](https://github.com/Syncbak-Git/aspnet-identity-pw) by [jt000](https://github.com/jt000) * [:link:](assert/assert.d.ts) [assert and power-assert](https://github.com/Jxck/assert) by [vvakame](https://github.com/vvakame) @@ -65,6 +66,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](bigint/bigint.d.ts) [BigInt](https://github.com/Evgenus/BigInt) by [Eugene Chernyshov](https://github.com/Evgenus) * [:link:](big-integer/big-integer.d.ts) [BigInteger.js](https://github.com/peterolson/BigInteger.js) by [Ingo Bürk](https://github.com/Airblader), [Roel van Uden](https://github.com/Deathspike) * [:link:](bigscreen/bigscreen.d.ts) [BigScreen](http://brad.is/coding/BigScreen) by [Douglas Eichelberger](https://github.com/dduugg) +* [:link:](bitwise-xor/bitwise-xor.d.ts) [bitwise-xor](https://github.com/czzarr/node-bitwise-xor) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](bluebird/bluebird.d.ts) [bluebird](https://github.com/petkaantonov/bluebird) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](body-parser/body-parser.d.ts) [body-parser](http://expressjs.com) by [Santi Albo](https://github.com/santialbo), [VILIC VANE](https://vilic.info), [Jonathan Häberle](https://github.com/dreampulse) * [:link:](boom/boom.d.ts) [boom](http://github.com/hapijs/boom) by [Igor Rogatty](http://github.com/rogatty) @@ -76,7 +78,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](bootstrap.paginator/bootstrap.paginator.d.ts) [bootstrap.paginator](https://github.com/lyonlai/bootstrap-paginator) by [derikwhittaker](https://github.com/derikwhittaker) * [:link:](bootstrap.timepicker/bootstrap.timepicker.d.ts) [bootstrap.timepicker](https://github.com/jdewit/bootstrap-timepicker) by [derikwhittaker](https://github.com/derikwhittaker) * [:link:](box2d/box2dweb.d.ts) [bootstrap.timepicker](http://code.google.com/p/box2dweb) by [jbaldwin](https://github.com/jbaldwin) -* [:link:](breeze/breeze.d.ts) [Breeze](http://www.breezejs.com) by [Boris Yankov](https://github.com/borisyankov), [IdeaBlade](https://github.com/IdeaBlade/Breeze) +* [:link:](breeze/breeze.d.ts) [Breeze 1.5.x](http://www.breezejs.com) by [Boris Yankov](https://github.com/borisyankov), [IdeaBlade](https://github.com/IdeaBlade/Breeze) * [:link:](browser-harness/browser-harness.d.ts) [Browser Harness](https://github.com/scriby/browser-harness) by [Chris Scribner](https://github.com/scriby) * [:link:](browser-sync/browser-sync.d.ts) [browser-sync](http://www.browsersync.io) by [Asana](https://asana.com) * [:link:](browserify/browserify.d.ts) [Browserify](http://browserify.org) by [Andrew Gaspar](https://github.com/AndrewGaspar) @@ -84,6 +86,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](buffer-equal/buffer-equal.d.ts) [buffer-equal](https://github.com/substack/node-buffer-equal) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](bl/bl.d.ts) [BufferList](https://github.com/rvagg/bl) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](bufferstream/bufferstream.d.ts) [bufferstream](https://github.com/dodo/node-bufferstream) by [Bart van der Schoor](https://github.com/Bartvds) +* [:link:](bunyan-prettystream/bunyan-prettystream.d.ts) [bunyan-prettystream](https://www.npmjs.com/package/bunyan-prettystream) by [Jason Swearingen](https://github.com/jasonswearingen) * [:link:](business-rules-engine/business-rules-engine.d.ts) [business-rules-engine](https://github.com/rsamec/form) by [Roman Samec](https://github.com/rsamec) * [:link:](byline/byline.d.ts) [byline](https://github.com/jahewson/node-byline) by [Stefan Steinhart](https://github.com/reppners) * [:link:](camljs/camljs.d.ts) [camljs](http://camljs.codeplex.com) by [Andrey Markeev](http://markeev.com) @@ -96,10 +99,12 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](chai-http/chai-http.d.ts) [chai-http](https://github.com/chaijs/chai-http) by [Wim Looman](https://github.com/Nemo157) * [:link:](chai-jquery/chai-jquery.d.ts) [chai-jquery](https://github.com/chaijs/chai-jquery) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid) * [:link:](chalk/chalk.d.ts) [chalk](https://github.com/sindresorhus/chalk) by [Diullei Gomes](https://github.com/Diullei), [Bart van der Schoor](https://github.com/Bartvds) +* [:link:](chance/chance.d.ts) [Chance](http://chancejs.com) by [Chris Bowdon](https://github.com/cbowdon) * [:link:](change-case/change-case.d.ts) [change-case](https://github.com/blakeembrey/change-case) by [Asana](https://asana.com) * [:link:](chartjs/chart.d.ts) [Chart.js](https://github.com/nnnick/Chart.js) by [Steve Fenton](https://github.com/Steve-Fenton) * [:link:](checksum/checksum.d.ts) [checksum](https://github.com/dshaw/checksum) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](cheerio/cheerio.d.ts) [Cheerio](https://github.com/cheeriojs/cheerio) by [Bret Little](https://github.com/blittle), [VILIC VANE](http://vilic.info), [Wayne Maurer](https://github.com/wmaurer) +* [:link:](chokidar/chokidar.d.ts) [chokidar](https://github.com/paulmillr/chokidar) by [Stefan Steinhart](https://github.com/reppners) * [:link:](chosen/chosen.jquery.d.ts) [Chosen.JQuery](http://harvesthq.github.com/chosen) by [Boris Yankov](https://github.com/borisyankov) * [:link:](chroma-js/chroma-js.d.ts) [Chroma.js](https://github.com/gka/chroma.js) by [Sebastian Brückner](https://github.com/invliD) * [:link:](chrome/chrome.d.ts) [Chrome extension development](http://developer.chrome.com/extensions) by [Matthew Kimber](https://github.com/matthewkimber), [otiai10](https://github.com/otiai10) @@ -135,7 +140,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](dat-gui/dat-gui.d.ts) [dat.GUI](https://github.com/dataarts/dat.gui) by [Satoru Kimura](https://github.com/gyohk) * [:link:](date.format.js/date.format.d.ts) [Date Format](http://blog.stevenlevithan.com/archives/date-time-format) by [Rob Stutton](https://github.com/balrob) * [:link:](datejs/datejs.d.ts) [DateJS](http://www.datejs.com) by [David Khristepher Santos](http://github.com/rupertavery) -* [:link:](dcjs/dc.d.ts) [DCJS](https://github.com/dc-js) by [hans windhoff](https://github.com/hansrwindhoff) +* [:link:](dcjs/dc.d.ts) [DCJS](https://github.com/dc-js/dc.js) by [hans windhoff](https://github.com/hansrwindhoff), [matt traynham](https://github.com/mtraynham) * [:link:](debug/debug.d.ts) [debug](https://github.com/visionmedia/debug) by [Seon-Wook Park](https://github.com/swook) * [:link:](deep-diff/deep-diff.d.ts) [deep-diff](https://github.com/flitbit/diff) by [ZauberNerd](https://github.com/ZauberNerd) * [:link:](deep-freeze/deep-freeze.d.ts) [deep-freeze](https://github.com/substack/deep-freeze) by [Bart van der Schoor](https://github.com/Bartvds) @@ -156,6 +161,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](dot/dot.d.ts) [doT](https://github.com/olado/doT) by [ZombieHunter](https://github.com/ZombieHunter) * [:link:](dotdotdot/dotdotdot.d.ts) [dotdotdot](http://dotdotdot.frebsite.nl) by [Milan Jaros](https://github.com/milanjaros) * [:link:](doublearray/doublearray.d.ts) [doublearray](https://github.com/takuyaa/doublearray) by [MIZUSHIMA Junki](https://github.com/mzsm) +* [:link:](drop/drop.d.ts) [Drop](http://github.hubspot.com/drop) by [Adi Dahiya](https://github.com/adidahiya) * [:link:](dropboxjs/dropboxjs.d.ts) [dropbox-js](https://github.com/dropbox/dropbox-js) by [Steve Fenton](https://github.com/Steve-Fenton), [Pedro Casaubon](https://github.com/xperiments) * [:link:](dropzone/dropzone.d.ts) [Dropzone](http://www.dropzonejs.com) by [Natan Vivo](https://github.com/nvivo) * [:link:](dts-bundle/dts-bundle.d.ts) [dts-bundle](https://github.com/TypeStrong/dts-bundle) by [Asana](https://asana.com) @@ -174,9 +180,11 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](epiceditor/epiceditor.d.ts) [EpicEditor](http://epiceditor.com) by [Boris Yankov](https://github.com/borisyankov) * [:link:](errorhandler/errorhandler.d.ts) [errorhandler](https://github.com/expressjs/errorhandler) by [Santi Albo](https://github.com/santialbo) * [:link:](es6-promise/es6-promise.d.ts) [es6-promise](https://github.com/jakearchibald/ES6-Promise) by [François de Campredon](https://github.com/fdecampredon), [vvakame](https://github.com/vvakame) +* [:link:](escape-latex/escape-latex.d.ts) [escape-latex](https://github.com/dangmai/escape-latex) by [Oliver Schneider](https://github.com/olsio) * [:link:](esprima/esprima.d.ts) [Esprima](http://esprima.org) by [teppeis](https://github.com/teppeis) * [:link:](event-loop-lag/event-loop-lag.d.ts) [event-loop-lag](https://github.com/pebble/event-loop-lag) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](eventemitter2/eventemitter2.d.ts) [EventEmitter2](https://github.com/asyncly/EventEmitter2) by [ryiwamoto](https://github.com/ryiwamoto) +* [:link:](eventemitter3/eventemitter3.d.ts) [EventEmitter3](https://github.com/primus/eventemitter3) by [Yuichi Murata](https://github.com/mrk21) * [:link:](exit/exit.d.ts) [exit](https://github.com/cowboy/node-exit) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](expect.js/expect.js.d.ts) [expect.js](https://github.com/LearnBoost/expect.js) by [Teppei Sato](https://github.com/teppeis) * [:link:](expectations/expectations.d.ts) [expectations.js](https://github.com/spmason/expectations) by [vvakame](https://github.com/vvakame) @@ -208,6 +216,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](flipsnap/flipsnap.d.ts) [flipsnap.js](http://pxgrid.github.io/js-flipsnap) by [kubosho](https://github.com/kubosho), [gsino](https://github.com/gsino), [Mayuki Sawatari](https://github.com/mayuki) * [:link:](flot/jquery.flot.d.ts) [Flot](http://www.flotcharts.org) by [Matt Burland](https://github.com/burlandm) * [:link:](flux/flux.d.ts) [Flux](http://facebook.github.io/flux) by [Steve Baker](https://github.com/stkb) +* [:link:](fluxxor/fluxxor.d.ts) [Fluxxor](https://github.com/BinaryMuse/fluxxor) by [Yuichi Murata](https://github.com/mrk21) * [:link:](ion.rangeSlider/ion.rangeSlider.d.ts) [for Ion.RangeSlider](https://github.com/IonDen/ion.rangeSlider) by [Sixin Li](https://github.com/sixinli) * [:link:](form-data/form-data.d.ts) [form-data](https://github.com/felixge/node-form-data) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](formidable/formidable.d.ts) [Formidable](https://github.com/felixge/node-formidable) by [Wim Looman](https://github.com/Nemo157) @@ -218,6 +227,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](ftdomdelegate/ftdomdelegate.d.ts) [ftdomdelegate](https://github.com/ftlabs/ftdomdelegate) by [Christian Holm Nielsen](https://github.com/dotnetnerd) * [:link:](fullCalendar/fullCalendar.d.ts) [FullCalendar](http://arshaw.com/fullcalendar) by [Neil Stalker](https://github.com/nestalk) * [:link:](fuse/fuse.d.ts) [Fuse.js](https://github.com/krisk/Fuse) by [Greg Smith](https://github.com/smrq) +* [:link:](jquery-galleria/jquery-galleria.d.ts) [galleria.js](https://github.com/aino/galleria) by [Robert Imig](https://github.com/rimig) * [:link:](gamepad/gamepad.d.ts) [Gamepad API](http://www.w3.org/TR/gamepad) by [Kon](http://phyzkit.net) * [:link:](gamequery/gamequery.d.ts) [gameQuery](http://gamequeryjs.com) by [David Laubreiter](https://github.com/Laubi) * [:link:](gently/gently.d.ts) [gently](https://www.npmjs.org/package/gently) by [bonnici](https://github.com/bonnici) @@ -236,6 +246,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](google.geolocation/google.geolocation.d.ts) [Google Geolocation](https://code.google.com/p/geo-location-javascript) by [Vincent Bortone](https://github.com/vbortone) * [:link:](googlemaps/google.maps.d.ts) [Google Geolocation](https://developers.google.com/maps) by [Folia A/S](http://www.folia.dk) * [:link:](gapi.pagespeedonline/gapi.pagespeedonline.d.ts) [Google Page Speed Online Api](https://developers.google.com/speed/pagespeed) by [Frank M](https://github.com/sgtfrankieboy) +* [:link:](google.picker/google.picker.d.ts) [Google Picker API](https://developers.google.com/picker) by [grapswiz](https://github.com/grapswiz) * [:link:](recaptcha/recaptcha.d.ts) [Google Recaptcha](https://www.google.com/recaptcha) by [Brent Jenkins](https://github.com/brentj73) * [:link:](gapi.translate/gapi.translate.d.ts) [Google Translate API](https://developers.google.com/translate) by [Frank M](https://github.com/sgtfrankieboy) * [:link:](gapi.urlshortener/gapi.urlshortener.d.ts) [Google Url Shortener API](https://developers.google.com/url-shortener) by [Frank M](https://github.com/sgtfrankieboy) @@ -246,16 +257,25 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](greensock/greensock.d.ts) [GreenSock Animation Platform](http://www.greensock.com/get-started-js) by [Robert S](https://github.com/codebelt) * [:link:](gridfs-stream/gridfs-stream.d.ts) [gridfs-stream](https://github.com/aheckmann/gridfs-stream) by [Lior Mualem](https://github.com/liorm) * [:link:](gruntjs/gruntjs.d.ts) [Grunt 0.4.x](http://gruntjs.com) by [Jeff May](https://github.com/jeffmay), [Basarat Ali Syed](https://github.com/basarat) +* [:link:](gsap/Ease.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) +* [:link:](gsap/Core.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) +* [:link:](gsap/TweenLite.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) * [:link:](gulp/gulp.d.ts) [Gulp v3.8.x](http://gulpjs.com) by [Drew Noakes](https://drewnoakes.com) * [:link:](gulp-autoprefixer/gulp-autoprefixer.d.ts) [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) by [Asana](https://asana.com) +* [:link:](gulp-concat/gulp-concat.d.ts) [gulp-concat](http://github.com/wearefractal/gulp-concat) by [Keita Kagurazaka](https://github.com/k-kagurazaka) +* [:link:](gulp-flatten/gulp-flatten.d.ts) [gulp-flatten](https://github.com/armed/gulp-flatten) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-gh-pages/gulp-gh-pages.d.ts) [gulp-gh-pages](https://github.com/rowoot/gulp-gh-pages) by [Asana](https://asana.com) * [:link:](gulp-if/gulp-if.d.ts) [gulp-if](https://github.com/robrich/gulp-if) by [Asana](https://asana.com) +* [:link:](gulp-inject/gulp-inject.d.ts) [gulp-inject](https://github.com/klei/gulp-inject) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-istanbul/gulp-istanbul.d.ts) [gulp-istanbul](https://github.com/SBoudrias/gulp-istanbul) by [Asana](https://asana.com) +* [:link:](gulp-less/gulp-less.d.ts) [gulp-less](https://github.com/plus3network/gulp-less) by [Keita Kagurazaka](https://github.com/k-kagurazaka) +* [:link:](gulp-minify-css/gulp-minify-css.d.ts) [gulp-minify-css](https://github.com/jonathanepollack/gulp-minify-css) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-mocha/gulp-mocha.d.ts) [gulp-mocha](https://github.com/sindresorhus/gulp-mocha) by [Asana](https://asana.com) * [:link:](gulp-rename/gulp-rename.d.ts) [gulp-rename](https://github.com/hparra/gulp-rename) by [Asana](https://asana.com) * [:link:](gulp-replace/gulp-replace.d.ts) [gulp-replace](https://github.com/lazd/gulp-replace) by [Asana](https://asana.com) * [:link:](gulp-sass/gulp-sass.d.ts) [gulp-sass](https://github.com/dlmanning/gulp-sass) by [Asana](https://asana.com) * [:link:](gulp-sourcemaps/gulp-sourcemaps.d.ts) [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) by [Asana](https://asana.com) +* [:link:](gulp-tsd/gulp-tsd.d.ts) [gulp-tsd](https://github.com/moznion/gulp-tsd) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-tslint/gulp-tslint.d.ts) [gulp-tslint](https://github.com/panuhorsmalahti/gulp-tslint) by [Asana](https://asana.com) * [:link:](gulp-typedoc/gulp-typedoc.d.ts) [gulp-typedoc](https://github.com/rogierschouten/gulp-typedoc) by [Asana](https://asana.com) * [:link:](gulp-typescript/gulp-typescript.d.ts) [gulp-typescript](https://github.com/ivogabe/gulp-typescript) by [Asana](https://asana.com) @@ -289,6 +309,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](interactjs/interact.d.ts) [Interacting for interact.js](https://github.com/taye/interact.js) by [Douglas Eichelberger](https://github.com/dduugg), [Adi Dahiya](https://github.com/adidahiya) * [:link:](intercomjs/intercom.d.ts) [intercom.js](https://github.com/diy/intercom.js) by [spencerwi](http://github.com/spencerwi) * [:link:](cordova-ionic/cordova-ionic.d.ts) [Ionic Cordova plugins](https://github.com/driftyco) by [Hendrik Maus](https://github.com/hendrikmaus) +* [:link:](is_js/is_js.d.ts) [is.js](http://arasatasaygin.github.io/is.js) by [Rodrigo Cabral](https://github.com/cabralRodrigo) * [:link:](iscroll/iscroll.d.ts) [iScroll](http://cubiq.org/iscroll-4) by [Boris Yankov](https://github.com/borisyankov), [Christiaan Rakowski](https://github.com/csrakowski) * [:link:](iscroll/iscroll-5.d.ts) [iScroll 5](http://cubiq.org/iscroll-5-ready-for-beta-test) by [Christiaan Rakowski](https://github.com/csrakowski) * [:link:](iscroll/iscroll-lite.d.ts) [iScroll Lite](http://cubiq.org/iscroll-4) by [Boris Yankov](https://github.com/borisyankov), [Christiaan Rakowski](https://github.com/csrakowski) @@ -302,12 +323,14 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jasmine-jquery/jasmine-jquery.d.ts) [Jasmine-JQuery](https://github.com/velesin/jasmine-jquery) by [Gregor Stamac](https://github.com/gstamac) * [:link:](jasmine-matchers/jasmine-matchers.d.ts) [jasmine-matchers](https://github.com/uxebu/jasmine-matchers) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](java-applet/java-applet.d.ts) [Java Applet](https://www.java.com) by [Cyril Schumacher](https://github.com/cyrilschumacher) +* [:link:](hooker/hooker.d.ts) [JavaScript Hooker](https://github.com/cowboy/javascript-hooker) by [Michael Zabka](https://github.com/misak113) +* [:link:](jbinary/jbinary.d.ts) [jBinary](https://github.com/jDataView/jBinary) by [Tim Bureck](https://github.com/tbureck) * [:link:](jdataview/jdataview.d.ts) [jDataView](https://github.com/jDataView/jDataView) by [Ingvar Stepanyan](https://github.com/RReverser) * [:link:](jest/jest.d.ts) [Jest](http://facebook.github.io/jest) by [Asana](https://asana.com) * [:link:](jjv/jjv.d.ts) [JJV](https://github.com/acornejo/jjv) by [Wim Looman](https://github.com/Nemo157) * [:link:](jjve/jjve.d.ts) [JJVE](https://github.com/silas/jjve) by [Wim Looman](https://github.com/Nemo157) * [:link:](joi/joi.d.ts) [joi](https://github.com/spumko/joi) by [Bart van der Schoor](https://github.com/Bartvds) -* [:link:](jointjs/jointjs.d.ts) [Joint JS](http://www.jointjs.com) by [Aidan Reel](http://github.com/areel), [David Durman](http://github.com/DavidDurman) +* [:link:](jointjs/jointjs.d.ts) [Joint JS](http://www.jointjs.com) by [Aidan Reel](http://github.com/areel), [David Durman](http://github.com/DavidDurman), [Ewout Van Gossum](https://github.com/DenEwout) * [:link:](jqrangeslider/jqrangeslider.d.ts) [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) by [Dániel Tar](https://github.com/qcz) * [:link:](jquery/jquery.d.ts) [jQuery 1.10.x / 2.0.x](http://jquery.com) by [Boris Yankov](https://github.com/borisyankov), [Christian Hoffmeister](https://github.com/choffmeister), [Steve Fenton](https://github.com/Steve-Fenton), [Diullei Gomes](https://github.com/Diullei), [Tass Iliopoulos](https://github.com/tasoili), [Jason Swearingen](https://github.com/jasons-novaleaf), [Sean Hill](https://github.com/seanski), [Guus Goossens](https://github.com/Guuz), [Kelly Summerlin](https://github.com/ksummerlin), [Basarat Ali Syed](https://github.com/basarat), [Nicholas Wolverson](https://github.com/nwolverson), [Derek Cicerone](https://github.com/derekcicerone), [Andrew Gaspar](https://github.com/AndrewGaspar), [James Harrison Fisher](https://github.com/jameshfisher), [Seikichi Kondo](https://github.com/seikichi), [Benjamin Jackman](https://github.com/benjaminjackman), [Poul Sorensen](https://github.com/s093294), [Josh Strobl](https://github.com/JoshStrobl), [John Reilly](https://github.com/johnnyreilly), [Dick van den Brink](https://github.com/DickvdBrink) * [:link:](jquery.blockUI/jquery.blockUI.d.ts) [jQuery BlockUI Plugin](http://malsup.com/jquery/block) by [Jeffrey Lee](http://blog.darkthread.net) @@ -319,6 +342,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jquery.dataTables/jquery.dataTables.d.ts) [JQuery DataTables](http://www.datatables.net) by [Armin Sander](https://github.com/pragmatrix) * [:link:](jquery.fileupload/jquery.fileupload.d.ts) [jQuery File Upload Plugin](https://github.com/blueimp/jQuery-File-Upload) by [Rob Alarcon](https://github.com/rob-alarcon) * [:link:](jquery.joyride/jquery.joyride.d.ts) [jQuery JoyRide Plugin](https://github.com/zurb/joyride) by [Vincent Bortone](https://github.com/vbortone) +* [:link:](jqgrid/jqgrid.d.ts) [jQuery jqgrid Plugin](https://github.com/tonytomov/jqGrid) by [Lokesh Peta](https://github.com/lokeshpeta) * [:link:](jquerymobile/jquerymobile.d.ts) [jQuery Mobile](http://jquerymobile.com) by [Boris Yankov](https://github.com/borisyankov) * [:link:](jquery.notifyBar/jquery.notifyBar.d.ts) [jQuery Notify Bar](http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar) by [Shunsuke Ohtani](https://github.com/zaneli) * [:link:](jquery.base64/jquery.base64.d.ts) [jQuery Plugin - base64 codec](https://github.com/yatt/jquery.base64) by [Shinya Mochizuki](https://github.com/enrapt-mochizuki) @@ -378,6 +402,9 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](js-yaml/js-yaml.d.ts) [js-yaml](https://github.com/nodeca/js-yaml) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](jsbn/jsbn.d.ts) [jsbn](http://www-cs-students.stanford.edu/%7Etjw/jsbn) by [Eugene Chernyshov](https://github.com/Evgenus) * [:link:](jscrollpane/jscrollpane.d.ts) [jScrollPane](http://jscrollpane.kelvinluck.com) by [Dániel Tar](https://github.com/qcz) +* [:link:](js-data/js-data.d.ts) [JSData](https://github.com/js-data/js-data) by [Stefan Steinhart](https://github.com/reppners) +* [:link:](js-data-http/js-data-http.d.ts) [JSData Http Adapter](https://github.com/js-data/js-data-http) by [Stefan Steinhart](https://github.com/reppners) +* [:link:](js-data-angular/js-data-angular.d.ts) [JSDataAngular](https://github.com/js-data/js-data-angular) by [Stefan Steinhart](https://github.com/reppners) * [:link:](jsdeferred/jsdeferred.d.ts) [JSDeferred](https://github.com/cho45/jsdeferred) by [Daisuke Mino](https://github.com/minodisk) * [:link:](jsdom/jsdom.d.ts) [jsdom](https://github.com/tmpvar/jsdom) by [Asana](https://asana.com) * [:link:](jsesc/jsesc.d.ts) [jsesc](https://github.com/mathiasbynens/jsesc) by [Bart van der Schoor](https://github.com/Bartvds) @@ -385,6 +412,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jshamcrest/jshamcrest.d.ts) [JsHamcrest](https://github.com/danielfm/jshamcrest) by [David Harkness](https://github.com/dharkness) * [:link:](hashset/hashset.d.ts) [jshashset](http://www.timdown.co.uk/jshashtable/jshashset.html) by [Sergey Gerasimov](https://github.com/gerich-home) * [:link:](hashtable/hashtable.d.ts) [jshashtable](http://www.timdown.co.uk/jshashtable) by [Sergey Gerasimov](https://github.com/gerich-home) +* [:link:](jsnox/jsnox.d.ts) [JSnoX](https://github.com/af/jsnox) by [Steve Baker](https://github.com/stkb) * [:link:](json-pointer/json-pointer.d.ts) [json-pointer 1.0 l](https://www.npmjs.org/package/json-pointer) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](jsoneditoronline/jsoneditoronline.d.ts) [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) by [Vincent Bortone](https://github.com/vbortone) * [:link:](JSONStream/JSONStream.d.ts) [JSONStream](http://github.com/dominictarr/JSONStream) by [Bart van der Schoor](https://github.com/Bartvds) @@ -412,17 +440,20 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](knockout.postbox/knockout-postbox.d.ts) [knockout-postbox](https://github.com/rniemeyer/knockout-postbox) by [Judah Gabriel Himango](https://debuggerdotbreak.wordpress.com) * [:link:](knockout.projections/knockout.projections.d.ts) [knockout-projections](https://github.com/stevesanderson/knockout-projections) by [John Reilly](https://github.com/johnnyreilly) * [:link:](knockout-secure-binding/knockout-secure-binding.d.ts) [knockout-secure-binding](https://github.com/brianmhunt/knockout-secure-binding) by [Pine Mizune](https://github.com/pine613) +* [:link:](knockout-transformations/knockout-transformations.d.ts) [knockout-transformations](https://github.com/One-com/knockout-transformations) by [John Reilly](https://github.com/johnnyreilly), [Wim Looman](https://github.com/Nemo157) * [:link:](knockout.mapper/knockout.mapper.d.ts) [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) by [Brandon Meyer](https://github.com/BMeyerKC) * [:link:](knockout.mapping/knockout.mapping.d.ts) [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) by [Boris Yankov](https://github.com/borisyankov) * [:link:](knockout.rx/knockout.rx.d.ts) [knockout.rx](https://github.com/Igorbek/knockout.rx) by [Igor Oleinikov](https://github.com/Igorbek) * [:link:](knockstrap/knockstrap.d.ts) [Knockstrap](http://faulknercs.github.io/Knockstrap) by [Adam Pluciński](https://github.com/adaskothebeast) * [:link:](knockout.kogrid/ko-grid.d.ts) [ko-grid](http://knockout-contrib.github.io/KoGrid) by [huer12](https://github.com/huer12) +* [:link:](ko.plus/ko.plus.d.ts) [ko.plus](https://github.com/stevegreatrex/ko.plus) by [Howard Richards](https://github.com/conficient) * [:link:](kolite/kolite.d.ts) [KoLite](https://github.com/CodeSeven/kolite) by [Boris Yankov](https://github.com/borisyankov) * [:link:](kuromoji/kuromoji.d.ts) [kuromoji.js](https://github.com/takuyaa/kuromoji.js) by [MIZUSHIMA Junki](https://github.com/mzsm) * [:link:](ladda/ladda.d.ts) [Ladda](https://github.com/hakimel/Ladda) by [Danil Flores](https://github.com/dflor003), [Michael Lee](https://github.com/leemicw) * [:link:](later/later.d.ts) [LaterJS](http://bunkat.github.io/later) by [Jason D Dryhurst-Smith](http://jasonds.co.uk) * [:link:](lazy.js/lazy.js.d.ts) [Lazy.js](https://github.com/dtao/lazy.js) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](leaflet/leaflet.d.ts) [Leaflet.js](https://github.com/Leaflet/Leaflet) by [Vladimir Zotov](https://github.com/rgripper) +* [:link:](leaflet-label/leaflet-label.d.ts) [Leaflet.label](https://github.com/Leaflet/Leaflet.label) by [Wim Looman](https://github.com/Nemo157) * [:link:](jquery.leanModal/jquery.leanModal.d.ts) [leanModal.js](http://leanmodal.finelysliced.com.au) by [FinelySliced](https://github.com/FinelySliced) * [:link:](leapmotionTS/LeapMotionTS.d.ts) [Leap Motion TS](https://github.com/logotype/LeapMotionTS) by [Victor Norgren](https://github.com/logotype) * [:link:](less/less.d.ts) [LESS](http://lesscss.org) by [AndrewGaspar](https://github.com/AndrewGaspar) @@ -437,18 +468,23 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](log4javascript/log4javascript.d.ts) [log4javascript](http://log4javascript.org) by [Markus Wagner](https://github.com/Ritzlgrmft) * [:link:](log4js/log4js.d.ts) [log4js](https://github.com/nomiddlename/log4js-node) by [Kentaro Okuno](http://github.com/armorik83) * [:link:](logg/logg.d.ts) [logg](https://github.com/dpup/node-logg) by [Bret Little](https://github.com/blittle) +* [:link:](logrotate-stream/logrotate-stream.d.ts) [logrotate-stream](https://github.com/dstokes/logrotate-stream) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](long/long.d.ts) [Long.js](https://github.com/dcodeIO/Long.js) by [Toshihide Hara](https://github.com/kerug) * [:link:](lru-cache/lru-cache.d.ts) [lru-cache](https://github.com/isaacs/node-lru-cache) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](lscache/lscache.d.ts) [lscache](https://github.com/pamelafox/lscache) by [Chris Martinez](https://github.com/Chris-Martinezz) * [:link:](lunr/lunr.d.ts) [lunr.js](https://github.com/olivernn/lunr.js) by [Sebastian Lenz](https://github.com/sebastian-lenz) * [:link:](lz-string/lz-string.d.ts) [lz-string](https://github.com/pieroxy/lz-string) by [Roman Nikitin](https://github.com/M0ns1gn0r) +* [:link:](main-bower-files/main-bower-files.d.ts) [main-bower-files](https://github.com/ck86/main-bower-files) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](mapbox/mapbox.d.ts) [Mapbox](https://www.mapbox.com/mapbox.js) by [Maxime Fabre](https://github.com/anahkiasen) * [:link:](mapsjs/mapsjs.d.ts) [Mapsjs](https://github.com/mapsjs) by [Matthew James Davis](https://github.com/davismj) * [:link:](marionette/marionette.d.ts) [Marionette](https://github.com/marionettejs) by [Zeeshan Hamid](https://github.com/zhamid), [Natan Vivo](https://github.com/nvivo), [Sven Tschui](https://github.com/sventschui) * [:link:](marked/marked.d.ts) [Marked](https://github.com/chjj/marked) by [William Orr](https://github.com/worr) +* [:link:](maskedinput/maskedinput.d.ts) [Masked Input plugin for jQuery](http://digitalbush.com/projects/masked-input-plugin) by [Lokesh Peta](https://github.com/lokeshpeta) * [:link:](mathjax/mathjax.d.ts) [MathJax](https://github.com/mathjax/MathJax) by [Roland Zwaga](https://github.com/rolandzwaga) * [:link:](mCustomScrollbar/mCustomScrollbar.d.ts) [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) by [Sarah Williams](https://github.com/flurg) * [:link:](memory-cache/memory-cache.d.ts) [memory-cache](http://github.com/ptarjan/node-cache) by [Jeff Goddard](https://github.com/jedigo) +* [:link:](merge-stream/merge-stream.d.ts) [merge-stream](https://github.com/grncdr/merge-stream) by [Keita Kagurazaka](https://github.com/k-kagurazaka) +* [:link:](mess/mess.d.ts) [mess](https://github.com/bobrik/node-mess) by [Wim Looman](https://github.com/Nemo157) * [:link:](messenger/messenger.d.ts) [Messenger.js](https://github.com/HubSpot/messenger) by [Derek Cicerone](https://github.com/derekcicerone) * [:link:](meteor/meteor.d.ts) [Meteor](http://www.meteor.com) by [Dave Allen](https://github.com/fullflavedave) * [:link:](method-override/method-override.d.ts) [method-override](https://github.com/expressjs/method-override) by [Santi Albo](https://github.com/santialbo) @@ -499,6 +535,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](needle/needle.d.ts) [needle](https://github.com/tomas/needle) by [San Chen](https://github.com/bigsan) * [:link:](nexpect/nexpect.d.ts) [nexpect](https://github.com/nodejitsu/nexpect) by [vvakame](http://github.com/vvakame) * [:link:](ng-grid/ng-grid.d.ts) [ng-grid](http://angular-ui.github.io/ng-grid) by [Ken Smith](https://github.com/smithkl42), [Roland Zwaga](https://github.com/rolandzwaga), [Kent Cooper](https://github.com/kentcooper) +* [:link:](angular-idle/angular-idle.d.ts) [ng-idle](http://hackedbychinese.github.io/ng-idle) by [mthamil](https://github.com/mthamil) * [:link:](ngprogress/ngprogress.d.ts) [ngProgress](http://victorbjelkholm.github.io/ngProgress) by [Martin McWhorter](https://github.com/martinmcwhorter) * [:link:](ngprogress-lite/ngprogress-lite.d.ts) [ngprogress-lite](https://github.com/voronianski/ngprogress-lite) by [Luke Forder](https://github.com/LukeForder) * [:link:](nightmare/nightmare.d.ts) [Nightmare](https://github.com/segmentio/nightmare) by [horiuchi](https://github.com/horiuchi) @@ -516,6 +553,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](multiparty/multiparty.d.ts) [node-multiparty](https://github.com/andrewrk/node-multiparty) by [Ken Fukuyama](https://github.com/kenfdev) * [:link:](mysql/mysql.d.ts) [node-mysql](https://github.com/felixge/node-mysql) by [William Johnston](https://github.com/wjohnsto) * [:link:](node-persist/node-persist.d.ts) [node-persist](https://github.com/simonlast/node-persist) by [Spencer Williams](http://spencerwi.com) +* [:link:](node-polyglot/node-polyglot.d.ts) [node-polyglot](https://github.com/airbnb/polyglot.js) by [Tim Jackson-Kiely](https://github.com/timjk) * [:link:](promptly/promptly.d.ts) [node-promptly](https://github.com/IndigoUnited/node-promptly) by [Dan Spencer](https://github.com/danrspencer) * [:link:](radius/radius.d.ts) [node-radius](https://github.com/retailnext/node-radius) by [Peter Harris](https://github.com/codeanimal) * [:link:](node-uuid/node-uuid.d.ts) [node-uuid.js](https://github.com/broofa/node-uuid) by [Jeff May](https://github.com/jeffmay) @@ -530,8 +568,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](nodeunit/nodeunit.d.ts) [nodeunit](https://github.com/caolan/nodeunit) by [Jeff Goddard](https://github.com/jedigo) * [:link:](nomnom/nomnom.d.ts) [nomnom](https://github.com/harthur/nomnom) by [Paul Vick](https://github.com/panopticoncentral) * [:link:](nopt/nopt.d.ts) [nopt](https://github.com/npm/nopt) by [jbondc](https://github.com/jbondc) -* [:link:](notifyjs/notifyjs.d.ts) [notify.js](https://github.com/alexgibson/notify.js) by [soundTricker](https://github.com/soundTricker) * [:link:](notify/notify.d.ts) [Notify.js](https://github.com/jpillora/notifyjs) by [Xiaohan Zhang](https://github.com/hellochar) +* [:link:](notifyjs/notifyjs.d.ts) [notify.js](https://github.com/alexgibson/notify.js) by [soundTricker](https://github.com/soundTricker) * [:link:](noVNC/noVNC.d.ts) [noVNC](https://github.com/kanaka/noVNC) by [Ken Smith](https://github.com/smithkl42) * [:link:](npm/npm.d.ts) [npm](https://github.com/npm/npm) by [Maxime LUCE](https://github.com/SomaticIT) * [:link:](nprogress/nprogress.d.ts) [NProgress](https://github.com/rstacruz/nprogress) by [Judah Gabriel Himango](http://debuggerdotbreak.wordpress.com) @@ -575,6 +613,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](power-assert-formatter/power-assert-formatter.d.ts) [power-assert-formatter](https://github.com/twada/power-assert-formatter) by [vvakame](https://github.com/vvakame) * [:link:](precise/precise.d.ts) [precise](https://www.npmjs.org/package/precise) by [Peter Harris](https://github.com/codeanimal) * [:link:](preloadjs/preloadjs.d.ts) [PreloadJS](http://www.createjs.com/#!/PreloadJS) by [Pedro Ferreira](https://bitbucket.org/drk4) +* [:link:](prelude-ls/prelude-ls.d.ts) [prelude.ls](http://www.preludels.com) by [Aya Morisawa](https://github.com/AyaMorisawa) * [:link:](progressjs/progress.d.ts) [ProgressJs](http://usablica.github.io/progress.js) by [Shunsuke Ohtani](https://github.com/zaneli) * [:link:](promise-pool/promise-pool.d.ts) [promise-pool](https://github.com/vilic/promise-pool) by [VILIC VANE](https://github.com/vilic) * [:link:](promises-a-plus/promises-a-plus.d.ts) [promises-a-plus](http://promisesaplus.com) by [Igor Oleinikov](https://github.com/Igorbek) @@ -590,6 +629,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](rabbit.js/rabbit.js.d.ts) [rabbit.js](https://github.com/squaremo/rabbit.js) by [Wonshik Kim](https://github.com/wokim) * [:link:](ractive/ractive.d.ts) [Ractive 0.7.0 edge f22ab8ad0a640591b1c263f57e21d1565cb26bf5](http://ractivejs.org) by [Han Lin Yap](http://yap.nu) * [:link:](raphael/raphael.d.ts) [Raphael](http://raphaeljs.com) by [CheCoxshall](https://github.com/CheCoxshall) +* [:link:](rappid/rappid.d.ts) [Rappid](http://jointjs.com/about-rappid) by [Ewout Van Gossum](https://github.com/DenEwout) * [:link:](ravenjs/ravenjs.d.ts) [Raven.js](https://github.com/getsentry/raven-js) by [Santi Albo](https://github.com/santialbo) * [:link:](react/react.d.ts) [React](http://facebook.github.io/react) by [Asana](https://asana.com) * [:link:](react-router/react-router.d.ts) [React Router](https://github.com/rackt/react-router) by [Yuichi Murata](https://github.com/mrk21) @@ -610,6 +650,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](riotjs/riotjs.d.ts) [riot.js](https://github.com/moot/riotjs) by [vvakame](https://github.com/vvakame) * [:link:](routie/routie.d.ts) [routie](https://github.com/jgallen23/routie) by [Adilson](https://github.com/Adilson) * [:link:](rtree/rtree.d.ts) [rtree](https://github.com/leaflet-extras/RTree) by [Omede Firouz](https://github.com/oefirouz) +* [:link:](run-sequence/run-sequence.d.ts) [run-sequence](https://github.com/OverZealous/run-sequence) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](rx/rx.d.ts) [RxJS](http://rx.codeplex.com) by [gsino](http://www.codeplex.com/site/users/view/gsino), [Igor Oleinikov](https://github.com/Igorbek) * [:link:](rx/rx.aggregates.d.ts) [RxJS-Aggregates](http://rx.codeplex.com) by [Carl de Billy](http://carl.debilly.net), [Igor Oleinikov](https://github.com/Igorbek) * [:link:](rx/rx.all.d.ts) [RxJS-All](http://rx.codeplex.com) by [Carl de Billy](http://carl.debilly.net), [Igor Oleinikov](https://github.com/Igorbek) @@ -637,6 +678,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](sequelize/sequelize.d.ts) [Sequelize 2.0.0 dev13](http://sequelizejs.com) by [samuelneff](https://github.com/samuelneff), [Peter Harris](https://github.com/codeanimal) * [:link:](sharedworker/SharedWorker.d.ts) [SharedWorker](http://www.w3.org/TR/workers) by [Toshiya Nakakura](https://github.com/nakakura) * [:link:](shelljs/shelljs.d.ts) [ShellJS](http://shelljs.org) by [Niklas Mollenhauer](https://github.com/nikeee) +* [:link:](should-promised/should-promised.d.ts) [should-promised](https://github.com/shouldjs/promised) by [Yaroslav Admin](https://github.com/devoto13) * [:link:](should/should.d.ts) [should.js](https://github.com/visionmedia/should.js) by [Alex Varju](https://github.com/varju), [Maxime LUCE](https://github.com/SomaticIT) * [:link:](showdown/showdown.d.ts) [Showdown](https://github.com/coreyti/showdown) by [cbowdon](https://github.com/cbowdon) * [:link:](siesta/siesta.d.ts) [Siesta](http://www.bryntum.com/products/siesta) by [bquarmby](https://github.com/bquarmby) @@ -664,6 +706,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](space-pen/space-pen.d.ts) [SpacePen](https://github.com/atom/space-pen) by [vvakame](https://github.com/vvakame) * [:link:](spectrum/spectrum.d.ts) [spectrum](https://github.com/bgrins/spectrum) by [Mordechai Zuber](https://github.com/M-Zuber) * [:link:](spin/spin.d.ts) [Spin.js](http://fgnass.github.com/spin.js) by [Boris Yankov](https://github.com/borisyankov), [Theodore Brown](https://github.com/theodorejb) +* [:link:](split/split.d.ts) [split](https://github.com/dominictarr/split) by [Marcin Porębski](https://github.com/marcinporebski) * [:link:](sprintf/sprintf.d.ts) [sprintff](https://github.com/maritz/node-sprintff) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](sharepoint/SharePoint.d.ts) [sptypescript](http://sptypescript.codeplex.com) by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru), [Andrey Markeev](http://markeev.com) * [:link:](sqlite3/sqlite3.d.ts) [sqlite3](https://github.com/mapbox/node-sqlite3) by [Nick Malaguti](https://github.com/nmalaguti) @@ -671,6 +714,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](stats/stats.d.ts) [Stats.js r12](http://github.com/mrdoob/stats.js) by [Gregory Dalton](https://github.com/gregolai) * [:link:](status-bar/status-bar.d.ts) [status-bar](https://github.com/atom/status-bar) by [vvakame](https://github.com/vvakame) * [:link:](storejs/storejs.d.ts) [store.js](https://github.com/marcuswestin/store.js) by [Vincent Bortone](https://github.com/vbortone) +* [:link:](stream-series/stream-series.d.ts) [stream-series](https://github.com/rschmukler/stream-series) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](stream-to-array/stream-to-array.d.ts) [stream-to-array](https://github.com/stream-utils/stream-to-array) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](stripe/stripe.d.ts) [stripe](https://stripe.com) by [Eric J. Smith](https://github.com/ejsmith) * [:link:](stylus/stylus.d.ts) [stylus](https://github.com/LearnBoost/stylus) by [Maxime LUCE](https://github.com/SomaticIT) @@ -693,6 +737,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](tedious/tedious.d.ts) [tedious](https://pekim.github.io/tedious) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](tedious-connection-pool/tedious-connection-pool.d.ts) [tedious-connection-pool](https://github.com/pekim/tedious-connection-pool) by [Cyprien Autexier](https://github.com/sandorfr) * [:link:](teechart/teechart.d.ts) [TeeChart](http://www.steema.com) by [Steema Software](https://steema.com) +* [:link:](tether/tether.d.ts) [Tether](http://github.hubspot.com/tether) by [Adi Dahiya](https://github.com/adidahiya) * [:link:](text-buffer/text-buffer.d.ts) [text-buffer](https://github.com/atom/text-buffer) by [vvakame](https://github.com/vvakame) * [:link:](text-encoding/text-encoding.d.ts) [text-encoding](https://github.com/inexorabletash/text-encoding) by [MIZUNE Pine](https://github.com/pine613) * [:link:](threejs/three-canvasrenderer.d.ts) [three.js (CanvasRenderer.js)](https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CanvasRenderer.js) by [Satoru Kimura](https://github.com/gyohk) @@ -763,12 +808,14 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](websocket/websocket.d.ts) [websocket](https://github.com/Worlize/WebSocket-Node) by [Paul Loyd](https://github.com/loyd) * [:link:](when/when.d.ts) [When](https://github.com/cujojs/when) by [Derek Cicerone](https://github.com/derekcicerone), [Wim Looman](https://github.com/Nemo157) * [:link:](which/which.d.ts) [which](https://github.com/isaacs/node-which) by [vvakame](https://github.com/vvakame) +* [:link:](windows-service/windows-service.d.ts) [windows-service](https://bitbucket.org/stephenwvickers/node-windows-service) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](winjs/winjs.d.ts) [WinJS](http://try.buildwinjs.com) by [TypeScript samples](https://www.typescriptlang.org), [Adam Hewitt](https://github.com/adamhewitt627), [Craig Treasure](https://github.com/craigktreasure), [Jeff Fisher](https://github.com/xirzec) * [:link:](winrt/winrt.d.ts) [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) by [TypeScript samples](https://www.typescriptlang.org) * [:link:](winston/winston.d.ts) [winston](https://github.com/flatiron/winston) by [bonnici](https://github.com/bonnici), [Peter Harris](https://github.com/codeanimal) * [:link:](wolfy87-eventemitter/wolfy87-eventemitter.d.ts) [wolfy87-eventemitter](https://github.com/Wolfy87/EventEmitter) by [ryiwamoto](https://github.com/ryiwamoto) * [:link:](wrench/wrench.d.ts) [wrench](https://github.com/ryanmcgrath/wrench-js) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](ws/ws.d.ts) [ws](https://github.com/einaros/ws) by [Paul Loyd](https://github.com/loyd) +* [:link:](x-editable/x-editable.d.ts) [X-Editable](http://vitalets.github.io/x-editable/index.html) by [Chris Kirby](https://github.com/sirkirby) * [:link:](x2js/xml2json.d.ts) [x2js](https://code.google.com/p/x2js) by [Horiuchi_H](https://github.com/horiuchi) * [:link:](jsfl/xJSFL.d.ts) [xJSFL](http://www.xjsfl.com) by [soywiz](https://github.com/soywiz) * [:link:](xpath/xpath.d.ts) [xpath](https://github.com/goto100/xpath) by [Andrew Bradley](https://github.com/cspotcode) @@ -784,6 +831,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](zepto/zepto.d.ts) [Zepto](http://zeptojs.com) by [Josh Baldwin](https://github.com/jbaldwin) * [:link:](zeroclipboard/zeroclipboard.d.ts) [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard) by [Eric J. Smith](https://github.com/ejsmith), [Blake Niemyjski](https://github.com/niemyjski), [György Balássy](https://github.com/balassy) * [:link:](node_zeromq/zmq.d.ts) [ZeroMQ Node](https://github.com/JustinTulloss/zeromq.node) by [Dave McKeown](http://github.com/davemckeown) +* [:link:](zip.js/zip.js.d.ts) [zip.js 2.x](https://github.com/gildas-lormeau/zip.js) by [Louis Grignon](https://github.com/lgrignon) * [:link:](scroller/easyscroller.d.ts) [Zynga EasyScroller](https://github.com/zynga/scroller) by [Boris Yankov](https://github.com/borisyankov) * [:link:](scroller/scroller.d.ts) [Zynga Scroller](https://github.com/zynga/scroller) by [Boris Yankov](https://github.com/borisyankov) * [:link:](viewporter/viewporter.d.ts) [Zynga Viewporter](https://github.com/zynga/viewporter) by [Boris Yankov](https://github.com/borisyankov) diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts index a065d4b21..c683540a3 100644 --- a/angular-hotkeys/angular-hotkeys-tests.ts +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -6,10 +6,13 @@ var hotkeyProvider: ng.hotkeys.HotkeysProvider; var hotkeyObj: ng.hotkeys.Hotkey; hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); +hotkeyProvider.add(["mod+s"], "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); hotkeyProvider.add(hotkeyObj); hotkeyProvider.bindTo(scope); hotkeyProvider.del("mod+s"); +hotkeyProvider.del(["mod+s"]); hotkeyProvider.get("mod+s"); +hotkeyProvider.get(["mod+s"]); hotkeyProvider.toggleCheatSheet(); hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback); @@ -21,5 +24,10 @@ hotkeyProvider.bindTo(scope) combo: 'w', description: 'blah blah', callback: function() {} + }) + .add({ + combo: ['w', 'mod+w'], + description: 'blah blah', + callback: function() {} }); diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index f209fbe08..0c0b9109a 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-hotkeys // Project: https://github.com/chieffancypants/angular-hotkeys -// Definitions by: Jason Zhao +// Definitions by: Jason Zhao , Stefan Steinhart // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -9,32 +9,42 @@ declare module ng.hotkeys { interface HotkeysProvider { template: string; + templateTitle:string; includeCheatSheet: boolean; cheatSheetHotkey: string; cheatSheetDescription: string; - add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): void; + add(combo: string|string[], callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; - add(hotkeyObj: ng.hotkeys.Hotkey): void; + add(combo: string|string[], description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; + + add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey; bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained; - del(combo: string): void; + del(combo: string|string[]): void; - get(combo: string): ng.hotkeys.Hotkey; + del(hotkeyObj: ng.hotkeys.Hotkey): void; + + get(combo: string|string[]): ng.hotkeys.Hotkey; toggleCheatSheet(): void; + + purgeHotkeys(): void; } interface HotkeysProviderChained { - add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained; + add(combo: string|string[], description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained; add(hotkeyObj: ng.hotkeys.Hotkey): HotkeysProviderChained; } interface Hotkey { - combo: string; + combo: string|string[]; description?: string; callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; + action?: string; + allowIn?: Array; + persistent?: boolean; } } diff --git a/angular-idle/angular-idle-tests.ts b/angular-idle/angular-idle-tests.ts new file mode 100644 index 000000000..fc39bf72a --- /dev/null +++ b/angular-idle/angular-idle-tests.ts @@ -0,0 +1,23 @@ +/// + +angular.module('app', ['ngIdle']) + .config(['$keepaliveProvider', '$idleProvider', + ($keepaliveProvider: ng.idle.IKeepAliveProvider, $idleProvider: ng.idle.IIdleProvider) => { + $idleProvider.activeOn('mousemove keydown DOMMouseScroll mousewheel mousedown'); + $idleProvider.idleDuration(5); + $idleProvider.warningDuration(5); + $idleProvider.keepalive(true) + $idleProvider.autoResume(true); + $keepaliveProvider.interval(10); + }]) + .run(['$keepalive', '$idle', ($keepalive: ng.idle.IKeepAliveService, $idle: ng.idle.IIdleService) => { + $idle.watch(); + + if ($idle.running() || $idle.idling()) { + $idle.unwatch(); + } + + $keepalive.start(); + $keepalive.ping(); + $keepalive.stop(); + }]); \ No newline at end of file diff --git a/angular-idle/angular-idle.d.ts b/angular-idle/angular-idle.d.ts new file mode 100644 index 000000000..57ef2380b --- /dev/null +++ b/angular-idle/angular-idle.d.ts @@ -0,0 +1,134 @@ +// Type definitions for ng-idle v0.3.5 +// Project: http://hackedbychinese.github.io/ng-idle/ +// Definitions by: mthamil +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng.idle { + + /** + * Used to configure the $keepalive service. + */ + interface IKeepAliveProvider extends IServiceProvider { + + /** + * If configured, options will be used to issue a request using $http. + * If the value is null, no HTTP request will be issued. + * You can specify a string, which it will assume to be a URL to a simple GET request. + * Otherwise, you can use the same options $http takes. However, cache will always be false. + * + * @param value May be string or object, default is null. + */ + http(value: any): void; + + /** + * This specifies how often the keepalive event is triggered and the + * HTTP request is issued. + * + * @param seconds Integer, default is 5 minutes. Must be greater than 0. + */ + interval(seconds: number): void; + } + + /** + * $keepalive will use a timeout to periodically wake, broadcast a $keepalive event on the root scope, + * and optionally make an $http request. By default, the $idle service will stop and start $keepalive + * when a user becomes idle or returns from idle, respectively. It is also started automatically when + * $idle.watch() is called. This can be disabled by configuring the $idleProvider. + */ + interface IKeepAliveService { + + /** + * Starts pinging periodically until stop() is called. + */ + start(): void; + + /** + * Stops pinging. + */ + stop(): void; + + /** + * Performs one ping only. + */ + ping(): void; + } + + /** + * Used to configure the $idle service. + */ + interface IIdleProvider extends IServiceProvider { + + /** + * Specifies the DOM events the service will watch to reset the idle timeout. + * Multiple events should be separated by a space. + * + * @param events string, default 'mousemove keydown DOMMouseScroll mousewheel mousedown' + */ + activeOn(events: string): void; + + /** + * The idle timeout duration in seconds. After this amount of time passes without the user + * performing an action that triggers one of the watched DOM events, the user is considered + * idle. + * + * @param seconds integer, default is 20min + */ + idleDuration(seconds: number): void; + + /** + * The amount of time the user has to respond (in seconds) before they have been considered + * timed out. + * + * @param seconds integer, default is 30s + */ + warningDuration(seconds: number): void; + + /** + * When true, user activity will automatically interrupt the warning countdown and reset the + * idle state. If false, you will need to manually call watch() when you want to start + * watching for idleness again. + * + * @param enabled boolean, default is true + */ + autoResume(enabled: boolean): void; + + /** + * When true, the $keepalive service is automatically stopped and started as needed. + * + * @param enabled boolean, default is true + */ + keepalive(enabled: boolean): void; + } + + /** + * $idle, once watch() is called, will start a timeout which if expires, will enter a warning state + * countdown. Once the countdown reaches zero, idle will broadcast a timeout event indicating the + * user has timed out (where your app should log them out or whatever you like). If the user performs + * an action that triggers a watched DOM event that bubbles up to document.body, this will reset the + * idle/warning state and start the process over again. + */ + interface IIdleService { + + /** + * Whether or not the watch() has been called and it is watching for idleness. + */ + running(): boolean; + + /** + * Whether or not the user appears to be idle. + */ + idling(): boolean; + + /** + * Starts watching for idleness, or resets the idle/warning state and continues watching. + */ + watch(): void; + + /** + * Stops watching for idleness, and resets the idle/warning state. + */ + unwatch(): void; + } +} \ No newline at end of file diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index a01c93ef5..f649d65f7 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS 1.3 (ngAnimate module) // Project: http://angularjs.org -// Definitions by: Michel Salib , Adi Dahiya +// Definitions by: Michel Salib , Adi Dahiya , Raphael Schweizer // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -25,6 +25,17 @@ declare module ng.animate { */ enabled(value?: boolean, element?: JQuery): boolean; + /** + * Performs an inline animation on the element. + * + * @param element the element that will be the focus of the animation + * @param from a collection of CSS styles that will be applied to the element at the start of the animation + * @param to a collection of CSS styles that the element will animate towards + * @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate') + * @returns the animation callback promise + */ + animate(element: JQuery, from: any, to: any, className?: string): ng.IPromise; + /** * Appends the element to the parentElement element that resides in the document and then runs the enter animation. * diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index d764bec6b..c907bbfe9 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1024,7 +1024,7 @@ declare module ng { // Not garanteed to have, since it's a non-mandatory option //capacity: number; }; - put(key: string, value?: any): void; + put(key: string, value?: T): T; get(key: string): any; remove(key: string): void; removeAll(): void; @@ -1262,7 +1262,7 @@ declare module ng { statusText?: string; } - interface IHttpPromise extends IPromise { + interface IHttpPromise extends IPromise> { success(callback: IHttpPromiseCallback): IHttpPromise; error(callback: IHttpPromiseCallback): IHttpPromise; then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise|TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; @@ -1448,7 +1448,7 @@ declare module ng { controller?: any; controllerAs?: string; bindToController?: boolean; - link?: IDirectiveLinkFn; + link?: IDirectiveLinkFn | IDirectivePrePost; name?: string; priority?: number; replace?: boolean; @@ -1501,7 +1501,7 @@ declare module ng { // see http://docs.angularjs.org/api/ng.$animate /////////////////////////////////////////////////////////////////////// interface IAnimateService { - addClass(element: JQuery, className: string, done?: Function): void; + addClass(element: JQuery, className: string, done?: Function): IPromise; enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; leave(element: JQuery, done?: Function): void; move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; diff --git a/archy/archy-tests.ts b/archy/archy-tests.ts new file mode 100644 index 000000000..b2f62384f --- /dev/null +++ b/archy/archy-tests.ts @@ -0,0 +1,32 @@ +/// + +import archy = require("archy"); + +var opts: archy.Options = { +}; + +var data: archy.Data = { + label: 'beep', + nodes: [ + 'ity', + { + label: 'boop', + nodes: [ + { + label: 'o_O', + nodes: [ + { + label: 'oh', + nodes: ['hello', 'puny'] + }, + 'human' + ] + }, + 'party\ntime!' + ] + } + ] +}; + +var str = archy(data); +console.log(str); diff --git a/archy/archy.d.ts b/archy/archy.d.ts new file mode 100644 index 000000000..3d989a895 --- /dev/null +++ b/archy/archy.d.ts @@ -0,0 +1,21 @@ +// Type definitions for archy +// Project: https://github.com/substack/node-archy +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "archy" { + function archy(obj: archy.Data, prefix?: string, opts?: archy.Options): string; + function archy(obj: string, prefix?: string, opts?: archy.Options): string; + + module archy { + interface Data { + label: string; + nodes?: (Data | string)[]; + } + interface Options { + unicode?: boolean; + } + } + + export = archy; +} diff --git a/async/async-explicit-tests.ts b/async/async-explicit-tests.ts new file mode 100644 index 000000000..10d8f0bd2 --- /dev/null +++ b/async/async-explicit-tests.ts @@ -0,0 +1,44 @@ +/// + +interface StringCallback { (err: Error, result: string): void; } +interface AsyncStringGetter { (callback: StringCallback): void; } + +var taskArray: AsyncStringGetter[] = [ + function (callback) { + setTimeout(function () { + callback(null, 'one'); + }, 200); + }, + function (callback) { + setTimeout(function () { + callback(null, 'two'); + }, 100); + }, +]; + +async.series(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); +async.parallel(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); +async.parallelLimit(taskArray, 3, function (err, results) { console.log(results[0].match(/o/)) }); + + +interface Lookup { [key: string]: T; } +interface NumberCallback { (err: Error, result: number): void; } +interface AsyncNumberGetter { (callback: NumberCallback): void; } + +var taskDict: Lookup = { + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +} + +async.series(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); +async.parallel(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); +async.parallelLimit(taskDict, 3, function(err, results) { console.log(results['one'].toFixed(1)) }); + diff --git a/async/async-explicit-tests.ts.tscparams b/async/async-explicit-tests.ts.tscparams new file mode 100644 index 000000000..3195c46cd --- /dev/null +++ b/async/async-explicit-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny diff --git a/async/async-tests.ts b/async/async-tests.ts index 9a563276a..a6b041b4d 100644 --- a/async/async-tests.ts +++ b/async/async-tests.ts @@ -67,6 +67,17 @@ async.series([ ], function (err, results) { }); +async.series([ + function (callback) { + callback(null, 'one'); + }, + function (callback) { + callback(null, 'two'); + }, +], +function (err, results) { }); + + async.series({ one: function (callback) { setTimeout(function () { @@ -81,6 +92,21 @@ async.series({ }, function (err, results) { }); +async.series({ + one: function (callback) { + setTimeout(function () { + callback(null, 1); + }, 200); + }, + two: function (callback) { + setTimeout(function () { + callback(null, 2); + }, 100); + }, +}, +function (err, results) { }); + + async.parallel([ function (callback) { setTimeout(function () { @@ -95,6 +121,20 @@ async.parallel([ ], function (err, results) { }); +async.parallel([ + function (callback) { + setTimeout(function () { + callback(null, 'one'); + }, 200); + }, + function (callback) { + setTimeout(function () { + callback(null, 'two'); + }, 100); + }, +], +function (err, results) { }); + async.parallel({ one: function (callback) { @@ -110,6 +150,20 @@ async.parallel({ }, function (err, results) { }); +async.parallel({ + one: function (callback) { + setTimeout(function () { + callback(null, 1); + }, 200); + }, + two: function (callback) { + setTimeout(function () { + callback(null, 2); + }, 100); + }, +}, +function (err, results) { }); + var count = 0; @@ -136,7 +190,7 @@ async.waterfall([ ], function (err, result) { }); -var q = async.queue(function (task: any, callback) { +var q = async.queue(function (task: any, callback) { console.log('hello ' + task.name); callback(); }, 2); @@ -189,29 +243,29 @@ q.resume(); q.kill(); // tests for strongly typed tasks -var q2 = async.queue(function (task: string, callback) { +var q2 = async.queue(function (task: string, callback) { console.log('Task: ' + task); callback(); }, 1); q2.push('task1'); -q2.push('task2', function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.push('task2', function (error) { + console.log('Finished tasks'); }); -q2.push(['task3', 'task4', 'task5'], function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.push(['task3', 'task4', 'task5'], function (error) { + console.log('Finished tasks'); }); q2.unshift('task1'); -q2.unshift('task2', function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.unshift('task2', function (error) { + console.log('Finished tasks'); }); -q2.unshift(['task3', 'task4', 'task5'], function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.unshift(['task3', 'task4', 'task5'], function (error) { + console.log('Finished tasks'); }); var filename = ''; diff --git a/async/async.d.ts b/async/async.d.ts index 5f558c384..bb8890ef7 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -3,26 +3,32 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped +interface Dictionary { [key: string]: T; } + interface ErrorCallback { (err?: Error): void; } -interface AsyncResultsCallback { (err: Error, results: T[]): void; } interface AsyncResultCallback { (err: Error, result: T): void; } -interface AsyncTimesCallback { (n: number, callback: AsyncResultsCallback): void; } +interface AsyncResultArrayCallback { (err: Error, results: T[]): void; } +interface AsyncResultObjectCallback { (err: Error, results: Dictionary): void; } +interface AsyncTimesCallback { (n: number, callback: AsyncResultArrayCallback): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } -interface AsyncWorker { (task: T, callback: Function): void; } +interface AsyncWorker { (task: T, callback: ErrorCallback): void; } + +interface AsyncFunction { (callback: AsyncResultCallback): void; } +interface AsyncVoidFunction { (callback: ErrorCallback): void; } interface AsyncQueue { length(): number; concurrency: number; started: boolean; paused: boolean; - push(task: T, callback?: AsyncResultsCallback): void; - push(task: T[], callback?: AsyncResultsCallback): void; - unshift(task: T, callback?: AsyncResultsCallback): void; - unshift(task: T[], callback?: AsyncResultsCallback): void; + push(task: T, callback?: ErrorCallback): void; + push(task: T[], callback?: ErrorCallback): void; + unshift(task: T, callback?: ErrorCallback): void; + unshift(task: T[], callback?: ErrorCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -38,8 +44,8 @@ interface AsyncPriorityQueue { concurrency: number; started: boolean; paused: boolean; - push(task: T, priority: number, callback?: AsyncResultsCallback): void; - push(task: T[], priority: number, callback?: AsyncResultsCallback): void; + push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -56,9 +62,9 @@ interface Async { each(arr: T[], iterator: AsyncIterator, callback: ErrorCallback): void; eachSeries(arr: T[], iterator: AsyncIterator, callback: ErrorCallback): void; eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: ErrorCallback): void; - map(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - mapSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; + map(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + mapSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; filter(arr: T[], iterator: AsyncResultIterator, callback: (results: T[]) => any): any; select(arr: T[], iterator: AsyncResultIterator, callback: (results: T[]) => any): any; filterSeries(arr: T[], iterator: AsyncResultIterator, callback: (results: T[]) => any): any; @@ -70,34 +76,34 @@ interface Async { foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; - detect(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - detectSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - sortBy(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - some(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - any(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; + detect(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + detectSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + sortBy(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + some(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + any(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; every(arr: T[], iterator: AsyncResultIterator, callback: (result: boolean) => any): any; all(arr: T[], iterator: AsyncResultIterator, callback: (result: boolean) => any): any; - concat(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - concatSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; + concat(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + concatSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; // Control Flow - series(tasks: T[], callback?: AsyncResultsCallback): void; - series(tasks: T, callback?: AsyncResultsCallback): void; - parallel(tasks: T[], callback?: AsyncResultsCallback): void; - parallel(tasks: T, callback?: AsyncResultsCallback): void; - parallelLimit(tasks: T[], limit: number, callback?: AsyncResultsCallback): void; - parallelLimit(tasks: T, limit: number, callback?: AsyncResultsCallback): void; - whilst(test: Function, fn: Function, callback: Function): void; - until(test: Function, fn: Function, callback: Function): void; - waterfall(tasks: T[], callback?: AsyncResultsCallback): void; - waterfall(tasks: T, callback?: AsyncResultsCallback): void; + series(tasks: Array>, callback?: AsyncResultArrayCallback): void; + series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; + parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; + parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; + parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; + parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; + whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; + doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; + until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; + doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; + waterfall(tasks: Function[], callback?: AsyncResultArrayCallback): void; queue(worker: AsyncWorker, concurrency: number): AsyncQueue; priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; - // auto(tasks: any[], callback?: AsyncResultsCallback): void; - auto(tasks: any, callback?: AsyncResultsCallback): void; + auto(tasks: any, callback?: AsyncResultArrayCallback): void; iterator(tasks: Function[]): Function; - apply(fn: Function, ...arguments: any[]): void; - nextTick(callback: Function): void; + apply(fn: Function, ...arguments: any[]): AsyncFunction; + nextTick(callback: Function): void; times (n: number, callback: AsyncTimesCallback): void; timesSeries (n: number, callback: AsyncTimesCallback): void; diff --git a/bingmaps/Microsoft.Maps.d.ts b/bingmaps/Microsoft.Maps.d.ts index e01db13b3..238caa359 100644 --- a/bingmaps/Microsoft.Maps.d.ts +++ b/bingmaps/Microsoft.Maps.d.ts @@ -390,11 +390,10 @@ declare module Microsoft.Maps { } export interface PolylineOptions { - - strokeColor: Color; - strokeDashArray: string; - strokeThickness: number; - visible: boolean; + strokeColor?: Color; + strokeDashArray?: string; + strokeThickness?: number; + visible?: boolean; } export class Polygon implements Entity { @@ -422,11 +421,12 @@ declare module Microsoft.Maps { } export interface PolygonOptions { - - strokeColor: Color; - strokeDashArray: string; - strokeThickness: number; - visible: boolean; + fillColor?: Color; + infoBox?: Infobox; + strokeColor?: Color; + strokeDashArray?: string; + strokeThickness?: number; + visible?: boolean; } export class Pushpin implements Entity { @@ -570,4 +570,4 @@ declare module Microsoft.Maps { export function loadModule(moduleKey: string, options: ModuleOptions): void; export function moduleLoaded(moduleKey: string): void; export function registerModule(moduleKey: string, scriptUrl: string, options?: ModuleOptions): void; -} \ No newline at end of file +} diff --git a/bitwise-xor/bitwise-xor-tests.ts b/bitwise-xor/bitwise-xor-tests.ts new file mode 100644 index 000000000..66b67a7b5 --- /dev/null +++ b/bitwise-xor/bitwise-xor-tests.ts @@ -0,0 +1,11 @@ + +/// + +"use strict"; + +import xor = require("bitwise-xor"); + +var b: Buffer; + +b = xor("a", "b"); +b = xor(new Buffer("a"), new Buffer("b")); diff --git a/bitwise-xor/bitwise-xor.d.ts b/bitwise-xor/bitwise-xor.d.ts new file mode 100644 index 000000000..0db872f91 --- /dev/null +++ b/bitwise-xor/bitwise-xor.d.ts @@ -0,0 +1,17 @@ +// Type definitions for bitwise-xor 0.0.0 +// Project: https://github.com/czzarr/node-bitwise-xor +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module "bitwise-xor" { + + /** + * Bitwise XOR between two Buffers or Strings, returns a Buffer + */ + function xor(b1: Buffer, b2: Buffer): Buffer; + function xor(s1: string, s2: string): Buffer; + + export = xor; +} + diff --git a/breeze/breeze-tests.ts b/breeze/breeze-tests.ts index 2510ce9ca..979bc5683 100644 --- a/breeze/breeze-tests.ts +++ b/breeze/breeze-tests.ts @@ -405,6 +405,11 @@ function test_entityQuery() { .where("toUpper(substring(CompanyName, 1, 2))", breeze.FilterQueryOp.Equals, "OM"); var q2 = query.toType("foo").orderBy("foo2"); + var pred = new breeze.Predicate('items', 'any', 'serialNumber', 'contains', '12345'); + var pred = new breeze.Predicate('items', breeze.FilterQueryOp.Any, 'serialNumber', breeze.FilterQueryOp.Contains, '12345'); + var pred = breeze.Predicate.create('items', 'any', 'serialNumber', 'contains', '12345'); + var pred = breeze.Predicate.create('items', breeze.FilterQueryOp.Any, 'serialNumber', breeze.FilterQueryOp.Contains, '12345'); + var json = query.toJSON(); } diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 7887dbbf0..4821ed427 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Breeze 1.4 +// Type definitions for Breeze 1.5.x // Project: http://www.breezejs.com/ // Definitions by: Boris Yankov , IdeaBlade // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -10,6 +10,7 @@ // Updated Aug 22 2014 for Breeze 1.4.17 and removing Q dependency - Steve Schmitt ( www.ideablade.com) // Updated Jan 16 2015 for Breeze 1.4.17 to add support for noimplicitany - Kevin Wilson ( www.kwilson.me.uk ) // Updated Jan 20 2015 for Breeze 1.5.2 and merging changes from DefinitelyTyped +// Updated Feb 28 2015 add any/all clause on Predicate declare module breeze.core { @@ -770,6 +771,8 @@ declare module breeze { constructor(property: string, operator: FilterQueryOpSymbol, value: any); constructor(property: string, operator: string, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType }); constructor(property: string, operator: FilterQueryOpSymbol, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType }); + constructor(property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any); // for any/all clauses + constructor(property: string, filterop: string, property2: string, filterop2: string, value: any); // for any/all clauses /** Create predicate from an expression tree */ constructor(tree: Object); @@ -798,6 +801,8 @@ declare module breeze { (...predicates: Predicate[]): Predicate; (property: string, operator: string, value: any, valueIsLiteral?: boolean): Predicate; (property: string, operator: FilterQueryOpSymbol, value: any, valueIsLiteral?: boolean): Predicate; + (property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any): Predicate; // for any/all clauses + (property: string, filterop: string, property2: string, filterop2: string, value: any): Predicate; // for any/all clauses } class QueryOptions { diff --git a/bunyan-prettystream/bunyan-prettystream-tests.ts b/bunyan-prettystream/bunyan-prettystream-tests.ts new file mode 100644 index 000000000..3dd7b15a3 --- /dev/null +++ b/bunyan-prettystream/bunyan-prettystream-tests.ts @@ -0,0 +1,4 @@ +/// + +import PrettyStream = require("bunyan-prettystream"); +var stream = new PrettyStream(); diff --git a/bunyan-prettystream/bunyan-prettystream.d.ts b/bunyan-prettystream/bunyan-prettystream.d.ts new file mode 100644 index 000000000..9f9fa4f57 --- /dev/null +++ b/bunyan-prettystream/bunyan-prettystream.d.ts @@ -0,0 +1,14 @@ +// Type definitions for bunyan-prettystream +// Project: https://www.npmjs.com/package/bunyan-prettystream +// Definitions by: Jason Swearingen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "bunyan-prettystream" { + import stream = require("stream"); + class PrettyStream extends stream.Writable { + public pipe(destination: T, options?: { end?: boolean; }): T; + } + export = PrettyStream; +} \ No newline at end of file diff --git a/byline/byline.d.ts b/byline/byline.d.ts index 6dac6ad50..475386b28 100644 --- a/byline/byline.d.ts +++ b/byline/byline.d.ts @@ -9,7 +9,7 @@ declare module "byline" { import stream = require("stream"); export interface LineStreamOptions extends stream.TransformOptions { - keepEmptyLines: boolean; + keepEmptyLines?: boolean; } export interface LineStream extends stream.Transform { @@ -35,4 +35,4 @@ declare module "byline" { export function createStream(stream:NodeJS.ReadableStream, options?:LineStreamOptions):LineStream; export var LineStream:LineStreamCreatable; -} \ No newline at end of file +} diff --git a/chance/chance-tests.ts b/chance/chance-tests.ts new file mode 100644 index 000000000..5a2aa9a9c --- /dev/null +++ b/chance/chance-tests.ts @@ -0,0 +1,36 @@ +/// + +// Instantiation +var globalInstance: Chance.Chance = chance; +var createYourOwn = new Chance(Math.random); + +// Basic usage +var randBool: boolean = chance.bool(); + +var birthday: Date = chance.birthday(); +var birthdayStr: Date|string = chance.birthday({ string: true }); + +var strArr: string[] = chance.n(chance.string, 42); + +var uniqInts: number[] = chance.unique(chance.integer, 99); + +var currencyPair = chance.currency_pair(); +var firstCurrency = currencyPair[0]; +var secondCurrency = currencyPair[1]; + +// Mixins can be used with on-the-fly type declaration +declare module Chance { + interface Chance { + time(): string; + } +} + +chance.mixin({ + time: function () { + var h = chance.hour({ twentyfour: true }), + m = chance.minute(); + return `${h}:${m}`; + } +}); + +var timeString: string = chance.time(); diff --git a/chance/chance.d.ts b/chance/chance.d.ts new file mode 100644 index 000000000..2af960efe --- /dev/null +++ b/chance/chance.d.ts @@ -0,0 +1,213 @@ +// Type definitions for Chance 0.7.3 +// Project: http://chancejs.com +// Definitions by: Chris Bowdon +// Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module Chance { + + interface ChanceStatic { + Chance(): Chance; + new(): Chance; + new(seed: number): Chance; + new(generator: () => any): Chance; + } + + interface Chance { + + // Basics + bool(opts?: Options): boolean; + character(opts?: Options): string; + floating(opts?: Options): number; + integer(opts?: Options): number; + natural(opts?: Options): number; + string(opts?: Options): string; + + // Text + paragraph(opts?: Options): string; + sentence(opts?: Options): string; + syllable(opts?: Options): string; + word(opts?: Options): string; + + // Person + age(opts?: Options): number; + birthday(): Date; + birthday(opts?: Options): Date|string; + cpf(): string; + first(opts?: Options): string; + last(opts?: Options): string; + name(opts?: Options): string; + name_prefix(opts?: Options): string; + name_suffix(opts?: Options): string; + prefix(opts?: Options): string; + ssn(opts?: Options): string; + suffix(opts?: Options): string; + + // Mobile + android_id(): string; + apple_token(): string; + bb_pin(): string; + wp7_anid(): string; + wp8_anid2(): string; + + // Web + color(opts?: Options): string; + domain(opts?: Options): string; + email(opts?: Options): string; + fbid(): string; + google_analytics(): string; + hashtag(): string; + ip(): string; + ipv6(): string; + klout(): string; + tld(): string; + twitter(): string; + url(opts?: Options): string; + + // Location + address(opts?: Options): string; + altitude(opts?: Options): number; + areacode(): string; + city(): string; + coordinates(opts?: Options): string; + country(opts?: Options): string; + depth(opts?: Options): number; + geohash(opts?: Options): string; + latitude(opts?: Options): number; + longitude(opts?: Options): number; + phone(opts?: Options): string; + postal(): string; + province(opts?: Options): string; + state(opts?: Options): string; + street(opts?: Options): string; + zip(opts?: Options): string; + + // Time + ampm(): string; + date(): Date; + date(opts: DateOptions): Date|string; + hammertime(): number; + hour(opts?: Options): number; + millisecond(): number; + minute(): number; + month(): string; + month(opts: Options): Month; + second(): number; + timestamp(): number; + year(opts?: Options): string; + + // Finance + cc(opts?: Options): string; + cc_type(): string; + cc_type(opts: Options): string|CreditCardType; + currency(): Currency; + currency_pair(): [ Currency, Currency ]; + dollar(opts?: Options): string; + exp(): string; + exp(opts: Options): string|CreditCardExpiration; + exp_month(opts?: Options): string; + exp_year(opts?: Options): string; + + // Helpers + capitalize(str: string): string; + mixin(desc: MixinDescriptor): any; + pad(num: number, width: number, padChar?: string): string; + pick(arr: T[]): T; + pick(arr: T[], count: number): T[]; + set: Setter; + shuffle(arr: T[]): T[]; + + // Miscellaneous + d4(): number; + d6(): number; + d8(): number; + d10(): number; + d12(): number; + d20(): number; + d30(): number; + d100(): number; + guid(): string; + hash(opts?: Options): string; + n(generator: () => T, count: number, opts?: Options): T[]; + normal(opts?: Options): string; + radio(opts?: Options): string; + rpg(dice: string): number[]; + rpg(dice: string, opts?: Options): number[]|number; + tv(opts?: Options): string; + unique(generator: () => T, count: number, opts?: Options): T[]; + weighted(values: T[], weights: number[]): T; + + // "Hidden" + cc_types(): CreditCardType[]; + mersenne_twister(seed?: number): any; // API return type not defined in docs + months(): Month[]; + name_prefixes(): Name[]; + provinces(): Name[]; + states(): Name[]; + street_suffix(): Name; + street_suffixes(): Name[]; + } + + // A more rigorous approach might be to produce + // the correct options interfaces for each method + interface Options { [id: string]: any; } + + interface DateOptions { + string?: boolean; + american?: boolean; + year?: number; + month?: number; + day?: number; + } + + interface Month { + name: string; + short_name: string; + numeric: string; + } + + interface CreditCardType { + name: string; + short_name: string; + prefix: string; + length: number; + } + + interface Currency { + code: string; + name: string; + } + + interface CreditCardExpiration { + month: string; + year: string; + } + + interface MixinDescriptor { [id: string]: () => any; } + + interface Setter { + (key: 'firstNames', values: string[]): any; + (key: 'lastNames', values: string[]): any; + (key: 'provinces', values: string[]): any; + (key: 'us_states_and_dc', values: string[]): any; + (key: 'territories', values: string[]): any; + (key: 'armed_forces', values: string[]): any; + (key: 'street_suffixes', values: string[]): any; + (key: 'months', values: string[]): any; + (key: 'cc_types', values: string[]): any; + (key: 'currency_types', values: string[]): any; + (key: string, values: T[]): any; + } + + interface Name { + name: string; + abbreviation: string; + } +} + +// window.chance +declare var chance: Chance.Chance; +declare var Chance: Chance.ChanceStatic; + +// import Chance = require('chance'); +declare module 'chance' { + export = Chance; +} diff --git a/chokidar/chokidar-tests.ts b/chokidar/chokidar-tests.ts new file mode 100644 index 000000000..b89dd81a0 --- /dev/null +++ b/chokidar/chokidar-tests.ts @@ -0,0 +1,41 @@ +/// + +import fs = require('fs'); +import chokidar = require('chokidar'); + +var watcher = chokidar.watch('file, dir, or glob', { + ignored: /[\/\\]\./, persistent: true +}); + +var log = console.log.bind(console); + +watcher + .on('add', function(path:string) { log('File', path, 'has been added'); }) + .on('addDir', function(path:string) { log('Directory', path, 'has been added'); }) + .on('change', function(path:string) { log('File', path, 'has been changed'); }) + .on('unlink', function(path:string) { log('File', path, 'has been removed'); }) + .on('unlinkDir', function(path:string) { log('Directory', path, 'has been removed'); }) + .on('error', function(error:any) { log('Error happened', error); }) + .on('ready', function() { log('Initial scan complete. Ready for changes.'); }) + .on('raw', function(event:Event, path:string, details:any) { log('Raw event info:', event, path, details); }) + +// 'add', 'addDir' and 'change' events also receive stat() results as second +// argument when available: http://nodejs.org/api/fs.html#fs_class_fs_stats +watcher.on('change', function(path:string, stats:fs.Stats) { + if (stats) console.log('File', path, 'changed size to', stats.size); +}); + +// Watch new files. +watcher.add('new-file'); +watcher.add(['new-file-2', 'new-file-3', '**/other-file*']); + +// Un-watch some files. +watcher.unwatch('new-file*'); + +// Only needed if watching is `persistent: true`. +watcher.close(); + +// One-liner +require('chokidar').watch('.', {ignored: /[\/\\]\./}).on('all', function(event:string, path:string) { + console.log(event, path); +}); \ No newline at end of file diff --git a/chokidar/chokidar.d.ts b/chokidar/chokidar.d.ts new file mode 100644 index 000000000..6a417ca72 --- /dev/null +++ b/chokidar/chokidar.d.ts @@ -0,0 +1,42 @@ +// Type definitions for chokidar 1.0.0 +// Project: https://github.com/paulmillr/chokidar +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "fs" +{ + interface FSWatcher + { + add(fileDirOrGlob:string):void; + add(filesDirsOrGlobs:Array):void; + unwatch(fileDirOrGlob:string):void; + unwatch(filesDirsOrGlobs:Array):void; + } +} + +declare module "chokidar" +{ + interface WatchOptions + { + persistent?:boolean; + ignored?:any; + ignoreInitial?:boolean; + followSymlinks?:boolean; + cwd?:string; + usePolling?:boolean; + useFsEvents?:boolean; + alwaysStat?:boolean; + depth?:number; + interval?:number; + binaryInterval?:number; + ignorePermissionErrors?:boolean; + atomic?:boolean; + } + + import fs = require("fs"); + + function watch( fileDirOrGlob:string, options?:WatchOptions ):fs.FSWatcher; + function watch( filesDirsOrGlobs:Array, options?:WatchOptions ):fs.FSWatcher; +} diff --git a/chrome/chrome-cast.ts b/chrome/chrome-cast.ts new file mode 100644 index 000000000..71a530542 --- /dev/null +++ b/chrome/chrome-cast.ts @@ -0,0 +1,1033 @@ +// Type definitions for Chrome Cast application development +// Project: https://developers.google.com/cast/ +// Definitions by: Thomas Stig Jacobsen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//////////////////// +// Cast +// @see https://code.google.com/p/chromium/codesearch#chromium/src/ui/file_manager/externs/chrome_cast.js +//////////////////// +declare module chrome.cast { + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.AutoJoinPolicy + */ + interface AutoJoinPolicy { + TAB_AND_ORIGIN_SCOPED: string; + ORIGIN_SCOPED: string; + PAGE_SCOPED: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.DefaultActionPolicy + */ + interface DefaultActionPolicy { + CREATE_SESSION: string; + CAST_THIS_TAB: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Capability + */ + interface Capability { + VIDEO_OUT: string; + AUDIO_OUT: string; + VIDEO_IN: string; + AUDIO_IN: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ErrorCode + */ + interface ErrorCode { + CANCEL: string; + TIMEOUT: string; + API_NOT_INITIALIZED: string; + INVALID_PARAMETER: string; + EXTENSION_NOT_COMPATIBLE: string; + EXTENSION_MISSING: string; + RECEIVER_UNAVAILABLE: string; + SESSION_ERROR: string; + CHANNEL_ERROR: string; + LOAD_MEDIA_FAILED: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverAvailability + */ + interface ReceiverAvailability { + AVAILABLE: string; + UNAVAILABLE: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SenderPlatform + */ + interface SenderPlatform { + CHROME: string; + IOS: string; + ANDROID: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverType + */ + interface ReceiverType { + CAST: string; + HANGOUT: string; + CUSTOM: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverAction + */ + interface ReceiverAction { + CAST: string; + STOP: string; + } + + + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionStatus + */ + interface SessionStatus { + CONNECTED: string; + DISCONNECTED: string; + STOPPED: string; + } + + /** + * @const {!Array.} + * @see https://developers.google.com/cast/docs/reference/chrome/ + */ + var VERSION: Array; + + /** + * @type {boolean} + */ + var isAvailable: boolean; + + /** + * @param {!chrome.cast.ApiConfig} apiConfig + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + export function initialize( + apiConfig: chrome.cast.ApiConfig, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void; + + /** + * @param {function(!chrome.cast.Session)} successCallback + * @param {function(chrome.cast.Error)} errorCallback + * @param {chrome.cast.SessionRequest=} opt_sessionRequest + * @param {string=} opt_label + */ + export function requestSession( + successCallback: (session: chrome.cast.Session) => void, + errorCallback: (error: chrome.cast.Error) => void, + sessionRequest?: chrome.cast.SessionRequest, + label?: string + ): void + + /** + * @param {string} sessionId The id of the session to join. + */ + export function requestSessionById( + sessionId: string + ): void + + /** + * @param {chrome.cast.ReceiverActionListener} listener + */ + export function addReceiverActionListener( + listener: (receiver: chrome.cast.Receiver, receiverAction: chrome.cast.ReceiverAction) => void + ): void + + /** + * @param {chrome.cast.ReceiverActionListener} listener + */ + export function removeReceiverActionListener( + listener: (receiver: chrome.cast.Receiver, receiverAction: chrome.cast.ReceiverAction) => void + ): void + + /** + * @param {string} message The message to log. + */ + export function logMessage( + message: string + ): void + + /** + * @param {!Array.} receivers + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + export function setCustomReceivers( + receivers: Array, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.Receiver} receiver + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + export function setReceiverDisplayStatus( + receiver: chrome.cast.Receiver, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + interface ApiConfig { + /** + * @param {!chrome.cast.SessionRequest} sessionRequest + * @param {function(!chrome.cast.Session)} sessionListener + * @param {function(!chrome.cast.ReceiverAvailability,Array.)} + * receiverListener + * @param {chrome.cast.AutoJoinPolicy=} opt_autoJoinPolicy + * @param {chrome.cast.DefaultActionPolicy=} opt_defaultActionPolicy + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ApiConfig + */ + new( + sessionRequest: chrome.cast.SessionRequest, + sessionListener: (session: chrome.cast.Session) => void, + receiverListener: (receiverAvailability: chrome.cast.ReceiverAvailability) => void, + autoJoinPolicy?: chrome.cast.AutoJoinPolicy, + defaultActionPolicy: chrome.cast.DefaultActionPolicy + ); + + sessionRequest: chrome.cast.SessionRequest; + sessionListener: (session: chrome.cast.Session) => void; + receiverListener: (receiverAvailability: chrome.cast.ReceiverAvailability) => void; + autoJoinPolicy?: chrome.cast.AutoJoinPolicy; + defaultActionPolicy: chrome.cast.DefaultActionPolicy; + } + + /** + * @param {!chrome.cast.ErrorCode} code + * @param {string=} opt_description + * @param {Object=} opt_details + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Error + */ + interface Error { + new( + code: chrome.cast.ErrorCode, + description?: string, + details?: Object + ); + + code: chrome.cast.ErrorCode; + description?: string; + details?: string; + + } + + interface Image { + /** + * @param {string} url + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Image + */ + new( + url: string + ); + + url: string; + height?: number; + width?: number; + } + + interface SenderApplication { + + new( + platform: chrome.cast.SenderPlatform + ); + + platform: chrome.cast.SenderPlatform; + url?: string; + packageId?: string; + } + + interface SessionRequest { + /** + * @param {string} appId + * @param {!Array.=} opt_capabilities + * @param {number=} opt_timeout + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest + */ + new( + appId: string, + capabilities?: Array, + timeout?: number + ); + + appId: string; + capabilities: Array; + requestSessionTimeout: number; + language?: string; + } + + interface Session { + /** + * @param {string} sessionId + * @param {string} appId + * @param {string} displayName + * @param {!Array.} appImages + * @param {!chrome.cast.Receiver} receiver + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session + */ + new( + sessionId: string, + appId: string, + displayName: string, + appImages: Array, + receiver: chrome.cast.Receiver + ); + + sessionId: string; + appId: string; + displayName: string; + appImages: Array; + receiver: chrome.cast.Receiver; + senderApps: Array; + namespaces: Array<{name: string}>; + media: Array; + status: chrome.cast.SessionStatus + + /** + * @param {number} newLevel + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + setReceiverVolumeLevel( + newLevel: number, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {boolean} muted + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + setReceiverMuted( + muted: boolean, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + leave( + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + stop( + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {string} namespace + * @param {!Object|string} message + * @param {!function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + sendMessage( + namespace: string, + message: string, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {function(boolean)} listener + */ + addUpdateListener( + listener: (boolean) => void + ) + + /** + * @param {function(boolean)} listener + */ + removeUpdateListener( + listener: (boolean) => void + ) + + /** + * @param {string} namespace + * @param {function(string,string)} listener + */ + addMessageListener( + namespace: string, + listener: (string, string) => void + ) + + /** + * @param {string} namespace + * @param {function(string,string)} listener + */ + removeMessageListener( + namespace: string, + listener: (string, string) => void + ) + + /** + * @param {function(!chrome.cast.media.Media)} listener + */ + addMediaListener( + listener: (media: chrome.cast.media.Media) => void + ) + + /** + * @param {function(!chrome.cast.media.Media)} listener + */ + removeMediaListener( + listener: (media: chrome.cast.media.Media) => void + ) + + /** + * @param {!chrome.cast.media.LoadRequest} loadRequest + * @param {function(!chrome.cast.media.Media)} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + loadMedia( + loadRequest: chrome.cast.media.LoadRequest, + successCallback: (media: chrome.cast.media.Media) => void, + errorCallback: (error: chrome.cast.Error) => void + ) + } + + interface Receiver { + /** + * @param {string} label + * @param {string} friendlyName + * @param {Array.=} opt_capabilities + * @param {chrome.cast.Volume=} opt_volume + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Receiver + */ + new( + label: string, + friendlyName: string, + capabilities?: Array, + volume?: chrome.cast.Volume + ); + + label: string; + friendlyName: string; + capabilities: Array; + volume: chrome.cast.Volume; + receiverType: chrome.cast.ReceiverType; + displayStatus: chrome.cast.ReceiverDisplayStatus; + } + + interface ReceiverDisplayStatus { + /** + * @param {string} statusText + * @param {!Array.} appImages + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverDisplayStatus + */ + new( + statusText: string, + appImages: Array + ); + + statusText: string; + appImages: Array; + } + + interface Volume { + /** + * @param {?number=} opt_level + * @param {?boolean=} opt_muted + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Volume + */ + new( + level?: number, + muted?: boolean + ); + + level?: number; + muted?: boolean; + } +} + +declare module chrome.cast.media { + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MediaCommand + */ + interface MediaCommand { + PAUSE: string; + SEEK: string; + STREAM_VOLUME: string; + STREAM_MUTE: string; + } + + /** + * @enum {number} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MetadataType + */ + interface MetadataType { + GENERIC: number; + TV_SHOW: number; + MOVIE: number; + MUSIC_TRACK: number; + PHOTO: number; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PlayerState + */ + interface PlayerState { + IDLE: string; + PLAYING: string; + PAUSED: string; + BUFFERING: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.ResumeState + */ + interface ResumeState { + PLAYBACK_START: string; + PLAYBACK_PAUSE: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.StreamType + */ + interface StreamType { + BUFFERED: string; + LIVE: string; + OTHER: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.IdleReason + */ + interface IdleReason { + CANCELLED: string; + INTERRUPTED: string; + FINISHED: string; + ERROR: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TrackType + */ + interface TrackType { + TEXT: string; + AUDIO: string; + VIDEO: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackType + */ + interface TextTrackType { + SUBTITLES: string; + CAPTIONS: string; + DESCRIPTIONS: string; + CHAPTERS: string; + METADATA: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackEdgeType + */ + interface TextTrackEdgeType { + NONE: string; + OUTLINE: string; + DROP_SHADOW: string; + RAISED: string; + DEPRESSED: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackWindowType + */ + interface TextTrackWindowType { + NONE: string; + NORMAL: string; + ROUNDED_CORNERS: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackFontGenericFamily + */ + interface TextTrackFontGenericFamily { + SANS_SERIF: string; + MONOSPACED_SANS_SERIF: string; + SERIF: string; + MONOSPACED_SERIF: string; + CASUAL: string; + CURSIVE: string; + SMALL_CAPITALS: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackFontStyle + */ + interface TextTrackFontStyle { + NORMAL: string; + BOLD: string; + BOLD_ITALIC: string; + ITALIC: string; + } + + interface GetStatusRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.GetStatusRequest + */ + new(); + + customData: Object; + } + + interface PauseRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PauseRequest + */ + new(); + + customData: Object; + } + + interface PlayRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PlayRequest + */ + new(); + + customData: Object; + } + + interface SeekRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.SeekRequest + */ + new(); + + currentTime: number; + resumeState: chrome.cast.media.ResumeState; + customData: Object; + } + + interface StopRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.StopRequest + */ + new(); + + customData: Object; + } + + interface VolumeRequest { + /** + * @param {!chrome.cast.Volume} volume + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.VolumeRequest + */ + new( + volume: chrome.cast.Volume + ); + + volume: chrome.cast.Volume; + customData: Object; + } + + interface LoadRequest { + /** + * @param {!chrome.cast.media.MediaInfo} mediaInfo + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.LoadRequest + */ + new( + mediaInfo: chrome.cast.media.MediaInfo + ); + + activeTrackIds: Array; + autoplay: boolean; + currentTime: number; + customData: Object; + media: chrome.cast.media.MediaInfo; + } + + interface EditTracksInfoRequest { + /** + * @param {Array.=} opt_activeTrackIds + * @param {chrome.cast.media.TextTrackStyle=} opt_textTrackStyle + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.EditTracksInfoRequest + */ + new( + activeTrackIds?: Array, + textTrackStyle?: chrome.cast.media.TextTrackStyle + ); + + activeTrackIds: Array; + textTrackStyle: chrome.cast.media.TextTrackStyle; + } + + interface GenericMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.GenericMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + title: string; + subtitle: string; + images: Array; + releaseDate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + releaseYear: number; + } + + interface MovieMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MovieMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + title: string; + studio: string; + subtitle: string; + images: Array; + releaseDate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + releaseYear: number; + } + + interface TvShowMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TvShowMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + seriesTitle: string; + title: string; + season: number; + episode: number; + images: Array; + originalAirdate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + episodeTitle: string; + seasonNumber: number; + episodeNumber: number; + releaseYear: number; + } + + interface MusicTrackMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MusicTrackMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + albumName: string; + title: string; + albumArtist: string; + artist: string; + composer: string; + songName: string; + trackNumber: number; + discNumber: number; + images: Array; + releaseDate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + artistName: string; + releaseYear: number; + } + + interface PhotoMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PhotoMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + title: string; + artist: string; + location: string; + images: Array; + latitude: number; + longitude: number; + width: number; + height: number; + creationDateTime: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + } + + interface MediaInfo { + /** + * @param {string} contentId + * @param {string} contentType + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MediaInfo + */ + new( + contentId: string, + contentType: string + ); + + contentId: string; + streamType: chrome.cast.media.StreamType; + contentType: string; + metadata: Object; + duration: number; + tracks: Array; + textTrackStyle: chrome.cast.media.TextTrackStyle; + customData: Object; + } + + interface Media { + /** + * @param {string} sessionId + * @param {number} mediaSessionId + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media + */ + new( + sessionId: string, + mediaSessionId: number + ); + + sessionId: string; + mediaSessionId: number; + media: chrome.cast.media.MediaInfo; + playbackRate: number; + playerState: chrome.cast.media.PlayerState; + supportedMediaCommands: Array; + volume: chrome.cast.Volume; + idleReason: chrome.cast.media.IdleReason; + activeTrackIds: Array; + customData: Object; + + // Deprecated + currentTime: number; + + /** + * @param {chrome.cast.media.GetStatusRequest} getStatusRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + getStatus( + getStatusRequest: chrome.cast.media.GetStatusRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {chrome.cast.media.PlayRequest} playRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + play( + playRequest: chrome.cast.media.PlayRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {chrome.cast.media.PauseRequest} pauseRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + pause( + pauseRequest: chrome.cast.media.PauseRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.SeekRequest} seekRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + seek( + seekRequest: chrome.cast.media.SeekRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {chrome.cast.media.StopRequest} stopRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + stop( + stopRequest: chrome.cast.media.StopRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.VolumeRequest} volumeRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + setVolume( + volumeRequest: chrome.cast.media.VolumeRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.EditTracksInfoRequest} editTracksInfoRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + editTracksInfo( + editTracksInfoRequest: chrome.cast.media.EditTracksInfoRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.MediaCommand} command + * @return {boolean} + */ + supportsCommand( + command: chrome.cast.media.MediaCommand + ): boolean + + /** + * @param {function(boolean)} listener + */ + addUpdateListener( + listener: (boolean) => void + ) + + /** + * @param {function(boolean)} listener + */ + removeUpdateListener( + listener: (boolean) => void + ) + + // Deprecated + /** + * @return {number} + * @suppress {deprecated} Uses currentTime member to compute estimated time. + */ + getEstimatedTime(): number + } + + interface Track { + /** + * @param {number} trackId + * @param {!chrome.cast.media.TrackType} trackType + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Track + */ + new( + trackId: number, + trackType: chrome.cast.media.TrackType + ); + + trackId: number; + trackContentId: string; + trackContentType: string; + type: chrome.cast.media.TrackType; + name: string; + language: string; + subtype: chrome.cast.media.TextTrackType; + customData: Object; + } + + interface TextTrackStyle { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackStyle + */ + new(); + + foregroundColor: string; + backgroundColor: string; + edgeType: chrome.cast.media.TextTrackEdgeType; + edgeColor: string; + windowType: chrome.cast.media.TextTrackWindowType; + windowColor: string; + windowRoundedCornerRadius: number; + fontScale: number; + fontFamily: string; + fontGenericFamily: chrome.cast.media.TextTrackFontGenericFamily; + fontStyle: chrome.cast.media.TextTrackFontStyle; + customData: Object; + } +} + +/** + * @namespace + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.timeout + */ +declare module chrome.cast.media.timeout { + var load: number; + var getStatus: number; + var play: number; + var pause: number; + var seek: number; + var stop: number; + var setVolume: number; + var editTracksInfo: number; +} \ No newline at end of file diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index b3b994930..bc0d52227 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -5,6 +5,13 @@ /// +//////////////////// +// Global object +//////////////////// +interface Window { + chrome: typeof chrome; +} + //////////////////// // Alarms //////////////////// @@ -1524,8 +1531,11 @@ declare module chrome.runtime { } interface MessageSender { - id: string; + id?: string; tab?: chrome.tabs.Tab; + frameId?: number; + url?: string; + tlsChannelId?: string; } interface PlatformInfo { @@ -1535,10 +1545,11 @@ declare module chrome.runtime { } interface Port { - postMessage: Function; + postMessage: (message: Object) => void; + disconnect: () => void; sender?: MessageSender; onDisconnect: chrome.events.Event; - onMessage: chrome.events.Event; + onMessage: PortMessageEvent; name: string; } @@ -1550,6 +1561,10 @@ declare module chrome.runtime { version: string; } + interface PortMessageEvent extends chrome.events.Event { + addListener(callback: (message: Object, port: Port) => void): void; + } + interface ExtensionMessageEvent extends chrome.events.Event { addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; } @@ -2253,20 +2268,20 @@ declare module chrome.webRequest { interface OnCompletedDetails extends CallbackDetails { ip?: string; - statusLine?: string; + statusLine: string; responseHeaders?: HttpHeader[]; fromCache: boolean; statusCode: number; } interface OnHeadersReceivedDetails extends CallbackDetails { - statusLine?: string; + statusLine: string; responseHeaders?: HttpHeader[]; } interface OnBeforeRedirectDetails extends CallbackDetails { ip?: string; - statusLine?: string; + statusLine: string; responseHeaders?: HttpHeader[]; fromCache: boolean; redirectUrl: string; @@ -2279,7 +2294,7 @@ declare module chrome.webRequest { } interface OnAuthRequiredDetails extends CallbackDetails { - statusLine?: string; + statusLine: string; challenger: Challenger; responseHeaders?: HttpHeader[]; isProxy: boolean; @@ -2299,7 +2314,7 @@ declare module chrome.webRequest { interface OnResponseStartedDetails extends CallbackDetails { ip?: string; - statusLine?: string; + statusLine: string; responseHeaders?: HttpHeader[]; fromCache: boolean; statusCode: number; diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 08005eb67..a187d8ec1 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -544,6 +544,9 @@ declare module CodeMirror { insertLeft?: boolean; }): CodeMirror.TextMarker; + /** Returns an array of all the bookmarks and marked ranges found between the given positions. */ + findMarks(from: CodeMirror.Position, to: CodeMirror.Position): TextMarker[]; + /** Returns an array of all the bookmarks and marked ranges present at the given position. */ findMarksAt(pos: CodeMirror.Position): TextMarker[]; diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 15b1375f3..3ab8a9b88 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -702,8 +702,9 @@ declare module D3 { * Parse a delimited string into objects using the header row. * * @param string delimited formatted string to parse + * @param accessor to modify properties of each row */ - parse(string: string): any[]; + parse(string: string, accessor?: (row: any, index?: number) => any): any[]; /** * Parse a delimited string into tuples, ignoring the header row. * @@ -727,7 +728,7 @@ declare module D3 { }; classed: { - (name: string): string; + (name: string): boolean; (name: string, value: any): Selection; (name: string, valueFunction: (data: any, index: number) => any): Selection; (classValueMap: Object): Selection; @@ -778,7 +779,7 @@ declare module D3 { filter: { (filter: (data: any, index: number) => boolean, thisArg?: any): UpdateSelection; - //(filter: string): UpdateSelection; + (filter: string): UpdateSelection; }; call(callback: (selection: Selection, ...args: any[]) => void, ...args: any[]): Selection; @@ -849,7 +850,7 @@ declare module D3 { sortKeys(comparator: (d1: any, d2: any) => number): Nest; sortValues(comparator: (d1: any, d2: any) => number): Nest; rollup(rollupFunction: (data: any, index: number) => any): Nest; - map(values: any[]): any; + map(values: any[], mapType?: any): any; entries(values: any[]): NestKeyValue[]; } @@ -1672,8 +1673,8 @@ declare module D3 { } export interface Symbol { - type: (string:string) => Symbol; - size: (number:number) => Symbol; + type: (symbolType: string | ((datum: any, index: number) => string)) => Symbol; + size: (size: number | ((datum: any, index: number) => number)) => Symbol; (datum:any, index:number): string; } @@ -1751,7 +1752,7 @@ declare module D3 { export interface Axis { (selection: Selection): void; (transition: Transition.Transition): void; - + scale: { (): any; (scale: any): Axis; diff --git a/dcjs/dc-1.6.0.d.ts b/dcjs/dc-1.6.0.d.ts new file mode 100644 index 000000000..2b06c34dd --- /dev/null +++ b/dcjs/dc-1.6.0.d.ts @@ -0,0 +1,199 @@ +// Type definitions for DCJS +// Project: https://github.com/dc-js +// Definitions by: hans windhoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files + +/// +/// + + + +declare module dc { + + // helper for get/set situation + interface IGetSet { + (): T; + (t:T): V; + } +export interface ILegendwidget { + x: IGetSet; + y: IGetSet; + gap: IGetSet; + itemHeight: IGetSet; + horizontal: IGetSet; + legendWidth: IGetSet; + itemWidth: IGetSet; + } + export interface IBaseChart { + width: IGetSet; + height: IGetSet; + minWidth: IGetSet; + minHeight: IGetSet; + dimension: IGetSet; + group: IGetSet; // not sure here + transitionDuration: IGetSet; + colors: IGetSet; + keyAccessor: IGetSet<(d:any) => number, T>; + valueAccessor: IGetSet<(d:any) => number, T>; + label: IGetSet<(l:any) => string, T>; + renderLabel: IGetSet; + renderlet: (fnctn: (t:T) => void) => T; + title: IGetSet<(t:string) => string, T>; + filter: IGetSet; + filterAll: () => void; + expireCache: () => void; + legend: (l:ILegendwidget) => T; + chartID: () => number; + options: (o:Object)=>void ; + select: (selector: D3.Selection) => D3.Selection; + selectAll: (selector: D3.Selection) => D3.Selection; + } + + export interface IEvents { + trigger(fnctn: () => void, delay?: number):void; + } + + export var events: IEvents; + + export interface IListener { + on: (eventName: string, fnctn: (c:T) => void) => T; + } + + export interface ImarginObj { + top: number; + right: number; + bottom: number; + left: number; + + } + + export interface IMarginable { + margins: IGetSet; + } + + // abstract interfaces + export interface IAbstractColorChart { + colorDomain: IGetSet; + } + export interface IAbstractStackableChart { + stack: (group: IChartGroup, name?:string, retriever?: (d:Object)=>number) => T; + } + + export interface IAbstractCoordinateGridChart { + x: IGetSet; + y: IGetSet; + elasticY: IGetSet; + xAxis: IGetSet; + yAxis: IGetSet; + yAxisPadding: IGetSet; + xAxisPadding: IGetSet; + renderHorizontalGridLines: IGetSet; + + } + + export interface IAbstractBubblechart { + r: IGetSet; + radiusValueAccessor: IGetSet<(d:any) => number, T>; + } + + + + // function interfaces + export interface columnFunction { + (rowinfo:any): string; + } + export interface sortbyFunction { + (rowinfo:any): any; + } + export interface orderFunction { + (a: T, b: T): number; + } + + + // chart interfaces + + + export interface IBubblechart extends + IBaseChart, + IAbstractColorChart, + IAbstractBubblechart, + IAbstractCoordinateGridChart, + IMarginable, + IListener { + } + + export interface IPiechart extends + IBaseChart, + IAbstractColorChart, + IAbstractBubblechart, + IAbstractCoordinateGridChart, + IMarginable, + IListener { + radius: IGetSet; + minAngleForLabel: IGetSet; + + } + + export interface IBarchart extends + IBaseChart, + IAbstractStackableChart, + IAbstractCoordinateGridChart, + IMarginable, + IListener { + centerBar: (b:boolean) => IBarchart; + gap: (gapBetweenBars: number) => IBarchart; + } + + export interface ILinechart extends + IBaseChart, + IAbstractStackableChart, + IAbstractCoordinateGridChart, + IMarginable, + IListener { + } + + + export interface IDatachart extends + IBaseChart, + IAbstractStackableChart, + IAbstractCoordinateGridChart, + IMarginable, + IListener { + size: IGetSet; + columns: IGetSet; + sortBy: IGetSet; + order: IGetSet; + } + + + export interface IRowchart extends + IBaseChart, + IAbstractColorChart, + IAbstractStackableChart, + IAbstractCoordinateGridChart, + IMarginable, + IListener { + } + + + + + // utilities + export interface IChartGroup { } + + export function filterAll(chartGroup?: IChartGroup): void; + export function renderAll(chartGroup?: IChartGroup): void; + export function redrawAll(chartGroup?: IChartGroup): void; + + + export function bubbleChart(cssSel: string): IBubblechart; + export function pieChart(cssSel: string): IPiechart; + export function barChart(cssSel: string): IBarchart; + export function lineChart(cssSel: string): ILinechart; + export function dataTable(cssSel: string): IDatachart; + export function rowChart(cssSel: string): IRowchart; + + +} diff --git a/dcjs/dc-tests.ts b/dcjs/dc-tests.ts index 60d3aa059..91b1dc77d 100644 --- a/dcjs/dc-tests.ts +++ b/dcjs/dc-tests.ts @@ -3,240 +3,221 @@ /// interface IYelpData { - city: string; - review_count: number; - name: string; - neighborhoods: string[]; - type: string; - business_id: string; - full_address: string; - state: string; - longitude: number; - stars: number; - latitude: number; - open: boolean; - categories: string[] + city: string; + review_count: number; + name: string; + neighborhoods: string[]; + type: string; + business_id: string; + full_address: string; + state: string; + longitude: number; + stars: number; + latitude: number; + open: boolean; + categories: string[] } interface IYelpDataExtended { - count: number; - review_sum: number; - star_sum: number; - review_avg: number; - star_avg: number; + count: number; + review_sum: number; + star_sum: number; + review_avg: number; + star_avg: number; } /******************************************************** -* * -* dj.js example using Yelp Kaggle Test Dataset * -* Eamonn O'Loughlin 9th May 2013 * -* * -********************************************************/ + * * + * dj.js example using Yelp Kaggle Test Dataset * + * Eamonn O'Loughlin 9th May 2013 * + * * + ********************************************************/ /******************************************************** -* * -* Step0: Load data from json file * -* * -********************************************************/ -d3.json("data/yelp_test_set_business.json", function (yelp_data:IYelpData[]) { - -/******************************************************** -* * -* Step1: Create the dc.js chart objects & ling to div * -* * -********************************************************/ -var bubbleChart = dc.bubbleChart("#dc-bubble-graph"); -var pieChart = dc.pieChart("#dc-pie-graph"); -var volumeChart = dc.barChart("#dc-volume-chart"); -var lineChart = dc.lineChart("#dc-line-chart"); -var dataTable = dc.dataTable("#dc-table-graph"); -var rowChart = dc.rowChart("#dc-row-graph"); + * * + * Step0: Load data from json file * + * * + ********************************************************/ +d3.json("data/yelp_test_set_business.json", (yelp_data:IYelpData[]) => { -/******************************************************** -* * -* Step2: Run data through crossfilter * -* * -********************************************************/ -var ndx = crossfilter(yelp_data); - -/******************************************************** -* * -* Step3: Create Dimension that we'll need * -* * -********************************************************/ + /******************************************************** + * * + * Step1: Create the dc.js chart objects & ling to div * + * * + ********************************************************/ + var bubbleChart: DC.BubbleChart = dc.bubbleChart("#dc-bubble-graph"); + var pieChart: DC.PieChart = dc.pieChart("#dc-pie-graph"); + var volumeChart: DC.BarChart = dc.barChart("#dc-volume-chart"); + var lineChart: DC.LineChart = dc.lineChart("#dc-line-chart"); + var dataTable: DC.DataTableWidget = dc.dataTable("#dc-table-graph"); + var rowChart: DC.RowChart = dc.rowChart("#dc-row-graph"); - // for volumechart - var cityDimension = ndx.dimension(function (d) { return d.city; }); - var cityGroup = cityDimension.group(); - var cityDimensionGroup = cityDimension.group().reduce( - //add - function(p: IYelpDataExtended,v:IYelpData){ - ++p.count; - p.review_sum += v.review_count; - p.star_sum += v.stars; - p.review_avg = p.review_sum / p.count; - p.star_avg = p.star_sum / p.count; - return p; - }, - //remove - function(p: IYelpDataExtended,v:IYelpData){ - --p.count; - p.review_sum -= v.review_count; - p.star_sum -= v.stars; - p.review_avg = p.review_sum / p.count; - p.star_avg = p.star_sum / p.count; - return p; - }, - //init - function(){ - return {count:0, review_sum: 0, star_sum: 0, review_avg: 0, star_avg: 0}; - } - ); + /******************************************************** + * * + * Step2: Run data through crossfilter * + * * + ********************************************************/ + var ndx: CrossFilter.CrossFilter = crossfilter(yelp_data); - // for pieChart - var startValue = ndx.dimension(function (d) { - return d.stars*1.0; - }); - var startValueGroup = startValue.group(); + /******************************************************** + * * + * Step3: Create Dimension that we'll need * + * * + ********************************************************/ - // For datatable - var businessDimension = ndx.dimension(function (d) { return d.business_id; }); -/******************************************************** -* * -* Step4: Create the Visualisations * -* * -********************************************************/ - - bubbleChart.width(650) - .height(300) - .dimension(cityDimension) - .group(cityDimensionGroup) - .transitionDuration(1500) - .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) - .colorDomain([-12000, 12000]) - - .x(d3.scale.linear().domain([0, 5.5])) - .y(d3.scale.linear().domain([0, 5.5])) - .r(d3.scale.linear().domain([0, 2500])) - .keyAccessor(function (p) { - return p.value.star_avg; - }) - .valueAccessor(function (p) { - return p.value.review_avg; - }) - .radiusValueAccessor(function (p) { - return p.value.count; - }) - .transitionDuration(1500) - .elasticY(true) - .yAxisPadding(1) - .xAxisPadding(1) - .label(function (p) { - return p.key; - }) - .renderLabel(true) - .renderlet(function (chart) { - rowChart.filter(chart.filter()); - }) - .on("postRedraw", function (chart) { - dc.events.trigger(function () { - rowChart.filter(chart.filter()); - }); - }); - ; + // for volumechart + var cityDimension: CrossFilter.Dimension = ndx.dimension((d: IYelpData) => d.city); + var cityGroup: CrossFilter.Group = cityDimension.group(); + var cityDimensionGroup: CrossFilter.Group = cityDimension.group().reduce( + //add + (p: IYelpDataExtended, v:IYelpData) => { + ++p.count; + p.review_sum += v.review_count; + p.star_sum += v.stars; + p.review_avg = p.review_sum / p.count; + p.star_avg = p.star_sum / p.count; + return p; + }, + //remove + (p: IYelpDataExtended, v:IYelpData) => { + --p.count; + p.review_sum -= v.review_count; + p.star_sum -= v.stars; + p.review_avg = p.review_sum / p.count; + p.star_avg = p.star_sum / p.count; + return p; + }, + //init + () => { + return {count: 0, review_sum: 0, star_sum: 0, review_avg: 0, star_avg: 0}; + } + ); + // for pieChart + var startValue: CrossFilter.Dimension = ndx.dimension((d: IYelpData) => d.stars * 1.0); + var startValueGroup: CrossFilter.Group = startValue.group(); -pieChart.width(200) - .height(200) - .transitionDuration(1500) - .dimension(startValue) - .group(startValueGroup) - .radius(90) - .minAngleForLabel(0) - .label(function(d) { return d.data.key; }) - .on("filtered", function (chart) { - dc.events.trigger(function () { - if(chart.filter()) { - console.log(chart.filter()); - volumeChart.filter([chart.filter()-.25,chart.filter()-(-0.25)]); - } - else volumeChart.filterAll(); - }); - }); + // For datatable + var businessDimension: CrossFilter.Dimension = ndx.dimension((d: IYelpData) => d.business_id); + /******************************************************** + * * + * Step4: Create the Visualisations * + * * + ********************************************************/ -volumeChart.width(230) - .height(200) - .dimension(startValue) - .group(startValueGroup) - .transitionDuration(1500) - .centerBar(true) - .gap(17) - .x(d3.scale.linear().domain([0.5, 5.5])) - .elasticY(true) - .on("filtered", function (chart) { - dc.events.trigger(function () { - if(chart.filter()) { - console.log(chart.filter()); - lineChart.filter(chart.filter()); - } - else - {lineChart.filterAll()} - }); - }) - .xAxis().tickFormat(function(v) {return v;}); + bubbleChart + .width(650) + .height(300) + .dimension(cityDimension) + .group(cityDimensionGroup) + .transitionDuration(1500) + .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) + .colorDomain([-12000, 12000]) + .x(d3.scale.linear().domain([0, 5.5])) + .y(d3.scale.linear().domain([0, 5.5])) + .r(d3.scale.linear().domain([0, 2500])) + .keyAccessor((p: any) => p.value.star_avg) + .valueAccessor((p: any) => p.value.review_avg) + .radiusValueAccessor((p: any) => p.value.count) + .transitionDuration(1500) + .elasticY(true) + .yAxisPadding(1) + .xAxisPadding(1) + .label((p: any) => p.key) + .renderLabel(true) + .renderlet((chart: DC.BubbleChart) => rowChart.filter(chart.filter())) + .on("postRedraw", (chart: DC.BubbleChart) => dc.events.trigger(() => rowChart.filter(chart.filter()))); -console.log(startValueGroup.top(1)[0].value); + pieChart + .width(200) + .height(200) + .transitionDuration(1500) + .dimension(startValue) + .group(startValueGroup) + .radius(90) + .minAngleForLabel(0) + .label((d: any) => d.data.key) + .on("filtered", (chart: DC.PieChart) => + dc.events.trigger(() => { + if (chart.filter()) { + console.log(chart.filter()); + volumeChart.filter([chart.filter()-.25,chart.filter()-(-0.25)]); + } + else volumeChart.filterAll(); + })); -lineChart.width(230) - .height(200) - .dimension(startValue) - .group(startValueGroup) - .x(d3.scale.linear().domain([0.5, 5.5])) - .valueAccessor(function(d) { - return d.value; - }) - .renderHorizontalGridLines(true) - .elasticY(true) - .xAxis().tickFormat(function(v) {return v;}); ; + volumeChart + .width(230) + .height(200) + .dimension(startValue) + .group(startValueGroup) + .transitionDuration(1500) + .centerBar(true) + .gap(17) + .x(d3.scale.linear().domain([0.5, 5.5])) + .elasticY(true) + .on("filtered", (chart: DC.BarChart) => + dc.events.trigger(() => { + if(chart.filter()) { + console.log(chart.filter()); + lineChart.filter(chart.filter()); + } + else { + lineChart.filterAll() + } + })) + .xAxis() + .tickFormat((v: string) => v); -rowChart.width(340) - .height(850) - .dimension(cityDimension) - .group(cityGroup) - .renderLabel(true) - .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) - .colorDomain([0, 0]) - .renderlet(function (chart) { - bubbleChart.filter(chart.filter()); - }) - .on("filtered", function (chart) { - dc.events.trigger(function () { - bubbleChart.filter(chart.filter()); - }); - }); + console.log(startValueGroup.top(1)[0].value); + lineChart + .width(230) + .height(200) + .dimension(startValue) + .group(startValueGroup) + .x(d3.scale.linear().domain([0.5, 5.5])) + .valueAccessor((d: any) => d.value) + .renderHorizontalGridLines(true) + .elasticY(true) + .xAxis() + .tickFormat((v: string) => v); -dataTable.width(800).height(800) - .dimension(businessDimension) - .group(function(d:Object) { return "List of all Selected Businesses" - }) - .size(100) - .columns([ - function(d) { return d.name; }, - function(d) { return d.city; }, - function(d) { return d.stars; }, - function(d) { return d.review_count; }, - function(d) { return 'Map"} - ]) - .sortBy(function(d){ return d.stars; }) - // (optional) sort order, :default ascending - .order(d3.ascending); -/******************************************************** -* * -* Step6: Render the Charts * -* * -********************************************************/ - - dc.renderAll(); + rowChart + .width(340) + .height(850) + .dimension(cityDimension) + .group(cityGroup) + .renderLabel(true) + .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) + .colorDomain([0, 0]) + .renderlet((chart: DC.RowChart) => bubbleChart.filter(chart.filter())) + .on("filtered", (chart: DC.RowChart) => + dc.events.trigger(() => + bubbleChart.filter(chart.filter()))); + + dataTable + .width(800) + .height(800) + .dimension(businessDimension) + .group((d: any) => "List of all Selected Businesses") + .size(100) + .columns([ + (d: IYelpData) => d.name, + (d: IYelpData) => d.city, + (d: IYelpData) => d.stars, + (d: IYelpData) => d.review_count, + (d: IYelpData) => 'Map" + ]) + .sortBy((d: IYelpData) => d.stars) + // (optional) sort order, :default ascending + .order(d3.ascending); + /******************************************************** + * * + * Step6: Render the Charts * + * * + ********************************************************/ + + dc.renderAll(); }); diff --git a/dcjs/dc.d.ts b/dcjs/dc.d.ts index 2b06c34dd..5a83b5c7c 100644 --- a/dcjs/dc.d.ts +++ b/dcjs/dc.d.ts @@ -1,6 +1,6 @@ // Type definitions for DCJS -// Project: https://github.com/dc-js -// Definitions by: hans windhoff +// Project: https://github.com/dc-js/dc.js +// Definitions by: hans windhoff , matt traynham // Definitions: https://github.com/borisyankov/DefinitelyTyped // this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files @@ -8,192 +8,426 @@ /// /// +declare module DC { + // helper for get/set situation + export interface IGetSet { + (): T; + (t: T): V; + } + export interface IBiGetSet { + (): T; + (t: T, r?: R): V; + } -declare module dc { + export interface Accessor { + (datum: T, index?: number): V; + } - // helper for get/set situation - interface IGetSet { - (): T; - (t:T): V; - } -export interface ILegendwidget { - x: IGetSet; - y: IGetSet; - gap: IGetSet; - itemHeight: IGetSet; - horizontal: IGetSet; - legendWidth: IGetSet; - itemWidth: IGetSet; - } - export interface IBaseChart { - width: IGetSet; - height: IGetSet; - minWidth: IGetSet; - minHeight: IGetSet; - dimension: IGetSet; - group: IGetSet; // not sure here - transitionDuration: IGetSet; - colors: IGetSet; - keyAccessor: IGetSet<(d:any) => number, T>; - valueAccessor: IGetSet<(d:any) => number, T>; - label: IGetSet<(l:any) => string, T>; - renderLabel: IGetSet; - renderlet: (fnctn: (t:T) => void) => T; - title: IGetSet<(t:string) => string, T>; - filter: IGetSet; - filterAll: () => void; - expireCache: () => void; - legend: (l:ILegendwidget) => T; - chartID: () => number; - options: (o:Object)=>void ; - select: (selector: D3.Selection) => D3.Selection; - selectAll: (selector: D3.Selection) => D3.Selection; - } + export interface UnitFunction { + (start: number, end: number, domain?: Array): number|Array; + } - export interface IEvents { - trigger(fnctn: () => void, delay?: number):void; - } + export interface FloatPointUnits { + precision(precision: number): UnitFunction; + } - export var events: IEvents; + export interface Units { + integers: UnitFunction; + ordinal: UnitFunction; + fp: FloatPointUnits; + } - export interface IListener { - on: (eventName: string, fnctn: (c:T) => void) => T; - } + export interface Events { + trigger(fn: () => void, delay?: number): void; + } - export interface ImarginObj { - top: number; - right: number; - bottom: number; - left: number; - - } + export interface Errors { + Exception(msg: string): void; + InvalidStateException(msg: string): void; + } - export interface IMarginable { - margins: IGetSet; - } + export interface Filter { + isFiltered(value: any): boolean; + } - // abstract interfaces - export interface IAbstractColorChart { - colorDomain: IGetSet; - } - export interface IAbstractStackableChart { - stack: (group: IChartGroup, name?:string, retriever?: (d:Object)=>number) => T; - } + export interface Filters { + RangedFilter(low: any, high: any): Filter; + TwoDimensionalFilter(arr: Array): Filter; + RangedTwoDimensionalFilter(arr: Array): Filter; + } - export interface IAbstractCoordinateGridChart { - x: IGetSet; - y: IGetSet; - elasticY: IGetSet; - xAxis: IGetSet; - yAxis: IGetSet; - yAxisPadding: IGetSet; - xAxisPadding: IGetSet; - renderHorizontalGridLines: IGetSet; - - } + export interface Logger { + enableDebugLog: boolean; + warn(msg: string): void; + debug(msg: string): void; + deprecate(fn: Function, msg: string): void; + } - export interface IAbstractBubblechart { - r: IGetSet; - radiusValueAccessor: IGetSet<(d:any) => number, T>; - } + export interface Printers { + filters(filters: Array): string; + filter(filter: any): string; + } + export interface Round { + floor(n: number): number; + ceil(n: number): number; + round(n: number): number; + } + export interface Utils { + printSingleValue(filter: any): string; + add(l: any, r: any): any; + subtract(l: any, r: any): any; + isNumber(n: any): boolean; + isFloat(n: any): boolean; + isInteger(n: any): boolean; + isNegligible(n: any): boolean; + clamp(n: number, min: number, max: number): number; + uniqueId(): number; + nameToId(name: string): string; + appendOrSelect(parent: D3.Selection, selector: string, tag: any): D3.Selection; + safeNumber(n: any): number; + } - // function interfaces - export interface columnFunction { - (rowinfo:any): string; - } - export interface sortbyFunction { - (rowinfo:any): any; - } - export interface orderFunction { - (a: T, b: T): number; - } + export interface Legend { + x: IGetSet; + y: IGetSet; + gap: IGetSet; + itemHeight: IGetSet; + horizontal: IGetSet; + legendWidth: IGetSet; + itemWidth: IGetSet; + autoItemWidth: IGetSet; + render: () => void; + } + export interface BaseMixin { + width: IGetSet; + height: IGetSet; + minWidth: IGetSet; + minHeight: IGetSet; + dimension: IGetSet; + data: IGetSet<(group: any) => Array, T>; + group: IGetSet; + ordering: IGetSet, T>; + filterAll(): void; + select(selector: D3.Selection|string): D3.Selection; + selectAll(selector: D3.Selection|string): D3.Selection; + anchor(anchor: BaseMixin|D3.Selection|string, chartGroup?: string): D3.Selection; + anchorName(): string; + svg: IGetSet; + resetSvg(): void; + filterPrinter: IGetSet<(filters: Array) => string, T>; + turnOnControls(): void; + turnOffControls(): void; + transitionDuration: IGetSet; + render(): void; + redraw(): void; + redrawGroup(): void; + hasFilterHandler: IGetSet<(filters: Array, filter: any) => boolean, T>; + hasFilter(filter?: any): boolean; + removeFilterHandler: IGetSet<(filters: Array) => Array, T>; + addFilterHandler: IGetSet<(filters: Array) => Array, T>; + resetFilterHandler: IGetSet<(filters: Array) => Array, T>; + filter: IGetSet; + filters(): Array; + onClick(datum: any): void; + filterHandler: IGetSet<(dimension: any, filter: any) => any, T>; + keyAccessor: IGetSet, T>; + valueAccessor: IGetSet, T>; + label: IGetSet, T>; + renderLabel: IGetSet; + title: IGetSet, T>; + renderTitle: IGetSet; + chartGroup: IGetSet; + expireCache(): T; + legend: IGetSet; + options(optionsObject: any): T; + renderlet(fn: (chart: T) => any): T; + on(event: string, fn: (chart: T) => any): T; + } - // chart interfaces - + export interface Margins { + left: number; + top: number; + right: number; + bottom: number; + } - export interface IBubblechart extends - IBaseChart, - IAbstractColorChart, - IAbstractBubblechart, - IAbstractCoordinateGridChart, - IMarginable, - IListener { - } + export interface MarginMixin { + margins: IGetSet + } - export interface IPiechart extends - IBaseChart, - IAbstractColorChart, - IAbstractBubblechart, - IAbstractCoordinateGridChart, - IMarginable, - IListener { - radius: IGetSet; - minAngleForLabel: IGetSet; + export interface ColorMixin { + colors: IGetSet|Array, T>; + ordinalColors(r: Array): void; + linearColors(r: Array): void; + colorAccessor: IGetSet, T>; + colorDomain: IGetSet, T>; + calculateColorDomain(): void; + getColor(datum: any, index?: number): string; + colorCalculator: IGetSet, T>; + } - } + export interface CoordinateGridMixin extends BaseMixin, MarginMixin, BaseMixin { + rangeChart: IGetSet, T>; + zoomScale: IGetSet, T>; + zoomOutRestrict: IGetSet; + g: IGetSet; + mouseZoomable: IGetSet; + chartBodyG(): D3.Selection; + x: IGetSet, T>; + xUnits: IGetSet; + xAxis: IGetSet; + elasticX: IGetSet; + xAxisPadding: IGetSet; + xUnitCount(): number; + useRightYAxis: IGetSet; + isOrdinal(): boolean; + xAxisLabel: IBiGetSet; + yAxisLabel: IBiGetSet; + y: IGetSet, T>; + yAxis: IGetSet; + elasticY: IGetSet; + renderHorizontalGridLines: IGetSet; + renderVerticalGridLines: IGetSet; + xAxisMin(): any; + xAxisMax(): any; + yAxisMin(): any; + yAxisMax(): any; + yAxisPadding: IGetSet; + round: IGetSet<(value: any) => any, T>; + clipPadding: IGetSet; + focus(range?: Array): void; + brushOn: IGetSet; + } - export interface IBarchart extends - IBaseChart, - IAbstractStackableChart, - IAbstractCoordinateGridChart, - IMarginable, - IListener { - centerBar: (b:boolean) => IBarchart; - gap: (gapBetweenBars: number) => IBarchart; - } + export interface StackMixin { + stack(group: any, name?: string, accessor?: Accessor): void; + hidableStacks: IGetSet; + hideStack(name: string): void; + showStack(name: string): void; + // title(stackName: string, titleFn: Accessor); + stackLayout: IGetSet; + } - export interface ILinechart extends - IBaseChart, - IAbstractStackableChart, - IAbstractCoordinateGridChart, - IMarginable, - IListener { - } + export interface CapMixin { + cap: IGetSet; + othersLabel: IGetSet; + othersGrouper: IGetSet<(data: Array) => Array, T>; + } + export interface BubbleMixin extends ColorMixin { + r: IGetSet, T>; + radiusValueAccessor: IGetSet, T>; + minRadiusWithLabel: IGetSet; + maxBubbleRelativeSize: IGetSet; + } - export interface IDatachart extends - IBaseChart, - IAbstractStackableChart, - IAbstractCoordinateGridChart, - IMarginable, - IListener { - size: IGetSet; - columns: IGetSet; - sortBy: IGetSet; - order: IGetSet; - } + export interface PieChart extends CapMixin, ColorMixin, BaseMixin { + slicesCap: IGetSet; + innerRadius: IGetSet; + radius: IGetSet; + cx: IGetSet; + cy: IGetSet; + minAngleForLabel: IGetSet; + } + export interface BarChart extends StackMixin, CoordinateGridMixin { + centerBar: IGetSet; + barPadding: IGetSet; + outerPadding: IGetSet; + gap: IGetSet; + alwaysUseRounding: IGetSet; + } - export interface IRowchart extends - IBaseChart, - IAbstractColorChart, - IAbstractStackableChart, - IAbstractCoordinateGridChart, - IMarginable, - IListener { - } + export interface RenderDataPointOptions { + fillOpacity: number; + strokeOpacity: number; + radius: number; + } + export interface LineChart extends StackMixin, CoordinateGridMixin { + interpolate: IGetSet; + tension: IGetSet; + defined: IGetSet, LineChart>; + dashStyle: IGetSet, LineChart>; + renderArea: IGetSet; + dotRadius: IGetSet; + renderDataPoints: IGetSet; + } + export interface DataCountWidgetHTML { + all: string; + some: string; + } + export interface DataCountWidget extends BaseMixin { + html: IGetSet; + formatNumber: IGetSet, DataCountWidget>; + } - // utilities - export interface IChartGroup { } + export interface DataTableWidget extends BaseMixin { + size: IGetSet; + columns: IGetSet|string|Array|string>>, DataTableWidget>; + sortBy: IGetSet, DataTableWidget>; + order: IGetSet<(a: any, b: any) => number, DataTableWidget>; + } - export function filterAll(chartGroup?: IChartGroup): void; - export function renderAll(chartGroup?: IChartGroup): void; - export function redrawAll(chartGroup?: IChartGroup): void; + export interface DataGridWidget extends BaseMixin { + size: IGetSet; + html: IGetSet, DataTableWidget>; + htmlGroup: IGetSet, DataTableWidget>; + sortBy: IGetSet, DataTableWidget>; + order: IGetSet<(a: any, b: any) => number, DataTableWidget>; + } + export interface BubbleChart extends BubbleMixin, CoordinateGridMixin { + elasticRadius: IGetSet; + } - export function bubbleChart(cssSel: string): IBubblechart; - export function pieChart(cssSel: string): IPiechart; - export function barChart(cssSel: string): IBarchart; - export function lineChart(cssSel: string): ILinechart; - export function dataTable(cssSel: string): IDatachart; - export function rowChart(cssSel: string): IRowchart; + export interface CompositeChart extends CoordinateGridMixin { + useRightAxisGridLines: IGetSet; + childOptions: IGetSet; + rightYAxisLabel: IGetSet; + compose: IGetSet>, CompositeChart>; + children(): Array>; + shareColors: IGetSet; + shareTitle: IGetSet; + rightY: IGetSet, CompositeChart>; + rightYAxis: IGetSet; + } + export interface SeriesChart extends CompositeChart { + chart: IGetSet<(c: any) => BaseMixin, SeriesChart>; + seriesAccessor: IGetSet, SeriesChart>; + seriesSort: IGetSet<(a: any, b: any) => number, SeriesChart>; + valueSort: IGetSet<(a: any, b: any) => number, SeriesChart>; + } + export interface GeoChoroplethLayer { + name: string; + keyAccessor: Accessor; + data: any; + } + + export interface GeoChoroplethChart extends ColorMixin, BaseMixin { + overlayGeoJson(json: any, name: string, keyAccessor: Accessor): void; + projection: IGetSet; + geoJsons(): Array; + geoPath(): D3.Geo.Path; + removeGeoJson(name: string): void; + } + + export interface BubbleOverlayChart extends BubbleMixin, BaseMixin { + point(name: string, x: number, y: number): void; + } + + export interface RowChart extends CapMixin, MarginMixin, ColorMixin, BaseMixin { + x: IGetSet, RowChart>; + renderTitleLabel: IGetSet; + xAxis: IGetSet; + fixedBarHeight: IGetSet; + gap: IGetSet; + elasticX: IGetSet; + labelOffsetX: IGetSet; + labelOffsetY: IGetSet; + titleLabelOffsetX: IGetSet; + } + + export interface ScatterPlot extends CoordinateGridMixin { + existenceAccessor: IGetSet, ScatterPlot>; + symbol: IGetSet; + symbolSize: IGetSet; + highlightedSize: IGetSet; + hiddenSize: IGetSet; + } + + export interface NumberDisplayWidgetHTML { + one: string; + some: string; + none: string; + } + + export interface NumberDisplayWidget extends BaseMixin { + html: IGetSet; + value(): string; + formatNumber: IGetSet, NumberDisplayWidget>; + } + + export interface HeatMap extends ColorMixin, MarginMixin, BaseMixin { + colsLabel: IGetSet, HeatMap>; + rowsLabel: IGetSet, HeatMap>; + rows: IGetSet, HeatMap>; + cols: IGetSet, HeatMap>; + boxOnClick: IGetSet<(d: any) => void, HeatMap>; + xAxisOnClick: IGetSet<(d: any) => void, HeatMap>; + yAxisOnClick: IGetSet<(d: any) => void, HeatMap>; + } + + export interface BoxPlot extends CoordinateGridMixin { + boxPadding: IGetSet; + outerPadding: IGetSet; + boxWidth: IGetSet; + tickFormat: IGetSet, BoxPlot>; + } + + export interface ChartRegistry { + has(chart: BaseMixin): boolean; + register(chart: BaseMixin, group?: string): void; + deregister(chart: BaseMixin, group?: string): void; + clear(group?: string): void; + list(group?: string): Array>; + } + + export interface Base { + chartRegistry: ChartRegistry; + registerChart(chart: BaseMixin, group?: string): void; + deregisterChart(chart: BaseMixin, group?: string): void; + hasChart(chart: BaseMixin): boolean; + deregisterAllCharts(group?: string): void; + filterAll(group?: string): void; + refocusAll(group?: string): void; + renderAll(group?: string): void; + redrawAll(group?: string): void; + disableTransitions: boolean; + transition(selections: D3.Selection, duration: number, callback: (s: D3.Selection) => void): void; + + units: Units; + events: Events; + errors: Errors; + instanceOfChart(object: any): boolean; + logger: Logger; + override(object: any, fnName: string, newFn: Function): void; + printers: Printers; + pluck(n: string, f?: Accessor): Accessor; + round: Round; + utils: Utils; + + legend(): Legend; + + pieChart(parent: string, chartGroup?: string): PieChart; + barChart(parent: string, chartGroup?: string): BarChart; + lineChart(parent: string, chartGroup?: string): LineChart; + dataCount(parent: string, chartGroup?: string): DataCountWidget; + dataTable(parent: string, chartGroup?: string): DataTableWidget; + dataGrid(parent: string, chartGroup?: string): DataGridWidget; + bubbleChart(parent: string, chartGroup?: string): BubbleChart; + compositeChart(parent: string, chartGroup?: string): CompositeChart; + seriesChart(parent: string, chartGroup?: string): SeriesChart; + geoChoroplethChart(parent: string, chartGroup?: string): GeoChoroplethChart; + bubbleOverlayChart(parent: string, chartGroup?: string): BubbleOverlayChart; + rowChart(parent: string, chartGroup?: string): RowChart; + scatterPlot(parent: string, chartGroup?: string): ScatterPlot; + numberDisplay(parent: string, chartGroup?: string): NumberDisplayWidget; + heatMap(parent: string, chartGroup?: string): HeatMap; + boxPlot(parent: string, chartGroup?: string): BoxPlot; + } +} + +declare var dc: DC.Base; + +declare module 'dc' { + export = dc; } diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index 650258c4a..63cda16dd 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -9754,7 +9754,7 @@ declare module dojo { * * * - * + * */ init(): void; } @@ -18375,7 +18375,7 @@ declare module dojo { * * * - * + * */ init(): void; } @@ -25085,7 +25085,7 @@ declare module dojo { * * * - * + * */ init(): void; } diff --git a/drop/drop-tests.ts b/drop/drop-tests.ts new file mode 100644 index 000000000..b5ae47456 --- /dev/null +++ b/drop/drop-tests.ts @@ -0,0 +1,28 @@ +/// +/// + +var yellowBox = document.querySelector(".yellow"); +var greenBox = document.querySelector(".green"); + +var d = new Drop({ + position: "bottom left", + openOn: "click", + constrainToWindow: true, + constrainToScrollParent: true, + classes: "", + tetherOptions: {} +}); + +d.open(); +d.close(); +d.remove(); +d.toggle(); +d.position(); +d.destroy(); + +d.on("open", () => null); +d.on("close", () => null); +d.once("close", () => null); +d.off("close", () => null); +d.off("open"); + diff --git a/drop/drop.d.ts b/drop/drop.d.ts new file mode 100644 index 000000000..18568afdd --- /dev/null +++ b/drop/drop.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Drop v0.5 +// Project: http://github.hubspot.com/drop/ +// Definitions by: Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module drop { + + interface DropStatic { + new(options: IDropOptions): Drop; + } + + interface IDropOptions { + target?: Element; + content?: Element | string | (() => string); + position?: string; + openOn?: string; + constrainToWindow?: boolean; + constrainToScrollParent?: boolean; + remove?: boolean; + tetherOptions?: tether.ITetherOptions; + } + + interface Drop { + content: HTMLElement; + open(): void; + close(): void; + remove(): void; + toggle(): void; + position(): void; + destroy(): void; + /* + * Drop instances fire "open" and "close" events. + */ + on(event: string, handler: Function, context?: any): void; + once(event: string, handler: Function, context?: any): void; + off(event: string, handler?: Function): void; + } + +} + +declare module "drop" { + export = drop; +} + +declare var Drop: drop.DropStatic; + diff --git a/ember/ember-tests.ts b/ember/ember-tests.ts index 39e960e00..ef9b7e6d1 100644 --- a/ember/ember-tests.ts +++ b/ember/ember-tests.ts @@ -2,9 +2,9 @@ /// -var App; +var App : any; -App = Em.Application.create(); +App = Em.Application.create(); App.president = Em.Object.create({ name: 'Barack Obama' @@ -27,7 +27,7 @@ declare class MyPerson extends Em.Object { } var Person1 = Em.Object.extend({ - say: (thing) => { + say: (thing: string) => { alert(thing); } }); @@ -119,7 +119,7 @@ App.AlertView = Em.View.extend({ App.ListingView = Em.View.extend({ templateName: 'listing', - edit: (event) => { + edit: (event: any) => { event.view.set('isEditing', true); } }); @@ -133,7 +133,7 @@ App.userController = Em.Object.create({ }) }); -Handlebars.registerHelper('highlight', function(property, options) { +Handlebars.registerHelper('highlight', function(property: string, options: any) { var value = Em.Handlebars.get(this, property, options); return new Handlebars.SafeString('' + value + ''); }); @@ -195,7 +195,7 @@ people2.everyProperty('isHappy', true); people2.someProperty('isHappy', true); // Examples taken from http://emberjs.com/api/classes/Ember.RSVP.Promise.html -var promise = new Ember.RSVP.Promise(function(resolve, reject) { +var promise = new Ember.RSVP.Promise(function(resolve: Function, reject: Function) { // on success resolve('ok!'); @@ -203,8 +203,8 @@ var promise = new Ember.RSVP.Promise(function(resolve, reject) { reject('no-k!'); }); -promise.then(function(value) { +promise.then(function(value: any) { // on fulfillment -}, function(reason) { +}, function(reason: any) { // on rejection }); diff --git a/ember/ember.d.ts b/ember/ember.d.ts index b6cdde9d6..22cbb8ab5 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -11,15 +11,147 @@ declare var Handlebars: HandlebarsStatic; declare module EmberStates { interface Transition { - abort(): void; - addInitialStates(): void; - matchContextsToStates(contexts: any[]): void; - normalize(manager: Ember.StateManager, contexts: any[]): void; - removeUnchangedContexts(manager: Ember.StateManager): void; - retry(): void; - sendEvents(eventName: string, sendRecursiveArguments: boolean, isUnhandledPass: boolean): void; - sendRecursively(event: string, currentState: Ember.State, isUnhandledPass: boolean): void; targetName: string; + urlMethod: string; + intent: any; + params: {}|any; + pivotHandler: any; + resolveIndex: number; + handlerInfos: any; + resolvedModels: {}|any; + isActive: boolean; + state: any; + queryParams: {}|any; + queryParamsOnly: boolean; + + isTransition: boolean; + + /** + The Transition's internal promise. Calling `.then` on this property + is that same as calling `.then` on the Transition object itself, but + this property is exposed for when you want to pass around a + Transition's promise, but not the Transition object itself, since + Transition object can be externally `abort`ed, while the promise + cannot. + */ + promise: Ember.RSVP.Promise; + + /** + Custom state can be stored on a Transition's `data` object. + This can be useful for decorating a Transition within an earlier + hook and shared with a later hook. Properties set on `data` will + be copied to new transitions generated by calling `retry` on this + transition. + */ + data: any; + + /** + A standard promise hook that resolves if the transition + succeeds and rejects if it fails/redirects/aborts. + + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @arg {Function} onFulfilled + @arg {Function} onRejected + @arg {String} label optional string for labeling the promise. Useful for tooling. + @return {Promise} + */ + then(onFulfilled: Function, onRejected: Function, label?: string): Ember.RSVP.Promise; + + /** + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method catch + @arg {Function} onRejection + @arg {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + catch(onRejection: Function, label?: string): Ember.RSVP.Promise; + + /** + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method finally + @arg {Function} callback + @arg {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + finally(callback: Function, label?: string): Ember.RSVP.Promise; + + /** + Aborts the Transition. Note you can also implicitly abort a transition + by initiating another transition while a previous one is underway. + */ + abort(): EmberStates.Transition; + normalize(manager: Ember.StateManager, contexts: any[]): void; + + /** + Retries a previously-aborted transition (making sure to abort the + transition if it's still active). Returns a new transition that + represents the new attempt to transition. + */ + retry(): EmberStates.Transition; + + /** + Sets the URL-changing method to be employed at the end of a + successful transition. By default, a new Transition will just + use `updateURL`, but passing 'replace' to this method will + cause the URL to update using 'replaceWith' instead. Omitting + a parameter will disable the URL change, allowing for transitions + that don't update the URL at completion (this is also used for + handleURL, since the URL has already changed before the + transition took place). + + @arg {String} method the type of URL-changing method to use + at the end of a transition. Accepted values are 'replace', + falsy values, or any other non-falsy value (which is + interpreted as an updateURL transition). + + @return {Transition} this transition + */ + method(method: string): EmberStates.Transition; + + /** + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @arg {Boolean} [ignoreFailure=false] a boolean specifying whether unhandled events throw an error + @arg {String} name the name of the event to fire + */ + trigger(ignoreFailure:boolean, eventName: string): void; + /** + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @arg {String} name the name of the event to fire + */ + trigger(eventName: string): void; + + /** + Transitions are aborted and their promises rejected + when redirects occur; this method returns a promise + that will follow any redirects that occur and fulfill + with the value fulfilled by any redirecting transitions + that occur. + + @return {Promise} a promise that fulfills with the same + value that the final redirecting transition fulfills with + */ + followRedirects(): Ember.RSVP.Promise; } } @@ -61,7 +193,7 @@ interface String { } interface Array { - constructor(arr: any[]); + constructor(arr: any[]): void; activate(): void; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; @@ -88,16 +220,40 @@ interface Array { every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: any): boolean; - filter(callback: Function, target: any): any[]; + filter(callback: Function, target?: any): any[]; filterBy(key: string, value?: string): any[]; - find(callback: Function, target: any): any; + + /** + Returns the first item in the array for which the callback returns true. + This method works similar to the `filter()` method defined in JavaScript 1.6 + except that it will stop working on the array once a match is found. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @function find + @arg callback The callback to execute + @arg {Object} [target] The target object to use + @return {Object} Found item or `undefined`. +*/ + find(callback: Function, target?: any): any; findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; - indexOf(object: any, startAt: number): number; + indexOf(object: any, startAt?: number): number; insertAt(idx: number, object: any): any[]; invoke(methodName: string, ...args: any[]): any[]; - lastIndexOf(object: any, startAt: number): number; + lastIndexOf(object: any, startAt?: number): number; + map(callback: Function, target?: any): any[]; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; @@ -111,7 +267,7 @@ interface Array { removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; - replace(idx: number, amt: number, objects: any[]); + replace(idx: number, amt: number, objects: any[]): void; reverseObjects(): any[]; setEach(key: string, value?: any): any; setObjects(objects: any[]): any[]; @@ -154,6 +310,9 @@ interface Array { toggleProperty(keyName: string): any; copy(deep: boolean): any[]; frozenCopy(): any[]; + // 1.3 + isAny(key: string, value?: string): boolean; + isEvery(key: string, value?: string): boolean; } interface ApplicationCreateArguments { @@ -175,7 +334,7 @@ interface ApplicationInitializerArguments { } interface ApplicationInitializerFunction { - (container: Ember.Container, application: Ember.Application); + (container: Ember.Container, application: Ember.Application): void; } interface CoreObjectArguments { @@ -202,11 +361,11 @@ interface ItemIndexEnumerableCallbackTarget { } interface ItemIndexEnumerableCallback { - (item: any, index: number, enumerable: Ember.Enumerable); + (item: any, index: number, enumerable: Ember.Enumerable): void; } interface ReduceCallback { - (previousValue: any, item: any, index: number, enumerable: Ember.Enumerable); + (previousValue: any, item: any, index: number, enumerable: Ember.Enumerable): void; } interface TransitionsHash { @@ -233,10 +392,10 @@ interface RenderOptions { } interface ModifyObserver { - (obj: any, path: string, target: any, method?: Function); - (obj: any, path: string, target: any, method?: string); - (obj: any, path: string, func: Function, method?: Function); - (obj: any, path: string, func: Function, method?: string); + (obj: any, path: string, target: any, method?: Function): void; + (obj: any, path: string, target: any, method?: string): void; + (obj: any, path: string, func: Function, method?: Function): void; + (obj: any, path: string, func: Function, method?: string): void; } declare module Ember { @@ -399,7 +558,7 @@ declare module Ember { everyProperty(key: string, value?: string): boolean; filter(callback: Function, target: any): any[]; filterBy(key: string, value?: string): any[]; - find(callback: Function, target: any): any; + find(callback: Function, target?: any): any; findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; @@ -495,7 +654,7 @@ declare module Ember { static isClass: boolean; static isMethod: boolean; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; - addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; any(callback: Function, target?: any): boolean; anyBy(key: string, value?: string): boolean; arrayContentDidChange(startIdx: number, removeAmt: number, addAmt: number): any[]; @@ -512,10 +671,10 @@ declare module Ember { enumerableContentDidChange(removing: Enumerable, adding: number): any; enumerableContentDidChange(removing: number, adding: Enumerable): any; enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; - enumerableContentWillChange(removing: number, adding: number): any[]; - enumerableContentWillChange(removing: Enumerable, adding: number): any[]; - enumerableContentWillChange(removing: number, adding: Enumerable): any[]; - enumerableContentWillChange(removing: Enumerable, adding: Enumerable): any[]; + enumerableContentWillChange(removing: number, adding: number): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; + enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: Enumerable): Enumerable; every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: string): boolean; @@ -543,7 +702,7 @@ declare module Ember { rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; - removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; replace(idx: number, amt: number, objects: any[]): any; replaceContent(idx: number, amt: number, objects: any[]): void; reverseObjects(): any[]; @@ -553,10 +712,10 @@ declare module Ember { slice(beginIndex?: number, endIndex?: number): any[]; some(callback: Function, target?: any): boolean; toArray(): any[]; - uniq(): any[]; + uniq(): Enumerable; unshiftObject(object: any): any; unshiftObjects(objects: any[]): any[]; - without(value: any): any[]; + without(value: any): Enumerable; '[]': any[]; '@each': EachProxy; Boolean: boolean; @@ -565,9 +724,9 @@ declare module Ember { lastObject: any; length: number; addObject(object: any): any; - addObjects(objects: Enumerable): any[]; + addObjects(objects: Enumerable): MutableEnumberable; removeObject(object: any): any; - removeObjects(objects: Enumerable): any[]; + removeObjects(objects: Enumerable): MutableEnumberable; } var BOOTED: boolean; /** @@ -958,8 +1117,9 @@ declare module Ember { /** A subclass of the JavaScript Error object for use in Ember. **/ + // Restore this to 'typeof Error' when https://github.com/Microsoft/TypeScript/issues/983 is resolved // ReSharper disable once DuplicatingLocalDeclaration - var Error: typeof Error; + var Error: any; // typeof Error; /** Handles delegating browser events to their corresponding Ember.Views. For example, when you click on a view, Ember.EventDispatcher ensures that that view's mouseDown method gets called. @@ -1001,8 +1161,8 @@ declare module Ember { module Handlebars { function compile(string: string): Function; function get(root: any, path: string, options?: {}): any; - function helper(name: string, func: Function, dependentKeys: string): void; - function helper(name: string, view: View, dependentKeys: string): void; + function helper(name: string, func: Function, dependentKeys?: string): void; + function helper(name: string, view: View, dependentKeys?: string): void; class helpers { action(actionName: string, context: any, options?: {}): void; bindAttr(options?: {}): string; @@ -1307,7 +1467,7 @@ declare module Ember { constructor(arr: any[]); static activate(): void; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; - addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; any(callback: Function, target?: any): boolean; anyBy(key: string, value?: string): boolean; arrayContentDidChange(startIdx: number, removeAmt: number, addAmt: number): any[]; @@ -1324,10 +1484,10 @@ declare module Ember { enumerableContentDidChange(removing: Enumerable, adding: number): any; enumerableContentDidChange(removing: number, adding: Enumerable): any; enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; - enumerableContentWillChange(removing: number, adding: number): any[]; - enumerableContentWillChange(removing: Enumerable, adding: number): any[]; - enumerableContentWillChange(removing: number, adding: Enumerable): any[]; - enumerableContentWillChange(removing: Enumerable, adding: Enumerable): any[]; + enumerableContentWillChange(removing: number, adding: number): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; + enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: Enumerable): Enumerable; every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: any): boolean; @@ -1354,7 +1514,7 @@ declare module Ember { rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; - removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; replace(idx: number, amt: number, objects: any[]): any; reverseObjects(): any[]; setEach(key: string, value?: any): any; @@ -1363,10 +1523,10 @@ declare module Ember { slice(beginIndex?: number, endIndex?: number): any[]; some(callback: Function, target?: any): boolean; toArray(): any[]; - uniq(): any[]; + uniq(): Enumerable; unshiftObject(object: any): any; unshiftObjects(objects: any[]): any[]; - without(value: any): any[]; + without(value: any): Enumerable; '[]': any[]; '@each': EachProxy; Boolean: boolean; @@ -1375,30 +1535,30 @@ declare module Ember { lastObject: any; length: number; addObject(object: any): any; - addObjects(objects: Enumerable): any[]; + addObjects(objects: Enumerable): MutableEnumberable; removeObject(object: any): any; - removeObjects(objects: Enumerable): any[]; + removeObjects(objects: Enumerable): MutableEnumberable; addObserver: ModifyObserver; - beginPropertyChanges(): any[]; + beginPropertyChanges(): Observable; cacheFor(keyName: string): any; decrementProperty(keyName: string, decrement?: number): number; - endPropertyChanges(): any[]; + endPropertyChanges(): Observable; get(keyName: string): any; getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; incrementProperty(keyName: string, increment?: number): number; - notifyPropertyChange(keyName: string): any[]; - propertyDidChange(keyName: string): any[]; - propertyWillChange(keyName: string): any[]; - removeObserver(key: string, target: any, method: string): Observable; - removeObserver(key: string, target: any, method: Function): Observable; - set(keyName: string, value: any): any[]; - setProperties(hash: {}): any[]; + notifyPropertyChange(keyName: string): Observable; + propertyDidChange(keyName: string): Observable; + propertyWillChange(keyName: string): Observable; + removeObserver(key: string, target: any, method: string): void; + removeObserver(key: string, target: any, method: Function): void; + set(keyName: string, value: any): Observable; + setProperties(hash: {}): Observable; toggleProperty(keyName: string): any; - copy(deep: boolean): any[]; - frozenCopy(): any[]; + copy(deep: boolean): Copyable; + frozenCopy(): Copyable; } class NoneLocation extends Object { static detect(obj: any): boolean; @@ -1422,6 +1582,7 @@ declare module Ember { Creates a subclass of the Object class. **/ static extend(arguments?: CoreObjectArguments): T; + static extend(mixins? : Mixin, arguments?: CoreObjectArguments): T; /** Creates an instance of the class. @param arguments A hash containing values with which to initialize the newly instantiated object. @@ -1522,11 +1683,14 @@ declare module Ember { notifyPropertyChange(keyName: string): Observable; propertyDidChange(keyName: string): Observable; propertyWillChange(keyName: string): Observable; - removeObserver(key: string, target: {}, method: string): Observable; - removeObserver(key: string, target: {}, method: Function): Observable; + removeObserver(key: string, target: {}, method: string): void; + removeObserver(key: string, target: {}, method: Function): void; set(keyName: string, value: any): Observable; setProperties(hash: {}): Observable; - toggleProperty(keyName: string): any; + /** + Set the value of a boolean property to the opposite of its current value. + */ + toggleProperty(keyName: string): boolean; } class OrderedSet { add(obj: any): void; @@ -1596,7 +1760,7 @@ declare module Ember { serialize(model: {}, params: string[]): string; setupController(controller: Controller, model: {}): void; // ReSharper disable once InconsistentNaming - transitionTo(name: string, ...object: any[]): void; + transitionTo(name: string, ...object: any[]): EmberStates.Transition; actions: ActionsHash; } class Router extends Object { @@ -2363,9 +2527,9 @@ declare module Em { var copy: typeof Ember.copy; var create: typeof Ember.create; var debug: typeof Ember.debug; - var defineProperty: typeof defineProperty; - var deprecate: typeof deprecate; - var deprecateFunc: typeof deprecateFunc; + var defineProperty: typeof Ember.defineProperty; + var deprecate: typeof Ember.deprecate; + var deprecateFunc: typeof Ember.deprecateFunc; var destroy: typeof Ember.destroy; var empty: typeof deprecateFunc; var endPropertyChanges: typeof Ember.endPropertyChanges; @@ -2382,7 +2546,248 @@ declare module Em { var handleErrors: typeof Ember.handleErrors; var hasListeners: typeof Ember.hasListeners; var hasOwnProperty: typeof Ember.hasOwnProperty; - var immediateObserver: typeof immediateObserver; + var immediateObserver: typeof Ember.immediateObserver; + var imports: typeof Ember.imports; + var inspect: typeof Ember.inspect; + var instrument: typeof Ember.instrument; + var isArray: typeof Ember.isArray; + var isEmpty: typeof Ember.isEmpty; + var isEqual: typeof Ember.isEqual; + var isGlobalPath: typeof Ember.isGlobalPath; + var isNamespace: typeof Ember.isNamespace; + var isNone: typeof Ember.isNone; + var isPrototypeOf: typeof Ember.isPrototypeOf; + var isWatching: typeof Ember.isWatching; + var keys: typeof Ember.keys; + var listenersDiff: typeof Ember.listenersDiff; + var listenersFor: typeof Ember.listenersFor; + var listenersUnion: typeof Ember.listenersUnion; + var lookup: typeof Ember.lookup; + var makeArray: typeof Ember.makeArray; + var merge: typeof Ember.merge; + var meta: typeof Ember.meta; + var metaPath: typeof Ember.metaPath; + var mixin: typeof Ember.mixin; + var none: typeof Ember.none; + var normalizeTuple: typeof Ember.normalizeTuple; + var observer: typeof Ember.observer; + var observersFor: typeof Ember.observersFor; + var onLoad: typeof Ember.onLoad; + var oneWay: typeof Ember.oneWay; + var onError: typeof Ember.onError; + var overrideChains: typeof Ember.overrideChains; + var platform: typeof Ember.platform; + var propertyDidChange: typeof Ember.propertyDidChange; + var propertyIsEnumerable: typeof Ember.propertyIsEnumerable; + var propertyWillChange: typeof Ember.propertyWillChange; + var removeBeforeObserver: typeof Ember.removeBeforeObserver; + var removeChainWatcher: typeof Ember.removeChainWatcher; + var removeListener: typeof Ember.removeListener; + var removeObserver: typeof Ember.removeObserver; + var required: typeof Ember.required; + var rewatch: typeof Ember.rewatch; + var run: typeof Ember.run; + var runLoadHooks: typeof Ember.runLoadHooks; + var sendEvent: typeof Ember.sendEvent; + var set: typeof Ember.set; + var setMeta: typeof Ember.setMeta; + var setPath: typeof Ember.setPath; + var setProperties: typeof Ember.setProperties; + var subscribe: typeof Ember.subscribe; + var toLocaleString: typeof Ember.toLocaleString; + var toString: typeof Ember.toString; + var tryCatchFinally: typeof Ember.tryCatchFinally; + var tryFinally: typeof Ember.tryFinally; + var tryInvoke: typeof Ember.tryInvoke; + var trySet: typeof Ember.trySet; + var trySetPath: typeof Ember.trySetPath; + var typeOf: typeof Ember.typeOf; + var unwatch: typeof Ember.unwatch; + var unwatchKey: typeof Ember.unwatchKey; + var unwatchPath: typeof Ember.unwatchPath; + var uuid: typeof Ember.uuid; + var valueOf: typeof Ember.valueOf; + var warn: typeof Ember.warn; + var watch: typeof Ember.watch; + var watchKey: typeof Ember.watchKey; + var watchPath: typeof Ember.watchPath; + var watchedEvents: typeof Ember.watchedEvents; + var wrap: typeof Ember.wrap; +} + +/** + * External ambient module - to allow "import Ember = require('Ember');" to work correctly + */ + +declare module "Ember" { + + var $: typeof Ember.$; + var A: typeof Ember.A; + class ActionHandlerMixin extends Ember.ActionHandlerMixin { } + class Application extends Ember.Application { } + class Array extends Ember.Array { } + class ArrayController extends Ember.ArrayController { } + var ArrayPolyfills: typeof Ember.ArrayPolyfills; + class ArrayProxy extends Ember.ArrayProxy { } + var BOOTED: typeof Ember.BOOTED; + class Binding extends Ember.Binding { } + class Button extends Ember.Button { } + class Checkbox extends Ember.Checkbox { } + class CollectionView extends Ember.CollectionView { } + class Comparable extends Ember.Comparable { } + class Component extends Ember.Component { } + class ComputedProperty extends Ember.ComputedProperty { } + class Container extends Ember.Container { } + class ContainerView extends Ember.ContainerView { } + class Controller extends Ember.Controller { } + class ControllerMixin extends Ember.ControllerMixin { } + class Copyable extends Ember.Copyable { } + class CoreObject extends Ember.CoreObject { } + class CoreView extends Ember.CoreView { } + class DAG extends Ember.DAG { } + var DEFAULT_GETTER_FUNCTION: typeof Ember.DEFAULT_GETTER_FUNCTION; + class DefaultResolver extends Ember.DefaultResolver { } + class Deffered extends Ember.Deferred { } + class DeferredMixin extends Ember.DeferredMixin { } + class Descriptor extends Ember.Descriptor { } + var EMPTY_META: typeof Ember.EMPTY_META; + var ENV: typeof Ember.ENV; + var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; + class EachProxy extends Ember.EachProxy { } + class Enumerable extends Ember.Enumerable { } + var EnumerableUtils: typeof Ember.EnumerableUtils; + var Error: typeof Ember.Error; + class EventDispatcher extends Ember.EventDispatcher { } + class Evented extends Ember.Evented { } + var FROZEN_ERROR: typeof Ember.FROZEN_ERROR; + class Freezable extends Ember.Freezable { } + var GUID_KEY: typeof Ember.GUID_KEY; + module Handlebars { + var compile: typeof Ember.Handlebars.compile; + var get: typeof Ember.Handlebars.get; + var helper: typeof Ember.Handlebars.helper; + class helpers extends Ember.Handlebars.helpers { } + var precompile: typeof Ember.Handlebars.precompile; + var registerBoundHelper: typeof Ember.Handlebars.registerBoundHelper; + class Compiler extends Ember.Handlebars.Compiler { } + class JavaScriptCompiler extends Ember.Handlebars.JavaScriptCompiler { } + var registerHelper: typeof Ember.Handlebars.registerHelper; + var registerPartial: typeof Ember.Handlebars.registerPartial; + var K: typeof Ember.Handlebars.K; + var createFrame: typeof Ember.Handlebars.createFrame; + var Exception: typeof Ember.Handlebars.Exception; + class SafeString extends Ember.Handlebars.SafeString { } + var parse: typeof Ember.Handlebars.parse; + var print: typeof Ember.Handlebars.print; + var logger: typeof Ember.Handlebars.logger; + var log: typeof Ember.Handlebars.log; + } + class HashLocation extends Ember.HashLocation { } + class HistoryLocation extends Ember.HistoryLocation { } + var IS_BINDING: typeof Ember.IS_BINDING; + class Instrumentation extends Ember.Instrumentation { } + var K: typeof Ember.K; + var LOG_BINDINGS: typeof Ember.LOG_BINDINGS; + var LOG_STACKTRACE_ON_DEPRECATION: typeof Ember.LOG_STACKTRACE_ON_DEPRECATION; + var LOG_VERSION: typeof Ember.LOG_VERSION; + class LinkView extends Ember.LinkView { } + class Location extends Ember.Location { } + var Logger: typeof Ember.Logger; + var MANDATORY_SETTER_FUNCTION: typeof Ember.MANDATORY_SETTER_FUNCTION; + var META_KEY: typeof Ember.META_KEY; + class Map extends Ember.Map { } + class MapWithDefault extends Ember.MapWithDefault { } + class Mixin extends Ember.Mixin { } + class MutableArray extends Ember.MutableArray { } + class MutableEnumerable extends Ember.MutableEnumberable { } + var NAME_KEY: typeof Ember.NAME_KEY; + class Namespace extends Ember.Namespace { } + class NativeArray extends Ember.NativeArray { } + class NoneLocation extends Ember.NoneLocation { } + var ORDER_DEFINITION: typeof Ember.ORDER_DEFINITION; + class Object extends Ember.Object { } + class ObjectController extends Ember.ObjectController { } + class ObjectProxy extends Ember.ObjectProxy { } + class Observable extends Ember.Observable { } + class OrderedSet extends Ember.OrderedSet { } + module RSVP { + class Promise extends Ember.RSVP.Promise { } + } + class RenderBuffer extends Ember.RenderBuffer { } + class Route extends Ember.Route { } + class Router extends Ember.Router { } + class RouterDSL extends Ember.RouterDSL { } + var SHIM_ES5: typeof Ember.SHIM_ES5; + var STRINGS: typeof Ember.STRINGS; + class Select extends Ember.Select { } + class SelectOption extends Ember.SelectOption { } + class Set extends Ember.Set { } + class SortableMixin extends Ember.SortableMixin { } + class State extends Ember.State { } + class StateManager extends Ember.StateManager { } + module String { + var camelize: typeof Ember.String.camelize; + var capitalize: typeof Ember.String.capitalize; + var classify: typeof Ember.String.classify; + var dasherize: typeof Ember.String.dasherize; + var decamelize: typeof Ember.String.decamelize; + var fmt: typeof Ember.String.fmt; + var htmlSafe: typeof Ember.String.htmlSafe; + var loc: typeof Ember.String.loc; + var underscore: typeof Ember.String.underscore; + var w: typeof Ember.String.w; + } + var TEMPLATES: typeof Ember.TEMPLATES; + class TargetActionSupport extends Ember.TargetActionSupport { } + class Test extends Ember.Test { } + class TextArea extends Ember.TextArea { } + class TextField extends Ember.TextField { } + class TextSupport extends Ember.TextSupport { } + var VERSION: typeof Ember.VERSION; + class View extends Ember.View { } + class ViewTargetActionSupport extends Ember.ViewTargetActionSupport { } + var ViewUtils: typeof Ember.ViewUtils; + var addBeforeObserver: typeof Ember.addBeforeObserver; + var addListener: typeof Ember.addListener; + var addObserver: typeof Ember.addObserver; + var alias: typeof Ember.alias; + var aliasMethod: typeof Ember.aliasMethod; + var anyUnprocessedMixins: typeof Ember.anyUnprocessedMixins; + var assert: typeof Ember.assert; + var beforeObserver: typeof Ember.beforeObserver; + var beforeObserversFor: typeof Ember.beforeObserversFor; + var beginPropertyChanges: typeof Ember.beginPropertyChanges; + var bind: typeof Ember.bind; + var cacheFor: typeof Ember.cacheFor; + var canInvoke: typeof Ember.canInvoke; + var changeProperties: typeof Ember.changeProperties; + var compare: typeof Ember.compare; + var computed: typeof Ember.computed; + var config: typeof Ember.config; + var controllerFor: typeof Ember.controllerFor; + var copy: typeof Ember.copy; + var create: typeof Ember.create; + var debug: typeof Ember.debug; + var defineProperty: typeof Ember.defineProperty; + var deprecate: typeof Ember.deprecate; + var deprecateFunc: typeof Ember.deprecateFunc; + var destroy: typeof Ember.destroy; + var empty: typeof Ember.deprecateFunc; + var endPropertyChanges: typeof Ember.endPropertyChanges; + var exports: typeof Ember.exports; + var finishChains: typeof Ember.finishChains; + var flushPendingChains: typeof Ember.flushPendingChains; + var generateController: typeof Ember.generateController; + var generateGuid: typeof Ember.generateGuid; + var get: typeof Ember.get; + var getMeta: typeof Ember.getMeta; + var getPath: typeof Ember.getPath; + var getWithDefault: typeof Ember.getWithDefault; + var guidFor: typeof Ember.guidFor; + var handleErrors: typeof Ember.handleErrors; + var hasListeners: typeof Ember.hasListeners; + var hasOwnProperty: typeof Ember.hasOwnProperty; + var immediateObserver: typeof Ember.immediateObserver; var imports: typeof Ember.imports; var inspect: typeof Ember.inspect; var instrument: typeof Ember.instrument; diff --git a/es6-promise/es6-promise.d.ts b/es6-promise/es6-promise.d.ts index 271838807..4a793e540 100644 --- a/es6-promise/es6-promise.d.ts +++ b/es6-promise/es6-promise.d.ts @@ -54,12 +54,12 @@ declare module Promise { * the array passed to all can be a mixture of promise-like objects and other objects. * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. */ - function all(promises: Promise[]): Promise; + function all(promises: (R | Thenable)[]): Promise; /** * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ - function race(promises: Promise[]): Promise; + function race(promises: (R | Thenable)[]): Promise; } declare module 'es6-promise' { diff --git a/escape-latex/escape-latex-tests.ts b/escape-latex/escape-latex-tests.ts new file mode 100644 index 000000000..7a5b74dfe --- /dev/null +++ b/escape-latex/escape-latex-tests.ts @@ -0,0 +1,5 @@ +/// + +import lescape = require('escape-latex'); + +lescape("String to be escaped here #yolo"); \ No newline at end of file diff --git a/escape-latex/escape-latex.d.ts b/escape-latex/escape-latex.d.ts new file mode 100644 index 000000000..fd6f90b45 --- /dev/null +++ b/escape-latex/escape-latex.d.ts @@ -0,0 +1,9 @@ +// Type definitions for escape-latex 0.1.2 +// Project: https://github.com/dangmai/escape-latex +// Definitions by: Oliver Schneider +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'escape-latex' { + function lescape(texString: string): string; + export = lescape; +} \ No newline at end of file diff --git a/eventemitter3/eventemitter3-test.ts b/eventemitter3/eventemitter3-test.ts new file mode 100644 index 000000000..05138ab34 --- /dev/null +++ b/eventemitter3/eventemitter3-test.ts @@ -0,0 +1,65 @@ +/// +'use strict'; + +import EventEmitter = require('eventemitter3'); + +class EventEmitterTest { + v: EventEmitter; + + constructor() { + this.v = new EventEmitter(); + this.v = new EventEmitter.EventEmitter(); + this.v = new EventEmitter.EventEmitter2(); + this.v = new EventEmitter.EventEmitter3(); + } + + listeners() { + var v1: Function[] = this.v.listeners('click'); + } + + emit() { + var v1: boolean = this.v.emit('click'); + var v2: boolean = this.v.emit('click', 1); + var v3: boolean = this.v.emit('click', 1, '1'); + var v4: boolean = this.v.emit('click', 1, '1', true); + var v5: boolean = this.v.emit('click', 1, '1', true, new Date()); + } + + on() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.on('click', fn); + var v2: EventEmitter = this.v.on('click', fn, this); + } + + once() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.once('click', fn); + var v2: EventEmitter = this.v.once('click', fn, this); + } + + removeListener() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.removeListener('click', fn); + var v2: EventEmitter = this.v.removeListener('click', fn, true); + } + + removeAllListeners() { + var v1: EventEmitter = this.v.removeAllListeners('click'); + } + + off() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.off('click', fn); + var v2: EventEmitter = this.v.off('click', fn, true); + } + + addListener() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.addListener('click', fn); + var v2: EventEmitter = this.v.addListener('click', fn, this); + } + + setMaxListeners() { + var v1: EventEmitter = this.v.setMaxListeners(); + } +} diff --git a/eventemitter3/eventemitter3.d.ts b/eventemitter3/eventemitter3.d.ts new file mode 100644 index 000000000..60f6e6e93 --- /dev/null +++ b/eventemitter3/eventemitter3.d.ts @@ -0,0 +1,100 @@ +// Type definitions for EventEmitter3 0.1.6 +// Project: https://github.com/primus/eventemitter3 +// Definitions by: Yuichi Murata +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module EventEmitter3 { + export class EventEmitter { + /** + * Minimal EventEmitter interface that is molded against the Node.js + * EventEmitter interface. + * + * @constructor + * @api public + */ + constructor(); + + /** + * Return a list of assigned event listeners. + * + * @param {String} event The events that should be listed. + * @returns {Array} + * @api public + */ + listeners(event: string): Function[]; + + /** + * Emit an event to all registered event listeners. + * + * @param {String} event The name of the event. + * @returns {Boolean} Indication if we've emitted an event. + * @api public + */ + emit(event: string, ...args: any[]): boolean; + + /** + * Register a new EventListener for the given event. + * + * @param {String} event Name of the event. + * @param {Functon} fn Callback function. + * @param {Mixed} context The context of the function. + * @api public + */ + on(event: string, fn: Function, context?: any): EventEmitter; + + /** + * Add an EventListener that's only called once. + * + * @param {String} event Name of the event. + * @param {Function} fn Callback function. + * @param {Mixed} context The context of the function. + * @api public + */ + once(event: string, fn: Function, context?: any): EventEmitter; + + /** + * Remove event listeners. + * + * @param {String} event The event we want to remove. + * @param {Function} fn The listener that we need to find. + * @param {Boolean} once Only remove once listeners. + * @api public + */ + removeListener(event: string, fn: Function, once?: boolean): EventEmitter; + + /** + * Remove all listeners or only the listeners for the specified event. + * + * @param {String} event The event want to remove all listeners for. + * @api public + */ + removeAllListeners(event: string): EventEmitter; + + // + // Alias methods names because people roll like that. + // + off(event: string, fn: Function, once?: boolean): EventEmitter; + addListener(event: string, fn: Function, context?: any): EventEmitter; + + // + // This function doesn't apply anymore. + // + setMaxListeners(): EventEmitter; + } + export module EventEmitter { + // + // Expose the module. + // + export class EventEmitter extends EventEmitter3.EventEmitter {} + export class EventEmitter2 extends EventEmitter3.EventEmitter {} + export class EventEmitter3 extends EventEmitter3.EventEmitter {} + } +} + +declare module 'eventemitter3' { + // + // Expose the module. + // + class EventEmitter extends EventEmitter3.EventEmitter {} + export = EventEmitter; +} diff --git a/expect.js/expect.js-commonjs-tests.ts b/expect.js/expect.js-commonjs-tests.ts new file mode 100644 index 000000000..e95b870d9 --- /dev/null +++ b/expect.js/expect.js-commonjs-tests.ts @@ -0,0 +1,123 @@ +/// + +import expect = require("expect.js"); + +function test_expect() { + expect(); + expect(1); + expect(true); + expect({}); + expect(0); +} + +function test_expect_properties() { + expect(0).be.an; + expect(0).have.own; + expect(0).not.be.an; + expect(0).not.have.own; + expect(0).not.include; + expect(0).not.only.have.own; + expect(0).not.to.be; + expect(0).not.to.have.own; + expect(0).not.to.include; + expect(0).not.to.only.have.own; + expect(0).only.have.own; + expect(0).to.be.an; + expect(0).to.have.own; + expect(0).to.include; + expect(0).to.not.be.an; + expect(0).to.not.have.own; + expect(0).to.not.include; + expect(0).to.not.only.have.own; + expect(0).to.only.have.own; + expect(0).be; +} + +function test_ok() { + expect(true).to.be.ok(); +} + +function test_be() { + expect(1).to.be(1); +} + +function test_equal() { + expect(1).to.equal(1); +} + +function test_eql() { + expect({ a: 'b' }).to.eql({ a: 'b' }); +} + +function test_a() { + // string + expect(5).to.be.a('number'); + expect([]).to.be.an('array'); + + // constructors + expect(5).to.be.a(Number); + expect([]).to.be.an(Array); +} + +function test_match() { + expect('1.2.3').to.match(/[0-9]+\.[0-9]+\.[0-9]+/); +} + +function test_contain() { + // string + expect('hello world').to.contain('world'); + expect('hello world').to.string('world'); + // any + expect([1, 2]).to.contain(1); + expect([1, 2]).to.string(1); +} + +function test_length() { + expect([1,2,3]).to.have.length(3); +} + +function test_empty() { + expect([]).to.be.empty(); +} + +function test_property() { + expect(window).to.have.property('expect'); + expect(window).to.have.property('expect', expect); +} + +function test_key() { + expect({ a: 'b' }).to.have.key('a'); + expect({ a: 'b' }).to.include.key('a'); + expect({ a: 'b', c: 'd' }).to.only.have.keys('a', 'c'); + expect({ a: 'b', c: 'd' }).to.only.have.keys(['a', 'c']); + expect({ a: 'b', c: 'd' }).to.not.only.have.key('a'); +} + +function test_throwException() { + var fn = () => {}; + expect(fn).to.throwError(); + expect(fn).to.throwException(function (e) { + expect(e).to.be.a(SyntaxError); + }); + expect(fn).to.throwException(/matches the exception message/); + expect(fn).to.not.throwException(); +} + +function test_within() { + expect(1).to.be.within(0, Infinity); +} + +function test_greaterThan() { + expect(5).to.be.greaterThan(3); + expect(3).to.be.above(0); +} + +function test_lessThan() { + expect(1).to.be.lessThan(3); + expect(0).to.be.below(3); +} + +function test_fail() { + expect().fail(); + expect().fail('Custom failure message'); +} \ No newline at end of file diff --git a/expect.js/expect.js-tests.ts b/expect.js/expect.js-tests.ts index 098df13bb..7b19219bb 100644 --- a/expect.js/expect.js-tests.ts +++ b/expect.js/expect.js-tests.ts @@ -28,7 +28,7 @@ function test_expect_properties() { expect(0).to.not.include; expect(0).to.not.only.have.own; expect(0).to.only.have.own; - expect(0).be + expect(0).be; } function test_ok() { @@ -118,4 +118,4 @@ function test_lessThan() { function test_fail() { expect().fail(); expect().fail('Custom failure message'); -} +} \ No newline at end of file diff --git a/expect.js/expect.js.d.ts b/expect.js/expect.js.d.ts index 8e5cfe142..2db884b97 100644 --- a/expect.js/expect.js.d.ts +++ b/expect.js/expect.js.d.ts @@ -214,3 +214,9 @@ declare module Expect { own: Assertion; } } + +declare module "expect.js" { + + export = expect; + +} \ No newline at end of file diff --git a/flot/jquery.flot.d.ts b/flot/jquery.flot.d.ts index 9ea862c5c..c179d2f03 100644 --- a/flot/jquery.flot.d.ts +++ b/flot/jquery.flot.d.ts @@ -107,7 +107,7 @@ declare module jquery.flot { ticks?: any; // null or number or ticks array or (fn: axis -> ticks array) tickSize?: any; // number or array minTickSize?: any; // number or array - tickFormatter?: (t: number) => string; // (fn: number, object -> string) or string + tickFormatter?: (t: number, a?: axis) => string; // (fn: number, object -> string) or string tickDecimals?: number; labelWidth?: number; diff --git a/fluxxor/fluxxor-test.ts b/fluxxor/fluxxor-test.ts new file mode 100644 index 000000000..87e978248 --- /dev/null +++ b/fluxxor/fluxxor-test.ts @@ -0,0 +1,164 @@ +/// + +import React = require('react'); +import Fluxxor = require('fluxxor'); + +class DispatcherTest { + v: Fluxxor.Dispatcher; + + constructor() { + var stores: Fluxxor.Store[]; + this.v = new Fluxxor.Dispatcher(stores); + } + + addStore() { + var store: Fluxxor.Store; + var v1: void = this.v.addStore('mystore', store); + } + + dispatch() { + var fn = () => console.log(1); + var v1: void = this.v.dispatch(fn); + } + + doDispatchLoop() { + var fn = () => console.log(1); + var v1: void = this.v.doDispatchLoop(fn); + } + + waitForStores() { + var store: Fluxxor.Store; + var fn = () => console.log(1); + var v1: void = this.v.waitForStores(store, ['mystore1', 'mystore2'], fn); + } +} + +class FluxTest { + v: Fluxxor.Flux; + + constructor() { + var stores: any; + var actions: any; + this.v = new Fluxxor.Flux(stores, actions); + } + + props() { + var stores: any = this.v.stores; + var actions: any = this.v.actions; + } + + addActions() { + var actions: any; + var v1: void = this.v.addActions(actions); + } + + addAction() { + var fn = () => console.log(1); + + // first form + var v1: void = this.v.addAction('action1', fn); + var v2: void = this.v.addAction('action1', 'action2', fn); + + // second form + var v3: void = this.v.addAction(['action1'], fn); + var v4: void = this.v.addAction(['action1','action2'], fn); + } + + store() { + var store1: any = this.v.store('mystore'); + } + + addStore() { + var store: Fluxxor.Store; + var v1: void = this.v.addStore('mystore', store); + } + + addStores() { + var stores: any; + var v1: void = this.v.addStores(stores); + } +} + +class StoreTest { + v: Fluxxor.Store; + + bindActions() { + var fn = () => console.log(1); + + // first form + var v1: void = this.v.bindActions('action1', fn); + var v2: void = this.v.bindActions( + 'action1', fn, + 'action2', fn + ); + + // second form + var v3: void = this.v.bindActions([ + 'action1', fn, + 'action2', fn, + ]); + } + + waitFor() { + var fn = () => console.log(1); + var v1: void = this.v.waitFor(['mystore1','mystore2'], fn); + } +} + +class ContextTest { + v: Fluxxor.Context; + + props() { + var v1: Fluxxor.Flux = this.v.flux; + } +} + +class FluxMixinTest { + v: Fluxxor.FluxMixin; + + constructor() { + this.v = Fluxxor.FluxMixin(React); + } + + getFlux() { + var v1: Fluxxor.Flux = this.v.getFlux(); + } +} + +class FluxChildMixinTest { + v: Fluxxor.FluxChildMixin; + + constructor() { + this.v = Fluxxor.FluxChildMixin(React); + } + + getFlux() { + var v1: Fluxxor.Flux = this.v.getFlux(); + } +} + +class StoreWatchMixinTest { + v: Fluxxor.StoreWatchMixin; + + constructor() { + this.v = Fluxxor.StoreWatchMixin('store1'); + this.v = Fluxxor.StoreWatchMixin('store1','store2'); + this.v = Fluxxor.StoreWatchMixin('store1','store2','store3'); + } + + getStateFromFlux() { + var v1: StoreState = this.v.getStateFromFlux(); + } +} +new StoreWatchMixinTest(); +new StoreWatchMixinTest<{ a: Fluxxor.Store; }>(); +new StoreWatchMixinTest<{ b: Fluxxor.Store; }>(); + +function createStoreTest() { + var spec: Fluxxor.StoreSpec; + var Class: Fluxxor.StoreClass = Fluxxor.createStore(spec); + var store1: any = new Class(); + var store2: any = new Class({value: 1}); +} + +var versionTest: string = Fluxxor.version; diff --git a/fluxxor/fluxxor.d.ts b/fluxxor/fluxxor.d.ts new file mode 100644 index 000000000..e857a6b15 --- /dev/null +++ b/fluxxor/fluxxor.d.ts @@ -0,0 +1,70 @@ +// Type definitions for Fluxxor 1.5.2 +// Project: https://github.com/BinaryMuse/fluxxor +// Definitions by: Yuichi Murata +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module Fluxxor { + class Dispatcher { + constructor(stores: any); + addStore(name: string, store: Store): void; + dispatch(action: Function): void; + doDispatchLoop(action: Function): void; + waitForStores(store: Store, stores: string[], fn: Function): void; + } + + class Flux extends EventEmitter3.EventEmitter { + constructor(stores: any, actions: any); + addActions(actions: any): void; + addAction(...args: Array): void; + addAction(names: string[], action: Function): void; + store(name: string): any; + addStore(name: string, store: Store): void; + addStores(stores: any): void; + stores: any; + actions: any; + } + + interface Store extends EventEmitter3.EventEmitter { + bindActions(...args: Array): void; + bindActions(args: Array): void; + waitFor(stores: string[], fn: Function): void; + } + + interface StoreSpec { + initialize?(instance?: any, options?: {}): void; + actions?: any; + } + + interface StoreClass { + new (options?: {}): any; + } + + interface Context { + flux: Flux; + } + + interface FluxMixin { + getFlux(): Flux; + } + + interface FluxChildMixin { + getFlux(): Flux; + } + + interface StoreWatchMixin { + getStateFromFlux(): StoreState; + } + + function FluxMixin(React: React.Exports): FluxMixin; + function FluxChildMixin(React: React.Exports): FluxChildMixin; + function StoreWatchMixin(...storeNames: string[]): StoreWatchMixin; + function createStore(spec: StoreSpec): StoreClass; + var version: string; +} + +declare module 'fluxxor' { + export = Fluxxor; +} diff --git a/google.picker/google.picker-tests.ts b/google.picker/google.picker-tests.ts new file mode 100644 index 000000000..280765354 --- /dev/null +++ b/google.picker/google.picker-tests.ts @@ -0,0 +1,18 @@ +/// + +var createPicker = () => { + var picker = new google.picker.PickerBuilder() + .addView(new google.picker.DocsUploadView()) + .setOAuthToken("accessToken") + .setDeveloperKey("developerKey") + .setCallback((data:any) => { + var url = "nothing"; + if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) { + var doc = data[google.picker.Response.DOCUMENTS][0]; + url = doc[google.picker.Document.URL]; + } + }) + .setOrigin("origin") + .build(); + picker.setVisible(true); +}; diff --git a/google.picker/google.picker.d.ts b/google.picker/google.picker.d.ts new file mode 100644 index 000000000..6d0d5a0e3 --- /dev/null +++ b/google.picker/google.picker.d.ts @@ -0,0 +1,224 @@ +// Type definitions for Google Picker API +// Project: https://developers.google.com/picker/ +// Definitions by: grapswiz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module google { + module picker { + export class PickerBuilder { + constructor(); + + // Add a View to the navigation pane. + addView(viewOrId:any):PickerBuilder; + + // Add a ViewGroup to the top-level navigation pane. + addViewGroup(viewGroup:any):PickerBuilder; + + // Disable a picker feature. + disableFeature(feature:string):PickerBuilder; + + // Enable a picker feature. + enableFeature(feature:string):PickerBuilder; + + // Get the relay URL, used for gadgets.rpc. + getRelayUrl():string; + + // Get the dialog title. + getTitle():string; + + // Disable the title bar from being shown. To re-enable, call setTitle with a non-empty title or undefined. + hideTitleBar():PickerBuilder; + + // Check if a picker Feature is enabled. + isFeatureEnabled(feature:string):boolean; + + // Sets the Google Drive App ID needed to allow application to access the user's files via the Google Drive API. + setAppId(appId:string):PickerBuilder; + + // Set the callback method called when the user picks and item (or items), or cancels. The callback method receives a single callback object. The structure of the callback object is described in the JSON Guide. + setCallback(method:Function):PickerBuilder; + + // Sets the Browser API key obtained from Google Developers Console. See the Developer's Guide for details on how to obtain the Browser API key. + setDeveloperKey(key:string):PickerBuilder; + + // Set the document. + setDocument(document:string):PickerBuilder; + + // ISO 639 language code. If the language is not supported, en-US is used. This method provides an alternative to setting the locale at google.load() time. See the Developer's Guide for a list of supported locales. + setLocale(locale:string):PickerBuilder; + + // Sets an OAuth token to use for authenticating the current user. Depending on the scope of the token, only certain views will display data. Valid scopes are Google Docs, Drive, Photos, YouTube. + setOAuthToken(token:string):PickerBuilder; + + // Sets the origin of picker dialog. The origin should be set to the window.location.protocol + '//' + window.location.host of the top-most page, if your application is running in an iframe. + setOrigin(origin:string):PickerBuilder; + + // Set the relay URL, used for gadgets.rpc. + setRelayUrl(url:string):PickerBuilder; + + // Set the list of MIME types which will be selectable. Use commas to separate MIME types if more than one is required. + setSelectableMimeTypes(type:string):PickerBuilder; + + // Set the preferred dialog size. The dialog will be auto-centered. It has a minimum size of (566,350) and a maximum size of (1051,650). + setSize():PickerBuilder; + + // Set the dialog title. + setTitle(title:string):PickerBuilder; + + // Specify an album ID for photo uploads. See Picasa Web Albums Data API documentation for more information about albums. + setUploadToAlbumId(albumId:string):PickerBuilder; + + // Returns the URI generated by this builder. + toUri():string; + + // Construct the Picker object. The Picker object is returned. + build():Picker; + } + + /** + * Picker is the top level object representing the UI action with the user. These objects are not created directly, but instead use the PickerBuilder object. + */ + export interface Picker { + isVisible(): boolean; + setCallback():Picker; + setRelayUrl(url:string):Picker; + setVisible(visible:boolean):Picker; + } + + /** + * Use DocsUploadView to upload documents to Google Drive. + */ + export class DocsUploadView { + constructor(); + + // Allows the user to select a folder in Google Drive to upload to. + setIncludeFolders(included:boolean):DocsUploadView; + + // Sets the upload destination to the specified folder. This overrides ".setIncludeFolders" to false. + setParent(parentId:string):DocsUploadView; + } + + /** + * DocsView is a subclass of View that can be used for Google Drive views. + */ + export class DocsView { + // Constructor. The ViewId must be one of the Google Drive views. Default is ViewId.DOCS. + constructor(viewId?:string); + + // Show folders in the view items. + setIncludeFolders(included:boolean):DocsView; + + // Allows the user to select a folder in Google Drive. + setSelectFolderEnabled(enabled:boolean):DocsView; + + // Selects which mode the view will use to display the documents. + setMode(mode:string):DocsView; + + // Filters the documents based on whether they are owned by the user, or shared with the user. + setOwnedByMe(me?:boolean):DocsView; + + // Sets the initial parent folder to display. + setParent(parentId:string):DocsView; + + // Filters the documents based on whether they are starred by the user. + setStarred(starred:boolean):DocsView; + } + + /** + * DocsViewMode is an enumerated type for displaying data within a DocsView. Use these values in calls to DocsView.setMode. + */ + export var DocsViewMode:{ + // Display documents in a thumbnail grid. + GRID: string; + // Display documents in a detailed list. + LIST: string; + }; + + export var Feature:{ + // Show only documents owned by the user when showing items from Google Drive. + MINE_ONLY: string; + + // Allow user to choose more than one item. + MULTISELECT_ENABLED: string; + + // Hide the navigation pane. If the navigation pane is hidden, users can only select from the first view chosen. + NAV_HIDDEN: string; + + // For photo uploads, controls whether per-photo selection (as opposed to per-album) selection is enabled. + SIMPLE_UPLOAD_ENABLED: string; + }; + + export var ViewId:{ + DOCS: string; + DOCS_IMAGES: string; + DOCS_IMAGES_AND_VIDEOS: string; + DOCS_VIDEOS: string; + DOCUMENTS: string; + DRAWINGS: string; + FOLDERS: string; + FORMS: string; + IMAGE_SEARCH: string; + MAPS: string; + PDFS: string; + PHOTOS: string; + PHOTO_ALBUMS: string; + PHOTO_UPLOAD: string; + PRESENTATIONS: string; + RECENTLY_PICKED: string; + SPREADSHEETS: string; + VIDEO_SEARCH: string; + WEBCAM: string; + YOUTUBE: string; + }; + + export var Action:{ + CANCEL: string; + PICKED: string; + }; + + /** + * Document is an enumerated type used to convey information about a specific picked item. Only fields which are relevant to the selected item are returned. This value will be in the Response.DOCUMENTS field in the callback data. + */ + export var Document:{ + ADDRESS_LINES: string; + AUDIENCE: string; + DESCRIPTION: string; + DURATION: string; + EMBEDDABLE_URL: string; + ICON_URL: string; + ID: string; + IS_NEW: string; + LAST_EDITED_UTC: string; + LATITUDE: string; + LONGITUDE: string; + MIME_TYPE: string; + NAME: string; + NUM_CHILDREN: string; + PARENT_ID: string; + PHONE_NUMBERS: string; + SERVICE_ID: string; + THUMBNAILS: string; + TYPE: string; + URL: string; + }; + + /** + * Response is an enumerated type used to convey information about the user's picked items. + */ + export var Response:{ + ACTION: string; + DOCUMENTS: string; + PARENTS: string; + VIEW: string; + }; + + export var Type:{ + ALBUM: string; + DOCUMENT: string; + LOCATION: string; + PHOTO: string; + URL: string; + VIDEO: string; + }; + } +} \ No newline at end of file diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts index d9d53ab2b..222faec1d 100644 --- a/google.visualization/google.visualization.d.ts +++ b/google.visualization/google.visualization.d.ts @@ -722,6 +722,49 @@ declare module google { width?: number; } + //#endregion + //#region AnnotationChart + + // https://developers.google.com/chart/interactive/docs/gallery/annotationchart + export class AnnotationChart extends CoreChartBase + { + draw(data: DataTable, options: AnnotationChartOptions): void; + draw(data: DataView, options: AnnotationChartOptions): void; + setVisibleChartRange(start: Date, end: Date): void; + getVisibleChartRange(): {start: Date; end: Date }; + hideDataColumns(columnIndexes: number | number[]): void; + showDataColumns(columnIndexes: number | number[]): void; + } + + // https://developers.google.com/chart/interactive/docs/gallery/annotationchart#Configuration_Options + export interface AnnotationChartOptions + { + allowHtml?: boolean; + allValuesSuffix?: string; + annotationsWidth?: number; + colors?: string[]; + dateFormat?: string; + displayAnnotations?: boolean; + displayAnnotationsFilter?: boolean; + displayDateBarSeparator?: boolean; + displayExactValues?: boolean; + displayLegendDots?: boolean; + displayLegendValues?: boolean; + displayRangeSelector?: boolean; + displayZoomButtons?: boolean; + fill?: number; + legendPosition?: string; + max?: number; + min?: number; + numberFormats?: any; + scaleColumns?: number[]; + scaleFormat?: string; + scaleType?: string; + thickness?: number; + zoomEndTime?: Date; + zoomStartTime?: Date; + } + //#endregion //#region SteppedAreaChart diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 7de19d016..baea9dcfb 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -790,6 +790,22 @@ declare module grunt { */ registerMultiTask(taskName: string, taskFunction: Function): void registerMultiTask(taskName: string, taskDescription: string, taskFunction: Function): void + + /** + * Check with the name, if a task exists in the registered tasks. + * @param name The task name to check. + * @since 0.4.5 + */ + exists(name: string): boolean; + + /** + * Rename a task. This might be useful if you want to override the default behavior of a task, while retaining the old name. + * Note that if a task has been renamed, the this.name and this.nameArgs properties will change accordingly. + * @see ITask + * @param oldname The previous name of the task. + * @param newname The new name for the task. + */ + renameTask(oldname: string, newname: string): void } /** diff --git a/gsap/Core.d.ts b/gsap/Core.d.ts new file mode 100644 index 000000000..94ad72d63 --- /dev/null +++ b/gsap/Core.d.ts @@ -0,0 +1,184 @@ +// Type definitions for GSAP v1.16.0 +// Project: http://greensock.com/ +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class Animation { + /** Base class for all TweenLite, TweenMax, TimelineLite, and TimelineMax classes, providing core methods/properties/functionality, but there is no reason to create an instance of this class directly. */ + constructor(duration?: number, vars?: any); + + /** A place to store any data you want (initially populated with vars.data if it exists). */ + data: any; + + /** [Read-only] Parent timeline. */ + timeline: SimpleTimeLine; + + /** The vars object passed into the constructor which stores configuration variables like onComplete, onUpdate, etc. */ + vars: any; + + /** Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin. */ + delay(): number; + delay(value: number): Animation; + + /** Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + duration(): number; + duration(value: number): Animation; + + /** Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback. */ + eventCallback(type: string): Function; + eventCallback(type: string, callback: Function, params?: any[], scope?: any): Animation; + + /** Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. */ + invalidate(): Animation; + + /** Indicates whether or not the animation is currently active (meaning the virtual playhead is actively moving across this instance's time span and it is not paused, nor are any of its ancestor timelines). */ + isActive(): boolean; + + /** Kills the animation entirely or in part depending on the parameters. */ + kill(vars?: any, target?: any): Animation; + + /** Pauses the instance, optionally jumping to a specific time. */ + pause(atTime?: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the animation's paused state which indicates whether or not the animation is currently paused. */ + paused(): boolean; + paused(value: boolean): Animation; + + /** Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is). */ + play(from?: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + progress(): number; + progress(value: number, suppressEvents?: boolean): Animation; + + /** Restarts and begins playing forward from the beginning. */ + restart(includeDelay?: boolean, suppressEvents?: boolean): Animation; + + /** Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. */ + resume(from?: any, suppressEvents?: boolean): Animation; + + /** Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease. */ + reverse(from?: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards. */ + reversed(): boolean; + reversed(value: boolean): Animation; + + /** Jumps to a specific time without affecting whether or not the instance is paused or reversed. */ + seek(time: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined). */ + startTime(): number; + startTime(value: number): Animation; + + /** Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration. */ + time(): number; + time(value: number, suppressEvents?: boolean): Animation; + + /** Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. */ + timeScale(): number; + timeScale(value: number): Animation; + + /** Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + totalDuration(): number; + totalDuration(value: number): Animation; + + /** Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + totalProgress(): number; + totalProgress(value: number, suppressEvents?: boolean): Animation; + + /** Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax). */ + totalTime(): number; + totalTime(time: number, suppressEvents?: boolean): Animation; +} + +declare class SimpleTimeLine extends Animation { + /** SimpleTimeline is the base class for TimelineLite and TimelineMax, providing the most basic timeline functionality and it is used for the root timelines in TweenLite but is only intended for internal use in the GreenSock tweening platform. It is meant to be very fast and lightweight. */ + constructor(vars?: any); + + /** If true, child tweens/timelines will be removed as soon as they complete. */ + autoRemoveChildren: boolean; + + /** Controls whether or not child tweens/timelines are repositioned automatically (changing their startTime) in order to maintain smooth playback when properties are changed on-the-fly. */ + smoothChildTiming: boolean; + + /** Adds a TweenLite, TweenMax, TimelineLite, or TimelineMax instance to the timeline at a specific time. */ + add(child: any, position?: any, align?: string, stagger?: number): SimpleTimeLine; + + /** renders */ + render(time: number, suppressEvents?: boolean, force?: boolean): SimpleTimeLine; + + // INHERITANCE FROM ANIMATION + + /** Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin. */ + delay(): number; + delay(value: number): SimpleTimeLine; + + /** Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + duration(): number; + duration(value: number): SimpleTimeLine; + + /** Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback. */ + eventCallback(type: string): Function; + eventCallback(type: string, callback: Function, params?: any[], scope?: any): SimpleTimeLine; + + /** Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. */ + invalidate(): SimpleTimeLine; + + /** Kills the animation entirely or in part depending on the parameters. */ + kill(vars?: any, target?: any): SimpleTimeLine; + + /** Pauses the instance, optionally jumping to a specific time. */ + pause(atTime?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the animation's paused state which indicates whether or not the animation is currently paused. */ + paused(): boolean; + paused(value: boolean): SimpleTimeLine; + + /** Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is). */ + play(from?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + progress(): number; + progress(value: number, suppressEvents?: boolean): SimpleTimeLine; + + /** Restarts and begins playing forward from the beginning. */ + restart(includeDelay?: boolean, suppressEvents?: boolean): SimpleTimeLine; + + /** Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. */ + resume(from?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease. */ + reverse(from?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards. */ + reversed(): boolean; + reversed(value: boolean): SimpleTimeLine; + + /** Jumps to a specific time without affecting whether or not the instance is paused or reversed. */ + seek(time: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined). */ + startTime(): number; + startTime(value: number): SimpleTimeLine; + + /** Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration. */ + time(): number; + time(value: number, suppressEvents?: boolean): SimpleTimeLine; + + /** Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. */ + timeScale(): number; + timeScale(value: number): SimpleTimeLine; + + /** Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + totalDuration(): number; + totalDuration(value: number): SimpleTimeLine; + + /** Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + totalProgress(): number; + totalProgress(value: number, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax). */ + totalTime(): number; + totalTime(time: number, suppressEvents?: boolean): SimpleTimeLine; +} \ No newline at end of file diff --git a/gsap/Ease.d.ts b/gsap/Ease.d.ts new file mode 100644 index 000000000..26689f438 --- /dev/null +++ b/gsap/Ease.d.ts @@ -0,0 +1,11 @@ +// Type definitions for GSAP v1.16.0 +// Project: http://greensock.com/ +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class Ease { + constructor(func?: Function, extraParams?: any[], type?: number, power?: number); + + /** Translates the tween's progress ratio into the corresponding ease ratio. */ + getRatio(p: number): number; +} \ No newline at end of file diff --git a/gsap/TweenLite.d.ts b/gsap/TweenLite.d.ts new file mode 100644 index 000000000..ef535e189 --- /dev/null +++ b/gsap/TweenLite.d.ts @@ -0,0 +1,130 @@ +// Type definitions for GSAP v1.16.0 +// Project: http://greensock.com/ +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare class TweenLite { + constructor(target: any, duration: number, vars: any); + + /** Provides An easy way to change the default easing equation. */ + static defaultEase: Ease; + + /** Provides An easy way to change the default overwrite mode. */ + static defaultOverwrite: string; + + /** The selector engine (like jQuery) that should be used when a tween receives a string as its target, like TweenLite.to("#myID", 1, {x:"100px"}). */ + static selector: (query: string) => any; + + /** [READ-ONLY] Target object (or array of objects) whose properties the tween affects. */ + target: any; + + /** The object that dispatches a "tick" event each time the engine updates, making it easy for you to add your own listener(s) to run custom logic after each update (great for game developers). */ + static ticker: any; + + /** Provides a simple way to call a function after a set amount of time (or frames). */ + static delayedCall(delay: number, callback: Function, params?: any[], scope?: any, useFrames?: boolean): TweenLite; + + /** Static method for creating a TweenLite instance that tweens backwards - you define the BEGINNING values and the current values are used as the destination values which is great for doing things like animating objects onto the screen because you can set them up initially the way you want them to look at the end of the tween and then animate in from elsewhere. */ + static from(target: any, duration: number, vars: any): TweenLite; + + /** Static method for creating a TweenLite instance that allows you to define both the starting and ending values (as opposed to to() and from() tweens which are based on the target's current values at one end or the other). */ + static fromTo(target: any, duration: number, fromVars: any, toVars: any): TweenLite; + + /** Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes. */ + static getTweensOf(target: any, onlyActive?: boolean): TweenLite[]; + + /** [override] Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. */ + invalidate(): TweenLite; + + /** Immediately kills all of the delayedCalls to a particular function. */ + static killDelayedCallsTo(func: Function): void; + + /** Kills all the tweens (or specific tweening properties) of a particular object or delayedCalls to a particular function. */ + static killTweensOf(target: any, onlyActive?: boolean, vars?: any): void; + + /** Permits you to control what happens when too much time elapses between two ticks (updates) of the engine, adjusting the core timing mechanism to compensate and avoid "jumps". */ + static lagSmoothing(threshold: number, adjustedLag: number): void; + + /** Forces a render of all active tweens which can be useful if, for example, you set up a bunch of from() tweens and then you need to force an immediate render (even of "lazy" tweens) to avoid a brief delay before things render on the very next tick. */ + static render(): void; + + /** Immediately sets properties of the target accordingly - essentially a zero-duration to() tween with a more intuitive name. */ + static set(target: any, vars: any): TweenLite; + + /** Static method for creating a TweenLite instance that animates to the specified destination values (from the current values). */ + static to(target: any, duration: number, vars: any): TweenLite; + + // INHERITANCE FROM ANIMATION + + /** Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin. */ + delay(): number; + delay(value: number): TweenLite; + + /** Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + duration(): number; + duration(value: number): TweenLite; + + /** Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback. */ + eventCallback(type: string): Function; + eventCallback(type: string, callback: Function, params?: any[], scope?: any): TweenLite; + + /** Kills the animation entirely or in part depending on the parameters. */ + kill(vars?: any, target?: any): TweenLite; + + /** Pauses the instance, optionally jumping to a specific time. */ + pause(atTime?: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the animation's paused state which indicates whether or not the animation is currently paused. */ + paused(): boolean; + paused(value: boolean): TweenLite; + + /** Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is). */ + play(from?: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + progress(): number; + progress(value: number, suppressEvents?: boolean): TweenLite; + + /** Restarts and begins playing forward from the beginning. */ + restart(includeDelay?: boolean, suppressEvents?: boolean): TweenLite; + + /** Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. */ + resume(from?: any, suppressEvents?: boolean): TweenLite; + + /** Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease. */ + reverse(from?: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards. */ + reversed(): boolean; + reversed(value: boolean): TweenLite; + + /** Jumps to a specific time without affecting whether or not the instance is paused or reversed. */ + seek(time: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined). */ + startTime(): number; + startTime(value: number): TweenLite; + + /** Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration. */ + time(): number; + time(value: number, suppressEvents?: boolean): TweenLite; + + /** Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. */ + timeScale(): number; + timeScale(value: number): TweenLite; + + /** Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + totalDuration(): number; + totalDuration(value: number): TweenLite; + + /** Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + totalProgress(): number; + totalProgress(value: number, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax). */ + totalTime(): number; + totalTime(time: number, suppressEvents?: boolean): TweenLite; +} \ No newline at end of file diff --git a/gsap/gsap-tests.ts b/gsap/gsap-tests.ts new file mode 100644 index 000000000..e1740127b --- /dev/null +++ b/gsap/gsap-tests.ts @@ -0,0 +1,8 @@ +/// + +var tween = TweenLite + .to(document.getElementById('some-div'), 1, { + width: '200px', + height: '200px' + }) + .seek(0.5); \ No newline at end of file diff --git a/gulp-concat/gulp-concat-tests.ts b/gulp-concat/gulp-concat-tests.ts new file mode 100644 index 000000000..a2a475b97 --- /dev/null +++ b/gulp-concat/gulp-concat-tests.ts @@ -0,0 +1,23 @@ +/// +/// + +import gulp = require("gulp"); +import concat = require("gulp-concat"); + +gulp.task("concat:simple", () => { + gulp.src(["file*.txt"]) + .pipe(concat("file.txt")) + .pipe(gulp.dest("build")); +}); + +gulp.task("concat:newLine", () => { + gulp.src(["file*.txt"]) + .pipe(concat("file.txt", { newLine: ";" })) + .pipe(gulp.dest("build")); +}); + +gulp.task("concat:vinyl", () => { + gulp.src(["file*.txt"]) + .pipe(concat({ path: "file.txt", stat: { mode: 0666 } })) + .pipe(gulp.dest("build")); +}); diff --git a/gulp-concat/gulp-concat.d.ts b/gulp-concat/gulp-concat.d.ts new file mode 100644 index 000000000..cad21c303 --- /dev/null +++ b/gulp-concat/gulp-concat.d.ts @@ -0,0 +1,42 @@ +// Type definitions for gulp-concat +// Project: http://github.com/wearefractal/gulp-concat +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-concat" { + + interface IOptions { + newLine: string; + } + + interface IFsStats { + dev?: number; + ino?: number; + mode?: number; + nlink?: number; + uid?: number; + gid?: number; + rdev?: number; + size?: number; + blksize?: number; + blocks?: number; + atime?: Date; + mtime?: Date; + ctime?: Date; + } + + interface IVinylOptions { + cwd?: string; + base?: string; + path?: string; + stat?: IFsStats; + contents?: NodeJS.ReadableStream | Buffer; + } + + function concat(filename: string, options?: IOptions): NodeJS.ReadWriteStream; + function concat(options: IVinylOptions): NodeJS.ReadWriteStream; + + export = concat; +} diff --git a/gulp-flatten/gulp-flatten-tests.ts b/gulp-flatten/gulp-flatten-tests.ts new file mode 100644 index 000000000..ee5622564 --- /dev/null +++ b/gulp-flatten/gulp-flatten-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import gulp = require("gulp"); +import flatten = require("gulp-flatten"); + +gulp.task("flatten:simple", () => { + gulp.src(["files/**/*.txt"]) + .pipe(flatten()) + .pipe(gulp.dest("build")); +}); + +gulp.task("flatten:newPath", () => { + gulp.src(["files/**/*.txt"]) + .pipe(flatten({ newPath: "new/path" })) + .pipe(gulp.dest("build")); +}); diff --git a/gulp-flatten/gulp-flatten.d.ts b/gulp-flatten/gulp-flatten.d.ts new file mode 100644 index 000000000..ccd9cedf1 --- /dev/null +++ b/gulp-flatten/gulp-flatten.d.ts @@ -0,0 +1,17 @@ +// Type definitions for gulp-flatten +// Project: https://github.com/armed/gulp-flatten +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-flatten" { + + interface IOptions { + newPath: string; + } + + function flatten(options?: IOptions): NodeJS.ReadWriteStream; + + export = flatten; +} diff --git a/gulp-inject/gulp-inject-tests.ts b/gulp-inject/gulp-inject-tests.ts new file mode 100644 index 000000000..804e6f9b5 --- /dev/null +++ b/gulp-inject/gulp-inject-tests.ts @@ -0,0 +1,41 @@ +/// +/// + +import gulp = require("gulp"); +import inject = require("gulp-inject"); + +gulp.task("inject:simple", () => { + gulp.src("src/index.html") + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }))) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:relative", () => { + gulp.src(["src/index.html"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { relative: true })) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:starttag", () => { + gulp.src(["src/index.html"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { starttag: "" })) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:name", () => { + gulp.src(["src/index.html"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { name: "head" })) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:transform", () => { + gulp.src(["files.json"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css", "src/**/*.html"], { read: false }), { + starttag: "\"{{ext}}\": [", + endtag: "]", + transform: (filepath, file, i, length) => { + return " \"" + filepath + "\"" + (i + 1 < length ? "," : ""); + } + })) + .pipe(gulp.dest("build")); +}); diff --git a/gulp-inject/gulp-inject.d.ts b/gulp-inject/gulp-inject.d.ts new file mode 100644 index 000000000..42f5fb348 --- /dev/null +++ b/gulp-inject/gulp-inject.d.ts @@ -0,0 +1,36 @@ +// Type definitions for gulp-inject +// Project: https://github.com/klei/gulp-inject +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-inject" { + + import File = require("vinyl"); + + interface ITagFunction { + (targetExt: string, sourceExt: string): string; + } + + interface ITransformFunction { + (filepath: string, file?: File, index?: number, length?: number, targetFile?: File): string; + } + + interface IOptions { + ignorePath?: string | string[]; + relative?: boolean; + addPrefix?: string; + addRootSlash?: boolean; + name?: string; + starttag?: string | ITagFunction; + endtag?: string | ITagFunction; + transform?: ITransformFunction; + selfClosingTag?: boolean; + } + + function inject(sources: NodeJS.ReadableStream, options?: IOptions): NodeJS.ReadWriteStream; + + export = inject; +} diff --git a/gulp-less/gulp-less-tests.ts b/gulp-less/gulp-less-tests.ts new file mode 100644 index 000000000..76e0a697c --- /dev/null +++ b/gulp-less/gulp-less-tests.ts @@ -0,0 +1,13 @@ +/// +/// + +import gulp = require("gulp"); +import less = require("gulp-less"); + +gulp.task("less", () => { + gulp.src("less/**/*.less") + .pipe(less({ + paths: ["less/includes"] + })) + .pipe(gulp.dest("public/css")); +}); diff --git a/gulp-less/gulp-less.d.ts b/gulp-less/gulp-less.d.ts new file mode 100644 index 000000000..9ca5e35b7 --- /dev/null +++ b/gulp-less/gulp-less.d.ts @@ -0,0 +1,18 @@ +// Type definitions for gulp-less +// Project: https://github.com/plus3network/gulp-less +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-less" { + + interface IOptions { + paths: string[]; + plugins?: any[]; + } + + function less(options?: IOptions): NodeJS.ReadWriteStream; + + export = less; +} diff --git a/gulp-minify-css/gulp-minify-css-tests.ts b/gulp-minify-css/gulp-minify-css-tests.ts new file mode 100644 index 000000000..1375042dd --- /dev/null +++ b/gulp-minify-css/gulp-minify-css-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +import gulp = require("gulp"); +import minifyCSS = require("gulp-minify-css"); + +gulp.task("minify-css", () => { + gulp.src("css/**/*.css") + .pipe(minifyCSS({ keepBreaks: true })) + .pipe(gulp.dest("dist")); +}); diff --git a/gulp-minify-css/gulp-minify-css.d.ts b/gulp-minify-css/gulp-minify-css.d.ts new file mode 100644 index 000000000..be6d45b8b --- /dev/null +++ b/gulp-minify-css/gulp-minify-css.d.ts @@ -0,0 +1,31 @@ +// Type definitions for gulp-minify-css +// Project: https://github.com/jonathanepollack/gulp-minify-css +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-minify-css" { + + interface IOptions { + cache?: boolean; + advanced?: boolean; + aggressiveMerging?: boolean; + benchmark?: boolean; + compatibility?: string; + debug?: boolean; + inliner?: Object; + keepBreaks?: boolean; + keepSpecialComments?: string | number; + processImport?: boolean; + rebase?: boolean; + relativeTo?: string; + root?: string; + roundingPrecision?: number; + shorthandCompacting?: boolean; + } + + function minifyCSS(options?: IOptions): NodeJS.ReadWriteStream; + + export = minifyCSS; +} diff --git a/gulp-tsd/gulp-tsd-tests.ts b/gulp-tsd/gulp-tsd-tests.ts new file mode 100644 index 000000000..9475ace65 --- /dev/null +++ b/gulp-tsd/gulp-tsd-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import gulp = require("gulp"); +import tsd = require("gulp-tsd"); + +gulp.task("tsd", () => { + gulp.src("gulp_tsd.json") + .pipe(tsd()); +}); + +gulp.task("tsd:options", callback => { + tsd({ + command: "reinstall", + config: "tsd.json" + }, callback); +}); diff --git a/gulp-tsd/gulp-tsd.d.ts b/gulp-tsd/gulp-tsd.d.ts new file mode 100644 index 000000000..68a4c6728 --- /dev/null +++ b/gulp-tsd/gulp-tsd.d.ts @@ -0,0 +1,21 @@ +// Type definitions for gulp-tsd +// Project: https://github.com/moznion/gulp-tsd +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-tsd" { + + interface IOptions { + command?: string; + latest?: boolean; + config?: string; + opts?: Object; + } + + function tsd(opts?: IOptions, callback?: gulp.ITaskCallback): NodeJS.ReadWriteStream; + + export = tsd; +} diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index 98e96e2ef..3b0801651 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -191,7 +191,15 @@ interface HighchartsBoolOrShadow { interface HighchartsChartResetZoomButton { position: HighchartsPosition; relativeTo?: string; - theme?: any; //TO DO + theme?: HighchartsChartResetZoomButtonTheme; //TO DO +} + +interface HighchartsChartResetZoomButtonTheme { + fill?:string; //css HEX colours. + stroke?: string;//css HEX colours. + r?: number; // Radius % + states?: any; // HTML element states eg: hover, with css attributes in object. + display?:string; // css attr eg: 'none' } interface HighchartsChartOptions { diff --git a/hooker/hooker-tests.ts b/hooker/hooker-tests.ts new file mode 100644 index 000000000..d9aea606c --- /dev/null +++ b/hooker/hooker-tests.ts @@ -0,0 +1,72 @@ +/// + +import hooker = require('hooker'); + +// Type definitions for JavaScript Hooker v0.2.3 +// Project: https://github.com/cowboy/javascript-hooker +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped +function tests() { + var objectToHook: any = { + hello: 'world' + }; + hooker.hook(objectToHook, 'hello', () => { }); + hooker.hook(objectToHook, 'hello', () => { + return null; + }); + hooker.hook(objectToHook, ['hello', 'foo'], () => { }); + hooker.hook(objectToHook, ['hello', 'bar'], () => { + return null; + }); + hooker.hook(objectToHook, 'bar', () => { + return hooker.filter(this, ['foo', 'bar']); + }); + hooker.hook(objectToHook, 'bar', () => { + return hooker.override('good'); + }); + hooker.hook(objectToHook, 'bar', () => { + return hooker.preempt('good'); + }); + hooker.orig(objectToHook, 'hello'); + hooker.orig(objectToHook, ['hello', 'foo']); + hooker.hook(objectToHook, 'foo', { + pre: () => { } + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { + return hooker.preempt(1); + } + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { + return hooker.override(1); + } + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { + return hooker.filter(1, ['abc']); + } + }); + hooker.hook(objectToHook, 'foo', { + post: () => { } + }); + hooker.hook(objectToHook, 'foo', { + post: () => { + return hooker.filter(1, ['abc']); + } + }); + hooker.hook(objectToHook, 'foo', { + once: false + }); + hooker.hook(objectToHook, 'foo', { + passName: true + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { }, + post: () => { + return hooker.filter(this, []); + }, + once: true, + passName: false + }); +} diff --git a/hooker/hooker.d.ts b/hooker/hooker.d.ts new file mode 100644 index 000000000..570805d39 --- /dev/null +++ b/hooker/hooker.d.ts @@ -0,0 +1,42 @@ +// Type definitions for JavaScript Hooker v0.2.3 +// Project: https://github.com/cowboy/javascript-hooker +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare type HookerPostHookFunction = (result: any, ...args: any[]) => IHookerPostHookResult|void; +declare type HookerPreHookFunction = (...args: any[]) => IHookerPreHookResult|void; + +declare module "hooker" { + function hook(object: any, props: string|string[], options: IHookerOptions): void; + function hook(object: any, props: string|string[], prehookFunction: HookerPreHookFunction): void; + function unhook(object: any, props?: string|string[]): string[]; + function orig(object: any, props: string|string[]): Function; + function override(value: any): HookerOverride; + function preempt(value: any): HookerPreempt; + function filter(context: any, args: any[]): HookerFilter; +} + +declare class HookerOverride implements IHookerPostHookResult, IHookerPreHookResult { + value: any; +} + +declare class HookerPreempt implements IHookerPreHookResult { + value: any; +} + +declare class HookerFilter implements IHookerPreHookResult { + context: any; + args: any[]; +} + +interface IHookerPostHookResult {} + +interface IHookerPreHookResult {} + +interface IHookerOptions { + pre?: HookerPreHookFunction; + post?: HookerPostHookFunction; + once?: boolean; + passName?: boolean; +} diff --git a/ini/ini-tests.ts b/ini/ini-tests.ts new file mode 100644 index 000000000..44241625f --- /dev/null +++ b/ini/ini-tests.ts @@ -0,0 +1,10 @@ +/// +/// + +import fs = require("fs"); +import ini = require("ini"); + +var ini_content = fs.readFileSync("path_to_file.ini", "utf-8"); + +var ini_object: any = ini.decode(ini_content); +var ini_rev_string: string = ini.encode(ini_object); \ No newline at end of file diff --git a/ini/ini.d.ts b/ini/ini.d.ts new file mode 100644 index 000000000..6cab73533 --- /dev/null +++ b/ini/ini.d.ts @@ -0,0 +1,25 @@ +// Type definitions for ini v1.3.3 +// Project: https://github.com/isaacs/ini +// Definitions by: Marcin Porębski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "ini" +{ + interface EncodeOptions { + section: string + whitespace: boolean + } + + function decode(inistring: string): any; + + function parse(initstring: string): any; + + function encode(object: any, options?: EncodeOptions): string; + + function stringify(object: any, options?: EncodeOptions): string; + + function safe(val: string): string; + + function unsafe(val: string): string; + +} diff --git a/is_js/is_js-tests.ts b/is_js/is_js-tests.ts new file mode 100644 index 000000000..d90728e85 --- /dev/null +++ b/is_js/is_js-tests.ts @@ -0,0 +1,655 @@ +/// + +//#region Type checks + +var getArguments = function () { + return arguments; +}; +var arguments = getArguments(); +is.arguments(arguments); +is.not.arguments({ foo: 'bar' }); +is.all.arguments(arguments, 'bar'); +is.any.arguments(['foo'], arguments); +is.all.arguments([arguments, 'foo', 'bar']); + +is.array(['foo', 'bar', 'baz']); +is.not.array({ foo: 'bar' }); +is.all.array(['foo'], 'bar'); +is.any.array(['foo'], 'bar'); +is.all.array([[1, 2], 'foo', 'bar']); + +is.boolean(true); +is.not.boolean({ foo: 'bar' }); +is.all.boolean(true, 'bar'); +is.any.boolean(true, 'bar'); +is.all.boolean([true, 'foo', 'bar']); + +is.date(new Date()); +is.not.date({ foo: 'bar' }); +is.all.date(new Date(), 'bar'); +is.any.date(new Date(), 'bar'); +is.all.date([new Date(), 'foo', 'bar']); + +is.error(new Error()); +is.not.error({ foo: 'bar' }); +is.all.error(new Error(), 'bar'); +is.any.error(new Error(), 'bar'); +is.all.error([new Error(), 'foo', 'bar']); + +is.function(toString); +is.not.function({ foo: 'bar' }); +is.all.function(toString, 'bar'); +is.any.function(toString, 'bar'); +is.all.function([toString, 'foo', 'bar']); + +is.nan(NaN); +is.not.nan(42); +is.all.nan(NaN, 1); +is.any.nan(NaN, 2); +is.all.nan([NaN, 'foo', 1]); + +is.null(null); +is.not.null(42); +is.all.null(null, 1); +is.any.null(null, 2); +is.all.null([null, 'foo', 1]); + +is.number(42); +is.not.number('42'); +is.all.number('foo', 1); +is.any.number({}, 2); +is.all.number([42, 'foo', 1]); + +is.object({ foo: 'bar' }); +is.object(toString); +is.not.object('foo'); +is.all.object({}, 1); +is.any.object({}, 2); +is.all.object([{}, new Object()]); + +is.json({ foo: 'bar' }); +is.json(toString); +is.not.json([]); +is.all.json({}, 1); +is.any.json({}, 2); +is.all.json([{}, { foo: 'bar' }]); + +is.regexp(/test/); +is.not.regexp(['foo']); +is.all.regexp(/test/, 1); +is.any.regexp(new RegExp('ab+c'), 2); +is.all.regexp([{}, /test/]); + +is.string('foo'); +is.not.string(['foo']); +is.all.string('foo', 1); +is.any.string('foo', 2); +is.all.string([{}, 'foo']); + +is.char('f'); +is.not.char(['foo']); +is.all.char('f', 1); +is.any.char('f', 2); +is.all.char(['f', 'o', 'o']); + +is.undefined(undefined); +is.not.undefined(null); +is.all.undefined(undefined, 1); +is.any.undefined(undefined, 2); +is.all.undefined([{}, undefined]); + +is.sameType(42, 7); +is.sameType(42, '7'); +is.not.sameType(42, 7); + +//#endregion + +//#region Presence checks + +is.empty({}); +is.empty([]); +is.empty(''); +is.not.empty(['foo']); +is.all.empty('', {}, ['foo']); +is.any.empty([], 42); +is.all.empty([{}, 'foo']); + +is.existy({}); +is.existy(null); +is.not.existy(undefined); +is.all.existy(null, ['foo']); +is.any.existy(undefined, 42); +is.all.existy([{}, 'foo']); + +is.truthy(true); +is.truthy(null); +is.not.truthy(false); +is.all.truthy(null, true); +is.any.truthy(undefined, true); +is.all.truthy([{}, true]); + +is.falsy(false); +is.falsy(null); +is.not.falsy(true); +is.all.falsy(null, false); +is.any.falsy(undefined, true); +is.all.falsy([false, true, undefined]); + +is.space(' '); +is.space('foo'); +is.not.space(true); +is.all.space(' ', 'foo'); +is.any.space(' ', true); +is.all.space([' ', 'foo', undefined]); + +//#endregion + +//#region RegExp checks + +is.url('http://www.test.com'); +is.url('foo'); +is.not.url(true); +is.all.url('http://www.test.com', 'foo'); +is.any.url('http://www.test.com', true); +is.all.url(['http://www.test.com', 'foo', undefined]); + +is.email('test@test.com'); +is.email('foo'); +is.not.email('foo'); +is.all.email('test@test.com', 'foo'); +is.any.email('test@test.com', 'foo'); +is.all.email(['test@test.com', 'foo', undefined]); + +is.creditCard(378282246310005); +is.creditCard(123); +is.not.creditCard(123); +is.all.creditCard(378282246310005, 123); +is.any.creditCard(378282246310005, 123); +is.all.creditCard([378282246310005, 123, undefined]); + +is.alphaNumeric('alphaNu3er1k'); +is.alphaNumeric('*?'); +is.not.alphaNumeric('*?'); +is.all.alphaNumeric('alphaNu3er1k', '*?'); +is.any.alphaNumeric('alphaNu3er1k', '*?'); +is.all.alphaNumeric(['alphaNu3er1k', '*?']); + +is.timeString('13:45:30'); +is.timeString('90:90:90'); +is.not.timeString('90:90:90'); +is.all.timeString('13:45:30', '90:90:90'); +is.any.timeString('13:45:30', '90:90:90'); +is.all.timeString(['13:45:30', '90:90:90']); + +is.dateString('11/11/2011'); +is.dateString('90/11/2011'); +is.not.dateString('90/11/2011'); +is.all.dateString('11/11/2011', '90/11/2011'); +is.any.dateString('11/11/2011', '90/11/2011'); +is.all.dateString(['11/11/2011', '90/11/2011']); + +is.usZipCode('02201-1020'); +is.usZipCode('123'); +is.not.usZipCode('123'); +is.all.usZipCode('02201-1020', '123'); +is.any.usZipCode('02201-1020', '123'); +is.all.usZipCode(['02201-1020', '123']); + +is.caPostalCode('L8V3Y1'); +is.caPostalCode('L8V 3Y1'); +is.caPostalCode('123'); +is.not.caPostalCode('123'); +is.all.caPostalCode('L8V3Y1', '123'); +is.any.caPostalCode('L8V3Y1', '123'); +is.all.caPostalCode(['L8V3Y1', '123']); + +is.ukPostCode('B184BJ'); +is.ukPostCode('123'); +is.not.ukPostCode('123'); +is.all.ukPostCode('B184BJ', '123'); +is.any.ukPostCode('B184BJ', '123'); +is.all.ukPostCode(['B184BJ', '123']); + +is.nanpPhone('609-555-0175'); +is.nanpPhone('123'); +is.not.nanpPhone('123'); +is.all.nanpPhone('609-555-0175', '123'); +is.any.nanpPhone('609-555-0175', '123'); +is.all.nanpPhone(['609-555-0175', '123']); + +is.eppPhone('+90.2322456789'); +is.eppPhone('123'); +is.not.eppPhone('123'); +is.all.eppPhone('+90.2322456789', '123'); +is.any.eppPhone('+90.2322456789', '123'); +is.all.eppPhone(['+90.2322456789', '123']); + +is.socialSecurityNumber('017-90-7890'); +is.socialSecurityNumber('123'); +is.not.socialSecurityNumber('123'); +is.all.socialSecurityNumber('017-90-7890', '123'); +is.any.socialSecurityNumber('017-90-7890', '123'); +is.all.socialSecurityNumber(['017-90-7890', '123']); + +is.affirmative('yes'); +is.affirmative('no'); +is.not.affirmative('no'); +is.all.affirmative('yes', 'no'); +is.any.affirmative('yes', 'no'); +is.all.affirmative(['yes', 'y', 'true', 't', 'ok', 'okay']); + +is.hexadecimal('f0f0f0'); +is.hexadecimal(2.5); +is.not.hexadecimal('string'); +is.all.hexadecimal('ff', 'f50'); +is.any.hexadecimal('ff5500', true); +is.all.hexadecimal(['fff', '333', 'f50']); + +is.hexColor('#333'); +is.hexColor('#3333'); +is.not.hexColor(0.5); +is.all.hexColor('fff', 'f50'); +is.any.hexColor('ff5500', 0.5); +is.all.hexColor(['fff', '333', 'f50']); + +is.ip('198.156.23.5'); +is.ip('1.2..5'); +is.not.ip('8:::::::7'); +is.all.ip('0:1::4:ff5:54:987:C', '123.123.123.123'); +is.any.ip('123.8.4.3', '0.0.0.0'); +is.all.ip(['123.123.23.12', 'A:B:C:D:E:F:0:0']); + +is.ipv4('198.12.3.142'); +is.ipv4('1.2..5'); +is.not.ipv4('8:::::::7'); +is.all.ipv4('198.12.3.142', '123.123.123.123'); +is.any.ipv4('255.255.255.255', '850..1.4'); +is.all.ipv4(['198.12.3.142', '1.2.3']); + +is.ipv6('2001:DB8:0:0:1::1'); +is.ipv6('985.12.3.4'); +is.not.ipv6('8:::::::7'); +is.all.ipv6('2001:DB8:0:0:1::1', '1:50:198:2::1:2:8'); +is.any.ipv6('255.255.255.255', '2001:DB8:0:0:1::1'); +is.all.ipv6(['2001:DB8:0:0:1::1', '1.2.3']); + +//#endregion + +//#region String checks + +is.include('Some text goes here', 'text'); +is.include('test', 'text'); +is.not.include('test', 'text'); + +is.upperCase('YEAP'); +is.upperCase('nope'); +is.not.upperCase('Nope'); +is.all.upperCase('YEAP', 'nope'); +is.any.upperCase('YEAP', 'nope'); +is.all.upperCase(['YEAP', 'ALL UPPERCASE']); + +is.lowerCase('yeap'); +is.lowerCase('NOPE'); +is.not.lowerCase('Nope'); +is.all.lowerCase('yeap', 'NOPE'); +is.any.lowerCase('yeap', 'NOPE'); +is.all.lowerCase(['yeap', 'all lowercase']); + +is.startWith('yeap', 'ye'); +is.startWith('nope', 'ye'); +is.not.startWith('nope not that', 'not'); + +is.endWith('yeap', 'ap'); +is.endWith('nope', 'no'); +is.not.endWith('nope not that', 'not'); +is.endWith('yeap that one', 'one'); + +is.capitalized('Yeap'); +is.capitalized('nope'); +is.not.capitalized('nope not capitalized'); +is.not.capitalized('nope Capitalized'); +is.all.capitalized('Yeap', 'All', 'Capitalized'); +is.any.capitalized('Yeap', 'some', 'Capitalized'); +is.all.capitalized(['Nope', 'not']); + +is.palindrome('testset'); +is.palindrome('nope'); +is.not.palindrome('nope not palindrome'); +is.not.palindrome('tt'); +is.all.palindrome('testset', 'tt'); +is.any.palindrome('Yeap', 'some', 'testset'); +is.all.palindrome(['Nope', 'testset']); + +//#endregion + +//#region Arithmetic checks + +is.equal(42, 40 + 2); +is.equal('yeap', 'yeap'); +is.equal(true, true); +is.not.equal('yeap', 'nope'); + +is.even(42); +is.not.even(41); +is.all.even(40, 42, 44); +is.any.even(39, 42, 43); +is.all.even([40, 42, 43]); + +is.odd(41); +is.not.odd(42); +is.all.odd(39, 41, 43); +is.any.odd(39, 42, 44); +is.all.odd([40, 42, 43]); + +is.positive(41); +is.not.positive(-42); +is.all.positive(39, 41, 43); +is.any.positive(-39, 42, -44); +is.all.positive([40, 42, -43]); + +is.negative(-41); +is.not.negative(42); +is.all.negative(-39, -41, -43); +is.any.negative(-39, 42, 44); +is.all.negative([40, 42, -43]); + +is.above(41, 30); +is.not.above(42, 50); + +is.under(30, 35); +is.not.under(42, 30); + +is.within(30, 20, 40); +is.not.within(40, 30, 35); + +is.decimal(41.5); +is.not.decimal(42); +is.all.decimal(39.5, 41.5, -43.5); +is.any.decimal(-39, 42.5, 44); +is.all.decimal([40, 42.5, -43]); + +is.integer(41); +is.not.integer(42.5); +is.all.integer(39, 41, -43); +is.any.integer(-39, 42.5, 44); +is.all.integer([40, 42.5, -43]); + +is.finite(41); +is.not.finite(42 / 0); +is.all.finite(39, 41, -43); +is.any.finite(-39, Infinity, 44); +is.all.finite([Infinity, -Infinity, 42.5]); + +is.infinite(Infinity); +is.not.infinite(42); +is.all.infinite(Infinity, -Infinity, -43 / 0); +is.any.infinite(-39, Infinity, 44); +is.all.infinite([Infinity, -Infinity, 42.5]); + +//#endregion + +//#region Object checks + +is.propertyCount({ this: 'is', 'sample': {} }, 2); +is.propertyCount({ this: 'is', 'sample': {} }, 3); +is.not.propertyCount({}, 2); + +is.propertyDefined({ yeap: 'yeap' }, 'yeap'); +is.propertyDefined({ yeap: 'yeap' }, 'nope'); +is.not.propertyDefined({}, 'nope'); + +is.windowObject(window); +is.windowObject({ nope: 'nope' }); +is.not.windowObject({}); + +is.all.windowObject(window, { nope: 'nope' }); +is.any.windowObject(window, { nope: 'nope' }); +is.all.windowObject([window, { nope: 'nope' }]); + +var obj = document.createElement('div'); +is.domNode(obj); +is.domNode({ nope: 'nope' }); +is.not.domNode({}); +is.all.domNode(obj, obj); +is.any.domNode(obj, { nope: 'nope' }); +is.all.domNode([obj, { nope: 'nope' }]); + +//#endregion + +//#region Array checks + +is.inArray(2, [1, 2, 3]); +is.inArray(4, [1, 2, 3]); +is.not.inArray(4, [1, 2, 3]); + +is.sorted([1, 2, 3]); +is.sorted([1, 2, 4, 3]); +is.not.sorted([5, 4, 3]); +is.all.sorted([1, 2], [3, 4]); +is.any.sorted([1, 2], [5, 4]); +is.all.sorted([[1, 2], [5, 4]]); + +//#endregion + +//#region Environment checks + +is.ie(); +is.ie(6); +is.not.ie(); + +is.chrome(); +is.not.chrome(); + +is.firefox(); +is.not.firefox(); + +is.opera(); +is.not.opera(); + +is.safari(); +is.not.safari(); + +is.ios(); +is.not.ios(); + +is.iphone(); +is.not.iphone(); + +is.ipad(); +is.not.ipad(); + +is.ipod(); +is.not.ipod(); + +is.android(); +is.not.android(); + +is.androidPhone(); +is.not.androidPhone(); + +is.androidTablet(); +is.not.androidTablet(); + +is.blackberry(); + +is.not.blackberry(); + +is.windowsPhone(); +is.not.windowsPhone(); + +is.windowsTablet(); +is.not.windowsTablet(); + +is.windows(); +is.not.windows(); + +is.mac(); +is.not.mac(); + +is.linux(); +is.not.linux(); + +is.desktop(); +is.not.desktop(); + +is.mobile(); +is.not.mobile(); + +is.tablet(); +is.not.tablet(); + +is.online(); +is.not.online(); + +is.offline(); +is.not.offline(); + +//#endregion + +//#region Time checks + +var today = new Date(); +var yesterday = new Date(new Date().setDate(new Date().getDate() - 1)); +var tomorrow = new Date(new Date().setDate(new Date().getDate() + 1)); +var monday = new Date('01/26/2015'); +var sunday = new Date('01/25/2015'); +var saturday = new Date('01/24/2015'); + +is.today(today); +is.today(yesterday) +is.not.today(yesterday); +is.all.today(today, today); +is.any.today(today, yesterday); +is.all.today([today, yesterday]); + +is.yesterday(today); +is.yesterday(yesterday); +is.not.yesterday(today); +is.all.yesterday(yesterday, today); +is.any.yesterday(today, yesterday); +is.all.yesterday([today, yesterday]); + +is.tomorrow(today); +is.tomorrow(tomorrow); +is.not.tomorrow(today); +is.all.tomorrow(tomorrow, today); +is.any.tomorrow(today, tomorrow); +is.all.tomorrow([today, tomorrow]); + +is.past(yesterday); +is.past(tomorrow); +is.not.past(tomorrow); +is.all.past(tomorrow, yesterday); +is.any.past(yesterday, tomorrow); +is.all.past([yesterday, tomorrow]); + +is.future(yesterday); +is.future(tomorrow); +is.not.future(yesterday); +is.all.future(tomorrow, yesterday); +is.any.future(yesterday, tomorrow); +is.all.future([yesterday, tomorrow]); + +var mondayObj = new Date('01/26/2015'); +var tuesdayObj = new Date('01/27/2015'); +is.day(mondayObj, 'monday'); +is.day(mondayObj, 'tuesday'); +is.not.day(mondayObj, 'tuesday'); + +var januaryObj = new Date('01/26/2015'); +var februaryObj = new Date('02/26/2015'); +is.month(januaryObj, 'january'); +is.month(februaryObj, 'january'); +is.not.month(februaryObj, 'january'); + +var year2015 = new Date('01/26/2015'); +var year2016 = new Date('01/26/2016'); +is.year(year2015, 2015); +is.year(year2016, 2015); +is.not.year(year2016, 2015); + +is.leapYear(2016); +is.leapYear(2015); +is.not.leapYear(2015); +is.all.leapYear(2015, 2016); +is.any.leapYear(2015, 2016); +is.all.leapYear([2016, 2080]); + +is.weekend(sunday); +is.weekend(monday); +is.not.weekend(monday); +is.all.weekend(sunday, saturday); +is.any.weekend(sunday, saturday, monday); +is.all.weekend([sunday, saturday, monday]); + +is.weekday(monday); +is.weekday(sunday); +is.not.weekday(sunday); +is.all.weekday(monday, saturday); +is.any.weekday(sunday, saturday, monday); +is.all.weekday([sunday, saturday, monday]); + +is.inDateRange(sunday, saturday, monday); +is.inDateRange(saturday, sunday, monday); +is.not.inDateRange(saturday, sunday, monday); + +var twoDaysAgo = new Date(new Date().setDate(new Date().getDate() - 2)); +var nineDaysAgo = new Date(new Date().setDate(new Date().getDate() - 9)); +is.inLastWeek(twoDaysAgo); +is.inLastWeek(nineDaysAgo); +is.not.inLastWeek(nineDaysAgo); + +var tenDaysAgo = new Date(new Date().setDate(new Date().getDate() - 10)); +var fortyDaysAgo = new Date(new Date().setDate(new Date().getDate() - 40)); +is.inLastMonth(tenDaysAgo); +is.inLastMonth(fortyDaysAgo); +is.not.inLastMonth(fortyDaysAgo); + +var twoMonthsAgo = new Date(new Date().setMonth(new Date().getMonth() - 2)); +var thirteenMonthsAgo = new Date(new Date().setMonth(new Date().getMonth() - 13)); +is.inLastYear(twoMonthsAgo); +is.inLastYear(thirteenMonthsAgo); +is.not.inLastYear(thirteenMonthsAgo); + +var twoDaysLater = new Date(new Date().setDate(new Date().getDate() + 2)); +var nineDaysLater = new Date(new Date().setDate(new Date().getDate() + 9)); +is.inNextWeek(twoDaysLater); +is.inNextWeek(nineDaysLater); +is.not.inNextWeek(nineDaysLater); + +var tenDaysLater = new Date(new Date().setDate(new Date().getDate() + 10)); +var fortyDaysLater = new Date(new Date().setDate(new Date().getDate() + 40)); +is.inNextMonth(tenDaysLater); +is.inNextMonth(fortyDaysLater); +is.not.inNextMonth(fortyDaysLater); + +var twoMonthsLater = new Date(new Date().setMonth(new Date().getMonth() + 2)); +var thirteenMonthsLater = new Date(new Date().setMonth(new Date().getMonth() + 13)); +is.inNextYear(twoMonthsLater); +is.inNextYear(thirteenMonthsLater); +is.not.inNextYear(thirteenMonthsLater); + +var firstQuarter = new Date('01/26/2015'); +var secondQuarter = new Date('05/26/2015'); +is.quarterOfYear(firstQuarter, 1); +is.quarterOfYear(secondQuarter, 1); +is.not.quarterOfYear(secondQuarter, 1); + +var january1 = new Date('01/01/2015'); +var june1 = new Date('06/01/2015'); +is.dayLightSavingTime(june1); +is.dayLightSavingTime(january1); +is.not.dayLightSavingTime(january1); + +//#endregion + +//#region Configuration methods + +is.url('https://www.duckduckgo.com'); +is.setRegexp(/quack/, 'url'); +is.url('quack'); + +var customName = is.setNamespace(); +customName.odd(3); + +//#endregion \ No newline at end of file diff --git a/is_js/is_js.d.ts b/is_js/is_js.d.ts new file mode 100644 index 000000000..aff47a7c5 --- /dev/null +++ b/is_js/is_js.d.ts @@ -0,0 +1,1323 @@ +// Type definitions for is.js +// Project: http://arasatasaygin.github.io/is.js/ +// Definitions by: Rodrigo Cabral +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface IsStatic { + + //#region Type checks + + /** + * Checks if the given value type is arguments. + */ + arguments(value: any): boolean; + + /** + * Checks if the given value type is array. + */ + array(value: any): boolean; + + /** + * Checks if the given value type is boolean. + */ + boolean(value: any): boolean; + + /** + * Checks if the given value type is date. + */ + date(value: any): boolean; + + /** + * Checks if the given value type is error. + */ + error(value: any): boolean; + + /** + * Checks if the given value type is function. + */ + function(value: any): boolean; + + /** + * Checks if the given value type is NaN. + */ + nan(value: any): boolean; + + /** + * Checks if the given value type is null. + */ + null(value: any): boolean; + + /** + * Checks if the given value type is number. + */ + number(value: any): boolean; + + /** + * Checks if the given value type is object. + */ + object(value: any): boolean; + + /** + * Checks if the given value type is pure json object. + */ + json(value: any): boolean; + + /** + * Checks if the given value type is RegExp. + */ + regexp(value: any): boolean; + + /** + * Checks if the given value type is string. + */ + string(value: any): boolean; + + /** + * Checks if the given value type is char. + */ + char(value: any): boolean; + + /** + * Checks if the given value type is undefined. + */ + undefined(value: any): boolean; + + /** + * Checks if the given value types are same type. + */ + sameType(value1: any, value2: any): boolean; + + //#endregion + + //#region Presence checks + + /** + * Checks if the given value is empty. + */ + empty(value: any): boolean; + + /** + * Checks if the given value is existy. (not null or undefined) + */ + existy(value: any): boolean; + + /** + * Checks if the given value is truthy. (existy and not false) + */ + truthy(value: any): boolean; + + /** + * Checks if the given value is falsy. + */ + falsy(value: any): boolean; + + /** + * Checks if the given value is space. + */ + space(value: any): boolean; + + //#endregion + + //#region RegExp checks + + /** + * Checks if the given value matches url regexp. + */ + url(value: any): boolean; + + /** + * Checks if the given value matches email regexp. + */ + email(value: any): boolean; + + /** + * Checks if the given value matches credit card regexp. + */ + creditCard(value: any): boolean; + + /** + * Checks if the given value matches alpha numeric regexp. + */ + alphaNumeric(value: any): boolean; + + /** + * Checks if the given value matches time string regexp. + */ + timeString(value: any): boolean; + + /** + * Checks if the given value matches date string regexp. + */ + dateString(value: any): boolean; + + /** + * Checks if the given value matches US zip code regexp. + */ + usZipCode(value: any): boolean; + + /** + * Checks if the given value matches Canada postal code regexp. + */ + caPostalCode(value: any): boolean; + + /** + * Checks if the given value matches UK post code regexp. + */ + ukPostCode(value: any): boolean; + + /** + * Checks if the given value matches North American numbering plan phone regexp. + */ + nanpPhone(value: any): boolean; + + /** + * Checks if the given value matches extensible provisioning protocol phone regexp. + */ + eppPhone(value: any): boolean; + + /** + * Checks if the given value matches social security number regexp. + */ + socialSecurityNumber(value: any): boolean; + + /** + * Checks if the given value matches affirmative regexp. + */ + affirmative(value: any): boolean; + + /** + * Checks if the given value matches hexadecimal regexp. + */ + hexadecimal(value: any): boolean; + + /** + * Checks if the given value matches hexcolor regexp. + */ + hexColor(value: any): boolean; + + /** + * Checks if the given value matches ip regexp. + */ + ip(value: any): boolean; + + /** + * Checks if the given value matches ipv4 regexp + */ + ipv4(value: any): boolean; + + /** + * Checks if the given value matches ipv6 regexp + */ + ipv6(value: any): boolean; + + //#endregion + + //#region String checks + + /** + * Checks if the given string contains a substring. + */ + include(value1: string, value2: string): boolean; + + /** + * Checks if the given string is UPPERCASE. + */ + upperCase(value: string): boolean; + + /** + * Checks if the given string is lowercase. + */ + lowerCase(value: string): boolean; + + /** + * Checks if the given string starts with substring. + */ + startWith(value1: string, value2: string): boolean; + + /** + * Checks if the given string ends with substring. + */ + endWith(value1: string, value2: string): boolean; + + /** + * Checks if the given string is capitalized. + */ + capitalized(value: string): boolean; + + /** + * Checks if the given string is palindrome. + */ + palindrome(value: string): boolean; + + //#endregion + + //#region Arithmetic checks + + /** + * Checks if the given values are equal. + */ + equal(value1: any, value2: any): boolean; + + /** + * Checks if the given value is even. + */ + even(value: number): boolean; + + /** + * Checks if the given value is odd. + */ + odd(value: number): boolean; + + /** + * Checks if the given value is positive. + */ + positive(value: number): boolean; + + /** + * Checks if the given value is negative. + */ + negative(value: number): boolean; + + /** + * Checks if the given value is above minimum value. + */ + above(value: number, min: number): boolean; + + /** + * Checks if the given value is under maximum value. + */ + under(value: number, max: number): boolean; + + /** + * Checks if the given value is within minimum and maximum values. + */ + within(value: number, min: number, max: number): boolean; + + /** + * Checks if the given value is decimal. + */ + decimal(value: number): boolean; + + /** + * Checks if the given value is integer. + */ + integer(value: number): boolean; + + /** + * Checks if the given value is finite. + */ + finite(value: number): boolean; + + /** + * Checks if the given value is infinite. + */ + infinite(value: number): boolean; + + //#endregion + + //#region Object checks + + /** + * Checks if objects' property count is equal to given count. + */ + propertyCount(value: any, count: number): boolean; + + /** + * Checks if the given property is defined on object. + */ + propertyDefined(value: any, property: string): boolean; + + /** + * Checks if the given object is window object. + */ + windowObject(value: any): boolean; + + /** + * Checks if the given object is a dom node. + */ + domNode(value: any): boolean; + + //#endregion + + //#region Array checks + + /** + * Checks if the given item is in array. + */ + inArray(value: T, array: T[]): boolean; + + /** + * Checks if the given array is sorted. + */ + sorted(value: any[]): boolean; + + //#endregion + + //#region Environment checks + + /** + * Checks if current browser is ie + * @parm value Optional version number of browser + */ + ie(value?: number): boolean; + + /** + * Checks if current browser is chrome. + */ + chrome(): boolean; + + /** + * Checks if current browser is firefox. + */ + firefox(): boolean; + + /** + * Checks if current browser is opera. + */ + opera(): boolean; + + /** + * Checks if current browser is safari. + */ + safari(): boolean; + + /** + * Checks if current device has ios. + */ + ios(): boolean; + + /** + * Checks if current device is iPhone. + */ + iphone(): boolean; + + /** + * Checks if current device is iPad. + */ + ipad(): boolean; + + /** + * Checks if current device is iPod. + */ + ipod(): boolean; + + /** + * Checks if current device has Android. + */ + android(): boolean; + + /** + * Checks if current device is Android phone. + */ + androidPhone(): boolean; + + /** + * Checks if current device is Android tablet. + */ + androidTablet(): boolean; + + /** + * Checks if current device is Blackberry. + */ + blackberry(): boolean; + + /** + * Checks if current device is Windows phone. + */ + windowsPhone(): boolean; + + /** + * Checks if current device is Windows tablet. + */ + windowsTablet(): boolean; + + /** + * Checks if current OS is Windows. + */ + windows(): boolean; + + /** + * Checks if current OS is Mac OS X. + */ + mac(): boolean; + + /** + * Checks if current OS is linux. + */ + linux(): boolean; + + /** + * Checks if current device is desktop. + */ + desktop(): boolean; + + /** + * Checks if current device is mobile. + */ + mobile(): boolean; + + /** + * Checks if current device is tablet. + */ + tablet(): boolean; + + /** + * Checks if current device is online. + */ + online(): boolean; + + /** + * Checks if current device is offline. + */ + offline(): boolean; + + //#endregion + + //#region Time checks + + /** + * Checks if the given date object indicate today. + */ + today(value: Date): boolean; + + /** + * Checks if the given date object indicate yesterday. + */ + yesterday(value: Date): boolean; + + /** + * Checks if the given date object indicate tomorrow. + */ + tomorrow(value: Date): boolean; + + /** + * Checks if the given date object indicate past. + */ + past(value: Date): boolean; + + /** + * Checks if the given date object indicate future. + */ + future(value: Date): boolean; + + /** + * Checks if the given date objects' day equal given dayString parameter. + */ + day(value: Date, dayString: string): boolean; + + /** + * Checks if the given date objects' month equal given monthString parameter. + */ + month(value: Date, monthString: string): boolean; + + /** + * Checks if the given date objects' year equal given yearNumber parameter. + */ + year(value: Date, yearNumber: number): boolean; + + /** + * Checks if the given year number is a leap year + */ + leapYear(value: number): boolean; + + /** + * Checks if the given date objects' day is weekend. + */ + weekend(value: Date): boolean; + + /** + * Checks if the given date objects' day is weekday. + */ + weekday(value: Date): boolean; + + /** + * Checks if date is within given range. + */ + inDateRange(value: Date, start: Date, end: Date): boolean; + + /** + * Checks if the given date is between now and 7 days ago. + */ + inLastWeek(value: Date): boolean; + + /** + * Checks if the given date is between now and a month ago. + */ + inLastMonth(value: Date): boolean; + + /** + * Checks if the given date is between now and a year ago. + */ + inLastYear(value: Date): boolean; + + /** + * Checks if the given date is between now and 7 days later. + */ + inNextWeek(value: Date): boolean; + + /** + * Checks if the given date is between now and a month later. + */ + inNextMonth(value: Date): boolean; + + /** + * Checks if the given date is between now and a year later. + */ + inNextYear(value: Date): boolean; + + /** + * Checks if the given date is in the parameter quarter. + */ + quarterOfYear(value: Date, quarter: number): boolean; + + /** + * Checks if the given date is in daylight saving time. + */ + dayLightSavingTime(value: Date): boolean; + + //#endregion + +} + +interface IsStaticApi { + + //#region Type checks + + /** + * Checks if the given value type is arguments. + */ + arguments(...value: any[]): boolean; + + /** + * Checks if the given value type is arguments. + */ + arguments(value: any[]): boolean; + + /** + * Checks if the given value type is array. + */ + array(...value: any[]): boolean; + + /** + * Checks if the given value type is array. + */ + array(value: any[]): boolean; + + /** + * Checks if the given value type is boolean. + */ + boolean(...value: any[]): boolean; + + /** + * Checks if the given value type is boolean. + */ + boolean(value: any[]): boolean; + + /** + * Checks if the given value type is date. + */ + date(...value: any[]): boolean; + + /** + * Checks if the given value type is date. + */ + date(value: any[]): boolean; + + /** + * Checks if the given value type is error. + */ + error(...value: any[]): boolean; + + /** + * Checks if the given value type is error. + */ + error(value: any[]): boolean; + + /** + * Checks if the given value type is function. + */ + function(...value: any[]): boolean; + + /** + * Checks if the given value type is function. + */ + function(value: any[]): boolean; + + /** + * Checks if the given value type is NaN. + */ + nan(...value: any[]): boolean; + + /** + * Checks if the given value type is NaN. + */ + nan(value: any[]): boolean; + + /** + * Checks if the given value type is null. + */ + null(...value: any[]): boolean; + + /** + * Checks if the given value type is null. + */ + null(value: any[]): boolean; + + /** + * Checks if the given value type is number. + */ + number(...value: any[]): boolean; + + /** + * Checks if the given value type is number. + */ + number(value: any[]): boolean; + + /** + * Checks if the given value type is object. + */ + object(...value: any[]): boolean; + + /** + * Checks if the given value type is object. + */ + object(value: any[]): boolean; + + /** + * Checks if the given value type is pure json object. + */ + json(...value: any[]): boolean; + + /** + * Checks if the given value type is pure json object. + */ + json(value: any[]): boolean; + + /** + * Checks if the given value type is RegExp. + */ + regexp(...value: any[]): boolean; + + /** + * Checks if the given value type is RegExp. + */ + regexp(value: any[]): boolean; + + /** + * Checks if the given value type is string. + */ + string(...value: any[]): boolean; + + /** + * Checks if the given value type is string. + */ + string(value: any[]): boolean; + + /** + * Checks if the given value type is char. + */ + char(...value: any[]): boolean; + + /** + * Checks if the given value type is char. + */ + char(value: any[]): boolean; + + /** + * Checks if the given value type is undefined. + */ + undefined(...value: any[]): boolean; + + /** + * Checks if the given value type is undefined. + */ + undefined(value: any[]): boolean; + + //#endregion + + //#region Presence checks + + /** + * Checks if the given value is empty. + */ + empty(...value: any[]): boolean; + + /** + * Checks if the given value is empty. + */ + empty(value: any[]): boolean; + + /** + * Checks if the given value is existy. (not null or undefined) + */ + existy(...value: any[]): boolean; + + /** + * Checks if the given value is existy. (not null or undefined) + */ + existy(value: any[]): boolean; + + /** + * Checks if the given value is truthy. (existy and not false) + */ + truthy(...value: any[]): boolean; + + /** + * Checks if the given value is truthy. (existy and not false) + */ + truthy(value: any[]): boolean; + + /** + * Checks if the given value is falsy. + */ + falsy(...value: any[]): boolean; + + /** + * Checks if the given value is falsy. + */ + falsy(value: any[]): boolean; + + /** + * Checks if the given value is space. + */ + space(...value: any[]): boolean; + + /** + * Checks if the given value is space. + */ + space(value: any[]): boolean; + + //#endregion + + //#region RegExp checks + + /** + * Checks if the given value matches url regexp. + */ + url(...value: any[]): boolean; + + /** + * Checks if the given value matches url regexp. + */ + url(value: any[]): boolean; + + /** + * Checks if the given value matches email regexp. + */ + email(...value: any[]): boolean; + + /** + * Checks if the given value matches email regexp. + */ + email(value: any[]): boolean; + + /** + * Checks if the given value matches credit card regexp. + */ + creditCard(...value: any[]): boolean; + + /** + * Checks if the given value matches credit card regexp. + */ + creditCard(value: any[]): boolean; + + /** + * Checks if the given value matches alpha numeric regexp. + */ + alphaNumeric(...value: any[]): boolean; + + /** + * Checks if the given value matches alpha numeric regexp. + */ + alphaNumeric(value: any[]): boolean; + + /** + * Checks if the given value matches time string regexp. + */ + timeString(...value: any[]): boolean; + + /** + * Checks if the given value matches time string regexp. + */ + timeString(value: any[]): boolean; + + /** + * Checks if the given value matches date string regexp. + */ + dateString(...value: any[]): boolean; + + /** + * Checks if the given value matches date string regexp. + */ + dateString(value: any[]): boolean; + + /** + * Checks if the given value matches US zip code regexp. + */ + usZipCode(...value: any[]): boolean; + + /** + * Checks if the given value matches US zip code regexp. + */ + usZipCode(value: any[]): boolean; + + /** + * Checks if the given value matches Canada postal code regexp. + */ + caPostalCode(...value: any[]): boolean; + + /** + * Checks if the given value matches Canada postal code regexp. + */ + caPostalCode(value: any[]): boolean; + + /** + * Checks if the given value matches UK post code regexp. + */ + ukPostCode(...value: any[]): boolean; + + /** + * Checks if the given value matches UK post code regexp. + */ + ukPostCode(value: any[]): boolean; + + /** + * Checks if the given value matches North American numbering plan phone regexp. + */ + nanpPhone(...value: any[]): boolean; + + /** + * Checks if the given value matches North American numbering plan phone regexp. + */ + nanpPhone(value: any[]): boolean; + + /** + * Checks if the given value matches extensible provisioning protocol phone regexp. + */ + eppPhone(...value: any[]): boolean; + + /** + * Checks if the given value matches extensible provisioning protocol phone regexp. + */ + eppPhone(value: any[]): boolean; + + /** + * Checks if the given value matches social security number regexp. + */ + socialSecurityNumber(...value: any[]): boolean; + + /** + * Checks if the given value matches social security number regexp. + */ + socialSecurityNumber(value: any[]): boolean; + + /** + * Checks if the given value matches affirmative regexp. + */ + affirmative(...value: any[]): boolean; + + /** + * Checks if the given value matches affirmative regexp. + */ + affirmative(value: any[]): boolean; + + /** + * Checks if the given value matches hexadecimal regexp. + */ + hexadecimal(...value: any[]): boolean; + + /** + * Checks if the given value matches hexadecimal regexp. + */ + hexadecimal(value: any[]): boolean; + + /** + * Checks if the given value matches hexcolor regexp. + */ + hexColor(...value: any[]): boolean; + + /** + * Checks if the given value matches hexcolor regexp. + */ + hexColor(value: any[]): boolean; + + /** + * Checks if the given value matches ip regexp. + */ + ip(...value: any[]): boolean; + + /** + * Checks if the given value matches ip regexp. + */ + ip(value: any[]): boolean; + + /** + * Checks if the given value matches ipv4 regexp. + */ + ipv4(...value: any[]): boolean; + + /** + * Checks if the given value matches ipv4 regexp. + */ + ipv4(value: any[]): boolean; + + /** + * Checks if the given value matches ipv6 regexp. + */ + ipv6(...value: any[]): boolean; + + /** + * Checks if the given value matches ipv6 regexp. + */ + ipv6(value: any[]): boolean; + + //#endregion + + //#region String checks + + /** + * Checks if the given string is UPPERCASE. + */ + upperCase(...value: string[]): boolean; + + /** + * Checks if the given string is UPPERCASE. + */ + upperCase(value: string[]): boolean; + + /** + * Checks if the given string is lowercase. + */ + lowerCase(...value: string[]): boolean; + + /** + * Checks if the given string is lowercase. + */ + lowerCase(value: string[]): boolean; + + /** + * Checks if the given string is capitalized. + */ + capitalized(...value: string[]): boolean; + + /** + * Checks if the given string is capitalized. + */ + capitalized(value: string[]): boolean; + + /** + * Checks if the given string is palindrome + */ + palindrome(...value: string[]): boolean; + + /** + * Checks if the given string is palindrome + */ + palindrome(value: string[]): boolean; + + //#endregion + + //#region Arithmetic checks + + /** + * Checks if the given value is even. + */ + even(...value: number[]): boolean; + + /** + * Checks if the given value is even. + */ + even(value: number[]): boolean; + + /** + * Checks if the given value is odd. + */ + odd(...value: number[]): boolean; + + /** + * Checks if the given value is odd. + */ + odd(value: number[]): boolean; + + /** + * Checks if the given value is positive. + */ + positive(...value: number[]): boolean; + + /** + * Checks if the given value is positive. + */ + positive(value: number[]): boolean; + + /** + * Checks if the given value is negative. + */ + negative(...value: number[]): boolean; + + /** + * Checks if the given value is negative. + */ + negative(value: number[]): boolean; + + /** + * Checks if the given value is decimal. + */ + decimal(...value: number[]): boolean; + + /** + * Checks if the given value is decimal. + */ + decimal(value: number[]): boolean; + + /** + * Checks if the given value is integer. + */ + integer(...value: number[]): boolean; + + /** + * Checks if the given value is integer. + */ + integer(value: number[]): boolean; + + /** + * Checks if the given value is finite. + */ + finite(...value: number[]): boolean; + + /** + * Checks if the given value is finite. + */ + finite(value: number[]): boolean; + + /** + * Checks if the given value is infinite. + */ + infinite(...value: number[]): boolean; + + /** + * Checks if the given value is infinite. + */ + infinite(value: number[]): boolean; + + //#endregion + + //#region Object checks + + /** + * Checks if the given object is window object. + */ + windowObject(...value: any[]): boolean; + + /** + * Checks if the given object is window object. + */ + windowObject(value: any[]): boolean; + + /** + * Checks if the given object is a dom node. + */ + domNode(...value: any[]): boolean; + + /** + * Checks if the given object is a dom node. + */ + domNode(value: any[]): boolean; + + //#endregion + + //#region Array checks + + /** + * Checks if the given array is sorted. + */ + sorted(...value: number[][]): boolean; + + /** + * Checks if the given array is sorted. + */ + sorted(value: number[][]): boolean; + + //#endregion + + //#region Time checks + + /** + * Checks if the given date object indicate today. + */ + today(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate today. + */ + today(value: Date[]): boolean; + + /** + * Checks if the given date object indicate yesterday. + */ + yesterday(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate yesterday. + */ + yesterday(value: Date[]): boolean; + + /** + * Checks if the given date object indicate tomorrow. + */ + tomorrow(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate tomorrow. + */ + tomorrow(value: Date[]): boolean; + + /** + * Checks if the given date object indicate past. + */ + past(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate past. + */ + past(value: Date[]): boolean; + + /** + * Checks if the given date object indicate future. + */ + future(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate future. + */ + future(value: Date[]): boolean; + + /** + * Checks if the given year number is a leap year + */ + leapYear(...value: number[]): boolean; + + /** + * Checks if the given year number is a leap year + */ + leapYear(value: number[]): boolean; + + /** + * Checks if the given date objects' day is weekend. + */ + weekend(...value: Date[]): boolean; + + /** + * Checks if the given date objects' day is weekend. + */ + weekend(value: Date[]): boolean; + + /** + * Checks if the given date objects' day is weekday. + */ + weekday(...value: Date[]): boolean; + + /** + * Checks if the given date objects' day is weekday. + */ + weekday(value: Date[]): boolean; + + //#endregion +} + +interface Is extends IsStatic { + + not: IsStatic; + any: IsStaticApi; + all: IsStaticApi; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'url'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'email'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'creditCard'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'alphaNumeric'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'timeString'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'dateString'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'usZipCode'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'caPostalCode'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'nanpPhone'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'eppPhone'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'affirmative'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'hexadecimal'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'hexColor'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'ip'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'ipv6'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: string): boolean; + + /** + * Change namespace of library to prevent name collisions. + */ + setNamespace(): Is; +} + +declare var is: Is; + +declare module 'is' { + export = is; +} \ No newline at end of file diff --git a/jbinary/jbinary-tests.ts b/jbinary/jbinary-tests.ts new file mode 100644 index 000000000..c1e286fce --- /dev/null +++ b/jbinary/jbinary-tests.ts @@ -0,0 +1,16 @@ +/// + +var originalData = [0x05, 0x03, 0x7F, 0x1E]; +var b1 = new jBinary(originalData); +console.log(b1.readAll()); +console.log(b1.read('int8')); + +b1.seek(4); +console.log(b1.read('int8')); + +console.log(b1.tell()); + +b1.write('int8', 0x9A, 2); +b1.writeAll(originalData); + +console.log(b1.slice(0, 2)); diff --git a/jbinary/jbinary.d.ts b/jbinary/jbinary.d.ts new file mode 100644 index 000000000..f9a2f2aaa --- /dev/null +++ b/jbinary/jbinary.d.ts @@ -0,0 +1,32 @@ +// Type definitions for jBinary +// Project: https://github.com/jDataView/jBinary +// Definitions by: Tim Bureck +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Additional notes: +// Method stubs and types are taken from the official jBinary documentation, which can be found here: +// https://github.com/jDataView/jBinary/wiki/jBinary-Constructor +// https://github.com/jDataView/jBinary/wiki/jBinary-Methods + +/// + +declare class jBinary +{ + + constructor(data:Array); + constructor(data:jDataView, typeSet:Object); + constructor(bufferSize:number, typeSet:Object); + + read(type:string, offset?:number):any; + readAll():any; + + write(type:string, data:any, offset?:number):number; + writeAll(data:any):number; + + tell():number; + seek(position:number, callback?: (prop:jBinary, data:any) => any):number; + skip(count:number, callback?: (prop:jBinary, data:any) => any):number; + + slice(start:number, end:number, forceCopy?:boolean):jBinary; + as(typeSet:Object, modifyOriginal?:boolean):jBinary; +} \ No newline at end of file diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 9e6a2f0cc..19e239445 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Joint JS 0.6 +// Type definitions for Joint JS 0.9.3 // Project: http://www.jointjs.com/ -// Definitions by: Aidan Reel , David Durman +// Definitions by: Aidan Reel , David Durman , Ewout Van Gossum // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -16,34 +16,36 @@ declare module joint { } class Graph extends Backbone.Model { - initialize(); - fromJSON(json: any); - clear(); - addCell(cell: Cell); - addCells(cells: Cell[]); - getConnectedLinks(cell: Cell, opt?: any): Link[]; - disconnectLinks(cell: Cell); - removeLinks(cell: Cell); + addCell(cell:Cell) : void; + addCells(cells:Cell[]) : void; + initialize() : void; + fromJSON(json:any) : void; + toJSON() : Object; + clear() : void; + getConnectedLinks(cell:Cell, opt?:any):Link[]; + disconnectLinks(cell:Cell) : void; + removeLinks(cell:Cell) : void; findModelsFromPoint(point:{x : number; y: number}):Element[]; } class Cell extends Backbone.Model { - toJSON(); - remove(options?: any); - toFront(); - toBack(); - embed(cell: Cell); - unembed(cell: Cell); - getEmbeddedCells(): Cell[]; - clone(opt?: any): Backbone.Model; // @todo: return can either be Cell or Cell[]. - attr(attrs: any): Cell; + toJSON() : Object; + remove(options?:any) : void; + toFront() : void; + toBack() : void; + embed(cell:Cell) : void; + unembed(cell:Cell) : void; + getEmbeddedCells():Cell[]; + clone(opt?:any):Backbone.Model; // @todo: return can either be Cell or Cell[]. + attr(attrs:any):Cell; } class Element extends Cell { - position(x: number, y: number): Element; - translate(tx: number, ty?: number): Element; - resize(width: number, height: number): Element; - rotate(angle: number, absolute): Element; + position(x:number, y:number):Element; + translate(tx:number, ty?:number):Element; + resize(width:number, height:number):Element; + rotate(angle:number, options : {absolute : boolean; origin: {x:number;y:number}}):Element; + remove(): void; } interface IDefaults { @@ -51,9 +53,10 @@ declare module joint { } class Link extends Cell { - defaults(): IDefaults; - disconnect(): Link; - label(idx?: number, value?: any): any; // @todo: returns either a label under idx or Link if both idx and value were passed + defaults():IDefaults; + disconnect():Link; + label(idx?:number, value?:any):any; // @todo: returns either a label under idx or Link if both idx and value were passed + remove(): void; } interface IOptions { @@ -66,82 +69,66 @@ declare module joint { } class Paper extends Backbone.View { - options: IOptions; - setDimensions(width: number, height: number); - scale(sx: number, sy?: number, ox?: number, oy?: number): Paper; - rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already - findView(el: any): CellView; - findViewByModel(modelOrId: any): CellView; - findViewsFromPoint(p: { x: number; y: number; }): CellView[]; - findViewsInArea(r: { x: number; y: number; width: number; height: number; }): CellView[]; - snapToGrid(p): { x: number; y: number; }; + options:IOptions; + + setDimensions(width:number, height:number) : void; + scale(sx:number, sy?:number, ox?:number, oy?:number):Paper; + rotate(deg:number, ox?:number, oy?:number):Paper; // @todo not released yet though it's in the source code already + findView(el:any):CellView; + findViewByModel(modelOrId:any):CellView; + findViewsFromPoint(p:{ x: number; y: number; }):CellView[]; + findViewsInArea(r:{ x: number; y: number; width: number; height: number; }):CellView[]; } - class ElementView extends CellView { - scale(sx: number, sy: number); + class ElementView extends CellView { + scale(sx:number, sy:number) : void; } class CellView extends Backbone.View { - getBBox(): { x: number; y: number; width: number; height: number; }; - highlight(el?: any); - unhighlight(el?: any); - findMagnet(el: any); - getSelector(el: any); + getBBox():{ x: number; y: number; width: number; height: number; }; + highlight(el?:any): void; + unhighlight(el?:any): void; + findMagnet(el:any): void; + getSelector(el:any): void; + + pointerdblclick(evt:any, x:number, y:number):void; + pointerclick(evt:any, x:number, y:number):void; + pointerdown(evt:any, x:number, y:number):void; + pointermove(evt:any, x:number, y:number):void; + pointerup(evt:any, x:number, y:number):void; } class LinkView extends CellView { - getConnectionLength(): number; - getPointAtLength(length: number): { x: number; y: number; }; + getConnectionLength():number; + getPointAtLength(length:number):{ x: number; y: number; }; } - + } - module ui { - interface Handle { - name : string; - position : string; - icon: string; - } - - class SelectionView extends Backbone.Model { - paper:joint.dia.Paper; - graph:joint.dia.Graph; - model:Backbone.Collection; - - constructor(opt:{ - paper : joint.dia.Paper; - graph : joint.dia.Graph; - model : Backbone.Collection - }); - - createSelectionBox(cellView:joint.dia.CellView); - destroySelectionBox(cellView:joint.dia.CellView); - startSelecting(evt:any); - cancelSelection(); - - addHandle(handle:Handle); - removeHandle(name:string); - changeHandle(name:string, handle:Handle); - } - } + module ui {} module shapes { module basic { - class Generic extends joint.dia.Element { } - class Rect extends Generic { } - class Text extends Generic { } - class Circle extends Generic { } - class Image extends Generic { } + class Generic extends joint.dia.Element { + } + class Rect extends Generic { + } + class Text extends Generic { + } + class Circle extends Generic { + } + class Image extends Generic { + } } } module util { - function uuid(): string; - function guid(obj: any): string; - function mixin(objects: any[]): any; - function supplement(objects: any[]): any; - function deepMixin(objects: any[]): any; - function deepSupplement(objects: any[], defaultIndicator?: any): any; + function uuid():string; + function guid(obj:any):string; + function mixin(objects:any[]):any; + function supplement(objects:any[]):any; + function deepMixin(objects:any[]):any; + function deepSupplement(objects:any[], defaultIndicator?:any):any; } } diff --git a/jqgrid/jqgrid-tests.ts b/jqgrid/jqgrid-tests.ts new file mode 100644 index 000000000..64b7d7d7b --- /dev/null +++ b/jqgrid/jqgrid-tests.ts @@ -0,0 +1,6 @@ +// Type definitions for jQuery jqgrid Plugin 1.3 +// Definitions by: Lokesh Peta +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// \ No newline at end of file diff --git a/jqgrid/jqgrid.d.ts b/jqgrid/jqgrid.d.ts new file mode 100644 index 000000000..71d39f6fe --- /dev/null +++ b/jqgrid/jqgrid.d.ts @@ -0,0 +1,64 @@ +// Type definitions for jQuery jqgrid Plugin 1.3 +// Project: https://github.com/tonytomov/jqGrid +// Definitions by: Lokesh Peta +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +interface JQueryJqGridColumn { + name: string; + index: string; + hidden?: boolean; + sortable?: boolean; + search?: boolean; + width?: number; + formatter?: (cellvalue: any, options: any, rowObject: any) => any; +} + +interface IJqGridJsonReader { + repeatitems: boolean; + root(obj: any): any; + page(obj: any): any; + total(obj: any): number; + records(obj: {data: any[]}): number; +} + +interface JQueryJqGridOptions { + datatype?: string; + mtype?: string; + autoencode?: boolean; + pager?: string; + rowNum?: number; + rowList?: number[]; + colNames?: string[]; + colModel?: JQueryJqGridColumn[]; + sortname?: string; + sortorder?: string; + multiselect?: boolean; + multiboxonly?: boolean; + forceFit?: boolean; + height?: number; + width?: number; + shrinkToFit?: boolean; + url?: string; + jsonReader?: IJqGridJsonReader; + gridComplete?:()=>void; +} + +interface JQueryJqGridStatic { + (): JQuery; + (gridName: string): any; + (gridName: string, propName: string): any; + (gridName: string, obj: any): any; + (gridName: string, id: any, colname: any): any; + (options: JQueryJqGridOptions): JQuery; +} + +interface JQueryStatic { + jqGrid?: JQueryJqGridStatic; +} + +interface JQuery { + jqGrid?: JQueryJqGridStatic; + + setGridParam(obj: any): void; +} \ No newline at end of file diff --git a/jqgrid/jqgrid.d.ts.tscparams b/jqgrid/jqgrid.d.ts.tscparams new file mode 100644 index 000000000..ce89a9e7d --- /dev/null +++ b/jqgrid/jqgrid.d.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs --target es5 \ No newline at end of file diff --git a/jquery-galleria/jquery-galleria-tests.ts b/jquery-galleria/jquery-galleria-tests.ts new file mode 100644 index 000000000..413e368f8 --- /dev/null +++ b/jquery-galleria/jquery-galleria-tests.ts @@ -0,0 +1,23 @@ +/// +module JqueryGalleriaTests { + var container = document.createElement("galleria"); + + var gOptions: GalleriaJS.GalleriaOptions; + + gOptions.lightbox = true; + gOptions.autoplay = true; + + Galleria.run("galleria", gOptions); + + gOptions.lightbox = false; + + Galleria.ready(function() { + this.configure(gOptions).refreshImage(); + }); + + Galleria.run("galleria"); + + gOptions.autoplay = false; + + Galleria.run(); +} \ No newline at end of file diff --git a/jquery-galleria/jquery-galleria.d.ts b/jquery-galleria/jquery-galleria.d.ts new file mode 100644 index 000000000..95b94aa50 --- /dev/null +++ b/jquery-galleria/jquery-galleria.d.ts @@ -0,0 +1,39 @@ +// Type definitions for galleria.js v1.4.2 +// Project: https://github.com/aino/galleria +// Definitions by: Robert Imig +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module GalleriaJS { + + interface GalleriaOptions { + dataSource: GalleriaEntry[]; + autoplay?: boolean; + lightbox?: boolean; + } + + interface GalleriaEntry { + image?: string; + thumbnail?: string; + title?: string; + description?: string; + } + + interface GalleriaFactory { + run(): GalleriaFactory; + run(selector: String): GalleriaFactory; + run(selector: String, options: GalleriaOptions): GalleriaFactory; + + loadTheme(url : String): GalleriaFactory; + configure(options: GalleriaOptions): GalleriaFactory; + + ready( method: () => any): void; + + refreshImage(): GalleriaFactory; + resize(): GalleriaFactory; + load( data: GalleriaEntry[]): GalleriaFactory; + setOptions( options: GalleriaOptions): GalleriaFactory; + } + +} + +declare var Galleria: GalleriaJS.GalleriaFactory; \ No newline at end of file diff --git a/jquery.contextMenu/jquery.contextMenu.d.ts b/jquery.contextMenu/jquery.contextMenu.d.ts index 95e890c20..620564fcd 100644 --- a/jquery.contextMenu/jquery.contextMenu.d.ts +++ b/jquery.contextMenu/jquery.contextMenu.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery contextMenu 1.5.25 +// Type definitions for jQuery contextMenu 1.6.6 // Project: http://medialize.github.com/jQuery-contextMenu/ // Definitions by: Natan Vivo // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -30,4 +30,5 @@ interface JQueryContextMenuOptions { interface JQueryStatic { contextMenu(options?: JQueryContextMenuOptions): JQuery; + contextMenu(type: string): JQuery; } diff --git a/jquery.noty/jquery.noty.d.ts b/jquery.noty/jquery.noty.d.ts index 88b0d0b7d..2cd233fa1 100644 --- a/jquery.noty/jquery.noty.d.ts +++ b/jquery.noty/jquery.noty.d.ts @@ -47,7 +47,6 @@ interface NotyCallbackOptions { } interface NotyStatic { - (notyOptions: NotyOptions); defaults: NotyOptions; @@ -57,23 +56,27 @@ interface NotyStatic { closeAll(); setText(id: any, text: string); setType(id: any, type: string); +} +interface Noty { + (notyOptions: NotyOptions); + + show(); + close(); + setText(text: string); + setType(type: string); + setTimeout(timeout: number); + + closed: boolean; + shown: boolean; } interface JQueryStatic { noty: NotyStatic; } -declare var noty: { - - (notyOptions: NotyOptions); - - show(); - close(); - setText(text: string); - setType(type: string); - setTimeout(timeout: number); - - closed: boolean; - shown: boolean; +interface JQuery { + noty: Noty; } + +declare var noty: Noty; diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index b82711120..8ddc072b0 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -286,9 +286,8 @@ interface JQueryPromiseCallback { (value?: T, ...args: any[]): void; } -interface JQueryPromiseOperator { - (callback: JQueryPromiseCallback, ...callbacks: JQueryPromiseCallback[]): JQueryPromise; - (callback: JQueryPromiseCallback[], ...callbacks: JQueryPromiseCallback[]): JQueryPromise; +interface JQueryPromiseOperator { + (callback1: JQueryPromiseCallback|JQueryPromiseCallback[], ...callbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; } /** @@ -301,28 +300,27 @@ interface JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always: JQueryPromiseOperator; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done: JQueryPromiseOperator; + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail: JQueryPromiseOperator; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback: JQueryPromiseCallback): JQueryPromise; - progress(progressCallbacks: JQueryPromiseCallback[]): JQueryPromise; + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Determine the current state of a Deferred object. @@ -356,50 +354,12 @@ interface JQueryPromise { * Interface for the JQuery deferred, part of callbacks */ interface JQueryDeferred extends JQueryPromise { - /** - * Add handlers to be called when the Deferred object is either resolved or rejected. - * - * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. - * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. - */ - always(alwaysCallbacks1?: JQueryPromiseCallback, ...alwaysCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback, ...alwaysCallbacks2: any[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacks2: any[]): JQueryDeferred; - /** - * Add handlers to be called when the Deferred object is resolved. - * - * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. - * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. - */ - done(doneCallbacks1?: JQueryPromiseCallback, ...doneCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback, ...doneCallbacks2: any[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacks2: any[]): JQueryDeferred; - /** - * Add handlers to be called when the Deferred object is rejected. - * - * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. - * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. - */ - fail(failCallbacks1?: JQueryPromiseCallback, ...failCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback, ...failCallbacks2: any[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacks2: any[]): JQueryDeferred; - /** - * Add handlers to be called when the Deferred object generates progress notifications. - * - * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. - */ - progress(progressCallback: JQueryPromiseCallback): JQueryDeferred; - progress(progressCallbacks: JQueryPromiseCallback[]): JQueryDeferred; - /** * Call the progressCallbacks on a Deferred object with the given args. * * @param args Optional arguments that are passed to the progressCallbacks. */ - notify(...args: any[]): JQueryDeferred; + notify(value?: any, ...args: any[]): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given context and args. @@ -407,21 +367,21 @@ interface JQueryDeferred extends JQueryPromise { * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. */ - notifyWith(context: any, ...args: any[]): JQueryDeferred; + notifyWith(context: any, value?: any, ...args: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given args. * * @param args Optional arguments that are passed to the failCallbacks. */ - reject(...args: any[]): JQueryDeferred; + reject(value?: any, ...args: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given context and args. * * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. */ - rejectWith(context: any, ...args: any[]): JQueryDeferred; + rejectWith(context: any, value?: any, ...args: any[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given args. @@ -437,7 +397,7 @@ interface JQueryDeferred extends JQueryPromise { * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. */ - resolveWith(context: any, ...args: any[]): JQueryDeferred; + resolveWith(context: any, value?: T, ...args: any[]): JQueryDeferred; /** * Return a Deferred's Promise object. diff --git a/js-data-angular/js-data-angular-tests.ts b/js-data-angular/js-data-angular-tests.ts new file mode 100644 index 000000000..8e036212f --- /dev/null +++ b/js-data-angular/js-data-angular-tests.ts @@ -0,0 +1,78 @@ +/// + +interface IUser { + +} + +interface CustomScope extends ng.IScope { + + comments: Array; + user: IUser; + users: Array; +} + +angular.module('myApp') + .controller('commentsCtrl', function ($scope:CustomScope, store:JSData.DS, Comment:JSData.DSResourceDefinition, User:JSData.DSResourceDefinition) { + + Comment.findAll().then(function (comments) { + $scope.comments = comments; + }); + + // shortest version + User.bindOne(1, $scope, 'user'); + +// short version + store.bindOne('user', 1, $scope, 'user'); + +// long version + $scope.$watch(function () { + return store.lastModified('user', 1); + }, function () { + $scope.user = store.get('user', 1); + }); + + var params = { + where: { + age: { + '>': 30 + } + } + }; + +// shortest verions + User.bindAll(params, $scope, 'users'); + +// short version + store.bindAll('user', params, $scope, 'users'); + +// long version + $scope.$watch(function () { + return store.lastModified('user'); + }, function () { + $scope.users = store.filter('user', params); + }); + }); + +angular.module('myApp') + .run(function (DS:JSData.DS) { + // We don't register the "User" resource + // as a service, so it can only be used + // via DS.('user', ...) + // The advantage here is that this code + // is guaranteed to be executed, and you + // only ever have to inject "DS" + DS.defineResource('user'); + }) + .factory('Comment', function (DS:JSData.DS) { + // This code won't execute unless you actually + // inject "Comment" somewhere in your code. + // Thanks Angular... + // Some like injecting actual Resource + // definitions, instead of just "DS" + return DS.defineResource('comment'); + }); + +angular.module('myApp') + .config(function (DSProvider:JSData.DSProvider) { + DSProvider.defaults.basePath = '/myApi'; // etc. + }); \ No newline at end of file diff --git a/js-data-angular/js-data-angular.d.ts b/js-data-angular/js-data-angular.d.ts new file mode 100644 index 000000000..242c6d5ab --- /dev/null +++ b/js-data-angular/js-data-angular.d.ts @@ -0,0 +1,28 @@ +// Type definitions for JSDataAngular v2.1.0 +// Project: https://github.com/js-data/js-data-angular +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module JSData { + + interface DSProvider { + defaults:DSConfiguration; + } + + interface DS { + + bindAll(resourceName:string, params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array)=>void):Function; + + bindOne(resourceName:string, id:string | number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + } + + interface DSResourceDefinition { + + bindAll(params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array)=>void):Function; + + bindOne(id:string | number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + } +} \ No newline at end of file diff --git a/js-data-http/js-data-http-tests.ts b/js-data-http/js-data-http-tests.ts new file mode 100644 index 000000000..d7c07d654 --- /dev/null +++ b/js-data-http/js-data-http-tests.ts @@ -0,0 +1,167 @@ +/// + +var adapter = new DSHttpAdapter(); +var store = new JSData.DS(); +store.registerAdapter('http', adapter, { default: true }); + +var ADocument:JSData.DSResourceDefinition = store.defineResource('document'); + +ADocument.inject({ id: 5, author: 'John' }); + +// bypass the data store +adapter.update(ADocument, 5, { author: 'Johnny' }).then(function (document:any) { + document; // { id: 5, author: 'Johnny' } + + // The updated document has NOT been injected into the data store because we bypassed the data store + ADocument.get(document.id); // { id: 5, author: 'John' } +}); + +// Normally you would just go through the data store +ADocument.update(5, { author: 'Johnny' }).then(function (document:any) { + document; // { id: 5, author: 'Johnny' } + + // the updated document has been injected into the data store + ADocument.get(document.id); // { id: 5, author: 'Johnny' } +}); + +ADocument.inject({ id: 5, author: 'John' }); +ADocument.inject({ id: 6, author: 'John' }); + +// bypass the data store +adapter.updateAll(ADocument, { author: 'Johnny' }, { author: 'John' }).then(function (documents) { + documents[0]; // { id: 5, author: 'Johnny' } + + // The updated documents have NOT been injected into the data store because we bypassed the data store + ADocument.filter({ author: 'John' }); // [{...}, {...}] + ADocument.filter({ author: 'Johnny' }); // [] +}); + +// Normally you would just go through the data store +ADocument.updateAll({ author: 'Johnny' }, { author: 'John' }).then(function (documents) { + documents[0]; // { id: 5, author: 'Johnny' } + + // the updated documents have been injected into the data store + ADocument.filter({ author: 'John' }); // [] + ADocument.filter({ author: 'Johnny' }); // [{...}, {...}] +}); + +adapter.PUT('/user/1', { name: 'Johnny' }).then(function (data) { + data.data; // { id: 1, name: 'Johnny', ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +adapter.POST('/user/1', { name: 'John' }).then(function (data) { + data.data; // { id: 1, name: 'John', ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +adapter.HTTP({ url: '/user/1', method: 'put', data: { name: 'Johnny' }}).then(function (data) { + data.data; // { id: 1, name: 'Johnny', ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +adapter.GET('/user/1').then(function (data) { + data.data; // { id: 1, ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +var User:JSData.DSResourceDefinition = store.defineResource('user'); + +var params:any = { + age: { + '>': 30 + } +}; + +// bypass the data store +adapter.findAll(User, params).then(function (users) { + // users[0].age; 55 // etc., etc. + + // the users have NOT been injected into the data store because we bypassed the data store + User.filter(params); // [] +}); + +// normally you would go through the data store +User.findAll(params).then(function (users) { + // users[0].age; 55 // etc., etc. + + // the users have been injected into the data store + User.filter(params); // [{...}, {...}, ...] +}); + +// bypass the data store +adapter.find(ADocument, 5).then(function (document:any) { + document; // { id: 5, author: 'John Anderson' } + + // the document has NOT been injected into the data store because we bypassed the data store + ADocument.get(document.id); // undefined +}); + +// Normally you would just go through the data store +ADocument.find(5).then(function (document:any) { + document; // { id: 5, author: 'John Anderson' } + + // the document has been injected into the data store + ADocument.get(document.id); // { id: 5, author: 'John Anderson' } +}); + +var params:any = { + author: 'John' +}; + +// bypass the data store +adapter.destroyAll(ADocument, params).then(function () { + // the documents have NOT been ejected from the data store because we bypassed the data store + ADocument.filter(params); // [{...}, {...}, ...] +}); + +// normally you would go through the data store +ADocument.destroyAll(params).then(function () { + // the documents have been ejected from the data store + ADocument.filter(params); // [] +}); + +ADocument.inject({ id: 5, author: 'John' }); + +// bypass the data store +adapter.destroy(ADocument, 5).then(function () { + // the document is still in the data store because we bypassed the data store + //ADocument.get(document.id); // { id: 5, author: 'John' } +}); + +// Normally you would just go through the data store +ADocument.destroy(5).then(function () { + // the document has been ejected from the data store + //ADocument.get(document.id); // undefined +}); + +adapter.DEL('/user/1').then(function (data) { + data.data; // 1 + data.headers; // {...} + data.status; // 204 + data.config; //{...} +}); + +// bypass the data store +adapter.create(ADocument, { author: 'John' }).then(function (document:any) { + document; // { id: 5, author: 'John' } + + // The new document has NOT been injected into the data store because we bypassed the data store + ADocument.get(document.id); // undefined +}); + +// Normally you would just go through the data store +ADocument.create({ author: 'John' }).then(function (document:any) { + document; // { id: 5, author: 'John' } + + // the new document has been injected into the data store + ADocument.get(document.id); // { id: 5, author: 'John' } +}); \ No newline at end of file diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts new file mode 100644 index 000000000..295e7cc6f --- /dev/null +++ b/js-data-http/js-data-http.d.ts @@ -0,0 +1,40 @@ +// Type definitions for JSData Http Adapter v1.2.0 +// Project: https://github.com/js-data/js-data-http +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JSData { + + interface DSHttpAdapterOptions { + serialize?: (resourceName:string, data:any)=>any; + deserialize?: (resourceName:string, data:any)=>any; + queryTransform?: (resourceName:string, params:DSFilterParams)=>any; + httpConfig?: any; + forceTrailingSlash?: boolean; + log?: boolean | ((message?:any, ...optionalParams:any[])=> void); + error?: boolean | ((message?:any, ...optionalParams:any[])=> void); + } + + interface DSHttpAdapterPromiseResolveType { + data: any; + headers: any; + status: number; + config: any; + } + + interface DSHttpAdapter extends IDSAdapter { + + new(options?:DSHttpAdapterOptions):DSHttpAdapter; + + // DSHttpAdapter uses axios so options are axios config objects. + HTTP(options?:Object):JSDataPromise; + DEL(url:string, data?:Object, options?:Object):JSDataPromise; + GET(url:string, data?:Object, options?:Object):JSDataPromise; + POST(url:string, data?:Object, options?:Object):JSDataPromise; + PUT(url:string, data?:Object, options?:Object):JSDataPromise; + } +} + +declare var DSHttpAdapter:JSData.DSHttpAdapter; \ No newline at end of file diff --git a/js-data/js-data-node-tests.ts b/js-data/js-data-node-tests.ts new file mode 100644 index 000000000..a0b39a161 --- /dev/null +++ b/js-data/js-data-node-tests.ts @@ -0,0 +1,17 @@ +/// + +import JSData = require('js-data'); +//TODO +//import DSRedisAdapter = require('js-data-redis') +var store = new JSData.DS(); + +// register and use http by default for async operations +//TODO +//store.registerAdapter('redis', new DSRedisAdapter(), {default: true}); + +// simplest model definition +var User = store.defineResource('user'); + +User.find(1).then(function (user: any) { + user; // { id: 1, name: 'John' } +}); \ No newline at end of file diff --git a/js-data/js-data-tests.ts b/js-data/js-data-tests.ts new file mode 100644 index 000000000..c6fe6d13b --- /dev/null +++ b/js-data/js-data-tests.ts @@ -0,0 +1,524 @@ +/// + +interface IUser { + id?: number; + name?: string; + age?: number; + first?: string; + last?: string; + comments?:Array; + profile?:any; +} + +interface IUserWithMethod extends IUser { + fullName?: () => string; +} + +interface IUserWithComputedProperty extends IUser { + fullName?: string; +} + +var store = new JSData.DS(); + +// register and use http by default for async operations +//TODO +//store.registerAdapter('http', new DSHttpAdapter(), {default: true}); + +// simplest model definition +var User = store.defineResource('user'); + +User.find(1).then(function (user:IUser) { + user; // { id: 1, name: 'John' } +}); + +var user:IUser = User.createInstance({name: 'John'}); + +var store = new JSData.DS(); +var User = store.defineResource('user'); +var user:IUser = User.inject({id: 1, name: 'John'}); +var user2:IUser = User.inject({id: 1, age: 30}); + +user; // User { id: 1, name: 'John', age: 30 } +user2; // User { id: 1, name: 'John', age: 30 } +User.get(1); // User { id: 1, name: 'John', age: 30 } +user === user2; // true +user === User.get(1); // true +user2 === User.get(1); // true + +var store = new JSData.DS({ + // set a default lifecycle hook + afterCreate: function () { + } +}); + +var User = store.defineResource({ + name: 'user', + // override the hook for this resource + afterCreate: function () { + } +}); + +User.create({ + name: 'john' +}, { + // override the hook just for this method call + afterCreate: function () { + } +}).then(()=> { + +}); + +var store = new JSData.DS(); + +var UserWithMethod = store.defineResource({ + name: 'user', + methods: { + fullName: function () { + return this.first + ' ' + this.last; + } + } +}); + +var userWithMethod = UserWithMethod.createInstance({first: 'John', last: 'Anderson'}); + +userWithMethod.fullName(); // "John Anderson" + +var store = new JSData.DS(); + +var UserWithComputedProperty = store.defineResource({ + name: 'user', + computed: { + // each function's argument list defines the fields + // that the computed property depends on + fullName: ['first', 'last', function (first:string, last:string) { + return first + ' ' + last; + }], + // shortand, use the array syntax above if you want + // you computed properties to work after you've + // minified your code. Shorthand style won't work when minified + initials: function (first:string, last:string) { + return first.toUpperCase()[0] + '. ' + last.toUpperCase()[0] + '.'; + } + } +}); + +var userWithComputedProperty:IUserWithComputedProperty = UserWithComputedProperty.inject({ + id: 1, + first: 'John', + last: 'Anderson' +}); + +userWithComputedProperty.fullName; // "John Anderson" + +userWithComputedProperty.first = 'Fred'; + +// js-data relies on dirty-checking, so the +// computed property (probably) hasn't been updated yet +userWithComputedProperty.fullName; // "John Anderson" + +// If your browser supports Object.observe this will have no effect +// otherwise it will trigger the dirty-checking +store.digest(); + +userWithComputedProperty.fullName; // "Fred Anderson" + +interface IComment { + comments?: any; + profile?: any; +} + +var aComment:JSData.DSResourceDefinition = store.defineResource('comment'); + +// Get all comments where comment.userId == 5 +aComment.filter({ + where: { + userId: { + '==': 5 + } + } +}); + +// Get all comments where comment.userId == 5 +aComment.filter({ + userId: 5 +}); + +// Get all comments where comment.userId === 5 +aComment.filter({ + where: { + userId: { + '===': 5 + } + } +}); + +// Get all comments where comment.userId != 5 +aComment.filter({ + where: { + userId: { + '!=': 5 + } + } +}); + +// Get all comments where comment.userId !== 5 +aComment.filter({ + where: { + userId: { + '!==': 5 + } + } +}); + +// Get all users where user.age > 30 +User.filter({ + where: { + age: { + '>': 30 + } + } +}); + +// Get all users where user.age >= 30 +User.filter({ + where: { + age: { + '>=': 30 + } + } +}); + +// Get all users where user.age < 30 +User.filter({ + where: { + age: { + '<': 30 + } + } +}); + +// Get all users where user.name is in "John Anderson" +User.filter({ + where: { + name: { + 'in': 'John Anderson' + } + } +}); + +// Get all users where user.role is in ["admin", "owner"] +User.filter({ + where: { + role: { + 'in': ['admin', 'owner'] + } + } +}); + +// Get all users where user.name is NOT in "John Anderson" +User.filter({ + where: { + name: { + 'notIn': 'John Anderson' + } + } +}); + +// Get all users where user.role is NOT in ["admin", "owner"] +User.filter({ + where: { + role: { + 'notIn': ['admin', 'owner'] + } + } +}); + +// Get all users where user.name contains "John" +User.filter({ + where: { + name: { + 'contains': 'John' + } + } +}); + +// Get all users where user.roles contains "admin" +User.filter({ + where: { + roles: { + 'contains': 'admin' + } + } +}); + +// Sorts users by age in ascending order +User.filter({ + orderBy: 'age' +}); + +// Sorts users by age in descending order +User.filter({ + orderBy: ['age', 'DESC'] +}); + +// Sorts users by age in descending order and then sort by name in ascending order to break a tie +User.filter({ + orderBy: [ + ['age', 'DESC'], + ['name', 'ASC'] + ] +}); + +var PAGE_SIZE = 20; +var currentPage = 1; + +interface IPost { + +} + +var Post:JSData.DSResourceDefinition; + +// Grab the first "page" of posts +Post.filter({ + offset: PAGE_SIZE * (currentPage - 1), + limit: PAGE_SIZE +}); + +var User = store.defineResource({ + name: 'user', + relations: { + hasMany: { + comment: { + localField: 'comments', + foreignKey: 'userId' + } + }, + hasOne: { + profile: { + localField: 'profile', + foreignKey: 'userId' + } + }, + belongsTo: { + organization: { + localKey: 'organizationId', + localField: 'organization', + + // if you add this to a belongsTo relation + // then js-data will attempt to use + // a nested url structure, e.g. /organization/15/user/4 + parent: true + } + } + } +}); + +var Organization = store.defineResource({ + name: 'organization', + relations: { + hasMany: { + // this is an example of multiple relations + // of the same type to the same resource + user: [ + { + localField: 'users', + foreignKey: 'organizationId' + }, + { + localField: 'owners', + foreignKey: 'organizationId' + } + ] + } + } +}); + +var Profile = store.defineResource({ + name: 'profile', + relations: { + belongsTo: { + user: { + localField: 'user', + localKey: 'userId' + } + } + } +}); + +var OtherComment = store.defineResource({ + name: 'comment', + relations: { + belongsTo: { + user: { + localField: 'user', + localKey: 'userId' + } + } + } +}); + +User.find(10).then(function (user:IUser) { + // let's assume the server only returned the user + user.comments; // undefined + user.profile; // undefined + + User.loadRelations(user, ['comment', 'profile']).then(function (user:IUser) { + user.comments; // array + user.profile; // object + }); +}); + +var OtherOtherComment = store.defineResource({ + name: 'comment', + relations: { + belongsTo: { + post: { + parent: true, + localKey: 'postId', + localField: 'post' + } + } + } +}); + +// The comment isn't in the data store yet, so js-data wouldn't know +// what the id of the parent "post" would be, so we pass it in manually +OtherOtherComment.find(5, {params: {postId: 4}}); // GET /post/4/comment/5 + +// vs + +var promise = OtherOtherComment.find(5); // GET /comment/5 + +promise.then().catch().finally(); + +OtherOtherComment.inject({id: 1, postId: 2}); + +// We don't have to provide the parentKey here +// because js-data found it in the comment +OtherOtherComment.update(1, {content: 'stuff'}); // PUT /post/2/comment/1 + +// If you don't want the nested for just one of the calls then +// you can do the following: +OtherOtherComment.update(1, {content: 'stuff'}, {params: {postId: false}}); // PUT /comment/1 + +var store = new JSData.DS({ + // set the default + beforeCreate: function (resource, data, cb) { + // do something general + cb(null, data); + } +}); + +var User = store.defineResource({ + name: 'user', + // set just for this resource + beforeCreate: function (resource, data, cb) { + // do something more specific to "users" + cb(null, data); + } +}); + +User.create({name: 'John'}, { + // set just for this method call + beforeCreate: function (resource, data, cb) { + // do something specific for this method call + cb(null, data); + } +}); + +module CustomAdapterTest { + + class MyCustomAdapter implements JSData.IDSAdapter { + + // All of the methods shown here must return a promise + +// "definition" is a resource defintion that would +// be returned by DS#defineResource + +// "options" would be the options argument that +// was passed into the DS method that is calling +// the adapter method + + create(definition:JSData.DSResourceDefinition, attrs:Object, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must resolve the promise with the created item + + var promise:JSData.JSDataPromise; + return promise; + } + + find(definition:JSData.DSResourceDefinition, id:any, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must resolve the promise with the found item + + var promise:JSData.JSDataPromise; + return promise; + } + + findAll(definition:JSData.DSResourceDefinition, params:JSData.DSFilterParams, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must resolve the promise with the found items + + var promise:JSData.JSDataPromise; + return promise; + } + + update(definition:JSData.DSResourceDefinition, id:any, attrs:Object, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must resolve the promise with the updated items + + var promise:JSData.JSDataPromise; + return promise; + } + + updateAll(definition:JSData.DSResourceDefinition, attrs:Object, params:JSData.DSFilterParams, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must resolve the promise with the updated items + + var promise:JSData.JSDataPromise; + return promise; + } + + destroy(definition:JSData.DSResourceDefinition, id:any, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must return a promise + + var promise:JSData.JSDataPromise; + return promise; + } + + destroyAll(definition:JSData.DSResourceDefinition, params:JSData.DSFilterParams, options:JSData.DSConfiguration):JSData.JSDataPromise { + // Must return a promise + + var promise:JSData.JSDataPromise; + return promise; + } + } + + var store = new JSData.DS(); + store.registerAdapter('mca', new MyCustomAdapter(), {default: true}); + // the data store will now use your custom adapter by default +} + +/** + * showing the use of open ended interface to realize typings + * on the Datastore.definitions object where all resource definitions + * are saved. + */ + +interface MyCustomDataStore { + + myResource: JSData.DSResourceDefinition +} + +interface MyResourceDefinition { + +} + +module JSData { + + interface DS { + + definitions: MyCustomDataStore; + } +} + +var store = new JSData.DS(); + +var myResourceDefinition = store.defineResource('myResource'); + +myResourceDefinition = store.definitions.myResource; \ No newline at end of file diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts new file mode 100644 index 000000000..bec41d331 --- /dev/null +++ b/js-data/js-data.d.ts @@ -0,0 +1,285 @@ +// Type definitions for JSData v1.5.4 +// Project: https://github.com/js-data/js-data +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/////////////////////////////////////////////////////////////////////////////// +// js-data module (js-data.js) +/////////////////////////////////////////////////////////////////////////////// + +// defining what exists in JSData and how it looks +declare module JSData { + + interface JSDataPromise { + + then(onFulfilled?: (value: R) => U | JSDataPromise, onRejected?: (error: any) => U | JSDataPromise): JSDataPromise; + + catch(onRejected?: (error: any) => U | JSDataPromise): JSDataPromise; + + // enhanced with finally + finally(finallyCb?:() => U):JSDataPromise; + } + + //TODO switch to class again when typescript supports open ended class declaration + interface DS { + + new(config?:DSConfiguration):DS; + + // rather undocumented + errors:DSErrors; + + // those are objects containing the defined resources and adapters + definitions:any; + adapters:any; + + defaults:DSConfiguration; + + // async + create(resourceName:string, attrs:Object, options?:DSConfiguration):JSDataPromise; + destroy(resourceName:string, id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + destroyAll(resourceName:string, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise; + find(resourceName:string, id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + findAll(resourceName:string, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + loadRelations(resourceName:string, idOrInstance:string | number | Object, relations:string | Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + update(resourceName:string, id:string | number, attrs:Object, options?:DSSaveConfiguration):JSDataPromise; + updateAll(resourceName:string, attrs:Object, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + reap(resourceName:string, options?:DSConfiguration):JSDataPromise; + refresh(resourceName:string, id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + save(resourceName:string, id:string | number, options?:DSSaveConfiguration):JSDataPromise; + + // sync + changeHistory(resourceName:string, id?:string | number):Array; + changes(resourceName:string, id:string | number):Object; + compute(resourceName:string, idOrInstance:number | string | Object ):T; + createInstance(resourceName:string, attrs?:T, options?:DSAdapterOperationConfiguration):T; + defineResource(resourceNameOrDefinition:string | DSResourceDefinitionConfiguration):DSResourceDefinition; + digest():void; + eject(resourceName:string, id:string | number, options?:DSConfiguration):T; + ejectAll(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; + filter(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; + get(resourceName:string, id:string | number, options?:DSConfiguration):T; + getAll(resourceName:string, ids?:Array):Array; + hasChanges(resourceName:string, id:string | number):boolean; + inject(resourceName:string, attrs:T, options?:DSConfiguration):T; + inject(resourceName:string, items:Array, options?:DSConfiguration):Array; + is(resourceName:string, object:Object): boolean; + lastModified(resourceName:string, id?:string | number):number; // timestamp + lastSaved(resourceName:string, id?:string | number):number; // timestamp + link(resourceName:string, id:string | number, relations?:Array):T; + linkAll(resourceName:string, params:DSFilterParams, relations?:Array):T; + linkInverse(resourceName:string, id:string | number, relations?:Array):T; + previous(resourceName:string, id:string | number):T; + unlinkInverse(resourceName:string, id:string | number, relations?:Array):T; + + registerAdapter(adapterId:string, adapter:IDSAdapter, options?:{default: boolean}):void; + } + + interface DSConfiguration extends IDSResourceLifecycleEventHandlers { + actions?: Object; + allowSimpleWhere?: boolean; + basePath?: string; + bypassCache?: boolean; + cacheResponse?: boolean; + defaultAdapter?: string; + defaultFilter?: (collection:Array, resourceName:string, params:DSFilterParams, options:DSConfiguration)=>Array; + eagerEject?: boolean; + // TODO enable when eagerInject in DS#create is implemented + //eagerInject?: boolean; + endpoint?: string; + error?: boolean | ((message?:any, ...optionalParams:any[])=> void); + fallbackAdapters?: Array; + findAllFallbackAdapters?: Array; + findAllStrategy?: string; + findBelongsTo?: boolean; + findFallbackAdapters?: Array; + findHasOne?: boolean; + findHasMany?: boolean; + findInverseLinks?: boolean; + findStrategy?: string + idAttribute?: string; + ignoredChanges?: Array; + // TODO ignoreMissing is undocumented + //ignoreMissing: boolean; + keepChangeHistory?: boolean; + loadFromServer?: boolean; + log?: boolean | ((message?: any, ...optionalParams: any[])=> void); + maxAge?: number; + notify?: boolean; + reapAction?: string; + reapInterval?: number; + resetHistoryOnInject?: boolean; + strategy?: string; + upsert?: boolean; + useClass?: boolean; + useFilter?: boolean; + } + + interface DSAdapterOperationConfiguration extends DSConfiguration { + adapter?: string + } + + interface DSSaveConfiguration extends DSAdapterOperationConfiguration { + changesOnly?: boolean; + } + + interface DSResourceDefinitionConfiguration extends DSConfiguration { + name: string; + computed?: any; + methods?: any; + relations?: { + hasMany?: Object; + hasOne?: Object; + belongsTo?: Object; + }; + } + + interface DSResourceDefinition extends DSResourceDefinitionConfiguration { + + //async + create(attrs:Object, options?:DSConfiguration):JSDataPromise; + destroy(id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + destroyAll(params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise; + find(id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + findAll(params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + loadRelations(idOrInstance:string | number | Object, relations:string | Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + update(id:string | number, attrs:Object, options?:DSSaveConfiguration):JSDataPromise; + updateAll(attrs:Object, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + reap(resourceNametions?:DSConfiguration):JSDataPromise; + refresh(id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + save(id:string | number, options?:DSSaveConfiguration):JSDataPromise; + + // sync + changeHistory(id?:string | number):Array; + changes(id:string | number):Object; + compute(idOrInstance:number | string | Object ):T; + createInstance(attrs?:T, options?:DSAdapterOperationConfiguration):T; + digest():void; + eject(id:string | number, options?:DSConfiguration):T; + ejectAll(params:DSFilterParams, options?:DSConfiguration):Array; + filter(params:DSFilterParams, options?:DSConfiguration):Array; + get(id:string | number, options?:DSConfiguration):T; + getAll(ids?:Array):Array; + hasChanges(id:string | number):boolean; + inject(attrs:T, options?:DSConfiguration):T; + inject(items:Array, options?:DSConfiguration):Array; + is(object:Object): boolean; + lastModified(id?:string | number):number; // timestamp + lastSaved(id?:string | number):number; // timestamp + link(id:string | number, relations?:Array):T; + linkAll(params:DSFilterParams, relations?:Array):T; + linkInverse(id:string | number, relations?:Array):T; + previous(id:string | number):T; + unlinkInverse(id:string | number, relations?:Array):T; + } + + interface DSFilterParams { + where?: Object; + + limit?: number; + + skip?: number; + offset?: number; + + orderBy?: string | Array | Array>; + sort?: string | Array | Array>; + } + + interface IDSResourceLifecycleValidateEventHandlers { + beforeValidate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + validate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterValidate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleCreateEventHandlers { + beforeCreate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterCreate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleCreateInstanceEventHandlers { + beforeCreateInstance?: (resourceName:string, data:any)=>void; + afterCreateInstance?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleUpdateEventHandlers { + beforeUpdate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterUpdate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleDestroyEventHandlers { + beforeDestroy?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterDestroy?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleInjectEventHandlers { + beforeInject?: (resourceName:string, data:any)=>void; + afterInject?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleEjectEventHandlers { + beforeEject?: (resourceName:string, data:any)=>void; + afterEject?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleReapEventHandlers { + beforeReap?: (resourceName:string, data:any)=>void; + afterReap?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleEventHandlers extends IDSResourceLifecycleCreateEventHandlers, + IDSResourceLifecycleCreateInstanceEventHandlers, + IDSResourceLifecycleValidateEventHandlers, + IDSResourceLifecycleUpdateEventHandlers, + IDSResourceLifecycleDestroyEventHandlers, + IDSResourceLifecycleInjectEventHandlers, + IDSResourceLifecycleEjectEventHandlers, + IDSResourceLifecycleReapEventHandlers { + + } + + // errors + interface DSErrors { + + // types + IllegalArgumentError:DSError; + IA:DSError; + RuntimeError:DSError; + R:DSError; + NonexistentResourceError:DSError; + NER:DSError; + } + + interface DSError extends Error { + new (message?:string):DSError; + message: string; + type: string; + } + + // DSAdapter interface + interface IDSAdapter { + create(config:DSResourceDefinition, attrs:Object, options?:DSConfiguration):JSDataPromise; + + destroy(config:DSResourceDefinition, id:string | number, options?:DSConfiguration):JSDataPromise; + + destroyAll(config:DSResourceDefinition, params:DSFilterParams, options?:DSConfiguration):JSDataPromise; + + find(config:DSResourceDefinition, id:string | number, options?:DSConfiguration):JSDataPromise; + + findAll(config:DSResourceDefinition, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; + + update(config:DSResourceDefinition, id:string | number, attrs:Object, options?:DSConfiguration):JSDataPromise; + + updateAll(config:DSResourceDefinition, attrs:Object, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; + } +} + +// declaring the existing global js object +declare var JSData:{ + DS: JSData.DS; + DSErrors: JSData.DSErrors; +}; + +//Support node require +declare module 'js-data' { + + export = JSData; +} \ No newline at end of file diff --git a/jsnox/jsnox-tests.ts b/jsnox/jsnox-tests.ts new file mode 100644 index 000000000..4e990766b --- /dev/null +++ b/jsnox/jsnox-tests.ts @@ -0,0 +1,57 @@ +/// +import React = require('react'); +import jsnox = require('jsnox'); +var $ = jsnox(React); + +interface PersonProps { + firstName: string + lastName: string + age: number +} + +var Person = React.createClass({ + render(): React.ReactHTMLElement { return null } +}); + +var PersonTag = React.createFactory(Person); + +var clickHandler: React.MouseEventHandler + +// Tests with spec string +function spec_string () { + var result: React.ReactHTMLElement + + // just spec string + result = $('div') + + // No properties, just children + result = $('div', 'hello') // one string child + result = $('div', $('span', 'world')) // one element child + result = $('div', ['hello', $('span', 'world')]) // mixed array of children + + // With html properties + result = $('div', { onClick: clickHandler }) // no children + result = $('div', { onClick: clickHandler }, 'hello') // one string child + result = $('div', { onClick: clickHandler }, $('span', 'world')) // one element child + result = $('div', { onClick: clickHandler }, ['hello', $('span', 'world')]) // mixed array of children +} + +// Tests with react component +function react_component() { + var result: React.ReactHTMLElement + + // with nothing more + result = $(Person) + + // No properties, just children + result = $(Person, 'hello') // one string child + result = $(Person, $('span', 'world')) // one element child + result = $(Person, ['hello', $('span', 'world')]) // mixed array of children + + // With component props + var props = { firstName: 'Bob', lastName: 'Garfield', age: 72 } + result = $(Person, props) // no children + result = $(Person, props, 'hello') // one string child + result = $(Person, props, $('span', 'world')) // one element child + result = $(Person, props, ['hello', PersonTag()]) // mixed array of children +} \ No newline at end of file diff --git a/jsnox/jsnox.d.ts b/jsnox/jsnox.d.ts new file mode 100644 index 000000000..b3e4460c0 --- /dev/null +++ b/jsnox/jsnox.d.ts @@ -0,0 +1,68 @@ +// Type definitions for JSnoX +// Project: https://github.com/af/jsnox +// Definitions by: Steve Baker +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'jsnox' { + + /* + * JSnoX requires an object with a createElement method. + * This will normally be the React object but could be something else + */ + interface ReactLikeObject { + createElement

(type: React.ComponentClass

| string, + props: P, children: React.ReactNode): React.ReactElement

; + } + + interface Module { + (reactObj: ReactLikeObject): CreateElement + } + + interface CreateElement { + /** + * Renders an HTML element from the given spec string, with children but without + * extra props. + * @param specString A string that defines a component in a way that resembles + * CSS selectors. Eg. "input:email#foo.bar.baz[name=email][required]" + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ + (specString: string, children: React.ReactNode): React.ReactHTMLElement + + /** + * Renders an HTML element from the given spec string, with optional props + * and children + * @param specString A string that defines a component in a way that resembles + * CSS selectors. Eg. "input:email#foo.bar.baz[name=email][required]" + * @param props Object of html attribute key-value pairs + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ + (specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.ReactHTMLElement + + + /** + * Renders a React component, with children but no props + * @param component A plain React component (created from React.createClass()) or + * component factory (created from React.createFactory()) + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ +

(component: React.ComponentClass

, children: React.ReactNode): React.ReactElement

+ + /** + * Renders a React component, with optional props and children + * @param component A plain React component (created from React.createClass()) or + * component factory (created from React.createFactory()) + * @param props Props object to pass to the component + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ +

(component: React.ComponentClass

, props?: P, children?: React.ReactNode): React.ReactElement

+ } + + var exports: Module + export = exports +} diff --git a/jsplumb/jquery.jsPlumb.d.ts b/jsplumb/jquery.jsPlumb.d.ts index 39d5bf869..3e37b5774 100644 --- a/jsplumb/jquery.jsPlumb.d.ts +++ b/jsplumb/jquery.jsPlumb.d.ts @@ -19,23 +19,26 @@ interface jsPlumbInstance { addEndpoint(ep: string): any; removeClass(el: any, clazz: string): void; hasClass(el: any, clazz: string): void; - draggable(el: string, options?: DragOptions): jsPlumbInstance; - draggable(ids: string[], options?: DragOptions): jsPlumbInstance; - connect(connection: ConnectParams, referenceParams?: ConnectParams): Connection; - makeSource(el: string, options: SourceOptions): void; - makeTarget(el: string, options: TargetOptions): void; - repaintEverything(): void; - detachEveryConnection(): void; + draggable(el: string, options?: DragOptions): jsPlumbInstance; + draggable(ids: string[], options?: DragOptions): jsPlumbInstance; + connect(connection: ConnectParams, referenceParams?: ConnectParams): Connection; + makeSource(el: string, options: SourceOptions): void; + makeTarget(el: string, options: TargetOptions): void; + repaintEverything(): void; + detachEveryConnection(): void; detachAllConnections(el: string): void; - removeAllEndpoints(el: string, recurse?: boolean): jsPlumbInstance; - removeAllEndpoints(el: Element, recurse?: boolean): jsPlumbInstance; - select(params: SelectParams): Connections; - getConnections(options?: any, flat?: any): any[]; - deleteEndpoint(uuid: string, doNotRepaintAfterwards?: boolean): jsPlumbInstance; - deleteEndpoint(endpoint: Endpoint, doNotRepaintAfterwards?: boolean): jsPlumbInstance; - repaint(el: string): jsPlumbInstance; - repaint(el: Element): jsPlumbInstance; - + removeAllEndpoints(el: string, recurse?: boolean): jsPlumbInstance; + removeAllEndpoints(el: Element, recurse?: boolean): jsPlumbInstance; + select(params: SelectParams): Connections; + getConnections(options?: any, flat?: any): any[]; + deleteEndpoint(uuid: string, doNotRepaintAfterwards?: boolean): jsPlumbInstance; + deleteEndpoint(endpoint: Endpoint, doNotRepaintAfterwards?: boolean): jsPlumbInstance; + repaint(el: string): jsPlumbInstance; + repaint(el: Element): jsPlumbInstance; + getInstance(): jsPlumbInstance; + getInstance(defaults: Defaults): jsPlumbInstance; + getInstanceIndex(): number; + SVG: string; CANVAS: string; VML: string; diff --git a/knockout-transformations/knockout-transformations-tests.ts b/knockout-transformations/knockout-transformations-tests.ts new file mode 100644 index 000000000..5f132858c --- /dev/null +++ b/knockout-transformations/knockout-transformations-tests.ts @@ -0,0 +1,206 @@ +/// +/// + +// Test map +var sourceItems: KnockoutObservableArray = ko.observableArray([1, 2, 3, 4, 5]); +var squares: KnockoutObservableArray = sourceItems.map(function (x) { return x * x; }); +var squaresAsStrings: KnockoutObservableArray = sourceItems.map(function (x) { return (x * x).toString(); }); + +sourceItems.push(6); +// 'squares' has automatically updated and now contains [1, 4, 9, 16, 25, 36] +// 'squaresAsStrings' has automatically updated and now contains ['1', '4', '9', '16', '25', '36'] + +sourceItems.reverse(); +// 'squares' now contains [36, 25, 16, 9, 4, 1] +// 'squaresAsStrings' now contains ['36', '25', '16', '9', '4', '1'] + +// Test Filtering + +var evenSquares: KnockoutObservableArray = squares.filter(function (x) { return x % 2 === 0; }); +// evenSquares is now an observable containing [36, 16, 4] + +sourceItems.push(9); +// This has no effect on evenSquares, because 9*9=81 is odd + +sourceItems.push(10); +// evenSquares now contains [36, 16, 4, 100] + +var sortedEvenSquares: KnockoutObservableArray = evenSquares.sortBy(function (evenSquare, descending) { + return descending(evenSquare); +}); +// sortedEvenSquares now contains [100, 36, 16, 4] + +class Person { + public name: KnockoutObservable; + public yearOfBirth: KnockoutObservable; + + constructor(name: string, yearOfBirth: number) { + this.name = ko.observable(name); + this.yearOfBirth = ko.observable(yearOfBirth); + } +} + +var persons: KnockoutObservableArray = ko.observableArray([ + new Person("Marilyn Monroe", 1926), + new Person("Abraham Lincoln", 1809), + new Person("Mother Teresa", 1910), + new Person("John F. Kennedy", 1917), + new Person("Martin Luther King", 1929), + new Person("Nelson Mandela", 1918), + new Person("Winston Churchill", 1874), + new Person("Bill Gates", 1955), + new Person("Muhammad Ali", 1942), + new Person("Mahatma Gandhi", 1869), + new Person("Queen Elizabeth II", 1926) +]); + +// Persons sorted by name +var sortedByName: KnockoutObservableArray = persons.sortBy(function (person) { + return person.name(); +}); + +// sortedByName now contains +// [ +// new Person("Abraham Lincoln", 1809), +// new Person("Bill Gates", 1955), +// new Person("John F. Kennedy", 1917), +// new Person("Mahatma Gandhi", 1869), +// new Person("Marilyn Monroe", 1926), +// new Person("Martin Luther King", 1929), +// new Person("Mother Teresa", 1910), +// new Person("Muhammad Ali", 1942) +// new Person("Nelson Mandela", 1918), +// new Person("Queen Elizabeth II", 1926), +// new Person("Winston Churchill", 1874), +// ] + +// Persons sorted by year of birth descending and then by name +var sortedByYearOfBirthAndThenName: KnockoutObservableArray = persons.sortBy(function (person, descending) { + return [descending(person.yearOfBirth()), person.name()]; +}); + +// sortedByYearOfBirthAndThenName now contains +// [ +// new Person("Abraham Lincoln", 1809), +// new Person("Mahatma Gandhi", 1869), +// new Person("Winston Churchill", 1874), +// new Person("Mother Teresa", 1910), +// new Person("John F. Kennedy", 1917), +// new Person("Nelson Mandela", 1918), +// new Person("Martin Luther King", 1929), +// new Person("Bill Gates", 1955), +// new Person("Marilyn Monroe", 1926), +// new Person("Queen Elizabeth II", 1926), +// new Person("Muhammad Ali", 1942) +// ] + +var squareIndex: KnockoutObservable<{ [index: string]: number[] }> = squares.indexBy(function (square) { + return square % 2 === 0 ? 'even' : 'odd'; +}); + +// squareIndex now contains +// { even: [36, 16, 4], odd: [25, 9, 1] } + +// Persons indexed by year of birth +var personsIndexedByYearBirth: KnockoutObservable<{ [index: number]: Person[] }> = persons.indexBy(function (person) { + return person.yearOfBirth(); +}); + +// personsIndexedByYearBirth now contains +// { +// 1809: [new Person("Abraham Lincoln", 1809)], +// 1869: [new Person("Mahatma Gandhi", 1869)], +// 1874: [new Person("Winston Churchill", 1874)], +// 1910: [new Person("Mother Teresa", 1910)], +// 1917: [new Person("John F. Kennedy", 1917)], +// 1918: [new Person("Nelson Mandela", 1918)], +// 1929: [new Person("Martin Luther King", 1929)], +// 1955: [new Person("Bill Gates", 1955)], +// 1926: [new Person("Marilyn Monroe", 1926), +// new Person("Queen Elizabeth II", 1926)], +// 1942: [new Person("Muhammad Ali", 1942)] +// } + +// Persons indexed uniquely by name. +// Notice unique indexes requires items to map to distint keys; +// otherwise an exception is thrown. +var personsIndexedByName: KnockoutObservable<{ [name: string]: Person }> = persons.uniqueIndexBy(function (person) { + return person.name(); +}); + +// personsIndexedByName now contains +// { +// "Abraham Lincoln": new Person("Abraham Lincoln", 1809), +// "Mahatma Gandhi": new Person("Mahatma Gandhi", 1869), +// "Winston Churchill": new Person("Winston Churchill", 1874), +// "Mother Teresa": new Person("Mother Teresa", 1910), +// "John F. Kennedy": new Person("John F. Kennedy", 1917), +// "Nelson Mandela": new Person("Nelson Mandela", 1918), +// "Martin Luther King": new Person("Martin Luther King", 1929), +// "Bill Gates": new Person("Bill Gates", 1955), +// "Marilyn Monroe": new Person("Marilyn Monroe", 1926), +// "Queen Elizabeth II": new Person("Queen Elizabeth II", 1926), +// "Muhammad Ali": new Person("Muhammad Ali", 1942) +// } + +var texts: KnockoutObservableArray = ko.observableArray(['foo', 'bar', 'baz', 'qux', 'quux']); +// Index texts by +var indexedTexts: KnockoutObservable<{ [suffixOrPrefix: string]: string[] }> = texts.indexBy(function (text) { + var firstLetter = text[0]; + var lastLetter = text[text.length - 1]; + return [firstLetter, lastLetter]; +}); + +// indexedTexts now contains +// { +// f: ['foo'], +// b: ['bar', 'baz'], +// q: ['qux', 'quux'], +// o: ['foo'], +// r: ['bar'], +// z: ['baz'], +// x: ['qux', 'quux'] +// } + + +(() => { + var sourceItems: KnockoutObservableArray = ko.observableArray([1, 2, 3, 4, 5]); + var asString: KnockoutObservableArray; + + asString = sourceItems.map((x: number) => x.toString()); + + asString = sourceItems.map({ + mapping: (x: number) => x.toString(), + }); + + asString = sourceItems.map({ + mapping: (x: number) => x.toString(), + disposeItem: (x: string) => console.log('disposing map to', x), + }); + + asString = sourceItems.map({ + mappingWithDisposeCallback: (x: number) => ({ + mappedValue: x.toString(), + dispose: () => console.log('disposing map from', x), + }), + }); + + asString = sourceItems.map(x => x.toString()); + + asString = sourceItems.map({ + mapping: x => x.toString(), + }); + + asString = sourceItems.map({ + mapping: x => x.toString(), + disposeItem: x => console.log('disposing map to', x), + }); + + asString = sourceItems.map({ + mappingWithDisposeCallback: x => ({ + mappedValue: x.toString(), + dispose: () => console.log('disposing map from', x), + }), + }); + +}); diff --git a/knockout-transformations/knockout-transformations.d.ts b/knockout-transformations/knockout-transformations.d.ts new file mode 100644 index 000000000..3048e7a0f --- /dev/null +++ b/knockout-transformations/knockout-transformations.d.ts @@ -0,0 +1,35 @@ +// Type definitions for knockout-transformations 2.0.0 +// Project: https://github.com/One-com/knockout-transformations +// Definitions by: John Reilly , Wim Looman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module KnockoutTransformations { + interface Mapping { + (value: T): TResult; + } + interface MappingOption { + mapping: Mapping; + disposeItem?: (item: TResult) => void; + } + interface MappingWithDisposeCallbackOption { + mappingWithDisposeCallback: (value: T) => { + mappedValue: TResult; + dispose: () => void; + }; + } +} + +interface KnockoutObservableArrayFunctions { + map(mapping: KnockoutTransformations.Mapping): KnockoutObservableArray; + map(mapping: KnockoutTransformations.MappingOption): KnockoutObservableArray; + map(mapping: KnockoutTransformations.MappingWithDisposeCallbackOption): KnockoutObservableArray; + + filter(predicate: (value: T) => boolean): KnockoutObservableArray; + sortBy(sorter: (value: T, descending: (sorter: any) => any) => any): KnockoutObservableArray; + indexBy(indexer: (value: T) => string): KnockoutObservable<{ [index: string]: T[] }>; + indexBy(indexer: (value: T) => string[]): KnockoutObservable<{ [index: string]: T[] }>; + indexBy(indexer: (value: T) => any): KnockoutObservable; + uniqueIndexBy(indexer: (value: T) => string): KnockoutObservable<{ [index: string]: T }>; +} diff --git a/knockout.validation/knockout.validation.d.ts b/knockout.validation/knockout.validation.d.ts index f0b956d03..3ce139a99 100644 --- a/knockout.validation/knockout.validation.d.ts +++ b/knockout.validation/knockout.validation.d.ts @@ -108,7 +108,6 @@ interface KnockoutValidationGroup { interface KnockoutValidationStatic { init(options?: KnockoutValidationConfiguration, force?: boolean): void; - configure(options: KnockoutValidationConfiguration): void; reset(): void; group(obj: any, options?: any): KnockoutValidationErrors; diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 9e7015659..5aa7c61cb 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -118,6 +118,7 @@ interface KnockoutBindingContext { $parents: any[]; $root: any; $data: any; + $rawData: any | KnockoutObservable; $index?: KnockoutObservable; $parentContext?: KnockoutBindingContext; @@ -132,8 +133,8 @@ interface KnockoutAllBindingsAccessor { } interface KnockoutBindingHandler { - init? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; - update? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + init?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; }; + update?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => void; options?: any; preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string; } @@ -294,7 +295,7 @@ interface KnockoutUtils { stringTokenize(str: string, delimiter: string): string[]; - stringStartsWith(str: string, startsWith: string): string; + stringStartsWith(str: string, startsWith: string): boolean; domNodeIsContainedBy(node: any, containedByNode: any): boolean; @@ -343,6 +344,7 @@ interface KnockoutArrayChange { status: string; value: T; index: number; + moved?: number; } ////////////////////////////////// diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index 78d464f07..7b0c8174e 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -163,6 +163,7 @@ function test_bindings() { ko.bindingHandlers.yourBindingName = { init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { + return { "controlsDescendantBindings": true }; }, update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { } @@ -655,4 +656,4 @@ function testUnwrapUnion() { var possibleObs: KnockoutObservable | number; var num = ko.unwrap(possibleObs); -} \ No newline at end of file +} diff --git a/ko.plus/ko.plus-tests.ts b/ko.plus/ko.plus-tests.ts new file mode 100644 index 000000000..992332e2b --- /dev/null +++ b/ko.plus/ko.plus-tests.ts @@ -0,0 +1,132 @@ +/// +/// + +// Tests for ko.plus.d.ts +// Project: https://github.com/stevegreatrex/ko.plus +// Definitions by: Howard Richards +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* + Version 1.0 - initial commit + + Version 1.1 - added test for makeEditable + + Note: Typescript version 1.4 or higher is required for union types + and type declarations +*/ + +function CommandTests() { + + // initalize command with an execute method + var cmd1 = ko.command(() => { + return "Hello cmd1"; + }); + + // initialize command and add done and fail callbacks + var cmd2 = ko.command(() => { + return "Hello cmd2"; + }) + .done((data: any) => { + alert("success"); + }) + .fail((error: string) => { + alert(error); + }); + + // initialize command with options (action only) + var cmd3 = ko.command({ + action: () => { return "Hello cmd3"; } + }); + + // initialize command with options (action only) + var cmd4 = ko.command({ + action: () => { return "Hello cmd4"; } + }); + + + // test execute the command + cmd1(); + + // test properties of the commmand + var isRunning = cmd1.isRunning(); + var failed = cmd1.failed(); + var completed = cmd1.completed(); + var canExecute = cmd1.canExecute(); + +} + +function EditableTests() { + + // test ko.editable initializers + var edit1 = ko.editable(); // no intializer + + var edit2 = ko.editable("test"); // with typed initializer + + var edit3 = ko.editable({ test: true }); // with anything + + var edit4 = ko.editable(1); // with union types + var edit5 = ko.editable("test"); + + ko.editable.makeEditable(this); + + // test getting the value + var value = edit1(); + + // test editable + var isEditing = edit1.isEditing(); + + // test editableArray functions: + edit1.beginEdit(); + edit1.endEdit(); + edit1.cancelEdit(); + edit1.rollback(); +} + +function EditableArrayTests() { + + // test ko.editable intializers + var edit1 = ko.editableArray(); // no init value + + var edit2 = ko.editableArray([1, 2, 3]); // init value + + var edit3 = ko.editableArray(["a", 1, false, {}]); // mixed + + var edit4 = ko.editableArray(["a", 1]); // constrained + + // test getting the array value + var value = edit1(); + + // test properties + var isEditing = edit1.isEditing(); + + // test functions: + edit1.beginEdit(); + edit1.endEdit(); + edit1.cancelEdit(); + edit1.rollback(); + +} + +function SortableTests() { + + // sorting is added via an extender, there are no .d.ts + // types for this at present + var sort1 = ko.observableArray([1, 2, 3]).extend({ sortable: true }); + + // extended sort definition with key+descending + var sort2 = ko.observableArray([ + { id: 3, name: "alice" }, + { id: 2, name: "james" }, + { id: 1, name: "bob" }, + ]).extend({ + sortable: { + key: 'id', + descending: false + } + }); + + sort2.setSourceKey("id"); + sort2.sortDescending(true); + sort2.setSourceKey("name"); + sort2.sortDescending(false); +} \ No newline at end of file diff --git a/ko.plus/ko.plus.d.ts b/ko.plus/ko.plus.d.ts new file mode 100644 index 000000000..65301aa7c --- /dev/null +++ b/ko.plus/ko.plus.d.ts @@ -0,0 +1,155 @@ +// Type definitions for ko.plus v0.0.21 +// Project: https://github.com/stevegreatrex/ko.plus +// Definitions by: Howard Richards +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * + * Extensions to KO to provide a command, editable and sortable patterns + * - available at http://www.nuget.org/packages/ko.plus/ + * + * (requires TypeScript version 1.4 or higher) + * + * Version 1.0 - initial commit + * + * Version 1.1 - fixed bug - makeEditable is now a function on .editable + * also refactored how the Editable classes inherit to simplify + */ + +// +// Add methods to the 'ko' Knockout object +// +interface KnockoutStatic { + // create a command - two overloads + command: (param: KoPlus.Callback | KoPlus.CommandOptions) => KoPlus.Command; + + editable: KoPlus.EditableStatic; + editableArray: KoPlus.EditableArrayStatic; +} + +//#region Sortable type extensions + +// +// extends the KnockoutObservableArray to add sorting methods +// see https://github.com/stevegreatrex/ko.plus#properties-and-functions +// +interface KnockoutObservableArray { + sortKey: KnockoutObservable; + + sortDescending: KnockoutObservable; + + setSourceKey: (key: string) => void; +} + +//#endregion + +// +// declare new binding handlers in ko.plus +// +interface KnockoutBindingHandlers { + loadingWhen: KnockoutBindingHandler; + + command: KnockoutBindingHandler; + + sortBy: KnockoutBindingHandler; +} + +// +// namespace for ko.plus types +// +declare module KoPlus { + // predefine a callback type + export type Callback = () => void; + + //#region Command types + + // + // the Command interface - returned by ko.command(..) + // + export interface Command { + // execute the command + (): void; + + // + // properties: https://github.com/stevegreatrex/ko.plus#properties + // + isRunning: KnockoutObservable; + + canExecute: KnockoutComputed; + + failed: KnockoutObservable; + + completed: KnockoutObservable; + + // + // functions + // see https://github.com/stevegreatrex/ko.plus#functions + // + done: (callback: (data: any) => void) => Command; + + fail: (callback: (error: string) => void) => Command; + + always: (callback: Callback) => Command; + + then: (resolve: Callback, reject: Callback) => Command; + } + + // + // options when defining a command using the option method + // see https://github.com/stevegreatrex/ko.plus#options + // + export interface CommandOptions { + // [required] sets the command action method + action: Callback; + + // [optional] function to determine if command can be executed + canExecute?: () => boolean; + + // [optional] context to use in the command + context?: any; + } + + //#endregion + + //#region Editable types + + export interface EditableStatic extends KnockoutObservableStatic { + (value?: T): Editable; + + makeEditable(target: any): void; + } + + export interface EditableArrayStatic extends KnockoutObservableArrayStatic { + (value?: Array): EditableArray; + + makeEditable(target: any): void; //> + } + + // + // defines common editable functions and isEditing property + // (used by both editable and editableArray + // + export interface EditableFunctions { + isEditing: KnockoutObservable; + beginEdit(): void; + endEdit(): void; + cancelEdit(): void; + rollback(): void; + } + + // + // extend the standard KnockoutObservable to add editable functions + // + export interface Editable extends KnockoutObservable, EditableFunctions { + } + + // + // extend the standard KnockoutObservableArray to add editable functions + // + export interface EditableArray extends KnockoutObservableArray, EditableFunctions { + } + + //#endregion +} \ No newline at end of file diff --git a/lazy.js/lazy.js-tests.ts b/lazy.js/lazy.js-tests.ts index cab0787c3..5e45ccf13 100644 --- a/lazy.js/lazy.js-tests.ts +++ b/lazy.js/lazy.js-tests.ts @@ -74,6 +74,10 @@ function fnMemoCallback(memo: Bar, value: Foo): Bar { return bar; } +function fnCompareCallback(x: any, y: any): number { + return num; +} + function fnGeneratorCallback(index: number): Foo { return foo; } @@ -140,7 +144,13 @@ fooSequence = fooSequence.reverse(); fooSequence = fooSequence.shuffle(); bool = fooSequence.some(); bool = fooSequence.some(fnTestCallback); +fooSequence = fooSequence.sort(); +fooSequence = fooSequence.sort(fnCompareCallback); +fooSequence = fooSequence.sort(fnCompareCallback, bool); +fooSequence = fooSequence.sortBy(str); +fooSequence = fooSequence.sortBy(str, bool); fooSequence = fooSequence.sortBy(fnNumberCallback); +fooSequence = fooSequence.sortBy(fnNumberCallback, bool); fooSequence = fooSequence.sortedIndex(foo); fooSequence = fooSequence.sum(); fooSequence = fooSequence.sum(fnNumberCallback); @@ -148,6 +158,7 @@ fooSequence = fooSequence.takeWhile(fnTestCallback); fooSequence = fooSequence.union(fooArr); fooSequence = fooSequence.uniq(); fooSequence = fooSequence.where(obj); +fooSequence = fooSequence.without(foo, foo); fooSequence = fooSequence.without(fooArr); fooSequence = fooSequence.zip(arr); diff --git a/lazy.js/lazy.js.d.ts b/lazy.js/lazy.js.d.ts index d388ba6f7..02cf1833b 100644 --- a/lazy.js/lazy.js.d.ts +++ b/lazy.js/lazy.js.d.ts @@ -73,6 +73,10 @@ declare module LazyJS { (index: number): T; } + interface CompareCallback { + (x: any, y: any): number; + } + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - interface Iterator { @@ -153,7 +157,9 @@ declare module LazyJS { rest(count?: number): Sequence; shuffle(): Sequence; some(predicateFn?: TestCallback): boolean; - sortBy(sortFn: NumberCallback): Sequence; + sort(sortFn?: CompareCallback, descending?: boolean): Sequence; + sortBy(sortFn: string, descending?: boolean): Sequence; + sortBy(sortFn: NumberCallback, descending?: boolean): Sequence; sortedIndex(value: T): Sequence; size(): number; sum(valueFn?: NumberCallback): Sequence; @@ -161,6 +167,7 @@ declare module LazyJS { union(var_args: T[]): Sequence; uniq(): Sequence; where(properties: Object): Sequence; + without(...var_args: T[]): Sequence; without(var_args: T[]): Sequence; zip(var_args: T[]): Sequence; diff --git a/leaflet-label/leaflet-label-tests.ts b/leaflet-label/leaflet-label-tests.ts new file mode 100644 index 000000000..57a2feb45 --- /dev/null +++ b/leaflet-label/leaflet-label-tests.ts @@ -0,0 +1,142 @@ +/// + +var map: L.Map; +var label: L.Label; + +// Icon +var icon: L.Icon = new L.Icon({ labelAnchor: L.point(1, 1) }); + +// CircleMarker +var circleMarker: L.CircleMarker = new L.CircleMarker(new L.LatLng(0, 0), { labelAnchor: L.point(1, 1) }); + +circleMarker = circleMarker.bindLabel('test', { + className: 'thingy', + clickable: true, + direction: 'right', + noHide: false, + offset: new L.Point(0, 0), + opacity: 0.5, + zoomAnimation: true, +}); + +circleMarker.showLabel(); +circleMarker.hideLabel(); +circleMarker.setLabelNoHide(true); +circleMarker.updateLabelContent('test2'); +label = circleMarker.getLabel() +circleMarker = circleMarker.unbindLabel(); + +// Marker +var marker = new L.Marker(new L.LatLng(0, 0)); + +marker = marker.bindLabel('test', { + className: 'thingy', + clickable: true, + direction: 'right', + noHide: false, + offset: new L.Point(0, 0), + opacity: 0.5, + zoomAnimation: true, +}); + +marker.showLabel(); +marker.hideLabel(); +marker.setLabelNoHide(true); +marker.updateLabelContent('test2'); +label = marker.getLabel() +marker = marker.unbindLabel(); +marker.setOpacity(0.5); +marker.setOpacity(0.5, true); + +// Path +var path: L.Path = new L.Polyline([L.latLng(0, 0)]); + +path = path.bindLabel('test', { + className: 'thingy', + clickable: true, + direction: 'right', + noHide: false, + offset: new L.Point(0, 0), + opacity: 0.5, + zoomAnimation: true, +}); + +path.updateLabelContent('test2'); + +path = path.unbindLabel(); + +// Label + +label = new L.Label(); + +label.setOpacity(0.7); +label.updateZIndex(5); +label.setLatLng(new L.LatLng(3, 3)); +label.setContent('thing'); +label.close(); + +// Examples from the README +var example: () => void; + +example = () => { + L.marker(L.latLng(-37.7772, 175.2606)).bindLabel('Look revealing label!').addTo(map); +}; + +example = () => { + L.polyline([ + L.latLng(-37.7612, 175.2756), + L.latLng(-37.7702, 175.2796), + L.latLng(-37.7802, 175.2750), + ]).bindLabel('Even polylines can have labels.').addTo(map); +}; + +example = () => { + L.marker(L.latLng(-37.785, 175.263)) + .bindLabel('A sweet static label!', { noHide: true }) + .addTo(map); +}; + +example = () => { + var myIcon = L.icon({ + iconUrl: 'my-icon.png', + iconSize: L.point(20, 20), + iconAnchor: L.point(10, 10), + labelAnchor: L.point(6, 0) // as I want the label to appear 2px past the icon (10 + 2 - 6) + }); + L.marker(L.latLng(-37.7772, 175.2606), { + icon: myIcon + }).bindLabel('My label', { + noHide: true, + direction: 'auto' + }); +}; + +example = () => { + var myIcon = L.icon({ + iconUrl: 'my-icon.png', + iconSize: L.point(20, 20), + iconAnchor: L.point(10, 10), + labelAnchor: L.point(6, 0) // as I want the label to appear 2px past the icon (10 + 2 - 6) + }); + L.marker(L.latLng(-37.7772, 175.2606), { + icon: myIcon + }).bindLabel('Look revealing label!').addTo(map); +}; + +example = () => { + var markerLabel = L.marker(L.latLng(-37.7772, 175.2606)).bindLabel('Look revealing label!').addTo(map); + + // Sets opacity of marker to 0.3 and opacity of label to 1 + markerLabel.setOpacity(0.3); + + // Sets opacity of marker to 0.3 and opacity of label to 0.3 + markerLabel.setOpacity(0.3, true); + + // Sets opacity of marker to 0 and opacity of label to 0 + markerLabel.setOpacity(0); + markerLabel.setOpacity(0, true); + + // Sets opacity of marker to 1 and opacity of label to 1 + markerLabel.setOpacity(1); + markerLabel.setOpacity(1, true); +}; diff --git a/leaflet-label/leaflet-label.d.ts b/leaflet-label/leaflet-label.d.ts new file mode 100644 index 000000000..38bb43d7a --- /dev/null +++ b/leaflet-label/leaflet-label.d.ts @@ -0,0 +1,76 @@ +// Type definitions for Leaflet.label v0.2.1 +// Project: https://github.com/Leaflet/Leaflet.label +// Definitions by: Wim Looman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module L { + export interface IconOptions { + labelAnchor?: Point; + } + + export interface CircleMarkerOptions { + labelAnchor?: Point; + } + + export interface Marker { + showLabel(): Marker; + hideLabel(): Marker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): Marker; + unbindLabel(): Marker; + updateLabelContent(content: string): void; + getLabel(): Label; + setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; + } + + export interface CircleMarker { + showLabel(): CircleMarker; + hideLabel(): CircleMarker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): CircleMarker; + unbindLabel(): CircleMarker; + updateLabelContent(content: string): void; + getLabel(): Label; + } + + export interface FeatureGroup { + clearLayers(): FeatureGroup; + bindLabel(content: string, options?: LabelOptions): FeatureGroup; + unbindLabel(): FeatureGroup; + updateLabelContent(content: string): FeatureGroup; + } + + export interface Path { + bindLabel(content: string, options?: LabelOptions): Path; + unbindLabel(): Path; + updateLabelContent(content: string): void; + } + + export interface LabelOptions { + className?: string; + clickable?: boolean; + direction?: string; // 'left' | 'right' | 'auto'; + noHide?: boolean; + offset?: Point; + opacity?: number; + zoomAnimation?: boolean; + } + + export interface LabelStatic extends ClassStatic { + new(options?: LabelOptions): Label; + } + + export var Label: LabelStatic; + + export interface Label extends IEventPowered

+ extends ReactElementBase, P> {} + + interface ReactClassicElement

+ extends ReactElementBase | string, P> {} + + interface ReactDOMElement

// subtype of ReactClassicElement + extends ReactElementBase {} + + type ReactHTMLElement = ReactDOMElement; + type ReactSVGElement = ReactDOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

{ + (props?: P, ...children: ReactNode[]): ReactClassicElement

; + } + + interface DOMFactory

{ + (props?: P, ...children: ReactNode[]): ReactDOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElementBase | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass( + spec: ComponentSpec): ClassicComponentClass; + + function createFactory

( + type: string): DOMFactory

; + function createFactory

( + type: ClassicComponentClass | string): ClassicFactory

; + function createFactory

( + type: ComponentClass): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): ReactDOMElement

; + function createElement

( + type: ClassicComponentClass | string, + props?: P, + ...children: ReactNode[]): ReactClassicElement

; + function createElement

( + type: ComponentClass, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: ReactDOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ReactClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElementBase): string; + function renderToStaticMarkup(element: ReactElementBase): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props: P, context: any); + setState(state: S, callback?: () => any): void; + forceUpdate(): void; + props: P; + state: S; + context: any; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClassBase

{ + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + } + + interface ComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): Component; + defaultProps?: P; + } + + interface ClassicComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getInitialState?(): S; + getDefaultProps?(): P; + } + + interface ComponentSpec extends Mixin { + render(): ReactElementBase; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: number | string; + ref?: string; + } + + interface DOMAttributes extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: MouseEventHandler; + onDragEnd?: MouseEventHandler; + onDragEnter?: MouseEventHandler; + onDragExit?: MouseEventHandler; + onDragLeave?: MouseEventHandler; + onDragOver?: MouseEventHandler; + onDragStart?: MouseEventHandler; + onDrop?: MouseEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface CSSProperties { + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number; + lineClamp?: number; + lineHeight?: number; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + } + + interface HTMLAttributes extends DOMAttributes { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + className?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formNoValidate?: boolean; + frameBorder?: number | string; + height?: number | string; + hidden?: boolean; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + id?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + manifest?: string; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scrollLeft?: number; + scrolling?: string; + scrollTop?: number; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + } + + interface SVGAttributes extends DOMAttributes { + cx?: SVGLength | SVGAnimatedLength; + cy?: any; + d?: string; + dx?: SVGLength | SVGAnimatedLength; + dy?: SVGLength | SVGAnimatedLength; + fill?: any; // SVGPaint | string + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: SVGLength | SVGAnimatedLength; + fy?: SVGLength | SVGAnimatedLength; + gradientTransform?: SVGTransformList | SVGAnimatedTransformList; + gradientUnits?: string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: SVGLength | SVGAnimatedLength; + rx?: SVGLength | SVGAnimatedLength; + ry?: SVGLength | SVGAnimatedLength; + spreadMethod?: string; + stopColor?: any; // SVGColor | string + stopOpacity?: number | string; + stroke?: any; // SVGPaint + strokeDasharray?: string; + strokeLinecap?: string; + strokeOpacity?: number | string; + strokeWidth?: SVGLength | SVGAnimatedLength; + textAnchor?: string; + transform?: SVGTransformList | SVGAnimatedTransformList; + version?: string; + viewBox?: string; + x1?: SVGLength | SVGAnimatedLength; + x2?: SVGLength | SVGAnimatedLength; + x?: SVGLength | SVGAnimatedLength; + y1?: SVGLength | SVGAnimatedLength; + y2?: SVGLength | SVGAnimatedLength + y?: SVGLength | SVGAnimatedLength; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + svg: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + diff --git a/react/future/react-addons-0.13.0-tests.ts b/react/future/react-addons-0.13.0-tests.ts new file mode 100644 index 000000000..d76097cd6 --- /dev/null +++ b/react/future/react-addons-0.13.0-tests.ts @@ -0,0 +1,387 @@ +/// +import React = require("react/addons"); + +interface Props extends React.Props { + hello: string; + world?: string; + foo: number; + bar: boolean; +} + +interface State { + inputValue?: string; + seconds?: number; +} + +interface Context { + someValue?: string; +} + +interface ChildContext { + someOtherValue: string; +} + +interface MyComponent extends React.Component { + reset(): void; +} + +var props: Props = { + key: 42, + ref: "myComponent42", + hello: "world", + foo: 42, + bar: true +}; + +var container: Element; +var INPUT_REF: string = "input"; + +// +// Top-Level API +// -------------------------------------------------------------------------- + +var ClassicComponent: React.ClassicComponentClass = + React.createClass({ + getDefaultProps: () => { + return { + hello: undefined, + world: "peace", + foo: undefined, + bar: undefined + }; + }, + getInitialState: () => { + return { + inputValue: this.context.someValue, + seconds: this.props.foo + }; + }, + reset: () => { + this.replaceState(this.getInitialState()); + }, + render: () => { + return React.DOM.div(null, + React.DOM.input({ + ref: INPUT_REF, + value: this.state.inputValue + })); + } + }); + +class ModernComponent extends React.Component + implements React.ChildContextProvider { + + constructor(props: Props, context: Context) { + super(props, context); + this.state = { + inputValue: context.someValue, + seconds: props.foo + }; + } + + static propTypes: React.ValidationMap = { + foo: React.PropTypes.number + } + + static contextTypes: React.ValidationMap = { + someValue: React.PropTypes.string + } + + static childContextTypes: React.ValidationMap = { + someOtherValue: React.PropTypes.string + } + + getChildContext() { + return { + someOtherValue: 'foo' + } + } + + state = { + inputValue: this.context.someValue, + seconds: this.props.foo + } + + reset() { + this.setState({ + inputValue: this.context.someValue, + seconds: this.props.foo + }); + } + + render() { + return React.DOM.div(null, + React.DOM.input({ + ref: INPUT_REF, + value: this.state.inputValue + })); + } +} + +// React.createFactory +var factory: React.Factory = + React.createFactory(ModernComponent); +var factoryElement: React.ReactElement = + factory(props); + +var classicFactory: React.ClassicFactory = + React.createFactory(ClassicComponent); +var classicFactoryElement: React.ReactClassicElement = + classicFactory(props); + +var domFactory: React.DOMFactory = + React.createFactory("foo"); +var domFactoryElement: React.ReactDOMElement = + domFactory(); + +// React.createElement +var element: React.ReactElement = + React.createElement(ModernComponent, props); +var classicElement: React.ReactClassicElement = + React.createElement(ClassicComponent, props); +var domElement: React.ReactHTMLElement = + React.createElement("div"); + +// React.render +var component: React.Component = + React.render(element, container); +var classicComponent: React.ClassicComponent = + React.render(classicElement, container); +var domComponent: React.DOMComponent = + React.render(domElement, container); + +// Other Top-Level API +var unmounted: boolean = React.unmountComponentAtNode(container); +var str: string = React.renderToString(element); +var markup: string = React.renderToStaticMarkup(element); +var notValid: boolean = React.isValidElement(props); // false +var isValid = React.isValidElement(element); // true +React.initializeTouchEvents(true); +var domNode: Element = React.findDOMNode(component); +domNode = React.findDOMNode(domNode); + +// +// React Elements +// -------------------------------------------------------------------------- + +var type = element.type; +var elementProps: Props = element.props; +var key = element.key; +var ref: string = element.ref; + +// +// React Components +// -------------------------------------------------------------------------- + +var displayName: string = ClassicComponent.displayName; +var defaultProps: Props = ClassicComponent.getDefaultProps(); +var propTypes: React.ValidationMap = ClassicComponent.propTypes; + +// +// Component API +// -------------------------------------------------------------------------- + +// modern +var componentState: State = component.state; +component.setState({ inputValue: "!!!" }); +component.forceUpdate(); + +// classic +var htmlElement: Element = classicComponent.getDOMNode(); +var divElement: HTMLDivElement = classicComponent.getDOMNode(); +var isMounted: boolean = classicComponent.isMounted(); +classicComponent.setProps(elementProps); +classicComponent.replaceProps(props); +classicComponent.replaceState({ inputValue: "???", seconds: 60 }); + +var inputRef: React.HTMLComponent = + component.refs[INPUT_REF]; +var value: string = inputRef.getDOMNode().value; + +var myComponent = component; +myComponent.reset(); + +// +// Attributes +// -------------------------------------------------------------------------- + +var children = ["Hello world", [null], React.DOM.span(null)]; +var divStyle = { // CSSProperties + flex: "1 1 main-size", + backgroundImage: "url('hello.png')" +}; +var htmlAttr: React.HTMLAttributes = { + key: 36, + ref: "htmlComponent", + children: children, + className: "test-attr", + style: divStyle, + onClick: (event: React.MouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + }, + dangerouslySetInnerHTML: { + __html: "STRONG" + } +}; +React.DOM.div(htmlAttr); +React.DOM.span(htmlAttr); +React.DOM.input(htmlAttr); + +// +// React.PropTypes +// -------------------------------------------------------------------------- + +var PropTypesSpecification: React.ComponentSpec = { + propTypes: { + optionalArray: React.PropTypes.array, + optionalBool: React.PropTypes.bool, + optionalFunc: React.PropTypes.func, + optionalNumber: React.PropTypes.number, + optionalObject: React.PropTypes.object, + optionalString: React.PropTypes.string, + optionalNode: React.PropTypes.node, + optionalElement: React.PropTypes.element, + optionalMessage: React.PropTypes.instanceOf(Date), + optionalEnum: React.PropTypes.oneOf(["News", "Photos"]), + optionalUnion: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number, + React.PropTypes.instanceOf(Date) + ]), + optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number), + optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.number), + optionalObjectWithShape: React.PropTypes.shape({ + color: React.PropTypes.string, + fontSize: React.PropTypes.number + }), + requiredFunc: React.PropTypes.func.isRequired, + requiredAny: React.PropTypes.any.isRequired, + customProp: function(props: any, propName: string, componentName: string) { + if (!/matchme/.test(props[propName])) { + return new Error("Validation failed!"); + } + return null; + } + }, + render: (): React.ReactHTMLElement => { + return null; + } +}; + +// +// ContextTypes +// -------------------------------------------------------------------------- + +var ContextTypesSpecification: React.ComponentSpec = { + contextTypes: { + optionalArray: React.PropTypes.array, + optionalBool: React.PropTypes.bool, + optionalFunc: React.PropTypes.func, + optionalNumber: React.PropTypes.number, + optionalObject: React.PropTypes.object, + optionalString: React.PropTypes.string, + optionalNode: React.PropTypes.node, + optionalElement: React.PropTypes.element, + optionalMessage: React.PropTypes.instanceOf(Date), + optionalEnum: React.PropTypes.oneOf(["News", "Photos"]), + optionalUnion: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number, + React.PropTypes.instanceOf(Date) + ]), + optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number), + optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.number), + optionalObjectWithShape: React.PropTypes.shape({ + color: React.PropTypes.string, + fontSize: React.PropTypes.number + }), + requiredFunc: React.PropTypes.func.isRequired, + requiredAny: React.PropTypes.any.isRequired, + customProp: function(props: any, propName: string, componentName: string) { + if (!/matchme/.test(props[propName])) { + return new Error("Validation failed!"); + } + return null; + } + }, + render: (): React.ReactHTMLElement => { + return null; + } +}; + +// +// React.Children +// -------------------------------------------------------------------------- + +var childMap: { [key: string]: number } = + React.Children.map(children, (child) => { return 42; }); +React.Children.forEach(children, (child) => {}); +var nChildren: number = React.Children.count(children); +var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); + +// +// Example from http://facebook.github.io/react/ +// -------------------------------------------------------------------------- + +interface TimerState { + secondsElapsed: number; +} +class Timer extends React.Component<{}, TimerState> { + static state = { + secondsElapsed: 0 + } + private _interval: number; + tick() { + this.setState({ secondsElapsed: this.state.secondsElapsed + 1 }); + } + componentDidMount() { + var me = this; + this._interval = setInterval(() => me.tick(), 1000); + } + componentWillUnmount() { + clearInterval(this._interval); + } + render() { + return React.DOM.div( + null, + "Seconds Elapsed: ", + this.state.secondsElapsed + ); + } +} +React.render(React.createElement(Timer), container); + +// +// React.addons +// -------------------------------------------------------------------------- + +var cx = React.addons.classSet; +var className: string = cx({ a: true, b: false, c: true }); +className = cx("a", null, "b"); + +// +// React.addons (Transitions) +// -------------------------------------------------------------------------- + +React.createFactory(React.addons.TransitionGroup)({ component: "div" }); +React.createFactory(React.addons.CSSTransitionGroup)({ + component: React.createClass({ + render: (): React.ReactElement => null + }), + childFactory: (c) => c, + transitionName: "transition", + transitionAppear: false, + transitionEnter: true, + transitionLeave: true +}); + +// +// React.addons.TestUtils +// -------------------------------------------------------------------------- + +var node: Element; +React.addons.TestUtils.Simulate.click(node); +React.addons.TestUtils.Simulate.change(node); +React.addons.TestUtils.Simulate.keyDown(node, { key: "Enter" }); + diff --git a/react/react-0.13.0.d.ts b/react/future/react-addons-0.13.0.d.ts similarity index 75% rename from react/react-0.13.0.d.ts rename to react/future/react-addons-0.13.0.d.ts index 9ee102541..bb4af1d1e 100644 --- a/react/react-0.13.0.d.ts +++ b/react/future/react-addons-0.13.0.d.ts @@ -1,151 +1,193 @@ -// Type definitions for React 0.13.0 +// Type definitions for ReactWithAddons v0.13.0 (external module) // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module React { +declare module "react/addons" { // - // React Elements + // React Elements // ---------------------------------------------------------------------- - - type ReactType = ComponentClass | string; - interface ReactElement

{ - type: ComponentClass | string; + interface ReactElementBase { + type: T; props: P; key: number | string; ref: string; } - interface ReactClassicElement

extends ReactElement

{ - } + interface ReactElement

+ extends ReactElementBase, P> {} - interface ReactHTMLElement extends ReactElement {} - interface ReactSVGElement extends ReactElement {} + interface ReactClassicElement

+ extends ReactElementBase | string, P> {} + + interface ReactDOMElement

// subtype of ReactClassicElement + extends ReactElementBase {} + + type ReactHTMLElement = ReactDOMElement; + type ReactSVGElement = ReactDOMElement; // - // React Nodes + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

{ + (props?: P, ...children: ReactNode[]): ReactClassicElement

; + } + + interface DOMFactory

{ + (props?: P, ...children: ReactNode[]): ReactDOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + + // + // React Nodes // http://facebook.github.io/react/docs/glossary.html // ---------------------------------------------------------------------- type ReactText = string | number; - type ReactChild = ReactElement | ReactText; + type ReactChild = ReactElementBase | ReactText; // Should be Array but type aliases cannot be recursive type ReactFragment = Array; type ReactNode = ReactChild | ReactFragment | boolean; // - // React Components + // Top Level API // ---------------------------------------------------------------------- - interface ComponentLifecycle { - componentWillMount?(): void; - componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: C): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: C): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: C): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; - componentWillUnmount?(): void; - } - - // "modern" ES6 classes - class Component implements ComponentLifecycle { - constructor(props: P, context: C); - // static members can't be type checked with generics. However, see ComponentClass - static defaultProps: any; - static propTypes: ValidationMap; - static contextTypes: ValidationMap; - static childContextTypes: ValidationMap; - static displayName: string; - setState(state: S, callback?: () => any): void; - forceUpdate(): void; - props: P; - state: S; - context: C; - refs: { - [key: string]: Component - }; - } - - interface ComponentClass { - new (props: P, context: C): Component; - // can cast to get type checking for generics if desired - defaultProps: P; - getDefaultProps?(): P; - propTypes: ValidationMap

; - contextTypes: ValidationMap; - childContextTypes: ValidationMap; - displayName: string; - } - - // "classic" createClass - class ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; - isMounted(): boolean; - getInitialState(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; - } - - interface ClassicComponentClass extends ComponentClass { - new (props: P, context: C): ClassicComponent; - } - - interface ChildContextProvider { - getChildContext: () => C; - } - - // - // ReactElement Factories - // ---------------------------------------------------------------------- + function createClass( + spec: ComponentSpec): ClassicComponentClass; - interface ComponentFactory

{ - (props?: P, ...children: ReactNode[]): ReactElement

; - } - - interface HTMLFactory extends ComponentFactory {} - interface SVGFactory extends ComponentFactory {} + function createFactory

( + type: string): DOMFactory

; + function createFactory

( + type: ClassicComponentClass | string): ClassicFactory

; + function createFactory

( + type: ComponentClass): Factory

; - // - // Top-Level API - // ---------------------------------------------------------------------- + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): ReactDOMElement

; + function createElement

( + type: ClassicComponentClass | string, + props?: P, + ...children: ReactNode[]): ReactClassicElement

; + function createElement

( + type: ComponentClass, + props?: P, + ...children: ReactNode[]): ReactElement

; - interface TopLevelAPI { - createClass(spec: ComponentSpec): ClassicComponentClass; - createElement

(type: ClassicComponentClass, props: P, ...children: ReactNode[]): ReactClassicElement

; - createElement

(type: ComponentClass | string, props: P, ...children: ReactNode[]): ReactElement

; - createFactory

(type: ComponentClass | string): ComponentFactory

; - render(element: ReactClassicElement

, container: Element, callback?: () => any): ClassicComponent; - render(element: ReactElement

, container: Element, callback?: () => any): Component; - unmountComponentAtNode(container: Element): boolean; - renderToString(element: ReactElement): string; - renderToStaticMarkup(element: ReactElement): string; - isValidElement(object: {}): boolean; - initializeTouchEvents(shouldUseTouch: boolean): void; - findDOMNode(component: Component): Element; - findDOMNode(component: Component): TElement; - } + function render

( + element: ReactDOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ReactClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElementBase): string; + function renderToStaticMarkup(element: ReactElementBase): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; // // Component API // ---------------------------------------------------------------------- - class DOMComponent

extends ClassicComponent { + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props: P, context: any); + setState(state: S, callback?: () => any): void; + forceUpdate(): void; + props: P; + state: S; + context: any; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { tagName: string; } - interface HTMLComponent extends DOMComponent {} - interface SVGComponent extends DOMComponent {} + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClassBase

{ + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + } + + interface ComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): Component; + defaultProps?: P; + } + + interface ClassicComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } // // Component Specs and Lifecycle // ---------------------------------------------------------------------- - - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; statics?: { [key: string]: any; }; @@ -154,13 +196,13 @@ declare module React { propTypes?: ValidationMap; contextTypes?: ValidationMap; childContextTypes?: ValidationMap - + getInitialState?(): S; getDefaultProps?(): P; } - interface ComponentSpec extends Mixin { - render(): ReactElement; + interface ComponentSpec extends Mixin { + render(): ReactElementBase; } // @@ -266,15 +308,16 @@ declare module React { interface WheelEventHandler extends EventHandler {} // - // Attributes + // Props / DOM Attributes // ---------------------------------------------------------------------- - interface ReactAttributes { + interface Props { children?: ReactNode; key?: number | string; ref?: string; + } - // Event Attributes + interface DOMAttributes extends Props { onCopy?: ClipboardEventHandler; onCut?: ClipboardEventHandler; onPaste?: ClipboardEventHandler; @@ -335,7 +378,7 @@ declare module React { strokeOpacity?: number; } - interface HTMLAttributes extends ReactAttributes { + interface HTMLAttributes extends DOMAttributes { accept?: string; acceptCharset?: string; accessKey?: string; @@ -443,9 +486,9 @@ declare module React { itemType?: string; } - interface SVGAttributes extends ReactAttributes { + interface SVGAttributes extends DOMAttributes { cx?: SVGLength | SVGAnimatedLength; - cy?: any; + cy?: any; d?: string; dx?: SVGLength | SVGAnimatedLength; dy?: SVGLength | SVGAnimatedLength; @@ -490,7 +533,7 @@ declare module React { } // - // React.DOM + // React.DOM // ---------------------------------------------------------------------- interface ReactDOM { @@ -677,14 +720,36 @@ declare module React { // React.addons // ---------------------------------------------------------------------- - interface ClassSet { - [key: string]: boolean; - } + export var addons: { + CSSTransitionGroup: CSSTransitionGroup; + LinkedStateMixin: LinkedStateMixin; + PureRenderMixin: PureRenderMixin; + TransitionGroup: TransitionGroup; + + batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + batchedUpdates(callback: (a: A) => any, a: A): void; + batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + classSet(cx: { [key: string]: boolean }): string; + classSet(...classList: string[]): string; + + cloneWithProps

(element: ReactElement

, props: P): ReactElement

; + + update(value: any[], spec: UpdateArraySpec): any[]; + update(value: {}, spec: UpdateSpec): any; + + // Development tools + Perf: ReactPerf; + TestUtils: ReactTestUtils; + }; // // React.addons (Transitions) // ---------------------------------------------------------------------- + type ReactType = ComponentClass | string; + interface TransitionGroupProps { component?: ReactType; childFactory?: (child: ReactElement) => ReactElement; @@ -697,8 +762,10 @@ declare module React { transitionLeave?: boolean; } - interface CSSTransitionGroup extends ComponentClass {} - interface TransitionGroup extends ComponentClass {} + type CSSTransitionGroup = + ComponentClass; + type TransitionGroup = + ComponentClass; // // React.addons (Mixins) @@ -709,11 +776,11 @@ declare module React { requestChange(newValue: T): void; } - interface LinkedStateMixin extends Mixin { + interface LinkedStateMixin extends Mixin { linkState(key: string): ReactLink; } - interface PureRenderMixin extends Mixin { + interface PureRenderMixin extends Mixin { } // @@ -779,34 +846,50 @@ declare module React { interface ReactTestUtils { Simulate: Simulate; - renderIntoDocument

(element: ReactElement

): Component; - renderIntoDocument>(element: ReactElement): C; + renderIntoDocument

(element: ReactElement

): Component; + renderIntoDocument>(element: ReactElement): C; mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; isElementOfType(element: ReactElement, type: ReactType): boolean; - isDOMComponent(instance: Component): boolean; - isCompositeComponent(instance: Component): boolean; - isCompositeComponentWithType(instance: Component, type: ComponentClass): boolean; - isTextComponent(instance: Component): boolean; + isTextComponent(instance: Component): boolean; + isDOMComponent(instance: Component): boolean; + isCompositeComponent(instance: Component): boolean; + isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; - findAllInRenderedTree(tree: Component, fn: (i: Component) => boolean): Component; + findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; - scryRenderedDOMComponentsWithClass(tree: Component, className: string): DOMComponent[]; - findRenderedDOMComponentWithClass(tree: Component, className: string): DOMComponent; + scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; - scryRenderedDOMComponentsWithTag(tree: Component, tagName: string): DOMComponent[]; - findRenderedDOMComponentWithTag(tree: Component, tagName: string): DOMComponent; + scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; - scryRenderedComponentsWithType( - tree: Component, type: ComponentClass): Component[]; - scryRenderedComponentsWithType>( - tree: Component, type: ComponentClass): C[]; + scryRenderedComponentsWithType( + tree: Component, + type: ComponentClass): Component[]; + scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; - findRenderedComponentWithType( - tree: Component, type: ComponentClass): Component; - findRenderedComponentWithType>( - tree: Component, type: ComponentClass): C; + findRenderedComponentWithType( + tree: Component, + type: ComponentClass): Component; + findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; } interface SyntheticEventData { @@ -845,7 +928,7 @@ declare module React { interface EventSimulator { (element: Element, eventData?: SyntheticEventData): void; - (descriptor: Component, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; } interface Simulate { @@ -884,44 +967,6 @@ declare module React { wheel: EventSimulator; } - // - // react Exports - // ---------------------------------------------------------------------- - - interface Exports extends TopLevelAPI { - DOM: ReactDOM; - PropTypes: ReactPropTypes; - Children: ReactChildren; - Component: ComponentClass; - } - - // - // react/addons Exports - // ---------------------------------------------------------------------- - - interface AddonsExports extends Exports { - addons: { - CSSTransitionGroup: CSSTransitionGroup; - LinkedStateMixin: LinkedStateMixin; - PureRenderMixin: PureRenderMixin; - TransitionGroup: TransitionGroup; - - batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; - batchedUpdates(callback: (a: A) => any, a: A): void; - batchedUpdates(callback: () => any): void; - - classSet(cx: ClassSet): string; - cloneWithProps

(element: ReactElement

, props: P): ReactElement

; - - update(value: any[], spec: UpdateArraySpec): any[]; - update(value: {}, spec: UpdateSpec): any; - - // Development tools - Perf: ReactPerf; - TestUtils: ReactTestUtils; - }; - } - // // Browser Interfaces // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts @@ -951,13 +996,3 @@ declare module React { } } -declare module "react" { - var exports: React.Exports; - export = exports; -} - -declare module "react/addons" { - var exports: React.AddonsExports; - export = exports; -} - diff --git a/react/future/react-addons-global-0.13.0.d.ts b/react/future/react-addons-global-0.13.0.d.ts new file mode 100644 index 000000000..d11a4ae03 --- /dev/null +++ b/react/future/react-addons-global-0.13.0.d.ts @@ -0,0 +1,259 @@ +// Type definitions for ReactWithAddons v0.13.0 (internal module) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module React { + // + // React.addons + // ---------------------------------------------------------------------- + + export var addons: { + CSSTransitionGroup: CSSTransitionGroup; + LinkedStateMixin: LinkedStateMixin; + PureRenderMixin: PureRenderMixin; + TransitionGroup: TransitionGroup; + + batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + batchedUpdates(callback: (a: A) => any, a: A): void; + batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + classSet(cx: { [key: string]: boolean }): string; + classSet(...classList: string[]): string; + + cloneWithProps

(element: ReactElement

, props: P): ReactElement

; + + update(value: any[], spec: UpdateArraySpec): any[]; + update(value: {}, spec: UpdateSpec): any; + + // Development tools + Perf: ReactPerf; + TestUtils: ReactTestUtils; + }; + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = + ComponentClass; + type TransitionGroup = + ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpec { + $set: any; + $merge: {}; + $apply(value: any): any; + // [key: string]: UpdateSpec; + } + + interface UpdateArraySpec extends UpdateSpec { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + interface ReactPerf { + start(): void; + stop(): void; + printInclusive(measurements: Measurements[]): void; + printExclusive(measurements: Measurements[]): void; + printWasted(measurements: Measurements[]): void; + printDOM(measurements: Measurements[]): void; + getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + interface ReactTestUtils { + Simulate: Simulate; + + renderIntoDocument

(element: ReactElement

): Component; + renderIntoDocument>(element: ReactElement): C; + + mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; + + isElementOfType(element: ReactElement, type: ReactType): boolean; + isTextComponent(instance: Component): boolean; + isDOMComponent(instance: Component): boolean; + isCompositeComponent(instance: Component): boolean; + isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + scryRenderedComponentsWithType( + tree: Component, + type: ComponentClass): Component[]; + scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + findRenderedComponentWithType( + tree: Component, + type: ComponentClass): Component; + findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + interface Simulate { + blur: EventSimulator; + change: EventSimulator; + click: EventSimulator; + cut: EventSimulator; + doubleClick: EventSimulator; + drag: EventSimulator; + dragEnd: EventSimulator; + dragEnter: EventSimulator; + dragExit: EventSimulator; + dragLeave: EventSimulator; + dragOver: EventSimulator; + dragStart: EventSimulator; + drop: EventSimulator; + focus: EventSimulator; + input: EventSimulator; + keyDown: EventSimulator; + keyPress: EventSimulator; + keyUp: EventSimulator; + mouseDown: EventSimulator; + mouseEnter: EventSimulator; + mouseLeave: EventSimulator; + mouseMove: EventSimulator; + mouseOut: EventSimulator; + mouseOver: EventSimulator; + mouseUp: EventSimulator; + paste: EventSimulator; + scroll: EventSimulator; + submit: EventSimulator; + touchCancel: EventSimulator; + touchEnd: EventSimulator; + touchMove: EventSimulator; + touchStart: EventSimulator; + wheel: EventSimulator; + } +} + diff --git a/react/future/react-global-0.13.0.d.ts b/react/future/react-global-0.13.0.d.ts new file mode 100644 index 000000000..60675aec9 --- /dev/null +++ b/react/future/react-global-0.13.0.d.ts @@ -0,0 +1,747 @@ +// Type definitions for React v0.13.0 (internal module) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module React { + // + // React Elements + // ---------------------------------------------------------------------- + + interface ReactElementBase { + type: T; + props: P; + key: number | string; + ref: string; + } + + interface ReactElement

+ extends ReactElementBase, P> {} + + interface ReactClassicElement

+ extends ReactElementBase | string, P> {} + + interface ReactDOMElement

// subtype of ReactClassicElement + extends ReactElementBase {} + + type ReactHTMLElement = ReactDOMElement; + type ReactSVGElement = ReactDOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

{ + (props?: P, ...children: ReactNode[]): ReactClassicElement

; + } + + interface DOMFactory

{ + (props?: P, ...children: ReactNode[]): ReactDOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElementBase | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass( + spec: ComponentSpec): ClassicComponentClass; + + function createFactory

( + type: string): DOMFactory

; + function createFactory

( + type: ClassicComponentClass | string): ClassicFactory

; + function createFactory

( + type: ComponentClass): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): ReactDOMElement

; + function createElement

( + type: ClassicComponentClass | string, + props?: P, + ...children: ReactNode[]): ReactClassicElement

; + function createElement

( + type: ComponentClass, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: ReactDOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ReactClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElementBase): string; + function renderToStaticMarkup(element: ReactElementBase): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props: P, context: any); + setState(state: S, callback?: () => any): void; + forceUpdate(): void; + props: P; + state: S; + context: any; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClassBase

{ + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + } + + interface ComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): Component; + defaultProps?: P; + } + + interface ClassicComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getInitialState?(): S; + getDefaultProps?(): P; + } + + interface ComponentSpec extends Mixin { + render(): ReactElementBase; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: number | string; + ref?: string; + } + + interface DOMAttributes extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: MouseEventHandler; + onDragEnd?: MouseEventHandler; + onDragEnter?: MouseEventHandler; + onDragExit?: MouseEventHandler; + onDragLeave?: MouseEventHandler; + onDragOver?: MouseEventHandler; + onDragStart?: MouseEventHandler; + onDrop?: MouseEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface CSSProperties { + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number; + lineClamp?: number; + lineHeight?: number; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + } + + interface HTMLAttributes extends DOMAttributes { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + className?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formNoValidate?: boolean; + frameBorder?: number | string; + height?: number | string; + hidden?: boolean; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + id?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + manifest?: string; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scrollLeft?: number; + scrolling?: string; + scrollTop?: number; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + } + + interface SVGAttributes extends DOMAttributes { + cx?: SVGLength | SVGAnimatedLength; + cy?: any; + d?: string; + dx?: SVGLength | SVGAnimatedLength; + dy?: SVGLength | SVGAnimatedLength; + fill?: any; // SVGPaint | string + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: SVGLength | SVGAnimatedLength; + fy?: SVGLength | SVGAnimatedLength; + gradientTransform?: SVGTransformList | SVGAnimatedTransformList; + gradientUnits?: string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: SVGLength | SVGAnimatedLength; + rx?: SVGLength | SVGAnimatedLength; + ry?: SVGLength | SVGAnimatedLength; + spreadMethod?: string; + stopColor?: any; // SVGColor | string + stopOpacity?: number | string; + stroke?: any; // SVGPaint + strokeDasharray?: string; + strokeLinecap?: string; + strokeOpacity?: number | string; + strokeWidth?: SVGLength | SVGAnimatedLength; + textAnchor?: string; + transform?: SVGTransformList | SVGAnimatedTransformList; + version?: string; + viewBox?: string; + x1?: SVGLength | SVGAnimatedLength; + x2?: SVGLength | SVGAnimatedLength; + x?: SVGLength | SVGAnimatedLength; + y1?: SVGLength | SVGAnimatedLength; + y2?: SVGLength | SVGAnimatedLength + y?: SVGLength | SVGAnimatedLength; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + svg: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + diff --git a/react/react-addons-0.13.0-tests.ts b/react/react-addons-0.13.0-tests.ts deleted file mode 100644 index 6081a9824..000000000 --- a/react/react-addons-0.13.0-tests.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// -import React = require("react/addons"); - -var isImportant: boolean; -var isRead: boolean; -var classSet: React.ClassSet = { - "message": true, - "message-important": isImportant, - "message-read": isRead -}; -var cx = React.addons.classSet; -var classes: string = cx(classSet); - -// -// React.addons (Transitions) -// -------------------------------------------------------------------------- - -React.createFactory(React.addons.TransitionGroup)({ component: "div" }); -React.createFactory(React.addons.CSSTransitionGroup)({ - component: React.createClass({ - render: (): React.ReactElement => null - }), - childFactory: (c) => c, - transitionName: "transition", - transitionAppear: false, - transitionEnter: true, - transitionLeave: true -}); - -// -// React.addons.TestUtils -// -------------------------------------------------------------------------- - -var that: React.Component; -var node = React.findDOMNode(that.refs["input"]); -React.addons.TestUtils.Simulate.click(node); -React.addons.TestUtils.Simulate.change(node); -React.addons.TestUtils.Simulate.keyDown(node, {key: "Enter"}); - -interface GreetingProps { - name: string; -} -interface GreetingState { - morning: boolean; -} -interface Greeting extends React.Component { -} -var Greeting = React.createClass({ - displayName: "Greeting", - getInitialState: function() { - return {morning: true}; - }, - render: function() { - var me = this; - return React.DOM.div( - null, - me.state.morning ? "Hello " : "Goodbye ", - me.props.name); - } -}); - -var root = React.addons.TestUtils.renderIntoDocument( - React.createElement(Greeting, {name: "John"})); -var greeting = React.addons.TestUtils - .findRenderedComponentWithType(root, Greeting); -greeting.setState({ - morning: false -}); diff --git a/rest/rest-tests.ts b/rest/rest-tests.ts index 26346389f..6d267c792 100644 --- a/rest/rest-tests.ts +++ b/rest/rest-tests.ts @@ -135,3 +135,17 @@ client = rest .wrap(fail) .wrap(knownConfig, { prop: 'value' }) .wrap(transformedConfig, { prop: 'value' }); + +import xhrClient = require('rest/client/xhr'); +import nodeClient = require('rest/client/node'); +import jsonpClient = require('rest/client/jsonp'); +import xdrClient = require('rest/client/xdr'); + +rest.setDefaultClient(xhrClient); +rest.setDefaultClient(nodeClient); +rest.setDefaultClient(jsonpClient); +rest.setDefaultClient(xdrClient); + +var defaultClient: rest.Client = rest.getDefaultClient(); + +rest.resetDefaultClient(); diff --git a/rest/rest.d.ts b/rest/rest.d.ts index 37041e150..a96e0822a 100644 --- a/rest/rest.d.ts +++ b/rest/rest.d.ts @@ -14,6 +14,10 @@ declare module "rest" { function rest(request: rest.Request): rest.ResponsePromise; module rest { + export function setDefaultClient(client: Client): void; + export function getDefaultClient(): Client; + export function resetDefaultClient(): void; + export function wrap(interceptor: Interceptor, config?: T): Client; export interface Request { @@ -319,3 +323,27 @@ declare module "rest/mime/registry" { export = registry; } + +declare module "rest/client/xhr" { + import rest = require("rest"); + var xhr: rest.Client; + export = xhr; +} + +declare module "rest/client/node" { + import rest = require("rest"); + var node: rest.Client; + export = node; +} + +declare module "rest/client/jsonp" { + import rest = require("rest"); + var jsonp: rest.Client; + export = jsonp; +} + +declare module "rest/client/xdr" { + import rest = require("rest"); + var xdr: rest.Client; + export = xdr; +} diff --git a/run-sequence/run-sequence-tests.ts b/run-sequence/run-sequence-tests.ts new file mode 100644 index 000000000..98e57d9f3 --- /dev/null +++ b/run-sequence/run-sequence-tests.ts @@ -0,0 +1,33 @@ +/// +/// + +import gulp = require("gulp"); +import tmp = require("run-sequence"); +var runSequence = tmp.use(gulp); + +gulp.task("run-sequence", callback => { + runSequence("task1", + ["task2", "task3"], + "taks4", + callback); +}); + +gulp.task("task1", () => { + gulp.src("file1.txt") + .pipe(gulp.dest("build")); +}); + +gulp.task("task2", () => { + gulp.src("file2.txt") + .pipe(gulp.dest("build")); +}); + +gulp.task("task3", () => { + gulp.src("file3.txt") + .pipe(gulp.dest("build")); +}); + +gulp.task("task4", () => { + gulp.src("file4.txt") + .pipe(gulp.dest("build")); +}); diff --git a/run-sequence/run-sequence.d.ts b/run-sequence/run-sequence.d.ts new file mode 100644 index 000000000..3a2cb449c --- /dev/null +++ b/run-sequence/run-sequence.d.ts @@ -0,0 +1,19 @@ +// Type definitions for run-sequence +// Project: https://github.com/OverZealous/run-sequence +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "run-sequence" { + + interface IRunSequence { + (...streams: (string | string[] | gulp.ITaskCallback)[]): NodeJS.ReadWriteStream; + + use(gulp: gulp.Gulp): IRunSequence; + } + + var _tmp: IRunSequence; + export = _tmp; +} diff --git a/selectize/selectize.d.ts b/selectize/selectize.d.ts index 8bc47a0ff..3ac665458 100644 --- a/selectize/selectize.d.ts +++ b/selectize/selectize.d.ts @@ -150,6 +150,13 @@ declare module Selectize { */ selectOnTab?: boolean; + /** + * An array of plugins to use + * + * Default: null + */ + plugins?: string[]; + // Data / Searching // ------------------------------------------------------------------------------------------------------------ diff --git a/should-promised/should-promised-tests.ts b/should-promised/should-promised-tests.ts new file mode 100644 index 000000000..03167e663 --- /dev/null +++ b/should-promised/should-promised-tests.ts @@ -0,0 +1,21 @@ +/// +/// +/// + +var promise: Promise = new Promise(function (resolve, reject) {}); + +promise.should.be.Promise; +(10).should.not.be.a.Promise; + +promise.should.be.fulfilled; + +promise.should.be.rejected; + +promise.should.be.rejectedWith(Error); +promise.should.be.rejectedWith('boom'); +promise.should.be.rejectedWith(/boom/); +promise.should.be.rejectedWith(Error, { message: 'boom' }); +promise.should.be.rejectedWith({ message: 'boom' }); + +promise.should.be.eventually.equal(10); +promise.should.be.finally.equal(10); diff --git a/should-promised/should-promised.d.ts b/should-promised/should-promised.d.ts new file mode 100644 index 000000000..c6c95ba98 --- /dev/null +++ b/should-promised/should-promised.d.ts @@ -0,0 +1,14 @@ +// Type definitions for should-promised +// Project: https://github.com/shouldjs/promised +// Definitions by: Yaroslav Admin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface ShouldAssertion { + Promise: ShouldAssertion; + fulfilled: ShouldAssertion; + rejected: ShouldAssertion; + rejectedWith(message: (string | Function | RegExp), properties?: Object): ShouldAssertion; + rejectedWith(message: Object): ShouldAssertion; + finally: ShouldAssertion; + eventually: ShouldAssertion; +} diff --git a/sigmajs/sigmajs.d.ts b/sigmajs/sigmajs.d.ts index 749e3d86b..62bee1980 100644 --- a/sigmajs/sigmajs.d.ts +++ b/sigmajs/sigmajs.d.ts @@ -74,6 +74,14 @@ declare module SigmaJs{ nodes(ids: string[]): Node[]; } + interface Image { + clip?: number; + scale?: number; + url?: string; + x?: number; + y?: number; + } + interface Miscellaneous { animation: Animation; } diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 706d6a012..aa17d1e57 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -108,5 +108,5 @@ interface ConnectionSettings { interface JQueryStatic { signalR: SignalR; connection: SignalR; - hubConnection(url?: string, queryString?: any, logging?: boolean): HubConnection; + hubConnection(url?: string, options?: HubConnectionSettings): HubConnection; } diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index 00d2f2688..677d4fcc2 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -37,19 +37,19 @@ declare module SocketIO { emit(name: string, ...args: any[]): Socket; use(fn: Function): Namespace; - on(event: 'connection', listener: (socket: Socket) => void): any; - on(event: 'connect', listener: (socket: Socket) => void): any; - on(event: string, listener: Function): any; + on(event: 'connection', listener: (socket: Socket) => void): Namespace; + on(event: 'connect', listener: (socket: Socket) => void): Namespace; + on(event: string, listener: Function): Namespace; } interface Namespace extends NodeJS.EventEmitter { name: string; - connected: { [id: number]: Socket }; - use(fn: Function): Namespace + connected: { [id: string]: Socket }; + use(fn: Function): Namespace; - on(event: 'connection', listener: (socket: Socket) => void): any; - on(event: 'connect', listener: (socket: Socket) => void): any; - on(event: string, listener: Function): any; + on(event: 'connection', listener: (socket: Socket) => void): Namespace; + on(event: 'connect', listener: (socket: Socket) => void): Namespace; + on(event: string, listener: Function): Namespace; } interface Socket { @@ -63,12 +63,17 @@ declare module SocketIO { leave(name: string, fn?: Function): Socket; to(room: string): Socket; in(room: string): Socket; + send(...args: any[]): Socket; + write(...args: any[]): Socket; - on(event: string, listener: Function): any; + on(event: string, listener: Function): Socket; + once(event: string, listener: Function): Socket; + removeListener(event: string, listener: Function): Socket; + removeAllListeners(event: string): Socket; broadcast: Socket; volatile: Socket; connected: boolean; - disconnect(close: boolean): Socket; + disconnect(close?: boolean): Socket; } interface Client { diff --git a/split/split-tests.ts b/split/split-tests.ts new file mode 100644 index 000000000..b9aef877f --- /dev/null +++ b/split/split-tests.ts @@ -0,0 +1,16 @@ +/// +/// + +import stream = require("stream"); +import split = require("split"); + +var testStream = new stream.Readable(); + +testStream.pipe = function(dest: stream.Writable) { + dest.write("This is \r\n new \r\n line"); + return dest; +}; + +testStream.pipe(split(/(\r?\n)/, null, {maxLength: 20})).on("data", function(line: Buffer) { + console.log("Line: " + line.toString('ascii') + "\r\n"); +}); diff --git a/split/split.d.ts b/split/split.d.ts new file mode 100644 index 000000000..9bf6a9320 --- /dev/null +++ b/split/split.d.ts @@ -0,0 +1,17 @@ +// Type definitions for split v0.3.3 +// Project: https://github.com/dominictarr/split +// Definitions by: Marcin Porębski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "split" { + + interface SplitOptions { + maxLength: number + } + + function split(matcher?:any, mapper?:any, options?: SplitOptions):any; + + export = split; +} \ No newline at end of file diff --git a/stream-series/stream-series-tests.ts b/stream-series/stream-series-tests.ts new file mode 100644 index 000000000..2ed31ffb1 --- /dev/null +++ b/stream-series/stream-series-tests.ts @@ -0,0 +1,12 @@ +/// + +import stream = require("stream"); +import Stream = stream.Duplex; +import series = require("stream-series"); + +var stream1 = new Stream(); +var stream2 = new Stream(); +var stream3 = new Stream(); + +var orderedStream = series(stream1, stream3, stream2); +console.log(orderedStream.toString()); diff --git a/stream-series/stream-series.d.ts b/stream-series/stream-series.d.ts new file mode 100644 index 000000000..6c2d07d78 --- /dev/null +++ b/stream-series/stream-series.d.ts @@ -0,0 +1,11 @@ +// Type definitions for stream-series +// Project: https://github.com/rschmukler/stream-series +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "stream-series" { + function series(...streams: T[]): NodeJS.ReadWriteStream; + export = series; +} diff --git a/superagent/superagent-tests.ts b/superagent/superagent-tests.ts index 5779f81e9..436874aaf 100644 --- a/superagent/superagent-tests.ts +++ b/superagent/superagent-tests.ts @@ -1,13 +1,249 @@ -/// +/// +/// -import superagent = require('superagent') +// via: http://visionmedia.github.io/superagent/ -var agent = superagent.agent(); -agent - .post('http://localhost:3000/signin') - .send({ email: 'test@dummy.com', password: 'bacon' }) - .end((err, res) => { - if (err) throw err; - if (res.status !== 200) throw new Error('bad status ' + res.status); - if (res.body.foo === 'bar') throw new Error('bad body'); +import request = require('superagent') +import fs = require('fs'); + +request + .post('/api/pet') + .send({ name: 'Manny', species: 'cat' }) + .set('X-API-Key', 'foobar') + .set('Accept', 'application/json') + .end((res: request.Response) => { + if (res.ok) { + console.log('yay got ' + JSON.stringify(res.body)); + } else { + console.log('Oh no! error ' + res.text); + } }); + +var agent = request.agent(); +agent + .post('/api/pet') + .send({ name: 'Manny', species: 'cat' }) + .set('X-API-Key', 'foobar') + .set('Accept', 'application/json') + .end((res: request.Response) => { + if (res.error) { + console.log('oh no ' + res.error.message); + } else { + console.log('got ' + res.status + ' response'); + } + }); + + +var callback = (res: request.Response) => {}; + +// Request basics +request + .get('/search') + .end(callback); + +request('GET', '/search') + .end(callback); + +request + .head('/favicon.ico') + .end(callback); + +request + .del('/user/1') + .end(callback); + +request('/search') + .end(callback); + +// Setting header fields +request + .get('/search') + .set('API-Key', 'foobar') + .set('Accept', 'application/json') + .end(callback); + +request + .get('/search') + .set({ 'API-Key': 'foobar', Accept: 'application/json' }) + .end(callback); + +// GET requests +request + .get('/search') + .query({ query: 'Manny' }) + .query({ range: '1..5' }) + .query({ order: 'desc' }) + .end(callback); + +request + .get('/search') + .query({ query: 'Manny', range: '1..5', order: 'desc' }) + .end(callback); + +request + .get('/querystring') + .query('search=Manny&range=1..5') + .end(callback); + +request + .get('/querystring') + .query('search=Manny') + .query('range=1..5') + .end(callback); + +// POST / PUT requests +request.post('/user') + .set('Content-Type', 'application/json') + .send('{"name":"tj","pet":"tobi"}') + .end(callback); + +request.post('/user') + .send({ name: 'tj', pet: 'tobi' }) + .end(callback); + +request.post('/user') + .send({ name: 'tj' }) + .send({ pet: 'tobi' }) + .end(callback); + +request.post('/user') + .send('name=tj') + .send('pet=tobi') + .end(callback); + +request.post('/user') + .type('form') + .send({ name: 'tj' }) + .send({ pet: 'tobi' }) + .end(callback); + +// Setting the Content-Type +request.post('/user') + .set('Content-Type', 'application/json'); + +request.post('/user') + .type('application/json'); + +request.post('/user') + .type('json'); + +request.post('/user') + .type('png'); + +request.get('/user') + .accept('application/json'); + +request.get('/user') + .accept('json'); + +request.get('/user') + .accept('png'); + +// Query strings +request + .post('/') + .query({ format: 'json' }) + .query({ dest: '/login' }) + .send({ post: 'data', here: 'wahoo' }) + .end(callback); + +// Parsing response bodies +request('/search') + .end((res: request.Response) => { + var status: number = res.status; + var body = res.body; + var files: Object = res.files; + var text: string = res.text; + var contentLength = res.header['content-length']; + var contentType: string = res.type; + var charset: string = res.charset; + }); + +var req = request.get('/hoge'); +// Aborting requests +req.abort(); + +// Request timeouts +req.timeout(100); + +// Basic authentication +request.get('http://tobi:learnboost@local').end(callback); +request + .get('http://local') + .auth('tobo', 'learnboost') + .end(callback); + +// Following redirects +request + .get('/some.png') + .redirects(2) + .end(callback); + +// Piping data +/* +(function() { +var stream = fs.createReadStream('path/to/my.json'); +var req = request.post('/somewhere'); +req.type('json'); +stream.pipe(req); +})(); +*/ + +(function() { +var stream = fs.createWriteStream('path/to/my.json'); +var req = request.get('/some.json'); +req.pipe(stream); +})(); + +// Multipart requests +(function() { +var req = request.post('/upload'); + +req.part() + .set('Content-Type', 'image/png') + .set('Content-Disposition', 'attachment; filename="myimage.png"') + .write('some image data') + .write('some more image data'); + +req.part() + .set('Content-Disposition', 'form-data; name="name"') + .set('Content-Type', 'text/plain') + .write('tobi'); + +req.end(callback); +})(); + +// Attaching files +request + .post('/upload') + .attach('avatar', 'path/to/tobi.png', 'user.png') + .attach('image', 'path/to/loki.png') + .attach('file', 'path/to/jane.png') + .end(callback); + +// Field values +request + .post('/upload') + .field('user[name]', 'Tobi') + .field('user[email]', 'tobi@learnboost.com') + .attach('image', 'path/to/tobi.png') + .end(callback); + +// CORS +request + .get('http://localhost:4001/') + .withCredentials() + .end(callback); + +// Error handling +request + .post('/upload') + .attach('image', 'path/to/tobi.png') + .end((err: any, res: request.Response): void => {}); +request + .post('/upload') + .attach('image', 'path/to/tobi.png') + .on('error', (err: any) => {}) + .end(callback); + + diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index 0abed7438..ef477e16a 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -6,85 +6,108 @@ /// declare module "superagent" { - import stream = require('stream'); - export interface Response { - text: string; - body: any; - files: any; - header: any; - type: string; - charset: string; - status: number; - statusType: number; - info: boolean; - ok: boolean; - redirect: boolean; - clientError: boolean; - serverError: boolean; - error: any; - accepted: boolean; - noContent: boolean; - badRequest: boolean; - unauthorized: boolean; - notAcceptable: boolean; - notFound: boolean; - forbidden: boolean; - get(header: string): string; + import stream = require('stream'); + + type CallbackHandler = { (err: any, res: request.Response): void; }|{ (res: request.Response): void; }; + + var request: request.SuperAgentStatic; + + module request { + interface SuperAgentStatic extends SuperAgent { + (url: string): SuperAgentRequest; + (method: string, url: string): SuperAgentRequest; + + agent(): SuperAgent; + } + + interface SuperAgent> extends stream.Stream { + get(url: string, callback?: CallbackHandler): Req; + post(url: string, callback?: CallbackHandler): Req; + put(url: string, callback?: CallbackHandler): Req; + head(url: string, callback?: CallbackHandler): Req; + del(url: string, callback?: CallbackHandler): Req; + options(url: string, callback?: CallbackHandler): Req; + trace(url: string, callback?: CallbackHandler): Req; + copy(url: string, callback?: CallbackHandler): Req; + lock(url: string, callback?: CallbackHandler): Req; + mkcol(url: string, callback?: CallbackHandler): Req; + move(url: string, callback?: CallbackHandler): Req; + purge(url: string, callback?: CallbackHandler): Req; + propfind(url: string, callback?: CallbackHandler): Req; + proppatch(url: string, callback?: CallbackHandler): Req; + unlock(url: string, callback?: CallbackHandler): Req; + report(url: string, callback?: CallbackHandler): Req; + mkactivity(url: string, callback?: CallbackHandler): Req; + checkout(url: string, callback?: CallbackHandler): Req; + merge(url: string, callback?: CallbackHandler): Req; + // m-search(url: string, callback?: CallbackHandler): Req; + notify(url: string, callback?: CallbackHandler): Req; + subscribe(url: string, callback?: CallbackHandler): Req; + unsubscribe(url: string, callback?: CallbackHandler): Req; + patch(url: string, callback?: CallbackHandler): Req; + search(url: string, callback?: CallbackHandler): Req; + connect(url: string, callback?: CallbackHandler): Req; + + parse(fn: Function): Req; + saveCookies(res: Response): void; + attachCookies(req: Req): void; + } + + interface Response extends NodeJS.ReadableStream { + text: string; + body: any; + files: any; + header: any; + type: string; + charset: string; + status: number; + statusType: number; + info: boolean; + ok: boolean; + redirect: boolean; + clientError: boolean; + serverError: boolean; + error: Error; + accepted: boolean; + noContent: boolean; + badRequest: boolean; + unauthorized: boolean; + notAcceptable: boolean; + notFound: boolean; + forbidden: boolean; + get(header: string): string; + } + + interface Request> /* extends NodeJS.WritableStream */ { + abort(): void; + accept(type: string): Req; + attach(field: string, file: string, filename?: string): Req; + auth(user: string, name: string): Req; + buffer(val: boolean): Req; + clearTimeout(): Req; + end(callback?: CallbackHandler): Req; + field(name: string, val: string): Req; + get(field: string): string; + on(name: string, handler: Function): Req; + on(name: 'error', handler: (err: any) => void): Req; + part(): Req; + pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable; + query(val: Object): Req; + redirects(n: number): Req; + send(data: string): Req; + send(data: Object): Req; + set(field: string, val: string): Req; + set(field: Object): Req; + timeout(ms: number): Req; + type(val: string): Req; + withCredentials(): Req; + write(data: string, encoding?: string): Req; + write(data: Buffer, encoding?: string): Req; + } + interface SuperAgentRequest extends Request>>> {} + } - export interface Request { - attach(field: string, file: string, filename: string): Request; - redirects(n: number): Request; - part(): Request; - set(field: string, val: string): Request; - set(field: Object): Request; - get(field: string): string; - type(val: string): Request; - query(val: Object): Request; - send(data: string): Request; - send(data: Object): Request; - write(data: string, encoding: string): boolean; - write(data: Buffer, encoding: string): boolean; - pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable; - buffer(val: boolean): Request; - timeout(ms: number): Request; - clearTimeout(): Request; - abort(): void; - auth(user: string, name: string): Request; - field(name: string, val: string): Request; - end(callback?: (err: Error, res: Response) => void): Request; - } - - export interface Agent { - get(url: string, callback?: (err: Error, res: Response) => void): Request; - post(url: string, callback?: (err: Error, res: Response) => void): Request; - put(url: string, callback?: (err: Error, res: Response) => void): Request; - head(url: string, callback?: (err: Error, res: Response) => void): Request; - del(url: string, callback?: (err: Error, res: Response) => void): Request; - options(url: string, callback?: (err: Error, res: Response) => void): Request; - trace(url: string, callback?: (err: Error, res: Response) => void): Request; - copy(url: string, callback?: (err: Error, res: Response) => void): Request; - lock(url: string, callback?: (err: Error, res: Response) => void): Request; - mkcol(url: string, callback?: (err: Error, res: Response) => void): Request; - move(url: string, callback?: (err: Error, res: Response) => void): Request; - propfind(url: string, callback?: (err: Error, res: Response) => void): Request; - proppatch(url: string, callback?: (err: Error, res: Response) => void): Request; - unlock(url: string, callback?: (err: Error, res: Response) => void): Request; - report(url: string, callback?: (err: Error, res: Response) => void): Request; - mkactivity(url: string, callback?: (err: Error, res: Response) => void): Request; - checkout(url: string, callback?: (err: Error, res: Response) => void): Request; - merge(url: string, callback?: (err: Error, res: Response) => void): Request; - //m-search(url: string, callback?: (err: Error, res: Response) => void): Request; - notify(url: string, callback?: (err: Error, res: Response) => void): Request; - subscribe(url: string, callback?: (err: Error, res: Response) => void): Request; - unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Request; - patch(url: string, callback?: (err: Error, res: Response) => void): Request; - search(url: string, callback?: (err: Error, res: Response) => void): Request; - connect(url: string, callback?: (err: Error, res: Response) => void): Request; - parse(fn: Function): Request; - saveCookies(res: Response): void; - attachCookies(req: Request): void; - } - - export function agent(): Agent; + export = request; } + diff --git a/supertest/supertest-tests.ts b/supertest/supertest-tests.ts index 120cb43c0..d76c97ea4 100644 --- a/supertest/supertest-tests.ts +++ b/supertest/supertest-tests.ts @@ -11,7 +11,7 @@ supertest(app) .expect('Content-Type', /json/) .expect('Content-Length', '20') .expect(201) - .end((err, res) => { + .end((err: any, res: supertest.Response) => { if (err) throw err; }); @@ -20,13 +20,13 @@ var request = supertest(app); var agent = supertest.agent(); request .post('/login') - .end((err, res) => { + .end((err: any, res: supertest.Response) => { if (err) throw err; agent.saveCookies(res); var req = request.get('/admin'); agent.attachCookies(req); - req.expect(200, (err, res) => { + req.expect(200, (err: any, res: supertest.Response) => { if (err) throw err; }); }); @@ -35,11 +35,11 @@ request var client = supertest.agent(app); client .post('/login') - .end((err, res) => { + .end((err: any, res: supertest.Response) => { if (err) throw err; client.get('/admin') - .expect(200, (err, res) => { + .expect(200, (err: any, res: supertest.Response) => { if (err) throw err; }); }); @@ -48,7 +48,7 @@ client supertest(app) .get('/') .expect(hasPreviousAndNextKeys) - .end((err, res) => { + .end((err: any, res: supertest.Response) => { if (err) throw err; }); diff --git a/supertest/supertest.d.ts b/supertest/supertest.d.ts index cb2bb78b3..dccbd47c8 100644 --- a/supertest/supertest.d.ts +++ b/supertest/supertest.d.ts @@ -8,93 +8,32 @@ declare module "supertest" { import superagent = require('superagent'); - module supertest { - interface Test extends superagent.Request { - url: string; - serverAddress(app: any, path: string): string; - expect(status: number, callback?: (err: Error, res: Response) => void): Test; - expect(status: number, body: string, callback?: (err: Error, res: Response) => void): Test; - expect(body: string, callback?: (err: Error, res: Response) => void): Test; - expect(body: RegExp, callback?: (err: Error, res: Response) => void): Test; - expect(body: Object, callback?: (err: Error, res: Response) => void): Test; - expect(field: string, val: string, callback?: (err: Error, res: Response) => void): Test; - expect(field: string, val: RegExp, callback?: (err: Error, res: Response) => void): Test; - expect(checker: (res: Response) => any): Test; - - attach(field: string, file: string, filename: string): Test; - redirects(n: number): Test; - part(): Test; - set(field: string, val: string): Test; - set(field: Object): Test; - type(val: string): Test; - query(val: Object): Test; - send(data: string): Test; - send(data: Object): Test; - buffer(val: boolean): Test; - timeout(ms: number): Test; - clearTimeout(): Test; - auth(user: string, name: string): Test; - field(name: string, val: string): Test; - end(callback?: (err: Error, res: Response) => void): Test; - } - interface Response extends superagent.Response {} - - interface SuperTest { - get(url: string): Test; - post(url: string): Test; - put(url: string): Test; - head(url: string): Test; - del(url: string): Test; - options(url: string): Test; - trace(url: string): Test; - copy(url: string): Test; - lock(url: string): Test; - mkcol(url: string): Test; - move(url: string): Test; - propfind(url: string): Test; - proppatch(url: string): Test; - unlock(url: string): Test; - report(url: string): Test; - mkactivity(url: string): Test; - checkout(url: string): Test; - merge(url: string): Test; - //m-search(url: string): Test; - notify(url: string): Test; - subscribe(url: string): Test; - unsubscribe(url: string): Test; - patch(url: string): Test; - } - - interface TestAgent extends superagent.Agent { - get(url: string, callback?: (err: Error, res: Response) => void): Test; - post(url: string, callback?: (err: Error, res: Response) => void): Test; - put(url: string, callback?: (err: Error, res: Response) => void): Test; - head(url: string, callback?: (err: Error, res: Response) => void): Test; - del(url: string, callback?: (err: Error, res: Response) => void): Test; - options(url: string, callback?: (err: Error, res: Response) => void): Test; - trace(url: string, callback?: (err: Error, res: Response) => void): Test; - copy(url: string, callback?: (err: Error, res: Response) => void): Test; - lock(url: string, callback?: (err: Error, res: Response) => void): Test; - mkcol(url: string, callback?: (err: Error, res: Response) => void): Test; - move(url: string, callback?: (err: Error, res: Response) => void): Test; - propfind(url: string, callback?: (err: Error, res: Response) => void): Test; - proppatch(url: string, callback?: (err: Error, res: Response) => void): Test; - unlock(url: string, callback?: (err: Error, res: Response) => void): Test; - report(url: string, callback?: (err: Error, res: Response) => void): Test; - mkactivity(url: string, callback?: (err: Error, res: Response) => void): Test; - checkout(url: string, callback?: (err: Error, res: Response) => void): Test; - merge(url: string, callback?: (err: Error, res: Response) => void): Test; - //m-search(url: string, callback?: (err: Error, res: Response) => void): Test; - notify(url: string, callback?: (err: Error, res: Response) => void): Test; - subscribe(url: string, callback?: (err: Error, res: Response) => void): Test; - unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Test; - patch(url: string, callback?: (err: Error, res: Response) => void): Test; - search(url: string, callback?: (err: Error, res: Response) => void): Test; - connect(url: string, callback?: (err: Error, res: Response) => void): Test; - } - function agent(app?: any): supertest.TestAgent; - } + type CallbackHandler = { (err: any, res: supertest.Response): void; }|{ (res: supertest.Response): void; }; function supertest(app: any): supertest.SuperTest; + + module supertest { + function agent(app?: any): supertest.SuperTest; + + interface SuperTest extends superagent.SuperAgent { + } + + interface Test extends superagent.Request { + url: string; + serverAddress(app: any, path: string): string; + expect(status: number, callback?: CallbackHandler): Test; + expect(status: number, body: string, callback?: CallbackHandler): Test; + expect(body: string, callback?: CallbackHandler): Test; + expect(body: RegExp, callback?: CallbackHandler): Test; + expect(body: Object, callback?: CallbackHandler): Test; + expect(field: string, val: string, callback?: CallbackHandler): Test; + expect(field: string, val: RegExp, callback?: CallbackHandler): Test; + expect(checker: (res: Response) => any): Test; + } + + interface Response extends superagent.Response { + } + } + export = supertest; } diff --git a/tether/tether-tests.ts b/tether/tether-tests.ts new file mode 100644 index 000000000..4d3295b50 --- /dev/null +++ b/tether/tether-tests.ts @@ -0,0 +1,53 @@ +/// +/// + +var yellowBox = document.querySelector(".yellow"); +var greenBox = document.querySelector(".green"); + +new Tether({ + attachment: "bottom middle", + targetAttachment: "top middle", + targetModifier: "visible", + offset: "-15px 0", + targetOffset: "0 0" +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "top left", + optimizations: { + gpu: false + } +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "top left", + targetAttachment: "bottom left", + constraints: [ + { + to: "scrollParent", + pin: true + }, + { + to: "window", + attachment: "together" + } + ] +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "middle left", + targetAttachment: "middle left", + constraints: [ + { + to: "scrollParent", + pin: ["top"] + } + ] +}); + diff --git a/tether/tether.d.ts b/tether/tether.d.ts new file mode 100644 index 000000000..be1200f28 --- /dev/null +++ b/tether/tether.d.ts @@ -0,0 +1,50 @@ +// Type definitions for Tether v0.6 +// Project: http://github.hubspot.com/tether/ +// Definitions by: Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module tether { + + interface TetherStatic { + new(options: ITetherOptions): Tether; + } + + interface ITetherOptions { + attachment?: string; + classes?: {[className: string]: boolean}; + classPrefix?: string; + constraints?: ITetherConstraint[]; + element?: Element | string | any /* JQuery */; + enabled?: boolean; + offset?: string; + optimizations?: any; + target?: Element | string | any /* JQuery */; + targetAttachment?: string; + targetOffset?: string; + targetModifier?: string; + } + + interface ITetherConstraint { + attachment?: string; + outOfBoundsClass?: string; + pin?: boolean | string[]; + pinnedClass?: string; + to?: string | Element | number[]; + } + + interface Tether { + setOptions(options: ITetherOptions): void; + disable(): void; + enable(): void; + destroy(): void; + position(): void; + } + +} + +declare module "tether" { + export = tether; +} + +declare var Tether: tether.TetherStatic; + diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 78beab253..b74844407 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -5613,7 +5613,7 @@ declare module THREE { constructor(object: Object3D, hex?: number); object: Object3D; - box: Box3[]; + box: Box3; update(): void; } diff --git a/toastr/toastr-tests.ts b/toastr/toastr-tests.ts index 9a5ae6a19..adacb1934 100644 --- a/toastr/toastr-tests.ts +++ b/toastr/toastr-tests.ts @@ -48,7 +48,8 @@ function test_fromdemo() { debug: $('#debugInfo').prop('checked'), tapToDismiss: $('#tapToDismiss').prop('checked'), positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right', - preventDuplicates: true + preventDuplicates: true, + progressBar: true } if ($fadeIn.val().length) { toastr.options.showDuration = +$fadeIn.val() diff --git a/toastr/toastr.d.ts b/toastr/toastr.d.ts index 8745a6157..2fcdc3840 100644 --- a/toastr/toastr.d.ts +++ b/toastr/toastr.d.ts @@ -119,6 +119,11 @@ interface ToastrOptions { */ preventDuplicates?: boolean; + /** + * Visually indicates how long before a toast expires. + */ + progressBar?: boolean; + /** * Function to execute on toast click */ diff --git a/underscore.string/underscore.string.d.ts b/underscore.string/underscore.string.d.ts index 9c828fdf7..38271f3de 100644 --- a/underscore.string/underscore.string.d.ts +++ b/underscore.string/underscore.string.d.ts @@ -3,6 +3,8 @@ // Definitions by: Ry Racherbaumer // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + interface UnderscoreStatic { str: UnderscoreStringStatic; string: UnderscoreStringStatic; diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index aeaf253ca..9f49bc47a 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -264,7 +264,22 @@ interface UnderscoreStatic { detect( object: _.Dictionary, iterator: _.ObjectIterator, - context?: any): T; + context?: any): T; + + /** + * Looks through each value in the list, returning the index of the first one that passes a truth + * test (iterator). The function returns as soon as it finds an acceptable element, + * and doesn't traverse the entire list. + * @param list Searches for a value in this list. + * @param iterator Search iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned. + **/ + findIndex( + list: _.List, + iterator: _.ListIterator, + context?: any): T; + /** * Looks through each value in the list, returning an array of all the values that pass a truth diff --git a/webcola/webcola-tests.ts b/webcola/webcola-tests.ts index 9fc94d413..43c7bfe1e 100644 --- a/webcola/webcola-tests.ts +++ b/webcola/webcola-tests.ts @@ -1,6 +1,6 @@ /// module WebColaTests { - var adaptor = cola.adaptor({ + var adaptor = new cola.adaptor({ trigger: function() { }, kick: function() { @@ -23,8 +23,9 @@ module WebColaTests { .flowLayout('y', 0); adaptor.start(1, 2, 3); - adaptor.dragstart({}); - adaptor.dragend({}); adaptor.stop(); adaptor.resume(); + + cola.colaDragstart({}); + cola.colaDragend({}); } diff --git a/webcola/webcola.d.ts b/webcola/webcola.d.ts index ba17d1409..801455cba 100644 --- a/webcola/webcola.d.ts +++ b/webcola/webcola.d.ts @@ -4,11 +4,10 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module WebCola{ interface Adaptor { + new(options: { [index:number]: any }): Adaptor; avoidOverlaps(avodOverLaps: boolean): Adaptor; constraints(constraints: any): Adaptor; convergenceThreshold(convergenceThreshold: number): Adaptor; - dragend(node: { [index: number]: any }): void; - dragstart(node: { [index: number]: any }): void; flowLayout(axis: string, minSeparation: number): Adaptor; handleDisconnected(handleDisconnected: boolean): Adaptor; links(links: any): Adaptor; @@ -22,10 +21,13 @@ declare module WebCola{ initialAllConstraintsIterations: number ): void; stop(): void; + tick(): any; } interface Cola { - adaptor(options: { [index:number]: any }): Adaptor; + adaptor: Adaptor; + colaDragstart(node: { [index: number]: any }): void; + colaDragend(node: { [index: number]: any }): void; start(): void; stop(): void; } diff --git a/windows-service/windows-service-tests.ts b/windows-service/windows-service-tests.ts new file mode 100644 index 000000000..667a343d9 --- /dev/null +++ b/windows-service/windows-service-tests.ts @@ -0,0 +1,21 @@ +/// + +import stream = require("stream"); +import service = require("windows-service"); + +service.add("MyService"); +service.add("MyService", {programPath: "./service.js"}); + +var s: stream.Writable; +var t: stream.Writable; + +service.run(s, (): void => { + service.stop(0); +}); + +service.run(s, t, (): void => { + service.stop(0); +}); + +service.remove("MyService"); + diff --git a/windows-service/windows-service.d.ts b/windows-service/windows-service.d.ts new file mode 100644 index 000000000..a11666319 --- /dev/null +++ b/windows-service/windows-service.d.ts @@ -0,0 +1,74 @@ +// Type definitions for windows-service 1.0.4 +// Project: https://bitbucket.org/stephenwvickers/node-windows-service +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module "windows-service" { + import stream = require("stream"); + + /** + * Options for the add() function. + */ + export interface AddOptions { + /** + * The services display name, defaults to the name parameter + */ + displayName?: string; + /** + * The fully qualified path to the node binary used to run the service (i.e. c:\Program Files\nodejs\node.exe, defaults to the value of process.execPath + */ + nodePath?: string; + /** + * An array of strings specifying parameters to pass to nodePath, defaults to [] + */ + nodeArgs?: string[]; + /** + * The program to run using nodePath, defaults to the value of process.argv[1] + */ + programPath?: string; + /** + * An array of strings specifying parameters to pass to programPath, defaults to [] + */ + programArgs?: string[]; + } + + /** + * The add() function adds a Windows service. The service will be set to automatically start at boot time, but not started. + * The service can be started using the net start "My Service" command. An exception will be thrown if the service could + * not be added. The error will be an instance of the Error class. + * + * @param name The name parameter specifies the name of the created service. + * @param opts Options + */ + export function add(name: string, opts?: AddOptions): void; + + + /** + * The remove() function removes a Windows service. + * The name parameter specifies the name of the service to remove. This will be the same name parameter specified when adding the service. + * The service must be in a stopped state for it to be removed. The net stop "My Service" command can be used to stop the service before + * it is to be removed. + * An exception will be thrown if the service could not be removed. The error will be an instance of the Error class. + */ + export function remove(name: string): void; + + /** + * The run() function will connect the calling program to the Windows Service Control Manager, allowing the program to run as a Windows service. + * The programs process.stdout stream will be replaced with the stdoutLogStream parameter, and the programs process.stderr stream replaced with + * the stdoutLogStream parameter (this allows the redirection of all console.log() type calls to a service specific log file). If the stderrLogStream + * parameter is not specified the programs process.stderr stream will be replaced with the stdoutLogStream parameter. The callback function will be + * called when the service receives a stop request, e.g. because the Windows Service Controller was used to send a stop request to the service. + * The program should perform cleanup tasks and then call the service.stop() function. + */ + export function run(stdoutLogStream: stream.Writable, callback: () => void): void; + export function run(stdoutLogStream: stream.Writable, stderrLogStream: stream.Writable, callback: () => void): void; + + /** + * The stop() function will cause the service to stop, and the calling program to exit. + * Once the service has been stopped this function will terminate the program by calling the process.exit() function, passing to it the rcode + * parameter which defaults to 0. Before calling this function ensure the program has finished performing cleanup tasks. + * BE AWARE, THIS FUNCTION WILL NOT RETURN. + */ + export function stop(rcode?: number): void; +} diff --git a/x-editable/x-editable-tests.ts b/x-editable/x-editable-tests.ts new file mode 100644 index 000000000..bf4d34189 --- /dev/null +++ b/x-editable/x-editable-tests.ts @@ -0,0 +1,128 @@ +// Type definitions for X-Editable v1.5.1 +// Project: http://vitalets.github.io/x-editable/index.html +// Definitions by: Chris Kirby +// Definitions: https://github.com/sirkirby/DefinitelyTyped + +/// +/// + +// server post and response +$('#username').editable({ + success: function(response : any, newValue : any) { + if(response.status == 'error') return response.msg; //msg will be shown in editable form + } +}); + +// no post to the server +$('#username').editable({ + type: 'text', + title: 'Enter username', + success: function(response : any, newValue : any) { + // update view model + } +}); + +// text +$("#username").editable({ + url: "/post", + title: "Enter username" +}); + +// text area +$('#comments').editable({ + url: '/post', + title: 'Enter comments', + rows: 10 +}); + +// select +$("#status").editable({ + value: 2, + source: [ + {value: 1, text: 'Active'}, + {value: 2, text: 'Blocked'}, + {value: 3, text: 'Deleted'} + ] +}); + +// date +$('#dob').editable({ + format: 'yyyy-mm-dd', + viewformat: 'dd/mm/yyyy', + datepicker: { + weekStart: 1 + } +}); + +// datetime +$('#last_seen').editable({ + format: 'yyyy-mm-dd hh:ii', + viewformat: 'dd/mm/yyyy hh:ii', + datetimepicker: { + weekStart: 1 + } +}); + +// dateui +$('#dob').editable({ + format: 'yyyy-mm-dd', + viewformat: 'dd/mm/yyyy', + datepicker: { + firstDay: 1 + } +}); + +// combodate +$('#dob').editable({ + format: 'YYYY-MM-DD', + viewformat: 'DD.MM.YYYY', + template: 'D / MMMM / YYYY', + combodate: { + minYear: 2000, + maxYear: 2015, + minuteStep: 1 + } +}); + +// checklist +$('#options').editable({ + value: [2, 3], + source: [ + {value: 1, text: 'option1'}, + {value: 2, text: 'option2'}, + {value: 3, text: 'option3'} + ] +}); + +// select2 remote source (advanced) +$('#country').editable({ + select2: { + placeholder: 'Select Country', + allowClear: true, + minimumInputLength: 3, + id: function (item : any) { + return item.CountryId; + }, + ajax: { + url: '/getCountries', + dataType: 'json', + data: function (term : any, page : any) { + return { query: term }; + }, + results: function (data : any, page : any) { + return { results: data }; + } + }, + formatResult: function (item : any) { + return item.CountryName; + }, + formatSelection: function (item : any) { + return item.CountryName; + }, + initSelection: function (element : any, callback : any) { + return $.get('/getCountryById', { query: element.val() }, function (data : any) { + callback(data); + }); + } + } +}); diff --git a/x-editable/x-editable.d.ts b/x-editable/x-editable.d.ts new file mode 100644 index 000000000..7af603020 --- /dev/null +++ b/x-editable/x-editable.d.ts @@ -0,0 +1,79 @@ +// Type definitions for X-Editable v1.5.1 +// Project: http://vitalets.github.io/x-editable/index.html +// Definitions by: Chris Kirby +// Definitions: https://github.com/sirkirby/DefinitelyTyped + + +/// + +interface XEditableOptions +{ + ajaxOptions?: any; + anim?: string; + autotext?: string; + defaultValue?: any; + disabled?: boolean; + display?: any; + emptyclass?: string; + emptytext?: string; + error?: any; + highlight?: any; + mode?: string; + name?: string; + onblur?: string; + params?: any; + pk?: any; + placement?: string; + savenochange?: boolean; + selector?: string; + send?: string; + showbuttons?: any; + success?: any; + toggle?: string; + type?: string; + unsavedclass?: string; + url?: any; + validate?: any; + value?: any; + + +} + +interface XEditableSubmitOptions { + url?: any; + data?: any; + ajaxOptions?: any; + error(obj: any) : void; + success(obj: any, config: any) : void; +} + +interface XEditable { + options: XEditableOptions; + activate() : void; + destroy() : void; + disable() : void; + enable() : void; + getValue(isSingle: boolean) : any; + hide() : void; + option(key: any, value: any) : void; + setValue(value: any, convertStr: boolean) : void; + show(closeAll: boolean) : void; + submit(options: XEditableSubmitOptions) : void; + toggle(closeAll: boolean) : void; + toggleDisabled() : void; + validate() : void; +} + +interface JQuery { + /** + * Initializes editable with the specified options + * @param options an object with options specific to the editable instance + */ + editable(options?: any): XEditable; + /** + * Initializes editable calling the specific method with is parameters + * @param method the method to call + * @param params the parameters expected by the method + */ + editable(method: string, params?: any): XEditable; +} diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index aed7a8f03..f6d0dd981 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/yeoman/generator // Definitions by: Kentaro Okuno // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// declare module yo { export interface IYeomanGenerator { @@ -20,6 +21,30 @@ declare module yo { sourceRoot(rootPath: string): string; } + export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter { + argument(name: string, config: IArgumentConfig): void; + composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; + defaultFor(name: string): void; + destinationRoot(rootPath: string): string; + determineAppname(): void; + getCollisionFilter(): (output: any) => void; + hookFor(name: string, config: IHookConfig): void; + option(name: string, config: IYeomanGeneratorOption): void; + rootGeneratorName(): string; + run(args?: any): void; + run(args: any, callback?: Function): void; + runHooks(callback?: Function): void; + sourceRoot(rootPath: string): string; + addListener(event: string, listener: Function): NodeJS.EventEmitter; + on(event: string, listener: Function): NodeJS.EventEmitter; + once(event: string, listener: Function): NodeJS.EventEmitter; + removeListener(event: string, listener: Function): NodeJS.EventEmitter; + removeAllListeners(event?: string): NodeJS.EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } + export interface IArgumentConfig { desc: string; required: boolean; @@ -60,15 +85,10 @@ declare module yo { end: () => void; } - export interface IBase { - new(args: string, options: any): IYeomanGenerator; - new(args: string[], options: any): IYeomanGenerator; - extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + export interface INamedBase extends IYeomanGenerator { } - export interface INamedBase { - new(args: string, options: any): IYeomanGenerator; - new(args: string[], options: any): IYeomanGenerator; + export interface IBase extends INamedBase { } export interface IAssert { @@ -130,10 +150,16 @@ declare module yo { var file: any; var assert: IAssert; var test: ITestHelper; - var generators: { - Base: IBase; - NamedBase: INamedBase; - }; + module generators { + + export class NamedBase extends YeomanGeneratorBase implements INamedBase { + constructor(args: string | string[], options: any); + } + + export class Base extends NamedBase implements IBase { + static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } + } } declare module "yeoman-generator" { diff --git a/zip.js/zip.js-tests.ts b/zip.js/zip.js-tests.ts new file mode 100644 index 000000000..b00654996 --- /dev/null +++ b/zip.js/zip.js-tests.ts @@ -0,0 +1,45 @@ +/// + +// create the blob object storing the data to compress +var blob: Blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { + type : "text/plain" +}); +// creates a zip storing the file "lorem.txt" with blob as data +// the zip will be stored into a Blob object (zippedBlob) +zipBlob("lorem.txt", blob, function(zippedBlob: Blob) { + // unzip the first file from zipped data stored in zippedBlob + unzipBlob(zippedBlob, function(unzippedBlob: Blob) { + // logs the uncompressed Blob + console.log(unzippedBlob); + }); +}); + +function zipBlob(filename: string, blob: Blob, callback: (blob: Blob) => void) { + // use a zip.BlobWriter object to write zipped data into a Blob object + zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) { + // use a BlobReader object to read the data stored into blob variable + zipWriter.add(filename, new zip.BlobReader(blob), function() { + // close the writer and calls callback function + zipWriter.close(callback); + }); + }, theErrorHandler); +} + +function unzipBlob(blob: Blob, callback: (unzippedBlob: Blob) => void) { + // use a zip.BlobReader object to read zipped data stored into blob variable + zip.createReader(new zip.BlobReader(blob), function(zipReader) { + // get entries from the zip file + zipReader.getEntries(function(entries: zip.Entry[]) { + // get data from the first file + entries[0].getData(new zip.BlobWriter("text/plain"), function(data: Blob) { + // close the reader and calls callback function with uncompressed data as parameter + zipReader.close(); + callback(data); + }); + }); + }, theErrorHandler); +} + +function theErrorHandler(message: any) { + console.error(message); +} \ No newline at end of file diff --git a/zip.js/zip.js.d.ts b/zip.js/zip.js.d.ts new file mode 100644 index 000000000..fa976dca9 --- /dev/null +++ b/zip.js/zip.js.d.ts @@ -0,0 +1,94 @@ +// Type definitions for zip.js 2.x +// Project: https://github.com/gildas-lormeau/zip.js +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface FileEntry {} + +declare module zip { + export var useWebWorkers: boolean; + export var workerScriptsPath: string; + export var workerScripts: { + deflater?: string[]; + inflater?: string[]; + }; + + export class Reader { + public size: number; + public init(callback: () => void, onerror: (error: any) => void): void; + public readUint8Array(index: number, length: number, callback: (result: Uint8Array) => void, onerror?: (error: any) => void): void; + } + + export class TextReader extends Reader { + constructor(text: string); + } + + export class BlobReader extends Reader { + constructor(blob: Blob); + } + + export class Data64URIReader extends Reader { + constructor(dataURI: string); + } + + export class HttpReader extends Reader { + constructor(url: string); + } + + export function createReader(reader: zip.Reader, callback: (zipReader: ZipReader) => void, onerror?: (error: any) => void): void; + + export class ZipReader { + getEntries(callback: (entries: zip.Entry[]) => void): void; + close(callback?: () => void): void; + } + + export interface Entry { + filename: string; + directory: boolean; + compressedSize: number; + uncompressedSize: number; + lastModDate: Date; + lastModDateRaw: number; + comment: string; + crc32: number; + + getData(writer: zip.Writer, onend: (result: any) => void, onprogress?: (progress: number, total: number) => void, checkCrc32?: boolean): void; + } + + export class Writer { + public init(callback: () => void, onerror?: (error: any) => void): void; + public writeUint8Array(array: Uint8Array, callback: () => void, onerror?: (error: any) => void): void; + public getData(callback: (data: any) => void, onerror?: (error: any) => void) : void; + } + + export class TextWriter extends Writer { + constructor(encoding: string); + } + + export class BlobWriter extends Writer { + constructor(contentType: string); + } + + export class FileWriter extends Writer { + constructor(fileEntry: FileEntry); + } + + export class Data64URIWriter extends Writer { + constructor(mimeString?: string); + } + + export function createWriter(writer: zip.Writer, callback: (zipWriter: zip.ZipWriter) => void, onerror?: (error: any) => void, dontDeflate?: boolean): void; + + export interface WriteOptions { + directory?: boolean; + level?: number; + comment?: string; + lastModDate?: Date; + version?: number; + } + + export class ZipWriter { + public add(name: string, reader: zip.Reader, onend: () => void, onprogress?: (progress: number, total: number) => void, options?: WriteOptions): void; + public close(callback: (result: any) => void): void; + } +}