diff --git a/README.md b/README.md index ed1598397..2d552bfc1 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) +DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) =============== The repository for *high quality* TypeScript type definitions. @@ -49,6 +49,8 @@ List of Definitions * [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) * [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem)) * [d3.js](http://d3js.org/) (from TypeScript samples) +* [dhtmlxGantt](http://dhtmlx.com/docs/products/dhtmlxGantt) (by [Maksim Kozhukh](http://github.com/mkozhukh)) +* [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) * [docCookies](https://developer.mozilla.org/en-US/docs/Web/API/document.cookie) (by [Jon Egerton](https://github.com/jonegerton)) * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) @@ -66,14 +68,17 @@ List of Definitions * [Firebase](https://www.firebase.com/docs/javascript/firebase) (by [Vincent Bortone](https://github.com/vbortone)) * [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame)) * [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei)) +* [Flight by Twitter](http://flightjs.github.com/flight/) (by [Jonathan Hedrén](https://github.com/jonathanhedren)) * [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [FPSMeter](http://darsa.in/fpsmeter/) (by [Aaron Lampros](https://github.com/alampros)) * [FullCalendar](http://arshaw.com/fullcalendar/) (by [Neil Stalker](https://github.com/nestalk)) * [Gamepad](http://www.w3.org/TR/gamepad/) (by [Kon](http://phyzkit.net/)) +* [Giraffe](https://github.com/barc/backbone.giraffe) (by [Matt McCray](https://github.com/darthapo)) * [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz)) * [GoJS](http://gojs.net/) (by [Barbara Duckworth](https://github.com/barbara42)) +* [Greasemonkey](http://www.greasespot.net/) (by [Kota Saito](https://github.com/kotas)) * [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt)) -* [Grunt JS](http://gruntjs.com/) (by [Basarat Ali Syed](https://github.com/basarat)) +* [Grunt JS](http://gruntjs.com/) (by [Jeff May](https://github.com/jeffmay) and [Basarat Ali Syed](https://github.com/basarat)) * [Google API Client](https://code.google.com/p/google-api-javascript-client/) (by [Frank M](https://github.com/sgtfrankieboy)) * [Google App Engine Channel API](https://developers.google.com/appengine/docs/java/channel/javascript) (by [vvakame](https://github.com/vvakame)) * [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) @@ -90,7 +95,6 @@ List of Definitions * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) * [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) -* [Intl](http://www.ecma-international.org/ecma-402/1.0/) (by [Jeffery Grajkowski](http://github.com/pushplay)) * [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov) and [Christiaan Rakowski](https://github.com/csrakowski)) * [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/)) * [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) @@ -104,9 +108,10 @@ List of Definitions * [jQuery.areYouSure](https://github.com/codedance/jquery.AreYouSure) (by [Jon Egerton](https://github.com/jonegerton)) * [jQuery.autosize](http://www.jacklmoore.com/autosize/) (by [Jack Moore](http://www.jacklmoore.com/)) * [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) -* [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) +* [jQuery.CLEditor](http://premiumsoftware.net/CLEditor) (by [Jeffery Grajkowski](https://github.com/pushplay)) * [jQuery.clientSideLogging](https://github.com/remybach/jQuery.clientSideLogging/) (by [Diullei Gomes](https://github.com/diullei/)) * [jQuery.Colorbox](http://www.jacklmoore.com/colorbox/) (by [Gidon Junge](https://github.com/gjunge)) +* [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) * [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) * [jQuery.Cycle](http://jquery.malsup.com/cycle/) (by [François Guillot](http://fguillot.developpez.com/)) * [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix)) @@ -124,11 +129,13 @@ List of Definitions * [jquery.superLink](http://james.padolsey.com/demos/plugins/jQuery/superLink/superlink.jquery.js) (by [Blake Niemyjski](https://github.com/niemyjski)) * [jQuery.timeago](http://timeago.yarp.com/) (by [François Guillot](http://fguillot.developpez.com/)) * [jQuery.Timepicker](http://fgelinas.com/code/timepicker/) (by [Anwar Javed](https://github.com/anwarjaved)) +* [jQuery.Timer](http://jchavannes.com/jquery-timer/demo) (by [Joshua Strobl](https://github.com/JoshStrobl)) * [jQuery.TinyCarousel](http://baijs.nl/tinycarousel/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [jQuery.TinyScrollbar](http://baijs.nl/tinyscrollbar/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) +* [jQuery.base64](https://github.com/yatt/jquery.base64) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) * [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz)) * [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk)) * [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/)) @@ -141,7 +148,7 @@ List of Definitions * [Knockout.ES5](https://github.com/SteveSanderson/knockout-es5) (by [Sebastián Galiano](https://github.com/sgaliano)) * [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) (by [Brandon Meyer](https://github.com/BMeyerKC)) * [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) (by [Boris Yankov](https://github.com/borisyankov)) -* [Knockout.Postbox](https://github.com/rniemeyer/knockout-postbox) (by [Judah Gabriel](https://github.com/JudahGabriel)) +* [Knockout.Postbox](https://github.com/rniemeyer/knockout-postbox) (by [Judah Gabriel Himango](https://github.com/JudahGabriel)) * [Knockout.Validation](https://github.com/ericmbarnard/Knockout-Validation) (by [Dan Ludwig](https://github.com/danludwig)) * [Knockout.Viewmodel](http://coderenaissance.github.com/knockout.viewmodel/) (by [Oisin Grehan](https://github.com/oising)) * [ko.editables](http://romanych.github.com/ko.editables/) (by [Oisin Grehan](https://github.com/oising)) @@ -167,7 +174,9 @@ List of Definitions * [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) +* [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/)) +* [OpenLayers] (https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/)) * [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin)) * [PDF.js](https://github.com/mozilla/pdf.js) (by [Josh Baldwin](https://github.com/jbaldwin)) * [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto)) diff --git a/_infrastructure/tests/compile-runner.bat b/_infrastructure/tests/compile-runner.bat new file mode 100644 index 000000000..53e014841 --- /dev/null +++ b/_infrastructure/tests/compile-runner.bat @@ -0,0 +1 @@ +tsc runner.ts --out runner.js --module commonjs \ No newline at end of file diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 855cffa69..3721f7e11 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -552,10 +552,11 @@ else if (typeof require === "function") else return null; })(); -/// -/// var DefinitelyTyped; (function (DefinitelyTyped) { + /// + /// + /// (function (TestManager) { var path = require('path'); @@ -586,6 +587,8 @@ var DefinitelyTyped; var command = 'node ./_infrastructure/tests/typescript/tsc.js --module commonjs '; if (IO.fileExists(tsfile + '.tscparams')) { command += '@' + tsfile + '.tscparams'; + } else { + command += '--noImplicitAny'; } Exec.exec(command, [tsfile], function (ExecResult) { callback(ExecResult); @@ -612,6 +615,10 @@ var DefinitelyTyped; return Typing; })(); + ///////////////////////////////// + // Given a document root + ts file pattern this class returns: + // all the TS files OR just tests OR just definition files + ///////////////////////////////// var FileHandler = (function () { function FileHandler(path, pattern) { this.path = path; @@ -657,6 +664,10 @@ var DefinitelyTyped; return FileHandler; })(); + ///////////////////////////////// + // Timer.start starts a timer + // Timer.end stops the timer and sets asString to the pretty print value + ///////////////////////////////// var Timer = (function () { function Timer() { this.time = 0; @@ -686,6 +697,9 @@ var DefinitelyTyped; return Timer; })(); + ///////////////////////////////// + // All the common things that we pring are functions of this class + ///////////////////////////////// var Print = (function () { function Print(version, typings, tsFiles) { this.version = version; @@ -705,19 +719,19 @@ var DefinitelyTyped; this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); }; - Print.prototype.printSyntaxChecking = function () { + Print.prototype.printSyntaxCheckingHeader = function () { this.out('============================ \33[34m\33[1mSyntax checking\33[0m ================================\n'); }; - Print.prototype.printTypingTests = function () { + Print.prototype.printTypingTestsHeader = function () { this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n'); }; - Print.prototype.printSuccess = function () { + Print.prototype.printSuccessCharacter = function () { this.out('\33[36m\33[1m.\33[0m'); }; - Print.prototype.printFailure = function () { + Print.prototype.printFailureCharacter = function () { this.out('x'); }; @@ -725,6 +739,23 @@ var DefinitelyTyped; this.out('-----------------------------------------------------------------------------\n'); }; + Print.prototype.printBoldDiv = function () { + this.out('=============================================================================\n'); + }; + + Print.prototype.printErrorsHeader = function () { + this.out('=============================================================================\n'); + this.out(' \33[34m\33[1mErrors in files\33[0m \n'); + this.out('=============================================================================\n'); + }; + + Print.prototype.printErrorsForFile = function (file) { + this.out('----------------- For file:' + file.formatName()); + this.printBreak(); + this.out(file.execResult.stderr); + this.printBreak(); + }; + Print.prototype.printfilesWithSintaxErrorMessage = function () { this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n'); }; @@ -749,7 +780,7 @@ var DefinitelyTyped; this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); }; - Print.prototype.breack = function () { + Print.prototype.printBreak = function () { this.out('\n'); }; @@ -779,22 +810,30 @@ var DefinitelyTyped; return Print; })(); + ///////////////////////////// + // Represents the results of a test file execution + ///////////////////////////// var File = (function () { - function File(name, hasError) { - this.name = name; - this.hasError = hasError; + function File(baseDir, filePathWithName, execResult) { + this.baseDir = baseDir; + this.filePathWithName = filePathWithName; + this.execResult = execResult; } - File.prototype.formatName = function (baseDir) { - var dirName = path.dirname(this.name.substr(baseDir.length + 1)).replace('\\', '/'); + // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' + File.prototype.formatName = function () { + var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); var dir = dirName.split('/')[0]; - var file = path.basename(this.name, '.ts'); - var ext = path.extname(this.name); + var file = path.basename(this.filePathWithName, '.ts'); + var ext = path.extname(this.filePathWithName); return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext; }; return File; })(); + ///////////////////////////// + // Determine syntax errors in typings + ///////////////////////////// var SyntaxChecking = (function () { function SyntaxChecking(fileHandler, out) { this.fileHandler = fileHandler; @@ -806,7 +845,7 @@ var DefinitelyTyped; var list = []; for (var i = 0; i < this.files.length; i++) { - if (this.files[i].hasError) { + if (this.files[i].execResult.exitCode) { list.push(this.files[i]); } } @@ -818,7 +857,7 @@ var DefinitelyTyped; var list = []; for (var i = 0; i < this.files.length; i++) { - if (!this.files[i].hasError) { + if (!this.files[i].execResult.exitCode) { list.push(this.files[i]); } } @@ -843,7 +882,7 @@ var DefinitelyTyped; for (var i = 0; i < this.getFailedFiles().length; i++) { var errorFile = this.getFailedFiles()[i]; - this.out.printErrorFile(errorFile.formatName(this.fileHandler.path)); + this.out.printErrorFile(errorFile.formatName()); } } }; @@ -851,29 +890,26 @@ var DefinitelyTyped; SyntaxChecking.prototype.run = function (it, file, len, maxLen, callback) { var _this = this; if (!endsWith(file.toUpperCase(), '-TESTS.TS') && endsWith(file.toUpperCase(), '.TS') && file.indexOf('../_infrastructure') < 0) { - new Test(file).run(function (o) { - var failed = false; - - if (o.exitCode === 1) { - _this.out.printFailure(); - failed = true; + new Test(file).run(function (execResult) { + if (execResult.exitCode === 1) { + _this.out.printFailureCharacter(); len++; } else { - _this.out.printSuccess(); + _this.out.printSuccessCharacter(); len++; } - _this.files.push(new File(file, failed)); + _this.files.push(new File(_this.fileHandler.path, file, execResult)); if (len > maxLen) { len = 0; - _this.out.breack(); + _this.out.printBreak(); } if (it.hasNext()) { _this.run(it, it.next(), len, maxLen, callback); } else { - _this.out.breack(); + _this.out.printBreak(); _this.timer.end(); _this.printFailedFiles(); _this.printStats(); @@ -884,7 +920,7 @@ var DefinitelyTyped; } else if (it.hasNext()) { this.run(it, it.next(), len, maxLen, callback); } else { - this.out.breack(); + this.out.printBreak(); this.timer.end(); this.printStats(); this.printFailedFiles(); @@ -910,6 +946,9 @@ var DefinitelyTyped; return SyntaxChecking; })(); + ///////////////////////////// + // Determines errors in typing tests + ///////////////////////////// var TestEval = (function () { function TestEval(fileHandler, out) { this.fileHandler = fileHandler; @@ -921,7 +960,7 @@ var DefinitelyTyped; var list = []; for (var i = 0; i < this.files.length; i++) { - if (this.files[i].hasError) { + if (this.files[i].execResult.exitCode) { list.push(this.files[i]); } } @@ -933,7 +972,7 @@ var DefinitelyTyped; var list = []; for (var i = 0; i < this.files.length; i++) { - if (!this.files[i].hasError) { + if (!this.files[i].execResult.exitCode) { list.push(this.files[i]); } } @@ -958,7 +997,7 @@ var DefinitelyTyped; for (var i = 0; i < this.getFailedFiles().length; i++) { var errorFile = this.getFailedFiles()[i]; - this.out.printErrorFile(errorFile.formatName(this.fileHandler.path)); + this.out.printErrorFile(errorFile.formatName()); } } }; @@ -966,29 +1005,26 @@ var DefinitelyTyped; TestEval.prototype.run = function (it, file, len, maxLen, callback) { var _this = this; if (endsWith(file.toUpperCase(), '-TESTS.TS')) { - new Test(file).run(function (o) { - var failed = false; - - if (o.exitCode === 1) { - _this.out.printFailure(); - failed = true; + new Test(file).run(function (execResult) { + if (execResult.exitCode === 1) { + _this.out.printFailureCharacter(); len++; } else { - _this.out.printSuccess(); + _this.out.printSuccessCharacter(); len++; } - _this.files.push(new File(file, failed)); + _this.files.push(new File(_this.fileHandler.path, file, execResult)); if (len > maxLen) { len = 0; - _this.out.breack(); + _this.out.printBreak(); } if (it.hasNext()) { _this.run(it, it.next(), len, maxLen, callback); } else { - _this.out.breack(); + _this.out.printBreak(); _this.timer.end(); _this.printFailedFiles(); _this.printStats(); @@ -999,7 +1035,7 @@ var DefinitelyTyped; } else if (it.hasNext()) { this.run(it, it.next(), len, maxLen, callback); } else { - this.out.breack(); + this.out.printBreak(); this.timer.end(); this.printFailedFiles(); this.printStats(); @@ -1025,6 +1061,9 @@ var DefinitelyTyped; return TestEval; })(); + ///////////////////////////////// + // The main class to kick things off + ///////////////////////////////// var TestRunner = (function () { function TestRunner(dtPath) { this.dtPath = dtPath; @@ -1063,19 +1102,41 @@ var DefinitelyTyped; return count; }; + TestRunner.prototype.printErrorsDetected = function () { + var _this = this; + this.out.printErrorsHeader(); + + var printErrorsForFileIfFound = function (file) { + if (file.execResult.exitCode) + _this.out.printErrorsForFile(file); + }; + + // sc errors: + this.sc.files.forEach(printErrorsForFileIfFound); + this.out.printBoldDiv(); + + // te errors: + this.te.files.forEach(printErrorsForFileIfFound); + this.out.printBoldDiv(); + }; + TestRunner.prototype.run = function () { var _this = this; var timer = new Timer(); timer.start(); this.out.printHeader(); - this.out.printSyntaxChecking(); + // Run syntax tests + this.out.printSyntaxCheckingHeader(); this.sc.start(function (syntaxFailedCount, syntaxTotal) { - _this.out.printTypingTests(); + // Now run typing tests + _this.out.printTypingTestsHeader(); _this.te.start(function (testFailedCount, testTotal) { - var total = _this.printTypingsWithoutTest(); + // Get the tests without any typing and simultaneously print their names + var totalTypingsWithoutTest = _this.printTypingsWithoutTest(); + // End total timer and print final messages timer.end(); _this.out.printDiv(); @@ -1085,11 +1146,12 @@ var DefinitelyTyped; _this.out.printElapsedTime(timer.asString, timer.time); _this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal); _this.out.printTestErrorCount(testFailedCount, testTotal); - _this.out.printWithoutTestCount(total, _this.fh.allTypings().length); + _this.out.printWithoutTestCount(totalTypingsWithoutTest, _this.fh.allTypings().length); _this.out.printDiv(); if (syntaxFailedCount > 0 || testFailedCount > 0) { + _this.printErrorsDetected(); process.exit(1); } }); diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index bd60ebe7a..68682f536 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -1,560 +1,626 @@ -/// +/// + +/// /// -module DefinitelyTyped { - - export module TestManager { - - var path = require('path'); - - function endsWith(str, suffix) { - return str.indexOf(suffix, str.length - suffix.length) !== -1; - } - - class Iterator { - index: number = -1; - - constructor(public list: any[]){} - - public next() { - this.index++; - return this.list[this.index]; - } - - public hasNext() { - return this.list[1 + this.index] != null; - } - } - - class Tsc { - public static run(tsfile: string, callback: Function) { - var command = 'node ./_infrastructure/tests/typescript/tsc.js --module commonjs '; - if (IO.fileExists(tsfile + '.tscparams')) { - command += '@' + tsfile + '.tscparams'; - } - Exec.exec(command, [tsfile], (ExecResult) => { - callback(ExecResult); - }); - } - } - - class Test { - constructor(public tsfile: string) {} - - public run(callback: Function) { - Tsc.run(this.tsfile , callback); - } - } - - class Typing { - public fileHandler: FileHandler; - - constructor(public name: string, baseDir: string) { - this.fileHandler = new FileHandler(baseDir + '/' + name + '/', /.\.ts/g); - } - } - - class FileHandler { - public files: string[] = []; - public typings: Typing[] = []; - - constructor(public path: string, pattern: any) { - this.files = IO.dir(path, pattern, { recursive: true }).sort(); - } - - public allTS(): string[] { - return this.files; - } - - public allTests(): string[] { - var tests = []; - - for(var i = 0; i < this.files.length; i++) { - if (endsWith(this.files[i].toUpperCase(), '-TESTS.TS')) { - tests.push(this.files[i]); - } - } - - return tests; - } - - public allTypings(): string[] { - var typings = {}; - - for(var i = 0; i < this.files.length; i++) { - var file = this.files[i]; - var firName = path.dirname(file.substr(this.path.length + 1)).replace('\\', '/'); - var dir = firName.split('/')[0]; - - if(!typings[dir]) typings[dir] = true; - } - - var list = []; - for(var attr in typings) { - list.push(attr); - } - - return list; - } - } - - class Timer { - public startTime; - public time = 0; - public asString: string; - - private static prettyDate(date1, date2): string { - var diff = ((date2 - date1) / 1000), - day_diff = Math.floor(diff / 86400); - - if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ) - return; - - return (day_diff == 0 && ( - diff < 60 && (diff + " seconds") || - diff < 120 && "1 minute" || - diff < 3600 && Math.floor( diff / 60 ) + " minutes" || - diff < 7200 && "1 hour" || - diff < 86400 && Math.floor( diff / 3600 ) + " hours") || - day_diff == 1 && "Yesterday" || - day_diff < 7 && day_diff + " days" || - day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks"); - } - - public start() { - this.time = 0; - this.startTime = this.now(); - } - - private now() { - return Date.now(); - } - - public end() { - this.time = (this.now() - this.startTime) / 1000; - this.asString = Timer.prettyDate(this.startTime, this.now()); - } - } - - class Print { - constructor(public version: string, public typings: number, public tsFiles: number) { } - - public out(s) { - process.stdout.write(s); - } - - public printHeader() { - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.3.0\33[0m\n'); - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); - this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); - this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); - } - - public printSyntaxChecking() { - this.out('============================ \33[34m\33[1mSyntax checking\33[0m ================================\n'); - } - - public printTypingTests() { - this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n'); - } - - public printSuccess() { - this.out('\33[36m\33[1m.\33[0m'); - } - - public printFailure() { - this.out('x'); - } - - public printDiv() { - this.out('-----------------------------------------------------------------------------\n'); - } - - public printfilesWithSintaxErrorMessage() { - this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n'); - } - - public printFailedTestMessage() { - this.out(' \33[36m\33[1mFailed tests\33[0m\n'); - } - - public printTypingsWithoutTestsMessage() { - this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); - } - - public printTotalMessage() { - this.out(' \33[36m\33[1mTotal\33[0m\n'); - } - - public printErrorFile(file) { - this.out(' - ' + file + '\n'); - } - - public printTypingsWithoutTest(file) { - this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); - } - - public breack() { - this.out('\n'); - } - - public printSuccessCount(current: number, total: number) { - this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printFailedCount(current: number, total: number) { - this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printElapsedTime(time, s) { - this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); - } - - public printSyntaxErrorCount(current: number, total: number) { - this.out(' \33[36m\33[1mSyntax error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printTestErrorCount(current: number, total: number) { - this.out(' \33[36m\33[1mFailed tests :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printWithoutTestCount(current: number, total: number) { - this.out(' \33[36m\33[1mWithout tests :\33[0m \33[33m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - } - - class File { - - constructor(public name: string, public hasError: boolean) {} - - public formatName(baseDir: string): string { - var dirName = path.dirname(this.name.substr(baseDir.length + 1)).replace('\\', '/'); - var dir = dirName.split('/')[0]; - var file = path.basename(this.name, '.ts'); - var ext = path.extname(this.name); - - return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext; - } - } - - class SyntaxChecking { - - private timer: Timer; - - public files: File[] = []; - - private getFailedFiles(): File[] { - var list: File[] = []; - - for(var i = 0; i < this.files.length; i++) { - if(this.files[i].hasError) { - list.push(this.files[i]); - } - } - - return list; - } - - private getSuccessFiles(): File[] { - var list: File[] = []; - - for(var i = 0; i < this.files.length; i++) { - if(!this.files[i].hasError) { - list.push(this.files[i]); - } - } - - return list; - } - - constructor(public fileHandler: FileHandler, public out: Print) { - this.timer = new Timer(); - } - - private printStats() { - this.out.printDiv(); - this.out.printElapsedTime(this.timer.asString, this.timer.time); - this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length); - this.out.printFailedCount(this.getFailedFiles().length, this.files.length); - } - - private printFailedFiles() { - if (this.getFailedFiles().length > 0) { - this.out.printDiv(); - - this.out.printfilesWithSintaxErrorMessage(); - - this.out.printDiv(); - - for(var i = 0; i < this.getFailedFiles().length; i++) { - var errorFile = this.getFailedFiles()[i]; - this.out.printErrorFile(errorFile.formatName(this.fileHandler.path)); - } - } - } - - private run(it, file, len, maxLen, callback: Function) { - if (!endsWith(file.toUpperCase(), '-TESTS.TS') && endsWith(file.toUpperCase(), '.TS') && file.indexOf('../_infrastructure') < 0) { - new Test(file).run((o) => { - var failed = false; - - if(o.exitCode === 1) { - this.out.printFailure(); - failed = true; - len++; - } else { - this.out.printSuccess(); - len++; - } - - this.files.push(new File(file, failed)); - - if(len > maxLen) { - len = 0; - this.out.breack(); - } - - if (it.hasNext()) { - this.run(it, it.next(), len, maxLen, callback); - } else { - this.out.breack(); - this.timer.end(); - this.printFailedFiles(); - this.printStats(); - - callback(this.getFailedFiles().length, this.files.length); - } - }); - } else if (it.hasNext()) { - this.run(it, it.next(), len, maxLen, callback); - } else { - this.out.breack(); - this.timer.end(); - this.printStats(); - this.printFailedFiles(); - - callback(this.getFailedFiles().length, this.files.length); - } - } - - public start(callback: Function) { - this.timer.start(); - - var tsFiles = this.fileHandler.allTS(); - - var it = new Iterator(tsFiles); - - var len = 0; - var maxLen = 76; - - if (it.hasNext()) { - this.run(it, it.next(), len, maxLen, callback); - } - } - } - - class TestEval { - - private timer: Timer; - - public files: File[] = []; - - private getFailedFiles(): File[] { - var list: File[] = []; - - for(var i = 0; i < this.files.length; i++) { - if(this.files[i].hasError) { - list.push(this.files[i]); - } - } - - return list; - } - - private getSuccessFiles(): File[] { - var list: File[] = []; - - for(var i = 0; i < this.files.length; i++) { - if(!this.files[i].hasError) { - list.push(this.files[i]); - } - } - - return list; - } - - constructor(public fileHandler: FileHandler, public out: Print) { - this.timer = new Timer(); - } - - private printStats() { - this.out.printDiv(); - this.out.printElapsedTime(this.timer.asString, this.timer.time); - this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length); - this.out.printFailedCount(this.getFailedFiles().length, this.files.length); - } - - private printFailedFiles() { - if (this.getFailedFiles().length > 0) { - this.out.printDiv(); - - this.out.printFailedTestMessage(); - - this.out.printDiv(); - - for(var i = 0; i < this.getFailedFiles().length; i++) { - var errorFile = this.getFailedFiles()[i]; - this.out.printErrorFile(errorFile.formatName(this.fileHandler.path)); - } - } - } - - private run(it, file, len, maxLen, callback: Function) { - if (endsWith(file.toUpperCase(), '-TESTS.TS')) { - new Test(file).run((o) => { - var failed = false; - - if(o.exitCode === 1) { - this.out.printFailure(); - failed = true; - len++; - } else { - this.out.printSuccess(); - len++; - } - - this.files.push(new File(file, failed)); - - if(len > maxLen) { - len = 0; - this.out.breack(); - } - - if (it.hasNext()) { - this.run(it, it.next(), len, maxLen, callback); - } else { - this.out.breack(); - this.timer.end(); - this.printFailedFiles(); - this.printStats(); - - callback(this.getFailedFiles().length, this.files.length); - } - }); - } else if (it.hasNext()) { - this.run(it, it.next(), len, maxLen, callback); - } else { - this.out.breack(); - this.timer.end(); - this.printFailedFiles(); - this.printStats(); - - callback(this.getFailedFiles().length, this.files.length); - } - } - - public start(callback: Function) { - this.timer.start(); - - var tsFiles = this.fileHandler.allTS(); - - var it = new Iterator(tsFiles); - - var len = 0; - var maxLen = 76; - - if (it.hasNext()) { - this.run(it, it.next(), len, maxLen, callback); - } - } - } - - export class TestRunner { - private fh: FileHandler; - private out: Print; - private sc: SyntaxChecking; - private te: TestEval; - private typings: Typing[] = []; - - private printTypingsWithoutTest() { - var count = 0; - - if (this.typings.length > 0) { - this.out.printDiv(); - - this.out.printTypingsWithoutTestsMessage(); - - this.out.printDiv(); - - for(var i = 0; i < this.typings.length; i++) { - var typing = this.typings[i]; - if(typing.fileHandler.allTests().length == 0) { - if (typing.name != '_infrastructure' - && typing.name != '_ReSharper.DefinitelyTyped' - && typing.name != 'obj' - && typing.name != 'bin' - && typing.name != 'Properties') { - this.out.printTypingsWithoutTest(typing.name); - count++; - } - } - } - } - - return count; - } - - constructor(public dtPath: string) { - this.fh = new FileHandler(dtPath, /.\.ts/g); - this.out = new Print('0.9.1.1', this.fh.allTypings().length, this.fh.allTS().length); - this.sc = new SyntaxChecking(this.fh, this.out); - this.te = new TestEval(this.fh, this.out); - - var tpgs = this.fh.allTypings(); - for(var i = 0; i < tpgs.length; i++) { - this.typings.push(new Typing(tpgs[i], this.dtPath)); - } - } - - public run() { - var timer = new Timer(); - timer.start(); - - this.out.printHeader(); - this.out.printSyntaxChecking(); - - this.sc.start((syntaxFailedCount, syntaxTotal) => { - this.out.printTypingTests(); - this.te.start((testFailedCount, testTotal) => { - var total = this.printTypingsWithoutTest(); - - timer.end(); - - this.out.printDiv(); - this.out.printTotalMessage(); - this.out.printDiv(); - - this.out.printElapsedTime(timer.asString, timer.time); - this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal); - this.out.printTestErrorCount(testFailedCount, testTotal); - this.out.printWithoutTestCount(total, this.fh.allTypings().length); - - this.out.printDiv(); - - if (syntaxFailedCount > 0 || testFailedCount > 0) { - process.exit(1); - } - }); - }); - } - } - } +module DefinitelyTyped.TestManager { + + var path = require('path'); + + function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } + + class Iterator { + index: number = -1; + + constructor(public list: any[]) { } + + public next() { + this.index++; + return this.list[this.index]; + } + + public hasNext() { + return this.list[1 + this.index] != null; + } + } + + interface TscCallback { + (result: ExecResult): void; + } + + class Tsc { + public static run(tsfile: string, callback: TscCallback) { + var command = 'node ./_infrastructure/tests/typescript/tsc.js --module commonjs '; + if (IO.fileExists(tsfile + '.tscparams')) { + command += '@' + tsfile + '.tscparams'; + } else { + command += '--noImplicitAny'; + } + Exec.exec(command, [tsfile], (ExecResult) => { + callback(ExecResult); + }); + } + } + + class Test { + constructor(public tsfile: string) { } + + public run(callback: TscCallback) { + Tsc.run(this.tsfile, callback); + } + } + + class Typing { + public fileHandler: FileHandler; + + constructor(public name: string, baseDir: string) { + this.fileHandler = new FileHandler(baseDir + '/' + name + '/', /.\.ts/g); + } + } + + ///////////////////////////////// + // Given a document root + ts file pattern this class returns: + // all the TS files OR just tests OR just definition files + ///////////////////////////////// + class FileHandler { + public files: string[] = []; + public typings: Typing[] = []; + + constructor(public path: string, pattern: any) { + this.files = IO.dir(path, pattern, { recursive: true }).sort(); + } + + public allTS(): string[] { + return this.files; + } + + public allTests(): string[] { + var tests = []; + + for (var i = 0; i < this.files.length; i++) { + if (endsWith(this.files[i].toUpperCase(), '-TESTS.TS')) { + tests.push(this.files[i]); + } + } + + return tests; + } + + public allTypings(): string[] { + var typings = {}; + + for (var i = 0; i < this.files.length; i++) { + var file = this.files[i]; + var firName = path.dirname(file.substr(this.path.length + 1)).replace('\\', '/'); + var dir = firName.split('/')[0]; + + if (!typings[dir]) typings[dir] = true; + } + + var list = []; + for (var attr in typings) { + list.push(attr); + } + + return list; + } + } + + ///////////////////////////////// + // Timer.start starts a timer + // Timer.end stops the timer and sets asString to the pretty print value + ///////////////////////////////// + class Timer { + public startTime; + public time = 0; + public asString: string; + + private static prettyDate(date1, date2): string { + var diff = ((date2 - date1) / 1000), + day_diff = Math.floor(diff / 86400); + + if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) + return; + + return (day_diff == 0 && ( + diff < 60 && (diff + " seconds") || + diff < 120 && "1 minute" || + diff < 3600 && Math.floor(diff / 60) + " minutes" || + diff < 7200 && "1 hour" || + diff < 86400 && Math.floor(diff / 3600) + " hours") || + day_diff == 1 && "Yesterday" || + day_diff < 7 && day_diff + " days" || + day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); + } + + public start() { + this.time = 0; + this.startTime = this.now(); + } + + private now() { + return Date.now(); + } + + public end() { + this.time = (this.now() - this.startTime) / 1000; + this.asString = Timer.prettyDate(this.startTime, this.now()); + } + } + + ///////////////////////////////// + // All the common things that we pring are functions of this class + ///////////////////////////////// + class Print { + constructor(public version: string, public typings: number, public tsFiles: number) { } + + public out(s) { + process.stdout.write(s); + } + + public printHeader() { + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.3.0\33[0m\n'); + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); + this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); + this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); + } + + public printSyntaxCheckingHeader() { + this.out('============================ \33[34m\33[1mSyntax checking\33[0m ================================\n'); + } + + public printTypingTestsHeader() { + this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n'); + } + + public printSuccessCharacter() { + this.out('\33[36m\33[1m.\33[0m'); + } + + public printFailureCharacter() { + this.out('x'); + } + + public printDiv() { + this.out('-----------------------------------------------------------------------------\n'); + } + + public printBoldDiv() { + this.out('=============================================================================\n'); + } + + public printErrorsHeader() { + this.out('=============================================================================\n'); + this.out(' \33[34m\33[1mErrors in files\33[0m \n'); + this.out('=============================================================================\n'); + } + + public printErrorsForFile(file: File) { + this.out('----------------- For file:' + file.formatName() ); + this.printBreak(); + this.out(file.execResult.stderr); + this.printBreak(); + } + + public printfilesWithSintaxErrorMessage() { + this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n'); + } + + public printFailedTestMessage() { + this.out(' \33[36m\33[1mFailed tests\33[0m\n'); + } + + public printTypingsWithoutTestsMessage() { + this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); + } + + public printTotalMessage() { + this.out(' \33[36m\33[1mTotal\33[0m\n'); + } + + public printErrorFile(file: string) { + this.out(' - ' + file + '\n'); + } + + public printTypingsWithoutTest(file) { + this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); + } + + public printBreak() { + this.out('\n'); + } + + public printSuccessCount(current: number, total: number) { + this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printFailedCount(current: number, total: number) { + this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printElapsedTime(time, s) { + this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); + } + + public printSyntaxErrorCount(current: number, total: number) { + this.out(' \33[36m\33[1mSyntax error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printTestErrorCount(current: number, total: number) { + this.out(' \33[36m\33[1mFailed tests :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printWithoutTestCount(current: number, total: number) { + this.out(' \33[36m\33[1mWithout tests :\33[0m \33[33m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + } + + ///////////////////////////// + // Represents the results of a test file execution + ///////////////////////////// + class File { + static baseDir: string; + + constructor(public baseDir: string, public filePathWithName: string, public execResult: ExecResult) { } + + // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' + public formatName(): string { + var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); + var dir = dirName.split('/')[0]; + var file = path.basename(this.filePathWithName, '.ts'); + var ext = path.extname(this.filePathWithName); + + return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext; + } + } + + + ///////////////////////////// + // Determine syntax errors in typings + ///////////////////////////// + class SyntaxChecking { + + private timer: Timer; + + public files: File[] = []; + + private getFailedFiles(): File[] { + var list: File[] = []; + + for (var i = 0; i < this.files.length; i++) { + if (this.files[i].execResult.exitCode) { + list.push(this.files[i]); + } + } + + return list; + } + + private getSuccessFiles(): File[] { + var list: File[] = []; + + for (var i = 0; i < this.files.length; i++) { + if (!this.files[i].execResult.exitCode) { + list.push(this.files[i]); + } + } + + return list; + } + + constructor(public fileHandler: FileHandler, public out: Print) { + this.timer = new Timer(); + } + + private printStats() { + this.out.printDiv(); + this.out.printElapsedTime(this.timer.asString, this.timer.time); + this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length); + this.out.printFailedCount(this.getFailedFiles().length, this.files.length); + } + + private printFailedFiles() { + if (this.getFailedFiles().length > 0) { + this.out.printDiv(); + + this.out.printfilesWithSintaxErrorMessage(); + + this.out.printDiv(); + + for (var i = 0; i < this.getFailedFiles().length; i++) { + var errorFile = this.getFailedFiles()[i]; + this.out.printErrorFile(errorFile.formatName()); + } + } + } + + private run(it, file, len, maxLen, callback: Function) { + if (!endsWith(file.toUpperCase(), '-TESTS.TS') && endsWith(file.toUpperCase(), '.TS') && file.indexOf('../_infrastructure') < 0) { + new Test(file).run((execResult) => { + + if (execResult.exitCode === 1) { + this.out.printFailureCharacter(); + len++; + } else { + this.out.printSuccessCharacter(); + len++; + } + + this.files.push(new File(this.fileHandler.path, file, execResult)); + + if (len > maxLen) { + len = 0; + this.out.printBreak(); + } + + if (it.hasNext()) { + this.run(it, it.next(), len, maxLen, callback); + } else { + this.out.printBreak(); + this.timer.end(); + this.printFailedFiles(); + this.printStats(); + + callback(this.getFailedFiles().length, this.files.length); + } + }); + } else if (it.hasNext()) { + this.run(it, it.next(), len, maxLen, callback); + } else { + this.out.printBreak(); + this.timer.end(); + this.printStats(); + this.printFailedFiles(); + + callback(this.getFailedFiles().length, this.files.length); + } + } + + public start(callback: Function) { + this.timer.start(); + + var tsFiles = this.fileHandler.allTS(); + + var it = new Iterator(tsFiles); + + var len = 0; + var maxLen = 76; + + if (it.hasNext()) { + this.run(it, it.next(), len, maxLen, callback); + } + } + } + + ///////////////////////////// + // Determines errors in typing tests + ///////////////////////////// + class TestEval { + + private timer: Timer; + + public files: File[] = []; + + private getFailedFiles(): File[] { + var list: File[] = []; + + for (var i = 0; i < this.files.length; i++) { + if (this.files[i].execResult.exitCode) { + list.push(this.files[i]); + } + } + + return list; + } + + private getSuccessFiles(): File[] { + var list: File[] = []; + + for (var i = 0; i < this.files.length; i++) { + if (!this.files[i].execResult.exitCode) { + list.push(this.files[i]); + } + } + + return list; + } + + constructor(public fileHandler: FileHandler, public out: Print) { + this.timer = new Timer(); + } + + private printStats() { + this.out.printDiv(); + this.out.printElapsedTime(this.timer.asString, this.timer.time); + this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length); + this.out.printFailedCount(this.getFailedFiles().length, this.files.length); + } + + private printFailedFiles() { + if (this.getFailedFiles().length > 0) { + this.out.printDiv(); + + this.out.printFailedTestMessage(); + + this.out.printDiv(); + + for (var i = 0; i < this.getFailedFiles().length; i++) { + var errorFile = this.getFailedFiles()[i]; + this.out.printErrorFile(errorFile.formatName()); + } + } + } + + private run(it, file, len, maxLen, callback: Function) { + if (endsWith(file.toUpperCase(), '-TESTS.TS')) { + new Test(file).run((execResult) => { + + if (execResult.exitCode === 1) { + this.out.printFailureCharacter(); + len++; + } else { + this.out.printSuccessCharacter(); + len++; + } + + this.files.push(new File(this.fileHandler.path, file, execResult)); + + if (len > maxLen) { + len = 0; + this.out.printBreak(); + } + + if (it.hasNext()) { + this.run(it, it.next(), len, maxLen, callback); + } else { + this.out.printBreak(); + this.timer.end(); + this.printFailedFiles(); + this.printStats(); + + callback(this.getFailedFiles().length, this.files.length); + } + }); + } else if (it.hasNext()) { + this.run(it, it.next(), len, maxLen, callback); + } else { + this.out.printBreak(); + this.timer.end(); + this.printFailedFiles(); + this.printStats(); + + callback(this.getFailedFiles().length, this.files.length); + } + } + + public start(callback: Function) { + this.timer.start(); + + var tsFiles = this.fileHandler.allTS(); + + var it = new Iterator(tsFiles); + + var len = 0; + var maxLen = 76; + + if (it.hasNext()) { + this.run(it, it.next(), len, maxLen, callback); + } + } + } + + ///////////////////////////////// + // The main class to kick things off + ///////////////////////////////// + export class TestRunner { + private fh: FileHandler; + private out: Print; + private sc: SyntaxChecking; + private te: TestEval; + private typings: Typing[] = []; + + private printTypingsWithoutTest() { + var count = 0; + + if (this.typings.length > 0) { + this.out.printDiv(); + + this.out.printTypingsWithoutTestsMessage(); + + this.out.printDiv(); + + for (var i = 0; i < this.typings.length; i++) { + var typing = this.typings[i]; + if (typing.fileHandler.allTests().length == 0) { + if (typing.name != '_infrastructure' + && typing.name != '_ReSharper.DefinitelyTyped' + && typing.name != 'obj' + && typing.name != 'bin' + && typing.name != 'Properties') { + this.out.printTypingsWithoutTest(typing.name); + count++; + } + } + } + } + + return count; + } + + private printErrorsDetected() { + this.out.printErrorsHeader(); + + var printErrorsForFileIfFound = (file: File) => { + if (file.execResult.exitCode) + this.out.printErrorsForFile(file); + }; + + // sc errors: + this.sc.files.forEach(printErrorsForFileIfFound); + this.out.printBoldDiv(); + + // te errors: + this.te.files.forEach(printErrorsForFileIfFound); + this.out.printBoldDiv(); + } + + constructor(public dtPath: string) { + this.fh = new FileHandler(dtPath, /.\.ts/g); + this.out = new Print('0.9.1.1', this.fh.allTypings().length, this.fh.allTS().length); + this.sc = new SyntaxChecking(this.fh, this.out); + this.te = new TestEval(this.fh, this.out); + + var tpgs = this.fh.allTypings(); + for (var i = 0; i < tpgs.length; i++) { + this.typings.push(new Typing(tpgs[i], this.dtPath)); + } + } + + public run() { + var timer = new Timer(); + timer.start(); + + this.out.printHeader(); + + // Run syntax tests + this.out.printSyntaxCheckingHeader(); + this.sc.start((syntaxFailedCount, syntaxTotal) => { + + // Now run typing tests + this.out.printTypingTestsHeader(); + this.te.start((testFailedCount, testTotal) => { + + // Get the tests without any typing and simultaneously print their names + var totalTypingsWithoutTest = this.printTypingsWithoutTest(); + + // End total timer and print final messages + timer.end(); + + this.out.printDiv(); + this.out.printTotalMessage(); + this.out.printDiv(); + + this.out.printElapsedTime(timer.asString, timer.time); + this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal); + this.out.printTestErrorCount(testFailedCount, testTotal); + this.out.printWithoutTestCount(totalTypingsWithoutTest, this.fh.allTypings().length); + + this.out.printDiv(); + + if (syntaxFailedCount > 0 || testFailedCount > 0) { + this.printErrorsDetected(); + process.exit(1); + } + }); + }); + } + } } -declare var __dirname: any; - var dtPath = __dirname + '/../..'; var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath); diff --git a/_infrastructure/tests/src/io.ts b/_infrastructure/tests/src/io.ts index 6fce75489..2c7a81f4f 100644 --- a/_infrastructure/tests/src/io.ts +++ b/_infrastructure/tests/src/io.ts @@ -83,22 +83,12 @@ declare class Enumerator { public item(): any; constructor (o: any); } -declare function setTimeout(callback: () =>void , ms?: number); -//declare var require: any; -declare module process { - export var argv: string[]; - export var platform: string; - export function on(event: string, handler: (any) => void ): void; - export module stdout { - export function write(str: string); + +// Missing in node definitions, but called in code below. +interface NodeProcess { + mainModule: { + filename: string; } - export module stderr { - export function write(str: string); - } - export module mainModule { - export var filename: string; - } - export function exit(exitCode?: number); } var IO = (function() { diff --git a/ace/ace.d.ts.tscparams b/ace/ace.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/ace.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/all-tests.ts.tscparams b/ace/all-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/all-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-anchor-tests.ts.tscparams b/ace/tests/ace-anchor-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-anchor-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-background_tokenizer-tests.ts.tscparams b/ace/tests/ace-background_tokenizer-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-background_tokenizer-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-default-tests.ts.tscparams b/ace/tests/ace-default-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-default-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-document-tests.ts.tscparams b/ace/tests/ace-document-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-document-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-edit_session-tests.ts.tscparams b/ace/tests/ace-edit_session-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-edit_session-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-editor1-tests.ts.tscparams b/ace/tests/ace-editor1-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-editor1-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams b/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-editor_navigation-tests.ts.tscparams b/ace/tests/ace-editor_navigation-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-editor_navigation-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-editor_text_edit-tests.ts.tscparams b/ace/tests/ace-editor_text_edit-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-editor_text_edit-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-multi_select-tests.ts.tscparams b/ace/tests/ace-multi_select-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-multi_select-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-placeholder-tests.ts.tscparams b/ace/tests/ace-placeholder-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-placeholder-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-range-tests.ts.tscparams b/ace/tests/ace-range-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-range-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-range_list-tests.ts.tscparams b/ace/tests/ace-range_list-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-range_list-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-search-tests.ts.tscparams b/ace/tests/ace-search-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-search-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-selection-tests.ts.tscparams b/ace/tests/ace-selection-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-selection-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-token_iterator-tests.ts.tscparams b/ace/tests/ace-token_iterator-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-token_iterator-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ace/tests/ace-virtual_renderer-tests.ts.tscparams b/ace/tests/ace-virtual_renderer-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ace/tests/ace-virtual_renderer-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/amcharts/AmCharts.d.ts.tscparams b/amcharts/AmCharts.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/amcharts/AmCharts.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/amplifyjs/amplifyjs-tests.ts.tscparams b/amplifyjs/amplifyjs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/amplifyjs/amplifyjs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/amplifyjs/amplifyjs.d.ts.tscparams b/amplifyjs/amplifyjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/amplifyjs/amplifyjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/README.md b/angularjs/README.md index 1692d947c..806a605d5 100644 --- a/angularjs/README.md +++ b/angularjs/README.md @@ -35,6 +35,7 @@ To avoid cluttering the list of suggestions as you type in your IDE, all interfa * `ng.cookies` for **ngCookies** * `ng.mock` for **ngMock** * `ng.resource` for **ngResource** +* `ng.route` for **ngRoute** * `ng.sanitize` for **ngSanitize** **ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces. diff --git a/angularjs/angular-1.0-tests.ts b/angularjs/angular-1.0-tests.ts new file mode 100644 index 000000000..ff3c87f77 --- /dev/null +++ b/angularjs/angular-1.0-tests.ts @@ -0,0 +1,219 @@ +/// + +// issue: https://github.com/borisyankov/DefinitelyTyped/issues/369 +https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2012 Witold Szczerba + * License: MIT + */ +angular.module('http-auth-interceptor', []) + + .provider('authService', function () { + /** + * Holds all the requests which failed due to 401 response, + * so they can be re-requested in future, once login is completed. + */ + var buffer = []; + + /** + * Required by HTTP interceptor. + * Function is attached to provider to be invisible for regular users of this service. + */ + this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) { + buffer.push({ + config: config, + deferred: deferred + }); + } + + this.$get = ['$rootScope', '$injector', function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { + var $http: ng.IHttpService; //initialized later because of circular dependency problem + function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { + $http = $http || $injector.get('$http'); + $http(config).then(function (response) { + deferred.resolve(response); + }); + } + function retryAll() { + for (var i = 0; i < buffer.length; ++i) { + retry(buffer[i].config, buffer[i].deferred); + } + buffer = []; + } + + return { + loginConfirmed: function () { + $rootScope.$broadcast('event:auth-loginConfirmed'); + retryAll(); + } + } + }] + }) + +/** + * $http interceptor. + * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. + */ + .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider) { + + var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { + function success(response: ng.IHttpPromiseCallbackArg) { + return response; + } + + function error(response: ng.IHttpPromiseCallbackArg) { + if (response.status === 401) { + var deferred = $q.defer(); + authServiceProvider.pushToBuffer(response.config, deferred); + $rootScope.$broadcast('event:auth-loginRequired'); + return deferred.promise; + } + // otherwise + return $q.reject(response); + } + + return function (promise: ng.IHttpPromise) { + return promise.then(success, error); + } + + }]; + $httpProvider.responseInterceptors.push(interceptor); + }]); + + +module HttpAndRegularPromiseTests { + interface Person { + firstName: string; + lastName: string; + } + + interface ExpectedResponse extends Person { } + + interface SomeControllerScope extends ng.IScope { + person: Person; + theAnswer: number; + letters: string[]; + } + + var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { + $http.get("http://somewhere/some/resource") + .success((data: ExpectedResponse) => { + $scope.person = data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would type check + $scope.person = response.data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would NOT type check + $scope.person = response.data; + }); + + var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" }); + aPromise.then((person: Person) => { + $scope.person = person; + }); + + var bPromise: ng.IPromise = $q.when(42); + bPromise.then((answer: number) => { + $scope.theAnswer = answer; + }); + + var cPromise: ng.IPromise = $q.when(["a", "b", "c"]); + cPromise.then((letters: string[]) => { + $scope.letters = letters; + }); + } + + // Test that we can pass around a type-checked success/error Promise Callback + var anotherController: Function = ($scope: SomeControllerScope, $http: + ng.IHttpService, $q: ng.IQService) => { + + var buildFooData: Function = () => 42; + + var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { + $http.get('/foo', buildFooData()) + .success(callback); + } + + doFoo((data) => console.log(data)); + } +} + +// Test for AngularJS Syntax + +module My.Namespace { + export var x; // need to export something for module to kick in +} + +// IModule Registering Test +var mod = angular.module('tests', []); +mod.controller('name', function ($scope: ng.IScope) { }) +mod.controller('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.controller(My.Namespace); +mod.directive('name', function ($scope: ng.IScope) { }) +mod.directive('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.directive(My.Namespace); +mod.factory('name', function ($scope: ng.IScope) { }) +mod.factory('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.factory(My.Namespace); +mod.filter('name', function ($scope: ng.IScope) { }) +mod.filter('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.filter(My.Namespace); +mod.provider('name', function ($scope: ng.IScope) { }) +mod.provider('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.provider(My.Namespace); +mod.service('name', function ($scope: ng.IScope) { }) +mod.service('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.service(My.Namespace); +mod.constant('name', 23); +mod.constant('name', "23"); +mod.constant(My.Namespace); +mod.value('name', 23); +mod.value('name', "23"); +mod.value(My.Namespace); + +// Promise signature tests +var foo: ng.IPromise; +foo.then((x) => { + // x is inferred to be a number + return "asdf"; +}).then((x) => { + // x is inferred to be string + x.length; + return 123; +}).then((x) => { + // x is infered to be a number + x.toFixed(); + return; +}).then((x) => { + // x is infered to be void + // Typescript will prevent you to actually use x as a local variable + // Try object: + return { a: 123 }; +}).then((x) => { + // Object is inferred here + x.a = 123; + //Try a promise + var y: ng.IPromise; + return y; +}).then((x) => { + // x is infered to be a number, which is the resolved value of a promise + x.toFixed(); +}); + + +// angular.element() tests +var element = angular.element("div.myApp"); +var scope: ng.IScope = element.scope(); + + diff --git a/angularjs/angular-1.0-tests.ts.tscparams b/angularjs/angular-1.0-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/angularjs/angular-1.0-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/angular-1.0.d.ts b/angularjs/angular-1.0.d.ts new file mode 100755 index 000000000..ecb7bd2c9 --- /dev/null +++ b/angularjs/angular-1.0.d.ts @@ -0,0 +1,760 @@ +// Type definitions for Angular JS 1.0 +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: ng.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject:string[]; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + // All service providers extend this interface + interface IServiceProvider { + $get(): any; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + bootstrap(element: string, modules?: any[]): auto.IInjectorService; + bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService; + bootstrap(element: Element, modules?: any[]): auto.IInjectorService; + bootstrap(element: Document, modules?: any[]): auto.IInjectorService; + copy(source: any, destination?: any): any; + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + fromJson(json: string): any; + identity(arg?: any): any; + injector(modules?: any[]): auto.IInjectorService; + isArray(value: any): boolean; + isDate(value: any): boolean; + isDefined(value: any): boolean; + isElement(value: any): boolean; + isFunction(value: any): boolean; + isNumber(value: any): boolean; + isObject(value: any): boolean; + isString(value: any): boolean; + isUndefined(value: any): boolean; + lowercase(str: string): string; + /** construct your angular application + official docs: Interface for configuring angular modules. + see: http://docs.angularjs.org/api/angular.Module + */ + module( + /** name of your module you want to create */ + name: string, + /** name of modules yours depends on */ + requires?: string[], + configFunction?: any): IModule; + noop(...args: any[]): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codename: string; + }; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotadedFunction: any[]): IModule; + animation(object: Object): IModule; + /** configure existing services. + Use this method to register work which needs to be performed on module loading + */ + config(configFn: Function): IModule; + /** configure existing services. + Use this method to register work which needs to be performed on module loading + */ + config(inlineAnnotadedFunction: any[]): IModule; + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + controller(name: string, controllerConstructor: Function): IModule; + controller(name: string, inlineAnnotadedConstructor: any[]): IModule; + controller(object : Object): IModule; + directive(name: string, directiveFactory: (...params:any[])=> IDirective): IModule; + directive(name: string, inlineAnnotadedFunction: any[]): IModule; + directive(object: Object): IModule; + factory(name: string, serviceFactoryFunction: Function): IModule; + factory(name: string, inlineAnnotadedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotadedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderConstructor: Function): IModule; + provider(name: string, inlineAnnotadedConstructor: any[]): IModule; + provider(object: Object): IModule; + run(initializationFunction: Function): IModule; + run(inlineAnnotadedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotadedConstructor: any[]): IModule; + service(object: Object): IModule; + value(name: string, value: any): IModule; + value(object: Object): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + $set(name: string, value: any): void; + $observe(name: string, fn:(value?:any)=>any):void; + $attr: any; + } + + /////////////////////////////////////////////////////////////////////////// + // FormController + // see http://docs.angularjs.org/api/ng.directive:form.FormController + /////////////////////////////////////////////////////////////////////////// + interface IFormController { + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $error: any; + $setDirty(): void; + $setPristine(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + $setViewValue(value: string): void; + + // XXX Not sure about the types here. Documentation states it's a string, but + // I've seen it receiving other types throughout the code. + // Falling back to any for now. + $viewValue: any; + + // XXX Same as avove + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $error: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // Scope + // see http://docs.angularjs.org/api/ng.$rootScope.Scope + /////////////////////////////////////////////////////////////////////////// + interface IScope { + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + $emit(name: string, ...args: any[]): IAngularEvent; + + // Documentation says exp is optional, but actual implementaton counts on it + $eval(expression: string): any; + $eval(expression: (scope: IScope) => any): any; + + // Documentation says exp is optional, but actual implementaton counts on it + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean): IScope; + + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + + $id: number; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IAngularEvent { + targetScope: IScope; + currentScope: IScope; + name: string; + preventDefault: Function; + defaultPrevented: boolean; + + // Available only events that were $emit-ted + stopPropagation?: Function; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window {} + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService {} + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (func: Function, delay?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // FilterService + // see http://docs.angularjs.org/api/ng.$filter + // see http://docs.angularjs.org/api/ng.$filterProvider + /////////////////////////////////////////////////////////////////////////// + interface IFilterService { + (name: string): Function; + } + + interface IFilterProvider extends IServiceProvider { + register(name: string, filterFactory: Function): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + // We define this as separete interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // LocationService + // see http://docs.angularjs.org/api/ng.$location + // see http://docs.angularjs.org/api/ng.$locationProvider + // see http://docs.angularjs.org/guide/dev_guide.services.$location + /////////////////////////////////////////////////////////////////////////// + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + path(): string; + path(newPath: string): ILocationService; + port(): number; + protocol(): string; + replace(): ILocationService; + search(): any; + search(parametersMap: any): ILocationService; + search(parameter: string, parameterValue: any): ILocationService; + url(): string; + url(url: string): ILocationService; + } + + interface ILocationProvider extends IServiceProvider { + hashPrefix(): string; + hashPrefix(prefix: string): ILocationProvider; + html5Mode(): boolean; + + // Documentation states that parameter is string, but + // implementation tests it as boolean, which makes more sense + // since this is a toggler + html5Mode(active: boolean): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends Document {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + /////////////////////////////////////////////////////////////////////////// + // QService + // see http://docs.angularjs.org/api/ng.$q + /////////////////////////////////////////////////////////////////////////// + interface IQService { + all(promises: IPromise[]): IPromise; + defer(): IDeferred; + reject(reason?: any): IPromise; + when(value: T): IPromise; + } + + interface IPromise { + then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any): IPromise; + then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any): IPromise; + then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult): IPromise; + } + + interface IDeferred { + resolve(value?: T): void; + reject(reason?: any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CacheFactoryService + // see http://docs.angularjs.org/api/ng.$cacheFactory + /////////////////////////////////////////////////////////////////////////// + interface ICacheFactoryService { + // Lets not foce the optionsMap to have the capacity member. Even though + // it's the ONLY option considered by the implementation today, a consumer + // might find it useful to associate some other options to the cache object. + //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject; + (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject; + + // Methods bellow are not documented + info(): any; + get (cacheId: string): ICacheObject; + } + + interface ICacheObject { + info(): { + id: string; + size: number; + + // Not garanteed to have, since it's a non-mandatory option + //capacity: number; + }; + put(key: string, value?: any): void; + get (key: string): any; + remove(key: string): void; + removeAll(): void; + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + } + + interface ITemplateLinkingFunction { + // Let's hint but not force cloneAttachFn's signature + (scope: IScope, cloneAttachFn?: (clonedElement?: JQuery, scope?: IScope) => any): JQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: Function, locals?: any): any; + (controllerName: string, locals?: any): any; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotadedConstructor: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpService + // see http://docs.angularjs.org/api/ng.$http + /////////////////////////////////////////////////////////////////////////// + interface IHttpService { + // At least moethod and url must be provided... + (config: IRequestConfig): IHttpPromise; + get (url: string, RequestConfig?: any): IHttpPromise; + delete (url: string, RequestConfig?: any): IHttpPromise; + head(url: string, RequestConfig?: any): IHttpPromise; + jsonp(url: string, RequestConfig?: any): IHttpPromise; + post(url: string, data: any, RequestConfig?: any): IHttpPromise; + put(url: string, data: any, RequestConfig?: any): IHttpPromise; + defaults: IRequestConfig; + + // For debugging, BUT it is documented as public, so... + pendingRequests: any[]; + } + + // This is just for hinting. + // Some opetions might not be available depending on the request. + // see http://docs.angularjs.org/api/ng.$http#Usage for options explanations + interface IRequestConfig { + method: string; + url: string; + params?: any; + + // XXX it has it's own structure... perhaps we should define it in the future + headers?: any; + + cache?: any; + timeout?: number; + withCredentials?: boolean; + + // These accept multiple types, so let's defile them as any + data?: any; + transformRequest?: any; + transformResponse?: any; + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: (headerName: string) => string; + config?: IRequestConfig; + } + + interface IHttpPromise extends IPromise { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + } + + interface IHttpProvider extends IServiceProvider { + defaults: IRequestConfig; + interceptors: any[]; + responseInterceptors: any[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ng.$httpBackend + // You should never need to use this service directly. + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + // XXX Perhaps define callback signature in the future + (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // InterpolateService + // see http://docs.angularjs.org/api/ng.$interpolate + // see http://docs.angularjs.org/api/ng.$interpolateProvider + /////////////////////////////////////////////////////////////////////////// + interface IInterpolateService { + (text: string, mustHaveExpression?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see http://docs.angularjs.org/api/ng.$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService {} + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // RootScopeService + // see http://docs.angularjs.org/api/ng.$rootScope + /////////////////////////////////////////////////////////////////////////// + interface IRootScopeService extends IScope {} + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see http://docs.angularjs.org/api/ng.$route + // see http://docs.angularjs.org/api/ng.$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + reload(): void; + routes: any; + + // May not always be available. For instance, current will not be available + // to a controller that was not initialized as a result of a route maching. + current?: ICurrentRoute; + } + + // see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations + interface IRoute { + controller?: any; + name?: string; + template?: string; + templateUrl?: any; + resolve?: any; + redirectTo?: any; + reloadOnSearch?: boolean; + } + + // see http://docs.angularjs.org/api/ng.$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + otherwise(params: any): IRouteProvider; + when(path: string, route: IRoute): IRouteProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirective{ + priority?: number; + template?: any; + templateUrl?: any; + replace?: boolean; + transclude?: any; + restrict?: string; + scope?: any; + link?: Function; + compile?: Function; + controller?: any; + } + + /////////////////////////////////////////////////////////////////////////// + // angular.element + // when calling angular.element, angular returns a jQuery object, + // augmented with additional methods like e.g. scope. + // see: http://docs.angularjs.org/api/angular.element + /////////////////////////////////////////////////////////////////////////// + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + + controller(name: string): any; + injector(): any; + scope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + + + } + + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotadedFunction: any[]): string[]; + get (name: string): any; + instantiate(typeConstructor: Function, locals?: any): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + constant(name: string, value: any): void; + + decorator(name: string, decorator: Function): void; + decorator(name: string, decoratorInline: any[]): void; + factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; + provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; + service(name: string, constructor: Function): ng.IServiceProvider; + value(name: string, value: any): ng.IServiceProvider; + } + + } + +} diff --git a/angularjs/angular-cookies-1.0.d.ts b/angularjs/angular-cookies-1.0.d.ts new file mode 100644 index 000000000..4dc2e038e --- /dev/null +++ b/angularjs/angular-cookies-1.0.d.ts @@ -0,0 +1,30 @@ +/// Type definitions for Angular JS 1.0 (ngCookies module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngCookies module (angular-cookies.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.cookies { + + /////////////////////////////////////////////////////////////////////////// + // CookieService + // see http://docs.angularjs.org/api/ngCookies.$cookies + /////////////////////////////////////////////////////////////////////////// + interface ICookiesService {} + + /////////////////////////////////////////////////////////////////////////// + // CookieStoreService + // see http://docs.angularjs.org/api/ngCookies.$cookieStore + /////////////////////////////////////////////////////////////////////////// + interface ICookieStoreService { + get(key: string): any; + put(key: string, value: any): void; + remove(key: string): void; + } + +} diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts index 4dc2e038e..60eebbacb 100644 --- a/angularjs/angular-cookies.d.ts +++ b/angularjs/angular-cookies.d.ts @@ -1,4 +1,4 @@ -/// Type definitions for Angular JS 1.0 (ngCookies module) +/// Type definitions for Angular JS 1.2 (ngCookies module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-mocks-1.0.d.ts b/angularjs/angular-mocks-1.0.d.ts new file mode 100644 index 000000000..4d8decbf8 --- /dev/null +++ b/angularjs/angular-mocks-1.0.d.ts @@ -0,0 +1,150 @@ +// Type definitions for Angular JS 1.0 (ngMock, ngMockE2E module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// functions attached to global object (window) +/////////////////////////////////////////////////////////////////////////////// +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see http://docs.angularjs.org/api/angular.mock.debug + debug(obj: any): string; + + // see http://docs.angularjs.org/api/angular.mock.inject + inject(...fns: Function[]): any; + + // see http://docs.angularjs.org/api/angular.mock.module + module(...modules: any[]): any; + + // see http://docs.angularjs.org/api/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ngMock.$exceptionHandler + // see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ngMock.$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ngMock.$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface LogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ngMock.$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: any, headers?: any): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + expect(method: RegExp, url: string, data?: any, headers?: any): mock.IRequestHandler; + expect(method: RegExp, url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: any): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: string, data?: string, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + + expectDELETE(url: string, headers?: any): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: any): mock.IRequestHandler; + expectGET(url: string, headers?: any): mock.IRequestHandler; + expectGET(url: RegExp, headers?: any): mock.IRequestHandler; + expectHEAD(url: string, headers?: any): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: any): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + expectPATCH(url: string, data?: any, headers?: any): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + expectPOST(url: string, data?: any, headers?: any): mock.IRequestHandler; + expectPOST(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + expectPUT(url: string, data?: any, headers?: any): mock.IRequestHandler; + expectPUT(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + + whenDELETE(url: string, headers?: any): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: any): mock.IRequestHandler; + whenGET(url: string, headers?: any): mock.IRequestHandler; + whenGET(url: RegExp, headers?: any): mock.IRequestHandler; + whenHEAD(url: string, headers?: any): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: any): mock.IRequestHandler; + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + whenPATCH(url: string, data?: string, headers?: any): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPOST(url: string, data?: string, headers?: any): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPUT(url: string, data?: string, headers?: any): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts new file mode 100644 index 000000000..b43580f36 --- /dev/null +++ b/angularjs/angular-mocks-tests.ts @@ -0,0 +1,288 @@ +/// + +/////////////////////////////////////// +// IAngularStatic +/////////////////////////////////////// +var angular: ng.IAngularStatic; +var mock: ng.IMockStatic; + +mock = angular.mock; + + +/////////////////////////////////////// +// IMockStatic +/////////////////////////////////////// +var date: Date; + +mock.dump({ key: 'value' }); + +mock.inject( + function () { return 1; }, + function () { return 2; } + ); + +mock.module('module1', 'module2'); +mock.module( + function () { return 1; }, + function () { return 2; } + ); +mock.module({ module1: function () { return 1; } }); + +date = mock.TzDate(-7, '2013-1-1T15:00:00Z'); +date = mock.TzDate(-8, 12345678); + + +/////////////////////////////////////// +// IExceptionHandlerProvider +/////////////////////////////////////// +var exceptionHandlerProvider: ng.IExceptionHandlerProvider; + +exceptionHandlerProvider.mode('log'); + + +/////////////////////////////////////// +// IExceptionHandlerProvider +/////////////////////////////////////// +var timeoutService: ng.ITimeoutService; + +timeoutService.flush(); +timeoutService.flush(1234); +timeoutService.flushNext(); +timeoutService.flushNext(1234); +timeoutService.verifyNoPendingTasks(); + + +/////////////////////////////////////// +// ILogService, ILogCall +/////////////////////////////////////// +var logService: ng.ILogService; +var logCall: ng.ILogCall; +var logs: string[]; + +logService.assertEmpty(); +logService.reset(); + +logCall = logService.debug; +logCall = logService.error; +logCall = logService.info; +logCall = logService.log; +logCall = logService.warn; + +logs = logCall.logs; + + +/////////////////////////////////////// +// IHttpBackendService +/////////////////////////////////////// +var httpBackendService: ng.IHttpBackendService; +var requestHandler: ng.mock.IRequestHandler; + +httpBackendService.flush(); +httpBackendService.flush(1234); +httpBackendService.resetExpectations(); +httpBackendService.verifyNoOutstandingExpectation(); +httpBackendService.verifyNoOutstandingRequest(); + +requestHandler = httpBackendService.expect('GET', 'http://test.local'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.expectDELETE('http://test.local'); +requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectGET('http://test.local'); +requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectHEAD('http://test.local'); +requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectJSONP('http://test.local'); +requestHandler = httpBackendService.expectJSONP(/test.local/); + +requestHandler = httpBackendService.expectPATCH('http://test.local'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPOST('http://test.local'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPUT('http://test.local'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.when('GET', 'http://test.local'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.whenDELETE('http://test.local'); +requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenGET('http://test.local'); +requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenHEAD('http://test.local'); +requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenJSONP('http://test.local'); +requestHandler = httpBackendService.whenJSONP(/test.local/); + +requestHandler = httpBackendService.whenPATCH('http://test.local'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPOST('http://test.local'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPUT('http://test.local'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' }); + + +/////////////////////////////////////// +// IRequestHandler +/////////////////////////////////////// +requestHandler.passThrough(); +requestHandler.respond(function () { }); +requestHandler.respond({ key: 'value' }); +requestHandler.respond({ key: 'value' }, { header: 'value' }); +requestHandler.respond(404); +requestHandler.respond(404, { key: 'value' }); +requestHandler.respond(404, { key: 'value' }, { header: 'value' }); diff --git a/angularjs/angular-mocks-tests.ts.tscparams b/angularjs/angular-mocks-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/angularjs/angular-mocks-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts index 4d8decbf8..a607422dd 100644 --- a/angularjs/angular-mocks.d.ts +++ b/angularjs/angular-mocks.d.ts @@ -1,9 +1,8 @@ -// Type definitions for Angular JS 1.0 (ngMock, ngMockE2E module) +// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped - /// /////////////////////////////////////////////////////////////////////////////// @@ -26,14 +25,16 @@ declare module ng { } interface IMockStatic { - // see http://docs.angularjs.org/api/angular.mock.debug - debug(obj: any): string; - + // see http://docs.angularjs.org/api/angular.mock.dump + dump(obj: any): string; + // see http://docs.angularjs.org/api/angular.mock.inject inject(...fns: Function[]): any; - + // see http://docs.angularjs.org/api/angular.mock.module - module(...modules: any[]): any; + module(...modules: string[]): any; + module(...modules: Function[]): any; + module(modules: Object): any; // see http://docs.angularjs.org/api/angular.mock.TzDate TzDate(offset: number, timestamp: number): Date; @@ -55,7 +56,9 @@ declare module ng { // Augments the original service /////////////////////////////////////////////////////////////////////////// interface ITimeoutService { - flush(): void; + flush(delay?: number): void; + flushNext(expectedDelay?: number): void; + verifyNoPendingTasks(): void; } /////////////////////////////////////////////////////////////////////////// @@ -68,7 +71,7 @@ declare module ng { reset(): void; } - interface LogCall { + interface ILogCall { logs: string[]; } @@ -82,62 +85,127 @@ declare module ng { verifyNoOutstandingExpectation(): void; verifyNoOutstandingRequest(): void; - expect(method: string, url: string, data?: any, headers?: any): mock.IRequestHandler; - expect(method: string, url: RegExp, data?: any, headers?: any): mock.IRequestHandler; - expect(method: RegExp, url: string, data?: any, headers?: any): mock.IRequestHandler; - expect(method: RegExp, url: RegExp, data?: any, headers?: any): mock.IRequestHandler; - - when(method: string, url: string, data?: string, headers?: any): mock.IRequestHandler; - when(method: string, url: RegExp, data?: string, headers?: any): mock.IRequestHandler; - when(method: string, url: string, data?: RegExp, headers?: any): mock.IRequestHandler; - when(method: string, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; - when(method: RegExp, url: string, data?: string, headers?: any): mock.IRequestHandler; - when(method: RegExp, url: RegExp, data?: string, headers?: any): mock.IRequestHandler; - when(method: RegExp, url: string, data?: RegExp, headers?: any): mock.IRequestHandler; - when(method: RegExp, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; - - expectDELETE(url: string, headers?: any): mock.IRequestHandler; - expectDELETE(url: RegExp, headers?: any): mock.IRequestHandler; - expectGET(url: string, headers?: any): mock.IRequestHandler; - expectGET(url: RegExp, headers?: any): mock.IRequestHandler; - expectHEAD(url: string, headers?: any): mock.IRequestHandler; - expectHEAD(url: RegExp, headers?: any): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + expectDELETE(url: string, headers?: Object): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + expectGET(url: string, headers?: Object): mock.IRequestHandler; + expectGET(url: RegExp, headers?: Object): mock.IRequestHandler; + expectHEAD(url: string, headers?: Object): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; expectJSONP(url: string): mock.IRequestHandler; expectJSONP(url: RegExp): mock.IRequestHandler; - expectPATCH(url: string, data?: any, headers?: any): mock.IRequestHandler; - expectPATCH(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; - expectPOST(url: string, data?: any, headers?: any): mock.IRequestHandler; - expectPOST(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; - expectPUT(url: string, data?: any, headers?: any): mock.IRequestHandler; - expectPUT(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; - whenDELETE(url: string, headers?: any): mock.IRequestHandler; - whenDELETE(url: RegExp, headers?: any): mock.IRequestHandler; - whenGET(url: string, headers?: any): mock.IRequestHandler; - whenGET(url: RegExp, headers?: any): mock.IRequestHandler; - whenHEAD(url: string, headers?: any): mock.IRequestHandler; - whenHEAD(url: RegExp, headers?: any): mock.IRequestHandler; + expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenDELETE(url: string, headers?: Object): mock.IRequestHandler; + whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenGET(url: string, headers?: Object): mock.IRequestHandler; + whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenGET(url: RegExp, headers?: Object): mock.IRequestHandler; + whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenHEAD(url: string, headers?: Object): mock.IRequestHandler; + whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenJSONP(url: string): mock.IRequestHandler; whenJSONP(url: RegExp): mock.IRequestHandler; - whenPATCH(url: string, data?: string, headers?: any): mock.IRequestHandler; - whenPATCH(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; - whenPATCH(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; - whenPATCH(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; - whenPOST(url: string, data?: string, headers?: any): mock.IRequestHandler; - whenPOST(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; - whenPOST(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; - whenPOST(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; - whenPUT(url: string, data?: string, headers?: any): mock.IRequestHandler; - whenPUT(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; - whenPUT(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; - whenPUT(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; - } + + whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + } export module mock { - + // returned interface by the the mocked HttpBackendService expect/when methods interface IRequestHandler { - respond(func: Function): void; + respond(func: Function): void; respond(status: number, data?: any, headers?: any): void; respond(data: any, headers?: any): void; @@ -145,6 +213,6 @@ declare module ng { passThrough(): void; } - } + } } diff --git a/angularjs/angular-mocks.d.ts.tscparams b/angularjs/angular-mocks.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/angularjs/angular-mocks.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/angular-resource-1.0.d.ts b/angularjs/angular-resource-1.0.d.ts new file mode 100644 index 000000000..c66bb341d --- /dev/null +++ b/angularjs/angular-resource-1.0.d.ts @@ -0,0 +1,82 @@ +// Type definitions for Angular JS 1.0 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.resource { + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see http://docs.angularjs.org/api/ngResource.$resource + // Most part of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + isArray?: boolean; + params?: any; + headers?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + interface IResourceClass { + get: IActionCall; + save: IActionCall; + query: IActionCall; + remove: IActionCall; + delete: IActionCall; + } + + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // PATCH (in other words, methods with body). Otherwise, it's going + // to be considered as parameters to the request. + interface IActionCall { + (): IResource; + (dataOrParams: any): IResource; + (dataOrParams: any, success: Function): IResource; + (success: Function, error?: Function): IResource; + (params: any, data: any, success?: Function, error?: Function): IResource; + } + + interface IResource { + $save: IActionCall; + $remove: IActionCall; + $delete: IActionCall; + + // No documented, but they are there, just as any custom action will be + $query: IActionCall; + $get: IActionCall; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: ng.resource.IResourceService): ng.resource.IResourceClass; + } +} + +/** extensions to base ng based on using angular-resource */ +declare module ng { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + } +} diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts new file mode 100644 index 000000000..c2378350d --- /dev/null +++ b/angularjs/angular-resource-tests.ts @@ -0,0 +1,74 @@ +/// + +/////////////////////////////////////// +// IActionDescriptor +/////////////////////////////////////// +var actionDescriptor: ng.resource.IActionDescriptor; + +actionDescriptor.headers = { header: 'value' }; +actionDescriptor.isArray = true; +actionDescriptor.method = 'method action'; +actionDescriptor.params = { key: 'value' }; + + +/////////////////////////////////////// +// IResourceClass +/////////////////////////////////////// +var resourceClass: ng.resource.IResourceClass; +var resource: ng.resource.IResource; + +resource = resourceClass.delete(); +resource = resourceClass.delete({ key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, function () { }); +resource = resourceClass.delete(function () { }); +resource = resourceClass.delete(function () { }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.get(); +resource = resourceClass.get({ key: 'value' }); +resource = resourceClass.get({ key: 'value' }, function () { }); +resource = resourceClass.get(function () { }); +resource = resourceClass.get(function () { }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.query(); +resource = resourceClass.query({ key: 'value' }); +resource = resourceClass.query({ key: 'value' }, function () { }); +resource = resourceClass.query(function () { }); +resource = resourceClass.query(function () { }, function () { }); +resource = resourceClass.query({ key: 'value' }, { key: 'value' }); +resource = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.remove(); +resource = resourceClass.remove({ key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, function () { }); +resource = resourceClass.remove(function () { }); +resource = resourceClass.remove(function () { }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.save(); +resource = resourceClass.save({ key: 'value' }); +resource = resourceClass.save({ key: 'value' }, function () { }); +resource = resourceClass.save(function () { }); +resource = resourceClass.save(function () { }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + + +/////////////////////////////////////// +// IModule +/////////////////////////////////////// +var mod: ng.IModule; +var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction; +var resourceService: ng.resource.IResourceService; + +resourceServiceFactoryFunction = function (resourceService) { return resourceClass }; +mod = mod.factory('factory name', resourceServiceFactoryFunction); diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index c66bb341d..c15a933f8 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.0 (ngResource module) +// Type definitions for Angular JS 1.2 (ngResource module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -19,10 +19,10 @@ declare module ng.resource { // that deeply. /////////////////////////////////////////////////////////////////////////// interface IResourceService { - (url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): IResourceClass; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; } // Just a reference to facilitate describing new actions diff --git a/angularjs/angular-route-tests.ts b/angularjs/angular-route-tests.ts new file mode 100644 index 000000000..2ebe16a21 --- /dev/null +++ b/angularjs/angular-route-tests.ts @@ -0,0 +1,14 @@ +/// + +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2013 Jonathan Park @ Daptiv Solutions Inc + * License: MIT + */ + +declare var $routeProvider: ng.route.IRouteProvider; +$routeProvider + .when('/projects/:projectId/dashboard',{ + controller: '' + }) + .otherwise({redirectTo: '/'}); diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts new file mode 100644 index 000000000..b8d1db50b --- /dev/null +++ b/angularjs/angular-route.d.ts @@ -0,0 +1,64 @@ +// Type definitions for Angular JS 1.2 (ngRoute module) +// Project: http://angularjs.org +// Definitions by: Jonathan Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngRoute module (angular-route.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.route { + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see http://docs.angularjs.org/api/ngRoute.$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService {} + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see http://docs.angularjs.org/api/ngRoute.$route + // see http://docs.angularjs.org/api/ngRoute.$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + reload(): void; + routes: any; + + // May not always be available. For instance, current will not be available + // to a controller that was not initialized as a result of a route maching. + current?: ICurrentRoute; + } + + // see http://docs.angularjs.org/api/ngRoute.$routeProvider#when for options explanations + interface IRoute { + controller?: any; + controllerAs?: any; + name?: string; + template?: string; + templateUrl?: any; + resolve?: any; + redirectTo?: any; + reloadOnSearch?: boolean; + } + + // see http://docs.angularjs.org/api/ng.$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + otherwise(params: any): IRouteProvider; + /** + * This is a description + * + */ + when(path: string, route: IRoute): IRouteProvider; + } +} diff --git a/angularjs/angular-sanitize-1.0.d.ts b/angularjs/angular-sanitize-1.0.d.ts new file mode 100644 index 000000000..56a3bc2ae --- /dev/null +++ b/angularjs/angular-sanitize-1.0.d.ts @@ -0,0 +1,22 @@ +// Type definitions for Angular JS 1.0 (ngSanitize module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngSanitize module (angular-sanitize.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.sanitize { + + /////////////////////////////////////////////////////////////////////////// + // SanitizeService + // see http://docs.angularjs.org/api/ngSanitize.$sanitize + /////////////////////////////////////////////////////////////////////////// + interface ISanitizeService { + (html: string): string; + } + +} diff --git a/angularjs/angular-sanitize.d.ts b/angularjs/angular-sanitize.d.ts index 56a3bc2ae..43576ae3b 100644 --- a/angularjs/angular-sanitize.d.ts +++ b/angularjs/angular-sanitize.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular JS 1.0 (ngSanitize module) +// Type definitions for Angular JS 1.2 (ngSanitize module) // Project: http://angularjs.org // Definitions by: Diego Vilar // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/angularjs/angular-scenario-1.0.d.ts b/angularjs/angular-scenario-1.0.d.ts new file mode 100644 index 000000000..8dd605f7d --- /dev/null +++ b/angularjs/angular-scenario-1.0.d.ts @@ -0,0 +1,155 @@ +// Type definitions for Angular Scenario Testing +// Project: [http://angularjs.org] +// Definitions by: [RomanoLindano] +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module angularScenario { + export interface AngularModel { + scenario: any; + } + + export interface RunFunction { + (functionToRun: any): any; + } + export interface RunFunctionWithDescription { + (description: string, functionToRun: any): any; + } + + export interface PauseFunction { + (): any; + } + + export interface SleepFunction { + (seconds: number): any; + } + + export interface Future { + } + + export interface testWindow { + href(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface testLocation { + url(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface Browser { + navigateTo(url: string): void; + navigateTo(urlDescription: string, urlFunction: () => string): void; + reload(): void; + window(): testWindow; + location(): testLocation; + } + + export interface Matchers { + toEqual(value: any): void; + toBe(value: any): void; + toBeDefined(): void; + toBeTruthy(): void; + toBeFalsy(): void; + toMatch(regularExpression: any): void; + toBeNull(): void; + toContain(value: any): void; + toBeLessThan(value: any): void; + toBeGreaterThan(value: any): void; + } + + export interface CustomMatchers extends Matchers{ + } + + export interface Expect extends CustomMatchers { + not(): angularScenario.CustomMatchers; + } + + export interface UsingFunction { + (selector: string, selectorDescription?: string): void; + } + + export interface BindingFunction { + (bracketBindingExpression: string): Future; + } + + export interface Input { + enter(value: any); + check(): any; + select(radioButtonValue: any): any; + val(): Future; + } + + export interface Repeater { + count(): Future; + row(index: number): Future; + column(ngBindingExpression: string): Future; + } + + export interface Select { + option(value: any): any; + option(...listOfValues: any[]): any; + } + + export interface Element { + count(): Future; + click(): any; + query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) =>any): any; + val(): Future; + text(): Future; + html(): Future; + height(): Future; + innerHeight(): Future; + outerHeight(): Future; + width(): Future; + innerWidth(): Future; + outerWidth(): Future; + position(): Future; + scrollLeft(): Future; + scrollTop(): Future; + offset(): Future; + + val(value: any): void; + text(value: any): void; + html(value: any): void; + height(value: any): void; + innerHeight(value: any): void; + outerHeight(value: any): void; + width(value: any): void; + innerWidth(value: any): void; + outerWidth(value: any): void; + position(value: any): void; + scrollLeft(value: any): void; + scrollTop(value: any): void; + offset(value: any): void; + + attr(key: any): Future; + prop(key: any): Future; + css(key: any): Future; + + attr(key: any, value: any): void; + prop(key: any, value: any): void; + css(key: any, value: any): void; + } +} + +declare var describe: angularScenario.RunFunctionWithDescription; +declare var xdescribe: angularScenario.RunFunctionWithDescription; +declare var beforeEach: angularScenario.RunFunction; +declare var afterEach: angularScenario.RunFunction; +declare var it: angularScenario.RunFunctionWithDescription; +declare var xit: angularScenario.RunFunctionWithDescription; +declare var pause: angularScenario.PauseFunction; +declare var sleep: angularScenario.SleepFunction; +declare function browser(): angularScenario.Browser; +declare function expect(expectation: angularScenario.Future): angularScenario.Expect; +declare var using: angularScenario.UsingFunction; +declare var binding: angularScenario.BindingFunction; +declare function input(ngModelBinding: string): angularScenario.Input; +declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater; +declare function select(ngModelBinding: string): angularScenario.Select; +declare function element(selector: string, elementDescription?: string): angularScenario.Element; +declare var angular: angularScenario.AngularModel; diff --git a/angularjs/angular-scenario-1.0.d.ts.tscparams b/angularjs/angular-scenario-1.0.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/angularjs/angular-scenario-1.0.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/angular-scenario.d.ts.tscparams b/angularjs/angular-scenario.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/angularjs/angular-scenario.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 6a6892f57..bcfe31d16 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -182,6 +182,7 @@ mod.value('name', 23); mod.value('name', "23"); mod.value(My.Namespace); + // Promise signature tests var foo: ng.IPromise; foo.then((x) => { @@ -217,3 +218,17 @@ var element = angular.element("div.myApp"); var scope: ng.IScope = element.scope(); + +function test_IAttributes(attributes: ng.IAttributes){ + return attributes; +} + +test_IAttributes({ + $addClass: function (classVal){}, + $removeClass: function(classVal){}, + $set: function(key, value){}, + $observe: function(name, fn){ + return fn; + }, + $attr: {} +}); diff --git a/angularjs/angular-tests.ts.tscparams b/angularjs/angular-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/angularjs/angular-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 1a93d41f7..921cbafc9 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -81,11 +81,11 @@ declare module ng { animation(name: string, animationFactory: Function): IModule; animation(name: string, inlineAnnotadedFunction: any[]): IModule; animation(object: Object): IModule; - /** configure existing services. + /** configure existing services. Use this method to register work which needs to be performed on module loading */ config(configFn: Function): IModule; - /** configure existing services. + /** configure existing services. Use this method to register work which needs to be performed on module loading */ config(inlineAnnotadedFunction: any[]): IModule; @@ -94,9 +94,9 @@ declare module ng { controller(name: string, controllerConstructor: Function): IModule; controller(name: string, inlineAnnotadedConstructor: any[]): IModule; controller(object : Object): IModule; - directive(name: string, directiveFactory: (...params:any[])=> IDirective): IModule; + directive(name: string, directiveFactory: Function): IModule; directive(name: string, inlineAnnotadedFunction: any[]): IModule; - directive(object: Object): IModule; + directive(object: Object): IModule; factory(name: string, serviceFactoryFunction: Function): IModule; factory(name: string, inlineAnnotadedFunction: any[]): IModule; factory(object: Object): IModule; @@ -124,9 +124,33 @@ declare module ng { // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes /////////////////////////////////////////////////////////////////////////// interface IAttributes { - $set(name: string, value: any): void; - $observe(name: string, fn:(value?:any)=>any):void; - $attr: any; + // this is necessary to be able to access the scoped attributes. it's not very elegant + // because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way + // this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 + [name: string]: any; + + // Adds the CSS class value specified by the classVal parameter to the + // element. If animations are enabled then an animation will be triggered + // for the class addition. + $addClass(classVal: string): void; + + // Removes the CSS class value specified by the classVal parameter from the + // element. If animations are enabled then an animation will be triggered for + // the class removal. + $removeClass(classVal: string): void; + + // Set DOM element attribute value. + $set(key: string, value: any): void; + + // Observes an interpolated attribute. + // The observer function will be invoked once during the next $digest + // following compilation. The observer is then invoked whenever the + // interpolated value changes. + $observe(name: string, fn:(value?:any)=>any): Function; + + // A map of DOM element attribute names to the normalized name. This is needed + // to do reverse lookup from normalized name back to actual name. + $attr: Object; } /////////////////////////////////////////////////////////////////////////// @@ -139,6 +163,8 @@ declare module ng { $valid: boolean; $invalid: boolean; $error: any; + $addControl(control: ng.INgModelController): void; + $removeControl(control: ng.INgModelController): void; $setDirty(): void; $setPristine(): void; } @@ -150,14 +176,11 @@ declare module ng { interface INgModelController { $render(): void; $setValidity(validationErrorKey: string, isValid: boolean): void; - $setViewValue(value: string): void; - - // XXX Not sure about the types here. Documentation states it's a string, but - // I've seen it receiving other types throughout the code. - // Falling back to any for now. + // Documentation states viewValue and modelValue to be a string but other + // types do work and it's common to use them. + $setViewValue(value: any): void; $viewValue: any; - // XXX Same as avove $modelValue: any; $parsers: IModelParser[]; @@ -192,8 +215,8 @@ declare module ng { $emit(name: string, ...args: any[]): IAngularEvent; // Documentation says exp is optional, but actual implementaton counts on it - $eval(expression: string): any; - $eval(expression: (scope: IScope) => any): any; + $eval(expression: string, args?: Object): any; + $eval(expression: (scope: IScope) => any, args?: Object): any; // Documentation says exp is optional, but actual implementaton counts on it $evalAsync(expression: string): void; @@ -215,7 +238,7 @@ declare module ng { $parent: IScope; $id: number; - + // Hidden members $$isolateBindings: any; $$phase: any; @@ -253,6 +276,15 @@ declare module ng { cancel(promise: IPromise): boolean; } + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ng.$interval + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + /////////////////////////////////////////////////////////////////////////// // FilterService // see http://docs.angularjs.org/api/ng.$filter @@ -605,12 +637,6 @@ declare module ng { endSymbol(value: string): IInterpolateProvider; } - /////////////////////////////////////////////////////////////////////////// - // RouteParamsService - // see http://docs.angularjs.org/api/ng.$routeParams - /////////////////////////////////////////////////////////////////////////// - interface IRouteParamsService {} - /////////////////////////////////////////////////////////////////////////// // TemplateCacheService // see http://docs.angularjs.org/api/ng.$templateCache @@ -624,45 +650,58 @@ declare module ng { interface IRootScopeService extends IScope {} /////////////////////////////////////////////////////////////////////////// - // RouteService - // see http://docs.angularjs.org/api/ng.$route - // see http://docs.angularjs.org/api/ng.$routeProvider + // SCEService + // see http://docs.angularjs.org/api/ng.$sce /////////////////////////////////////////////////////////////////////////// - interface IRouteService { - reload(): void; - routes: any; + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + getTrustedCss(value: any): any; + getTrustedHtml(value: any): any; + getTrustedJs(value: any): any; + getTrustedResourceUrl(value: any): any; + getTrustedUrl(value: any): any; + parse(type: string, expression: string): (context: any, locals: any) => any; + parseAsCss(expression: string): (context: any, locals: any) => any; + parseAsHtml(expression: string): (context: any, locals: any) => any; + parseAsJs(expression: string): (context: any, locals: any) => any; + parseAsResourceUrl(expression: string): (context: any, locals: any) => any; + parseAsUrl(expression: string): (context: any, locals: any) => any; + trustAs(type: string, value: any): any; + trustAsHtml(value: any): any; + trustAsJs(value: any): any; + trustAsResourceUrl(value: any): any; + trustAsUrl(value: any): any; + isEnabled(): boolean; + } - // May not always be available. For instance, current will not be available - // to a controller that was not initialized as a result of a route maching. - current?: ICurrentRoute; + /////////////////////////////////////////////////////////////////////////// + // SCEProvider + // see http://docs.angularjs.org/api/ng.$sceProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEProvider extends IServiceProvider { + enabled(value: boolean): void; } - // see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations - interface IRoute { - controller?: any; - name?: string; - template?: string; - templateUrl?: any; - resolve?: any; - redirectTo?: any; - reloadOnSearch?: boolean; + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateService + // see http://docs.angularjs.org/api/ng.$sceDelegate + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateService { + getTrusted(type: string, mayBeTrusted: any): any; + trustAs(type: string, value: any): any; + valueOf(value: any): any; } - // see http://docs.angularjs.org/api/ng.$route#current - interface ICurrentRoute extends IRoute { - locals: { - $scope: IScope; - $template: string; - }; - - params: any; + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateProvider + // see http://docs.angularjs.org/api/ng.$sceDelegateProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateProvider extends IServiceProvider { + resourceUrlBlacklist(blacklist: any[]): void; + resourceUrlWhitelist(whitelist: any[]): void; } - - interface IRouteProvider extends IServiceProvider { - otherwise(params: any): IRouteProvider; - when(path: string, route: IRoute): IRouteProvider; - } - + /////////////////////////////////////////////////////////////////////////// // Directive // see http://docs.angularjs.org/api/ng.$compileProvider#directive @@ -670,16 +709,29 @@ declare module ng { /////////////////////////////////////////////////////////////////////////// interface IDirective{ + compile?: + (templateElement: any, + templateAttributes: IAttributes, + transclude: (scope: IScope, cloneLinkingFn: Function) => void + ) => any; + controller?: any; + controllerAs?: string; + link?: + (scope: IScope, + instanceElement: any, + instanceAttributes: IAttributes, + controller: any + ) => void; + name?: string; priority?: number; - template?: string; - templateUrl?: string; replace?: boolean; - transclude?: any; + require?: any; restrict?: string; scope?: any; - link?: Function; - compile?: Function; - controller?: Function; + template?: any; + templateUrl?: any; + terminal?: boolean; + transclude?: any; } /////////////////////////////////////////////////////////////////////////// diff --git a/arbiter/Arbiter-tests.ts.tscparams b/arbiter/Arbiter-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/arbiter/Arbiter-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/arbiter/Arbiter.d.ts.tscparams b/arbiter/Arbiter.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/arbiter/Arbiter.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/async/async-tests.ts.tscparams b/async/async-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/async/async-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/async/async.d.ts b/async/async.d.ts index 5ba56e0db..12aa4123f 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -13,7 +13,7 @@ interface AsyncWorker { (task: T, callback: Function): void; } interface AsyncQueue { length(): number; concurrency: number; - push(task: T, callback: AsyncMultipleResultsCallback): void; + push(task: T, callback?: AsyncMultipleResultsCallback): void; saturated: AsyncMultipleResultsCallback; empty: AsyncMultipleResultsCallback; drain: AsyncMultipleResultsCallback; @@ -79,4 +79,4 @@ declare var async: Async; declare module "async" { export = async; -} \ No newline at end of file +} diff --git a/async/async.d.ts.tscparams b/async/async.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/async/async.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/async/asyncamd-tests.ts.tscparams b/async/asyncamd-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/async/asyncamd-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/azure-mobile-services-client/AzureMobileServicesClient-tests.ts.tscparams b/azure-mobile-services-client/AzureMobileServicesClient-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/azure-mobile-services-client/AzureMobileServicesClient-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/backbone-relational/backbone-relational-tests.ts.tscparams b/backbone-relational/backbone-relational-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/backbone-relational/backbone-relational-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/backbone-relational/backbone-relational.d.ts.tscparams b/backbone-relational/backbone-relational.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/backbone-relational/backbone-relational.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/backbone/backbone-tests.ts.tscparams b/backbone/backbone-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/backbone/backbone-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index e2579c407..3902d8ffd 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -67,16 +67,16 @@ declare module Backbone { } class Events { - on(eventName: any, callback?: (...args: any[]) => void , context?: any): any; - off(eventName?: string, callback?: (...args: any[]) => void , context?: any): any; + on(eventName: any, callback?: Function, context?: any): any; + off(eventName?: string, callback?: Function, context?: any): any; trigger(eventName: string, ...args: any[]): any; - bind(eventName: string, callback: (...args: any[]) => void , context?: any): any; - unbind(eventName?: string, callback?: (...args: any[]) => void , context?: any): any; + bind(eventName: string, callback: Function, context?: any): any; + unbind(eventName?: string, callback?: Function, context?: any): any; - once(events: string, callback: (...args: any[]) => void , context?: any): any; - listenTo(object: any, events: string, callback: (...args: any[]) => void ): any; - listenToOnce(object: any, events: string, callback: (...args: any[]) => void ): any; - stopListening(object?: any, events?: string, callback?: (...args: any[]) => void ): any; + once(events: string, callback: Function, context?: any): any; + listenTo(object: any, events: string, callback: Function): any; + listenToOnce(object: any, events: string, callback: Function): any; + stopListening(object?: any, events?: string, callback?: Function): any; } class ModelBase extends Events { @@ -248,7 +248,7 @@ declare module Backbone { constructor(options?: RouterOptions); initialize(options?: RouterOptions); - route(route: string, name: string, callback?: (...parameter: any[]) => void ); + route(route: string, name: string, callback?: Function); navigate(fragment: string, options?: NavigateOptions); navigate(fragment: string, trigger?: boolean); @@ -269,7 +269,7 @@ declare module Backbone { getHash(window?: Window): string; getFragment(fragment?: string, forcePushState?: boolean): string; stop(): void; - route(route: string, callback: (...args: any[]) => void ); + route(route: string, callback: Function); checkUrl(e?: any): void; loadUrl(fragmentOverride: string): boolean; navigate(fragment: string, options?: any); @@ -339,4 +339,3 @@ declare module Backbone { function setDomLibrary(jQueryNew); } - diff --git a/backbone/backbone.d.ts.tscparams b/backbone/backbone.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/backbone/backbone.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/backgrid/backgrid.d.ts.tscparams b/backgrid/backgrid.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/backgrid/backgrid.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/bootstrap-notify/bootstrap-notify.d.ts.tscparams b/bootstrap-notify/bootstrap-notify.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/bootstrap-notify/bootstrap-notify.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/bootstrap.datepicker/bootstrap.datepicker-tests.ts.tscparams b/bootstrap.datepicker/bootstrap.datepicker-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/bootstrap.datepicker/bootstrap.datepicker-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/bootstrap.datepicker/bootstrap.datepicker.d.ts b/bootstrap.datepicker/bootstrap.datepicker.d.ts index 9be7bccc2..4cf27ef19 100644 --- a/bootstrap.datepicker/bootstrap.datepicker.d.ts +++ b/bootstrap.datepicker/bootstrap.datepicker.d.ts @@ -1,4 +1,4 @@ -// Type definitions for bootstrap.datepicker +// Type definitions for bootstrap.datepicker // Project: https://github.com/eternicode/bootstrap-datepicker // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -24,4 +24,10 @@ interface JQuery { datepicker(methodName: string): JQuery; datepicker(methodName: string, params: any): JQuery; datepicker(options: DatepickerOptions): JQuery; -} \ No newline at end of file + + off(events?: "changeDate", selector?: any, handler?: (eventObject: any) => any): JQuery; + + on(events: "changeDate", selector?: string, data?: any, handler?: (eventObject: any) => any): JQuery; + on(events: "changeDate", selector?: string, handler?: (eventObject: any) => any): JQuery; + on(events: "changeDate", handler?: (eventObject: any) => any): JQuery; +} diff --git a/bootstrap.paginator/bootstrap.paginator.d.ts.tscparams b/bootstrap.paginator/bootstrap.paginator.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/bootstrap.paginator/bootstrap.paginator.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/bootstrap/bootstrap-tests.ts.tscparams b/bootstrap/bootstrap-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/bootstrap/bootstrap-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/box2d/box2dweb-test.ts.tscparams b/box2d/box2dweb-test.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/box2d/box2dweb-test.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/box2d/box2dweb.d.ts.tscparams b/box2d/box2dweb.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/box2d/box2dweb.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/breeze/breeze-1.0-tests.ts.tscparams b/breeze/breeze-1.0-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/breeze/breeze-1.0-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/breeze/breeze-1.0.d.ts.tscparams b/breeze/breeze-1.0.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/breeze/breeze-1.0.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/breeze/breeze-1.2-tests.ts.tscparams b/breeze/breeze-1.2-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/breeze/breeze-1.2-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/breeze/breeze-1.2.d.ts.tscparams b/breeze/breeze-1.2.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/breeze/breeze-1.2.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/breeze/breeze-tests.ts.tscparams b/breeze/breeze-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/breeze/breeze-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/breeze/breeze.d.ts.tscparams b/breeze/breeze.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/breeze/breeze.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/browser-harness/browser-harness-tests.ts.tscparams b/browser-harness/browser-harness-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/browser-harness/browser-harness-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/browser-harness/browser-harness.d.ts b/browser-harness/browser-harness.d.ts index 3b8cf08be..8c410b94a 100644 --- a/browser-harness/browser-harness.d.ts +++ b/browser-harness/browser-harness.d.ts @@ -9,25 +9,25 @@ declare module "browser-harness" { import events = require("events"); interface HarnessEvents extends events.NodeEventEmitter { - once(event: string, listener: (driver: Driver) => void); - once(event: 'ready', listener: (driver: Driver) => void); + once(event: string, listener: (driver: Driver) => void): events.NodeEventEmitter; + once(event: 'ready', listener: (driver: Driver) => void): events.NodeEventEmitter; - on(event: string, listener: (driver: Driver) => void); - on(event: 'ready', listener: (driver: Driver) => void); + on(event: string, listener: (driver: Driver) => void): events.NodeEventEmitter; + on(event: 'ready', listener: (driver: Driver) => void): events.NodeEventEmitter; } interface DriverEvents extends events.NodeEventEmitter { - once(event: string, listener: (text: string) => void); - once(event: 'console.log', listener: (text: string) => void); - once(event: 'console.warn', listener: (text: string) => void); - once(event: 'console.error', listener: (text: string) => void); - once(event: 'window.onerror', listener: (text: string) => void); + once(event: string, listener: (text: string) => void): events.NodeEventEmitter; + once(event: 'console.log', listener: (text: string) => void): events.NodeEventEmitter; + once(event: 'console.warn', listener: (text: string) => void): events.NodeEventEmitter; + once(event: 'console.error', listener: (text: string) => void): events.NodeEventEmitter; + once(event: 'window.onerror', listener: (text: string) => void): events.NodeEventEmitter; - on(event: string, listener: (text: string) => void); - on(event: 'console.log', listener: (text: string) => void); - on(event: 'console.warn', listener: (text: string) => void); - on(event: 'console.error', listener: (text: string) => void); - on(event: 'window.onerror', listener: (text: string) => void); + on(event: string, listener: (text: string) => void): events.NodeEventEmitter; + on(event: 'console.log', listener: (text: string) => void): events.NodeEventEmitter; + on(event: 'console.warn', listener: (text: string) => void): events.NodeEventEmitter; + on(event: 'console.error', listener: (text: string) => void): events.NodeEventEmitter; + on(event: 'window.onerror', listener: (text: string) => void): events.NodeEventEmitter; } export interface Driver { diff --git a/browser-harness/browser-harness.d.ts.tscparams b/browser-harness/browser-harness.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/browser-harness/browser-harness.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/browserify/browserify-tests.ts.tscparams b/browserify/browserify-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/browserify/browserify-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/browserify/browserify.d.ts.tscparams b/browserify/browserify.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/browserify/browserify.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/camljs/camljs-tests.ts.tscparams b/camljs/camljs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/camljs/camljs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/camljs/camljs.d.ts.tscparams b/camljs/camljs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/camljs/camljs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/casperjs/casperjs.d.ts.tscparams b/casperjs/casperjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/casperjs/casperjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chai-fuzzy/chai-fuzzy-assert.d.ts.tscparams b/chai-fuzzy/chai-fuzzy-assert.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chai-fuzzy/chai-fuzzy-assert.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chai-jquery/chai-jquery-tests.ts.tscparams b/chai-jquery/chai-jquery-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chai-jquery/chai-jquery-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chai-jquery/chai-jquery.d.ts.tscparams b/chai-jquery/chai-jquery.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chai-jquery/chai-jquery.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chai/chai-assert-tests.ts.tscparams b/chai/chai-assert-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chai/chai-assert-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chai/chai-tests.ts b/chai/chai-tests.ts index 8a09c3f42..b559c515d 100644 --- a/chai/chai-tests.ts +++ b/chai/chai-tests.ts @@ -688,6 +688,12 @@ function _throw() { }, "blah: expected [Function] to throw error including 'hello' but got 'testing'"); } +function use(){ + chai.use(function (_chai, utils) { + _chai.can.use.any(); + }); +} + function respondTo() { function Foo() {}; var bar = {}; diff --git a/chai/chai-tests.ts.tscparams b/chai/chai-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chai/chai-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chai/chai.d.ts b/chai/chai.d.ts index 9d649a17c..9fc93a667 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -8,6 +8,9 @@ declare module chai { function expect(target: any): Expect; + // Provides a way to extend the internals of Chai + function use(fn: (chai: any, utils: any) => void); + interface ExpectStatic { (target: any): Expect; } diff --git a/chai/chai.d.ts.tscparams b/chai/chai.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chai/chai.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/cheerio/cheerio-tests.ts.tscparams b/cheerio/cheerio-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/cheerio/cheerio-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/cheerio/cheerio.d.ts.tscparams b/cheerio/cheerio.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/cheerio/cheerio.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chrome/chrome-app-tests.ts.tscparams b/chrome/chrome-app-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chrome/chrome-app-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chrome/chrome-app.d.ts.tscparams b/chrome/chrome-app.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chrome/chrome-app.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chrome/chrome-tests.ts.tscparams b/chrome/chrome-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chrome/chrome-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index a2faba4ac..8c9ec22dd 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -830,44 +830,11 @@ declare module chrome.events { // Extension //////////////////// declare module chrome.extension { - interface MessageSender { - id: string; - tab?: chrome.tabs.Tab; - } - - interface Port { - postMessage: Function; - sender?: MessageSender; - onDisconnect: chrome.events.Event; - onMessage: chrome.events.Event; - name: string; - } - interface FetchProperties { windowId?: number; type?: string; } - interface ConnectInfo { - name?: string; - } - - interface ExtensionMessageEvent extends chrome.events.Event { - addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; - } - - interface ExtensionMessageExternalEvent extends chrome.events.Event { - addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; - } - - interface ExtensionConnectEvent extends chrome.events.Event { - addListener(callback: (port: Port) => void): void; - } - - interface ExtensionConnectExternalEvent extends chrome.events.Event { - addListener(callback: (port: Port) => void): void; - } - var inIncognitoContext: boolean; var lastError: Object; @@ -876,15 +843,7 @@ declare module chrome.extension { export function setUpdateUrlData(data: string): void; export function getViews(fetchProperties?: FetchProperties): Window[]; export function isAllowedFileSchemeAccess(callback: (isAllowedAccess: boolean) => void): void; - export function sendMessage(message: any, responseCallback?: (response: any) => void): void; - export function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void; - export function connect(extensionId?: string, connectInfo?: ConnectInfo): Port; export function isAllowedIncognitoAccess(callback: (isAllowedAccess) => void): void; - - var onMessage: ExtensionMessageEvent; - var onMessageExternal: ExtensionMessageExternalEvent; - var onConnect: ExtensionConnectEvent; - var onConnectExternal: ExtensionConnectExternalEvent; } //////////////////// @@ -1461,11 +1420,62 @@ declare module chrome.runtime { var lastError: Object; var id: string; + interface ConnectInfo { + name?: string; + } + interface InstalledDetails { reason: string; previousVersion?: string; } + interface MessageOptions { + includeTlsChannelId?: boolean; + } + + interface MessageSender { + id: string; + tab?: chrome.tabs.Tab; + } + + interface PlatformInfo { + os: string; + arch: string; + nacl_arch: string; + } + + interface Port { + postMessage: Function; + sender?: MessageSender; + onDisconnect: chrome.events.Event; + onMessage: chrome.events.Event; + name: string; + } + + interface UpdateAvailableDetails { + version: string; + } + + interface UpdateCheckDetails { + version: string; + } + + interface ExtensionMessageEvent extends chrome.events.Event { + addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; + } + + interface ExtensionMessageExternalEvent extends chrome.events.Event { + addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; + } + + interface ExtensionConnectEvent extends chrome.events.Event { + addListener(callback: (port: Port) => void): void; + } + + interface ExtensionConnectExternalEvent extends chrome.events.Event { + addListener(callback: (port: Port) => void): void; + } + interface RuntimeSuspendEvent extends chrome.events.Event { addListener(callback: Function): void; } @@ -1484,17 +1494,43 @@ declare module chrome.runtime { interface RuntimeMessageEvent extends chrome.events.Event { addListener(callback: Function): void; } + + interface RuntimeRestartRequiredEvent extends chrome.events.Event { + addListener(callback: (reason: string) => void): void; + } + + interface RuntimeUpdateAvailableEvent extends chrome.events.Event { + addListener(callback: (details: UpdateAvailableDetails) => void): void; + } + export function connect(connectInfo?: ConnectInfo): Port; + export function connect(extensionId: string, connectInfo?: ConnectInfo): Port; + export function connectNative(application: string): Port; export function getBackgroundPage(callback: (backgroundPage?: Window) => void): void; export function getManifest(): Object; + export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void; + export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void; export function getURL(path: string): string; - + export function reload(): void; + export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void; + export function restart(): void; + export function sendMessage(message: any, responseCallback?: (response: any) => void): void; + export function sendMessage(message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; + export function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void; + export function sendMessage(extensionId: string, message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; + export function sendNativeMessage(application: string, message: any, responseCallback?: (response: any) => void ): void; + export function setUninstallUrl(url: string): void; + + var onConnect: ExtensionConnectEvent; + var onConnectExternal: ExtensionConnectExternalEvent; var onSuspend: RuntimeSuspendEvent; var onStartup: RuntimeStartupEvent; var onInstalled: RuntimeInstalledEvent; var onSuspendCanceled: RuntimeSuspendCanceledEvent; var onMessage: RuntimeMessageEvent; - var sendMessage:(req:any, cb:(resp:any)=>void)=>void; + var onMessageExternal: RuntimeMessageEvent; + var onRestartRequired: RuntimeRestartRequiredEvent; + var onUpdateAvailable: RuntimeUpdateAvailableEvent; } @@ -1717,6 +1753,7 @@ declare module chrome.tabs { } interface TabRemoveInfo { + windowId: number; isWindowClosing: boolean; } diff --git a/chrome/chrome.d.ts.tscparams b/chrome/chrome.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/chrome/chrome.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/codemirror/codemirror-tests.ts.tscparams b/codemirror/codemirror-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/codemirror/codemirror-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/codemirror/codemirror.d.ts.tscparams b/codemirror/codemirror.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/codemirror/codemirror.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/commander/commander-tests.ts.tscparams b/commander/commander-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/commander/commander-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/convert-source-map/convert-source-map-tests.ts.tscparams b/convert-source-map/convert-source-map-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/convert-source-map/convert-source-map-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/convert-source-map/convert-source-map.d.ts.tscparams b/convert-source-map/convert-source-map.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/convert-source-map/convert-source-map.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/crossroads/crossroads-tests.ts.tscparams b/crossroads/crossroads-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/crossroads/crossroads-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/crossroads/crossroads.d.ts.tscparams b/crossroads/crossroads.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/crossroads/crossroads.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/d3/d3-tests.ts.tscparams b/d3/d3-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/d3/d3-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/d3/d3.d.ts b/d3/d3.d.ts index a9684658b..e97e12bf5 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -719,6 +719,7 @@ declare module D3 { datum: { (values: (data: any, index: number) => any): UpdateSelection; (values: any): UpdateSelection; + () : any; }; filter: { diff --git a/d3/d3.d.ts.tscparams b/d3/d3.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/d3/d3.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/d3/plugins/d3.superformula-tests.ts.tscparams b/d3/plugins/d3.superformula-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/d3/plugins/d3.superformula-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/d3/plugins/d3.superformula.d.ts.tscparams b/d3/plugins/d3.superformula.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/d3/plugins/d3.superformula.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dhtmlxgantt/dhtmlxgantt-test.ts b/dhtmlxgantt/dhtmlxgantt-test.ts new file mode 100644 index 000000000..0b491ce2b --- /dev/null +++ b/dhtmlxgantt/dhtmlxgantt-test.ts @@ -0,0 +1,33 @@ +/// + +//date operations +var start: Date = gantt.date.week_start(new Date()); +var next: Date = gantt.date.add(new Date(), 1, "week"); + +//hotkeys +gantt.keys.edit_cancel = 13; + +//config options +gantt.config.details_on_create = true; +gantt.config.scale_height = 40; +gantt.config.xml_date = "%m-%d-%Y"; + +//templates +gantt.templates.task_class = function (start: Date, end: Date, task: any) { + if (task.some) + return "classA"; + else + return "classB"; +} + +//locale +gantt.locale.labels.new_task = "New task"; + +//API +gantt.init("scheduler_here", start); +gantt.load("/data/events"); + +//events +gantt.attachEvent("onBeforeLightbox", function (id: string) { + gantt.showTask(id); +}); \ No newline at end of file diff --git a/dhtmlxgantt/dhtmlxgantt-test.ts.tscparams b/dhtmlxgantt/dhtmlxgantt-test.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dhtmlxgantt/dhtmlxgantt-test.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dhtmlxgantt/dhtmlxgantt.d.ts b/dhtmlxgantt/dhtmlxgantt.d.ts new file mode 100644 index 000000000..fbdba3543 --- /dev/null +++ b/dhtmlxgantt/dhtmlxgantt.d.ts @@ -0,0 +1,989 @@ +// Type definitions for dhtmlxGantt 2.0 +// Project: http://dhtmlx.com/docs/products/dhtmlxGantt +// Definitions by: Maksim Kozhukh +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface GanttTemplates{ + /** + * specifies the format of dates that are set by means of API methods. Used to parse incoming dates + * @param date the date which needs formatting + */ + api_date(date: Date): string; + + /** + * specifies the format of dates in the "Start time" column + * @param date the date which needs formatting + */ + date_grid(date: Date): string; + + /** + * specifies the date format of the time scale (X-Axis) + * @param date the date which needs formatting + */ + date_scale(date: Date): string; + + /** + * specifies the text of tooltips that are displayed when the user creates a new dependency link + * @param from the id of the source task + * @param from_start true, if the link is being dragged from the start of the source task, false - if
from the end of the task + * @param to the id of the target task( 'null' or 'undefined', if the target task isn't specified yet) + * @param to_start true, if the link is being dragged to the start of the target task, false - if
to the end of the task + */ + drag_link(from: any, from_start: boolean, to: any, to_start: boolean): string; + + /** + * specifies the CSS class that will be applied to the link receiver (pop-up circle near the task bar) + * @param from the id of the source task + * @param from_start true, if the link is being dragged from the start of the source task, false - if
from the end of the task + * @param to the id of the target task( 'null' or 'undefined', if the target task isn't specified yet) + * @param to_start true, if the link is being dragged to the start of the target task, false - if
to the end of the task + */ + drag_link_class(from: any, from_start: boolean, to: any, to_start: boolean): string; + + /** + * specifies the custom content inserted before the labels of child items in the tree column + * @param task the task object + */ + grid_blank(task: any): string; + + /** + * specifies the icon of child items in the tree column + * @param task the task object + */ + grid_file(task: any): string; + + /** + * specifies the icon of parent items in the tree column + * @param task the task object + */ + grid_folder(task: any): string; + + /** + * specifies the CSS class that will be applied to the headers of the table's columns + * @param column the column's configuration object + * @param config the column's id ('name' attribute) + */ + grid_header_class(column: any, config: string): string; + + /** + * specifies the indent of the child items in a branch (in the tree column) + * @param task the task object + */ + grid_indent(task: any): string; + + /** + * specifies the icon of the open/close sign in the tree column + * @param task the task object + */ + grid_open(task: any): string; + + /** + * specifies the CSS class that will be applied to a grid row + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + grid_row_class(start: Date, end: Date, task: any): string; + + /** + * specifies the CSS class that will be applied to a link + * @param link the link object + */ + link_class(link: any): string; + + /** + * specifies the text in the header of the link's "delete" confirm window + * @param link the link object + */ + link_description(link: any): string; + + /** + * specifies the text in the completed part of the task bar + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + progress_text(start: Date, end: Date, task: any): string; + + /** + * specifies the content of the pop-up edit form + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + quick_info_content(start: Date, end: Date, task: any): string; + + /** + * specifies the date of the pop-up edit form + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + quick_info_date(start: Date, end: Date, task: any): string; + + /** + * specifies the title of the pop-up edit form + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + quick_info_title(start: Date, end: Date, task: any): string; + + /** + * specifies the CSS class that will be applied to the time scale of the timeline area + * @param date the date of a cell + */ + scale_cell_class(date: Date): string; + + /** + * specifies the CSS class that will be applied to the cells of the timeline area + * @param item the task object assigned to the row + * @param date the date of a cell + */ + task_cell_class(item: Date, date: Date): string; + + /** + * specifies the CSS class that will be applied to task bars + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + task_class(start: Date, end: Date, task: any): string; + + /** + * specifies the date format of the label in the 'Time period' section of the lightbox + * @param date the date which needs formatting + */ + task_date(date: Date): string; + + /** + * specifies the CSS class that will be applied to the row of the timeline area + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + task_row_class(start: Date, end: Date, task: any): string; + + /** + * specifies the text in the task bars and the header of the lightbox + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + task_text(start: Date, end: Date, task: any): string; + + /** + * specifies the date period in the header of the lightbox + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + task_time(start: Date, end: Date, task: any): string; + + /** + * specifies the format of the drop-down time selector in the lightbox + * @param date the date which needs formatting + */ + time_picker(date: Date): string; + + /** + * specifies the format of start and end dates displayed in the tooltip + * @param date the date which needs formatting + */ + tooltip_date_format(date: Date): string; + + /** + * specifies the text of tooltips + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + tooltip_text(start: Date, end: Date, task: any): string; + + /** + * a string from an XML file is converted into a date object in conformity with this template + * @param date the date which needs formatting + */ + xml_date(date: Date): string; + + /** + * a date object is converted into a string in conformity with this template. Used to send data back to the server + * @param date the date which needs formatting + */ + xml_format(date: Date): string; + + /** + * specifies the text assigned to tasks bars on the right side + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + rightside_text(start: Date, end: Date, task: any): string; + + /** + * specifies the text assigned to tasks bars on the left side + * @param start the date when a task is scheduled to begin + * @param end the date when a task is scheduled to be completed + * @param task the task object + */ + leftside_text(start: Date, end: Date, task: any): string; +} + +interface GanttConfigOptions{ + /** + * sets the date format that will be used by the addTask() method to +parse the start_date, end_date properties in case they are specified as strings + */ + api_date: string; + + /** + * enables automatic adjusting of the grid's columns to the grid's width + */ + autofit: boolean; + + /** + * stores a collection of buttons resided in the left bottom corner of the lightbox + */ + buttons_left: any; + + /** + * stores a collection of buttons resided in the right bottom corner of the lightbox + */ + buttons_right: any; + + /** + * configures the columns of the table + */ + columns: any; + + /** + * sets the format of dates in the "Start time" column of the table + */ + date_grid: string; + + /** + * sets the format of the time scale (X-Axis) + */ + date_scale: string; + + /** + * 'says' to open the lightbox while creating new events by clicking on the '+' button + */ + details_on_create: boolean; + + /** + * 'says' to open the lightbox after double clicking on a task + */ + details_on_dblclick: boolean; + + /** + * enables the possibility to drag the lightbox by the header + */ + drag_lightbox: boolean; + + /** + * enables creating dependency links by drag-and-drop + */ + drag_links: boolean; + + /** + * stores the types of available drag-and-drop modes + */ + drag_mode: any; + + /** + * enables the possibility to move tasks by drag-and-drop + */ + drag_move: boolean; + + /** + * enables the possibility to change the task progress by dragging the progress knob + */ + drag_progress: boolean; + + /** + * enables the possibility to resize tasks by drag-and-drop + */ + drag_resize: boolean; + + /** + * sets the number of 'gantt.config.duration_unit' units that will correspond to one unit of the 'duration' data property. + */ + duration_step: number; + + /** + * sets the duration unit in milliseconds + */ + duration_unit: number; + + /** + * sets the end value of the time scale (X–Axis) + */ + end_date: Date; + + /** + * 'says' the Gantt chart to re-render the scale each time a task doesn't fit into the existing scale interval + */ + fit_tasks: boolean; + + /** + * sets the maximum width of the grid + */ + grid_width: number; + + /** + * sets whether the timeline area will be initially scrolled to display the earliest task + */ + initial_scroll: boolean; + + /** + * specifies the lightbox object + */ + lightbox: any; + + /** + * increases the height of the lightbox + */ + lightbox_additional_height: number; + + /** + * sets the size of the link arrow + */ + link_arrow_size: number; + + /** + * sets the name of the attribute that will specify the id of the link's HTML element + */ + link_attribute: string; + + /** + * sets the width of dependency links in the timeline area + */ + link_line_width: number; + + /** + * sets the width of the area (over the link) sensitive to clicks + */ + link_wrapper_width: number; + + /** + * stores the types of links dependencies + */ + links: any; + + /** + * sets the minimum width for a column + */ + min_column_width: number; + + /** + * sets the minimum step (in milliseconds) for task's time values + */ + min_duration: number; + + /** + * activates the 'branch' mode that allows dragging tasks only within the parent branch + */ + order_branch: boolean; + + /** + * defines whether the task form will appear from the left/right side of the screen or near the selected task + */ + quick_info_detached: boolean; + + /** + * stores a collection of buttons resided in the pop-up edit form + */ + quickinfo_buttons: any; + + /** + * activates the read-only mode for the Gantt chart + */ + readonly: boolean; + + /** + * enables rounding the task's start and end dates to the nearest scale marks + */ + round_dnd_dates: boolean; + + /** + * sets the default height for rows of the table + */ + row_height: number; + + /** + * sets the height of the time scale and the header of the grid + */ + scale_height: number; + + /** + * sets the unit of the time scale (X-Axis) + */ + scale_unit: string; + + /** + * enables selection of tasks in the Gantt chart + */ + select_task: boolean; + + /** + * enables converting server-side dates from UTC to a local time zone (and backward) while sending data to the server + */ + server_utc: boolean; + + /** + * enables showing a progress/spinner while data is loading + */ + show_progress: boolean; + + /** + * enables sorting in the table + */ + sort: boolean; + + /** + * sets the start value of the time scale (X–Axis) + */ + start_date: Date; + + /** + * sets the start day of weeks + */ + start_on_monday: boolean; + + /** + * sets the step of the time scale (X-Axis) + */ + step: number; + + /** + * specifies the second time scale(s) + */ + subscales: any; + + /** + * sets the name of the attribute that will specify the id of the task's HTML element + */ + task_attribute: string; + + /** + * sets the format of the date label in the 'Time period' section of the lightbox + */ + task_date: string; + + /** + * sets the height of task bars in the timeline area + */ + task_height: number; + + /** + * sets the offset (in pixels) of the nearest task from the left border in the timeline + */ + task_scroll_offset: number; + + /** + * sets the format of the time drop-down selector in the lightbox + */ + time_picker: string; + + /** + * sets the minimum step (in minutes) for the task's time values + */ + time_step: number; + + /** + * sets the timeout in milliseconds before the tooltip is displayed for a task + */ + tooltip_timeout: number; + + /** + * enables/disables the touch support for the Gantt chart + */ + touch: any; + + /** + * defines the time period in milliseconds that is used to differ the long touch gesture from the scroll gesture + */ + touch_drag: any; + + /** + * sets the date format that is used to parse data from the data set + */ + xml_date: string; +} + + +interface GanttDateHelpers{ + add(origin: Date, count: number, unit: string): Date; + copy(origin: Date): Date; + + date_part(origin: Date): Date; + time_part(origin: Date): Date; + + day_start(origin: Date): Date; + month_start(origin: Date): Date; + week_start(origin: Date): Date; + year_start(origin: Date): Date; + + getISOWeek(origin: Date): number; + getUTCISOWeek(origin: Date): number; + + date_to_str(format: string): any; + str_to_date(format: string): any; + convert_to_utc(origin: Date): Date; + to_fixed(value: number): string; +} + +interface GanttHotkeys{ + edit_save: number; + edit_cancel: number; +} + +//Gantt.locale + +interface GanttLocaleDate{ + month_full: string[]; + month_short: string[]; + day_full: string[]; + day_short: string[]; +} + +interface GanttLocaleLabels{ + new_task: string; + icon_save: string; + icon_cancel: string; + icon_details: string; + icon_edit: string; + icon_delete: string; + confirm_closing: string; + confirm_deleting: string; + section_description: string; + section_time: string; + confirm_link_deleting: string; + link_from: string; + link_to: string; + link_start: string; + link_end: string; + minutes: string; + hours: string; + days: string; + weeks: string; + months: string; + years: string; +} + +interface GanttLocale{ + date: GanttLocaleDate; + labels: GanttLocaleLabels; +} + +interface GanttStatic{ + templates: GanttTemplates; + config: GanttConfigOptions; + date: GanttDateHelpers; + keys: GanttHotkeys; + skin: String; + version: String; + locale: GanttLocale; + $click: any; + + /** + * adds a new dependency link + * @param link the link object + */ + addLink(link: any): any; + + /** + * adds a new task + * @param task the task object + * @param parent the parent's id + */ + addTask(task: any, parent: string): any; + + /** + * attaches the handler to an inner event of dhtmlxGantt + * @param name the event's name, case-insensitive + * @param handler the handler function + */ + attachEvent(name: string, handler: (...args: any[])=>any): any; + + /** + * calls an inner event + * @param name the event's name, case-insensitive + * @param params an array of the event-related data + */ + callEvent(name: string, params: any): boolean; + + /** + * changes the link's id + * @param id the current link's id + * @param new_id the new link's id + */ + changeLinkId(id: any, new_id: any); + + /** + * changes the task's id + * @param id the current task's id + * @param new_id the new task's id + */ + changeTaskId(id: any, new_id: any); + + /** + * checks whether an event has some handler(s) specified + * @param name the event's name + */ + checkEvent(name: string): boolean; + + /** + * removes all tasks from the Gantt chart + */ + clearAll(); + + /** + * closes the branch with the specified id + * @param id the branch id + */ + close(id : any); + + /** + * deletes the specified dependency link + * @param id the dependency link's id + */ + deleteLink(id: any); + + /** + * deletes the specified task + * @param id the task's id + */ + deleteTask(id: string); + + /** + * detaches all handlers from events (which were attached before by the attachEvent() method) + */ + detachAllEvents(); + + /** + * detaches a handler from an event (which was attached before by the attachEvent() method) + * @param id the event's id + */ + detachEvent(id: string); + + /** + * iterates over specified tasks of the Gantt chart + * @param code a function that will iterate over tasks. Takes a task object as a parameter + * @param parent the parent id. If specified, the function will iterate over childs of the
specified parent + * @param master the object, that 'this' will refer to + */ + eachTask(code : (...args: any[])=>any, parent?: any, master?: any); + + /** + * returns the 1st-level child tasks of the specified parent branch + * @param id the parent branch's id + */ + getChildren(id: any): any; + + /** + * get the index of a task in the tree + * @param id the task id + */ + getGlobalTaskIndex(id: any); + + /** + * gets the label of a select control in the lightbox + * @param property the name of a data property that the control is mapped to + * @param key the option's id. This parameter is compared with the task's data property to
assign the select's option to the task + */ + getLabel(property: string, key: any); + + /** + * gets the lightbox's HTML object element + */ + getLightbox(): HTMLElement; + + /** + * returns the object of the lightbox's section + * @param name the name of the section + */ + getLightboxSection(name: string): any; + + /** + * returns values of the lightbox's sections + */ + getLightboxValues(): any; + + /** + * returns the dependency link object by the specified id + * @param id the link id + */ + getLink(id: any): any; + + /** + * returns the HTML element of the specified dependency link + * @param id the link id + */ + getLinkNode(id: any): HTMLElement; + + /** + * returns the id of the next item (no matter what the level of nesting is: the same or different) + * @param id the task id + */ + getNext(id: any): any; + + /** + * returns the id of the previous item (no matter what the level of nesting is: the same or different) + * @param id the task id + */ + getPrev(id: any): any; + + /** + * returns the scroll position + */ + getScrollState(): any; + + /** + * returns the id of the selected task + */ + getSelectedId(): any; + + /** + * gets the current state of the Gantt chart + */ + getState(): any; + + /** + * returns the task object + * @param id the task id + */ + getTask(id: any): any; + + /** + * returns a collection of tasks which occur during the specified period + * @param from the start date of the period + * @param to the end date of the period + */ + getTaskByTime(from?: Date, to?: Date): any; + + /** + * get the index of a task in the branch + * @param id the task id + */ + getTaskIndex(id: any): number; + + /** + * returns the HTML element of the task bar + * @param id the task id + */ + getTaskNode(id: any): HTMLElement; + + /** + * returns the HTML element of the task row in the table + * @param id the task id + */ + getTaskRowNode(id: any): HTMLElement; + + /** + * checks whether the specified item has child tasks + * @param id the task id + */ + hasChild(id: any): boolean; + + /** + * hides the lightbox modal overlay that blocks interactions with the remaining screen + * @param box an element to hide + */ + hideCover(box?: HTMLElement); + + /** + * closes the lightbox if it's currently active + */ + hideLightbox(); + + /** + * hides the pop-up task form (if it's currently active) + */ + hideQuickInfo(); + + /** + * constructor. Initializes a dhtmlxGantt object + * @param container an HTML container ( or its id) where a dhtmlxGantt object will be initialized + * @param from the start value of the time scale (X–Axis) + * @param to the end value of the time scale (X–Axis) + */ + init(container: any, from?: Date, to?: Date); + + /** + * checks whether the specified link is correct + * @param link the link object + */ + isLinkAllowed(link: any): boolean; + + /** + * checks whether the specified link exists + * @param id the link id + */ + isLinkExists(id: any): boolean; + + /** + * checks whether the specified task exists + * @param id the task id + */ + isTaskExists(id: any): boolean; + + /** + * checks whether the specifies task is currently rendered in the Gantt chart + * @param id the task's id + */ + isTaskVisible(id: any): boolean; + + /** + * loads data to the gantt from an external data source + * @param url the server-side url (may be a static file or a server side script that outputs data) + * @param type ('json', 'xml', 'oldxml') the data type. The default value - 'json' + * @param callback the callback function + */ + load(url: string, type?: string, callback?: (...args: any[])=>any); + + /** + * gets the id of a task from the specified HTML event + * @param e a native event + */ + locate(e: Event): string; + + /** + * moves a task to a new position + * @param sid the id of the task to move + * @param tindex the index of the position that the task will be moved to
(the index in the whole tree) + * @param parent the parent id. If specified, the tindex will refer to the index in the
'parent' branch + */ + moveTask(sid: any, tindex: number, parent?: any); + + /** + * opens the branch with the specified id + * @param id the branch id + */ + open(id: any); + + /** + * loads data from a client-side resource + * @param url a string or object which represents data + * @param type ( 'json', 'xml' ) the data type. The default value - 'json' + */ + parse(url: any, type?: string); + + /** + * refreshes data in the Gantt chart + */ + refreshData(); + + /** + * refreshes the specifies link + * @param id the link id + */ + refreshLink(id: any); + + /** + * refreshes the task and its related links + * @param id the task id + */ + refreshTask(id: any); + + /** + * renders the whole Gantt chart + */ + render(); + + /** + * removes the current lightbox's HTML object element + */ + resetLightbox(); + + /** + * forces the lightbox to resize + */ + resizeLightbox(); + + /** + * scrolls the Gantt container to the specified position + * @param x the value of the horizontal scroll + * @param y the value of the vertical scroll + */ + scrollTo(x: number, y: number); + + /** + * selects the specified task + * @param id the task id + */ + selectTask(id: any): any; + + /** + * serializes the data into JSON or XML format. + * @param type the format that the data will be serialized into.
Possible values: 'json' (default ), 'xml'. + */ + serialize(type?: string); + + /** + * returns a list of options + * @param list_name the name of a list + * @param options an array of options + */ + serverList(list_name: string, options?: any); + + /** + * resizes the Gantt chart + */ + setSizes(); + + /** + * shows the lightbox modal overlay that blocks interactions with the remaining screen + * @param box an element to hide + */ + showCover(box?: HTMLElement); + + /** + * opens the lightbox for the specified task + * @param id the task id + */ + showLightbox(id : any); + + /** + * displays the pop-up task form for the specified task + * @param id the task id + */ + showQuickInfo(id: any); + + /** + * makes the specified task visible on the screen + * @param id the task id + */ + showTask(id: any); + + /** + * sorts the tasks in the grid + * @param field the name of the column that the grid will be sorted by or a custom
sorting function + * @param desc specifies the sorting direction: true - descending sort and false - ascending
sort. By default, false + * @param parent the id of the parent task. Specify the parameter if you want to sort tasks only in
the branch of the specified parent. + */ + sort(field: any, desc?: boolean, parent?: any); + + /** + * removes selection from the selected task + */ + unselectTask(); + + /** + * updates the specified dependency link + * @param id the task id + */ + updateLink(id: string); + + /** + * updates the specified task + * @param id the task id + */ + updateTask(id: string); +} + + + +declare var gantt: GanttStatic; \ No newline at end of file diff --git a/dhtmlxgantt/dhtmlxgantt.d.ts.tscparams b/dhtmlxgantt/dhtmlxgantt.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dhtmlxgantt/dhtmlxgantt.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dhtmlxscheduler/dhtmlxscheduler-test.ts b/dhtmlxscheduler/dhtmlxscheduler-test.ts new file mode 100644 index 000000000..d526a1eaf --- /dev/null +++ b/dhtmlxscheduler/dhtmlxscheduler-test.ts @@ -0,0 +1,33 @@ +/// + +//date operations +var start: Date = scheduler.date.week_start(new Date()); +var next: Date = scheduler.date.add(new Date(), 1, "week"); + +//hotkeys +scheduler.keys.edit_cancel = 13; + +//config options +scheduler.config.details_on_create = true; +scheduler.config.xml_date = "%m-%d-%Y"; +scheduler.xy.bar_height = 40; + +//templates +scheduler.templates.event_class = function (start: Date, end: Date, event: any) { + if (event.some) + return "classA"; + else + return "classB"; +} + +//locale +scheduler.locale.labels.week_tab = "7 days"; + +//API +scheduler.init("scheduler_here", start); +scheduler.load("/data/events"); + +//events +scheduler.attachEvent("onEmptyClick", function (ev: Event) { + var date: Date = scheduler.getActionData(ev).date; +}); \ No newline at end of file diff --git a/dhtmlxscheduler/dhtmlxscheduler-test.ts.tscparams b/dhtmlxscheduler/dhtmlxscheduler-test.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dhtmlxscheduler/dhtmlxscheduler-test.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dhtmlxscheduler/dhtmlxscheduler.d.ts b/dhtmlxscheduler/dhtmlxscheduler.d.ts new file mode 100644 index 000000000..011532573 --- /dev/null +++ b/dhtmlxscheduler/dhtmlxscheduler.d.ts @@ -0,0 +1,1604 @@ +// Type definitions for dhtmlxScheduler 4.0 +// Project: http://dhtmlx.com/docs/products/dhtmlxScheduler +// Definitions by: Maksim Kozhukh +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface SchedulerTemplates{ + /** + * specifies the date in the header of the view + * @param start the start date of the view + * @param end the end date of the view + */ + agenda_date(start : Date, end : Date): string; + + /** + * specifies the text in the second column of the Agenda view + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + agenda_text(start: Date, end: Date, event: any): string; + + /** + * specifies the date in the first column of the Agenda view + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + agenda_time(start: Date, end: Date, event: any): string; + + /** + * specifies the format for dates that are set by means of API methods. Used to parse incoming dates + * @param date the date which needs formatting + */ + api_date(date: Date): string; + + /** + * specifies the format of the day in a cell + * @param date the cell date + */ + calendar_date(date: Date): string; + + /** + * specifies the date in the header of the calendar + * @param date the date which needs formatting + */ + calendar_month(date: Date): string; + + /** + * specifies the day name in the week sub-header of the view + * @param date the date which needs formatting + */ + calendar_scale_date(date: Date): string; + + /** + * specifies the date format of the lightbox start and end date inputs + * @param date the date which needs formatting + */ + calendar_time(date: Date): string; + + /** + * specifies the date in the header of the Day and Units views + * @param date the date which needs formatting + */ + day_date(date: Date): string; + + /** + * specifies the date in the sub-header of the Day view + * @param date the date which needs formatting + */ + day_scale_date(date: Date): string; + + /** + * specifies the date of an event. Applied to one-day events only + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + event_bar_date(start: Date, end: Date, event: any): string; + + /** + * specifies the event text. Applied to all events + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + event_bar_text(start: Date, end: Date, event: any): string; + + /** + * specifies the css style for the event container + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + event_class(start: Date, end: Date, event: any): string; + + /** + * specifies the time part of the start and end dates of the event. Mostly used by other templates for presenting time periods + * @param date the date which needs formatting + */ + event_date(date: Date): string; + + /** + * specifies the event header + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + event_header(start: Date, end: Date, event: any): string; + + /** + * specifies the event text + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + event_text(start: Date, end: Date, event: any): string; + + /** + * specifies the items of the Y-Axis + * @param date the date which needs formatting + */ + hour_scale(date: Date): string; + + /** + * specifies the format of requests in the dynamic loading mode + * @param date the date which needs formatting + */ + load_format(date: Date): string; + + /** + * specified the date in the header of the view + * @param start the start date of the view + * @param end the end date of the view + */ + map_date(start : Date, end : Date): string; + + /** + * specifies the text in the second column of the view + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + map_text(start: Date, end: Date, event: any): string; + + /** + * specifies the date in the first column of the view + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + map_time(start: Date, end: Date, event: any): string; + + /** + * specifies the date of the event in the Google Maps popup marker + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + marker_date(start: Date, end: Date, event: any): string; + + /** + * specifies the text of the event in the Google Maps popup marker + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + marker_text(start: Date, end: Date, event: any): string; + + /** + * specifies the date in the header of the view + * @param date the date which needs formatting + */ + month_date(date: Date): string; + + /** + * specifies the css class that will be applied to a day cell + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + month_date_class(start: Date, end: Date, event: any): string; + + /** + * specifies the format of the day in a cell + * @param date the date which needs formatting + */ + month_day(date: Date): string; + + /** + * specifies the presentation of the 'View more' link in the cell of the Month view + * @param date the date of a month cell + * @param count the number of events in the cell + */ + month_events_link(date: Date, count: number): string; + + /** + * specifies the date format of the X-Axis of the view + * @param date the date which needs formatting + */ + month_scale_date(date: Date): string; + + /** + * specifies the content of the pop-up edit form + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + quick_info_content(start: Date, end: Date, event: any): string; + + /** + * specifies the date of the pop-up edit form + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + quick_info_date(start: Date, end: Date, event: any): string; + + /** + * specifies the title of the pop-up edit form + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + quick_info_title(start: Date, end: Date, event: any): string; + + /** + * specifies the drop-down time selector in the lightbox + */ + time_picker(): string; + + /** + * specifies the format of start and end dates displayed in the tooltip + * @param date the date which needs formatting + */ + tooltip_date_format(date: Date): string; + + /** + * specifies the text of tooltips + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + tooltip_text(start: Date, end: Date, event: any): string; + + /** + * specifies the event text + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + * @param cellDate the date of a day cell that an one-day event or a single occurrence of the recurring event displayes in + * @param pos the position a single occurrence in the recurring event: 'start' - the first occurrence, 'end' - the last occurrence, 'middle' - for remaining occurrences + */ + week_agenda_event_text(start: Date, end: Date, event: any, cellDate: Date, pos: string): string; + + /** + * the date of a day cell of the view + * @param date the date which needs formatting + */ + week_agenda_scale_date(date: Date): string; + + /** + * specified the date in the header of the view + * @param start the start date of the view + * @param end the end date of the view + */ + week_date(start : Date, end : Date): string; + + /** + * specifies the css class that will be applied to a day cell + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + week_date_class(start: Date, end: Date, event: any): string; + + /** + * specifies the date in the sub-header of the view + * @param date the date which needs formatting + */ + week_scale_date(date: Date): string; + + /** + * a string from an XML file is converted into a date object in conformity with this template + * @param date the string which need to be parsed + */ + xml_date(date: Date): Date; + + /** + * a date object is converted into a string in conformity with this template. Used to send data back to the server + * @param date the date which needs formatting + */ + xml_format(date: Date): string; + + /** + * specifies the date in the header of the view + * @param date the date which needs formatting + */ + year_date(date: Date): string; + + /** + * specifies the month name in the header of a month block of the view. + * @param date the date which needs formatting + */ + year_month(date: Date): string; + + /** + * specifies the day name in the sub-header of a month block of the view + * @param date the date which needs formatting + */ + year_scale_date(date: Date): string; + + /** + * specifies the tooltip over a day cell containing some scheduled event(s) + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + year_tooltip(start: Date, end: Date, event: any): string; + + /** + * specifies the lightbox header + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + lightbox_header(start: Date, end: Date, event: any): string; + + /** + * specifies the date in the header of the view + * @param start the start date of the view + * @param end the end date of the view + */ + grid_date(start : Date, end : Date): string; + + /** + * specifies the format of dates in columns with id='date' + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param ev the event object + */ + grid_full_date(start: Date, end: Date, ev: any): string; + + /** + * specifies the format of dates in columns with id='start_date' or id='end_date' + * @param date the date which needs formatting + */ + grid_single_date(date: Date): string; + + /** + * specifies the text in the columns + * @param field_name the column id + * @param event the event object + */ + grid_field(field_name: string, event: any): string; + + /** + * specifies the number of scheduled events in a cell of the view + * @param evs an array of objects of events contained in a cell + */ + timeline_cell_value(evs: any): string; + + /** + * specifies the css style for a cell of the view + * @param evs an array of objects of events contained in a cell (defined only in the 'cell' mode) + * @param date the date of a column + * @param section the section object + */ + timeline_cell_class(evs: any, date : Date, section: any): string; + + /** + * specifies the name of a CSS class that will be applied to items of the X-Axis + * @param date the date which needs formatting + */ + timeline_scalex_class(date: Date): string; + + /** + * specifies the name of a CSS class that will be applied to items of the second X-Axis + * @param date the date which needs formatting + */ + timeline_second_scalex_class(date: Date): string; + + /** + * specifies the name of a CSS class that will be applied to items of the Y-Axis + * @param key the section id + * @param label the section label + * @param section the section object that contains the key and label properties + */ + timeline_scaley_class(key: string, label : string, section: any): string; + + /** + * specifies items of the Y-Axis + * @param key the section id (key) + * @param label the section label + * @param section the section object containing the key and label properties + */ + timeline_scale_label(key : string, label : string, section : any): string; + + /** + * specifies the tooltip over a day cell containing some scheduled event(s) + * @param start the date when an event is scheduled to begin + * @param end the date when an event is scheduled to be completed + * @param event the event object + */ + timeline_tooltip(start: Date, end: Date, event: any): string; + + /** + * specifies the date in the header of the view + * @param date1 the date when an event is scheduled to begin + * @param date2 the date when an event is scheduled to be completed + */ + timeline_date(date1 : Date, date2 : Date): string; + + /** + * specifies items of the X-Axis + * @param date the date which needs formatting + */ + timeline_scale_date(date: Date): string; + + /** + * specifies items of the second X-Axis + * @param date the date which needs formatting + */ + timeline_second_scale_date(date: Date): string; + + /** + * specifies the date in the header of the view + * @param date the date which needs formatting + */ + units_date(date: Date): string; + + /** + * specifies items of the X-Axis + * @param key the unit id (key) + * @param label the unit label + * @param unit the unit object containing the key and label properties + */ + units_scale_text(key : string, label : string, unit : any): string; +} + +interface SchedulerConfigOptions{ + /** + * 'says' to present the numbers of days in the Month view as clickable links that open the related day in the specified view + */ + active_link_view: string; + + /** + * sets the date to display events until + */ + agenda_end: Date; + + /** + * sets the date to start displaying events from + */ + agenda_start: Date; + + /** + * 'says' to show multi-day events in the regular way (as one-day events are displayed) + */ + all_timed: any; + + /** + * sets the date format that will be used by the addEvent() method to parse the start_date, end_date properties in case they are specified as strings + */ + api_date: string; + + /** + * enables automatic changing of the end event date after changing the start date + */ + auto_end_date: boolean; + + /** + * stores a collection of buttons resided in the left bottom corner of the lightbox + */ + buttons_left: any; + + /** + * stores a collection of buttons resided in the right bottom corner of the lightbox + */ + buttons_right: any; + + /** + * sets the maximum number of events in a cascade + */ + cascade_event_count: number; + + /** + * sets the 'cascade' display mode + */ + cascade_event_display: boolean; + + /** + * sets the left margin for a cascade of events + */ + cascade_event_margin: number; + + /** + * activates/disables checking of limits + */ + check_limits: boolean; + + /** + * sets the maximum allowable number of events per time slot + */ + collision_limit: number; + + /** + * forces the scheduler container to automatically change its size to show the whole content without scrolling + */ + container_autoresize: boolean; + + /** + * sets the format for the date in the header of the Week and Units views + */ + day_date: string; + + /** + * enables the possibility to create events by double click + */ + dblclick_create: boolean; + + /** + * sets the date format used by the templates 'day_date', 'week_date', 'day_scale_date' for setting date in the views' headers + */ + default_date: string; + + /** + * 'says' to use the extended form while creating new events by drag or double click + */ + details_on_create: boolean; + + /** + * 'says' to open the extended form after double clicking on an event + */ + details_on_dblclick: boolean; + + /** + * defines whether the marked(blocked) time spans should be highlighted in the scheduler + */ + display_marked_timespans: boolean; + + /** + * sets the default background color for the events retrieved by the showEvent() method + */ + displayed_event_color: string; + + /** + * sets the default font color for the events retrieved by the showEvent() method + */ + displayed_event_text_color: string; + + /** + * enables the possibility to create new events by drag-and-drop + */ + drag_create: boolean; + + /** + * enables the possibility to drag the lightbox by the header + */ + drag_lightbox: boolean; + + /** + * enables the possibility to move events by drag-and-drop + */ + drag_move: boolean; + + /** + * enables the possibility to resize events by drag-and-drop + */ + drag_resize: boolean; + + /** + * 'says' to open the lightbox while creating new events + */ + edit_on_create: boolean; + + /** + * sets the initial duration of events in minutes + */ + event_duration: number; + + /** + * sets the minimum value for the hour scale (Y-Axis) + */ + first_hour: number; + + /** + * moves views' tabs from the left to the right side + */ + fix_tab_position: boolean; + + /** + * enables setting of the event duration to the full day + */ + full_day: boolean; + + /** + * specifies whether events retrieved by the showEvent method should be highlighted while displaying + */ + highlight_displayed_event: boolean; + + /** + * sets the format of Y-Axis items + */ + hour_date: string; + + /** + * sets the height of an hour unit in pixels + */ + hour_size_px: number; + + /** + * stores a collection of icons visible in the side edit menu of the event box + */ + icons_edit: any; + + /** + * stores a collection of icons visible in the side selection menu of the event box + */ + icons_select: any; + + /** + * defines whether the date specified in the 'End by' field should be exclusive or inclusive + */ + include_end_by: boolean; + + /** + * sets the maximum value of the hour scale (Y-Axis) + */ + last_hour: number; + + /** + * adds the dotted left border to the scheduler + */ + left_border: boolean; + + /** + * specifies the lightbox object + */ + lightbox: any; + + /** + * defines the lightbox behavior while opening in the edit mode + */ + lightbox_recurring: string; + + /** + * sets the right border of the allowable date range + */ + limit_end: Date; + + /** + * sets the left border of the allowable date range + */ + limit_start: Date; + + /** + * sets the max and min values of the time selector in the lightbox to the values of the 'last_hour' and 'first_hour' options + */ + limit_time_select: boolean; + + /** + * limits viewing events + */ + limit_view: boolean; + + /** + * sets the format of server request parameters 'from', 'to' in case of dynamic loading + */ + load_date: string; + + /** + * sets the date to display events until + */ + map_end: Date; + + /** + * sets the position that will be displayed on the map in case the event location can't be identified + */ + map_error_position: any; + + /** + * the maximum width of the Google Maps's popup marker in the Map view + */ + map_infowindow_max_width: number; + + /** + * sets the initial position of the map + */ + map_initial_position: any; + + /** + * sets the initial zoom of Google Maps in the Map view + */ + map_initial_zoom: number; + + /** + * activates attempts to resolve the event location if the database doesn't have the event's coordinates stored + */ + map_resolve_event_location: boolean; + + /** + * enables/disables prompts asking the user to share his location for displaying on the map + */ + map_resolve_user_location: boolean; + + /** + * sets the date to start displaying events from + */ + map_start: Date; + + /** + * sets the type of Google Maps + */ + map_type: any; + + /** + * sets the zoom that will be used to show the user's location if he agrees to the browser offer to show it + */ + map_zoom_after_resolve: number; + + /** + * enables/disables the marker displaying the current time + */ + mark_now: boolean; + + /** + * sets the maximum number of displayable in a cell events + */ + max_month_events: number; + + /** + * specifies the minicalendar object + */ + minicalendar: any; + + /** + * sets the format for the header of the Month view + */ + month_date: string; + + /** + * sets the format for the day in a cell of the Month and Year views + */ + month_day: string; + + /** + * sets the minimum height of cells in the Month view + */ + month_day_min_height: number; + + /** + * enables rendering of multi-day events + */ + multi_day: boolean; + + /** + * sets the height of the area that displays multi-day events + */ + multi_day_height_limit: any; + + /** + * allows working with recurring events independently of time zones + */ + occurrence_timestamp_in_utc: boolean; + + /** + * defines the 'saving' behaviour for the case when the user edits the event text directly in the event box + */ + positive_closing: boolean; + + /** + * fixes dnd in case of non-linear time scale + */ + preserve_length: boolean; + + /** + * cancels preserving of the current scroll position while navigating between dates of the same view + */ + preserve_scroll: boolean; + + /** + * enables/disables caching of GET requests in the browser + */ + prevent_cache: boolean; + + /** + * defines whether the event form will appear from the left/right side of the screen or near the selected event + */ + quick_info_detached: boolean; + + /** + * activates the read-only mode for the scheduler + */ + readonly: boolean; + + /** + * activates the read-only mode for the lightbox + */ + readonly_form: boolean; + + /** + * sets the date format of the 'End by' field in the 'recurring' lighbox + */ + repeat_date: string; + + /** + * prevents including past days to events with the 'weekly' recurrence + */ + repeat_precise: boolean; + + /** + * sets the initial position of the vertical scroll in the scheduler (an hour in the 24h format) + */ + scroll_hour: number; + + /** + * shows/hides the select bar in the event box + */ + select: boolean; + + /** + * allows preventing short events from overlapping + */ + separate_short_events: boolean; + + /** + * enables converting server-side dates from UTC to a local time zone (and backward) during sending data to the server + */ + server_utc: boolean; + + /** + * enables showing a progress/spinner while data is loading (useful for dynamic loading) + */ + show_loading: boolean; + + /** + * sets the start day of weeks + */ + start_on_monday: boolean; + + /** + * sets the minimum step (in minutes) for event's time values + */ + time_step: number; + + /** + * enables/disables the touch support in the scheduler + */ + touch: any; + + /** + * defines the time period in milliseconds that is used to differ the long touch gesture from the scroll gesture + */ + touch_drag: any; + + /** + * enables/disables prompting messages in the right up corner of the screen + */ + touch_tip: boolean; + + /** + * 'says' events to occupy the whole width of the cell + */ + use_select_menu_space: boolean; + + /** + * sets the format for the date in the sub-header of the Month view + */ + week_date: string; + + /** + * enables/disables displaying the standard (wide) lightbox instead of the short one + */ + wide_form: boolean; + + /** + * sets the date format that is used to parse data from the data set + */ + xml_date: string; + + /** + * sets the number of rows in the Year view + */ + year_x: number; + + /** + * sets the number of columns in the Year view + */ + year_y: number; +} + + +interface SchedulerDateHelpers{ + add(origin: Date, count: number, unit: string): Date; + copy(origin: Date): Date; + + date_part(origin: Date): Date; + time_part(origin: Date): Date; + + day_start(origin: Date): Date; + month_start(origin: Date): Date; + week_start(origin: Date): Date; + year_start(origin: Date): Date; + + getISOWeek(origin: Date): number; + getUTCISOWeek(origin: Date): number; + + date_to_str(format: string): any; + str_to_date(format: string): any; + convert_to_utc(origin: Date): Date; + to_fixed(value: number): string; +} + +interface SchedulerHotkeys{ + edit_save: number; + edit_cancel: number; +} + +//scheduler.locale + +interface SchedulerLocaleDate{ + month_full: string[]; + month_short: string[]; + day_full: string[]; + day_short: string[]; +} + +interface SchedulerLocaleLabels{ + dhx_cal_today_button: string; + day_tab: string; + week_tab: string; + month_tab: string; + new_event: string; + icon_save: string; + icon_cancel: string; + icon_details: string; + icon_edit: string; + icon_delete: string; + confirm_closing: string; + confirm_deleting: string; + section_description: string; + section_time: string; +} + +interface SchedulerLocale{ + date: SchedulerLocaleDate; + labels: SchedulerLocaleLabels; +} + +interface SchedulerSizes{ + /** + * the height of day cells in the month view + */ + bar_height: number; + + /** + * the width of the event text input 140 day + */ + editor_width: number; + + /** + * increases the length of the lightbox + */ + lightbox_additional_height: number; + + /** + * the width of the date column in the Map view + */ + map_date_width: number; + + /** + * the width of the description column in the Map view + */ + map_description_width: number; + + /** + * the left margin of the main scheduler area + */ + margin_left: number; + + /** + * the bottom margin of the main scheduler area + */ + margin_top: number; + + /** + * the width of the selection menu + */ + menu_width: number; + + /** + * the minimal height of the event box + */ + min_event_height: number; + + /** + * the top offset of an event in a cell in the month view + */ + month_scale_height: number; + + /** + * the height of the navigation bar + */ + nav_height: number; + + /** + * the height of the X-Axis + */ + scale_height: number; + + /** + * the width of the Y-Axis + */ + scale_width: number; + + /** + * the width of the scrollbar area + */ + scroll_width: number; +} + +interface SchedulerStatic{ + templates: SchedulerTemplates; + config: SchedulerConfigOptions; + date: SchedulerDateHelpers; + keys: SchedulerHotkeys; + skin: String; + version: String; + xy: SchedulerSizes; + locale: SchedulerLocale; + + /** + * adds a new event + * @param event the event object + */ + addEvent(event: any): string; + + /** + * adds a new event and opens the lightbox to confirm + * @param event the event object + */ + addEventNow(event: any): string; + + /** + * marks dates but with certain settings makes blocking (unlike blockTime() allows setting custom styling for the limit) + * @param config the configuration object of the timespan to mark/block + */ + addMarkedTimespan(config: any); + + /** + * adds a section to the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + * @param section the object of the section to add + * @param parent_id the id of the parent section. Pass 'null' if you are adding a section to the root + */ + addSection(section: any, parent_id: string): boolean; + + /** + * attaches the handler to an inner event of dhtmlxScheduler + * @param name the event name, case-insensitive + * @param handler the handler function + */ + attachEvent(name: string, handler: (...args: any[])=>any): string; + + /** + * makes the scheduler reflect all data changes in the Backbone model and vice versa + * @param events the Backbone data collection + */ + backbone(events: any); + + /** + * blocks the specified date and applies the default 'dimmed' style to it. + * @param date a date to block ( if a number is provided, the parameter will be treated as a week day: '0' index refers to Sunday, '6' - to Saturday) + * @param time_points an array [start_minute,end_minute,..,start_minute_N,end_minute_N] where each pair sets a certain limit range. The array can have any number of such pairs + * @param items defines specific items of view(s) to block + */ + blockTime(date: any, time_points: any, items?: any); + + /** + * calls an inner event + * @param name the event name, case-insensitive + * @param params an array of the event related data + */ + callEvent(name: string, params: any): boolean; + + /** + * changes the event id + * @param id the current event id + * @param new_id the new event id + */ + changeEventId(id: string, new_id: string); + + /** + * checks whether the specified event occurs at the time that has been already occupied with another event(s) + * @param event the event object + */ + checkCollision(event: any): boolean; + + /** + * checks whether an event has some handler(s) specified + * @param name the event name + */ + checkEvent(name: string): boolean; + + /** + * checks whether an event resides in a specific timespan + * @param event the event object + * @param timespan the timespan type + */ + checkInMarkedTimespan(event: any, timespan: string): boolean; + + /** + * checks whether the specified event takes place at the blocked time period + * @param event the event object + */ + checkLimitViolation(event: any): boolean; + + /** + * removes all events from the scheduler + */ + clearAll(); + + /** + * closes all sections in the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + */ + closeAllSections(); + + /** + * closes the specified section in the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + * @param section_id the section id + */ + closeSection(section_id: string); + + /** + * collapses the expanded scheduler back to the normal size + */ + collapse(); + + /** + * creates the Grid view in the scheduler + * @param config the configuration object of the Grid view + */ + createGridView(config: any); + + /** + * creates the Timeline view in the scheduler + * @param config the configuration object of the Timeline view + */ + createTimelineView(config: any); + + /** + * creates the Units view in the scheduler + * @param config the configuration object of the Units view + */ + createUnitsView(config: any); + + /** + * deletes all sections from the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + */ + deleteAllSections(); + + /** + * deletes the specified event + * @param id the event id + */ + deleteEvent(id: any); + + /** + * removes marking/blocking set by the addMarkedTimespan() and blockTime() methods + * @param id the timespan id + */ + deleteMarkedTimespan(id: string); + + /** + * deletes a section from the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + * @param section_id the section id + */ + deleteSection(section_id: string): boolean; + + /** + * destroys previously created mini-calendar + * @param name the mini-calendar's object (if not specified, the scheduler attempts to destroy the last created mini calendar) + */ + destroyCalendar(name?: any); + + /** + * detaches a handler from an event (which was attached before by the attachEvent method) + * @param id the event id + */ + detachEvent(id: string); + + /** + * opens the inline editor to alter the event text (the editor in the event box) + * @param id the event id + */ + edit(id: string); + + /** + * closes the inline event edotor if it's currently open + * @param id the event id + */ + editStop(id: string); + + /** + * closes the lightbox + * @param mode if set to true, the changes made in the lightbox will be saved before closing. If - false, the changes will be cancelled. + * @param box the HTML container for the lightbox + */ + endLightbox(mode: boolean, box: HTMLElement); + + /** + * expands the scheduler to the full screen view + */ + expand(); + + /** + * gives access to the objects of lightbox's sections + * @param name the name of a lightbox section + */ + formSection(name: string): any; + + /** + * returns the current cursor-pointed date and section (if defined) + * @param e a native event object + */ + getActionData(e: Event): any; + + /** + * return the event object by its id + * @param event_id event_id + */ + getEvent(event_id: any); + + /** + * gets the event's end date + * @param id the event id + */ + getEventEndDate(id: string): Date; + + /** + * gets the event's start date + * @param id the event id + */ + getEventStartDate(id: string): Date; + + /** + * gets the event's text + * @param id the event id + */ + getEventText(id: string): string; + + /** + * returns a collection of events which occur during the specified period + * @param from the start date of the period + * @param to the end date of the period + */ + getEvents(from?: Date, to?: Date); + + /** + * gets the label of a select control in the lighbox + * @param property the name of a data property that the control is mapped to + * @param key the option id. This parameter is compared with the event data property to assign the select's option to an event + */ + getLabel(property: string, key: any); + + /** + * gets the lightbox's HTML object element + */ + getLightbox(): HTMLElement; + + /** + * returns all occurrences of a recurring event + * @param id the id of a recurring event + * @param number the maximum number of occurrences to return (by default, 100) + */ + getRecDates(id: string, number: number): any; + + /** + * gets the object of the currently displayable event + * @param id the event id + */ + getRenderedEvent(id: string): HTMLElement; + + /** + * gets the object of the specified section in the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + * @param section_id the section id + */ + getSection(section_id: string): any; + + /** + * gets the current state of the scheduler + */ + getState(): any; + + /** + * gets the user data associated with the specified event + * @param id the event id + * @param name the user data name + */ + getUserData(id: string, name: string): any; + + /** + * hides the lightbox modal overlay that blocks interactions with the remaining screen + * @param box an element to hide + */ + hideCover(box?: HTMLElement); + + /** + * hides the pop-up event form (if it's currently active) + */ + hideQuickInfo(); + + /** + * initializes an instance of dhtmlxScheduler + * @param container the id or object of the HTML container that the scheduler will be created inside + * @param date the initial date of the scheduler (by default, the current date) + * @param view the name of the initial view (by default, "week") + */ + init(container: any, date?: Date, view?: string); + + /** + * inverts the specified time zones + * @param zones an array [start_minute,end_minute,..,start_minute_N,end_minute_N] where each pair sets a certain limit range (in minutes). The array can have any number of such pairs + */ + invertZones(zones: any); + + /** + * checks whether the calendar is currently open in the scheduler + */ + isCalendarVisible(): any; + + /** + * checks whether the specified event one-day or multi-day + * @param event the event object + */ + isOneDayEvent(event: any): boolean; + + /** + * 'says' to change the active date in the mini calendar each time the active date in the scheduler is changed + * @param calendar the mini calendar object + * @param shift a function that defines the difference between active dates in the mini-calendar and the scheduler. The function takes the scheduler's date as a parameter and returns the date that should be displayed in the mini calendar + */ + linkCalendar(calendar: any, shift: (...args: any[])=>any); + + /** + * loads data to the scheduler from an external data source + * @param url the server side url (may be a static file or a server side script which outputs data as XML) + * @param type ('json', 'xml', 'ical') the data type. The default value - 'xml' + * @param callback the callback function + */ + load(url: string, type?: string, callback?: (...args: any[])=>any); + + /** + * applies a css class to the specified date + * @param calendar the calendar object + * @param date the date to mark + * @param css the name of a css class + */ + markCalendar(calendar: any, date: Date, css: string); + + /** + * marks and/or blocks date(s) by applying the default or a custom style to them. Marking is cancelled right after any internal update in the app. Can be used for highlighting + * @param config the configuration object of the timespan to mark/block + */ + markTimespan(config: any); + + /** + * opens all sections in the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + */ + openAllSections(); + + /** + * opens the specified section in the currently active view (if the opened view isn't Timeline in the 'Tree' mode - the method will be ignored) + * @param section_id the section id + */ + openSection(section_id: string); + + /** + * loads data from a client-side resource + * @param data a string or object which represents data + * @param type ('json', 'xml', 'ical') the data type. The default value - 'xml' + */ + parse(data: any, type?: string); + + /** + * creates a mini calendar + * @param config the calendar configuration object + */ + renderCalendar(config: any); + + /** + * generates the HTML content for a custom event box + * @param container the event container + * @param event the event object + */ + renderEvent(container: HTMLElement, event: any): boolean; + + /** + * removes the current lightbox's HTML object element + */ + resetLightbox(); + + /** + * scrolls the specified number of units in the Units view + * @param step the number of units to scroll (set the positive value to scroll units in the right direction, the negative value - in the left direction). + */ + scrollUnit(step: number); + + /** + * selects the specified event + * @param id the event id + */ + select(id: string); + + /** + * returns a list of options + * @param list_name the name of a list + * @param options an array of options + */ + serverList(list_name: string, options?: any); + + /** + * displays the specified view and date + * @param date the date to display + * @param view the name of a view to display + */ + setCurrentView(date?: Date, view?: string); + + /** + * adds a new event to the scheduler's data pool + * @param id the event id + * @param event the event object + */ + setEvent(id: any, event: any); + + /** + * sets the event's end date + * @param id the event id + * @param date the new end date of the event + */ + setEventEndDate(id: string, date: Date); + + /** + * set the event's start date + * @param id the event id + * @param date the new start date of the event + */ + setEventStartDate(id: string, date: Date); + + /** + * set the event's text + * @param id the event id + * @param text the new text of the event + */ + setEventText(id: string, text: string); + + /** + * forces the lightbox to resize + */ + setLightboxSize(); + + /** + * sets the mode that allows loading data by parts (enables the dynamic loading) + * @param mode the loading mode + */ + setLoadMode(mode: string); + + /** + * sets the user data associated with the specified event + * @param id the event id + * @param name the user data name + * @param value the user data value + */ + setUserData(id: string, name: string, value: any); + + /** + * shows the lightbox modal overlay that blocks interactions with the remaining screen + * @param box an element to hide + */ + showCover(box?: HTMLElement); + + /** + * shows and highlights the specified event in the current or specified view + * @param id the event id + * @param view the view name + */ + showEvent(id: string, view?: string); + + /** + * opens the lightbox for the specified event + * @param id the event id + */ + showLightbox(id: string); + + /** + * displays the pop-up event form for the specified event + * @param id the event id + */ + showQuickInfo(id: string); + + /** + * shows a custom lightbox in the specified HTML container centered on the screen + * @param id the event id + * @param box the lightbox's HTML container + */ + startLightbox(id : string, box: HTMLElement); + + /** + * convers scheduler's data to the ICal format + * @param header sets the value for the content header field + */ + toICal(header?: string): string; + + /** + * converts scheduler's data into the JSON format + */ + toJSON(): string; + + /** + * exports the current view to a PDF document (can be used for printing) + * @param url the path to the server-side PDF converter + * @param mode the color map of the resulting PDF document + */ + toPDF(url: string, mode?: string); + + /** + * exports several scheduler's views to a PDF document (can be used for printing) + * @param from the date to start export events from + * @param to the date to export events until + * @param view the name of a view that the export should be applied to + * @param path the path to the php file which generates a PDF file (details) + * @param color the color map in use + */ + toPDFRange(from: Date, to: Date, view: string, path: string, color: string); + + /** + * converts scheduler's data into the XML format + */ + toXML(): string; + + /** + * generates an unique ID (unique inside the current scheduler, not GUID) + */ + uid(); + + /** + * removes blocking set by the blockTime() method + * @param days (Date, number,array, string) days that should be limited + * @param zones the period in minutes that should be limited. Can be set to 'fullday' value to limit the entire day + * @param sections allows blocking date(s) just for specific items of specific views. BTW, the specified date(s) will be blocked just in the related view(s) + */ + unblockTime(days: any, zones?: any, sections?: any); + + /** + * removes a css class from the specified date + * @param calendar the mini calendar object + * @param date the date to unmark + * @param css the name of a css class to remove + */ + unmarkCalendar(calendar: any, date: Date, css: string); + + /** + * removes marking/blocking set by the markTimespan() method + * @param divs a timespan to remove marking/blocking from (or an array of timespans) + */ + unmarkTimespan(divs: any); + + /** + * unselects the specified event + * @param id the event id (if not specified, the currently selected event will be unselected) + */ + unselect(id?: string); + + /** + * displays the specified date in the mini calendar + * @param calendar the mini calendar object + * @param new_date a new date to display in the mini calendar + */ + updateCalendar(calendar: any, new_date: Date); + + /** + * updates tht specified collection with new options + * @param collection the name of the collection to update + * @param options the new values of the collection + */ + updateCollection(collection: string, options: any): boolean; + + /** + * updates the specified event + * @param id the event id + */ + updateEvent(id: string); + + /** + * displays the specified view and date (doesn't invokes any events) + * @param date the date to set + * @param view the view name + */ + updateView(date: Date, view: string); +} + + + +declare var scheduler: SchedulerStatic; \ No newline at end of file diff --git a/dhtmlxscheduler/dhtmlxscheduler.d.ts.tscparams b/dhtmlxscheduler/dhtmlxscheduler.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dhtmlxscheduler/dhtmlxscheduler.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/domo/domo-tests.ts.tscparams b/domo/domo-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/domo/domo-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dropzone/dropzone.d.ts.tscparams b/dropzone/dropzone.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dropzone/dropzone.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/durandal/durandal-1.x.d.ts.tscparams b/durandal/durandal-1.x.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/durandal/durandal-1.x.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index a8335413d..c2567f62c 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -1,5 +1,5 @@ /** - * Durandal 2.0.0 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved. + * Durandal 2.0.1 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved. * Available via the MIT license. * see: http://durandaljs.com or https://github.com/BlueSpire/Durandal for details. */ @@ -116,7 +116,7 @@ declare module 'durandal/system' { * @param {object} extension* Uses to extend the target object. */ export function extend(obj: any, ...extensions: any[]): any; - + /** * Uses a setTimeout to wait the specified milliseconds. * @param {number} milliseconds The number of milliseconds to wait. @@ -226,7 +226,7 @@ declare module 'durandal/viewEngine' { * @returns {boolean} True if the url is a view url, false otherwise. */ export function isViewUrl(url: string):boolean; - + /** * Converts a view url into a view id. * @param {string} url The url to convert. @@ -285,62 +285,8 @@ declare module 'durandal/viewEngine' { * @requires system */ declare module 'durandal/events' { - import ts = require('durandal/typescript'); - - /** - * Creates an object with eventing capabilities. - * @class Events - */ - class Events { - constructor(); - - /** - * Creates a subscription or registers a callback for the specified event. - * @param {string} events One or more events, separated by white space. - * @returns {Subscription} A subscription is returned. - */ - on(events: string): ts.EventSubscription; - - /** - * Creates a subscription or registers a callback for the specified event. - * @param {string} events One or more events, separated by white space. - * @param {function} [callback] The callback function to invoke when the event is triggered. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @returns {Events} The events object is returned for chaining. - */ - on(events: string, callback: Function, context?: any): Events; - - /** - * Removes the callbacks for the specified events. - * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed. - * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed. - * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed. - * @chainable - */ - off(events: string, callback: Function, context?: any): Events; - - /** - * Triggers the specified events. - * @param {string} [events] One or more events, separated by white space to trigger. - * @chainable - */ - trigger(events: string, ...eventArgs: any[]): Events; - - /** - * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object. - * @param {string} events One or more events, separated by white space to trigger by invoking the returned function. - * @returns {function} Calling the function will invoke the previously specified events on the events object. - */ - proxy(events: string): Function; - - /** - * Adds eventing capabilities to the specified object. - * @param {object} targetObject The object to add eventing capabilities to. - */ - static includeIn(targetObject: any): void; - } - - export = Events; + var theModule: DurandalEventModule; + export = theModule; } /** @@ -389,7 +335,7 @@ declare module 'durandal/binder' { * @param {object} [obj] The data to bind to, causing the creation of a child binding context if present. */ export function bindContext(bindingContext: KnockoutBindingContext, view: HTMLElement, obj?: any): BindingInstruction; - + /** * Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context. * @param {object} obj The data to bind to. @@ -407,136 +353,12 @@ declare module 'durandal/binder' { * @requires knockout */ declare module 'durandal/activator' { - interface ActivatorSettings { - /** - * The default value passed to an object's deactivate function as its close parameter. - * @default true - */ - closeOnDeactivate: boolean; - - /** - * Lower-cased words which represent a truthy value. - * @default ['yes', 'ok', 'true'] - */ - affirmations: string[]; - - /** - * Interprets the response of a `canActivate` or `canDeactivate` call using the known affirmative values in the `affirmations` array. - * @param {object} value - * @returns {boolean} - */ - interpretResponse(value: any): boolean; - - /** - * Determines whether or not the current item and the new item are the same. - * @param {object} currentItem - * @param {object} newItem - * @param {object} currentActivationData - * @param {object} newActivationData - * @returns {boolean} - */ - areSameItem(currentItem: any, newItem: any, currentActivationData: any, newActivationData: any): boolean; - - /** - * Called immediately before the new item is activated. - * @param {object} newItem - */ - beforeActivate(newItem: any): any; - - /** - * Called immediately after the old item is deactivated. - * @param {object} oldItem The previous item. - * @param {boolean} close Whether or not the previous item was closed. - * @param {function} setter The activate item setter function. - */ - afterDeactivate(oldItem: any, close: boolean, setter: Function): void; - } - - interface Activator extends KnockoutComputed { - /** - * The settings for this activator. - */ - settings: ActivatorSettings; - - /** - * An observable which indicates whether or not the activator is currently in the process of activating an instance. - * @returns {boolean} - */ - isActivating: KnockoutObservable; - - /** - * Determines whether or not the specified item can be deactivated. - * @param {object} item The item to check. - * @param {boolean} close Whether or not to check if close is possible. - * @returns {promise} - */ - canDeactivateItem(item: T, close: boolean): JQueryPromise; - - /** - * Deactivates the specified item. - * @param {object} item The item to deactivate. - * @param {boolean} close Whether or not to close the item. - * @returns {promise} - */ - deactivateItem(item: T, close: boolean): JQueryPromise; - - /** - * Determines whether or not the specified item can be activated. - * @param {object} item The item to check. - * @param {object} activationData Data associated with the activation. - * @returns {promise} - */ - canActivateItem(newItem: T, activationData?: any): JQueryPromise; - - /** - * Activates the specified item. - * @param {object} newItem The item to activate. - * @param {object} newActivationData Data associated with the activation. - * @returns {promise} - */ - activateItem(newItem: T, activationData?: any): JQueryPromise; - - /** - * Determines whether or not the activator, in its current state, can be activated. - * @returns {promise} - */ - canActivate(): JQueryPromise; - - /** - * Activates the activator, in its current state. - * @returns {promise} - */ - activate(): JQueryPromise; - - /** - * Determines whether or not the activator, in its current state, can be deactivated. - * @returns {promise} - */ - canDeactivate(close: boolean): JQueryPromise; - - /** - * Deactivates the activator, in its current state. - * @returns {promise} - */ - deactivate(close: boolean): JQueryPromise; - - /** - * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. - */ - includeIn(includeIn: any): void; - - /** - * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. - */ - forItems(items): Activator; - } - /** * The default settings used by activators. * @property {ActivatorSettings} defaults */ - export var defaults: ActivatorSettings; - + export var defaults: DurandalActivatorSettings; + /** * Creates a new activator. * @method create @@ -544,7 +366,7 @@ declare module 'durandal/activator' { * @param {ActivatorSettings} [settings] Per activator overrides of the default activator settings. * @returns {Activator} The created activator. */ - export function create(initialActiveItem?: T, settings?: ActivatorSettings): Activator; + export function create(initialActiveItem?: T, settings?: DurandalActivatorSettings): DurandalActivator; /** * Determines whether or not the provided object is an activator or not. @@ -568,7 +390,7 @@ declare module 'durandal/viewLocator' { * @param {string} [areasPath] Partial views are mapped to the "views" folder if not specified. Use this parameter to change their location. */ export function useConvention(modulesPath?: string, viewsPath?: string, areasPath?: string): void; - + /** * Maps an object instance to a view instance. * @param {object} obj The object to locate the view for. @@ -577,7 +399,7 @@ declare module 'durandal/viewLocator' { * @returns {Promise} A promise of the view. */ export function locateViewForObject(obj: any, area:string, elementsToSearch?: HTMLElement[]): JQueryPromise; - + /** * Converts a module id into a view id. By default the ids are the same. * @param {string} moduleId The module id. @@ -599,7 +421,7 @@ declare module 'durandal/viewLocator' { * @returns {string} The translated view id. */ export function translateViewIdToArea(viewId: string, area: string): string; - + /** * Locates the specified view. * @param {string|DOMElement} view A view. It will be immediately returned. @@ -608,7 +430,7 @@ declare module 'durandal/viewLocator' { * @returns {Promise} A promise of the view. */ export function locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; - + /** * Locates the specified view. * @param {string|DOMElement} viewUrlOrId A view url or view id to locate. @@ -725,100 +547,8 @@ declare module 'durandal/composition' { * @requires jquery */ declare module 'durandal/app' { - import Events = require('durandal/events'); - import ts = require('durandal/typescript'); - - /** - * The title of your application. - */ - export var title: string; - - /** - * Shows a dialog via the dialog plugin. - * @param {object|string} obj The object (or moduleId) to display as a dialog. - * @param {object} [activationData] The data that should be passed to the object upon activation. - * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. - * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. - */ - export function showDialog(obj: any, activationData?: any, context?: string):JQueryPromise; - - /** - * Shows a message box via the dialog plugin. - * @param {string} message The message to display in the dialog. - * @param {string} [title] The title message. - * @param {string[]} [options] The options to provide to the user. - * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. - */ - export function showMessage(message: string, title?: string, options?: string[]): JQueryPromise; - - /** - * Configures one or more plugins to be loaded and installed into the application. - * @method configurePlugins - * @param {object} config Keys are plugin names. Values can be truthy, to simply install the plugin, or a configuration object to pass to the plugin. - * @param {string} [baseUrl] The base url to load the plugins from. - */ - export function configurePlugins(config: Object, baseUrl?: string): void; - - /** - * Starts the application. - * @returns {promise} - */ - export function start(): JQueryPromise; - - /** - * Sets the root module/view for the application. - * @param {string} root The root view or module. - * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. - * @param {string} [applicationHost] The application host element id. By default the id 'applicationHost' will be used. - */ - export function setRoot(root: any, transition?: string, applicationHost?: string): void; - - /** - * Sets the root module/view for the application. - * @param {string} root The root view or module. - * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. - * @param {string} [applicationHost] The application host element. By default the id 'applicationHost' will be used. - */ - export function setRoot(root: any, transition?: string, applicationHost?: HTMLElement): void; - - /** - * Creates a subscription or registers a callback for the specified event. - * @param {string} events One or more events, separated by white space. - * @returns {Subscription} A subscription is returned. - */ - export function on(events: string): ts.EventSubscription; - - /** - * Creates a subscription or registers a callback for the specified event. - * @param {string} events One or more events, separated by white space. - * @param {function} [callback] The callback function to invoke when the event is triggered. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @returns {Events} The events object is returned for chaining. - */ - export function on(events: string, callback: Function, context?: any): Events; - - /** - * Removes the callbacks for the specified events. - * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed. - * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed. - * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed. - * @chainable - */ - export function off(events: string, callback: Function, context?: any): Events; - - /** - * Triggers the specified events. - * @param {string} [events] One or more events, separated by white space to trigger. - * @chainable - */ - export function trigger(events: string, ...eventArgs:any[]): Events; - - /** - * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object. - * @param {string} events One or more events, separated by white space to trigger by invoking the returned function. - * @returns {function} Calling the function will invoke the previously specified events on the events object. - */ - export function proxy(events: string): Function; + var theModule: DurandalAppModule; + export = theModule; } /** @@ -832,7 +562,6 @@ declare module 'durandal/app' { * @requires knockout */ declare module 'plugins/dialog' { - import activator = require('durandal/activator'); import composition = require('durandal/composition'); /** @@ -907,7 +636,7 @@ declare module 'plugins/dialog' { interface Dialog { owner: any; context: DialogContext; - activator: activator.Activator; + activator: DurandalActivator; close(): JQueryPromise; settings: composition.CompositionContext; } @@ -947,7 +676,7 @@ declare module 'plugins/dialog' { * @param {DialogContext} dialogContext The context to add. */ export function addContext(name: string, modalContext: DialogContext): void; - + /** * Gets the dialog model that is associated with the specified object. * @param {object} obj The object for whom to retrieve the dialog. @@ -958,9 +687,9 @@ declare module 'plugins/dialog' { /** * Closes the dialog associated with the specified object. * @param {object} obj The object whose dialog should be closed. - * @param {object} result* The results to return back to the dialog caller after closing. + * @param {object} results* The results to return back to the dialog caller after closing. */ - export function close(obj: any): void; + export function close(obj: any, ...results: any[]): void; /** * Shows a dialog. @@ -993,41 +722,6 @@ declare module 'plugins/dialog' { * @requires jquery */ declare module 'plugins/history' { - interface HistoryOptions { - /** - * The function that will be called back when the fragment changes. - */ - routeHandler: (fragment: string) => void; - - /** - * The url root used to extract the fragment when using push state. - */ - root?: string; - - /** - * Use hash change when present. - * @default true - */ - hashChange?: boolean; - - /** - * Use push state when present. - * @default false - */ - pushState?: boolean; - - /** - * Prevents loading of the current url when activating history. - * @default false - */ - silent?: boolean; - } - - interface NavigationOptions { - trigger: boolean; - replace: boolean; - } - /** * The setTimeout interval used when the browser does not support hash change events. * @default 50 @@ -1059,7 +753,7 @@ declare module 'plugins/history' { * @param {HistoryOptions} options. * @returns {boolean|undefined} Returns true/false from loading the url unless the silent option was selected. */ - export function activate(options: HistoryOptions): boolean; + export function activate(options: DurandalHistoryOptions): boolean; /** * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. @@ -1102,7 +796,7 @@ declare module 'plugins/history' { * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. * @return {boolean} Returns true/false from loading the url. */ - export function navigate(fragment: string, options: NavigationOptions): boolean; + export function navigate(fragment: string, options: DurandalNavigationOptions): boolean; /** * Navigates back in the browser history. @@ -1121,7 +815,7 @@ declare module 'plugins/http' { * @default callback */ export var callbackParam: string; - + /** * Makes an HTTP GET request. * @param {string} url The url to send the get request to. @@ -1138,7 +832,7 @@ declare module 'plugins/http' { * @returns {Promise} A promise of the response data. */ export function jsonp(url: string, query?: Object, callbackParam?: string): JQueryPromise; - + /** * Makes an HTTP POST request. * @param {string} url The url to send the post request to. @@ -1395,324 +1089,571 @@ declare module 'plugins/widget' { * @requires jquery */ declare module 'plugins/router' { - import activator = require('durandal/activator'); - import Events = require('durandal/events'); - import ts = require('durandal/typescript'); - - var RootRouter: ts.RootRouter; - - export = RootRouter; + var theModule: DurandalRootRouter; + export = theModule; } -/** - * Interface definitions used by other modules which were not possible to define within those modules due to TypeScript limitations. - */ -declare module 'durandal/typescript' { - import activator = require('durandal/activator'); - import history = require('plugins/history'); +interface DurandalEventSubscription { + /** + * Attaches a callback to the event subscription. + * @param {function} callback The callback function to invoke when the event is triggered. + * @param {object} [context] An object to use as `this` when invoking the `callback`. + * @chainable + */ + then(thenCallback: Function, context?: any): DurandalEventSubscription; /** - * Represents an event subscription. - * @class - */ - export interface EventSubscription { - /** - * Attaches a callback to the event subscription. - * @param {function} callback The callback function to invoke when the event is triggered. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @chainable - */ - then(thenCallback: Function, context?: any): EventSubscription; + * Attaches a callback to the event subscription. + * @param {function} [callback] The callback function to invoke when the event is triggered. If `callback` is not provided, the previous callback will be re-activated. + * @param {object} [context] An object to use as `this` when invoking the `callback`. + * @chainable + */ + on(thenCallback: Function, context?: any): DurandalEventSubscription; - /** - * Attaches a callback to the event subscription. - * @param {function} [callback] The callback function to invoke when the event is triggered. If `callback` is not provided, the previous callback will be re-activated. - * @param {object} [context] An object to use as `this` when invoking the `callback`. - * @chainable - */ - on(thenCallback: Function, context?: any): EventSubscription; - - /** - * Cancels the subscription. - * @chainable - */ - off(): EventSubscription; - } - - export interface RouteConfiguration { - title?: string; - moduleId?: string; - hash?: string; - routePattern?: RegExp; - isActive?: KnockoutComputed; - } - - export interface RouteInstruction { - fragment: string; - queryString: string; - config: RouteConfiguration; - params: any[]; - queryParams: Object; - } - - export interface RelativeRouteSettings { - moduleId?: string; - route?: string; - fromParent?: boolean; - } - - export interface Router { - /** - * The route handlers that are registered. Each handler consists of a `routePattern` and a `callback`. - */ - handlers: { routePattern: RegExp; callback: (fragment: string) => void; }[]; - - /** - * The route configs that are registered. - */ - routes: RouteConfiguration[]; - - /** - * The active item/screen based on the current navigation state. - */ - activeItem: activator.Activator; - - /** - * The route configurations that have been designated as displayable in a nav ui (nav:true). - */ - navigationModel: KnockoutObservableArray; - - /** - * Indicates that the router (or a child router) is currently in the process of navigating. - */ - isNavigating: KnockoutComputed; - - /** - * An observable surfacing the active routing instruction that is currently being processed or has recently finished processing. - * The instruction object has `config`, `fragment`, `queryString`, `params` and `queryParams` properties. - */ - activeInstruction: KnockoutObservable; - - /** - * Parses a query string into an object. - * @param {string} queryString The query string to parse. - * @returns {object} An object keyed according to the query string parameters. - */ - parseQueryString(queryString: string): Object; - - /** - * Add a route to be tested when the url fragment changes. - * @param {RegEx} routePattern The route pattern to test against. - * @param {function} callback The callback to execute when the route pattern is matched. - */ - route(routePattern: RegExp, callback: (fragment: string) => void ): void; - - /** - * Attempt to load the specified URL fragment. If a route succeeds with a match, returns `true`. If no defined routes matches the fragment, returns `false`. - * @param {string} fragment The URL fragment to find a match for. - * @returns {boolean} True if a match was found, false otherwise. - */ - loadUrl(fragment: string): boolean; - - /** - * Updates the document title based on the activated module instance, the routing instruction and the app.title. - * @param {object} instance The activated module. - * @param {object} instruction The routing instruction associated with the action. It has a `config` property that references the original route mapping config. - */ - updateDocumentTitle(instance: Object, instruction: RouteInstruction): void; - - /** - * Save a fragment into the hash history, or replace the URL state if the - * 'replace' option is passed. You are responsible for properly URL-encoding - * the fragment in advance. - * The options object can contain `trigger: false` if you wish to not have the - * route callback be fired, or `replace: true`, if - * you wish to modify the current URL without adding an entry to the history. - * @param {string} fragment The url fragment to navigate to. - * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. - * @return {boolean} Returns true/false from loading the url. - */ - navigate(fragment: string, trigger?: boolean): boolean; - - /** - * Save a fragment into the hash history, or replace the URL state if the - * 'replace' option is passed. You are responsible for properly URL-encoding - * the fragment in advance. - * The options object can contain `trigger: false` if you wish to not have the - * route callback be fired, or `replace: true`, if - * you wish to modify the current URL without adding an entry to the history. - * @param {string} fragment The url fragment to navigate to. - * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. - * @return {boolean} Returns true/false from loading the url. - */ - navigate(fragment: string, options: history.NavigationOptions): boolean; - - /** - * Navigates back in the browser history. - */ - navigateBack(): void; - - /** - * Converts a route to a hash suitable for binding to a link's href. - * @param {string} route - * @returns {string} The hash. - */ - convertRouteToHash(route: string): string; - - /** - * Converts a route to a module id. This is only called if no module id is supplied as part of the route mapping. - * @param {string} route - * @returns {string} The module id. - */ - convertRouteToModuleId(route: string): string; - - /** - * Converts a route to a displayable title. This is only called if no title is specified as part of the route mapping. - * @method convertRouteToTitle - * @param {string} route - * @returns {string} The title. - */ - convertRouteToTitle(route: string): string; - - /** - * Maps route patterns to modules. - * @param {string} route A route. - * @chainable - */ - map(route: string): Router; - - /** - * Maps route patterns to modules. - * @param {string} route A route pattern. - * @param {string} moduleId The module id to map the route to. - * @chainable - */ - map(route: string, moduleId: string): Router; - - /** - * Maps route patterns to modules. - * @param {RegExp} route A route pattern. - * @param {string} moduleId The module id to map the route to. - * @chainable - */ - map(route: RegExp, moduleId: string): Router; - - /** - * Maps route patterns to modules. - * @param {string} route A route pattern. - * @param {RouteConfiguration} config The route's configuration. - * @chainable - */ - map(route: string, config: RouteConfiguration): Router; - - /** - * Maps route patterns to modules. - * @method map - * @param {RegExp} route A route pattern. - * @param {RouteConfiguration} config The route's configuration. - * @chainable - */ - map(route: RegExp, config: RouteConfiguration): Router; - - /** - * Maps route patterns to modules. - * @param {RouteConfiguration} config The route's configuration. - * @chainable - */ - map(config: RouteConfiguration): Router; - - /** - * Maps route patterns to modules. - * @param {RouteConfiguration[]} configs An array of route configurations. - * @chainable - */ - map(configs: RouteConfiguration[]): Router; - - /** - * Builds an observable array designed to bind a navigation UI to. The model will exist in the `navigationModel` property. - * @param {number} defaultOrder The default order to use for navigation visible routes that don't specify an order. The defualt is 100. - * @chainable - */ - buildNavigationModel(defaultOrder?: number): Router; - - /** - * Configures the router to map unknown routes to modules at the same path. - * @chainable - */ - mapUnknownRoutes(): Router; - - /** - * Configures the router use the specified module id for all unknown routes. - * @param {string} notFoundModuleId Represents the module id to route all unknown routes to. - * @param {string} [replaceRoute] Optionally provide a route to replace the url with. - * @chainable - */ - mapUnknownRoutes(notFoundModuleId: string, replaceRoute?: string): Router; - - /** - * Configures how the router will handle unknown routes. - * @param {function} callback Called back with the route instruction containing the route info. The function can then modify the instruction by adding a moduleId and the router will take over from there. - * @chainable - */ - mapUnknownRoutes(callback: (instruction: RouteInstruction) => void ): Router; - - /** - * Configures how the router will handle unknown routes. - * @param {RouteConfiguration} config The route configuration to use for unknown routes. - * @chainable - */ - mapUnknownRoutes(config: RouteConfiguration): Router; - - /** - * Resets the router by removing handlers, routes, event handlers and previously configured options. - * @chainable - */ - reset(): Router; - - /** - * Makes all configured routes and/or module ids relative to a certain base url. - * @param {string} settings The value is used as the base for routes and module ids. - * @chainable - */ - makeRelative(settings: string): Router; - - /** - * Makes all configured routes and/or module ids relative to a certain base url. - * @param {RelativeRouteSettings} settings If an object, you can specify `route` and `moduleId` separately. In place of specifying route, you can set `fromParent:true` to make routes automatically relative to the parent router's active route. - * @chainable - */ - makeRelative(settings: RelativeRouteSettings): Router; - - /** - * Creates a child router. - * @returns {Router} The child router. - */ - createChildRouter(): Router; - - /** - * Inspects routes and modules before activation. Can be used to protect access by cancelling navigation or redirecting. - * @param {object} instance The module instance that is about to be activated by the router. - * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. - * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. - */ - guardRoute?:(instance:Object, instruction:RouteInstruction) => any; - } - - export interface RootRouter extends Router { - /** - * Activates the router and the underlying history tracking mechanism. - * @returns {Promise} A promise that resolves when the router is ready. - */ - activate(options?: history.HistoryOptions): JQueryPromise; - - /** - * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. - */ - deactivate(): void; - - /** - * Installs the router's custom ko binding handler. - */ - install(): void; - } + /** + * Cancels the subscription. + * @chainable + */ + off(): DurandalEventSubscription; } + +interface DurandalEventSupport { + /** + * Creates a subscription or registers a callback for the specified event. + * @param {string} events One or more events, separated by white space. + * @returns {Subscription} A subscription is returned. + */ + on(events: string): DurandalEventSubscription; + + /** + * Creates a subscription or registers a callback for the specified event. + * @param {string} events One or more events, separated by white space. + * @param {function} [callback] The callback function to invoke when the event is triggered. + * @param {object} [context] An object to use as `this` when invoking the `callback`. + * @returns {Events} The events object is returned for chaining. + */ + on(events: string, callback: Function, context?: any): T; + + /** + * Removes the callbacks for the specified events. + * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed. + * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed. + * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed. + * @chainable + */ + off(events: string, callback: Function, context?: any): T; + + /** + * Triggers the specified events. + * @param {string} [events] One or more events, separated by white space to trigger. + * @chainable + */ + trigger(events: string, ...eventArgs: any[]): T; + + /** + * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object. + * @param {string} events One or more events, separated by white space to trigger by invoking the returned function. + * @returns {function} Calling the function will invoke the previously specified events on the events object. + */ + proxy(events: string): Function; +} + +interface DurandalEventModule { + new (): DurandalEventSupport; + includeIn(targetObject: any): void; +} + +interface DurandalAppModule extends DurandalEventSupport { + /** + * The title of your application. + */ + title: string; + + /** + * Shows a dialog via the dialog plugin. + * @param {object|string} obj The object (or moduleId) to display as a dialog. + * @param {object} [activationData] The data that should be passed to the object upon activation. + * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. + * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. + */ + showDialog(obj: any, activationData?: any, context?: string): JQueryPromise; + + /** + * Shows a message box via the dialog plugin. + * @param {string} message The message to display in the dialog. + * @param {string} [title] The title message. + * @param {string[]} [options] The options to provide to the user. + * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. + */ + showMessage(message: string, title?: string, options?: string[]): JQueryPromise; + + /** + * Configures one or more plugins to be loaded and installed into the application. + * @method configurePlugins + * @param {object} config Keys are plugin names. Values can be truthy, to simply install the plugin, or a configuration object to pass to the plugin. + * @param {string} [baseUrl] The base url to load the plugins from. + */ + configurePlugins(config: Object, baseUrl?: string): void; + + /** + * Starts the application. + * @returns {promise} + */ + start(): JQueryPromise; + + /** + * Sets the root module/view for the application. + * @param {string} root The root view or module. + * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. + * @param {string} [applicationHost] The application host element id. By default the id 'applicationHost' will be used. + */ + setRoot(root: any, transition?: string, applicationHost?: string): void; + + /** + * Sets the root module/view for the application. + * @param {string} root The root view or module. + * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root. + * @param {string} [applicationHost] The application host element. By default the id 'applicationHost' will be used. + */ + setRoot(root: any, transition?: string, applicationHost?: HTMLElement): void; +} + +interface DurandalActivatorSettings { + /** + * The default value passed to an object's deactivate function as its close parameter. + * @default true + */ + closeOnDeactivate: boolean; + + /** + * Lower-cased words which represent a truthy value. + * @default ['yes', 'ok', 'true'] + */ + affirmations: string[]; + + /** + * Interprets the response of a `canActivate` or `canDeactivate` call using the known affirmative values in the `affirmations` array. + * @param {object} value + * @returns {boolean} + */ + interpretResponse(value: any): boolean; + + /** + * Determines whether or not the current item and the new item are the same. + * @param {object} currentItem + * @param {object} newItem + * @param {object} currentActivationData + * @param {object} newActivationData + * @returns {boolean} + */ + areSameItem(currentItem: any, newItem: any, currentActivationData: any, newActivationData: any): boolean; + + /** + * Called immediately before the new item is activated. + * @param {object} newItem + */ + beforeActivate(newItem: any): any; + + /** + * Called immediately after the old item is deactivated. + * @param {object} oldItem The previous item. + * @param {boolean} close Whether or not the previous item was closed. + * @param {function} setter The activate item setter function. + */ + afterDeactivate(oldItem: any, close: boolean, setter: Function): void; +} + +interface DurandalActivator extends KnockoutComputed { + /** + * The settings for this activator. + */ + settings: DurandalActivatorSettings; + + /** + * An observable which indicates whether or not the activator is currently in the process of activating an instance. + * @returns {boolean} + */ + isActivating: KnockoutObservable; + + /** + * Determines whether or not the specified item can be deactivated. + * @param {object} item The item to check. + * @param {boolean} close Whether or not to check if close is possible. + * @returns {promise} + */ + canDeactivateItem(item: T, close: boolean): JQueryPromise; + + /** + * Deactivates the specified item. + * @param {object} item The item to deactivate. + * @param {boolean} close Whether or not to close the item. + * @returns {promise} + */ + deactivateItem(item: T, close: boolean): JQueryPromise; + + /** + * Determines whether or not the specified item can be activated. + * @param {object} item The item to check. + * @param {object} activationData Data associated with the activation. + * @returns {promise} + */ + canActivateItem(newItem: T, activationData?: any): JQueryPromise; + + /** + * Activates the specified item. + * @param {object} newItem The item to activate. + * @param {object} newActivationData Data associated with the activation. + * @returns {promise} + */ + activateItem(newItem: T, activationData?: any): JQueryPromise; + + /** + * Determines whether or not the activator, in its current state, can be activated. + * @returns {promise} + */ + canActivate(): JQueryPromise; + + /** + * Activates the activator, in its current state. + * @returns {promise} + */ + activate(): JQueryPromise; + + /** + * Determines whether or not the activator, in its current state, can be deactivated. + * @returns {promise} + */ + canDeactivate(close: boolean): JQueryPromise; + + /** + * Deactivates the activator, in its current state. + * @returns {promise} + */ + deactivate(close: boolean): JQueryPromise; + + /** + * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. + */ + includeIn(includeIn: any): void; + + /** + * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. + */ + forItems(items): DurandalActivator; +} + +interface DurandalHistoryOptions { + /** + * The function that will be called back when the fragment changes. + */ + routeHandler: (fragment: string) => void; + + /** + * The url root used to extract the fragment when using push state. + */ + root?: string; + + /** + * Use hash change when present. + * @default true + */ + hashChange?: boolean; + + /** + * Use push state when present. + * @default false + */ + pushState?: boolean; + + /** + * Prevents loading of the current url when activating history. + * @default false + */ + silent?: boolean; +} + +interface DurandalNavigationOptions { + trigger: boolean; + replace: boolean; +} + +interface DurandalRouteConfiguration { + title?: string; + moduleId?: string; + hash?: string; + route?: string; + routePattern?: RegExp; + isActive?: KnockoutComputed; + nav:any; +} + +interface DurandalRouteInstruction { + fragment: string; + queryString: string; + config: DurandalRouteConfiguration; + params: any[]; + queryParams: Object; +} + +interface DurandalRelativeRouteSettings { + moduleId?: string; + route?: string; + fromParent?: boolean; +} + +interface DurandalRouterBase extends DurandalEventSupport { + /** + * The route handlers that are registered. Each handler consists of a `routePattern` and a `callback`. + */ + handlers: { routePattern: RegExp; callback: (fragment: string) => void; }[]; + + /** + * The route configs that are registered. + */ + routes: DurandalRouteConfiguration[]; + + /** + * The active item/screen based on the current navigation state. + */ + activeItem: DurandalActivator; + + /** + * The route configurations that have been designated as displayable in a nav ui (nav:true). + */ + navigationModel: KnockoutObservableArray; + + /** + * Indicates that the router (or a child router) is currently in the process of navigating. + */ + isNavigating: KnockoutComputed; + + /** + * An observable surfacing the active routing instruction that is currently being processed or has recently finished processing. + * The instruction object has `config`, `fragment`, `queryString`, `params` and `queryParams` properties. + */ + activeInstruction: KnockoutObservable; + + /** + * Parses a query string into an object. + * @param {string} queryString The query string to parse. + * @returns {object} An object keyed according to the query string parameters. + */ + parseQueryString(queryString: string): Object; + + /** + * Add a route to be tested when the url fragment changes. + * @param {RegEx} routePattern The route pattern to test against. + * @param {function} callback The callback to execute when the route pattern is matched. + */ + route(routePattern: RegExp, callback: (fragment: string) => void): void; + + /** + * Attempt to load the specified URL fragment. If a route succeeds with a match, returns `true`. If no defined routes matches the fragment, returns `false`. + * @param {string} fragment The URL fragment to find a match for. + * @returns {boolean} True if a match was found, false otherwise. + */ + loadUrl(fragment: string): boolean; + + /** + * Updates the document title based on the activated module instance, the routing instruction and the app.title. + * @param {object} instance The activated module. + * @param {object} instruction The routing instruction associated with the action. It has a `config` property that references the original route mapping config. + */ + updateDocumentTitle(instance: Object, instruction: DurandalRouteInstruction): void; + + /** + * Save a fragment into the hash history, or replace the URL state if the + * 'replace' option is passed. You are responsible for properly URL-encoding + * the fragment in advance. + * The options object can contain `trigger: false` if you wish to not have the + * route callback be fired, or `replace: true`, if + * you wish to modify the current URL without adding an entry to the history. + * @param {string} fragment The url fragment to navigate to. + * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. + * @return {boolean} Returns true/false from loading the url. + */ + navigate(fragment: string, trigger?: boolean): boolean; + + /** + * Save a fragment into the hash history, or replace the URL state if the + * 'replace' option is passed. You are responsible for properly URL-encoding + * the fragment in advance. + * The options object can contain `trigger: false` if you wish to not have the + * route callback be fired, or `replace: true`, if + * you wish to modify the current URL without adding an entry to the history. + * @param {string} fragment The url fragment to navigate to. + * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default. + * @return {boolean} Returns true/false from loading the url. + */ + navigate(fragment: string, options: DurandalNavigationOptions): boolean; + + /** + * Navigates back in the browser history. + */ + navigateBack(): void; + + /** + * Converts a route to a hash suitable for binding to a link's href. + * @param {string} route + * @returns {string} The hash. + */ + convertRouteToHash(route: string): string; + + /** + * Converts a route to a module id. This is only called if no module id is supplied as part of the route mapping. + * @param {string} route + * @returns {string} The module id. + */ + convertRouteToModuleId(route: string): string; + + /** + * Converts a route to a displayable title. This is only called if no title is specified as part of the route mapping. + * @method convertRouteToTitle + * @param {string} route + * @returns {string} The title. + */ + convertRouteToTitle(route: string): string; + + /** + * Maps route patterns to modules. + * @param {string} route A route. + * @chainable + */ + map(route: string): T; + + /** + * Maps route patterns to modules. + * @param {string} route A route pattern. + * @param {string} moduleId The module id to map the route to. + * @chainable + */ + map(route: string, moduleId: string): T; + + /** + * Maps route patterns to modules. + * @param {RegExp} route A route pattern. + * @param {string} moduleId The module id to map the route to. + * @chainable + */ + map(route: RegExp, moduleId: string): T; + + /** + * Maps route patterns to modules. + * @param {string} route A route pattern. + * @param {RouteConfiguration} config The route's configuration. + * @chainable + */ + map(route: string, config: DurandalRouteConfiguration): T; + + /** + * Maps route patterns to modules. + * @method map + * @param {RegExp} route A route pattern. + * @param {RouteConfiguration} config The route's configuration. + * @chainable + */ + map(route: RegExp, config: DurandalRouteConfiguration): T; + + /** + * Maps route patterns to modules. + * @param {RouteConfiguration} config The route's configuration. + * @chainable + */ + map(config: DurandalRouteConfiguration): T; + + /** + * Maps route patterns to modules. + * @param {RouteConfiguration[]} configs An array of route configurations. + * @chainable + */ + map(configs: DurandalRouteConfiguration[]): T; + + /** + * Builds an observable array designed to bind a navigation UI to. The model will exist in the `navigationModel` property. + * @param {number} defaultOrder The default order to use for navigation visible routes that don't specify an order. The defualt is 100. + * @chainable + */ + buildNavigationModel(defaultOrder?: number): T; + + /** + * Configures the router to map unknown routes to modules at the same path. + * @chainable + */ + mapUnknownRoutes(): T; + + /** + * Configures the router use the specified module id for all unknown routes. + * @param {string} notFoundModuleId Represents the module id to route all unknown routes to. + * @param {string} [replaceRoute] Optionally provide a route to replace the url with. + * @chainable + */ + mapUnknownRoutes(notFoundModuleId: string, replaceRoute?: string): T; + + /** + * Configures how the router will handle unknown routes. + * @param {function} callback Called back with the route instruction containing the route info. The function can then modify the instruction by adding a moduleId and the router will take over from there. + * @chainable + */ + mapUnknownRoutes(callback: (instruction: DurandalRouteInstruction) => void): T; + + /** + * Configures how the router will handle unknown routes. + * @param {RouteConfiguration} config The route configuration to use for unknown routes. + * @chainable + */ + mapUnknownRoutes(config: DurandalRouteConfiguration): T; + + /** + * Resets the router by removing handlers, routes, event handlers and previously configured options. + * @chainable + */ + reset(): T; + + /** + * Makes all configured routes and/or module ids relative to a certain base url. + * @param {string} settings The value is used as the base for routes and module ids. + * @chainable + */ + makeRelative(settings: string): T; + + /** + * Makes all configured routes and/or module ids relative to a certain base url. + * @param {RelativeRouteSettings} settings If an object, you can specify `route` and `moduleId` separately. In place of specifying route, you can set `fromParent:true` to make routes automatically relative to the parent router's active route. + * @chainable + */ + makeRelative(settings: DurandalRelativeRouteSettings): T; + + /** + * Creates a child router. + * @returns {Router} The child router. + */ + createChildRouter(): T; + + /** + * Inspects routes and modules before activation. Can be used to protect access by cancelling navigation or redirecting. + * @param {object} instance The module instance that is about to be activated by the router. + * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. + * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. + */ + guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => any; +} + +interface DurandalRouter extends DurandalRouterBase { } + +interface DurandalRootRouter extends DurandalRouterBase { + /** + * Activates the router and the underlying history tracking mechanism. + * @returns {Promise} A promise that resolves when the router is ready. + */ + activate(options?: DurandalHistoryOptions): JQueryPromise; + + /** + * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. + */ + deactivate(): void; + + /** + * Installs the router's custom ko binding handler. + */ + install(): void; +} \ No newline at end of file diff --git a/durandal/durandal.d.ts.tscparams b/durandal/durandal.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/durandal/durandal.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dustjs-linkedin/dustjs-linkedin-tests.ts.tscparams b/dustjs-linkedin/dustjs-linkedin-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dustjs-linkedin/dustjs-linkedin-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/dustjs-linkedin/dustjs-linkedin.d.ts.tscparams b/dustjs-linkedin/dustjs-linkedin.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/dustjs-linkedin/dustjs-linkedin.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ember/ember-tests.ts.tscparams b/ember/ember-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ember/ember-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 2ef232644..574bb3b9f 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -2728,13 +2728,13 @@ declare module Ember { (target: any, method: Function): void; begin(): void; cancel(timer: any): void; - debounce(target: any, method: Function, wait: number, immediate: boolean): void; - debounce(target: any, method: string, wait: number, immediate: boolean): void; + debounce(target: any, method: Function, ...args: any[]): void; + debounce(target: any, method: string, ...args: any[]): void; end(): void; join(target: any, method: Function, ...any): any; join(target: any, method: string, ...any): any; - later(target: any, method: Function, wait: boolean): string; - later(target: any, method: string, wait: boolean): string; + later(target: any, method: Function, ...args: any[]): string; + later(target: any, method: string, ...args: any[]): string; next(target: any, method: Function, ...any): number; next(target: any, method: string, ...any): number; once(target: any, method: Function, ...any): number; @@ -2744,8 +2744,8 @@ declare module Ember { scheduleOnce(queue: string, target: any, method: Function, ...any): void; scheduleOnce(queue: string, target: any, method: string, ...any): void; sync(): void; - throttle(target: any, method: Function, spacing: number): void; - throttle(target: any, method: string, spacing: number): void; + throttle(target: any, method: Function, ...args: any[]): void; + throttle(target: any, method: string, ...args: any[]): void; queues: any[]; }; function runLoadHooks(name: string, object: any): void; diff --git a/ember/ember.d.ts.tscparams b/ember/ember.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/ember/ember.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/epiceditor/epiceditor-tests.ts.tscparams b/epiceditor/epiceditor-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/epiceditor/epiceditor-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/epiceditor/epiceditor.d.ts.tscparams b/epiceditor/epiceditor.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/epiceditor/epiceditor.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/expect.js/expect.js-tests.ts.tscparams b/expect.js/expect.js-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/expect.js/expect.js-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/expect.js/expect.js.d.ts b/expect.js/expect.js.d.ts index c943f4e4f..82f85b19d 100644 --- a/expect.js/expect.js.d.ts +++ b/expect.js/expect.js.d.ts @@ -10,35 +10,35 @@ declare module Expect { /** * Check if the value is truthy */ - ok(); + ok(): void; /** * Assert that the function throws. * * @param fn callback to match error string against */ - throwError(fn?: Function); + throwError(fn?: Function): void; /** * Assert that the function throws. * * @param fn callback to match error string against */ - throwException(fn?: Function); + throwException(fn?: Function): void; /** * Assert that the function throws. * * @param regexp regexp to match error string against */ - throwError(regexp: RegExp); + throwError(regexp: RegExp): void; /** * Assert that the function throws. * * @param fn callback to match error string against */ - throwException(regexp: RegExp); + throwException(regexp: RegExp): void; /** * Checks if the array is empty. diff --git a/express/express-tests.ts.tscparams b/express/express-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/express/express-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/extjs/ExtJS-tests.ts.tscparams b/extjs/ExtJS-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/extjs/ExtJS-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/fabricjs/fabricjs-tests.ts.tscparams b/fabricjs/fabricjs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/fabricjs/fabricjs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/fabricjs/fabricjs.d.ts.tscparams b/fabricjs/fabricjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/fabricjs/fabricjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/fancybox/fancybox-tests.ts.tscparams b/fancybox/fancybox-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/fancybox/fancybox-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/fancybox/fancybox.d.ts.tscparams b/fancybox/fancybox.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/fancybox/fancybox.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/firebase/firebase-tests.ts.tscparams b/firebase/firebase-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/firebase/firebase-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/firebase/firebase.d.ts.tscparams b/firebase/firebase.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/firebase/firebase.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/firefox/firefox-tests.ts.tscparams b/firefox/firefox-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/firefox/firefox-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/firefox/firefox.d.ts b/firefox/firefox.d.ts index dd052f1a8..37dacbe95 100644 --- a/firefox/firefox.d.ts +++ b/firefox/firefox.d.ts @@ -33,7 +33,7 @@ interface App { installTime:number; receipts:any[]; - launch(); + launch():void; checkForUpdate():DOMRequest; } diff --git a/flexSlider/flexSlider-tests.ts.tscparams b/flexSlider/flexSlider-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/flexSlider/flexSlider-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/flexSlider/flexSlider.d.ts.tscparams b/flexSlider/flexSlider.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/flexSlider/flexSlider.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/flight/flight-tests.ts b/flight/flight-tests.ts new file mode 100644 index 000000000..1bfe68d3a --- /dev/null +++ b/flight/flight-tests.ts @@ -0,0 +1,49 @@ +/// +declare var el: Element; +declare var els: Element[]; +declare var mixinFn: Function; + +function TestComponent() { + var self: Flight.Component = this; + + self.defaultAttrs({ + fooSelector: '.bar' + }); + + this.onClick = function (ev: JQueryEventObject, data: Flight.EventData) { + var el: HTMLElement = data.el; + self.select('fooSelector').addClass('bar'); + }; + + self.around('initialize', function () { }); + self.before('initialize', function () { }); + self.after("initialize", function () { + + var $node: JQuery = self.$node; + var node: Element = self.node; + + self.on(el, 'click', {}); + self.on(els, 'click', function () { }); + self.on(document, 'click', this.onClick); + self.on('click', function () { }); + self.on('click', { + fooSelector: this.onClick + }); + + self.off('click', function () { }); + self.off(document, 'click'); + self.off(el, 'click') + self.off(els, 'click'); + + self.teardown(); + }); +} + +flight.component(TestComponent, mixinFn).attachTo(el); +flight.component(TestComponent, mixinFn).attachTo($(els)); +flight.component(TestComponent, mixinFn).attachTo('.test'); +flight.component(TestComponent, mixinFn).attachTo('.test', { + some: 'data' +}); + +flight.component.teardownAll(); diff --git a/flight/flight.d.ts b/flight/flight.d.ts new file mode 100644 index 000000000..a00f6d958 --- /dev/null +++ b/flight/flight.d.ts @@ -0,0 +1,238 @@ +/// + +// Type definitions for Flight 1.1.1 +// Project: http://flightjs.github.com/flight/ +// Definitions by: Jonathan Hedrén +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Flight { + + export interface Base { + + /** + * Most Components and Mixins need to define attributes. In Flight, + * default values are assigned by passing an object to the defaultAttrs + * function. + */ + defaultAttrs(obj: Object): void; + + /** + * The select method takes an attr key as its argument. The value of the + * attr must be a CSS Selector. The method will return all matching + * elements within the component's node. + * + * This is a handy alternative to jQuery's this.$node.find() and prevents + * accidental access to elements outside of the component's node. + * + * @param attr + */ + select(attr: string): JQuery; + + /** + * This method is attached to the prototype of every Component; it accepts + * the component's node and an options object as arguments. The core + * implementation, which is called every time an instance is created, will + * assign the node to the instance and override the default attrs with the + * options object. + * + * Components and Mixins will typically augment the core implementation by + * supplying a function as an argument to the after method (see the advice + * API for more information). This is a good place to set up event + * listeners that bind to callbacks. + */ + initialize(node: any, options: Object): void; + + /** + * This allows a component instance to listen to an event and register a + * callback to be invoked. Flight will automatically bind the context + * (this) of the callback to the component instance. + * + * @param selector Optional. Specify the DOM node(s) that should listen + * for the event. Defaults to the component instance's node value. + * + * @param eventType The event type to listen for. + * + * @param handler Either a function (callback) to be invoked, or a map of + * targets and callbacks. + */ + on(eventType: string, handler: Function): void; + on(eventType: string, handler: Object): void; + on(selector: string, eventType: string, handler: Function): void; + on(selector: Document, eventType: string, handler: Function): void; + on(selector: Element, eventType: string, handler: Function): void; + on(selector: Element[], eventType: string, handler: Function): void; + on(selector: string, eventType: string, handler: Object): void; + on(selector: Document, eventType: string, handler: Object): void; + on(selector: Element, eventType: string, handler: Object): void; + on(selector: Element[], eventType: string, handler: Object): void; + + /** + * If we no longer want a component instance to listen to an event we can + * use the off method to unsubscribe. + * + * @param selector Optional. The DOM node(s) listening for the event. + * Defaults to the component instance's node value. + * + * @param eventType The event type being listened to. + * + * @param handler Optional. The function (callback) to detach from the + * component instance. Defaults to the detaching all callbacks for the event. + */ + off(eventType: string, handler?: Function): void; + off(selector: string, eventType: string, handler?: Function): void; + off(selector: Document, eventType: string, handler?: Function): void; + off(selector: Element, eventType: string, handler?: Function): void; + off(selector: Element[], eventType: string, handler?: Function): void; + off(selector: string, eventType: Object, handler?: Function): void; + off(selector: Document, eventType: Object, handler?: Function): void; + off(selector: Element, eventType: Object, handler?: Function): void; + off(selector: Element[], eventType: Object, handler?: Function): void; + off(selector: string, eventType: string, handler?: Object): void; + off(selector: Document, eventType: string, handler?: Object): void; + off(selector: Element, eventType: string, handler?: Object): void; + off(selector: Element[], eventType: string, handler?: Object): void; + off(selector: string, eventType: Object, handler?: Object): void; + off(selector: Document, eventType: Object, handler?: Object): void; + off(selector: Element, eventType: Object, handler?: Object): void; + off(selector: Element[], eventType: Object, handler?: Object): void; + + /** + * Trigger an event. + * + * @param selector Optional. The DOM node(s) that the event will be + * dispatched to. Defaults to the component instance's node value. + * + * @param eventType String. The event type to be triggered. + * + * You can also specify a default function that will be called by the + * component, providing that nothing in the event's bubble chain invokes + * preventDefault. Default functions in custom events are analagous to the + * default actions of native events. + * + * To define a default function, make the eventType argument an object + * that specifies the event's type and a defaultBehavior property. A + * common use case is defining default behavior for keyboard events. + * + * @param eventPayload This is the payload of data that accompanies the event. + */ + trigger(eventType: string): void; + trigger(selector: string, eventType: string, eventPayload?: Object): void; + trigger(selector: Document, eventType: string, eventPayload?: Object): void; + trigger(selector: Element, eventType: string, eventPayload?: Object): void; + trigger(selector: Element[], eventType: string, eventPayload?: Object): void; + trigger(eventType: Object): void; + trigger(selector: string, eventType: Object, eventPayload?: Object): void; + trigger(selector: Document, eventType: Object, eventPayload?: Object): void; + trigger(selector: Element, eventType: Object, eventPayload?: Object): void; + trigger(selector: Element[], eventType: Object, eventPayload?: Object): void; + + /** + * Remove a component instance and its event bindings. + * + * It's a good idea to teardown components after each unit test - and + * teardown is also good for unbinding event listeners when, for example, + * the user navigates away from a page. + * + */ + teardown(): void; + } + + export interface Advice extends Base { + /** + * Run the customFunc function after the existingFunc function. + * + * @param existingFuncName The name of the existing function (existingFunc) + * you want to augment. + * + * customFunc The function to be invoked after existingFunc. + */ + after(method: string, fn: Function): void; + + /** + * Run the existingFunc function in the middle of the customFunc function. + * It's similar to underscore's _wrap function). + * + * @param existingFuncName The name of the existing function (existingFunc) + * you want to augment. + * + * customFunc The function to wrap around existingFunc. The existingFunc + * function will be passed to customFunc as an argument. + * + * The existing function is passed to the custom function as an argument so + * that it can be referenced. If the custom function does not call the + * existing function then it will replace that function instead of + * surrounding it. + */ + around(method: string, fn: Function): void; + + /** + * Run the customFunc function before the existingFunc function. + * + * @param existingFuncName The name of the existing function (existingFunc) + * you want to augment. + * + * @param customFunc The function to be invoked before existingFunc. + */ + before(method: string, fn: Function): void; + } + + export interface Component extends Base, Advice { + node: Element; + $node: JQuery; + } + + + export interface AdviceStatic { + withAdvice(): Function; + } + + export interface ComponentStatic { + (...fns: Function[]): ComponentStatic; + attachTo(selector: string, options?: Object): void; + attachTo(selector: Element, options?: Object): void; + attachTo(selector: JQuery, options?: Object): void; + teardownAll(): void; + } + + export interface ComposeStatic { + mixin(base: Object, mixins: Function[]): void; + } + + export interface DebugStatic { + events: { + logAll(): void; + logByAction(action: string): void; + logByName(name: string): void; + logNone(): void; + } + } + + export interface UtilsStatic { + compose(fn1: Function, fn2: Function, ...fns: Function[]): Function; + countThen(num: number, base: Function): Function; + debounce(func: Function, wait: number, immediate: boolean): Function; + delegate(rules: Object): void; + isDomObj(obj: Object): boolean; + isEnumerable(obj: Object, property: string): boolean; + merge(obj1: Object, obj2: Object, deepClone?: boolean): Object; + merge(obj1: Object, obj2: Object, ...args: any[]): Object; + push(base: Object, extra: Object, protect?: boolean): void; + throttle(func: Function, wait: number): Function; + toArray(obj: Object, from?: number): Array; + uniqueArray(array: Array): Array; + } + + export interface EventData { + el: HTMLElement; + } + + export interface FlightStatic { + advice: AdviceStatic; + component: ComponentStatic; + compose: ComposeStatic; + utils: UtilsStatic; + } +} + +declare var DEBUG: Flight.DebugStatic; +declare var flight: Flight.FlightStatic; \ No newline at end of file diff --git a/flot/jquery.flot.d.ts b/flot/jquery.flot.d.ts index fc484aae5..542810545 100644 --- a/flot/jquery.flot.d.ts +++ b/flot/jquery.flot.d.ts @@ -72,7 +72,7 @@ declare module jquery.flot { } interface seriesOptions { - color?: number; + color?: any; // color or number label?: string; lines?: linesOptions; bars?: barsOptions; diff --git a/flot/jquery.flot.d.ts.tscparams b/flot/jquery.flot.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/flot/jquery.flot.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/foundation/foundation-tests.ts.tscparams b/foundation/foundation-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/foundation/foundation-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/foundation/foundation.d.ts.tscparams b/foundation/foundation.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/foundation/foundation.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/fullCalendar/fullCalendar-tests.ts.tscparams b/fullCalendar/fullCalendar-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/fullCalendar/fullCalendar-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gamequery/gamequery-tests.ts.tscparams b/gamequery/gamequery-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gamequery/gamequery-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gapi.pagespeedonline/gapi.pagespeedonline.d.ts.tscparams b/gapi.pagespeedonline/gapi.pagespeedonline.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gapi.pagespeedonline/gapi.pagespeedonline.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gapi.translate/gapi.translate.d.ts.tscparams b/gapi.translate/gapi.translate.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gapi.translate/gapi.translate.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gapi.urlshortener/gapi.urlshortener.d.ts.tscparams b/gapi.urlshortener/gapi.urlshortener.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gapi.urlshortener/gapi.urlshortener.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gapi.youtube/gapi.youtube.d.ts.tscparams b/gapi.youtube/gapi.youtube.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gapi.youtube/gapi.youtube.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gapi.youtubeAnalytics/gapi.youtubeAnalytics.d.ts.tscparams b/gapi.youtubeAnalytics/gapi.youtubeAnalytics.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gapi.youtubeAnalytics/gapi.youtubeAnalytics.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/gapi/gapi.d.ts.tscparams b/gapi/gapi.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/gapi/gapi.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/giraffe/giraffe-tests.ts b/giraffe/giraffe-tests.ts new file mode 100644 index 000000000..70365bb59 --- /dev/null +++ b/giraffe/giraffe-tests.ts @@ -0,0 +1,37 @@ +/// + +class User extends Giraffe.Model { +} + +class MainView extends Giraffe.View { + + constructor(options?) { + this.appEvents = { + 'startup': 'app_onStartup' + } + super(options) + } + + app_onStartup() { + + } + +} + +class MyApp extends Giraffe.App { + constructor() { + this.routes= { + '': 'home' + } + super() + } + + home() { + this.attach( new MainView ) + } + +} + +var app= new MyApp(); + +app.start(); \ No newline at end of file diff --git a/giraffe/giraffe-tests.ts.tscparams b/giraffe/giraffe-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/giraffe/giraffe-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/giraffe/giraffe.d.ts b/giraffe/giraffe.d.ts new file mode 100644 index 000000000..24c41aa24 --- /dev/null +++ b/giraffe/giraffe.d.ts @@ -0,0 +1,186 @@ +// Type definitions for Giraffe +// Project: https://github.com/barc/backbone.giraffe +// Definitions by: Matt McCray +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Giraffe { + + interface GiraffeObject { + app: App; + appEvents?: StringMap; + dataEvents?: StringMap; + defaultOptions?: DefaultOptions; + + initialize?(); + beforeInitialize?(); + afterInitialize?(); + + dispose?(); + beforeDispose?(); + afterDispose?(); + } + + interface AttachmentOptions { + method?: string; + forceRender?: boolean; + suppressRender?: boolean; + } + + interface DefaultOptions { + disposeOnDetach?: boolean; + alwaysRender?: boolean; + saveScrollPosition?: boolean; + documentTitle?: string; + } + + interface AppMap { + [ cid:string ]: App; + } + interface ViewMap { + [ cid:string ]: View; + } + interface StringMap { + [ def:string ]: string; + } + + var app: App; + var apps: AppMap; + var defaultOptions: DefaultOptions; + var version: string; + var views: ViewMap; + + function bindAppEvents( instance:GiraffeObject ): GiraffeObject; + function bindDataEvents( instance:GiraffeObject ): GiraffeObject; + function bindEvent( context:Backbone.Events, target:Backbone.Events, event:any, callback:Function ); + function unbindEvent( context:Backbone.Events, target:Backbone.Events, event:any, callback:Function ); + function bindEventMap( context:Backbone.Events, target:Backbone.Events, eventMap:any ); + function unbindEventMap( context:Backbone.Events, target:Backbone.Events, eventMap:any ); + + function configure( instance:any, options?:any ); + function dispose( instance:GiraffeObject, ...args:any[] ): GiraffeObject; + function disposeThis( ...args:any[] ): GiraffeObject; + + function wrapFn( obj:any, name:string, before:Function, after:Function); + + class Collection extends Backbone.Collection implements GiraffeObject { + app: App; + model: Model; + } + + class Model extends Backbone.Model implements GiraffeObject { + app: App; + } + + class Router extends Backbone.Router implements GiraffeObject { + app: App; + namespace: string; + triggers: StringMap; + + cause( appEvent:string, ...args:any[] ); + isCaused( appEvent:string, ...args:any[] ): boolean; + getRoute( appEvent:string, ...args:any[] ): string; + + reload( url:string ); + } + + class View extends Backbone.View implements GiraffeObject { + app: App; + appEvents: StringMap; + children: View[]; + dataEvents: StringMap; + defaultOptions: DefaultOptions; + documentTitle: string; + parent: View; + template: any; + ui: StringMap; + + attachTo( el:any, options?:AttachmentOptions ): View; + attach( view:View, options?:AttachmentOptions ): View; + isAttached( el:any ): boolean; + + render( options?:any ): View; + beforeRender(); + afterRender(); + templateStrategy(): string; + serialize(): any; + + setParent( parent:View ): View; + + addChild( child:View ): View; + addChildren( children:View[] ): View; + removeChild( child:View, preserve?:boolean ): View; + removeChildren( preserve?:boolean ): View; + + detach( preserve?:boolean ): View; + detachChildren( preserve?:boolean ): View; + + invoke( method:string, ...args:any[] ); + + dispose(): View; + beforeDispose(): View; + afterDispose(): View; + + static detachByElement( el:any, preserve?:boolean ): View; + static getClosestView( el:any ): View; + static getByCid( cid:string ): View; + static to$El( el:any, parent?:any, allowParentMatch?:boolean ): JQuery; + static setDocumentEvents( events:string[], prefix?:string ): string[]; + static removeDocumentEvents( prefix?:string ); + static setDocumentEventPrefix( prefix?:string ); + static setTemplateStrategy( strategy:any, instance?:any ); + } + + class App extends View { + routes: StringMap; + + addInitializer( initializer:( options?:any, callback?:()=>void )=>void ): App; + + start( options?:any ): App; + } + + module Contrib { + + class Controller extends Backbone.Events implements GiraffeObject { + app: App; + } + + class CollectionView extends View { + + collection: Collection; + modelView: View; + modelViewArgs: any[]; + modelViewEl: any; + renderOnChange: boolean; + + findByModel( model:Model ): View; + addOne( model:Model ): View; + removeOne( model:Model ): View; + + static getDefaults( ctx:any ): any; + } + + class FastCollectionView extends View { + collection: Collection; + modelTemplate: any; + modelTemplateStrategy: string; + modelEl: any; + renderOnChange: boolean; + + modelSerialize(): any; + + addAll(): View; + addOne( model:Model ): View; + removeOne( model:Model ): View; + + removeByIndex( index:number ): View; + findElByModel( model:Model ): JQuery; + findElByIndex( index:number ): JQuery; + findModelByEl( el:any ): Model; + + static getDefaults( ctx:any ): any; + } + + } +} diff --git a/giraffe/giraffe.d.ts.tscparams b/giraffe/giraffe.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/giraffe/giraffe.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/globalize/globalize-tests.ts b/globalize/globalize-tests.ts index 577330424..5174f90f9 100644 --- a/globalize/globalize-tests.ts +++ b/globalize/globalize-tests.ts @@ -22,10 +22,14 @@ Globalize.addCultureInfo("fr", { messages: { "translate": "traduire" } }); console.log(Globalize.localize("translate", "fr")); Globalize.parseInt("1,234.56"); -Globalize.parseInt("1.234,56"); +Globalize.parseInt("1.234,56", 10); +Globalize.parseInt("1.234,56", 10, "de"); Globalize.parseFloat("1,234.56"); -Globalize.parseFloat("1.234,56"); +Globalize.parseFloat("1.234,56", 10); +Globalize.parseFloat("1.234,56", 10, "de"); Globalize.parseDate("1/2/2003"); +Globalize.parseDate("15 Jun 2012", "dd MMM yyyy"); +Globalize.parseDate("15 Jun 2012", ["dd MMM yyyy"]); Globalize.culture("fr"); Globalize.parseDate("1/2/2003"); diff --git a/globalize/globalize-tests.ts.tscparams b/globalize/globalize-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/globalize/globalize-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/globalize/globalize.d.ts b/globalize/globalize.d.ts index dd2876bc8..da17957f1 100644 --- a/globalize/globalize.d.ts +++ b/globalize/globalize.d.ts @@ -107,14 +107,16 @@ interface GlobalizeStatic { culture(cultureSelector: string): GlobalizeCulture; culture(cultureSelector: string[]): GlobalizeCulture; - addCultureInfo(cultureName, baseCultureName, info? ); + addCultureInfo(cultureName: string, baseCultureName, info?); findClosestCulture(cultureSelector: string); - format(value, format, cultureSelector? ); - localize(key, cultureSelector?); + format(value: number, format: string, cultureSelector?: string); + format(value: Date, format: string, cultureSelector?: string); + localize(key: string, cultureSelector?: string); - parseDate(value: string, formats? , cultureSelector?: string): Date; - parseInt(value: string, radix? , cultureSelector?: string): number; - parseFloat(value: string, radix? , cultureSelector?: string): number; + parseDate(value: string, format?: string, cultureSelector?: string): Date; + parseDate(value: string, formats?: string[], cultureSelector?: string): Date; + parseInt(value: string, radix?: number, cultureSelector?: string): number; + parseFloat(value: string, radix?: number, cultureSelector?: string): number; } declare var Globalize: GlobalizeStatic; diff --git a/globalize/globalize.d.ts.tscparams b/globalize/globalize.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/globalize/globalize.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/goJS/goJS-tests.ts.tscparams b/goJS/goJS-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/goJS/goJS-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/goJS/goJS.d.ts.tscparams b/goJS/goJS.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/goJS/goJS.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/google.analytics/ga-tests.ts.tscparams b/google.analytics/ga-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/google.analytics/ga-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/google.analytics/ga.d.ts.tscparams b/google.analytics/ga.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/google.analytics/ga.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/google.visualization/google.visualization-tests.ts b/google.visualization/google.visualization-tests.ts new file mode 100644 index 000000000..0f0082816 --- /dev/null +++ b/google.visualization/google.visualization-tests.ts @@ -0,0 +1,41 @@ +/// + +function test_arrayToDataTable() { + var array = [ + ['City', 'Population', 'Area'], + ['Rome', 2761477, 1285.31], + ['Milan', 1324110, 181.76], + ['Naples', 959574, 117.27], + ['Turin', 907563, 130.17], + ['Palermo', 655875, 158.9], + ['Genoa', 607906, 243.60], + ['Bologna', 380181, 140.7], + ['Florence', 371282, 102.41], + ['Fiumicino', 67370, 213.44], + ['Anzio', 52192, 43.43], + ['Ciampino', 38262, 11], + ]; + + var dataTable = google.visualization.arrayToDataTable(array); +} + +function test_ctorDataTable() { + var dataTable = new google.visualization.DataTable(); + return dataTable; +} + +function test_dataTableAddColumn() { + var dataTable = test_ctorDataTable(); + dataTable.addColumn('string', 'First Column'); + dataTable.addColumn('number', 'Second Column'); +} + +function test_dataTableAddRow() { + var dataTable = test_ctorDataTable(); + dataTable.addRow(['row1', 6]); + dataTable.addRow(['row2', -1]); + dataTable.addRow(['row3', 0]); +} + + + diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts new file mode 100644 index 000000000..511d65a23 --- /dev/null +++ b/google.visualization/google.visualization.d.ts @@ -0,0 +1,369 @@ +declare module google { + + function load(visualization: string, version: string, packages: any): void; + function setOnLoadCallback(handler: Function): void; + function setOnLoadCallback(handler: () => void): void; + + //https://developers.google.com/chart/interactive/docs/reference + module visualization { + //#region DataTable + + // https://developers.google.com/chart/interactive/docs/reference#DataTable + export class DataTable { + constructor(data?: any, version?: any); + addColumn(type: string, label?: string, id?: string): number; + addColumn(descriptionObject: DataTableColumnDescription): number; + addRow(cellObject: DataObjectCell): number; + addRow(cellArray?: any[]): number; + addRows(count: number): number; + addRows(array: DataObjectCell[][]): number; + addRows(array: any[]): number; + getFilteredRows(filters: DataTableCellFilter[]): number[]; + getFormattedValue(rowIndex: number, columnIndex: number): string; + getNumberOfColumns(): number; + getNumberOfRows(): number; + removeRow(rowIndex: number): void; + removeRows(rowIndex: number, numberOfRows: number): void; + setColumnLabel(columnIndex: number, label: string): void; + } + + export interface DataTableColumnDescription { + type?: string; + label?: string; + id?: string; + role?: string; + pattern?: string; + } + + export interface DataObject { + cols: DataObjectColumn[]; + rows: DataObjectRow[]; + p: any; + } + + export interface DataObjectColumn { + type: string; + id?: string; + label?: string; + pattern?: string; + p?: any; + } + + export interface DataObjectRow { + c: DataObjectCell[]; + p?: any; + } + + export interface DataTableCellFilter { + column: number; + } + + export interface DataObjectCell { + v?: any; + f?: string; + p?: any; + } + + export interface DataTableCellValueFilter extends DataTableCellFilter { + value: any; + } + + export interface DataTableCellRangeFilter extends DataTableCellFilter { + minValue?: any; + maxValue?: any; + } + + function arrayToDataTable(data: any[]): DataTable; + + //#endregion + //#region DataView + + // https://developers.google.com/chart/interactive/docs/reference#DataView + export class DataView { + constructor(data: DataTable); + constructor(data: DataView); + setColumns(columnIndexes: number[]): void; + } + + //#endregion + //#region GeoChart + + //https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart + export class GeoChart { + constructor(element: Element); + + // https://developers.google.com/chart/interactive/docs/gallery/geochart?hl=fr&csw=1#Methods + draw(data: DataTable, options: GeoChartOptions): void; + getSelection(): GeoChartSelection[]; + setSelection(selection: VisualizationSelectionArray[]): void; + clearChart(): void; + } + + // https://developers.google.com/chart/interactive/docs/gallery/geochart?hl=fr&csw=1#Configuration_Options + export interface GeoChartOptions { + backgroundColor?: any; + colorAxis?: GeoChartColorAxis; + datalessRegionColor?: string; + displayMode?: string; + enableRegionInteractivity?: boolean; + height?: number; + keepAspectRatio?: boolean; + legend?: GeoChartLegend; + region?: string; + magnifyingGlass?: GeoChartMagnifyingGlass; + markerOpacity?: number; + resolution?: string; + sizeAxis?: GeoChartAxis; + tooltip?: GeoChartTooltip; + width?: number; + } + export interface GeoChartAxis { + maxSize?: number; + maxValue?: number; + minSize?: number; + minValue?: number; + } + export interface GeoChartColorAxis extends GeoChartAxis { + minValue?: number; + maxValue?: number; + values?: number[]; + colors?: string[]; + } + export interface GeoChartTextStyle { + color?: string; + fontName?: string; + fontSize?: number; + bold?: boolean; + italic?: boolean; + } + export interface GeoChartLegend { + numberFormat?: string; + textStyle?: GeoChartTextStyle; + } + export interface GeoChartMagnifyingGlass { + enable?: boolean; + zoomFactor?: number; + } + export interface GeoChartTooltip { + textStyle?: GeoChartTextStyle; + trigger?: string; + } + export interface GeoChartRegionClickEvent { + region: string; + } + export interface GeoChartSelection { + row: number; + } + + //#endregion + //#region Common + + export interface ChartArea { + top: any; + left: any; + width: any; + height: any; + } + + export interface ChartTextStyle { + color?: string; + fontName?: string; + fontSize?: number; + bold?: boolean; + italic?: boolean; + } + + export interface ChartLegend { + alignment?: string; + maxLines?: number; + position?: string; + textStyle?: ChartTextStyle; + } + + // https://google-developers.appspot.com/chart/interactive/docs/animation + export interface TransitionAnimation { + duration?: number; + easing?: string; // linear, in, out, inAndOut + } + + export interface ChartAxis { + baseline?: number; // This option is only supported for a continuous axis. https://google-developers.appspot.com/chart/interactive/docs/customizing_axes#Terminology + baselineColor?: string; // google's documentation on this is wrong, specifies it as a number. The color of the baseline for the horizontal axis. Can be any HTML color string, for example: 'red' or '#00cc00' + direction?: number; // The direction in which the values along the horizontal axis grow. Specify -1 to reverse the order of the values. + format?: string; // icu pattern set http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details + gridlines?: ChartGridlines; + logScale?: boolean; + textPosition?: string; + textStyle?: ChartTextStyle; + ticks?: any[]; + title?: string; + titleTextStyle?: ChartTextStyle; + allowContainerBoundaryTextCufoff?: boolean; + slantedText?: boolean; + slantedTextAngle?: number; + maxAlternation?: number; + maxTextLines?: number; + minTextSpacing?: number; + showTextEvery?: number; + maxValue?: number; + minValue?: number; + viewWindowMode?: string; + viewWindow?: ChartViewWindow; + } + + export interface ChartGridlines { + color?: string; + count?: number; + minorGridlines?: ChartMinorGridlines; + } + + export interface ChartMinorGridlines { + color?: string; + count?: number; + } + + export interface ChartViewWindow { + max?: number; + min?: number; + } + + export interface ChartTooltip { + isHtml?: boolean; + showColorCode?: boolean; + textStyle?: ChartTextStyle; + trigger?: string; + } + + export interface ChartBoundingBox { + left: number; + top: number; + width: number; + height: number; + } + + export interface ChartLayoutInterface { + getBoundingBox(id: string): ChartBoundingBox; + getChartAreaBoundingBox(): ChartBoundingBox; + getHAxisValue(position: number, axisIndex?: number): number; + getVAxisValue(position: number, axisIndex?: number): number; + getXLocation(position: number, axisIndex?: number): number; + getYLocation(position: number, axisIndex?: number): number; + } + + export interface VisualizationSelectionArray { + column?: number; + row?: number; + } + + //#endregion + //#region ColumnChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart + export class ColumnChart { + constructor(element: Element); + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart#Methods + draw(data: DataTable, options?: ColumnChartOptions): void; + draw(data: DataView, options?: ColumnChartOptions): void; + getChartLayoutInterface(): ChartLayoutInterface; + getSelection(): any[]; + setSelection(selection: any[]): void; + clearChart(): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart#Configuration_Options + export interface ColumnChartOptions { + aggregationTarget?: string; + animation?: TransitionAnimation; + axisTitlesPosition?: string; // in, out, none + backgroundColor?: any; + bar?: ColumnChartBarOptions; + chartArea?: ChartArea; + colors?: string[]; + enableInteractivity?: boolean; + focusTarget?: string; + fontSize?: number; + fontName?: string; + hAxis?: ChartAxis; + height?: number; + isStacked?: boolean; + legend?: ChartLegend; + reverseCategories?: boolean; + selectionMode?: string // single / multiple + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxes?: any; + vAxis?: ChartAxis; + width?: number; + } + + export interface ColumnChartBarOptions { + groupWidth: any; + } + + //#endregion + //#region LineChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart + export class LineChart { + constructor(element: Element); + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Methods + draw(data: DataTable, options: any): void; + draw(data: DataView, options: any): void; + getChartLayoutInterface(): ChartLayoutInterface; + getSelection(): any[]; + setSelection(selection: any[]): void; + clearChart(): void; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Configuration_Options + export interface LineChartOptions { + aggregationTarget?: string; + animation?: TransitionAnimation; + axisTitlesPosition?: string; + backgroundColor?: any; + chartArea?: ChartArea; + colors?: string[]; + curveType?: string; + enableInteractivity?: boolean; + focusTarget?: string; + fontSize?: number; + fontName?: string; + hAxis?: ChartAxis; + height?: number; + interpolateNulls?: boolean; + legend?: ChartLegend; + lineWidth?: number; + pointSize?: number; + reverseCategories?: boolean; + selectionMode?: string // single / multiple + series?: any; + theme?: string; + title?: string; + titlePosition?: string; + titleTextStyle?: ChartTextStyle; + tooltip?: ChartTooltip; + vAxes?: any; + vAxis?: ChartAxis; + width?: number; + } + + //#endregion + //#region Events + + module events { + function addListener(visualization: any, eventName: string, callback: Function): any; + function addListener(visualization: any, eventName: string, callback: (...args: any[]) => void): any; + function removeListener(listener: any): void; + function removeAllListeners(visualization: any): void; + function trigger(visualization: any, eventName: string, args?: any): void; + } + + //#endregion + } +} \ No newline at end of file diff --git a/greasemonkey/greasemonkey-tests.ts b/greasemonkey/greasemonkey-tests.ts new file mode 100644 index 000000000..914c8f4e3 --- /dev/null +++ b/greasemonkey/greasemonkey-tests.ts @@ -0,0 +1,220 @@ +/// + +//////////////// +// Global variable +//////////////// + +var title: string = unsafeWindow.document.title; + +var scriptDescription: string = GM_info.script.description; +var scriptExcludes: string[] = GM_info.script.excludes; +var scriptIncludes: string[] = GM_info.script.includes; +var scriptMatches: string[] = GM_info.script.matches; +var scriptName: string = GM_info.script.name; +var scriptNamespace: string = GM_info.script.namespace; +var scriptResouces: Object = GM_info.script.resources; +var scriptRunAt: string = GM_info.script['run-at']; +var scriptUnwrap: boolean = GM_info.script.unwrap; +var scriptVersion: string = GM_info.script.version; +var scriptMetsStr: string = GM_info.scriptMetaStr; +var scriptWillUpdate: boolean = GM_info.scriptWillUpdate; +var gmVersion: string = GM_info.version; + +//////////////// +// Values +//////////////// + +GM_setValue('a', 'foobar'); +GM_setValue('b', 123); +GM_setValue('c', true); +GM_setValue('d', null); +// NG: GM_setValue('x', new Date()); + +var a: string = GM_getValue('a', 'foobar'); +var b: number = GM_getValue('b', 123); +var c: boolean = GM_getValue('c', true); +var d: any = GM_getValue('d', null); +var e: string = GM_getValue('e'); +var f: number = GM_getValue('f'); +var g: boolean = GM_getValue('g'); +// NG: var x: string = GM_getValue('x', 123); + +GM_deleteValue('d'); + +GM_listValues().forEach((name: string) => { + console.log(name + ":", GM_getValue(name)); +}); + +//////////////// +// Resources +//////////////// + +var prototypeSource: string = GM_getResourceText('prototype'); +var prototypeURL: string = GM_getResourceURL('prototype'); + +//////////////// +// Utilities +//////////////// + +GM_addStyle("body { color: white; background-color: black; } img { border: 0; }"); + +GM_log("Hello, World!"); + +GM_openInTab("http://www.example.com/"); + +GM_registerMenuCommand("Hello, world (simple)", helloSimple); +GM_registerMenuCommand("Hello, world!", hello, "h"); +// NG (Old Style): GM_registerMenuCommand("Hello, world! (again)", hello2, "e", "shift alt", "w"); +function helloSimple() {} +function hello() {} + +GM_setClipboard('http://www.example.com/short-url-code'); + +//////////////// +// XMLHttpRequest +//////////////// + +//// Examples from Greasemonkey Wiki + +// Bare Minimum + +GM_xmlhttpRequest({ + method: "GET", + url: "http://www.example.com/", + onload: function(response) { + alert(response.responseText); + } +}); + +// GET request + +GM_xmlhttpRequest({ + method: "GET", + url: "http://www.example.net/", + headers: { + "User-Agent": "Mozilla/5.0", // If not specified, navigator.userAgent will be used. + "Accept": "text/xml" // If not specified, browser defaults will be used. + }, + onload: function(response) { + var responseXML = response.responseXML; + // Inject responseXML into existing Object (only appropriate for XML content). + if (!response.responseXML) { + responseXML = new DOMParser() + .parseFromString(response.responseText, "text/xml"); + } + + GM_log([ + response.status, + response.statusText, + response.readyState, + response.responseHeaders, + response.responseText, + response.finalUrl, + responseXML + ].join("\n")); + } +}); + +// POST request + +GM_xmlhttpRequest({ + method: "POST", + url: "http://www.example.net/login", + data: "username=johndoe&password=xyz123", + headers: { + "Content-Type": "application/x-www-form-urlencoded" + }, + onload: function(response) { + if (response.responseText.indexOf("Logged in as") > -1) { + location.href = "http://www.example.net/dashboard"; + } + } +}); + +// HEAD request + +GM_xmlhttpRequest({ + url: "http://www.example.com", + method: "HEAD", + onload: function(response) { + GM_log(response.responseHeaders); + } +}); + +//// Checkk all options + +var result = GM_xmlhttpRequest({ + binary: false, + context: {}, + data: 'foo=1&bar=2', + headers: { 'User-Agent': 'greasemonkey' }, + method: 'POST', + onabort: (response: GMXMLHttpRequestResponse) => { }, + onerror: (response: GMXMLHttpRequestResponse) => { }, + onload: (response: GMXMLHttpRequestResponse) => { }, + onprogress: (response: GMXMLHttpRequestProgressResponse) => { }, + onreadystatechange: (response: GMXMLHttpRequestResponse) => { }, + ontimeout: (response: GMXMLHttpRequestResponse) => { }, + overrideMimeType: 'text/plain', + password: 'abc123', + synchronous: false, + timeout: 10, + upload: { + onabort: (response: GMXMLHttpRequestResponse) => { }, + onerror: (response: GMXMLHttpRequestResponse) => { }, + onload: (response: GMXMLHttpRequestResponse) => { }, + onprogress: (response: GMXMLHttpRequestProgressResponse) => { } + }, + url: 'http://example.com/', + user: 'guest' +}); + +//// Check responses + +GM_xmlhttpRequest({ + method: 'GET', + url: 'http://example.com/', + onload: (response: GMXMLHttpRequestResponse) => { + var readyState: number = response.readyState; + var responseHeaders: string = response.responseHeaders; + var responseText: string = response.responseText; + var status: number = response.status; + var statusText: string = response.statusText; + var context: any = response.context; + var finalUrl: string = response.finalUrl; + // NG: var loaded: number = response.loaded; + }, + onprogress: (response: GMXMLHttpRequestProgressResponse) => { + var status: number = response.status; + var lengthComputable: boolean = response.lengthComputable; + var loaded: number = response.loaded; + var total: number = response.total; + } +}); + +//// Synchronous + +var syncResult: GMXMLHttpRequestSyncResult = GM_xmlhttpRequest({ + method: 'GET', + url: 'http://example.com/', + synchronous: true +}); + +syncResult.abort(); +var finalUrl: string = syncResult.finalUrl; +var readyState: number = syncResult.readyState; +var responseHeaders: string = syncResult.responseHeaders; +var responseText: string = syncResult.responseText; +var status: number = syncResult.status; +var statusText: string = syncResult.statusText; + +//// Asynchronous + +var asyncResult: GMXMLHttpRequestAsyncResult = GM_xmlhttpRequest({ + method: 'GET', + url: 'http://example.com/', + synchronous: false +}); + +asyncResult.abort(); +// NG: var status: number = asyncResult.status; diff --git a/greasemonkey/greasemonkey.d.ts b/greasemonkey/greasemonkey.d.ts new file mode 100644 index 000000000..27abcfa7f --- /dev/null +++ b/greasemonkey/greasemonkey.d.ts @@ -0,0 +1,235 @@ +// Type definitions for Greasemonkey +// Project: http://www.greasespot.net/ +// Definitions by: Kota Saito +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// This definition is based on the API reference of Greasemonkey. +// http://wiki.greasespot.net/Greasemonkey_Manual:API + +//////////////// +// Global variable +//////////////// + +/** + * Window object of the content page where the user script is running on. + * @see {@link http://wiki.greasespot.net/UnsafeWindow} + */ +declare var unsafeWindow: Window; + +/** + * Meta data about the running user script. + * @see {@link http://wiki.greasespot.net/GM_info} + */ +declare var GM_info: { + script: { + description: string; + excludes: string[]; + includes: string[]; + matches: string[]; + name: string; + namespace: string; + resources: Object; + "run-at": string; + unwrap: boolean; + version: string; + }; + scriptMetaStr: string; + scriptWillUpdate: boolean; + version: string; +}; + +//////////////// +// Values +//////////////// + +/** + * Deletes an existing name / value pair from the script storage. + * @param name a name of the pair to delete. + * @see {@link http://wiki.greasespot.net/GM_deleteValue} + */ +declare function GM_deleteValue(name: string): void; + +/** + * Retrieves a value from the script storage. + * @param name a name to retrieve. + * @param defaultValue a value to be returned when the name does not exist. + * @returns a retrieved value, or passed default value, or undefined. + * @see {@link http://wiki.greasespot.net/GM_getValue} + */ +declare function GM_getValue(name: string, defaultValue?: any): any; +declare function GM_getValue(name: string, defaultValue?: string): string; +declare function GM_getValue(name: string, defaultValue?: number): number; +declare function GM_getValue(name: string, defaultValue?: boolean): boolean; + +/** + * Retrieves an array of names stored in the script storage. + * @returns an array of names in the storage. + * @see {@link http://wiki.greasespot.net/GM_listValues} + */ +declare function GM_listValues(): string[]; + +/** + * Stores a name / value pair to the script storage. + * @param name a name of the pair. + * @param value a value to be stored. + * @see {@link http://wiki.greasespot.net/GM_setValue} + */ +declare function GM_setValue(name: string, value: string): void; +declare function GM_setValue(name: string, value: boolean): void; +declare function GM_setValue(name: string, value: number): void; + +//////////////// +// Resources +//////////////// + +/** + * Gets a content of a resouce defined by {@link http://wiki.greasespot.net/Metadata_Block#.40resource|@resource}. + * @param resourceName a name of the resource to get. + * @returns the content of the resource. + * @see {@link http://wiki.greasespot.net/GM_getResourceText} + */ +declare function GM_getResourceText(resourceName: string): string; + +/** + * Gets a URL of a resource defined by {@link http://wiki.greasespot.net/Metadata_Block#.40resource|@resource}. + * @param resourceName a name of the resource. + * @returns a URL that returns the content of the resource. + * @see {@link http://wiki.greasespot.net/GM_getResourceURL} + */ +declare function GM_getResourceURL(resourceName: string): string; + +//////////////// +// Utilities +//////////////// + +/** + * Adds CSS to the content page. + * @param css a CSS string. It can have multiple style definitions. + * @see {@link http://wiki.greasespot.net/GM_addStyle} + */ +declare function GM_addStyle(css: string): void; + +/** + * Writes a message as a log to the console with the script identifier. + * @param message a message to be written. + * @see {@link http://wiki.greasespot.net/GM_log} + */ +declare function GM_log(message: any): void; + +/** + * Opens a URL in a new tab. + * @param url a URL to open. + * @returns window object of the opened tab. + * @see {@link http://wiki.greasespot.net/GM_openInTab} + */ +declare function GM_openInTab(url: string): Window; + +/** + * Registers an item as a submenu of User Script Commands. + * @param caption a caption of the menu item. + * @param commandFunc a function to be invoked when the item has been selected. + * @param accessKey a single character that can be used to select the item by keyboard. + * It should be a letter in the caption. + * @see {@link http://wiki.greasespot.net/GM_registerMenuCommand} + */ +declare function GM_registerMenuCommand(caption: string, commandFunc: Function, accessKey?: string): void; + +/** + * Sets a text to the clipboard of the opeating system. + * @param text a text to be set to the clipboard. + * @see {@link http://wiki.greasespot.net/GM_setClipboard} + */ +declare function GM_setClipboard(text: string): void; + +//////////////// +// XMLHttpRequest +//////////////// + +/** + * Request options for {@link GM_xmlhttpRequest}. + * @see {@link http://wiki.greasespot.net/GM_xmlhttpRequest#Arguments} + */ +interface GMXMLHttpRequestOptions { + binary?: boolean; + context?: any; + data?: string; + headers?: Object; + method: string; + onabort?: (response: GMXMLHttpRequestResponse) => any; + onerror?: (response: GMXMLHttpRequestResponse) => any; + onload?: (response: GMXMLHttpRequestResponse) => any; + onprogress?: (response: GMXMLHttpRequestProgressResponse) => any; + onreadystatechange?: (response: GMXMLHttpRequestResponse) => any; + ontimeout?: (response: GMXMLHttpRequestResponse) => any; + overrideMimeType?: string; + password?: string; + synchronous?: boolean; + timeout?: number; + upload?: { + onabort?: (response: GMXMLHttpRequestResponse) => any; + onerror?: (response: GMXMLHttpRequestResponse) => any; + onload?: (response: GMXMLHttpRequestResponse) => any; + onprogress?: (response: GMXMLHttpRequestProgressResponse) => any; + }; + url: string; + user?: string; +} + +/** + * Response object for general events of {@link GM_xmlhttpRequest}. + * @see {@link http://wiki.greasespot.net/GM_xmlhttpRequest#Response_Object} + */ +interface GMXMLHttpRequestResponse { + readyState: number; + responseHeaders: string; + responseText: string; + status: number; + statusText: string; + context: any; + finalUrl: string; +} + +/** + * Response object for onprogress event of {@link GM_xmlhttpRequest}. + */ +interface GMXMLHttpRequestProgressResponse extends GMXMLHttpRequestResponse { + lengthComputable: boolean; + loaded: number; + total: number; +} + +/** + * Returned object by {@link GM_xmlhttpRequest} in asynchronous mode. + */ +interface GMXMLHttpRequestAsyncResult { + abort(): void; +} + +/** + * Returned object by {@link GM_xmlhttpRequest} in synchronouse mode. + */ +interface GMXMLHttpRequestSyncResult { + abort(): void; + finalUrl: string; + readyState: number; + responseHeaders: string; + responseText: string; + status: number; + statusText: string; +} + +/** + * Returned object by {@link GM_xmlhttpRequest}. + * @see {@link http://wiki.greasespot.net/GM_xmlhttpRequest#Returns} + */ +interface GMXMLHttpRequestResult extends GMXMLHttpRequestAsyncResult, GMXMLHttpRequestSyncResult { +} + +/** + * Sends a HTTP request to a URL. + * @param options options and callbacks for HTTP request. + * @returns an object which can abort the request. + * If the request is sent in the synchronous mode, it also contains the response information. + * @see {@link http://wiki.greasespot.net/GM_setClipboard} + */ +declare function GM_xmlhttpRequest(options: GMXMLHttpRequestOptions): GMXMLHttpRequestResult; diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index abd1c90ed..9097fa7df 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -4,7 +4,7 @@ // http://gruntjs.com/getting-started#an-example-gruntfile // exports should work same as module.exports -exports = function (grunt) { +exports = (grunt: IGrunt) => { // Project configuration. grunt.initConfig({ @@ -26,4 +26,16 @@ exports = function (grunt) { // Default task(s). grunt.registerTask('default', ['uglify']); + + // util methods + var testOneArg = (a: number) => a * 2; + var asyncedOneArg = grunt.util.callbackify(testOneArg); + asyncedOneArg(1, (result: number) => { + console.log(result); + }); + var testTwoArgs = (a: number, b: string) => "it works with " + a + " " + b; + var asyncedTwoArgs = grunt.util.callbackify(testTwoArgs); + asyncedTwoArgs(2, "values", (result: string) => { + console.log(result); + }); }; \ No newline at end of file diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 463721da9..0b3d6ee2e 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -1,220 +1,1302 @@ -// Type definitions for Grunt JS -// Project: http://gruntjs.com/ -// Definitions by: Basarat Ali Syed -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Type definitions for Grunt 0.4.x +// Project: http://gruntjs.com +// Definitions by: Jeff May +// Definitions: https://github.com/jeffmay/DefinitelyTyped +/// -//////////////// -/// To add plugins update the IGruntConfig using open ended interface syntax -//////////////// -interface IGruntConfig { - pkg?: any; +/** + * {@link http://github.com/marak/colors.js/} + */ +interface String { + yellow: string; + cyan: string; + white: string; + magenta: string; + green: string; + red: string; + grey: string; + blue: string; } -//////////////// -/// Sample grunt plugin definition: -/// uglify : https://github.com/gruntjs/grunt-contrib-uglify -//////////////// -interface IGruntUglifyConfig { - mangle?: boolean; - compress?: boolean; - beautify?: boolean; - report?: any; // false / 'min' / 'gzip' - sourceMap?: any; // String / Function - sourceMapRoot?: string; - sourceMapIn?: string; - sourceMappingURL?: any; // String / Function - sourceMapPrefix?: number; - wrap?: string; - exportAll?: boolean; - preserveComments?: any; // boolean / string / function - banner?: string; -} -interface IGruntConfig { - uglify?: { - options?: IGruntUglifyConfig; - build?: { - src: string; - dest: string; - }; +declare module node { - }; + /** + * {@link http://npmjs.org/doc/json.html} + */ + interface NodePackage { + name: string + version: string + description?: string + keywords?: string[] + homepage?: string + } } +/** + * {@link http://github.com/isaacs/minimatch} + */ +declare module minimatch { + /** + * A minimal matching utility options. + * + * This is the matching library used internally by npm. + * Eventually, it will replace the C binding in node-glob. + * It works by converting glob expressions into JavaScript RegExp objects. + */ + interface IMinimatchOptions { + /* + All options are false by default. + */ + /** + * Dump a ton of stuff to stderr. + */ + debug?: boolean -//////////////// -// Main Grunt object -// http://gruntjs.com/api/grunt -//////////////// -interface IGrunt { - // Config - config: IGruntConfigObject; - initConfig(config?: IGruntConfig): void; + /** + * Do not expand {a,b} and {1..3} brace sets. + */ + nobrace?: boolean + /** + * Disable ** matching against multiple folder names. + */ + noglobstar?: boolean - // Tasks - task: any; - // Creating - registerTask: Function; - registerMultiTask: Function; - renameTask: Function; - // Loading - loadTasks: Function; - loadNpmTasks: Function; + /** + * Allow patterns to match filenames starting with a period, + * even if the pattern does not explicitly have a period in that spot. + */ + // Note that by default, a/**\/b will not match a/.d/b, unless dot is set. + dot?: boolean - // Errors - warn: Function; - fatal: Function; + /** + * Disable "extglob" style patterns like +(a|b). + */ + noext?: boolean - // Misc: - package: any; - version: any; + /** + * Perform a case-insensitive match. + */ + nocase?: boolean - // File - file: IGruntFileObject; + /** + * When a match is not found by minimatch.match, return a list containing the pattern itself. + * When set, an empty list is returned if there are no matches. + */ + nonull?: boolean - // Event - event: any; - // Fail - fail: any; - // Log - log: any; - // Options - option: any; - // Template - template: any; - // Util - util: any; + /** + * If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. + * For example, a?b would match the path /xyz/123/acb, but not /xyz/acb/123. + */ + matchBase?: boolean + + /** + * Suppress the behavior of treating # at the start of a pattern as a comment. + */ + nocomment?: boolean + + /** + * Suppress the behavior of treating a leading ! character as negation. + */ + nonegate?: boolean + + /** + * Returns from negate expressions the same as if they were not negated. (Ie, true on a hit, false on a miss.) + */ + flipNegate?: boolean + } } -//////////////// -/// Grunt Config object -/// http://gruntjs.com/api/grunt.config#accessing-config-data -//////////////// -interface IGruntConfigObject { - (...param: any[]): any; - init: (config?: IGruntConfig) => void; - get: Function; - process: Function; - getRaw: Function; - set: Function; - escape: (propString: string) => void; - requires: Function; +/* GRUNT CONFIGURATION + *********************/ + +declare module grunt { + + module config { + + /** + * {@link http://gruntjs.com/sample-gruntfile} + */ + interface IProjectConfig extends IConfigOptionFormat { + pkg: string + } + + /** + * @see IProjectConfig + */ + interface IConfigOptionFormat { + [plugin: string]: IConfigPluginFormat + } + + /** + * A map of plugin task names to config objects. + */ + interface IConfigPluginFormat { + [task: string]: grunt.task.ITaskOptions + } + + /** + * {@link http://gruntjs.com/api/grunt.config} + */ + interface ConfigModule { + /** + * Get or set a value from the project's Grunt configuration. + * This method serves as an alias to other methods; + * if two arguments are passed, grunt.config.set is called, + * otherwise grunt.config.get is called. + */ + (prop: string, value: any): any + (prop: string): any + + /** + * Initialize a configuration object for the current project. + * The specified configObject is used by tasks and can be accessed using the grunt.config method. + * Nearly every project's Gruntfile will call this method. + */ + init(config: IProjectConfig): void + + /** + * Get a value from the project's Grunt configuration. + * If prop is specified, that property's value is returned, or null if that property is not defined. + * If prop isn't specified, a copy of the entire config object is returned. + * Templates strings will be recursively processed using the grunt.config.process method. + * + * @note Although this accepts a generic type, you may still get the wrong typed value. + */ + get(prop: string): T + get(): ConfigModule + + /** + * Process a value, recursively expanding <% %> templates (via the grunt.template.process method) + * in the context of the Grunt config, as they are encountered. + * this method is called automatically by grunt.config.get but not by grunt.config.getRaw. + * + * If any retrieved value is entirely a single '<%= foo %>' or '<%= foo.bar %>' template string, + * and the specified foo or foo.bar property is a non-string (and not null or undefined) value, + * it will be expanded to the actual value. That, combined with grunt's task system automatically + * flattening arrays, can be extremely useful. + */ + process(value: string): T + + /** + * Get a raw value from the project's Grunt configuration, without processing <% %> template strings. + * If prop is specified, that property's value is returned, or null if that property is not defined. + * If prop isn't specified, a copy of the entire config object is returned. + */ + getRaw(prop: string): T + + /** + * Set a value into the project's Grunt configuration. + * @note any specified <% %> template strings will only be processed when config data is retrieved. + */ + set(prop: string, value: T): T + + /** + * Escape '.' dots in the given propString. This should be used for property names that contain dots. + */ + escape(propString: string): string + + /** + * Fail the current task if one or more required config properties is missing, null or undefined. + * One or more string or array config properties may be specified. + */ + requires(prop: string, ...andProps: string[]): void + requires(prop: string[], ...andProps: string[][]): void + } + } + + module event { + /** + * {@link http://github.com/hij1nx/EventEmitter2} + */ + interface EventModule { + + /** + * Adds a listener to the end of the listeners array for the specified event. + */ + addListener(event: string, listener: Function): EventModule + on(event: string, listener: Function): EventModule + + /** + * Adds a listener that will be fired when any event is emitted. + */ + onAny(listener: Function): EventModule + + /** + * Removes the listener that will be fired when any event is emitted. + */ + offAny(listener: Function): EventModule + + /** + * Adds a one time listener for the event. + * The listener is invoked only the first time the event is fired, after which it is removed. + */ + once(event: string, listener: Function): EventModule + + /** + * Adds a listener that will execute n times for the event before being removed. + * The listener is invoked only the first time the event is fired, after which it is removed. + */ + many(event: string, timesToListen: number, listener: Function): EventModule + + /** + * Remove a listener from the listener array for the specified event. + * Caution: changes array indices in the listener array behind the listener. + */ + removeListener(event: string, listener: Function): EventModule + off(event: string, listener: Function): EventModule + + /** + * Removes all listeners, or those of the specified event. + */ + removeAllListeners(event: string): EventModule + + /** + * By default EventEmitters will print a warning if more than 10 listeners are added to it. + * This is a useful default which helps finding memory leaks. Obviously not all Emitters + * should be limited to 10. This function allows that to be increased. + * + * Set to zero for unlimited. + */ + setMaxListener(n: number): void + + /** + * Returns an array of listeners for the specified event. + * This array can be manipulated, e.g. to remove listeners. + */ + listeners(event: string): Function[] + + /** + * Returns an array of listeners that are listening for any event that is specified. + * This array can be manipulated, e.g. to remove listeners. + */ + listenersAny(): Function[] + + /** + * Execute each of the listeners that may be listening for the specified event name + * in order with the list of arguments. + */ + emit(event: string, ...args: any[]): any + } + } + + module fail { + + enum ErrorCode { + NoError = 0, + Fatal = 1, + MissingGruntfile = 2, + Task = 3, + Template = 4, + Autocomplete = 5, + Warning = 6, + } + + interface FailModule { + + /** + * Display a warning and abort Grunt immediately. + * Grunt will continue processing tasks if the --force command-line option was specified. + */ + warn(error: string, errorCode?: ErrorCode): void + warn(error: Error, errorCode?: ErrorCode): void + + /** + * Display a warning and abort Grunt immediately. + */ + fatal(error: string, errorCode?: ErrorCode): void + fatal(error: Error, errorCode?: ErrorCode): void + } + } + + module file { + + /** + * {@link http://gruntjs.com/api/grunt.file#grunt.file.defaultencoding} + */ + interface IFileEncodedOption { + encoding: string + } + + /** + * {@link http://gruntjs.com/api/grunt.file#grunt.file.copy} + * + * @see IFileWriteBufferOption + * @see IFileWriteStringOption + */ + interface IFileWriteOptions { + /** + * These optional globbing patterns will be matched against the filepath + * (not the filename) using grunt.file.isMatch. If any specified globbing + * pattern matches, the file won't be processed via the `process` function. + * If `true` is specified, processing will be prevented. + */ + // noProcess?: string[] + // noProcess?: boolean + noProcess?: any + } + + /** + * @see IFileWriteOptions + */ + interface IFileWriteBufferOption extends grunt.file.IFileWriteOptions { + /** + * The source file contents and file path are passed into this function, + * whose return value will be used as the destination file's contents. If + * this function returns `false`, the file copy will be aborted. + */ + process?: (buffer: NodeBuffer) => boolean + } + + /** + * @see IFileWriteOptions + */ + interface IFileWriteStringOption extends grunt.file.IFileWriteOptions { + /** + * The source file contents and file path are passed into this function, + * whose return value will be used as the destination file's contents. If + * this function returns `false`, the file copy will be aborted. + */ + process?: (file: string) => boolean + } + + /** + * {@link http://gruntjs.com/api/grunt.file} + */ + interface FileModule { + + /** + * Set this property to change the default encoding used by all grunt.file methods. + * Defaults to 'utf8'. + * + * If you do have to change this value, it's recommended that you change + * it as early as possible inside your Gruntfile. + */ + defaultEncoding: string + + /** + * Read and return a file's contents. + * Returns a string, unless options.encoding is null in which case it returns a Buffer. + */ + read(filepath: string): string + read(filepath: string, options: IFileEncodedOption): NodeBuffer + + /** + * Read a file's contents, parsing the data as JSON and returning the result. + * @see FileModule.read for a list of supported options. + */ + readJSON(filepath: string): any + readJSON(filepath: string, options: IFileEncodedOption): NodeBuffer + + /** + * Read a file's contents, parsing the data as YAML and returning the result. + * @see FileModule.read for a list of supported options. + */ + readYAML(filepath: string): any + readYAML(filepath: string, options: IFileEncodedOption): NodeBuffer + + /** + * Write the specified contents to a file, creating intermediate directories if necessary. + * Strings will be encoded using the specified character encoding, Buffers will be written to disk as-specified. + * + * @param contents If `contents` is a Buffer, encoding is ignored. + * @param options If an encoding is not specified, default to grunt.file.defaultEncoding. + */ + write(filepath: string, contents: NodeBuffer, options?: IFileEncodedOption): void + + /** + * Copy a source file to a destination path, creating intermediate directories if necessary. + */ + copy(srcpath: string, destpath: string): void + copy(srcpath: string, destpath: string, options: IFileWriteStringOption): void + copy(srcpath: string, destpath: string, options: IFileWriteBufferOption): void + + /** + * Delete the specified filepath. Will delete files and folders recursively. + * + * @return true if the files could be deleted, otherwise false. + */ + delete(filepath: string, options?: { force?: boolean }): boolean + + /** + * Works like mkdir -p. Create a directory along with any intermediate directories. + * If mode isn't specified, it defaults to 0777 & (~process.umask()). + */ + mkdir(dirpath: string, mode?: string): void + + /** + * Recurse into a directory, executing callback for each file. + * + * Callback args: + * abspath - The full path to the current file, + * which is nothing more than the rootdir + subdir + filename arguments, joined. + * rootdir - The root director, as originally specified. + * subdir - The current file's directory, relative to rootdir. + * filename - The filename of the current file, without any directory parts. + */ + recurse( + rootdir: string, + callback: (abspath: string, rootdir: string, subdir: string, filename: string) => void + ): void + + /** + * Return a unique array of all file or directory paths that match the given globbing pattern(s). + * This method accepts either comma separated globbing patterns or an array of globbing patterns. + * Paths matching patterns that begin with ! will be excluded from the returned array. + * Patterns are processed in order, so inclusion and exclusion order is significant. + * + * File paths are relative to the Gruntfile unless the current working directory is changed with + * grunt.file.setBase or the --base command-line option. + */ + expand(patterns: string[]): string[] + expand(options: IFilesConfig, patterns: string[]): string[] + + /** + * Returns an array of src-dest file mapping objects. + * For each source file matched by a specified pattern, join that file path to the specified dest. + * This file path may be flattened or renamed, depending on the options specified. + * + * @see FileModule.expand method documentation for an explanation of how the patterns + * and options arguments may be specified. + */ + expandMapping(patterns: string[], dest: string, options: IExpandedFilesConfig): IFilesMap + + /** + * Match one or more globbing patterns against one or more file paths. + * Returns a uniqued array of all file paths that match any of the specified globbing patterns. + * Both the patterns and filepaths argument can be a single string or array of strings. + * Paths matching patterns that begin with ! will be excluded from the returned array. + * Patterns are processed in order, so inclusion and exclusion order is significant. + */ + match(pattern: string, filepath: string): string[] + match(pattern: string, filepaths: string[]): string[] + match(patterns: string[], filepath: string): string[] + match(patterns: string[], filepaths: string[]): string[] + match(options: minimatch.IMinimatchOptions, pattern: string, filepath: string): string[] + match(options: minimatch.IMinimatchOptions, pattern: string, filepaths: string[]): string[] + match(options: minimatch.IMinimatchOptions, patterns: string[], filepath: string): string[] + match(options: minimatch.IMinimatchOptions, patterns: string[], filepaths: string[]): string[] + + /** + * This method contains the same signature and logic as the grunt.file.match method, + * but simply returns true if any files were matched, otherwise false. + * + * @see FileModule.match + */ + isMatch(pattern: string, filepath: string): boolean + isMatch(pattern: string, filepaths: string[]): boolean + isMatch(patterns: string[], filepath: string): boolean + isMatch(patterns: string[], filepaths: string[]): boolean + isMatch(options: minimatch.IMinimatchOptions, pattern: string, filepath: string): boolean + isMatch(options: minimatch.IMinimatchOptions, pattern: string, filepaths: string[]): boolean + isMatch(options: minimatch.IMinimatchOptions, patterns: string[], filepath: string): boolean + isMatch(options: minimatch.IMinimatchOptions, patterns: string[], filepaths: string[]): boolean + + + /* + * Like the Node.js path.join method, the methods below will + * join all arguments together and normalize the resulting path. + */ + + /** + * Does the given path exist? + */ + exists(path: string, ...append: string[]): boolean + + /** + * Is the given path a symbolic link? + */ + isLink(path: string, ...append: string[]): boolean + + /** + * Is the given path a symbolic link? + */ + isDir(path: string, ...append: string[]): boolean + + /** + * Is the given path a file? + */ + isFile(path: string, ...append: string[]): boolean + + /** + * Is a given file path absolute? + */ + isPathAbsolute(path: string, ...append: string[]): boolean + + /** + * Do all the specified paths refer to the same path? + */ + arePathsEquivalent(path: string, ...append: string[]): boolean + + /** + * Are all descendant path(s) contained within the specified ancestor path? + */ + doesPathContain(ancestorPath: string, decendantPaths: string[]): boolean + + /** + * Is a given file path the current working directory (CWD)? + */ + isPathCwd(path: string, ...append: string[]): boolean + + /** + * Change grunt's current working directory (CWD). + * By default, all file paths are relative to the Gruntfile. + * This works just like the --base command-line option. + */ + setBase(path: string, ...append: string[]): void + + // External libraries + // TODO: Create declarations + glob: any + minimatch: any + findup: any + } + + /** + * A convenience type. + * + * {@link http://gruntjs.com/configuring-tasks#files} + */ + interface IFilesArray extends Array {} + + /** + * {@link http://gruntjs.com/configuring-tasks#files} + */ + interface IFilesConfig extends minimatch.IMinimatchOptions { + + /** + * Pattern(s) to match, relative to the {@link IExpandedFilesConfig.cwd}. + */ + src: string[] + + /** + * Destination path prefix. + */ + dest?: string + + /** + * Process a dynamic src-dest file mapping, + * @see {@link http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically for more information. + */ + expand?: boolean // = false + + /** + * Either a valid fs.Stats method name: + * - isFile + * - isDirectory + * - isBlockDevice + * - isCharacterDevice + * - isSymbolicLink + * - isFIFO + * - isSocket + * + * or a function that is passed the matched src filepath and returns true or false. + * + * string + * (src: string) => boolean + */ + // filter?: string + // filter?: (src: string) => boolean + filter?: any + } + + /** + * These are valid for compact-format + */ + interface IExpandedFilesConfig extends IFilesConfig { + + /** + * Enables the following options + */ + expand: boolean // = true + + /** + * All {@link IExpandedFilesConfig.src} matches are relative to (but don't include) this path. + */ + cwd?: boolean + + /** + * Replace any existing extension with this value in generated {@link IExpandedFilesConfig.dest} paths. + */ + ext?: boolean + + /** + * Remove all path parts from generated {@link IExpandedFilesConfig.dest} paths. + */ + flatten?: boolean + + /** + * This function is called for each matched src file, (after extension renaming and flattening). + * The {@link IExpandedFilesConfig.dest} and matched {@link IExpandedFilesConfig.src} path are passed in, + * and this function must return a new dest value. + * If the same dest is returned more than once, each src which used it will be added to an array of sources for it. + */ + rename?: boolean + } + + /** + * @see {@link http://gruntjs.com/configuring-tasks#files-object-format} + */ + interface IFilesMap { + /** + * A map of sources to a destination. + */ + [dest: string]: string[] + } + } + + module log { + + /** + * Grunt output should look consistent, and maybe even pretty. + * As such, there is a plethora of logging methods, and a few useful patterns. + * All of the methods that actually log something are chainable. + */ + interface CommonLogging { + + /** + * Log the specified msg string, with no trailing newline. + */ + write(msg: string): T + + /** + * Log the specified msg string, with trailing newline. + */ + writeln(msg: string): T + + /** + * If msg string is omitted, logs ERROR in red, + * otherwise logs >> msg, with trailing newline. + */ + error(msg: string): T + + /** + * Log an error with grunt.log.error, wrapping text to 80 columns using grunt.log.wraptext. + */ + errorlns(msg: string): T + + /** + * If msg string is omitted, logs OK in green, otherwise logs >> msg, with trailing newline. + */ + ok(msg: string): T + + /** + * Log an ok message with grunt.log.ok, wrapping text to 80 columns using grunt.log.wraptext. + */ + oklns(msg: string): T + + /** + * Log the specified msg string in bold, with trailing newline. + */ + subhead(msg: string): T + + /** + * Log a list of obj properties (good for debugging flags). + */ + writeflags(obj: any): T + } + + /** + * @note all methods available under grunt.verbose work exactly like grunt.log methods, + * but only log if the --verbose command-line option was specified. + */ + interface VerboseLogModule extends CommonLogging { + or: NotVerboseLogModule + } + + /** + * @note all methods available under grunt.verbose work exactly like grunt.log methods, + * but only log if the --verbose command-line option was not specified. + */ + interface NotVerboseLogModule extends CommonLogging { + or: VerboseLogModule + } + + /** + * {@link http://gruntjs.com/api/grunt.log} + */ + interface LogModule extends CommonLogging { + verbose: VerboseLogModule + notverbose: NotVerboseLogModule + } + } + + module option { + + /** + * {@link http://gruntjs.com/api/grunt.option} + */ + interface OptionModule { + + /** + * Gets or sets an option. + * Boolean options can be negated by prepending no- onto the key. For example: + * + * grunt.option('staging', false); + * var isDev = grunt.option('no-staging'); + * assert(isDev === true) + */ + (key: string, value: T): void + (key: string): T + + /** + * Initialize grunt.option. + * If initObject is omitted option will be initialized to an empty object + * otherwise will be set to initObject. + */ + init(initObject?: any): void + + /** + * Returns the options as an array of command line parameters. + */ + flags: grunt.IFlag[] + } + + } + + module task { + + interface TaskFunction extends ITask { + (...args: any[]): boolean + } + + /** + * {@link http://gruntjs.com/api/grunt.task} + */ + interface CommonTaskModule { + + /** + * If a task list is specified, the new task will be an alias for one or more other tasks. + * Whenever this "alias task" is run, every specified task in taskList will be run, in the order specified. + * The taskList argument must be an array of tasks. + */ + registerTask(taskName: string, taskList: string[]): void + + /** + * If a description and taskFunction are passed, the specified function will be executed + * whenever the task is run. + * + * In addition, the specified description will be shown when grunt --help is run. + * Task-specific properties and methods are available inside the task function as properties + * of the this object. The task function can return false to indicate that the task has failed. + * + * @note taskFunction.apply(scope: grunt.task.IMultiTask, args: any[]) + */ + registerTask(taskName: string, description: string, taskFunction: TaskFunction): void + + /** + * Register a "multi task." A multi task is a task that implicitly iterates over all of its + * named sub-properties (AKA targets) if no target was specified. + * In addition to the default properties and methods, extra multi task-specific properties + * are available inside the task function as properties of the this object. + * + * @note taskFunction.apply(scope: grunt.task.IMultiTask, args: any[]) + */ + registerMultiTask(taskName: string, taskFunction: grunt.task.ITask): void + registerMultiTask(taskName: string, taskDescription: string, taskFunction: TaskFunction): void + } + + /** + * {@link http://gruntjs.com/api/grunt.task#queueing-tasks} + */ + interface TaskModule extends CommonTaskModule { + /** + * Enqueue one or more tasks. + * Every specified task in taskList will be run immediately after the current task completes, + * in the order specified. The task list can be an array of tasks or individual task arguments. + */ + run(tasks: string[]): void + run(task: string, ...thenTasks: string[]): void + + /** + * Empty the task queue completely. Unless additional tasks are enqueued, no more tasks will be run. + */ + clearQueue(): void + + /** + * Normalizes a task target configuration object into an array of src-dest file mappings. + * This method is used internally by the multi task system this.files / grunt.task.current.files property. + */ + normalizeMultiTaskFiles(data: grunt.config.IProjectConfig, targetname?: string): grunt.file.IFilesMap + } + + interface AsyncResultCatcher { + /** + * Either false or an Error object may be passed to the done function + * to instruct Grunt that the task has failed. + */ + done(success: boolean): void; + done(error: Error): void; + done(result: any): void; + } + + /** + * @link http://gruntjs.com/inside-tasks + * + * Grunt version 0.4.x + */ + interface ITask { + + /** + * If a task is asynchronous, this method must be invoked to instruct Grunt to wait. + * It returns a handle to a "done" function that should be called when the task has completed. + * + * // Tell Grunt this task is asynchronous. + * var done = this.async(); + * // Your async code. + * setTimeout(function() { + * // Let's simulate an error, sometimes. + * var success = Math.random() > 0.5; + * // All done! + * done(success); + * }, 1000); + */ + async(): AsyncResultCatcher + + /** + * If one task depends on the successful completion of another task (or tasks), + * this method can be used to force Grunt to abort if the other task didn't run, + * or if the other task failed. + * + * @param tasks an array of task names or individual task names, as arguments. + * @note that this won't actually run the specified task(s), + * it will just fail the current task if they haven't already run successfully. + */ + requires(tasks: string[]): void + requires(tasks: string, ...otherTasks: string[]): void + requires(tasks: string[], ...otherTasks: string[][]): void + + /** + * Fail the current task if one or more required config properties is missing. + * One or more string or array config properties may be specified. + * this.requiresConfig(prop [, prop [, ...]]) + */ + requiresConfig(prop: string, ...andProps: string[]): void + + /** + * The name of the task, as defined in grunt.registerTask. + * For example, if a "sample" task was run as grunt sample or grunt sample:foo, + * inside the task function, this.name would be "sample". + */ + name: string + + /** + * The name of the task, including any colon-separated arguments or flags specified on the command-line. + * For example, if a "sample" task was run as grunt sample:foo, + * inside the task function, this.nameArgs would be "sample:foo". + */ + nameArgs: string + + /** + * An array of arguments passed to the task. + * For example, if a "sample" task was run as grunt sample:foo:bar, + * inside the task function, this.args would be ["foo", "bar"]. + */ + args: string[] + + /** + * An object generated from the arguments passed to the task. + * For example, if a "sample" task was run as grunt sample:foo:bar, + * inside the task function, this.flags would be {foo: true, bar: true}. + */ + flags: grunt.IFlag[] + + /** + * The number of grunt.log.error calls that occurred during this task. + * This can be used to fail a task if errors were logged during the task. + */ + errorCount: number + + /** + * Returns an options object. + * Properties of the optional defaultsObj argument will be overridden by any task-level options + * object properties, which will be further overridden in multi tasks by any target-level + * options object properties. + */ + // options(defaultsObj: T): ITaskOptions + // options(defaultsObj: T): T + options(defaultsObj: any): any + } + + /** + * {@link http://gruntjs.com/inside-tasks#inside-multi-tasks} + */ + interface IMultiTask extends ITask { + /** + * In a multi task, this property contains the name of the target currently being iterated over. + * For example, if a "sample" multi task was run as grunt sample:foo with the config data + * {sample: {foo: "bar"}}, inside the task function, this.target would be "foo". + */ + target: string + + /** + * In a multi task, all files specified using any Grunt-supported file formats and options, + * globbing patterns or dynamic mappings will automatically be normalized into a single format: + * the Files Array file format. + * + * What this means is that tasks don't need to contain a ton of boilerplate for explicitly + * handling custom file formats, globbing patterns, mapping source files to destination files + * or filtering out files or directories. A task user can just specify files per the Configuring + * tasks guide, and Grunt will handle all the details. + * + * Your task should iterate over the this.files array, utilizing the src and dest properties of + * each object in that array. The this.files property will always be an array. + * The src property will also always be an array, in case your task cares about multiple source + * files per destination file. + * + * @note it's possible that nonexistent files might be included in src values, + * so you may want to explicitly test that source files exist before using them. + */ + files: grunt.file.IFilesArray + + /** + * In a multi task, all src files files specified via any file format are reduced to a single array. + * If your task is "read only" and doesn't care about destination filepaths, + * use this array instead of this.files. + */ + filesSrc: string[] + + /** + * In a multi task, this is the actual data stored in the Grunt config object for the given target. + * For example, if a "sample" multi task was run as grunt sample:foo with the config data + * {sample: {foo: "bar"}}, inside the task function, this.data would be "bar". + * + * @note It is recommended that this.options this.files and this.filesSrc are used instead of this.data, + * as their values are normalized. + */ + data: T + } + + /** + * {@link http://gruntjs.com/configuring-tasks} + * + * A TaskConfig can be either be a full config or a compacted files config. + * @see ITaskCompactOptions + */ + interface ITaskOptions { + + options?: any + + // files?: grunt.file.IFilesArray + // files?: grunt.file.IFilesMap + files?: any + } + + /** + * @see ITaskOptions + */ + interface ITaskCompactOptions extends grunt.task.ITaskOptions, grunt.file.IFilesConfig {} + } + + module template { + + interface TemplateModule { + + /** + * Process a Lo-Dash template string. + * + * The template argument will be processed recursively until there are no more templates to process. + * + * The default data object is the entire config object, but if options.data is set, that object will + * be used instead. The default template delimiters are <% %> but if options.delimiters is set to a + * custom delimiter name, those template delimiters will be used instead. + * + * Inside templates, the grunt object is exposed so that you can do things like: + * <%= grunt.template.today('yyyy') %> + * + * @note if the data object already has a grunt property, the grunt API will not be accessible in templates. + */ + process(template: string): (options: any) => string + process(template: string, options: any): string + + /** + * Set the Lo-Dash template delimiters to a predefined set in case you grunt.util._.template + * needs to be called manually. + * + * The config delimiters <% %> are included by default. + */ + setDelimiters(name: string): void + + /** + * Add a named set of Lo-Dash template delimiters. + * + * You probably won't need to use this method, because the built-in delimiters should be sufficient, + * but you could always add {% %} or [% %] style delimiters. + */ + addDelimiters(name: string, opener: string, closer: string): void + + /** + * Format a date using the dateformat library. + * {@link http://github.com/felixge/node-dateformat} + * + * @note if you don't include the mask argument, dateFormat.masks.default is used + */ + date(date?: Date, format?: string): string + date(date?: number, format?: string): string + date(date?: string, format?: string): string + + /** + * Format today's date using the dateformat library using the current date and time. + * {@link http://github.com/felixge/node-dateformat} + * + * @note if you don't include the mask argument, dateFormat.masks.default is used + */ + today(format?: string): string + } + } + + module util { + + /** + * {@link http://gruntjs.com/api/grunt.util} + */ + interface UtilModule { + + /** + * Return the "kind" of a value. Like typeof but returns the internal [Class](Class/) value. + * Possible results are "number", "string", "boolean", "function", "regexp", "array", "date", + * "error", "null", "undefined" and the catch-all "object". + */ + kindOf(value: any): string + + /** + * Return a new Error instance (that can be thrown) with the appropriate message. + * If an Error object is specified instead of message that object will be returned. + * Also, if an Error object is specified for origError and Grunt was run with the --debug 9 option, + * the original Error stack will be dumped. + */ + error(message: string, origError?: Error): Error + error(error: Error, origError?: Error): Error + error(error: any, origError?: Error): Error + + /** + * The linefeed character, normalized for the current operating system. + * (\r\n on Windows, \n otherwise) + */ + linefeed: string + + /** + * Given a string, return a new string with all the linefeeds normalized for the current operating system. + * (\r\n on Windows, \n otherwise) + */ + normalizelf(str: string): string + + /** + * Recurse through nested objects and arrays, executing callbackFunction for each non-object value. + * If continueFunction returns false, a given object or value will be skipped. + */ + recurse(object: any, callbackFunction: (value: any) => void, continueFunction: (objOrValue: any) => boolean): void + + /** + * Return string str repeated n times. + */ + repeat(n: number, str: string): string + + /** + * Given str of "a/b", If n is 1, return "a" otherwise "b". + * You can specify a custom separator if '/' doesn't work for you. + */ + pluralize(n: number, str: string, separator?: string): string + + /** + * Spawn a child process, keeping track of its stdout, stderr and exit code. + * The method returns a reference to the spawned child. + * When the child exits, the done function is called. + * + * @param done a function with arguments: + * error - If the exit code was non-zero and a fallback wasn't specified, + * an Error object, otherwise null. + * result - The result object is an + * code - The numeric exit code. + */ + spawn(options: ISpawnOptions, done: (error: Error, result: ISpawnResult, code: number) => void): ISpawnedChild + + /** + * Given an array or array-like object, return an array. + * Great for converting arguments objects into arrays. + */ + toArray(arrayLikeObject: any): T[] + + /** + * Normalizes both "returns a value" and "passes result to a callback" functions to always + * pass a result to the specified callback. If the original function returns a value, + * that value will now be passed to the callback, which is specified as the last argument, + * after all other predefined arguments. If the original function passed a value to a callback, + * it will continue to do so. + */ + callbackify(syncOrAsyncFunction: () => R): + (callback: (result: R) => void) => void + callbackify(syncOrAsyncFunction: (a: A) => R): + (a: A, callback: (result: R) => void) => void + callbackify(syncOrAsyncFunction: (a: A, b: B) => R): + (a: A, b: B, callback: (result: R) => void) => void + callbackify(syncOrAsyncFunction: (a: A, b: B, c: C) => R): + (a: A, b: B, c: C, callback: (result: R) => void) => void + callbackify(syncOrAsyncFunction: (a: A, b: B, c: C, d: D) => R): + (a: A, b: B, c: C, d: D, callback: (result: R) => void) => void + + // Internal libraries + namespace: any + task: any + } + + /** + * {@link http://gruntjs.com/api/grunt.util#grunt.util.spawn} + */ + interface ISpawnOptions { + + /** + * The command to execute. It should be in the system path. + */ + cmd: string + + /** + * If specified, the same grunt bin that is currently running will be + * spawned as the child command, instead of the "cmd" option. + * Defaults to false. + */ + grunt?: boolean + + /** + * An array of arguments to pass to the command. + */ + args?: string[] + + /** + * Additional options for the Node.js child_process spawn method. + */ + opts?: ISpawnOptions + + /** + * If this value is set and an error occurs, it will be used as the value + * and null will be passed as the error value. + */ + fallback?: any + } + + /** + * @note When result is coerced to a string, the value is stdout if the exit code + * was zero, the fallback if the exit code was non-zero and a fallback was + * specified, or stderr if the exit code was non-zero and a fallback was + * not specified. + */ + interface ISpawnResult { + stdout: string + stderr: string + code: number + } + + /** + * {@link http://github.com/snbartell/node-spawn} + */ + interface ISpawnedChild { + /** + * Start the cmd with the options provided. + */ + start(): void + + /** + * Convenience function. Overrides options. restarts to 0. + * Runs command exactly once no matter the options passed into the constructor. + */ + once(): void + + /** + * Convenience function. Overrides options.restarts to -1. + * Runs command indefinitely no matter the options passed into the constructor. + */ + forever(): void + + /** + * Shut down the child and don't let it restart. + */ + kill(): void + } + } + + /* + * Common interfaces + */ + + interface IFlag { + [flag: string]: boolean + } + + /* + * Grunt module mixins. + */ + + interface IConfigComponents extends grunt.config.ConfigModule { + /** + * An alias + * @see grunt.config.ConfigModule.init + */ + initConfig(config: grunt.config.IProjectConfig): void + } + + interface ITaskComponents extends grunt.task.CommonTaskModule { + + /** + * The currently running task or multitask. + * @see IMultiTask for when to cast + */ + current: grunt.task.ITask + + /** + * Load task-related files from the specified directory, relative to the Gruntfile. + * This method can be used to load task-related files from a local Grunt plugin by + * specifying the path to that plugin's "tasks" subdirectory. + */ + loadTasks(tasksPath: string): void + + /** + * Load tasks from the specified Grunt plugin. + * This plugin must be installed locally via npm, and must be relative to the Gruntfile. + * Grunt plugins can be created by using the grunt-init gruntplugin template: grunt init:gruntplugin. + */ + loadNpmTasks(pluginName: string): void + } } -//////////////// -// Grunt File object -// http://gruntjs.com/api/grunt.file -//////////////// -interface IGruntFileObjectOptionsSimple { - encoding?: string; +/* GRUNT MODULE + **************/ + +/** + * The main Grunt module. + * + * {@link http://gruntjs.com/api/grunt} + */ +interface IGrunt extends grunt.IConfigComponents, grunt.fail.FailModule, grunt.ITaskComponents { + + config: grunt.config.ConfigModule + + event: grunt.event.EventModule + + fail: grunt.fail.FailModule + + file: grunt.file.FileModule + + log: grunt.log.LogModule + + option: grunt.option.OptionModule + + task: grunt.task.TaskModule + + template: grunt.template.TemplateModule + + util: grunt.util.UtilModule + + /** + * The current Grunt package.json metadata, as an object. + */ + package: node.NodePackage + + /** + * The current Grunt version, as a string. This is just a shortcut to the grunt.package.version property. + */ + version: string } -interface IGruntFileObjectOptions extends IGruntFileObjectOptionsSimple { - process?: Function; - noProcess?: any; -} -interface IGruntFileObject { - - // Character encoding - defaultEncoding: string; - - // Reading and writing - read(filepath: string, options?: IGruntFileObjectOptionsSimple): string; - readJSON(filepath: string, options?: IGruntFileObjectOptionsSimple): any; - readYAML(filepath: string, options?: IGruntFileObjectOptionsSimple): any; - write(filepath: string, contents: any, options?: IGruntFileObjectOptionsSimple): void; - copy(srcpath: string, destpath: string, options?: IGruntFileObjectOptions): void; - delete(filepath: string, options?: { force?: boolean; }): void; - - // Directories - mkdir(dirpath: string, mode?: number): void; - recurse(rootdir: string, callback: (abspath: string, rootdir: string, subdir: string, filename: string) => void): void; - - // Globbing patterns - expand(...patterns: string[]): string[]; - expand(options: Object, ...patterns: string[]): string[]; - expandMapping(patterns: string[], dest: string, options?: Object): any[]; - - match(patterns: string[], filepaths: string[]): string[]; - match(patterns: string[], filepaths: string): string[]; - match(patterns: string, filepaths: string[]): string[]; - match(patterns: string, filepaths: string): string[]; - match(options: Object, patterns: string[], filepaths: string[]): string[]; - match(options: Object, patterns: string[], filepaths: string): string[]; - match(options: Object, patterns: string, filepaths: string[]): string[]; - match(options: Object, patterns: string, filepaths: string): string[]; - - isMatch(patterns: string[], filepaths: string[]): boolean; - isMatch(patterns: string[], filepaths: string): boolean; - isMatch(patterns: string, filepaths: string[]): boolean; - isMatch(patterns: string, filepaths: string): boolean; - isMatch(options: Object, patterns: string[], filepaths: string[]): boolean; - isMatch(options: Object, patterns: string[], filepaths: string): boolean; - isMatch(options: Object, patterns: string, filepaths: string[]): boolean; - isMatch(options: Object, patterns: string, filepaths: string): boolean; - - // file types - exists(...paths: string[]): boolean; - isLink(...paths: string[]): boolean; - isDir(...paths: string[]): boolean; - isFile(...paths: string[]): boolean; - - // paths - isPathAbsolute(...paths: string[]): boolean; - arePathsEquivalent(...paths: string[]): boolean; - doesPathContain(ancestorPath: string, ...descendantPaths: string[]): boolean; - isPathCwd(...paths: string[]): boolean; - isPathInCwd(...paths: string[]): boolean; - setBase(...paths: string[]): void; - - // External libraries - glob: any; - minimatch: any; - findup: any; -} - -//////////////// -// 'this' when executing within a task -// http://gruntjs.com/api/inside-tasks -//////////////// -interface IGruntTaskThis { - async(): (err:any) => void; - requires(...taskNames: string[]): void; - requiresConfig(...props: string[]): void; - name: string; - nameArgs: string; - args: string[]; - flags: any; - errorCount: number; - options(defaults?: Object): any; -} - -//////////////// -// 'this' when executing within a multitask -// http://gruntjs.com/api/inside-tasks -//////////////// -interface IGruntMultiTaskThis extends IGruntTaskThis { - target: string; - files: IGruntFileArray[]; - filesSrc: string[]; - data: any; -} - -//////////////// -// Files array format -// http://gruntjs.com/configuring-tasks#files-array-format -//////////////// -interface IGruntFileArray { - src: string[]; - dest: string; - nonull?: boolean; - filter?: any; -} - -//////////////// -/// Globally called export function module.exports -//////////////// - -declare var exports: (grunt: IGrunt) => void; diff --git a/highcharts/highcharts-tests.ts.tscparams b/highcharts/highcharts-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/highcharts/highcharts-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/highcharts/highcharts.d.ts.tscparams b/highcharts/highcharts.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/highcharts/highcharts.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/history/history-tests.ts.tscparams b/history/history-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/history/history-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/history/history.d.ts.tscparams b/history/history.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/history/history.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/humane/humane-tests.ts.tscparams b/humane/humane-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/humane/humane-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/humane/humane.d.ts.tscparams b/humane/humane.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/humane/humane.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/i18next/i18next-tests.ts.tscparams b/i18next/i18next-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/i18next/i18next-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/i18next/i18next.d.ts.tscparams b/i18next/i18next.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/i18next/i18next.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/icheck/icheck-tests.ts.tscparams b/icheck/icheck-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/icheck/icheck-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/ix.js/ix-tests.ts b/ix.js/ix-tests.ts new file mode 100644 index 000000000..6953621ca --- /dev/null +++ b/ix.js/ix-tests.ts @@ -0,0 +1,116 @@ +/// + +var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string +var ec_ss = (a: string, b: string) => a == b; //equality comparer on string,string +var ec_nn = (a: number, b: number) => a === b; //equality comparer on number,number +var c_nn = (a: number, b: number) => a - b; //comparer on number,number + +// static + +Ix.Enumerable.throw(new Error("error")); +Ix.Enumerable.throwException(new Error("error")); + +var ax = Ix.Enumerable.generate(-100, a => a < 100, a=> a + 10, a=> a * 2); + +Ix.Enumerable.defer(() => ax); + +Ix.Enumerable.using(() => ax.getEnumerator(), e => Ix.Enumerable.return(e.getCurrent())); + +Ix.Enumerable.catch(ax, ax, ax); +Ix.Enumerable.catchException(ax, ax, ax); +Ix.Enumerable.catch(); +Ix.Enumerable.catchException(); + +Ix.Enumerable.onErrorResumeNext(ax, ax, ax); +Ix.Enumerable.onErrorResumeNext(); + +Ix.Enumerable.while(x => x.count() > 0, ax); +Ix.Enumerable.whileDo(x => x.count() > 0, ax); + +Ix.Enumerable.if(() => true, ax, ax); +Ix.Enumerable.ifThen(() => true, ax, ax); +Ix.Enumerable.if(() => true, ax); +Ix.Enumerable.ifThen(() => true, ax); + +Ix.Enumerable.doWhile(ax, x => x.count() > 0); + +Ix.Enumerable.case(() => 42, { 42: ax }, ax); +Ix.Enumerable.switchCase(() => 42, { 42: ax }, ax); +Ix.Enumerable.case(() => 42, { 42: ax }); +Ix.Enumerable.switchCase(() => 42, { 42: ax }); +Ix.Enumerable.case(() => "42", { "42": ax }, ax); +Ix.Enumerable.switchCase(() => "42", { "42": ax }, ax); +Ix.Enumerable.case(() => "42", { "42": ax }); +Ix.Enumerable.switchCase(() => "42", { "42": ax }); + +Ix.Enumerable.for(ax, a => ax); +Ix.Enumerable.forIn(ax, a => ax); + +// instance + +var bx: Ix.Enumerable; + +ax.isEmpty(); + +bx.minBy(b => b.length, c_nn); +bx.minBy(b => b.length); +bx.maxBy(b => b.length, c_nn); +bx.maxBy(b => b.length); + +ax.share(ax => bx); +ax.share(); + +ax.publish(ax => bx); +ax.publish(); + +ax.memoize(); + +ax.do({ onNext: (a: number) => console.log(a), onError: err => console.log(err), onCompleted: () => console.log("completed") }); +ax.do(a => console.log(a), err => console.log(err), () => console.log("completed")); +ax.do(a => console.log(a), err => console.log(err)); +ax.do((a: number) => console.log(a)); +ax.doAction({ onNext: (a: number) => console.log(a), onError: err => console.log(err), onCompleted: () => console.log("completed") }); +ax.doAction(a => console.log(a), err => console.log(err), () => console.log("completed")); +ax.doAction(a => console.log(a), err => console.log(err)); +ax.doAction((a: number) => console.log(a)); + +ax.bufferWithCount(10, 20); +ax.bufferWithCount(10); + +ax.ignoreElements(); + +bx.distinctBy(b => b.length, ec_nn); +bx.distinctBy(b => b.length); + +bx.distinctUntilChanged(b => b.length, ec_nn); +bx.distinctUntilChanged(b => b.length); +bx.distinctUntilChanged(); +bx.distinctUntilChanged(false, ec_ss); + +ax.expand(a => ax); + +ax.startWith(10, 20); + +ax.scan(0, (acc, a) => acc + a); +ax.scan((acc, a) => acc + a); + +ax.takeLast(10); +ax.skipLast(10); + +ax.repeat(10); +ax.repeat(); + +ax.catch(ax, ax, ax); +ax.catchException(ax, ax, ax); +ax.catch(ax); +ax.catchException(ax); +ax.catch(err => ax); +ax.catchException(err => ax); + +ax.finally(() => { }); +ax.finallyDo(() => { }); + +ax.onErrorResumeNext(ax); + +ax.retry(10); +ax.retry(); diff --git a/ix.js/ix.d.ts b/ix.js/ix.d.ts new file mode 100644 index 000000000..614a950fb --- /dev/null +++ b/ix.js/ix.d.ts @@ -0,0 +1,112 @@ +// Type definitions for IxJS 1.0.6 / ix.js +// Project: https://github.com/Reactive-Extensions/IxJS +// Definitions by: Igor Oleinikov + +/// + +declare module Ix { + + export interface Observer { + onNext? (value: T): void; + onError? (error: Error): void; + onCompleted? (): void; + } + + export interface Enumerable { + isEmpty(): boolean; + + minBy(keySelector: (item: T) => TKey, comparer: Comparer): Enumerable; + minBy(keySelector: (item: T) => number): Enumerable; + maxBy(keySelector: (item: T) => TKey, comparer: Comparer): Enumerable; + maxBy(keySelector: (item: T) => number): Enumerable; + + share(selector: (source: Enumerable) => Enumerable): Enumerable; + share(): Enumerable; + + publish(selector: (source: Enumerable) => Enumerable): Enumerable; + publish(): Enumerable; + + memoize(): Enumerable; + + do(onNext: (value: T) => void, onError?: (error: Error) => void, onCompleted?: () => void): Enumerable; + doAction(onNext: (value: T) => void, onError?: (error: Error) => void, onCompleted?: () => void): Enumerable; + do(onbserver: Observer): Enumerable; + doAction(onbserver: Observer): Enumerable; + + bufferWithCount(count: number, skip?: number): Enumerable; + + ignoreElements(): Enumerable; + + distinctBy(keySelector: (item: T) => TKey, comparer?: EqualityComparer): Enumerable; + + distinctUntilChanged(keySelector: (item: T) => TKey, comparer?: EqualityComparer): Enumerable; + distinctUntilChanged(): Enumerable; + // if need to set comparer without keySelector + distinctUntilChanged(_: boolean, comparer: EqualityComparer): Enumerable; + + expand(selector: (item: T) => Enumerable): Enumerable; + + startWith(...values: T[]): Enumerable; + + scan(seed: TSeed, accumulate: (acc: TAccumulator, item: T) => TAccumulator): Enumerable; + scan(accumulate: (acc: T, item: T) => T): Enumerable; + + takeLast(count: number): Enumerable; + skipLast(count: number): Enumerable; + + repeat(count?: number): Enumerable; + + catch(handler: (error: Error) => Enumerable): Enumerable; + catchException(handler: (error: Error) => Enumerable): Enumerable; + catch(second: Enumerable, ...other: Enumerable[]): Enumerable; + catchException(second: Enumerable, ...other: Enumerable[]): Enumerable; + + // todo: Enumerable>.catch(): Enumerable + //catch>(): Enumerable; + + finally(finallyAction: () => void): Enumerable; + finallyDo(finallyAction: () => void): Enumerable; + + onErrorResumeNext(second: Enumerable): Enumerable; + + retry(retryCount?: number): Enumerable; + } + + export interface EnumerableStatic { + throw(error: Error): Enumerable; + throwException(error: Error): Enumerable; + + defer(enumerableFactory: () => Enumerable): Enumerable; + + generate( + initialState: TState, + condition: Predicate, + iterate: (state: TState) => TState, + resultSelector: (state: TState) => TResult): Enumerable; + + using( + resourceFactory: () => TResource, + enumerableFactory: (resource: TResource) => Enumerable): Enumerable; + + catch(...sources: Enumerable[]): Enumerable; + catchException(...sources: Enumerable[]): Enumerable; + + onErrorResumeNext(...sources: Enumerable[]): Enumerable; + + while(condition: EnumerablePredicate>, source: Enumerable): Enumerable; + whileDo(condition: EnumerablePredicate>, source: Enumerable): Enumerable; + + if(condition: () => boolean, thenSource: Enumerable, elseSource?: Enumerable): Enumerable; + ifThen(condition: () => boolean, thenSource: Enumerable, elseSource?: Enumerable): Enumerable; + + doWhile(source: Enumerable, condition: EnumerablePredicate>): Enumerable; + + case(selector: () => number, sources: { [key: number]: Enumerable; }, defaultSource?: Enumerable): Enumerable; + case(selector: () => string, sources: { [key: string]: Enumerable; }, defaultSource?: Enumerable): Enumerable; + switchCase(selector: () => number, sources: { [key: number]: Enumerable; }, defaultSource?: Enumerable): Enumerable; + switchCase(selector: () => string, sources: { [key: string]: Enumerable; }, defaultSource?: Enumerable): Enumerable; + + for(source: Enumerable, resultSelector: EnumerableFunc): Enumerable; + forIn(source: Enumerable, resultSelector: EnumerableFunc): Enumerable; + } +} diff --git a/ix.js/l2o-tests.ts b/ix.js/l2o-tests.ts new file mode 100644 index 000000000..2399d4e9f --- /dev/null +++ b/ix.js/l2o-tests.ts @@ -0,0 +1,221 @@ +/// + +var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string +var ec_nn = (a: number, b: number) => a === b; //equality comparer on number,number +var c_nn = (a: number, b: number) => a - b; //comparer on number,number + +// static + +var ax = Ix.Enumerable.fromArray([0, 2, 7, 3, 4, 5]); + +var bx = Ix.Enumerable.create(() => { + var current = "."; + return Ix.Enumerator.create( + () => { current += "."; return true; }, + () => current, + () => { }); +}); + +Ix.Enumerator.create(() => true, () => 1); // without dispose method + +var cx = Ix.Enumerable.empty(); + +var dx = Ix.Enumerable.concat(ax, cx); + +var ex = Ix.Enumerable.return(42); +var fx = Ix.Enumerable.returnValue("42"); + +var gx = Ix.Enumerable.range(-100, 200); + +Ix.Enumerable.repeat(42, 42); +Ix.Enumerable.repeat(42); // infinite + +Ix.Enumerable.sequenceEqual(ax, fx, ec_ns); +Ix.Enumerable.sequenceEqual(ax, ex); // default comparer on same type + +// instance + +ax.getEnumerator(); + +ax.aggregate("", (acc, i) => acc + i, acc=> acc.length); +ax.aggregate("", (acc, i) => acc + i); +ax.aggregate((acc, i) => acc + i); + +ax.reduce((acc, i) => acc + i, 100); +ax.reduce((acc, i) => acc + i); + +ax.all(item => true); +ax.all(item => true, bx); +ax.every(item => true); +ax.every(item => true, bx); + +ax.any(); +ax.any(item => true); +ax.any(item => true, bx); +ax.some(); +ax.some(item => true); +ax.some(item => true, bx); + +ax.average(); +bx.average(item => item.length); +ax.min(); +bx.min(item => item.length); +ax.max(); +bx.max(item => item.length); +ax.sum(); +bx.sum(item => item.length); + +ax.concat(ax, cx, dx, ex, gx); + +ax.contains(10); +ax.contains("10", ec_ns); + +ax.count(); +ax.count(item=>false); +ax.count(item=> false, {}); + +cx.defaultIfEmpty(); +cx.defaultIfEmpty(10); + +dx.distinct(); +dx.distinct((d1, d2) => d1 === d2); + +ax.elementAt(2); +ax.elementAtOrDefault(2); + +//ax.except(bx, ec_ns); // bug https://typescript.codeplex.com/workitem/1841 +bx.except(fx); + +ax.first(); +ax.firstOrDefault(); +ax.last(); +ax.lastOrDefault(); +ax.single(); +ax.singleOrDefault(); + +ax.forEach(a => console.log(a)); +ax.forEach(a => console.log(a), cx); + +//bx.groupBy(b => b.length); // spec 3.5.2, waiting for restriction on generative recursion removal +bx.groupBy(b => b.length, b => "[" + b + "]"); +bx.groupBy(b => b.length, b => "[" + b + "]", (l, values) => l + values.count()); +bx.groupBy(b => b.length, false, (l, values) => l + values.count()); +bx.groupBy(b => b.length, b => "[" + b + "]", (l, values) => l + values.count(), ec_nn); +bx.groupBy(b => b.length, b => "[" + b + "]", false, (x, y) => x == y); +bx.groupBy(b => b.length, false, (l, values) => l + values.count(), ec_nn); +//bx.groupBy(b => b.length, false, false, ec_nn); // spec 3.5.2, waiting for restriction on generative recursion removal + +ax.groupJoin(bx, a => a, b => b, (a, b) => [a, b], ec_ns); +ax.groupJoin(bx, a => a, b => b.length, (a, b) => [a, b]); + +ax.join(bx, a => a, b => b, (a, b) => [a, b], ec_ns); +ax.join(bx, a => a, b => b.length, (a, b) => [a, b]); + +//ax.intersect(bx, ec_ns); // bug https://typescript.codeplex.com/workitem/1841 +ax.intersect(cx); +ax.union(cx); + +ax.orderBy(a=> -a).thenBy(a => a); +ax.orderBy(a=> -a, c_nn).thenBy(a => a, c_nn); +ax.orderByDescending(a=> -a).thenByDescending(a => a); +ax.orderByDescending(a=> -a, c_nn).thenByDescending(a => a, c_nn); + +ax.reverse(); + +ax.select(a=> a.toString()); +ax.select(a=> a.toString(), {}); +ax.map(a=> a.toString()); +ax.map(a=> a.toString(), {}); + +ax.selectMany(a=> bx); +ax.selectMany(a=> bx, (a, b) => [a, b]); + +ax.sequenceEqual(fx, ec_ns); +ax.sequenceEqual(ax, ec_nn); +ax.sequenceEqual(cx); + +ax.skip(10); +ax.skipWhile(a => a > 10); +ax.take(10); +ax.takeWhile(a => a > 10); + +ax.toArray(); + +bx.toDictionary(b => b.length, b => 10, ec_nn); +//bx.toDictionary(b => b.length, false, ec_nn); // spec 3.5.2, waiting for restriction on generative recursion removal +bx.toDictionary(b => b.length, b => 10); +//bx.toDictionary(b => b.length); // spec 3.5.2, waiting for restriction on generative recursion removal + +bx.toLookup(b => b.length, b => 10, ec_nn); +//bx.toLookup(b => b.length, false, ec_nn); // spec 3.5.2, waiting for restriction on generative recursion removal +bx.toLookup(b => b.length, b => 10); +//bx.toLookup(b => b.length); // spec 3.5.2, waiting for restriction on generative recursion removal + +ax.where(a=> a > 10, {}); +ax.where(a=> a > 10); +ax.filter(a=> a > 10, {}); +ax.filter(a=> a > 10); + +ax.zip(bx, (a: number, b: string) => [a, b]); +ax.zip(bx, (a, b) => [a, b]); + +// Disposable + +{ + var d: Ix.Disposable; + + d.dispose(); +} + +// Enumerator + +{ + var e: Ix.Enumerator; + + try { + while (e.moveNext()) { var c = e.getCurrent(); } + } + finally { + e.dispose(); + } +} + +// Dictionary + +{ + var dic = new Ix.Dictionary(0, ec_nn); + + var key = dic.toEnumerable().first().key; + var value = dic.toEnumerable().first().value; + + dic.add(1, "1"); + dic.remove(1); + dic.clear(); + dic.length(); + dic.tryGetValue(1); + dic.get(1); + dic.set(1, "1"); + dic.getValues(); + dic.has(1); +} + +// KeyValuePair + +{ + var kv: Ix.KeyValuePair; + var key = kv.key; + var value = kv.value; +} + +// Lookup + +{ + var lookup: Ix.Lookup; + + var key = lookup.toEnumerable().first().key; + lookup.toEnumerable().first().first(); + + lookup.has(1); + lookup.length(); + lookup.get(1).first(); +} \ No newline at end of file diff --git a/ix.js/l2o.d.ts b/ix.js/l2o.d.ts new file mode 100644 index 000000000..c3f3c415e --- /dev/null +++ b/ix.js/l2o.d.ts @@ -0,0 +1,256 @@ +// Type definitions for IxJS 1.0.6 / l2o.js +// Project: https://github.com/Reactive-Extensions/IxJS +// Definitions by: Igor Oleinikov + +declare module Ix { + export interface Disposable { + dispose(): void; + } + + export interface Enumerator extends Disposable { + moveNext(): boolean; + getCurrent(): T; + } + + export interface EnumeratorStatic { + new (moveNext: () => boolean, getCurrent: () => T, dispose: () => void): Enumerator; + create(moveNext: () => boolean, getCurrent: () => T, dispose?: () => void): Enumerator; + } + + var Enumerator: EnumeratorStatic; + + export interface EnumerableFunc { + (item: T, index: number, self: Enumerable): TResult; + } + export interface EnumerablePredicate extends EnumerableFunc { } + export interface Predicate { + (item: T): boolean; + } + export interface EqualityComparer { + (item1: TFirst, item2: TSecond): boolean; + } + export interface Comparer { + (item1: TFirst, item2: TSecond): number; + } + + export interface Enumerable { + // base functions + getEnumerator(): Enumerator; + + // "extension" functions + + aggregate(seed: TAccumulate, func: (accumulate: TAccumulate, current: T, index: number, self: Enumerable) => TAccumulate, resultSelector: (accumulate: TAccumulate) => TResult): TResult; + aggregate(seed: TAccumulate, func: (accumulate: TAccumulate, current: T, index: number, self: Enumerable) => TAccumulate): TAccumulate; + aggregate(func: (accumulate: T, current: T, index: number, self: Enumerable) => T): T; + + reduce(func: (accumulate: T, current: T, index: number, self: Enumerable) => T): T; + reduce(func: (accumulate: TAccumulate, current: T, index: number, self: Enumerable) => TAccumulate, seed: TAccumulate): TAccumulate; + + all(predicate: EnumerablePredicate, thisArg?: any): boolean; + every(predicate: EnumerablePredicate, thisArg?: any): boolean; // alias + + any(predicate?: EnumerablePredicate, thisArg?: any): boolean; + some(predicate?: EnumerablePredicate, thisArg?: any): boolean; // alias + + average(selector?: EnumerableFunc): number; + max(selector?: EnumerableFunc): number; + min(selector?: EnumerableFunc): number; + sum(selector?: EnumerableFunc): number; + + concat(...sources: Enumerable[]): Enumerable; + + contains(value: TValue, comparer: EqualityComparer): boolean; + contains(value: T): boolean; + + count(predicate?: EnumerablePredicate, thisArg?: any): number; + + defaultIfEmpty(defaultValue?: T): Enumerable; + + distinct(comparer?: EqualityComparer): Enumerable; + + elementAt(index: number): T; + elementAtOrDefault(index: number): T; + + except(second: Enumerable, comparer: EqualityComparer): Enumerable; + except(second: Enumerable): Enumerable; + + first(predicate?: Predicate): T; + firstOrDefault(predicate?: Predicate): T; + last(predicate?: Predicate): T; + lastOrDefault(predicate?: Predicate): T; + single(predicate?: Predicate): T; + singleOrDefault(predicate?: Predicate): T; + + forEach(action: EnumerableFunc, thisArg?: any): void; + + groupBy( + keySelector: (item: T) => TKey, + elementSelector: (item: T) => TElement, + resultSelector: (key: TKey, values: Enumerable) => TResult, + comparer?: EqualityComparer): Enumerable; + groupBy( + keySelector: (item: T) => TKey, + elementSelector: (item: T) => TElement): Grouping; + // spec 3.5.2, waiting for restriction on generative recursion removal + /*groupBy( + keySelector: (item: T) => TKey): Grouping;*/ + + // if need to set comparer without resultSelector + groupBy( + keySelector: (item: T) => TKey, + elementSelector: (item: T) => TElement, + _: boolean, + comparer: EqualityComparer): Grouping; + // if need to set resultSelector without elementSelector + groupBy( + keySelector: (item: T) => TKey, + _: boolean, + resultSelector: (key: TKey, values: Enumerable) => TResult, + comparer?: EqualityComparer): Enumerable; + // if need to set comparer without elementSelector and resultSelector + // spec 3.5.2, waiting for restriction on generative recursion removal + /*groupBy( + keySelector: (item: T) => TKey, + _: boolean, + __: boolean, + comparer: EqualityComparer): Grouping;*/ + + groupJoin( + inner: Enumerable, + outerKeySelector: (item: T) => TOuterKey, + innerKeySelector: (item: TInner) => TInnerKey, + resultSelector: (outer: T, innerSequence: Enumerable) => TResult, + comparer: EqualityComparer): Enumerable; + groupJoin( + inner: Enumerable, + outerKeySelector: (item: T) => TKey, + innerKeySelector: (item: TInner) => TKey, + resultSelector: (outer: T, innerSequence: Enumerable) => TResult): Enumerable; + + join( + inner: Enumerable, + outerKeySelector: (item: T) => TOuterKey, + innerKeySelector: (item: TInner) => TInnerKey, + resultSelector: (outer: T, inner: TInner) => TResult, + comparer: EqualityComparer): Enumerable; + join( + inner: Enumerable, + outerKeySelector: (item: T) => TKey, + innerKeySelector: (item: TInner) => TKey, + resultSelector: (outer: T, inner: TInner) => TResult): Enumerable; + + intersect(second: Enumerable, comparer: EqualityComparer): Enumerable; + intersect(second: Enumerable): Enumerable; + union(second: Enumerable, comparer?: EqualityComparer): Enumerable; + + orderBy(keySelector: (item: T) => TKey, comparer?: Comparer): OrderedEnumerable; + orderByDescending(keySelector: (item: T) => TKey, comparer?: Comparer): OrderedEnumerable; + + reverse(): Enumerable; + + select(selector: EnumerableFunc, thisArg?: any): Enumerable; + map(selector: EnumerableFunc, thisArg?: any): Enumerable; + + selectMany(collectionSelector: (item: T, index: number) => Enumerable, + resultSelector: (outer: T, inner: TCollection) => TResult): Enumerable; + selectMany(collectionSelector: (item: T, index: number) => Enumerable): Enumerable; + + sequenceEqual(second: Enumerable, comparer: EqualityComparer): boolean; + sequenceEqual(second: Enumerable): boolean; + + skip(count: number): Enumerable; + skipWhile(selector: EnumerablePredicate, thisArg?: any): Enumerable; + take(count: number): Enumerable; + takeWhile(selector: EnumerablePredicate, thisArg?: any): Enumerable; + + toArray(): T[]; + + toDictionary( + keySelector: (item: T) => TKey, + elementSelector: (item: T) => TValue, + comparer?: EqualityComparer): Dictionary; + // spec 3.5.2, waiting for restriction on generative recursion removal + /*toDictionary( + keySelector: (item: T) => TKey): Dictionary;*/ + // if need to set comparer without elementSelector + // spec 3.5.2, waiting for restriction on generative recursion removal + /*toDictionary( + keySelector: (item: T) => TKey, + _: boolean, + comparer: EqualityComparer): Dictionary;*/ + + toLookup( + keySelector: (item: T) => TKey, + elementSelector: (item: T) => TValue, + comparer?: EqualityComparer): Lookup; + // spec 3.5.2, waiting for restriction on generative recursion removal + /*toLookup( + keySelector: (item: T) => TKey): Lookup;*/ + // if need to set comparer without elementSelector + // spec 3.5.2, waiting for restriction on generative recursion removal + /*toLookup( + keySelector: (item: T) => TKey, + _: boolean, + comparer: EqualityComparer): Lookup;*/ + + where(selector: EnumerablePredicate, thisArg?: any): Enumerable; + filter(selector: EnumerablePredicate, thisArg?: any): Enumerable; + + zip(right: Enumerable, selector: (left: T, right: TRight) => TResult): Enumerable; + } + + export interface Grouping extends Enumerable { + key: TKey; + } + + export interface OrderedEnumerable extends Enumerable { + thenBy(keySelector: (item: T) => TKey, comparer?: Comparer): OrderedEnumerable; + thenByDescending(keySelector: (item: T) => TKey, comparer?: Comparer): OrderedEnumerable; + } + + class Dictionary { + constructor(capacity?: number, comparer?: EqualityComparer); + + toEnumerable(): Enumerable>; + + add(key: TKey, value: TValue): void; + remove(key: TKey): boolean; + clear(): void; + length(): number; + tryGetValue(key: TKey): TValue; + get(key: TKey): TValue; + set(key: TKey, value: TValue): void; + getValues(): TValue[]; + has(key: TKey): boolean; + } + + export interface KeyValuePair { + key: TKey; + value: TValue; + } + + export interface Lookup { + toEnumerable(): Enumerable>; + has(key: TKey): boolean; + length(): number; + get(key: TKey): Enumerable; + } + + export interface EnumerableStatic { + new (getEnumerator: () => Enumerator): Enumerable; + create(getEnumerator: () => Enumerator): Enumerable; + + concat(...sources: Enumerable[]): Enumerable; + empty(): Enumerable; + fromArray(array: T[]): Enumerable; + return(value: T): Enumerable; + returnValue(value: T): Enumerable; // alias for ; + repeat(value: T, repeatCount?: number): Enumerable; + + sequenceEqual(first: Enumerable, second: Enumerable, comparer: EqualityComparer): boolean; + sequenceEqual(first: Enumerable, second: Enumerable): boolean; + } + + var Enumerable: EnumerableStatic; +} \ No newline at end of file diff --git a/jake/jake-tests.ts.tscparams b/jake/jake-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jake/jake-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jake/jake.d.ts b/jake/jake.d.ts index f7e7a9e77..14d488bd3 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -201,14 +201,14 @@ declare module jake{ */ reenable(): void; - addListener(event: string, listener: Function); - on(event: string, listener: Function); - once(event: string, listener: Function): void; - removeListener(event: string, listener: Function): void; - removeAllListeners(event?: string): void; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, arg1?: any, arg2?: any): void; + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, arg1?: any, arg2?: any): boolean; } diff --git a/jake/jake.d.ts.tscparams b/jake/jake.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jake/jake.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jasmine-jquery/jasmine-jquery-tests.ts.tscparams b/jasmine-jquery/jasmine-jquery-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jasmine-jquery/jasmine-jquery-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jasmine-jquery/jasmine-jquery.d.ts.tscparams b/jasmine-jquery/jasmine-jquery.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jasmine-jquery/jasmine-jquery.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jasmine-matchers/jasmine-matchers-tests.ts.tscparams b/jasmine-matchers/jasmine-matchers-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jasmine-matchers/jasmine-matchers-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index 142d51bcb..2c6e836d2 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -32,6 +32,7 @@ declare module jasmine { function objectContaining(sample: any): ObjectContaining; function createSpy(name: string, originalFn?: Function): Spy; function createSpyObj(baseName: string, methodNames: any[]): any; + function createSpyObj(baseName: string, methodNames: any[]): T; function pp(value: any): string; function getEnv(): Env; diff --git a/jointjs/jointjs.d.ts.tscparams b/jointjs/jointjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jointjs/jointjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jqrangeslider/jqrangeslider-tests.ts.tscparams b/jqrangeslider/jqrangeslider-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jqrangeslider/jqrangeslider-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jqrangeslider/jqrangeslider.d.ts.tscparams b/jqrangeslider/jqrangeslider.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jqrangeslider/jqrangeslider.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.address/jquery.address.d.ts.tscparams b/jquery.address/jquery.address.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.address/jquery.address.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.base64/jquery.base64-tests.ts b/jquery.base64/jquery.base64-tests.ts new file mode 100644 index 000000000..5f6b6eaa6 --- /dev/null +++ b/jquery.base64/jquery.base64-tests.ts @@ -0,0 +1,8 @@ +/// +/// + +var encoded = $.base64.encode(""); +$.base64.decode(encoded); + +var encodedUTF8 = $.base64.encode("", true); +$.base64.decode(encodedUTF8, true); diff --git a/jquery.base64/jquery.base64.d.ts b/jquery.base64/jquery.base64.d.ts new file mode 100644 index 000000000..9af24ed01 --- /dev/null +++ b/jquery.base64/jquery.base64.d.ts @@ -0,0 +1,15 @@ +// Type definitions for jQuery Plugin - base64 codec +// Project: https://github.com/yatt/jquery.base64/ +// Definitions by: Shinya Mochizuki +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQueryBase64Static { + encode(data: string, isUTF8?: boolean): string; + decode(data: string, isUTF8?: boolean): string; +} + +interface JQueryStatic { + base64: JQueryBase64Static; +} diff --git a/jquery.bbq/jquery.bbq-tests.ts.tscparams b/jquery.bbq/jquery.bbq-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.bbq/jquery.bbq-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.bbq/jquery.bbq.d.ts.tscparams b/jquery.bbq/jquery.bbq.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.bbq/jquery.bbq.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.cleditor/jquery.cleditor-tests.ts b/jquery.cleditor/jquery.cleditor-tests.ts new file mode 100644 index 000000000..b29885150 --- /dev/null +++ b/jquery.cleditor/jquery.cleditor-tests.ts @@ -0,0 +1,42 @@ +/// +/// + +// cribbed from http://premiumsoftware.net/CLEditor/GettingStarted + +$(document).ready(function () { $("#input").cleditor(); }); + +$(document).ready(function() { + $("#input").cleditor({ + width: 500, // width not including margins, borders or padding + height: 250, // height not including margins, borders or padding + controls: // controls to add to the toolbar + "bold italic underline strikethrough subscript superscript | font size " + + "style | color highlight removeformat | bullets numbering | outdent " + + "indent | alignleft center alignright justify | undo redo | " + + "rule image link unlink | cut copy paste pastetext | print source", + colors: // colors in the color popup + "FFF FCC FC9 FF9 FFC 9F9 9FF CFF CCF FCF " + + "CCC F66 F96 FF6 FF3 6F9 3FF 6FF 99F F9F " + + "BBB F00 F90 FC6 FF0 3F3 6CC 3CF 66C C6C " + + "999 C00 F60 FC3 FC0 3C0 0CC 36F 63F C3C " + + "666 900 C60 C93 990 090 399 33F 60C 939 " + + "333 600 930 963 660 060 366 009 339 636 " + + "000 300 630 633 330 030 033 006 309 303", + fonts: // font names in the font popup + "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + + "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", + sizes: // sizes in the font size popup + "1,2,3,4,5,6,7", + styles: // styles in the style popup + [["Paragraph", "

"], ["Header 1", "

"], ["Header 2", "

"], + ["Header 3", "

"], ["Header 4","

"], ["Header 5","

"], + ["Header 6","
"]], + useCSS: false, // use CSS to style HTML when possible (not supported in ie) + docType: // Document type contained within the editor + '', + docCSSFile: // CSS file used to style the document contained within the editor + "", + bodyStyle: // style to assign to document body contained within the editor + "margin:4px; font:10pt Arial,Verdana; cursor:text" + }); + }); \ No newline at end of file diff --git a/jquery.cleditor/jquery.cleditor.d.ts b/jquery.cleditor/jquery.cleditor.d.ts new file mode 100644 index 000000000..c273f3227 --- /dev/null +++ b/jquery.cleditor/jquery.cleditor.d.ts @@ -0,0 +1,98 @@ +// Type definitions for jQuery CLEditor Plugin 1.4.3 +// Project: http://premiumsoftware.net/CLEditor +// Definitions by: Jeffery Grajkowski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * An editor is composed of a main div element used to hold a toolbar, + * a text area and an iframe. The toolbar can hold multiple groups + * which in turn hold multiple buttons. + */ +interface CLEditor { + $area: JQuery; + $frame: JQuery; + $main: JQuery; + $toolbar: JQuery; + disabled: boolean; + doc: Document; + options: JQueryCLEditorOptions; + change(handler: Function): CLEditor; + clear(): CLEditor; + disable(disabled: boolean): CLEditor; + execCommand(commands: string, value: any, useCSS?: boolean, button?: any): CLEditor; + focus(): CLEditor; + hidePopups(): CLEditor; + refresh(): CLEditor; + select(): CLEditor; + selectedHTML(): string; + selectedText(): string; + showMessage(message: string, button?: any): CLEditor; + sourceMode(): boolean; + updateFrame(): CLEditor; + updateTextArea(): CLEditor; +} + +interface JQueryCLEditorOptions { + width?: number; + height?: number; + controls?: string; + colors?: string; + fonts?: string; + sizes?: string; + styles?: string[][]; + useCSS?: boolean; + docType?: string; + docCSSFile?: string; + bodyStyle?: string; +} + +interface JQueryCLEditorButtonDefinition { + name: string; + title: string; + css?: any; + image?: string; + stripIndex?: number; + command?: string; + popupName?: string; + popupContent?: string; + getEnabled?: (data: JQueryCLEditorButtonDefinitionEventData) => boolean; + getPressed?: (data: JQueryCLEditorButtonDefinitionEventData) => boolean; + buttonClick?: (event: Event, data: JQueryCLEditorButtonDefinitionEventData) => boolean; + popupClick?: (event: Event, data: JQueryCLEditorButtonDefinitionEventData) => boolean; +} + +interface JQueryCLEditorButtonDefinitionEventData { + editor: CLEditor; + button: HTMLElement; + buttonName: string; + popup: HTMLElement; + popupName: string; + command: string; + value: any; + useCSS: boolean; +} + +/** + * This object contains global properties and methods used to create + * custom plugins and override built in functionality. + */ +interface JQueryCLEditorStatic { + defaultOptions: JQueryCLEditorOptions; + buttons: JQueryCLEditorButtonDefinition[]; + imagesPath: () => string; +} + +interface JQueryStatic { + cleditor: JQueryCLEditorStatic; +} + +interface JQuery { + /** + * If the cleditor object does not exist for a matched textarea element, + * it will be created using the default options combined with the supplied options. + * This is the core method for creating and selecting cleditor objects. + */ + cleditor(options?: JQueryCLEditorOptions): CLEditor; +} diff --git a/jquery.colorbox/jquery.colorbox-tests.ts.tscparams b/jquery.colorbox/jquery.colorbox-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.colorbox/jquery.colorbox-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.colorbox/jquery.colorbox.d.ts.tscparams b/jquery.colorbox/jquery.colorbox.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.colorbox/jquery.colorbox.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.contextMenu/jquery.contextMenu.d.ts.tscparams b/jquery.contextMenu/jquery.contextMenu.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.contextMenu/jquery.contextMenu.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.cycle/jquery.cycle-tests.ts.tscparams b/jquery.cycle/jquery.cycle-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.cycle/jquery.cycle-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.dataTables/jquery.dataTables-tests.ts.tscparams b/jquery.dataTables/jquery.dataTables-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.dataTables/jquery.dataTables-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.dynatree/jquery.dynatree.d.ts.tscparams b/jquery.dynatree/jquery.dynatree.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.dynatree/jquery.dynatree.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.jnotify/jquery.jnotify-tests.ts.tscparams b/jquery.jnotify/jquery.jnotify-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.jnotify/jquery.jnotify-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.jnotify/jquery.jnotify.d.ts.tscparams b/jquery.jnotify/jquery.jnotify.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.jnotify/jquery.jnotify.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.noty/jquery.noty.d.ts.tscparams b/jquery.noty/jquery.noty.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.noty/jquery.noty.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.payment/jquery.payment.d.ts.tscparams b/jquery.payment/jquery.payment.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.payment/jquery.payment.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.pickadate/jquery.pickadate-tests.ts b/jquery.pickadate/jquery.pickadate-tests.ts index 75ceafd47..f99d55ecc 100644 --- a/jquery.pickadate/jquery.pickadate-tests.ts +++ b/jquery.pickadate/jquery.pickadate-tests.ts @@ -39,7 +39,8 @@ $('.datepicker').pickadate({ // Escape any "rule" characters with an exclamation mark (!). format: 'You selecte!d: dddd, dd mmm, yyyy', formatSubmit: 'yyyy/mm/dd', - hiddenSuffix: '--submit' + hiddenPrefix: 'prefix__', + hiddenSuffix: '__suffix' }); $('.datepicker').pickadate({ @@ -88,6 +89,13 @@ $('.datepicker').pickadate({ ] }); +$('.datepicker').pickadate({ + disable: [ + new Date(2013, 3, 13), + new Date(2013, 3, 29) + ] +}); + $('.datepicker').pickadate({ disable: [ true, @@ -140,7 +148,8 @@ $('.timepicker').pickatime({ format: 'T!ime selected: h:i a', formatLabel: 'h:i a', formatSubmit: 'HH:i', - hiddenSuffix: '--submit' + hiddenPrefix: 'prefix__', + hiddenSuffix: '__suffix' }); $('.timepicker').pickatime({ @@ -266,6 +275,9 @@ picker.get('disable'); picker.set('clear'); +// reset disabled dates +picker.set('disable', undefined); + // Using arrays formatted as [YEAR,MONTH,DATE]. picker.set('select', [2013, 3, 20]); diff --git a/jquery.pickadate/jquery.pickadate-tests.ts.tscparams b/jquery.pickadate/jquery.pickadate-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.pickadate/jquery.pickadate-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.pickadate/jquery.pickadate.d.ts b/jquery.pickadate/jquery.pickadate.d.ts index 7d9531ecd..077ae15cd 100644 --- a/jquery.pickadate/jquery.pickadate.d.ts +++ b/jquery.pickadate/jquery.pickadate.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pickadate.js 3.2.0 +// Type definitions for pickadate.js 3.3.0 // Project: https://github.com/amsul/pickadate.js // Definitions by: Theodore Brown // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -37,6 +37,7 @@ interface pickadateOptions extends pickerOptions { // Formats format?: string; // default 'd mmmm, yyyy' formatSubmit?: string; // e.g. 'yyyy/mm/dd' + hiddenPrefix?: string; // default undefined hiddenSuffix?: string; // default '_submit' // Dropdown selectors @@ -51,7 +52,7 @@ interface pickadateOptions extends pickerOptions { max?: any; // Disable dates - disable?: any[]; // arrays formatted as [YEAR,MONTH,DATE] or integers representing days of the week (from 1 to 7). Switch to whitelist by setting first item in collection to `true`. + disable?: any[]; // Date objects, arrays formatted as [YEAR,MONTH,DATE], or integers representing days of the week (from 1 to 7). Switch to whitelist by setting first item in collection to `true`. // Classes klass?: { @@ -119,6 +120,7 @@ interface pickatimeOptions extends pickerOptions { format?: string; // default 'h:i A' formatLabel?: any; formatSubmit?: string; + hiddenPrefix?: string; // default undefined hiddenSuffix?: string; // default '_submit' // Time intervals diff --git a/jquery.pickadate/jquery.pickadate.d.ts.tscparams b/jquery.pickadate/jquery.pickadate.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.pickadate/jquery.pickadate.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.timeago/jquery.timeago-tests.ts.tscparams b/jquery.timeago/jquery.timeago-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.timeago/jquery.timeago-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.timeago/jquery.timeago.d.ts b/jquery.timeago/jquery.timeago.d.ts index b1a1eab3f..109a7b0a8 100644 --- a/jquery.timeago/jquery.timeago.d.ts +++ b/jquery.timeago/jquery.timeago.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jQuery.timeago.js 1.0.2 +// Type definitions for jQuery.timeago.js 1.0.2 // Project: http://timeago.yarp.com/ -// Definitions by: Franois Guillot +// Definitions by: François Guillot // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/jquery.timepicker/jquery.timepicker-tests.ts.tscparams b/jquery.timepicker/jquery.timepicker-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.timepicker/jquery.timepicker-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.timepicker/jquery.timepicker.d.ts.tscparams b/jquery.timepicker/jquery.timepicker.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.timepicker/jquery.timepicker.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.timer/jquery.timer-tests.ts b/jquery.timer/jquery.timer-tests.ts new file mode 100644 index 000000000..2e48bbe89 --- /dev/null +++ b/jquery.timer/jquery.timer-tests.ts @@ -0,0 +1,31 @@ +/// +/// + + // Create the timer + $("body").timer( + function () { + console.log("This function just got called"); + }, 10000, true + ); + + $("body").timer.set({ time: 5000 }); // Change the time from 10000 millseconds to 5000 milliseconds + $("body").timer.toggle(false); // Reset the timer + $("body").timer.stop(); // Stop the timer + $("body").timer.play(); // Start / play the timer + + // #region Outputting if timer is active or not + var isTimerActive = $("body").timer.isActive; // Define boolean isActive as isTimerActive + if (isTimerActive == true){ + console.log("Timer is active!"); + } + else{ + console.log("Timer is not active!"); + } + // #endregion + + // #region Get time remaining + console.log("Time remaining on timer: " + $("body").timer.remaining.toString); + // #endregion + + $("body").timer.stop(); // Stop the timer once more for the purpose of the tests (to test once()) + $("body").timer.once(1000); // Run the timer ONCE in 1 second \ No newline at end of file diff --git a/jquery.timer/jquery.timer-tests.ts.tscparams b/jquery.timer/jquery.timer-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.timer/jquery.timer-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.timer/jquery.timer.d.ts b/jquery.timer/jquery.timer.d.ts new file mode 100644 index 000000000..777758507 --- /dev/null +++ b/jquery.timer/jquery.timer.d.ts @@ -0,0 +1,31 @@ +// Type definitions for jQueryTimer 1.0 +// Project: https://github.com/jchavannes/jquery-timer +// Definitions by: Joshua Strobl +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQueryTimer { + // #region Constructors + (action?: Function, time?: Number, autostart?: Boolean): Object; + set(any): Object; + // #endregion + + // #region Actions + once(time: Number): Object; + play(reset?: Boolean): Object; + pause(): Object; + stop(): Object; + toggle(reset?: Boolean): Object; + // #endregion + + // #region Properties + isActive: Boolean; + remaining: Number; + // #endregion + +} + +interface JQuery { + timer: JQueryTimer; +} \ No newline at end of file diff --git a/jquery.timer/jquery.timer.d.ts.tscparams b/jquery.timer/jquery.timer.d.ts.tscparams new file mode 100644 index 000000000..3cc762b55 --- /dev/null +++ b/jquery.timer/jquery.timer.d.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file diff --git a/jquery.ui.layout/jquery.ui.layout.d.ts.tscparams b/jquery.ui.layout/jquery.ui.layout.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.ui.layout/jquery.ui.layout.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.validation/jquery.validation-tests.ts.tscparams b/jquery.validation/jquery.validation-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.validation/jquery.validation-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery.watermark/jquery.watermark-tests.ts.tscparams b/jquery.watermark/jquery.watermark-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery.watermark/jquery.watermark-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery/jquery-tests.ts.tscparams b/jquery/jquery-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquery/jquery-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index e824cf298..332ee75da 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -421,14 +421,14 @@ interface JQuery { prop(map: any): JQuery; prop(propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; - removeAttr(attributeName: any): JQuery; + removeAttr(attributeName: string): JQuery; - removeClass(className?: any): JQuery; + removeClass(className?: string): JQuery; removeClass(func: (index: any, cls: any) => any): JQuery; - removeProp(propertyName: any): JQuery; + removeProp(propertyName: string): JQuery; - toggleClass(className: any, swtch?: boolean): JQuery; + toggleClass(className: string, swtch?: boolean): JQuery; toggleClass(swtch?: boolean): JQuery; toggleClass(func: (index: any, cls: any, swtch: any) => any): JQuery; @@ -614,8 +614,9 @@ interface JQuery { off(events?: string, selector?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; off(eventsMap: { [key: string]: any; }, selector?: any): JQuery; - on(events: string, selector?: any, data?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; - on(events: string, selector?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + on(events: string, selector?: string, data?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + on(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + on(events: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; on(eventsMap: { [key: string]: any; }, selector?: any, data?: any): JQuery; one(events: string, selector?: any, data?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; diff --git a/jquerymobile/jquerymobile-tests.ts.tscparams b/jquerymobile/jquerymobile-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquerymobile/jquerymobile-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jquerymobile/jquerymobile.d.ts.tscparams b/jquerymobile/jquerymobile.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jquerymobile/jquerymobile.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jqueryui/jqueryui-tests.ts.tscparams b/jqueryui/jqueryui-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jqueryui/jqueryui-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 42de3a3af..1a09df7fd 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -73,7 +73,7 @@ declare module JQueryUI { } interface Autocomplete extends Widget, AutocompleteOptions, AutocompleteEvents { - escapeRegex: (string) => string; + escapeRegex: (value: string) => string; } @@ -154,7 +154,7 @@ declare module JQueryUI { interface Datepicker extends Widget, DatepickerOptions { regional: { [languageCod3: string]: any; }; - setDefaults(defaults: DatepickerOptions); + setDefaults(defaults: DatepickerOptions): void; formatDate(format: string, date: Date, settings?: DatepickerFormatDateOptions): string; parseDate(format: string, date: string, settings?: DatepickerFormatDateOptions): Date; iso8601Week(date: Date): void; diff --git a/jqueryui/jqueryui.d.ts.tscparams b/jqueryui/jqueryui.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jqueryui/jqueryui.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/js-signals/js-signals.d.ts.tscparams b/js-signals/js-signals.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/js-signals/js-signals.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jscrollpane/jscrollpane.d.ts.tscparams b/jscrollpane/jscrollpane.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jscrollpane/jscrollpane.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsdeferred/jsdeferred-tests.ts.tscparams b/jsdeferred/jsdeferred-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsdeferred/jsdeferred-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsdeferred/jsdeferred.d.ts.tscparams b/jsdeferred/jsdeferred.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsdeferred/jsdeferred.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsfl/jsfl.d.ts.tscparams b/jsfl/jsfl.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsfl/jsfl.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsfl/xJSFL.d.ts.tscparams b/jsfl/xJSFL.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsfl/xJSFL.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsoneditoronline/jsoneditoronline-tests.ts.tscparams b/jsoneditoronline/jsoneditoronline-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsoneditoronline/jsoneditoronline-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsoneditoronline/jsoneditoronline.d.ts.tscparams b/jsoneditoronline/jsoneditoronline.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsoneditoronline/jsoneditoronline.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jsplumb/jquery.jsPlumb.d.ts.tscparams b/jsplumb/jquery.jsPlumb.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jsplumb/jquery.jsPlumb.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/jstorage/jstorage-tests.ts.tscparams b/jstorage/jstorage-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jstorage/jstorage-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockback/knockback.d.ts.tscparams b/knockback/knockback.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockback/knockback.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams b/knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.deferred.updates/knockout.deferred.updates.d.ts b/knockout.deferred.updates/knockout.deferred.updates.d.ts index 7822c7d95..1371f3263 100644 --- a/knockout.deferred.updates/knockout.deferred.updates.d.ts +++ b/knockout.deferred.updates/knockout.deferred.updates.d.ts @@ -30,7 +30,7 @@ interface KnockoutComputedStatic { deferUpdates: boolean; } -interface KnockoutComputedFunctions { +interface KnockoutSubscription { deferUpdates: boolean; } diff --git a/knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams b/knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.editables/ko.editables.d.ts.tscparams b/knockout.editables/ko.editables.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.editables/ko.editables.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.es5/knockout.es5-tests.ts b/knockout.es5/knockout.es5-tests.ts index f8faf9529..c51b9bc9d 100644 --- a/knockout.es5/knockout.es5-tests.ts +++ b/knockout.es5/knockout.es5-tests.ts @@ -1,4 +1,4 @@ -/// +/// var empty = {}, obj = { a: 'string', b: 123, c: true, d: empty }, @@ -75,3 +75,12 @@ anOrder.lines.shift(); console.log(someOrderLine.subtotal == someOrderLine.getSubtotal()); // true console.log(anOrder.lines.length); // 1 + +//Array methods +anOrder.lines.remove(someOrderLine); +anOrder.lines.removeAll([someOrderLine]); +anOrder.lines.removeAll(); + +anOrder.lines.destroy(someOrderLine); +anOrder.lines.destroyAll([someOrderLine]); +anOrder.lines.destroyAll(); \ No newline at end of file diff --git a/knockout.es5/knockout.es5-tests.ts.tscparams b/knockout.es5/knockout.es5-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.es5/knockout.es5-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.es5/knockout.es5.d.ts b/knockout.es5/knockout.es5.d.ts index c546e1beb..868655545 100644 --- a/knockout.es5/knockout.es5.d.ts +++ b/knockout.es5/knockout.es5.d.ts @@ -8,7 +8,22 @@ interface KnockoutStatic { track(obj: any, propertyNames?: Array): any; defineProperty(obj: any, propertyName: string, evaluator: Function): any; - defineProperty(obj: any, propertyName: string, options: { get: () => any; set?: (value: any) => void; }): any; + defineProperty(obj: any, propertyName: string, options: KnockoutDefinePropertyOptions): any; getObservable(obj: any, propertyName: string): KnockoutObservable; valueHasMutated(obj: any, propertyName: string): void; +} + +interface KnockoutDefinePropertyOptions { + get(): any; + set?(value: any): void; +} + +interface Array { + remove(item): T[]; + removeAll(items: T[]): T[]; + removeAll(): T[]; + + destroy(item: T): void; + destroyAll(items: T[]): void; + destroyAll(): void; } \ No newline at end of file diff --git a/knockout.es5/knockout.es5.d.ts.tscparams b/knockout.es5/knockout.es5.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.es5/knockout.es5.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.mapper/knockout.mapper.d.ts.tscparams b/knockout.mapper/knockout.mapper.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.mapper/knockout.mapper.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.mapping/knockout.mapping.d.ts.tscparams b/knockout.mapping/knockout.mapping.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.mapping/knockout.mapping.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.postbox/knockout-postbox.d.ts b/knockout.postbox/knockout-postbox.d.ts index 3e6698851..daa35458a 100644 --- a/knockout.postbox/knockout-postbox.d.ts +++ b/knockout.postbox/knockout-postbox.d.ts @@ -19,6 +19,14 @@ interface KnockoutObservable { syncWith(topic: string, initializeWithLatestValue?: boolean, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservable; } +interface KnockoutObservableArray { + subscribeTo(topic: string, useLastPublishedValueToInitialize?: boolean, transform?: (val: any) => T): KnockoutObservableArray; + unsubscribeFrom(topic: string): KnockoutObservableArray; + publishOn(topic: string, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservableArray; + stopPublishingOn(topic: string): KnockoutObservableArray; + syncWith(topic: string, initializeWithLatestValue?: boolean, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservableArray; +} + interface KnockoutStatic { postbox: KnockoutPostBox; } \ No newline at end of file diff --git a/knockout.postbox/knockout-postbox.d.ts.tscparams b/knockout.postbox/knockout-postbox.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.postbox/knockout-postbox.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.rx/knockout.rx-tests.ts b/knockout.rx/knockout.rx-tests.ts new file mode 100644 index 000000000..674e9bb6a --- /dev/null +++ b/knockout.rx/knockout.rx-tests.ts @@ -0,0 +1,12 @@ +/// + +var ax: Rx.IObservable; + +var ao = ax.toKoObservable(); + +ao(100); +ao.getSubscriptionsCount(); + +ao.toObservable(); +ao.toObservable("change"); +ao.toObservable("error"); \ No newline at end of file diff --git a/knockout.rx/knockout.rx-tests.ts.tscparams b/knockout.rx/knockout.rx-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.rx/knockout.rx-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.rx/knockout.rx.d.ts b/knockout.rx/knockout.rx.d.ts new file mode 100644 index 000000000..4f44153d8 --- /dev/null +++ b/knockout.rx/knockout.rx.d.ts @@ -0,0 +1,26 @@ +// Type definitions for knockout.rx 0.1 +// Project: https://github.com/Igorbek/knockout.rx +// Definitions by: Igor Oleinikov + +/// +/// + +interface KnockoutSubscribableFunctions { + toObservable(event?: string): Rx.IObservable; + toObservable(event: string): Rx.IObservable; +} + +interface KnockoutObservableFunctions { + toObservableWithReplyLatest(): Rx.IObservable; +} + +interface KnockoutComputedFunctions { + toObservableWithReplyLatest(): Rx.IObservable; +} + +declare module Rx { + interface IObservable { + toKoSubscribable(): KnockoutSubscribable; + toKoObservable(initialValue?: T): KnockoutObservable; + } +} diff --git a/knockout.rx/knockout.rx.d.ts.tscparams b/knockout.rx/knockout.rx.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.rx/knockout.rx.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.validation/knockout.validation.d.ts b/knockout.validation/knockout.validation.d.ts index 725902e60..2e00c5223 100644 --- a/knockout.validation/knockout.validation.d.ts +++ b/knockout.validation/knockout.validation.d.ts @@ -117,10 +117,10 @@ interface KnockoutValidationStatic { addRule(observable: KnockoutObservable, rule: KnockoutValidationRule): KnockoutObservable; - addAnonymousRule(observable: KnockoutObservableBase, ruleObj: KnockoutValidationAnonymousRuleDefinition): void; + addAnonymousRule(observable: KnockoutObservable, ruleObj: KnockoutValidationAnonymousRuleDefinition): void; insertValidationMessage(element: Element): Element; - parseInputValidationAttributes(element: Element, valueAccessor: () => KnockoutObservableBase): void; + parseInputValidationAttributes(element: Element, valueAccessor: () => KnockoutObservable): void; rules: KnockoutValidationRuleDefinitions; @@ -129,12 +129,12 @@ interface KnockoutValidationStatic { utils: KnockoutValidationUtils; localize(msgTranslations: any): void; - validateObservable(observable: KnockoutObservableBase): boolean; + validateObservable(observable: KnockoutObservable): boolean; } interface KnockoutStatic { validation: KnockoutValidationStatic; - validatedObservable(initialValue: any): KnockoutObservableBase; + validatedObservable(initialValue: any): KnockoutObservable; applyBindingsWithValidation(viewModel: any, rootNode?: any, options?: KnockoutValidationConfiguration): void; } diff --git a/knockout.validation/knockout.validation.d.ts.tscparams b/knockout.validation/knockout.validation.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.validation/knockout.validation.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout.viewmodel/knockout.viewmodel.d.ts.tscparams b/knockout.viewmodel/knockout.viewmodel.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout.viewmodel/knockout.viewmodel.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout/all-tests.ts.tscparams b/knockout/all-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout/all-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout/knockout.amd.d.ts b/knockout/knockout.amd.d.ts index 960a0286d..7eb134612 100644 --- a/knockout/knockout.amd.d.ts +++ b/knockout/knockout.amd.d.ts @@ -24,10 +24,10 @@ declare module 'knockout' { export function isObservable(instance: any): boolean; export function isComputed(instance: any): boolean; export function dataFor(node: any): any; - export function removeNode(node: Element); - export function cleanNode(node: Element); - export function renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any); - export function renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any); + export function removeNode(node: Element): void; + export function cleanNode(node: Element): Element; + export function renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; + export function renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; ////////////////////////////////// //// templateSources.js @@ -44,9 +44,10 @@ declare module 'knockout' { //// templateRewriting.js //////////////////////////////////// export var templateRewriting: { - ensureTemplateIsRewritten(template, templateEngine, templateDocument); - memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine); - applyMemoizedBindingsToNextSibling(bindings); + ensureTemplateIsRewritten(template: Node, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any; + ensureTemplateIsRewritten(template: string, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any; + memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine): any; + applyMemoizedBindingsToNextSibling(bindings: any, nodeName: string): string; }; //////////////////////////////////// //// nativeTemplateEngine.js @@ -61,16 +62,25 @@ declare module 'knockout' { //////////////////////////////////// export var jqueryTmplTemplateEngine: { prototype: KnockoutTemplateEngine; - renderTemplateSource(templateSource, bindingContext, options); + renderTemplateSource(templateSource: Object, bindingContext: KnockoutBindingContext, options: Object): Node[]; createJavaScriptEvaluatorBlock(script: string): string; - addTemplate(templateName, templateMarkup); + addTemplate(templateName: string, templateMarkup: string): void; }; //////////////////////////////////// //// templating.js //////////////////////////////////// - export function setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine); - export function renderTemplate(template, dataOrBindingContext, options, targetNodeOrNodeArray, renderMode); - export function renderTemplateForEach(template, arrayOrObservableArray, options, targetNode, parentBindingContext); + export function renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + export function renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + export function renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + export function renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + export function renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + export function renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + export function renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + export function renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + export function renderTemplateForEach(template: Function, arrayOrObservableArray: Array, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + export function renderTemplateForEach(template: any, arrayOrObservableArray: Array, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + export function renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + export function renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable < Array>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; export var expressionRewriting: { bindingRewriteValidators: any; }; diff --git a/knockout/knockout.amd.d.ts.tscparams b/knockout/knockout.amd.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout/knockout.amd.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 08f7bc88b..79d0c1737 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -4,25 +4,18 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface KnockoutSubscribableFunctions { - extend(source); - dispose(): void; - peek(): any; - valueHasMutated(): void; - - valueWillMutate(): void; +interface KnockoutSubscribableFunctions { + notifySubscribers(valueToWrite: T, event?: string): void; } -interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions { - getDependenciesCount(): number; - getSubscriptionsCount(): number; - hasWriteFunction(): boolean; +interface KnockoutComputedFunctions { } -interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions { +interface KnockoutObservableFunctions { + equalityComparer(a: any, b: any): boolean; } -interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions { +interface KnockoutObservableArrayFunctions { // General Array functions indexOf(searchElement: T, fromIndex?: number): number; slice(start: number, end?: number): T[]; @@ -34,12 +27,13 @@ interface KnockoutObservableArrayFunctions extends KnockoutObservableFunction unshift(...items: T[]): number; reverse(): T[]; sort(): void; - sort(compareFunction): void; + sort(compareFunction: (left: any, right: any) => number): void; // Ko specific replace(oldItem: T, newItem: T): void; - remove(item): T[]; + remove(item: T): T[]; + remove(removeFunction: (item: T) => boolean): T[]; removeAll(items: T[]): T[]; removeAll(): T[]; @@ -49,18 +43,24 @@ interface KnockoutObservableArrayFunctions extends KnockoutObservableFunction } interface KnockoutSubscribableStatic { - fn: KnockoutSubscribableFunctions; + fn: KnockoutSubscribableFunctions; - new (): KnockoutSubscription; + new (): KnockoutSubscribable; } -interface KnockoutSubscription extends KnockoutSubscribableFunctions { - subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription; - notifySubscribers(valueToWrite, topic?: string); +interface KnockoutSubscription { + dispose(): void; +} + +interface KnockoutSubscribable extends KnockoutSubscribableFunctions { + subscribe(callback: (newValue: T) => void, target?: any, event?: string): KnockoutSubscription; + subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable; + getSubscriptionsCount(): number; } interface KnockoutComputedStatic { - fn: KnockoutComputedFunctions; + fn: KnockoutComputedFunctions; (): KnockoutComputed; (func: () => T, context?: any, options?: any): KnockoutComputed; @@ -68,51 +68,50 @@ interface KnockoutComputedStatic { (options?: any): KnockoutComputed; } -interface KnockoutComputed extends KnockoutComputedFunctions { - (): T; - (value: T): void; +interface KnockoutComputed extends KnockoutSubscribable, KnockoutComputedFunctions { + (): T; + (value: T): void; - subscribe(callback: (newValue: T) => void, target?:any, topic?: string): KnockoutSubscription; - notifySubscribers(valueToWrite: T, topic?: string); + peek(): T; + dispose(): void; + isActive(): boolean; + getDependenciesCount(): number; + extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed; } interface KnockoutObservableArrayStatic { - fn: KnockoutObservableArrayFunctions; (value?: T[]): KnockoutObservableArray; } -interface KnockoutObservableArray extends KnockoutObservableArrayFunctions { - (): T[]; - (value: T[]): void; - - subscribe(callback: (newValue: T[]) => void, target?:any, topic?: string): KnockoutSubscription; - notifySubscribers(valueToWrite: T[], topic?: string); +interface KnockoutObservableArray extends KnockoutObservable, KnockoutObservableArrayFunctions { + extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray; } interface KnockoutObservableStatic { - fn: KnockoutObservableFunctions; + fn: KnockoutObservableFunctions; (value?: T): KnockoutObservable; } -/** use as method to get/set the value */ -interface KnockoutObservableBase extends KnockoutObservableFunctions { - getSubscriptionsCount(): number; -} +interface KnockoutObservable extends KnockoutSubscribable, KnockoutObservableFunctions { + (): T; + (value: T): void; -interface KnockoutObservable extends KnockoutObservableBase { - (): T; - (value: T): void; - - subscribe(callback: (newValue: T) => void, target?:any, topic?: string): KnockoutSubscription; - notifySubscribers(valueToWrite: T, topic?: string); + peek(): T; + valueHasMutated(): void; + valueWillMutate(): void; + extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable; } interface KnockoutComputedDefine { - read(): T; - write(T); + read(): T; + write? (value: T): void; + disposeWhenNodeIsRemoved?: Node; + disposeWhen? (): boolean; + owner?: any; + deferEvaluation?: boolean; } interface KnockoutBindingContext { @@ -123,8 +122,8 @@ interface KnockoutBindingContext { $index?: number; $parentContext?: KnockoutBindingContext; - extend(any): any; - createChildContext(any): any; + extend(properties: any): any; + createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; } interface KnockoutBindingHandler { @@ -168,23 +167,23 @@ interface KnockoutBindingHandlers { } interface KnockoutMemoization { - memoize(callback); - unmemoize(memoId, callbackParams); - unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray); - parseMemoText(memoText); + memoize(callback: () => string): string; + unmemoize(memoId: string, callbackParams: Array): boolean; + unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: Array): boolean; + parseMemoText(memoText: string): string; } interface KnockoutVirtualElement {} interface KnockoutVirtualElements { allowedBindings: { [bindingName: string]: boolean; }; - emptyNode( e: KnockoutVirtualElement ); - firstChild( e: KnockoutVirtualElement ); - insertAfter( container: KnockoutVirtualElement, nodeToInsert: HTMLElement, insertAfter: HTMLElement ); - nextSibling( e: KnockoutVirtualElement ); - prepend( e: KnockoutVirtualElement, toInsert: HTMLElement ); - setDomNodeChildren( e: KnockoutVirtualElement, newChildren: { length: number;[index: number]: HTMLElement; } ); - childNodes( e: KnockoutVirtualElement ): HTMLElement[]; + emptyNode(node: KnockoutVirtualElement ): void; + firstChild(node: KnockoutVirtualElement ): KnockoutVirtualElement; + insertAfter( container: KnockoutVirtualElement, nodeToInsert: HTMLElement, insertAfter: HTMLElement ): void; + nextSibling(node: KnockoutVirtualElement): HTMLElement; + prepend(node: KnockoutVirtualElement, toInsert: HTMLElement ): void; + setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: HTMLElement; } ): void; + childNodes(node: KnockoutVirtualElement ): HTMLElement[]; } interface KnockoutExtenders { @@ -198,11 +197,11 @@ interface KnockoutUtils { // utils.domManipulation.js ////////////////////////////////// - simpleHtmlParse(html: string); + simpleHtmlParse(html: string): Array; - jQueryHtmlParse(html: string); + jQueryHtmlParse(html: string): Array; - parseHtmlFragment(html: string); + parseHtmlFragment(html: string): Array; setHtml(node: Element, html: string): void; @@ -213,13 +212,13 @@ interface KnockoutUtils { ////////////////////////////////// domData: { - get (node: Element, key: string); + get (node: Element, key: string): any; - set (node: Element, key: string, value: any); + set (node: Element, key: string, value: any): void; - getAll(node: Element, createIfNotFound: boolean); + getAll(node: Element, createIfNotFound: boolean): any; - clear(node: Element); + clear(node: Element): boolean; }; ////////////////////////////////// @@ -227,13 +226,13 @@ interface KnockoutUtils { ////////////////////////////////// domNodeDisposal: { - addDisposeCallback(node: Element, callback: Function); + addDisposeCallback(node: Element, callback: Function): void; - removeDisposeCallback(node: Element, callback: Function); + removeDisposeCallback(node: Element, callback: Function): void; - cleanNode(node: Element); + cleanNode(node: Element): Element; - removeNode(node: Element); + removeNode(node: Element): void; }; ////////////////////////////////// @@ -242,41 +241,29 @@ interface KnockoutUtils { fieldsIncludedWithJsonPost: any[]; - arrayForEach(array: T[], action: (item: T) => void): void; + compareArrays(a: T[], b: T[]): Array>; - arrayForEach(array: any[], action: (any) => void ): void; + arrayForEach(array: T[], action: (item: T) => void): void; arrayIndexOf(array: any[], item: any): number; arrayFirst(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T; - arrayFirst(array: any[], predicate: (item) => boolean, predicateOwner?: any): any; - arrayRemoveItem(array: any[], itemToRemove: any): void; arrayGetDistinctValues(array: T[]): T[]; - arrayGetDistinctValues(array: any[]): any[]; - arrayMap(array: T[], mapping: (item: T) => U): U[]; - arrayMap(array: any[], mapping: (item) => any): any[]; - arrayFilter(array: T[], predicate: (item: T) => boolean): T[]; - arrayFilter(array: any[], predicate: (item) => boolean): any[]; - arrayPushAll(array: T[], valuesToPush: T[]): T[]; - arrayPushAll(array: any[], valuesToPush: any[]): any[]; - arrayPushAll(array: KnockoutObservableArray, valuesToPush: T[]): T[]; - arrayPushAll(array: KnockoutObservableArray, valuesToPush: any[]): any[]; + extend(target: Object, source: Object): Object; - extend(target, source); - - emptyDomNode(domNode): void; + emptyDomNode(domNode: HTMLElement): void; moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement; @@ -337,15 +324,21 @@ interface KnockoutUtils { isIe7: boolean; } +interface KnockoutArrayChange { + status: string; + value: T; + index: number; +} + ////////////////////////////////// // templateSources.js ////////////////////////////////// interface KnockoutTemplateSourcesDomElement { - text(valueToWrite?); + text(valueToWrite?: any): any; - data(key, valueToWrite?); + data(key: string, valueToWrite?: any): any; } @@ -367,7 +360,7 @@ interface KnockoutTemplateSources { interface KnockoutNativeTemplateEngine { - renderTemplateSource(templateSource, bindingContext, options?); + renderTemplateSource(templateSource: Object, bindingContext?: KnockoutBindingContext, options?: Object): Array; } ////////////////////////////////// @@ -376,15 +369,15 @@ interface KnockoutNativeTemplateEngine { interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine { - createJavaScriptEvaluatorBlock(script: string); + createJavaScriptEvaluatorBlock(script: string): string; - makeTemplateSource(template, templateDocument); + makeTemplateSource(template: any, templateDocument?: Document): any; - renderTemplate(template, bindingContext, options, templateDocument); + renderTemplate(template: any, bindingContext: KnockoutBindingContext, options: Object, templateDocument: Document): any; - isTemplateRewritten(template, templateDocument): boolean; + isTemplateRewritten(template: any, templateDocument: Document): boolean; - rewriteTemplate(template, rewriterCallback, templateDocument); + rewriteTemplate(template: any, rewriterCallback: Function, templateDocument: Document): void; } ///////////////////////////////// @@ -413,10 +406,10 @@ interface KnockoutStatic { isWriteableObservable(instance: any): boolean; isComputed(instance: any): boolean; dataFor(node: any): any; - removeNode(node: Element); - cleanNode(node: Element); - renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any); - renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any); + removeNode(node: Element): void; + cleanNode(node: Element): Element; + renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; + renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; unwrap(value: any): any; ////////////////////////////////// @@ -442,11 +435,12 @@ interface KnockoutStatic { templateRewriting: { - ensureTemplateIsRewritten(template, templateEngine, templateDocument); + ensureTemplateIsRewritten(template: Node, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any; + ensureTemplateIsRewritten(template: string, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any; - memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine); + memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine): any; - applyMemoizedBindingsToNextSibling(bindings); + applyMemoizedBindingsToNextSibling(bindings: any, nodeName: string): string; }; ////////////////////////////////// @@ -470,22 +464,32 @@ interface KnockoutStatic { prototype: KnockoutTemplateEngine; - renderTemplateSource(templateSource, bindingContext, options); + renderTemplateSource(templateSource: Object, bindingContext: KnockoutBindingContext, options: Object): Node[]; createJavaScriptEvaluatorBlock(script: string): string; - addTemplate(templateName, templateMarkup); + addTemplate(templateName: string, templateMarkup: string): void; }; ////////////////////////////////// // templating.js ////////////////////////////////// - setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine); + setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine): void; - renderTemplate(template, dataOrBindingContext, options, targetNodeOrNodeArray, renderMode); + renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any; + renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; + renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any; - renderTemplateForEach(template, arrayOrObservableArray, options, targetNode, parentBindingContext); + renderTemplateForEach(template: Function, arrayOrObservableArray: Array, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + renderTemplateForEach(template: any, arrayOrObservableArray: Array, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; expressionRewriting: { bindingRewriteValidators: any; @@ -501,9 +505,9 @@ interface KnockoutStatic { selectExtensions: { - readValue(element: any); + readValue(element: HTMLElement): any; - writeValue(element: any, value: any); + writeValue(element: HTMLElement, value: any): void; }; } diff --git a/knockout/knockout.d.ts.tscparams b/knockout/knockout.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout/knockout.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout/knockoutamd-tests.ts.tscparams b/knockout/knockoutamd-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout/knockoutamd-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts.tscparams b/knockout/tests/knockout-templatingBehaviors-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout/tests/knockout-templatingBehaviors-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/knockout/tests/knockout-tests.ts.tscparams b/knockout/tests/knockout-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/knockout/tests/knockout-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/kolite/kolite-tests.ts.tscparams b/kolite/kolite-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/kolite/kolite-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/kolite/kolite.d.ts.tscparams b/kolite/kolite.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/kolite/kolite.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 4bb8bcbf1..6234475b4 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -1,35 +1,2341 @@ -// Type definitions for Leaflet.js 0.5 +// Type definitions for Leaflet.js 0.6.4 // Project: https://github.com/Leaflet/Leaflet -// Definitions by: Vladimir +// Definitions by: Vladimir Zotov // Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module L { + + export interface AttributionOptions { + + /** + * The position of the control (one of the map corners). See control positions. + * Default value: 'bottomright'. + */ + position?: string; + + /** + * The HTML text shown before the attributions. Pass false to disable. + * Default value: 'Powered by Leaflet'. + */ + prefix?: string; + + } +} + +declare module L { + + /** + * Creates a Bounds object from two coordinates (usually top-left and bottom-right + * corners). + */ + export function bounds(topLeft: Point, bottomRight: Point): Bounds; + + /** + * Creates a Bounds object defined by the points it contains. + */ + export function bounds(points: Point[]): Bounds; + + export class Bounds { + + /** + * Creates a Bounds object from two coordinates (usually top-left and bottom-right + * corners). + */ + constructor(topLeft: Point, bottomRight: Point); + + /** + * Creates a Bounds object defined by the points it contains. + */ + constructor(points: Point[]); + + /** + * Extends the bounds to contain the given point. + */ + extend(point: Point): void; + + /** + * Returns the center point of the bounds. + */ + getCenter(): Point; + + /** + * Returns true if the rectangle contains the given one. + */ + contains(otherBounds: Bounds): boolean; + + /** + * Returns true if the rectangle contains the given point. + */ + contains(point: Point): boolean; + + /** + * Returns true if the rectangle intersects the given bounds. + */ + intersects(otherBounds: Bounds): boolean; + + /** + * Returns true if the bounds are properly initialized. + */ + isValid(): boolean; + + /** + * Returns the size of the given bounds. + */ + getSize(): Point; + + /** + * The top left corner of the rectangle. + */ + min: Point; + + /** + * The bottom right corner of the rectangle. + */ + max: Point; + } +} + +declare module L { + + export class Browser { + + /** + * true for all Internet Explorer versions. + */ + static ie: boolean; + + /** + * true for Internet Explorer 6. + */ + static ie6: boolean; + + /** + * true for Internet Explorer 6. + */ + static ie7: boolean; + + /** + * true for webkit-based browsers like Chrome and Safari (including mobile + * versions). + */ + static webkit: boolean; + + /** + * true for webkit-based browsers that support CSS 3D transformations. + */ + static webkit3d: boolean; + + /** + * true for Android mobile browser. + */ + static android: boolean; + + /** + * true for old Android stock browsers (2 and 3). + */ + static android23: boolean; + + /** + * true for modern mobile browsers (including iOS Safari and different Android + * browsers). + */ + static mobile: boolean; + + /** + * true for mobile webkit-based browsers. + */ + static mobileWebkit: boolean; + + /** + * true for mobile Opera. + */ + static mobileOpera: boolean; + + /** + * true for all browsers on touch devices. + */ + static touch: boolean; + + /** + * true for browsers with Microsoft touch model (e.g. IE10). + */ + static msTouch: boolean; + + /** + * true for devices with Retina screens. + */ + static retina: boolean; + + } +} + + +declare module L { + + /** + * Instantiates a circle object given a geographical point, a radius in meters + * and optionally an options object. + */ + function circle(latlng: LatLng, radius: number, options?: PathOptions): Circle; + + export class Circle extends Path { + + /** + * Instantiates a circle object given a geographical point, a radius in meters + * and optionally an options object. + */ + constructor(latlng: LatLng, radius: number, options?: PathOptions); + + /** + * Returns the current geographical position of the circle. + */ + getLatLng(): LatLng; + + /** + * Returns the current radius of a circle. Units are in meters. + */ + getRadius(): number; + + /** + * Sets the position of a circle to a new location. + */ + setLatLng(latlng: LatLng): Circle; + + /** + * Sets the radius of a circle. Units are in meters. + */ + setRadius(radius: number): Circle; + + /** + * Returns a GeoJSON representation of the circle (GeoJSON Point Feature). + */ + toGeoJSON(): any; + + } +} + +declare module L { + + /** + * Instantiates a circle marker given a geographical point and optionally + * an options object. The default radius is 10 and can be altered by passing a + * "radius" member in the path options object. + */ + function circleMarker(latlng: LatLng, options?: PathOptions): CircleMarker; + + export class CircleMarker extends Circle { + + /** + * Instantiates a circle marker given a geographical point and optionally + * an options object. The default radius is 10 and can be altered by passing a + * "radius" member in the path options object. + */ + constructor(latlng: LatLng, options?: PathOptions); + + /** + * Sets the position of a circle marker to a new location. + */ + setLatLng(latlng: LatLng): CircleMarker; + + /** + * Sets the radius of a circle marker. Units are in pixels. + */ + setRadius(radius: number): CircleMarker; + + /** + * Returns a GeoJSON representation of the circle marker (GeoJSON Point Feature). + */ + toGeoJSON(): any; + } +} + +declare module L { + + export interface ClassExtendOptions { + /** + * options is a special property that unlike other objects that you pass + * to extend will be merged with the parent one instead of overriding it + * completely, which makes managing configuration of objects and default + * values convenient. + */ + options?: any; + + /** + * includes is a special class property that merges all specified objects + * into the class (such objects are called mixins). A good example of this + * is L.Mixin.Events that event-related methods like on, off and fire + * to the class. + */ + includes?: any; + + /** + * statics is just a convenience property that injects specified object + * properties as the static properties of the class, useful for defining + * constants. + */ + static?: any; + } + + /** + * L.Class powers the OOP facilities of Leaflet and is used to create + * almost all of the Leaflet classes documented. + */ + export class Class { + + /** + * You use L.Class.extend to define new classes, but you can use the + * same method on any class to inherit from it. + */ + static extend(options: ClassExtendOptions): any; + + /** + * You can also use the following shortcut when you just need to make + * one additional method call. + */ + static addInitHook(methodName: string, ...args: any[]): void; + } + +} + + + +declare module L { + + export class Control extends Class implements IControl { + + /** + * Creates a control with the given options. + */ + constructor(options?: ControlOptions); + + /** + * Sets the position of the control. See control positions. + */ + setPosition(position: string): Control; + + /** + * Returns the current position of the control. + */ + getPosition(): string; + + /** + * Adds the control to the map. + */ + addTo(map: Map): Control; + + /** + * Removes the control from the map. + */ + removeFrom(map: Map): Control; + + /** + * Returns the HTML container of the control. + */ + getContainer(): HTMLElement; + + // IControl members + + /** + * Should contain code that creates all the neccessary DOM elements for the + * control, adds listeners on relevant map events, and returns the element + * containing the control. Called on map.addControl(control) or control.addTo(map). + */ + onAdd(map: Map): HTMLElement; + + /** + * Optional, should contain all clean up code (e.g. removes control's event + * listeners). Called on map.removeControl(control) or control.removeFrom(map). + * The control's DOM container is removed automatically. + */ + onRemove(map: Map): void; + } + + module Control { + + export class Zoom extends L.Control { + + /** + * Creates a zoom control. + */ + constructor(options?: ZoomOptions); + } + + export class Attribution extends L.Control { + + /** + * Creates an attribution control. + */ + constructor(options?: AttributionOptions); + + /** + * Sets the text before the attributions. + */ + setPrefix(prefix: string): Attribution; + + /** + * Adds an attribution text (e.g. 'Vector data © CloudMade'). + */ + addAttribution(text: string): Attribution; + + /** + * Removes an attribution text. + */ + removeAttribution(text: string): Attribution; + + } + + export class Layers extends L.Control implements IEventPowered { + + /** + * Creates an attribution control with the given layers. Base layers will be + * switched with radio buttons, while overlays will be switched with checkboxes. + */ + constructor(baseLayers?: any, overlays?: any, options?: LayersOptions); + + /** + * Adds a base layer (radio button entry) with the given name to the control. + */ + addBaseLayer(layer: ILayer, name: string): Layers; + + /** + * Adds an overlay (checkbox entry) with the given name to the control. + */ + addOverlay(layer: ILayer, name: string): Layers; + + /** + * Remove the given layer from the control. + */ + removeLayer(layer: ILayer): Layers; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Layers; + hasEventListeners(type: string): boolean; + fireEvent(type: string, data?: any): Layers; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Layers; + fire(type: string, data?: any): Layers; addEventListener(eventMap: any, context?: any): Layers; + removeEventListener(eventMap?: any, context?: any): Layers; + clearAllEventListeners(): Layers + on(eventMap: any, context?: any): Layers; + off(eventMap?: any, context?: any): Layers; + } + + export class Scale extends L.Control { + + /** + * Creates an scale control with the given options. + */ + constructor(options?: ScaleOptions); + + } + } + + export class control { + + /** + * Creates a control with the given options. + */ + function (options?: ControlOptions): Control; + + /** + * Creates a zoom control. + */ + static zoom(options?: ZoomOptions): L.Control.Zoom; + + /** + * Creates an attribution control. + */ + static attribution(options?: AttributionOptions): L.Control.Attribution; + + /** + * Creates an attribution control with the given layers. Base layers will be + * switched with radio buttons, while overlays will be switched with checkboxes. + */ + static layers(baseLayers?: any, overlays?: any, options?: LayersOptions): L.Control.Layers; + + /** + * Creates an scale control with the given options. + */ + static scale(options?: ScaleOptions): L.Control.Scale; + } +} + +declare module L { + + export interface ControlOptions { + + /** + * The initial position of the control (one of the map corners). See control + * positions. + * Default value: 'topright'. + */ + position: string; + + } +} + +declare module L { + + export class CRS { + + /** + * The most common CRS for online maps, used by almost all free and commercial + * tile providers. Uses Spherical Mercator projection. Set in by default in + * Map's crs option. + */ + static EPSG3857: ICRS; + + /** + * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. + */ + static EPSG4326: ICRS; + + /** + * Rarely used by some commercial tile providers. Uses Elliptical Mercator + * projection. + */ + static EPSG3395: ICRS; + + /** + * A simple CRS that maps longitude and latitude into x and y directly. May be + * used for maps of flat surfaces (e.g. game maps). Note that the y axis should + * still be inverted (going from bottom to top). + */ + static Simple: ICRS; + + } +} + +declare module L { + + /** + * Creates a div icon instance with the given options. + */ + function divIcon(options: DivIconOptions): DivIcon; + + export class DivIcon extends Icon { + + /** + * Creates a div icon instance with the given options. + */ + constructor(options: DivIconOptions); + } +} + +declare module L { + + export interface DivIconOptions { + + /** + * Size of the icon in pixels. Can be also set through CSS. + */ + iconSize?: Point; + + /** + * The coordinates of the "tip" of the icon (relative to its top left corner). + * The icon will be aligned so that this point is at the marker's geographical + * location. Centered by default if size is specified, also can be set in CSS + * with negative margins. + */ + iconAnchor?: Point; + + /** + * A custom class name to assign to the icon. + * + * Default value: 'leaflet-div-icon'. + */ + className?: string; + + /** + * A custom HTML code to put inside the div element. + * + * Default value: ''. + */ + html?: string; + + } +} + +declare module L { + + export class DomEvent { + + /** + * Adds a listener fn to the element's DOM event of the specified type. this keyword + * inside the listener will point to context, or to the element if not specified. + */ + static addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; + + /** + * Removes an event listener from the element. + */ + static removeListener(el: HTMLElement, type: string, fn: (e: Event) => void): DomEvent; + + /** + * Stop the given event from propagation to parent elements. Used inside the + * listener functions: + * L.DomEvent.addListener(div, 'click', function + * (e) { + * L.DomEvent.stopPropagation(e); + * }); + */ + static stopPropagation(e: Event): DomEvent; + + /** + * Prevents the default action of the event from happening (such as following + * a link in the href of the a element, or doing a POST request with page reload + * when form is submitted). Use it inside listener functions. + */ + static preventDefault(e: Event): DomEvent; + + /** + * Does stopPropagation and preventDefault at the same time. + */ + static stop(e: Event): DomEvent; + + /** + * Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' + * and 'touchstart' events. + */ + static disableClickPropagation(el: HTMLElement): DomEvent; + + /** + * Gets normalized mouse position from a DOM event relative to the container + * or to the whole page if not specified. + */ + static getMousePosition(e: Event, container?: HTMLElement): Point; + + /** + * Gets normalized wheel delta from a mousewheel DOM event. + */ + static getWheelDelta(e: Event): number; + + } +} + +declare module L { + + export class DomUtil { + + /** + * Returns an element with the given id if a string was passed, or just returns + * the element if it was passed directly. + */ + static get(id: string): HTMLElement; + + /** + * Returns the value for a certain style attribute on an element, including + * computed values or values set through CSS. + */ + static getStyle(el: HTMLElement, style: string): string; + + /** + * Returns the offset to the viewport for the requested element. + */ + static getViewportOffset(el: HTMLElement): Point; + + /** + * Creates an element with tagName, sets the className, and optionally appends + * it to container element. + */ + static create(tagName: string, className: string, container?: HTMLElement): HTMLElement; + + /** + * Makes sure text cannot be selected, for example during dragging. + */ + static disableTextSelection(): void; + + /** + * Makes text selection possible again. + */ + static enableTextSelection(): void; + + /** + * Returns true if the element class attribute contains name. + */ + static hasClass(el: HTMLElement, name: string): boolean; + + /** + * Adds name to the element's class attribute. + */ + static addClass(el: HTMLElement, name: string): void; + + /** + * Removes name from the element's class attribute. + */ + static removeClass(el: HTMLElement, name: string): void; + + /** + * Set the opacity of an element (including old IE support). Value must be from + * 0 to 1. + */ + static setOpacity(el: HTMLElement, value: number): void; + + /** + * Goes through the array of style names and returns the first name that is a valid + * style name for an element. If no such name is found, it returns false. Useful + * for vendor-prefixed styles like transform. + */ + static testProp(props: string[]): any; + + /** + * Returns a CSS transform string to move an element by the offset provided in + * the given point. Uses 3D translate on WebKit for hardware-accelerated transforms + * and 2D on other browsers. + */ + static getTranslateString(point: Point): string; + + /** + * Returns a CSS transform string to scale an element (with the given scale origin). + */ + static getScaleString(scale: number, origin: Point): string; + + /** + * Sets the position of an element to coordinates specified by point, using + * CSS translate or top/left positioning depending on the browser (used by + * Leaflet internally to position its layers). Forces top/left positioning + * if disable3D is true. + */ + static setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void; + + /** + * Returns the coordinates of an element previously positioned with setPosition. + */ + static getPosition(el: HTMLElement): Point; + + /** + * Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). + */ + static TRANSITION: string; + + /** + * Vendor-prefixed transform style name. + */ + static TRANSFORM: string; + + } +} + +declare module L { + + /** + * Creates a Draggable object for moving the given element when you start dragging + * the dragHandle element (equals the element itself by default). + */ + function draggable(element: HTMLElement, dragHandle?: HTMLElement): Draggable; + + export class Draggable extends Class implements IEventPowered { + + /** + * Creates a Draggable object for moving the given element when you start dragging + * the dragHandle element (equals the element itself by default). + */ + constructor(element: HTMLElement, dragHandle?: HTMLElement); + + /** + * Enables the dragging ability. + */ + enable(): void; + + /** + * Disables the dragging ability. + */ + disable(): void; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Draggable; + hasEventListeners(type: string): boolean; + fireEvent(type: string, data?: any): Draggable; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Draggable; + fire(type: string, data?: any): Draggable; + addEventListener(eventMap: any, context?: any): Draggable; + removeEventListener(eventMap?: any, context?: any): Draggable; + clearAllEventListeners(): Draggable + on(eventMap: any, context?: any): Draggable; + off(eventMap?: any, context?: any): Draggable; + } +} + + + +declare module L { + + /** + * Create a layer group, optionally given an initial set of layers. + */ + function featureGroup(layers?: ILayer[]): FeatureGroup; + + export class FeatureGroup extends LayerGroup implements ILayer, IEventPowered { + + /** + * Create a layer group, optionally given an initial set of layers. + */ + constructor(layers?: ILayer[]); + + /** + * Binds a popup with a particular HTML content to a click on any layer from the + * group that has a bindPopup method. + */ + bindPopup(htmlContent: string, options?: PopupOptions): FeatureGroup; + + /** + * Returns the LatLngBounds of the Feature Group (created from bounds and coordinates + * of its children). + */ + getBounds(): LatLngBounds; + + /** + * Sets the given path options to each layer of the group that has a setStyle method. + */ + setStyle(style: PathOptions): FeatureGroup; + + /** + * Brings the layer group to the top of all other layers. + */ + bringToFront(): FeatureGroup; + + /** + * Brings the layer group to the bottom of all other layers. + */ + bringToBack(): FeatureGroup; + + //////////// + //////////// + /** + * Should contain code that creates DOM elements for the overlay, adds them + * to map panes where they should belong and puts listeners on relevant map events. + * Called on map.addLayer(layer). + */ + onAdd(map: Map): void; + + /** + * Should contain all clean up code that removes the overlay's elements from + * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). + */ + onRemove(map: Map): void; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup; + hasEventListeners(type: string): boolean; + fireEvent(type: string, data?: any): FeatureGroup; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup; + fire(type: string, data?: any): FeatureGroup; + addEventListener(eventMap: any, context?: any): FeatureGroup; + removeEventListener(eventMap?: any, context?: any): FeatureGroup; + clearAllEventListeners(): FeatureGroup + on(eventMap: any, context?: any): FeatureGroup; + off(eventMap?: any, context?: any): FeatureGroup; + } +} + +declare module L { + + export interface FitBoundsOptions extends ZoomPanOptions { + + /** + * Sets the amount of padding in the top left corner of a map container that + * shouldn't be accounted for when setting the view to fit bounds. Useful if + * you have some control overlays on the map like a sidebar and you don't + * want them to obscure objects you're zooming to. + * + * Default value: [0, 0]. + */ + paddingTopLeft?: Point; + + /** + * The same for bottom right corner of the map. + * + * Default value: [0, 0]. + */ + paddingBottomRight?: Point; + + /** + * Equivalent of setting both top left and bottom right padding to the same value. + * + * Default value: [0, 0]. + */ + padding?: Point; + } +} + +declare module L { + + /** + * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format + * to display on the map (you can alternatively add it later with addData method) + * and an options object. + */ + function geoJson(geojson?: any, options?: GeoJSONOptions): GeoJSON; + + export class GeoJSON extends FeatureGroup { + + /** + * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format + * to display on the map (you can alternatively add it later with addData method) + * and an options object. + */ + constructor(geojson?: any, options?: GeoJSONOptions); + + /** + * Adds a GeoJSON object to the layer. + */ + addData(data: any): boolean; + + /** + * Changes styles of GeoJSON vector layers with the given style function. + */ + setStyle(style: (featureData: any) => any): GeoJSON; + + /** + * Resets the the given vector layer's style to the original GeoJSON style, + * useful for resetting style after hover events. + */ + resetStyle(layer: Path): GeoJSON; + + /** + * Creates a layer from a given GeoJSON feature. + */ + static geometryToLayer(featureData: GeoJSON, pointToLayer?: (featureData: any, latlng: LatLng) => ILayer): ILayer; + + /** + * Creates a LatLng object from an array of 2 numbers (latitude, longitude) + * used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted + * as (longitude, latitude). + */ + static coordsToLatlng(coords: number[], reverse?: boolean): LatLng; + + /** + * Creates a multidimensional array of LatLng objects from a GeoJSON coordinates + * array. levelsDeep specifies the nesting level (0 is for an array of points, + * 1 for an array of arrays of points, etc., 0 by default). If reverse is set to + * true, the numbers will be interpreted as (longitude, latitude). + */ + static coordsToLatlngs(coords: number[], levelsDeep?: number, reverse?: boolean): LatLng[]; + + } +} + +declare module L { + export interface GeoJSONOptions { + /** + * Function that will be used for creating layers for GeoJSON points (if not + * specified, simple markers will be created). + */ + pointToLayer?: (featureData: any, latlng: LatLng) => ILayer; + + /** + * Function that will be used to get style options for vector layers created + * for GeoJSON features. + */ + style?: (featureData: any) => any; + + /** + * Function that will be called on each created feature layer. Useful for attaching + * events and popups to features. + */ + onEachFeature?: (featureData: any, layer: ILayer) => void; + + /** + * Function that will be used to decide whether to show a feature or not. + */ + filter?: (featureData: any, layer: ILayer) => boolean; + + /** + * Function that will be used for converting GeoJSON coordinates to LatLng points + * (if not specified, coords will be assumed to be WGS84 standard[longitude, latitude] + * values in degrees). + */ + coordsToLatLng?: (coords: any[]) => LatLng[]; + } +} + + + + +declare module L { + + /** + * Creates an icon instance with the given options. + */ + function icon(options: IconOptions): Icon; + + export class Icon extends Class { + + /** + * Creates an icon instance with the given options. + */ + constructor(options: IconOptions); + } + + module Icon { + + /** + * L.Icon.Default extends L.Icon and is the blue icon Leaflet uses + * for markers by default. + */ + export class Default extends Icon { + + /** + * Creates an icon instance with default options. + */ + constructor(options: IconOptions); + + static imagePath: string; + } + } +} + +declare module L { + + export interface IconOptions { + + /** + * (required) The URL to the icon image (absolute or relative to your script + * path). + */ + iconUrl?: string; + + /** + * The URL to a retina sized version of the icon image (absolute or relative to + * your script path). Used for Retina screen devices. + */ + iconRetinaUrl?: string; + + /** + * Size of the icon image in pixels. + */ + iconSize?: Point; + + /** + * The coordinates of the "tip" of the icon (relative to its top left corner). + * The icon will be aligned so that this point is at the marker's geographical + * location. Centered by default if size is specified, also can be set in CSS + * with negative margins. + */ + iconAnchor?: Point; + + /** + * The URL to the icon shadow image. If not specified, no shadow image will be + * created. + */ + shadowUrl?: string; + + /** + * The URL to the retina sized version of the icon shadow image. If not specified, + * no shadow image will be created. Used for Retina screen devices. + */ + shadowRetinaUrl?: string; + + /** + * Size of the shadow image in pixels. + */ + shadowSize?: Point; + + /** + * The coordinates of the "tip" of the shadow (relative to its top left corner) + * (the same as iconAnchor if not specified). + */ + shadowAnchor?: Point; + + /** + * The coordinates of the point from which popups will "open", relative to the + * icon anchor. + */ + popupAnchor?: Point; + + /** + * A custom class name to assign to both icon and shadow images. Empty by default. + */ + className?: string; + } +} + +declare module L { + + export interface IControl { + + /** + * Should contain code that creates all the neccessary DOM elements for the + * control, adds listeners on relevant map events, and returns the element + * containing the control. Called on map.addControl(control) or control.addTo(map). + */ + onAdd(map: Map): HTMLElement; + + /** + * Optional, should contain all clean up code (e.g. removes control's event + * listeners). Called on map.removeControl(control) or control.removeFrom(map). + * The control's DOM container is removed automatically. + */ + onRemove(map: Map): void; + } +} + +declare module L { + + export interface ICRS { + + /** + * Projection that this CRS uses. + */ + projection: IProjection; + + /** + * Transformation that this CRS uses to turn projected coordinates into screen + * coordinates for a particular tile service. + */ + transformation: Transformation; + + /** + * Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857'). + */ + code: string; + + /** + * Projects geographical coordinates on a given zoom into pixel coordinates. + */ + latLngToPoint(latlng: LatLng, zoom: number): Point; + + /** + * The inverse of latLngToPoint. Projects pixel coordinates on a given zoom + * into geographical coordinates. + */ + pointToLatLng(point: Point, zoom: number): LatLng; + + /** + * Projects geographical coordinates into coordinates in units accepted + * for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). + */ + project(latlng: LatLng): Point; + + /** + * Returns the scale used when transforming projected coordinates into pixel + * coordinates for a particular zoom. For example, it returns 256 * 2^zoom for + * Mercator-based CRS. + */ + scale(zoom: number): number; + + } +} + +declare module L { + + export interface IEventPowered { + + /** + * Adds a listener function (fn) to a particular event type of the object. You + * can optionally specify the context of the listener (object the this keyword + * will point to). You can also pass several space-separated types (e.g. 'click + * dblclick'). + */ + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): T; + + /** + * The same as above except the listener will only get fired once and then removed. + */ + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): T; + /** + * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} + */ + addEventListener(eventMap: any, context?: any): T; + + /** + * Removes a previously added listener function. If no function is specified, + * it will remove all the listeners of that particular event from the object. + */ + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): T; + + /** + * Removes a set of type/listener pairs. + */ + removeEventListener(eventMap?: any, context?: any): T; + + /** + * Returns true if a particular event type has some listeners attached to it. + */ + hasEventListeners(type: string): boolean; + + /** + * Fires an event of the specified type. You can optionally provide an data object + * — the first argument of the listener function will contain its properties. + */ + fireEvent(type: string, data?: any): T; + + /** + * Removes all listeners to all events on the object. + */ + clearAllEventListeners(): T; + + /** + * Alias to addEventListener. + */ + on(type: string, fn: (e: LeafletEvent) => void, context?: any): T; + + /** + * Alias to addEventListener. + */ + on(eventMap: any, context?: any): T; + + /** + * Alias to addOneTimeEventListener. + */ + once(type: string, fn: (e: LeafletEvent) => void, context?: any): T; + + /** + * Alias to removeEventListener. + */ + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): T; + + /** + * Alias to removeEventListener. + */ + off(eventMap?: any, context?: any): T; + + /** + * Alias to fireEvent. + */ + fire(type: string, data?: any): T; + } +} + +declare module L { + + export interface IHandler { + + /** + * Enables the handler. + */ + enable(): void; + + /** + * Disables the handler. + */ + disable(): void; + + /** + * Returns true if the handler is enabled. + */ + enabled(): boolean; + } +} + +declare module L { + + export interface ILayer { + + /** + * Should contain code that creates DOM elements for the overlay, adds them + * to map panes where they should belong and puts listeners on relevant map events. + * Called on map.addLayer(layer). + */ + onAdd(map: Map): void; + + /** + * Should contain all clean up code that removes the overlay's elements from + * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). + */ + onRemove(map: Map): void; + } +} + +declare module L { + + /** + * Instantiates an image overlay object given the URL of the image and the geographical + * bounds it is tied to. + */ + function imageOverlay(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay; + + export class ImageOverlay extends Class implements ILayer { + + /** + * Instantiates an image overlay object given the URL of the image and the geographical + * bounds it is tied to. + */ + constructor(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions); + + /** + * Adds the overlay to the map. + */ + addTo(map: Map): ImageOverlay; + + /** + * Sets the opacity of the overlay. + */ + setOpacity(opacity: number): ImageOverlay; + + /** + * Brings the layer to the top of all overlays. + */ + bringToFront(): ImageOverlay; + + /** + * Brings the layer to the bottom of all overlays. + */ + bringToBack(): ImageOverlay; + + //////////// + //////////// + /** + * Should contain code that creates DOM elements for the overlay, adds them + * to map panes where they should belong and puts listeners on relevant map events. + * Called on map.addLayer(layer). + */ + onAdd(map: Map): void; + + /** + * Should contain all clean up code that removes the overlay's elements from + * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). + */ + onRemove(map: Map): void; + } +} + +declare module L { + + export interface ImageOverlayOptions { + + /** + * The opacity of the image overlay. + */ + opacity?: number; + } +} + +declare module L { + + export interface IProjection { + + /** + * Projects geographical coordinates into a 2D point. + */ + project(latlng: LatLng): Point; + + /** + * The inverse of project. Projects a 2D point into geographical location. + */ + unproject(point: Point): LatLng; + } +} + +declare module L { + + /** + * A constant that represents the Leaflet version in use. + */ + export var version: string; + + /** + * This method restores the L global variale to the original value it had + * before Leaflet inclusion, and returns the real Leaflet namespace. + */ + export function noConflict(): typeof L; +} + +declare module L { + + /** + * Creates an object representing a geographical point with the given latitude + * and longitude. + */ + function latLng(latitude: number, longitude: number): LatLng; + + /** + * Creates an object representing a geographical point with the given latitude + * and longitude. + */ + function latLng(coords: number[]): LatLng; + + export class LatLng { + + /** + * Creates an object representing a geographical point with the given latitude + * and longitude. + */ + constructor(latitude: number, longitude: number); + + /** + * Creates an object representing a geographical point with the given latitude + * and longitude. + */ + constructor(coords: number[]); + + /** + * Returns the distance (in meters) to the given LatLng calculated using the + * Haversine formula. See description on wikipedia + */ + distanceTo(otherLatlng: LatLng): number; + + /** + * Returns true if the given LatLng point is at the same position (within a small + * margin of error). + */ + equals(otherLatlng: LatLng): boolean; + + /** + * Returns a string representation of the point (for debugging purposes). + */ + toString(): string; + + /** + * Returns a new LatLng object with the longitude wrapped around left and right + * boundaries (-180 to 180 by default). + */ + wrap(left: number, right: number): LatLng; + + /** + * Latitude in degrees. + */ + lat: number; + + /** + * Longitude in degrees. + */ + lng: number; + + /** + * A multiplier for converting degrees into radians. + * + * Value: Math.PI / 180. + */ + static DEG_TO_RAD: number; + + /** + * A multiplier for converting radians into degrees. + * + * Value: 180 / Math.PI. + */ + static RAD_TO_DEG: number; + + /** + * Max margin of error for the equality check. + * + * Value: 1.0E-9. + */ + static MAX_MARGIN: number; + } +} + +declare module L { + + /** + * Creates a LatLngBounds object by defining south-west and north-east corners + * of the rectangle. + */ + function latLngBounds(southWest: LatLng, northEast: LatLng): LatLngBounds; + + /** + * Creates a LatLngBounds object defined by the geographical points it contains. + * Very useful for zooming the map to fit a particular set of locations with fitBounds. + */ + function latLngBounds(latlngs: LatLng[]): LatLngBounds; + + export class LatLngBounds { + + /** + * Creates a LatLngBounds object by defining south-west and north-east corners + * of the rectangle. + */ + constructor(southWest: LatLng, northEast: LatLng); + + /** + * Creates a LatLngBounds object defined by the geographical points it contains. + * Very useful for zooming the map to fit a particular set of locations with fitBounds. + */ + constructor(latlngs: LatLng[]); + + /** + * Extends the bounds to contain the given point. + */ + extend(latlng: LatLng): LatLngBounds; + + /** + * Extends the bounds to contain the given bounds. + */ + extend(latlng: LatLngBounds): LatLngBounds; + + /** + * Returns the south-west point of the bounds. + */ + getSouthWest(): LatLng; + + /** + * Returns the north-east point of the bounds. + */ + getNorthEast(): LatLng; + + /** + * Returns the north-west point of the bounds. + */ + getNorthWest(): LatLng; + + /** + * Returns the south-east point of the bounds. + */ + getSouthEast(): LatLng; + + /** + * Returns the center point of the bounds. + */ + getCenter(): LatLng; + + /** + * Returns true if the rectangle contains the given one. + */ + contains(otherBounds: LatLngBounds): boolean; + + /** + * Returns true if the rectangle contains the given point. + */ + contains(latlng: LatLng): boolean; + + /** + * Returns true if the rectangle intersects the given bounds. + */ + intersects(otherBounds: LatLngBounds): boolean; + + /** + * Returns true if the rectangle is equivalent (within a small margin of error) + * to the given bounds. + */ + equals(otherBounds: LatLngBounds): boolean; + + /** + * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' + * format. Useful for sending requests to web services that return geo data. + */ + toBBoxString(): string; + + /** + * Returns bigger bounds created by extending the current bounds by a given + * percentage in each direction. + */ + pad(bufferRatio: number): LatLngBounds; + + /** + * Returns true if the bounds are properly initialized. + */ + isValid(): boolean; + + } +} + +declare module L { + + /** + * Create a layer group, optionally given an initial set of layers. + */ + function layerGroup(layers?: ILayer[]): LayerGroup; + + export class LayerGroup extends Class implements ILayer { + + /** + * Create a layer group, optionally given an initial set of layers. + */ + constructor(layers?: ILayer[]); + + /** + * Adds the group of layers to the map. + */ + addTo(map: Map): LayerGroup; + + /** + * Adds a given layer to the group. + */ + addLayer(layer: ILayer): LayerGroup; + + /** + * Removes a given layer from the group. + */ + removeLayer(layer: ILayer): LayerGroup; + + /** + * Removes a given layer of the given id from the group. + */ + removeLayer(id: string): LayerGroup; + + /** + * Returns true if the given layer is currently added to the group. + */ + hasLayer(layer: ILayer): boolean; + + /** + * Returns the layer with the given id. + */ + getLayer(id: string): ILayer; + + /** + * Returns an array of all the layers added to the group. + */ + getLayers(): ILayer[]; + + /** + * Removes all the layers from the group. + */ + clearLayers(): LayerGroup; + + /** + * Iterates over the layers of the group, optionally specifying context of + * the iterator function. + */ + eachLayer(fn: (layer: ILayer) => void, context?: any): LayerGroup; + + /** + * Returns a GeoJSON representation of the layer group (GeoJSON FeatureCollection). + */ + toGeoJSON(): any; + + //////////// + //////////// + /** + * Should contain code that creates DOM elements for the overlay, adds them + * to map panes where they should belong and puts listeners on relevant map events. + * Called on map.addLayer(layer). + */ + onAdd(map: Map): void; + + /** + * Should contain all clean up code that removes the overlay's elements from + * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). + */ + onRemove(map: Map): void; + } +} + + +declare module L { + + export interface LayersOptions { + + /** + * The position of the control (one of the map corners). See control positions. + * + * Default value: 'topright'. + */ + position?: string; + + /** + * If true, the control will be collapsed into an icon and expanded on mouse hover + * or touch. + * + * Default value: true. + */ + collapsed?: boolean; + + /** + * If true, the control will assign zIndexes in increasing order to all of its + * layers so that the order is preserved when switching them on/off. + * + * Default value: true. + */ + autoZIndex?: boolean; + + } +} + +declare module L { + + export interface LeafletErrorEvent extends LeafletEvent { + + /** + * Error message. + */ + message: string; + + /** + * Error code (if applicable). + */ + code: number; + } +} + +declare module L { + + export interface LeafletEvent { + + /** + * The event type (e.g. 'click'). + */ + type: string; + + /** + * The object that fired the event. + */ + target: any; + } +} + +declare module L { + + export interface LeafletGeoJSONEvent extends LeafletEvent { + + /** + * The layer for the GeoJSON feature that is being added to the map. + */ + layer: ILayer; + + /** + * GeoJSON properties of the feature. + */ + properties: any; + + /** + * GeoJSON geometry type of the feature. + */ + geometryType: string; + + /** + * GeoJSON ID of the feature (if present). + */ + id: string; + } +} + +declare module L { + + export interface LeafletLayerEvent extends LeafletEvent { + + /** + * The layer that was added or removed. + */ + layer: ILayer; + } +} + +declare module L { + + export interface LeafletLocationEvent extends LeafletEvent { + + /** + * Detected geographical location of the user. + */ + latlng: LatLng; + + /** + * Geographical bounds of the area user is located in (with respect to the accuracy + * of location). + */ + bounds: LatLngBounds; + + /** + * Accuracy of location in meters. + */ + accuracy: number; + + /** + * Height of the position above the WGS84 ellipsoid in meters. + */ + altitude: number; + + /** + * Accuracy of altitude in meters. + */ + altitudeAccuracy: number; + + /** + * The direction of travel in degrees counting clockwise from true North. + */ + heading: number; + + /** + * Current velocity in meters per second. + */ + speed: number; + + /** + * The time when the position was acquired. + */ + timestamp: number; + + } +} + +declare module L { + + export interface LeafletMouseEvent extends LeafletEvent { + + /** + * The geographical point where the mouse event occured. + */ + latlng: LatLng; + + /** + * Pixel coordinates of the point where the mouse event occured relative to + * the map layer. + */ + layerPoint: Point; + + /** + * Pixel coordinates of the point where the mouse event occured relative to + * the map сontainer. + */ + containerPoint: Point; + + /** + * The original DOM mouse event fired by the browser. + */ + originalEvent: MouseEvent; + } +} + +declare module L { + + export interface LeafletPopupEvent extends LeafletEvent { + + /** + * The popup that was opened or closed. + */ + popup: Popup; + } +} + +declare module L { + + export interface LeafletResizeEvent extends LeafletEvent { + + /** + * The old size before resize event. + */ + oldSize: Point; + + /** + * The new size after the resize event. + */ + newSize: Point; + } +} + +declare module L { + + export interface LeafletTileEvent extends LeafletEvent { + + /** + * The tile element (image). + */ + tile: HTMLElement; + + /** + * The source URL of the tile. + */ + url: string; + } +} + +declare module L { + + export class LineUtil { + + /** + * Dramatically reduces the number of points in a polyline while retaining + * its shape and returns a new array of simplified points. Used for a huge performance + * boost when processing/displaying Leaflet polylines for each zoom level + * and also reducing visual noise. tolerance affects the amount of simplification + * (lesser value means higher quality but slower and with more points). Also + * released as a separated micro-library Simplify.js. + */ + static simplify(points: Point[], tolerance: number): Point[]; + + /** + * Returns the distance between point p and segment p1 to p2. + */ + static pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; + + /** + * Returns the closest point from a point p on a segment p1 to p2. + */ + static closestPointOnSegment(p: Point, p1: Point, p2: Point): number; + + /** + * Clips the segment a to b by rectangular bounds (modifying the segment points + * directly!). Used by Leaflet to only show polyline points that are on the screen + * or near, increasing performance. + */ + static clipSegment(a: Point, b: Point, bounds: Bounds): void; + + } +} + +declare module L { + + export interface LocateOptions { + + /** + * If true, starts continous watching of location changes (instead of detecting + * it once) using W3C watchPosition method. You can later stop watching using + * map.stopLocate() method. + * + * Default value: false. + */ + watch?: boolean; + + /** + * If true, automatically sets the map view to the user location with respect + * to detection accuracy, or to world view if geolocation failed. + * + * Default value: false. + */ + setView?: boolean; + + /** + * The maximum zoom for automatic view setting when using `setView` option. + * + * Default value: Infinity. + */ + maxZoom?: number; + + /** + * Number of millisecond to wait for a response from geolocation before firing + * a locationerror event. + * + * Default value: 10000. + */ + timeout?: number; + + /** + * Maximum age of detected location. If less than this amount of milliseconds + * passed since last geolocation response, locate will return a cached location. + * + * Default value: 0. + */ + maximumAge?: number; + + /** + * Enables high accuracy, see description in the W3C spec. + * + * Default value: false. + */ + enableHighAccuracy?: boolean; + } +} + +declare module L { + + /** + * Instantiates a map object given a div element and optionally an + * object literal with map options described below. + */ + function map(id: HTMLElement, options?: MapOptions): Map; + + /** + * Instantiates a map object given a div element id and optionally an + * object literal with map options described below. + */ + function map(id: string, options?: MapOptions): Map; + + export class Map extends Class implements IEventPowered { + + /** + * Instantiates a map object given a div element and optionally an + * object literal with map options described below. + * + * @constructor + */ + constructor(id: HTMLElement, options?: MapOptions); + + /** + * Instantiates a map object given a div element id and optionally an + * object literal with map options described below. + * + * @constructor + */ + constructor(id: string, options?: MapOptions); + + // Methods for Modifying Map State + + /** + * Sets the view of the map (geographical center and zoom) with the given + * animation options. + */ + setView(center: LatLng, zoom: number, options?: ZoomPanOptions): Map; + + /** + * Sets the zoom of the map. + */ + setZoom(zoom: number, options?: ZoomOptions): Map; + + /** + * Increases the zoom of the map by delta (1 by default). + */ + zoomIn(delta?: number, options?: ZoomOptions): Map; + + /** + * Decreases the zoom of the map by delta (1 by default). + */ + zoomOut(delta?: number, options?: ZoomOptions): Map; + + /** + * Zooms the map while keeping a specified point on the map stationary + * (e.g. used internally for scroll zoom and double-click zoom). + */ + setZoomAround(latlng: LatLng, zoom: number, options?: ZoomOptions): Map; + + /** + * Sets a map view that contains the given geographical bounds with the maximum + * zoom level possible. + */ + fitBounds(bounds: LatLngBounds, options?: FitBoundsOptions): Map; + + /** + * Sets a map view that mostly contains the whole world with the maximum zoom + * level possible. + */ + fitWorld(options?: FitBoundsOptions): Map; + + /** + * Pans the map to a given center. Makes an animated pan if new center is not more + * than one screen away from the current one. + */ + panTo(latlng: LatLng, options?: PanOptions): Map; + + /** + * Pans the map to the closest view that would lie inside the given bounds (if + * it's not already). + */ + panInsideBounds(bounds: LatLngBounds): Map; + + /** + * Pans the map by a given number of pixels (animated). + */ + panBy(point: Point, options?: PanOptions): Map; + + /** + * Checks if the map container size changed and updates the map if so — call it + * after you've changed the map size dynamically, also animating pan by default. + * If options.pan is false, panning will not occur. + */ + invalidateSize(options: ZoomPanOptions): Map; + + /** + * Checks if the map container size changed and updates the map if so — call it + * after you've changed the map size dynamically, also animating pan by default. + */ + invalidateSize(animate: boolean): Map; + + /** + * Restricts the map view to the given bounds (see map maxBounds option), + * passing the given animation options through to `setView`, if required. + */ + setMaxBounds(bounds: LatLngBounds, options?: ZoomPanOptions): Map; + + /** + * Tries to locate the user using Geolocation API, firing locationfound event + * with location data on success or locationerror event on failure, and optionally + * sets the map view to the user location with respect to detection accuracy + * (or to the world view if geolocation failed). See Locate options for more + * details. + */ + locate(options?: LocateOptions): Map; + + /** + * Stops watching location previously initiated by map.locate({watch: true}) + * and aborts resetting the map view if map.locate was called with {setView: true}. + */ + stopLocate(): Map; + + /** + * Destroys the map and clears all related event listeners. + */ + remove(): Map; + + // Methods for Getting Map State + + /** + * Returns the geographical center of the map view. + */ + getCenter(): LatLng; + + /** + * Returns the current zoom of the map view. + */ + getZoom(): number; + + /** + * Returns the minimum zoom level of the map. + */ + getMinZoom(): number; + + /** + * Returns the maximum zoom level of the map. + */ + getMaxZoom(): number; + + /** + * Returns the LatLngBounds of the current map view. + */ + getBounds(): LatLngBounds; + + /** + * Returns the maximum zoom level on which the given bounds fit to the map view + * in its entirety. If inside (optional) is set to true, the method instead returns + * the minimum zoom level on which the map view fits into the given bounds in its + * entirety. + */ + getBoundsZoom(bounds: LatLngBounds, inside?: boolean): number; + + /** + * Returns the current size of the map container. + */ + getSize(): Point; + + /** + * Returns the bounds of the current map view in projected pixel coordinates + * (sometimes useful in layer and overlay implementations). + */ + getPixelBounds(): Bounds; + + /** + * Returns the projected pixel coordinates of the top left point of the map layer + * (useful in custom layer and overlay implementations). + */ + getPixelOrigin(): Point; + + // Methods for Layers and Controls + + /** + * Adds the given layer to the map. If optional insertAtTheBottom is set to true, + * the layer is inserted under all others (useful when switching base tile layers). + */ + addLayer(layer: ILayer, insertAtTheBottom?: boolean): Map; + + /** + * Removes the given layer from the map. + */ + removeLayer(layer: ILayer): Map; + + /** + * Returns true if the given layer is currently added to the map. + */ + hasLayer(layer: ILayer): boolean; + + /** + * Opens the specified popup while closing the previously opened (to make sure + * only one is opened at one time for usability). + */ + openPopup(popup: Popup): Map; + + /** + * Creates a popup with the specified options and opens it in the given point + * on a map. + */ + openPopup(html: string, latlng: LatLng, options?: PopupOptions): Map; + + /** + * Creates a popup with the specified options and opens it in the given point + * on a map. + */ + openPopup(el: HTMLElement, latlng: LatLng, options?: PopupOptions): Map; + + /** + * Closes the popup previously opened with openPopup (or the given one). + */ + closePopup(): Map; + + /** + * Adds the given control to the map. + */ + addControl(control: IControl): Map; + + /** + * Removes the given control from the map. + */ + removeControl(control: IControl): Map; + + // Conversion Methods + + /** + * Returns the map layer point that corresponds to the given geographical coordinates + * (useful for placing overlays on the map). + */ + latLngToLayerPoint(latlng: LatLng): Point; + + /** + * Returns the geographical coordinates of a given map layer point. + */ + layerPointToLatLng(point: Point): LatLng; + + /** + * Converts the point relative to the map container to a point relative to the + * map layer. + */ + containerPointToLayerPoint(point: Point): Point; + + /** + * Converts the point relative to the map layer to a point relative to the map + * container. + */ + layerPointToContainerPoint(point: Point): Point; + + /** + * Returns the map container point that corresponds to the given geographical + * coordinates. + */ + latLngToContainerPoint(latlng: LatLng): Point; + + /** + * Returns the geographical coordinates of a given map container point. + */ + containerPointToLatLng(point: Point): LatLng; + + /** + * Projects the given geographical coordinates to absolute pixel coordinates + * for the given zoom level (current zoom level by default). + */ + project(latlng: LatLng, zoom?: number): Point; + + /** + * Projects the given absolute pixel coordinates to geographical coordinates + * for the given zoom level (current zoom level by default). + */ + unproject(point: Point, zoom?: number): LatLng; + + /** + * Returns the pixel coordinates of a mouse click (relative to the top left corner + * of the map) given its event object. + */ + mouseEventToContainerPoint(event: LeafletMouseEvent): Point; + + /** + * Returns the pixel coordinates of a mouse click relative to the map layer given + * its event object. + */ + mouseEventToLayerPoint(event: LeafletMouseEvent): Point; + + /** + * Returns the geographical coordinates of the point the mouse clicked on given + * the click's event object. + */ + mouseEventToLatLng(event: LeafletMouseEvent): LatLng; + + // Other Methods + + /** + * Returns the container element of the map. + */ + getContainer(): HTMLElement; + + /** + * Returns an object with different map panes (to render overlays in). + */ + getPanes(): MapPanes; + + // REVIEW: Should we make it more flexible declaring parameter 'fn' as Function? + /** + * Runs the given callback when the map gets initialized with a place and zoom, + * or immediately if it happened already, optionally passing a function context. + */ + whenReady(fn: (map: Map) => void, context?: any): Map; + + // Properties + + /** + * Map dragging handler (by both mouse and touch). + */ + dragging: IHandler; + + /** + * Touch zoom handler. + */ + touchZoom: IHandler; + + /** + * Double click zoom handler. + */ + doubleClickZoom: IHandler; + + /** + * Scroll wheel zoom handler. + */ + scrollWheelZoom: IHandler; + + /** + * Box (shift-drag with mouse) zoom handler. + */ + boxZoom: IHandler; + + /** + * Keyboard navigation handler. + */ + keyboard: IHandler; + + /** + * Mobile touch hacks (quick tap and touch hold) handler. + */ + tap: IHandler; + + /** + * Zoom control. + */ + zoomControl: Control.Zoom; + + /** + * Attribution control. + */ + attributionControl: Control.Attribution; + + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Map; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Map; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Map; + hasEventListeners(type: string): boolean; + fireEvent(type: string, data?: any): Map; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): Map; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): Map; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Map; + fire(type: string, data?: any): Map;addEventListener(eventMap: any, context?: any): Map; + removeEventListener(eventMap?: any, context?: any): Map; + clearAllEventListeners(): Map + on(eventMap: any, context?: any): Map; + off(eventMap?: any, context?: any): Map; + } +} + +declare module L { + export interface MapOptions { + + // Map State Options + /** * Initial geographical center of the map. */ center?: LatLng; - + /** * Initial map zoom. */ zoom?: number; - + /** * Layers that will be added to the map initially. */ layers?: ILayer[]; - + /** * Minimum zoom level of the map. Overrides any minZoom set on map layers. */ minZoom?: number; - + /** * Maximum zoom level of the map. This overrides any maxZoom set on map layers. */ maxZoom?: number; - + /** * When this option is set, the map restricts the view to the given geographical * bounds, bouncing the user back when he tries to pan outside the view, and also @@ -37,166 +2343,199 @@ declare module L { * on the map size). To set the restriction dynamically, use setMaxBounds method */ maxBounds?: LatLngBounds; - + /** * Coordinate Reference System to use. Don't change this if you're not sure * what it means. + * + * Default value: L.CRS.EPSG3857. */ crs?: ICRS; + + // Interaction Options /** * Whether the map be draggable with mouse/touch or not. + * + * Default value: true. */ dragging?: boolean; - + /** * Whether the map can be zoomed by touch-dragging with two fingers. + * + * Default value: true. */ touchZoom?: boolean; - + /** * Whether the map can be zoomed by using the mouse wheel. + * + * Default value: true. */ scrollWheelZoom?: boolean; - + /** * Whether the map can be zoomed in by double clicking on it. + * + * Default value: true. */ doubleClickZoom?: boolean; /** * Whether the map can be zoomed to a rectangular area specified by dragging * the mouse while pressing shift. + * + * Default value: true. */ boxZoom?: boolean; + /** + * Enables mobile hacks for supporting instant taps (fixing 200ms click delay + * on iOS/Android) and touch holds (fired as contextmenu events). + * + * Default value: true. + */ + tap?: boolean; + + /** + * The max number of pixels a user can shift his finger during touch for it + * to be considered a valid tap. + * + * Default value: 15. + */ + tapTolerance?: number; + /** * Whether the map automatically handles browser window resize to update itself. + * + * Default value: true. */ trackResize?: boolean; - + /** * With this option enabled, the map tracks when you pan to another "copy" of * the world and seamlessly jumps to the original one so that all overlays like * markers and vector layers are still visible. + * + * Default value: false. */ worldCopyJump?: boolean; - + /** * Set it to false if you don't want popups to close when user clicks the map. + * + * Default value: true. */ closePopupOnClick?: boolean; + + // Keyboard Navigation Options /** * Makes the map focusable and allows users to navigate the map with keyboard * arrows and +/- keys. + * + * Default value: true. */ keyboard?: boolean; - + /** * Amount of pixels to pan when pressing an arrow key. + * + * Default value: 80. */ keyboardPanOffset?: number; - + /** * Number of zoom levels to change when pressing + or - key. + * + * Default value: 1. */ keyboardZoomOffset?: number; + + // Panning Inertia Options /** * If enabled, panning of the map will have an inertia effect where the map builds * momentum while dragging and continues moving in the same direction for some * time. Feels especially nice on touch devices. + * + * Default value: true. */ inertia?: boolean; - + /** * The rate with which the inertial movement slows down, in pixels/second2. + * + * Default value: 3000. */ inertiaDeceleration?: number; - + /** * Max speed of the inertial movement, in pixels/second. + * + * Default value: 1500. */ inertiaMaxSpeed?: number; - + /** * Amount of milliseconds that should pass between stopping the movement and - * releasing the mouse or touch to prevent inertial movement. 32 for touch devices - * and 14 for the rest by default. + * releasing the mouse or touch to prevent inertial movement. + * + * Default value: 32 for touch devices and 14 for the rest. */ inertiaThreshold?: number; + + // Control options /** * Whether the zoom control is added to the map by default. + * + * Default value: true. */ zoomControl?: boolean; - + /** * Whether the attribution control is added to the map by default. + * + * Default value: true. */ attributionControl?: boolean; + + // Animation options /** * Whether the tile fade animation is enabled. By default it's enabled in all * browsers that support CSS3 Transitions except Android. */ fadeAnimation?: boolean; - + /** * Whether the tile zoom animation is enabled. By default it's enabled in all * browsers that support CSS3 Transitions except Android. */ zoomAnimation?: boolean; + /** + * Won't animate zoom if the zoom difference exceeds this value. + * + * Default value: 4. + */ + zoomAnimationThreshold?: number; + /** * Whether markers animate their zoom with the zoom animation, if disabled * they will disappear for the length of the animation. By default it's enabled * in all browsers that support CSS3 Transitions except Android. */ markerZoomAnimation?: boolean; - - } - - export interface LocateOptions { - /** - * If true, starts continous watching of location changes (instead of detecting - * it once) using W3C watchPosition method. You can later stop watching using - * map.stopLocate() method. - */ - watch?: boolean; - - /** - * If true, automatically sets the map view to the user location with respect - * to detection accuracy, or to world view if geolocation failed. - */ - setView?: boolean; - - /** - * The maximum zoom for automatic view setting when using `setView` option. - */ - maxZoom?: number; - - /** - * Number of millisecond to wait for a response from geolocation before firing - * a locationerror event. - */ - timeout?: number; - - /** - * Maximum age of detected location. If less than this amount of milliseconds - * passed since last geolocation response, locate will return a cached location. - */ - maximumAge?: number; - - /** - * Enables high accuracy, see description in the W3C spec. - */ - enableHighAccuracy?: boolean; - } +} + +declare module L { export interface MapPanes { + /** * Pane that contains all other map panes. */ @@ -231,978 +2570,403 @@ declare module L { * Pane for popups. */ popupPane: HTMLElement; - } +} + +declare module L { - export class Map implements IEventPowered { - /** - * Instantiates a map object given a div element (or its id) and optionally an - * object literal with map options described below. - */ - constructor(id: HTMLElement, options?: MapOptions); + /** + * Instantiates a Marker object given a geographical point and optionally + * an options object. + */ + function marker(latlng: LatLng, options?: MarkerOptions): Marker; - /** - * Instantiates a map object given a div element (or its id) and optionally an - * object literal with map options described below. - */ - constructor(id: string, options?: MapOptions); + export class Marker extends Class implements ILayer, IEventPowered { - /** - * Sets the view of the map (geographical center and zoom). If forceReset is - * set to true, the map is reloaded even if it's eligible for pan or zoom animation - * (false by default). - */ - setView(center: LatLng, zoom: number, forceReset?: boolean): Map; - - /** - * Sets the zoom of the map. - */ - setZoom(zoom: number): Map; - - /** - * Increases the zoom of the map by delta (1 by default). - */ - zoomIn(delta?: number): Map; - - /** - * Decreases the zoom of the map by delta (1 by default). - */ - zoomOut(delta?: number): Map; - - /** - * Sets a map view that contains the given geographical bounds with the maximum - * zoom level possible. - */ - fitBounds(bounds: LatLngBounds): Map; - - /** - * Sets a map view that mostly contains the whole world with the maximum zoom - * level possible. - */ - fitWorld(): Map; - - /** - * Pans the map to a given center. Makes an animated pan if new center is not more - * than one screen away from the current one. - */ - panTo(latlng: LatLng): Map; - - /** - * Pans the map to the closest view that would lie inside the given bounds (if - * it's not already). - */ - panInsideBounds(bounds: LatLngBounds): Map; - - /** - * Pans the map by a given number of pixels (animated). - */ - panBy(point: Point): Map; - - /** - * Checks if the map container size changed and updates the map if so — call it - * after you've changed the map size dynamically. If animate is true, map animates - * the update. - */ - invalidateSize(animate?: boolean): Map; - - /** - * Restricts the map view to the given bounds (see map maxBounds option). - */ - setMaxBounds(bounds: LatLngBounds): Map; - - /** - * Tries to locate the user using Geolocation API, firing locationfound event - * with location data on success or locationerror event on failure, and optionally - * sets the map view to the user location with respect to detection accuracy - * (or to the world view if geolocation failed). See Locate options for more - * details. - */ - locate(options?: LocateOptions): Map; - - /** - * Stops watching location previously initiated by map.locate({watch: true}). - */ - stopLocate(): Map; - - /** - * Returns the geographical center of the map view. - */ - getCenter(): LatLng; - - /** - * Returns the current zoom of the map view. - */ - getZoom(): number; - - /** - * Returns the minimum zoom level of the map. - */ - getMinZoom(): number; - - /** - * Returns the maximum zoom level of the map. - */ - getMaxZoom(): number; - - /** - * Returns the LatLngBounds of the current map view. - */ - getBounds(): LatLngBounds; - - /** - * Returns the maximum zoom level on which the given bounds fit to the map view - * in its entirety. If inside (optional) is set to true, the method instead returns - * the minimum zoom level on which the map view fits into the given bounds in its - * entirety. - */ - getBoundsZoom(bounds: LatLngBounds, inside?: boolean): number; - - /** - * Returns the current size of the map container. - */ - getSize(): Point; - - /** - * Returns the bounds of the current map view in projected pixel coordinates - * (sometimes useful in layer and overlay implementations). - */ - getPixelBounds(): Bounds; - - /** - * Returns the projected pixel coordinates of the top left point of the map layer - * (useful in custom layer and overlay implementations). - */ - getPixelOrigin(): Point; - - /** - * Adds the given layer to the map. If optional insertAtTheBottom is set to true, - * the layer is inserted under all others (useful when switching base tile layers). - */ - addLayer(layer: ILayer, insertAtTheBottom?: boolean): Map; - - /** - * Removes the given layer from the map. - */ - removeLayer(layer: ILayer): Map; - - /** - * Returns true if the given layer is currently added to the map. - */ - hasLayer(layer: ILayer): boolean; - - /** - * Opens the specified popup while closing the previously opened (to make sure - * only one is opened at one time for usability). - */ - openPopup(popup: Popup): Map; - - /** - * Closes the popup opened with openPopup. - */ - closePopup(): Map; - - /** - * Adds the given control to the map. - */ - addControl(control: IControl): Map; - - /** - * Removes the given control from the map. - */ - removeControl(control: IControl): Map; - - /** - * Returns the map layer point that corresponds to the given geographical coordinates - * (useful for placing overlays on the map). - */ - latLngToLayerPoint(latlng: LatLng): Point; - - /** - * Returns the geographical coordinates of a given map layer point. - */ - layerPointToLatLng(point: Point): LatLng; - - /** - * Converts the point relative to the map container to a point relative to the - * map layer. - */ - containerPointToLayerPoint(point: Point): Point; - - /** - * Converts the point relative to the map layer to a point relative to the map - * container. - */ - layerPointToContainerPoint(point: Point): Point; - - /** - * Returns the map container point that corresponds to the given geographical - * coordinates. - */ - latLngToContainerPoint(latlng: LatLng): Point; - - /** - * Returns the geographical coordinates of a given map container point. - */ - containerPointToLatLng(point: Point): LatLng; - - /** - * Projects the given geographical coordinates to absolute pixel coordinates - * for the given zoom level (current zoom level by default). - */ - project(latlng: LatLng, zoom?: number): Point; - - /** - * Projects the given absolute pixel coordinates to geographical coordinates - * for the given zoom level (current zoom level by default). - */ - unproject(point: Point, zoom?: number): LatLng; - - /** - * Returns the pixel coordinates of a mouse click (relative to the top left corner - * of the map) given its event object. - */ - mouseEventToContainerPoint(event: LeafletMouseEvent): Point; - - /** - * Returns the pixel coordinates of a mouse click relative to the map layer given - * its event object. - */ - mouseEventToLayerPoint(event: LeafletMouseEvent): Point; - - /** - * Returns the geographical coordinates of the point the mouse clicked on given - * the click's event object. - */ - mouseEventToLatLng(event: LeafletMouseEvent): LatLng; - - /** - * Returns the container element of the map. - */ - getContainer(): HTMLElement; - - /** - * Returns an object with different map panes (to render overlays in). - */ - getPanes(): MapPanes; - - /** - * Runs the given callback when the map gets initialized with a place and zoom, - * or immediately if it happened already, optionally passing a function context. - */ - whenReady(fn: Function, context?: any): Map; - - /** - * Map dragging handler (by both mouse and touch). - */ - dragging: IHandler; - - /** - * Touch zoom handler. - */ - touchZoom: IHandler; - - /** - * Double click zoom handler. - */ - doubleClickZoom: IHandler; - - /** - * Scroll wheel zoom handler. - */ - scrollWheelZoom: IHandler; - - /** - * Box (shift-drag with mouse) zoom handler. - */ - boxZoom: IHandler; - - /** - * Keyboard navigation handler. - */ - keyboard: IHandler; - - /** - * Zoom control. - */ - zoomControl: Zoom; - - /** - * Attribution control. - */ - attributionControl: Attribution; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; - hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; - } - - export interface MarkerOptions { - /** - * Icon class to use for rendering the marker. See Icon documentation for details - * on how to customize the marker icon. Set to new L.Icon.Default() by default. - */ - icon?: Icon; - - /** - * If false, the marker will not emit mouse events and will act as a part of the - * underlying map. - */ - clickable?: boolean; - - /** - * Whether the marker is draggable with mouse/touch or not. - */ - draggable?: boolean; - - /** - * Text for the browser tooltip that appear on marker hover (no tooltip by default). - */ - title?: string; - - /** - * By default, marker images zIndex is set automatically based on its latitude. - * You this option if you want to put the marker on top of all others (or below), - * specifying a high value like 1000 (or high negative value, respectively). - */ - zIndexOffset?: number; - - /** - * The opacity of the marker. - */ - opacity?: number; - - /** - * If true, the marker will get on top of others when you hover the mouse over it. - */ - riseOnHover?: boolean; - - /** - * The z-index offset used for the riseOnHover feature. - */ - riseOffset?: number; - - } - - export class Marker implements ILayer, IEventPowered { /** * Instantiates a Marker object given a geographical point and optionally * an options object. */ constructor(latlng: LatLng, options?: MarkerOptions); - + /** * Adds the marker to the map. */ addTo(map: Map): Marker; - + /** * Returns the current geographical position of the marker. */ getLatLng(): LatLng; - + /** * Changes the marker position to the given point. */ setLatLng(latlng: LatLng): Marker; - + /** * Changes the marker icon. */ setIcon(icon: Icon): Marker; - + /** * Changes the zIndex offset of the marker. */ setZIndexOffset(offset: number): Marker; - + /** * Changes the opacity of the marker. */ setOpacity(opacity: number): Marker; - + /** * Updates the marker position, useful if coordinates of its latLng object * were changed directly. */ update(): Marker; + + /** + * Binds a popup with a particular HTML content to a click on this marker. You + * can also open the bound popup with the Marker openPopup method. + */ + bindPopup(html: string, options?: PopupOptions): Marker; + + /** + * Binds a popup with a particular HTML content to a click on this marker. You + * can also open the bound popup with the Marker openPopup method. + */ + bindPopup(el: HTMLElement, options?: PopupOptions): Marker; /** * Binds a popup with a particular HTML content to a click on this marker. You * can also open the bound popup with the Marker openPopup method. */ - bindPopup(htmlContent: string, options?: PopupOptions): Marker; + bindPopup(popup: Popup, options?: PopupOptions): Marker; /** * Unbinds the popup previously bound to the marker with bindPopup. */ unbindPopup(): Marker; - + /** * Opens the popup previously bound by the bindPopup method. */ openPopup(): Marker; - + /** * Closes the bound popup of the marker if it's opened. */ closePopup(): Marker; - //////////// - //// ILayer members - //////////// + /** + * Toggles the popup previously bound by the bindPopup method. + */ + togglePopup(): Marker; + /** + * Sets an HTML content of the popup of this marker. + */ + setPopupContent(html: string, options?: PopupOptions): Marker; + + /** + * Sets an HTML content of the popup of this marker. + */ + setPopupContent(el: HTMLElement, options?: PopupOptions): Marker; + + /** + * Returns a GeoJSON representation of the marker (GeoJSON Point Feature). + */ + toGeoJSON(popup: Popup, options?: PopupOptions): any; + + //////////// + //////////// /** * Should contain code that creates DOM elements for the overlay, adds them * to map panes where they should belong and puts listeners on relevant map events. * Called on map.addLayer(layer). */ onAdd(map: Map): void; - + /** * Should contain all clean up code that removes the overlay's elements from * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). */ onRemove(map: Map): void; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Marker; hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; + fireEvent(type: string, data?: any): Marker; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): Marker; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Marker; + fire(type: string, data?: any): Marker; + addEventListener(eventMap: any, context?: any): Marker; + removeEventListener(eventMap?: any, context?: any): Marker; + clearAllEventListeners(): Marker + on(eventMap: any, context?: any): Marker; + off(eventMap?: any, context?: any): Marker; } +} + +declare module L { - export interface PopupOptions { - /** - * Max width of the popup. - */ - maxWidth?: number; - - /** - * Min width of the popup. - */ - minWidth?: number; - - /** - * If set, creates a scrollable container of the given height inside a popup - * if its content exceeds it. - */ - maxHeight?: number; - - /** - * Set it to false if you don't want the map to do panning animation to fit the opened - * popup. - */ - autoPan?: boolean; - - /** - * Controls the presense of a close button in the popup. - */ - closeButton?: boolean; - - /** - * The offset of the popup position. Useful to control the anchor of the popup - * when opening it on some overlays. - */ - offset?: Point; - - /** - * The margin between the popup and the edges of the map view after autopanning - * was performed. - */ - autoPanPadding?: Point; - - /** - * Whether to animate the popup on zoom. Disable it if you have problems with - * Flash content inside popups. - */ - zoomAnimation?: boolean; - - } - - export class Popup implements ILayer { - /** - * Instantiates a Popup object given an optional options object that describes - * its appearance and location and an optional object that is used to tag the - * popup with a reference to the source object to which it refers. - */ - constructor(options?: PopupOptions, source?: any); - - /** - * Adds the popup to the map. - */ - addTo(map: Map): Popup; - - /** - * Adds the popup to the map and closes the previous one. The same as map.openPopup(popup). - */ - openOn(map: Map): Popup; - - /** - * Sets the geographical point where the popup will open. - */ - setLatLng(latlng: LatLng): Popup; - - /** - * Sets the HTML content of the popup. - */ - setContent(htmlContent: string): Popup; - - //////////// - //// ILayer members - //////////// - - /** - * Should contain code that creates DOM elements for the overlay, adds them - * to map panes where they should belong and puts listeners on relevant map events. - * Called on map.addLayer(layer). - */ - onAdd(map: Map): void; - - /** - * Should contain all clean up code that removes the overlay's elements from - * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). - */ - onRemove(map: Map): void; - - } - - export interface TileLayerOptions { - /** - * Minimum zoom number. - */ - minZoom?: number; - - /** - * Maximum zoom number. - */ - maxZoom?: number; - - /** - * Tile size (width and height in pixels, assuming tiles are square). - */ - tileSize?: number; - - /** - * Subdomains of the tile service. Can be passed in the form of one string (where - * each letter is a subdomain name) or an array of strings. - */ - subdomains?: any; - - /** - * URL to the tile image to show in place of the tile that failed to load. - */ - errorTileUrl?: string; - - /** - * e.g. "© CloudMade" — the string used by the attribution control, describes - * the layer data. - */ - attribution?: string; - - /** - * If true, inverses Y axis numbering for tiles (turn this on for TMS services). - */ - tms?: boolean; - - /** - * If set to true, the tile coordinates won't be wrapped by world width (-180 - * to 180 longitude) or clamped to lie within world height (-90 to 90). Use this - * if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor - * or photo maps). - */ - continuousWorld?: boolean; - - /** - * If set to true, the tiles just won't load outside the world width (-180 to 180 - * longitude) instead of repeating. - */ - noWrap?: boolean; - - /** - * The zoom number used in tile URLs will be offset with this value. - */ - zoomOffset?: number; - - /** - * If set to true, the zoom number used in tile URLs will be reversed (maxZoom - * - zoom instead of zoom) - */ - zoomReverse?: boolean; - - /** - * The opacity of the tile layer. - */ - opacity?: number; - - /** - * The explicit zIndex of the tile layer. Not set by default. - */ - zIndex?: number; - - /** - * If true, all the tiles that are not visible after panning are removed (for - * better performance). true by default on mobile WebKit, otherwise false. - */ - unloadInvisibleTiles?: boolean; - - /** - * If false, new tiles are loaded during panning, otherwise only after it (for - * better performance). true by default on mobile WebKit, otherwise false. - */ - updateWhenIdle?: boolean; - - /** - * If true and user is on a retina display, it will request four tiles of half the - * specified size and a bigger zoom level in place of one to utilize the high resolution. - */ - detectRetina?: boolean; - - /** - * If true, all the tiles that are not visible after panning are placed in a reuse - * queue from which they will be fetched when new tiles become visible (as opposed - * to dynamically creating new ones). This will in theory keep memory usage - * low and eliminate the need for reserving new memory whenever a new tile is - * needed. - */ - reuseTiles?: boolean; - - } - - export class TileLayer implements ILayer, IEventPowered { - /** - * Instantiates a tile layer object given a URL template and optionally an options - * object. - */ - constructor(urlTemplate: string, options?: TileLayerOptions); - - /** - * Adds the layer to the map. - */ - addTo(map: Map): TileLayer; - - /** - * Brings the tile layer to the top of all tile layers. - */ - bringToFront(): TileLayer; + export interface MarkerOptions { /** - * Brings the tile layer to the bottom of all tile layers. + * Icon class to use for rendering the marker. See Icon documentation for details + * on how to customize the marker icon. + * + * Default value: new L.Icon.Default(). */ - bringToBack(): TileLayer; - - /** - * Changes the opacity of the tile layer. - */ - setOpacity(opacity: number): TileLayer; - - /** - * Sets the zIndex of the tile layer. - */ - setZIndex(zIndex: number): TileLayer; - - /** - * Causes the layer to clear all the tiles and request them again. - */ - redraw(): TileLayer; - - /** - * Updates the layer's URL template and redraws it. - */ - setUrl(urlTemplate: string): TileLayer; - - static WMS: new () => WMS; - - static Canvas: new () => Canvas; - - //////////// - //// ILayer members - //////////// - - /** - * Should contain code that creates DOM elements for the overlay, adds them - * to map panes where they should belong and puts listeners on relevant map events. - * Called on map.addLayer(layer). - */ - onAdd(map: Map): void; - - /** - * Should contain all clean up code that removes the overlay's elements from - * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). - */ - onRemove(map: Map): void; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; - hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; - } - - export interface WMSOptions { - /** - * (required) Comma-separated list of WMS layers to show. - */ - layers?: string; - - /** - * Comma-separated list of WMS styles. - */ - styles?: string; - - /** - * WMS image format (use 'image/png' for layers with transparency). - */ - format?: string; - - /** - * If true, the WMS service will return images with transparency. - */ - transparent?: boolean; - - /** - * Version of the WMS service to use. - */ - version?: string; - - } - - export class WMS { - /** - * Instantiates a WMS tile layer object given a base URL of the WMS service and - * a WMS parameters/options object. - */ - constructor(baseUrl: string, options: WMSOptions); - - /** - * Merges an object with the new parameters and re-requests tiles on the current - * screen (unless noRedraw was set to true). - */ - setParams(params: WMS, noRedraw?: boolean): WMS; - - } - - export class Canvas { - /** - * Instantiates a Canvas tile layer object given an options object (optionally). - */ - constructor(options?: TileLayerOptions); - - /** - * You need to define this method after creating the instance to draw tiles; - * canvas is the actual canvas tile on which you can draw, tilePoint represents - * the tile numbers, and zoom is the current zoom. - */ - drawTile(canvas: HTMLCanvasElement, tilePoint: Point, zoom: number): Canvas; - - /** - * Calling redraw will cause the drawTile method to be called for all tiles. - * May be used for updating dynamic content drawn on the Canvas - */ - redraw(): Canvas; - - } - - export interface ImageOverlayOptions { - /** - * The opacity of the image overlay. - */ - opacity?: number; - - } - - export class ImageOverlay implements ILayer { - /** - * Instantiates an image overlay object given the URL of the image and the geographical - * bounds it is tied to. - */ - constructor(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions); - - /** - * Adds the overlay to the map. - */ - addTo(map: Map): ImageOverlay; - - /** - * Sets the opacity of the overlay. - */ - setOpacity(opacity: number): ImageOverlay; - - /** - * Brings the layer to the top of all overlays. - */ - bringToFront(): ImageOverlay; - - /** - * Brings the layer to the bottom of all overlays. - */ - bringToBack(): ImageOverlay; - - //////////// - //// ILayer members - //////////// - - /** - * Should contain code that creates DOM elements for the overlay, adds them - * to map panes where they should belong and puts listeners on relevant map events. - * Called on map.addLayer(layer). - */ - onAdd(map: Map): void; - - /** - * Should contain all clean up code that removes the overlay's elements from - * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). - */ - onRemove(map: Map): void; - - } - - export interface PathOptions { - /** - * Whether to draw stroke along the path. Set it to false to disable borders on - * polygons or circles. - */ - stroke?: boolean; - - /** - * Stroke color. - */ - color?: string; - - /** - * Stroke width in pixels. - */ - weight?: number; - - /** - * Stroke opacity. - */ - opacity?: number; - - /** - * Whether to fill the path with color. Set it to false to disable filling on polygons - * or circles. - */ - fill?: boolean; - - /** - * Fill color. - */ - fillColor?: string; - - /** - * Fill opacity. - */ - fillOpacity?: number; - - /** - * A string that defines the stroke dash pattern. Doesn't work on canvas-powered - * layers (e.g. Android 2). - */ - dashArray?: string; - + icon?: Icon; + /** - * If false, the vector will not emit mouse events and will act as a part of the + * If false, the marker will not emit mouse events and will act as a part of the * underlying map. + * + * Default value: true. */ clickable?: boolean; + + /** + * Whether the marker is draggable with mouse/touch or not. + * + * Default value: false. + */ + draggable?: boolean; + /** + * Whether the marker can be tabbed to with a keyboard and clicked by pressing enter. + * + * Default value: true. + */ + keyboard?: boolean; + + /** + * Text for the browser tooltip that appear on marker hover (no tooltip by default). + * + * Default value: ''. + */ + title?: string; + + /** + * By default, marker images zIndex is set automatically based on its latitude. + * You this option if you want to put the marker on top of all others (or below), + * specifying a high value like 1000 (or high negative value, respectively). + * + * Default value: 0. + */ + zIndexOffset?: number; + + /** + * The opacity of the marker. + * + * Default value: 1.0. + */ + opacity?: number; + + /** + * If true, the marker will get on top of others when you hover the mouse over it. + * + * Default value: false. + */ + riseOnHover?: boolean; + + /** + * The z-index offset used for the riseOnHover feature. + * + * Default value: 250. + */ + riseOffset?: number; } +} + +declare module L { + + /** + * Instantiates a multi-polyline object given an array of latlngs arrays (one + * for each individual polygon) and optionally an options object (the same + * as for MultiPolyline). + */ + function multiPolygon(latlngs: LatLng[][], options?: PolylineOptions): MultiPolygon; + + export class MultiPolygon extends FeatureGroup { + + /** + * Instantiates a multi-polyline object given an array of latlngs arrays (one + * for each individual polygon) and optionally an options object (the same + * as for MultiPolyline). + */ + constructor(latlngs: LatLng[][], options?: PolylineOptions); + + /** + * Replace all polygons and their paths with the given array of arrays + * of geographical points. + */ + setLatLngs(latlngs: LatLng[][]): MultiPolygon; + + /** + * Returns an array of arrays of geographical points in each polygon. + */ + getLatLngs(): LatLng[][]; + + /** + * Returns a GeoJSON representation of the multipolygon (GeoJSON MultiPolygon Feature). + */ + toGeoJSON(): any; + } +} + +declare module L { + + /** + * Instantiates a multi-polyline object given an array of arrays of geographical + * points (one for each individual polyline) and optionally an options object. + */ + function multiPolyline(latlngs: LatLng[][], options?: PolylineOptions): MultiPolyline; + + export class MultiPolyline extends FeatureGroup { + + /** + * Instantiates a multi-polyline object given an array of arrays of geographical + * points (one for each individual polyline) and optionally an options object. + */ + constructor(latlngs: LatLng[][], options?: PolylineOptions); + + /** + * Replace all polygons and their paths with the given array of arrays + * of geographical points. + */ + setLatLngs(latlngs: LatLng[][]): MultiPolyline; + + /** + * Returns an array of arrays of geographical points in each polygon. + */ + getLatLngs(): LatLng[][]; + + /** + * Returns a GeoJSON representation of the multipolyline (GeoJSON MultiLineString Feature). + */ + toGeoJSON(): any; + } +} + +declare module L { + + export interface PanOptions { + + /** + * If true, panning will always be animated if possible. If false, it will not + * animate panning, either resetting the map view if panning more than a screen + * away, or just setting a new offset for the map pane (except for `panBy` + * which always does the latter). + */ + animate?: boolean; + + /** + * Duration of animated panning. + * + * Default value: 0.25. + */ + duration?: number; + + /** + * The curvature factor of panning animation easing (third parameter of the Cubic + * Bezier curve). 1.0 means linear animation, the less the more bowed the curve. + * + * Default value: 0.25. + */ + easeLinearity?: number; + + /** + * If true, panning won't fire movestart event on start (used internally for panning inertia). + * + * Default value: false. + */ + noMoveStart?: boolean; + } +} + +declare module L { + + export class Path extends Class implements ILayer, IEventPowered { - export class Path implements ILayer, IEventPowered { /** * Adds the layer to the map. */ addTo(map: Map): Path; + + /** + * Binds a popup with a particular HTML content to a click on this path. + */ + bindPopup(html: string, options?: PopupOptions): Path; + + /** + * Binds a popup with a particular HTML content to a click on this path. + */ + bindPopup(el: HTMLElement, options?: PopupOptions): Path; /** * Binds a popup with a particular HTML content to a click on this path. */ - bindPopup(htmlContent: string, options?: PopupOptions): Path; + bindPopup(popup: Popup, options?: PopupOptions): Path; /** * Unbinds the popup previously bound to the path with bindPopup. */ unbindPopup(): Path; - + /** * Opens the popup previously bound by the bindPopup method in the given point, * or in one of the path's points if not specified. */ openPopup(latlng?: LatLng): Path; - + /** * Closes the path's bound popup if it is opened. */ closePopup(): Path; - + /** * Changes the appearance of a Path based on the options in the Path options object. */ setStyle(object: PathOptions): Path; - + /** * Returns the LatLngBounds of the path. */ getBounds(): LatLngBounds; - + /** * Brings the layer to the top of all path layers. */ bringToFront(): Path; - + /** * Brings the layer to the bottom of all path layers. */ bringToBack(): Path; - + /** * Redraws the layer. Sometimes useful after you changed the coordinates that * the path uses. */ redraw(): Path; - + /** * True if SVG is used for vector rendering (true for most modern browsers). */ static SVG: boolean; - + /** * True if VML is used for vector rendering (IE 6-8). */ static VML: boolean; - + /** * True if Canvas is used for vector rendering (Android 2). You can also force * this by setting global variable L_PREFER_CANVAS to true before the Leaflet @@ -1211,7 +2975,7 @@ declare module L { * a bug that causes removing such layers to be extremely slow. */ static CANVAS: boolean; - + /** * How much to extend the clip area around the map view (relative to its size, * e.g. 0.5 is half the screen in each direction). Smaller values mean that you @@ -1221,503 +2985,124 @@ declare module L { static CLIP_PADDING: number; //////////// - //// ILayer members //////////// - /** * Should contain code that creates DOM elements for the overlay, adds them * to map panes where they should belong and puts listeners on relevant map events. * Called on map.addLayer(layer). */ onAdd(map: Map): void; - + /** * Should contain all clean up code that removes the overlay's elements from * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). */ onRemove(map: Map): void; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Path; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Path; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Path; hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; + fireEvent(type: string, data?: any): Path; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): Path; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): Path; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Path; + fire(type: string, data?: any): Path; + addEventListener(eventMap: any, context?: any): Path; + removeEventListener(eventMap?: any, context?: any): Path; + clearAllEventListeners(): Path + on(eventMap: any, context?: any): Path; + off(eventMap?: any, context?: any): Path; } +} + +declare module L { - export interface PolylineOptions { - /** - * How much to simplify the polyline on each zoom level. More means better performance - * and smoother look, and less means more accurate representation. - */ - smoothFactor?: number; + export interface PathOptions { /** - * Disabled polyline clipping. + * Whether to draw stroke along the path. Set it to false to disable borders on + * polygons or circles. + * + * Default value: true. */ - noClip?: boolean; - - } - - export class Polyline extends Path { + stroke?: boolean; + /** - * Instantiates a polyline object given an array of geographical points and - * optionally an options object. + * Stroke color. + * + * Default value: '#03f'. */ - constructor(latlngs: LatLng[], options?: PolylineOptions); - + color?: string; + /** - * Adds a given point to the polyline. + * Stroke width in pixels. + * + * Default value: 5. */ - addLatLng(latlng: LatLng): Polyline; - + weight?: number; + /** - * Replaces all the points in the polyline with the given array of geographical - * points. + * Stroke opacity. + * + * Default value: 0.5. */ - setLatLngs(latlngs: LatLng[]): Polyline; - + opacity?: number; + /** - * Returns an array of the points in the path. + * Whether to fill the path with color. Set it to false to disable filling on polygons + * or circles. */ - getLatLngs(): LatLng[]; - + fill?: boolean; + /** - * Allows adding, removing or replacing points in the polyline. Syntax is the - * same as in Array#splice. Returns the array of removed points (if any). + * Fill color. + * + * Default value: same as color. */ - spliceLatLngs(index: number, pointsToRemove: number, ...latlngs: LatLng[]): LatLng[]; - + fillColor?: string; + /** - * Returns the LatLngBounds of the polyline. + * Fill opacity. + * + * Default value: 0.2. */ - getBounds(): LatLngBounds; - - } - - export class MultiPolyline extends FeatureGroup { + fillOpacity?: number; + /** - * Instantiates a multi-polyline object given an array of arrays of geographical - * points (one for each individual polyline) and optionally an options object. + * A string that defines the stroke dash pattern. Doesn't work on canvas-powered + * layers (e.g. Android 2). */ - constructor(latlngs: LatLng[][], options?: PolylineOptions); - - } - - export class Polygon extends Polyline { + dashArray?: string; + /** - * Instantiates a polygon object given an array of geographical points and - * optionally an options object (the same as for Polyline). You can also create - * a polygon with holes by passing an array of arrays of latlngs, with the first - * latlngs array representing the exterior ring while the remaining represent - * the holes inside. + * If false, the vector will not emit mouse events and will act as a part of the + * underlying map. + * + * Default value: true. */ - constructor(latlngs: LatLng[], options?: PolylineOptions); - - } - - export class MultiPolygon extends FeatureGroup { - /** - * Instantiates a multi-polyline object given an array of latlngs arrays (one - * for each individual polygon) and optionally an options object (the same - * as for MultiPolyline). - */ - constructor(latlngs: LatLng[][], options?: PolylineOptions); - - } - - export class Rectangle extends Polygon { - /** - * Instantiates a rectangle object with the given geographical bounds and - * optionally an options object. - */ - constructor(bounds: LatLngBounds, options?: PathOptions); - - /** - * Redraws the rectangle with the passed bounds. - */ - setBounds(bounds: LatLngBounds): Rectangle; - - } - - export class Circle extends Path { - /** - * Instantiates a circle object given a geographical point, a radius in meters - * and optionally an options object. - */ - constructor(latlng: LatLng, radius: number, options?: PathOptions); - - /** - * Returns the current geographical position of the circle. - */ - getLatLng(): LatLng; - - /** - * Returns the current radius of a circle. Units are in meters. - */ - getRadius(): number; - - /** - * Sets the position of a circle to a new location. - */ - setLatLng(latlng: LatLng): Circle; - - /** - * Sets the radius of a circle. Units are in meters. - */ - setRadius(radius: number): Circle; - - } - - export class CircleMarker extends Circle { - /** - * Instantiates a circle marker given a geographical point and optionally - * an options object. The default radius is 10 and can be altered by passing a - * "radius" member in the path options object. - */ - constructor(latlng: LatLng, options?: PathOptions); - - /** - * Sets the position of a circle marker to a new location. - */ - setLatLng(latlng: LatLng): CircleMarker; - - /** - * Sets the radius of a circle marker. Units are in pixels. - */ - setRadius(radius: number): CircleMarker; - - } - - export class LayerGroup implements ILayer { - /** - * Create a layer group, optionally given an initial set of layers. - */ - constructor(layers?: ILayer[]); - - /** - * Adds the group of layers to the map. - */ - addTo(map: Map): LayerGroup; - - /** - * Adds a given layer to the group. - */ - addLayer(layer: ILayer): LayerGroup; - - /** - * Removes a given layer from the group. - */ - removeLayer(layer: ILayer): LayerGroup; - - /** - * Removes all the layers from the group. - */ - clearLayers(): LayerGroup; - - /** - * Iterates over the layers of the group, optionally specifying context of - * the iterator function. - */ - eachLayer(fn: (layer: ILayer) => void, context?: any): LayerGroup; - - //////////// - //// ILayer members - //////////// - - /** - * Should contain code that creates DOM elements for the overlay, adds them - * to map panes where they should belong and puts listeners on relevant map events. - * Called on map.addLayer(layer). - */ - onAdd(map: Map): void; - - /** - * Should contain all clean up code that removes the overlay's elements from - * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). - */ - onRemove(map: Map): void; - - } - - export class FeatureGroup extends LayerGroup implements ILayer, IEventPowered { - /** - * Create a layer group, optionally given an initial set of layers. - */ - constructor(layers?: ILayer[]); - - /** - * Binds a popup with a particular HTML content to a click on any layer from the - * group that has a bindPopup method. - */ - bindPopup(htmlContent: string, options?: PopupOptions): FeatureGroup; - - /** - * Returns the LatLngBounds of the Feature Group (created from bounds and coordinates - * of its children). - */ - getBounds(): LatLngBounds; - - /** - * Sets the given path options to each layer of the group that has a setStyle method. - */ - setStyle(style: PathOptions): FeatureGroup; - - /** - * Brings the layer group to the top of all other layers. - */ - bringToFront(): FeatureGroup; - - /** - * Brings the layer group to the bottom of all other layers. - */ - bringToBack(): FeatureGroup; - - //////////// - //// ILayer members - //////////// - - /** - * Should contain code that creates DOM elements for the overlay, adds them - * to map panes where they should belong and puts listeners on relevant map events. - * Called on map.addLayer(layer). - */ - onAdd(map: Map): void; - - /** - * Should contain all clean up code that removes the overlay's elements from - * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). - */ - onRemove(map: Map): void; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; - hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; - } - - export interface GeoJSONOptions { - /** - * Function that will be used for creating layers for GeoJSON points (if not - * specified, simple markers will be created). - */ - pointToLayer?: (featureData: any, latlng: LatLng) => ILayer; - - /** - * Function that will be used to get style options for vector layers created - * for GeoJSON features. - */ - style?: (featureData: any) => any; - - /** - * Function that will be called on each created feature layer. Useful for attaching - * events and popups to features. - */ - onEachFeature?: (featureData: any, layer: ILayer) => void; - - /** - * Function that will be used to decide whether to show a feature or not. - */ - filter?: (featureData: any, layer: ILayer) => boolean; - - } - - export class GeoJSON extends FeatureGroup { - /** - * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format - * to display on the map (you can alternatively add it later with addData method) - * and an options object. - */ - constructor(geojson?: any, options?: GeoJSONOptions); - - /** - * Adds a GeoJSON object to the layer. - */ - addData(data: any): boolean; - - /** - * NOTE: A fake signature to allow an overriding overload. - */ - setStyle(style: PathOptions): FeatureGroup; - - /** - * Changes styles of GeoJSON vector layers with the given style function. - */ - setStyle(style: (featureData: any) => any): GeoJSON; - - /** - * Resets the the given vector layer's style to the original GeoJSON style, - * useful for resetting style after hover events. - */ - resetStyle(layer: Path): GeoJSON; - - /** - * Creates a layer from a given GeoJSON feature. - */ - static geometryToLayer(featureData: GeoJSON, pointToLayer?: (featureData: any, latlng: LatLng) => ILayer): ILayer; - - /** - * Creates a LatLng object from an array of 2 numbers (latitude, longitude) - * used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted - * as (longitude, latitude). - */ - static coordsToLatlng(coords: number[], reverse?: boolean): LatLng; - - /** - * Creates a multidimensional array of LatLng objects from a GeoJSON coordinates - * array. levelsDeep specifies the nesting level (0 is for an array of points, - * 1 for an array of arrays of points, etc., 0 by default). If reverse is set to - * true, the numbers will be interpreted as (longitude, latitude). - */ - static coordsToLatlngs(coords: number[], levelsDeep?: number, reverse?: boolean): LatLng[]; - - } - - export class LatLng { - /** - * Creates an object representing a geographical point with the given latitude - * and longitude. - */ - constructor(latitude: number, longitude: number); - - /** - * Returns the distance (in meters) to the given LatLng calculated using the - * Haversine formula. See description on wikipedia - */ - distanceTo(otherLatlng: LatLng): number; - - /** - * Returns true if the given LatLng point is at the same position (within a small - * margin of error). - */ - equals(otherLatlng: LatLng): boolean; - - /** - * Returns a string representation of the point (for debugging purposes). - */ - toString(): string; - - /** - * Returns a new LatLng object with the longitude wrapped around left and right - * boundaries (-180 to 180 by default). - */ - wrap(left: number, right: number): LatLng; - - /** - * Latitude in degrees. - */ - lat: number; - - /** - * Longitude in degrees. - */ - lng: number; - - } - - export class LatLngBounds { - /** - * Creates a LatLngBounds object by defining south-west and north-east corners - * of the rectangle. - */ - constructor(southWest: LatLng, northEast: LatLng); - - /** - * Extends the bounds to contain the given point or bounds. - */ - extend(latlng: LatLng): LatLngBounds; - - /** - * Extends the bounds to contain the given point or bounds. - */ - extend(latlng: LatLngBounds): LatLngBounds; - - /** - * Returns the south-west point of the bounds. - */ - getSouthWest(): LatLng; - - /** - * Returns the north-east point of the bounds. - */ - getNorthEast(): LatLng; - - /** - * Returns the north-west point of the bounds. - */ - getNorthWest(): LatLng; - - /** - * Returns the south-east point of the bounds. - */ - getSouthEast(): LatLng; - - /** - * Returns the center point of the bounds. - */ - getCenter(): LatLng; - - /** - * Returns true if the rectangle contains the given one. - */ - contains(otherBounds: LatLngBounds): boolean; - - /** - * Returns true if the rectangle contains the given point. - */ - contains(latlng: LatLng): boolean; - - /** - * Returns true if the rectangle intersects the given bounds. - */ - intersects(otherBounds: LatLngBounds): boolean; - - /** - * Returns true if the rectangle is equivalent (within a small margin of error) - * to the given bounds. - */ - equals(otherBounds: LatLngBounds): boolean; - - /** - * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' - * format. Useful for sending requests to web services that return geo data. - */ - toBBoxString(): string; - - /** - * Returns bigger bounds created by extending the current bounds by a given - * percentage in each direction. - */ - pad(bufferRatio: number): LatLngBounds; - - /** - * Returns true if the bounds are properly initialized. - */ - isValid(): boolean; + clickable?: boolean; + /** + * Sets the pointer-events attribute on the path if SVG backend is used. + */ + pointerEvents?: boolean; + } +} + +declare module L { + + /** + * Creates a Point object with the given x and y coordinates. If optional round + * is set to true, rounds the x and y values. + */ + function point(x: number, y: number, round?: boolean): Point; export class Point { + /** * Creates a Point object with the given x and y coordinates. If optional round * is set to true, rounds the x and y values. @@ -1728,48 +3113,48 @@ declare module L { * Returns the result of addition of the current and the given points. */ add(otherPoint: Point): Point; - + /** * Returns the result of subtraction of the given point from the current. */ subtract(otherPoint: Point): Point; - + /** * Returns the result of multiplication of the current point by the given number. */ multiplyBy(number: number): Point; - + /** * Returns the result of division of the current point by the given number. If * optional round is set to true, returns a rounded result. */ divideBy(number: number, round?: boolean): Point; - + /** * Returns the distance between the current and the given points. */ distanceTo(otherPoint: Point): number; - + /** * Returns a copy of the current point. */ clone(): Point; - + /** * Returns a copy of the current point with rounded coordinates. */ round(): Point; - + /** * Returns true if the given point has the same coordinates. */ equals(otherPoint: Point): boolean; - + /** * Returns a string representation of the point for debugging purposes. */ toString(): string; - + /** * The x coordinate. */ @@ -1779,776 +3164,108 @@ declare module L { * The y coordinate. */ y: number; - } +} + +declare module L { - export class Bounds { - /** - * Creates a Bounds object from two coordinates (usually top-left and bottom-right - * corners). - */ - constructor(topLeft: Point, bottomRight: Point); + /** + * Instantiates a polygon object given an array of geographical points and + * optionally an options object (the same as for Polyline). You can also create + * a polygon with holes by passing an array of arrays of latlngs, with the first + * latlngs array representing the exterior ring while the remaining represent + * the holes inside. + */ + function polygon(latlngs: LatLng[], options?: PolylineOptions): Polygon; + + export class Polygon extends Polyline { /** - * Extends the bounds to contain the given point. + * Instantiates a polygon object given an array of geographical points and + * optionally an options object (the same as for Polyline). You can also create + * a polygon with holes by passing an array of arrays of latlngs, with the first + * latlngs array representing the exterior ring while the remaining represent + * the holes inside. */ - extend(point: Point): void; - - /** - * Returns the center point of the bounds. - */ - getCenter(): Point; - - /** - * Returns true if the rectangle contains the given one. - */ - contains(otherBounds: Bounds): boolean; - - /** - * Returns true if the rectangle contains the given point. - */ - contains(point: Point): boolean; - - /** - * Returns true if the rectangle intersects the given bounds. - */ - intersects(otherBounds: Bounds): boolean; - - /** - * Returns true if the bounds are properly initialized. - */ - isValid(): boolean; - - /** - * Returns the size of the given bounds. - */ - getSize(): Point; - - /** - * The top left corner of the rectangle. - */ - min: Point; - - /** - * The bottom right corner of the rectangle. - */ - max: Point; - + constructor(latlngs: LatLng[], options?: PolylineOptions); } +} + +declare module L { - export interface IconOptions { - /** - * (required) The URL to the icon image (absolute or relative to your script - * path). - */ - iconUrl?: string; + /** + * Instantiates a polyline object given an array of geographical points and + * optionally an options object. + */ + function polyline(latlngs: LatLng[], options?: PolylineOptions): Polyline; + + export class Polyline extends Path { /** - * The URL to a retina sized version of the icon image (absolute or relative to - * your script path). Used for Retina screen devices. + * Instantiates a polyline object given an array of geographical points and + * optionally an options object. */ - iconRetinaUrl?: string; + constructor(latlngs: LatLng[], options?: PolylineOptions); + + /** + * Adds a given point to the polyline. + */ + addLatLng(latlng: LatLng): Polyline; + + /** + * Replaces all the points in the polyline with the given array of geographical + * points. + */ + setLatLngs(latlngs: LatLng[]): Polyline; + + /** + * Returns an array of the points in the path. + */ + getLatLngs(): LatLng[]; + + /** + * Allows adding, removing or replacing points in the polyline. Syntax is the + * same as in Array#splice. Returns the array of removed points (if any). + */ + spliceLatLngs(index: number, pointsToRemove: number, ...latlngs: LatLng[]): LatLng[]; + + /** + * Returns the LatLngBounds of the polyline. + */ + getBounds(): LatLngBounds; /** - * Size of the icon image in pixels. + * Returns a GeoJSON representation of the polyline (GeoJSON LineString Feature). */ - iconSize?: Point; - - /** - * The coordinates of the "tip" of the icon (relative to its top left corner). - * The icon will be aligned so that this point is at the marker's geographical - * location. Centered by default if size is specified, also can be set in CSS - * with negative margins. - */ - iconAnchor?: Point; - - /** - * The URL to the icon shadow image. If not specified, no shadow image will be - * created. - */ - shadowUrl?: string; - - /** - * The URL to the retina sized version of the icon shadow image. If not specified, - * no shadow image will be created. Used for Retina screen devices. - */ - shadowRetinaUrl?: string; - - /** - * Size of the shadow image in pixels. - */ - shadowSize?: Point; - - /** - * The coordinates of the "tip" of the shadow (relative to its top left corner) - * (the same as iconAnchor if not specified). - */ - shadowAnchor?: Point; - - /** - * The coordinates of the point from which popups will "open", relative to the - * icon anchor. - */ - popupAnchor?: Point; - - /** - * A custom class name to assign to both icon and shadow images. Empty by default. - */ - className?: string; - + toGeoJSON(): any; } +} + +declare module L { - export class Icon { - /** - * Creates an icon instance with the given options. - */ - constructor(options: IconOptions); + export interface PolylineOptions { /** - * Default properties for newly constructed icons. + * How much to simplify the polyline on each zoom level. More means better performance + * and smoother look, and less means more accurate representation. + * + * Default value: 1.0. */ - public static Default : IconDefault; - } - - export class IconDefault extends Icon { + smoothFactor?: number; + /** - * Creates an icon instance with default options. + * Disabled polyline clipping. + * + * Default value: false. */ - constructor(); - - imagePath: string; - } - - export interface DivIconOptions { - /** - * Size of the icon in pixels. Can be also set through CSS. - */ - iconSize?: Point; - - /** - * The coordinates of the "tip" of the icon (relative to its top left corner). - * The icon will be aligned so that this point is at the marker's geographical - * location. Centered by default if size is specified, also can be set in CSS - * with negative margins. - */ - iconAnchor?: Point; - - /** - * A custom class name to assign to the icon. 'leaflet-div-icon' by default. - */ - className?: string; - - /** - * A custom HTML code to put inside the div element, empty by default. - */ - html?: string; - - } - - export class DivIcon extends Icon{ - /** - * Creates a div icon instance with the given options. - */ - constructor(options: DivIconOptions); - - } - - export interface ControlOptions { - /** - * The initial position of the control (one of the map corners). See control - * positions. - */ - position: string; - - } - - export class Control implements IControl { - /** - * Creates a control with the given options. - */ - constructor(options?: ControlOptions); - - /** - * Sets the position of the control. See control positions. - */ - setPosition(position: string): Control; - - /** - * Returns the current position of the control. - */ - getPosition(): string; - - /** - * Adds the control to the map. - */ - addTo(map: Map): Control; - - /** - * Removes the control from the map. - */ - removeFrom(map: Map): Control; - - static Zoom: new () => Zoom; - - static Attribution: new () => Attribution; - - static Layers: new () => Layers; - - static Scale: new () => Scale; - - //////////// - //// IControl members - //////////// - - /** - * Should contain code that creates all the neccessary DOM elements for the - * control, adds listeners on relevant map events, and returns the element - * containing the control. Called on map.addControl(control) or control.addTo(map). - */ - onAdd(map: Map): HTMLElement; - - /** - * Optional, should contain all clean up code (e.g. removes control's event - * listeners). Called on map.removeControl(control) or control.removeFrom(map). - * The control's DOM container is removed automatically. - */ - onRemove(map: Map): void; - - } - - export interface ZoomOptions { - /** - * The position of the control (one of the map corners). See control positions. - */ - position?: string; - - } - - export class Zoom extends Control { - /** - * Creates a zoom control. - */ - constructor(options?: ZoomOptions); - - } - - export interface AttributionOptions { - /** - * The position of the control (one of the map corners). See control positions. - */ - position?: string; - - /** - * The HTML text shown before the attributions. Pass false to disable. - */ - prefix?: string; - - } - - export class Attribution extends Control { - /** - * Creates an attribution control. - */ - constructor(options?: AttributionOptions); - - /** - * Sets the text before the attributions. - */ - setPrefix(prefix: string): Attribution; - - /** - * Adds an attribution text (e.g. 'Vector data © CloudMade'). - */ - addAttribution(text: string): Attribution; - - /** - * Removes an attribution text. - */ - removeAttribution(text: string): Attribution; - - } - - export interface LayersOptions { - /** - * The position of the control (one of the map corners). See control positions. - */ - position?: string; - - /** - * If true, the control will be collapsed into an icon and expanded on mouse hover - * or touch. - */ - collapsed?: boolean; - - /** - * If true, the control will assign zIndexes in increasing order to all of its - * layers so that the order is preserved when switching them on/off. - */ - autoZIndex?: boolean; - - } - - export class Layers extends Control implements IEventPowered { - /** - * Creates an attribution control with the given layers. Base layers will be - * switched with radio buttons, while overlays will be switched with checkboxes. - */ - constructor(baseLayers?: any, overlays?: any, options?: LayersOptions); - - /** - * Adds a base layer (radio button entry) with the given name to the control. - */ - addBaseLayer(layer: ILayer, name: string): Layers; - - /** - * Adds an overlay (checkbox entry) with the given name to the control. - */ - addOverlay(layer: ILayer, name: string): Layers; - - /** - * Remove the given layer from the control. - */ - removeLayer(layer: ILayer): Layers; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; - hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; - } - - export interface ScaleOptions { - /** - * The position of the control (one of the map corners). See control positions. - */ - position?: string; - - /** - * Maximum width of the control in pixels. The width is set dynamically to show - * round values (e.g. 100, 200, 500). - */ - maxWidth?: number; - - /** - * Whether to show the metric scale line (m/km). - */ - metric?: boolean; - - /** - * Whether to show the imperial scale line (mi/ft). - */ - imperial?: boolean; - - /** - * If true, the control is updated on moveend, otherwise it's always up-to-date - * (updated on move). - */ - updateWhenIdle?: boolean; - - } - - export class Scale extends Control { - /** - * Creates an scale control with the given options. - */ - constructor(options?: ScaleOptions); - - } - - export interface IEventPowered { - /** - * Adds a listener function (fn) to a particular event type of the object. You - * can optionally specify the context of the listener (object the this keyword - * will point to). You can also pass several space-separated types (e.g. 'click - * dblclick'). - */ - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - - /** - * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - */ - addEventListener(eventMap: any, context?: any): IEventPowered; - - /** - * Removes a previously added listener function. If no function is specified, - * it will remove all the listeners of that particular event from the object. - */ - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - - /** - * Removes a set of type/listener pairs. - */ - removeEventListener(eventMap: any, context?: any): IEventPowered; - - /** - * Returns true if a particular event type has some listeners attached to it. - */ - hasEventListeners(type: string): boolean; - - /** - * Fires an event of the specified type. You can optionally provide an data object - * — the first argument of the listener function will contain its properties. - */ - fireEvent(type: string, data?: any): IEventPowered; - - /** - * Alias to addEventListener. - */ - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - - /** - * Alias to addEventListener. - */ - on(eventMap: any, context?: any): IEventPowered; - - /** - * Alias to removeEventListener. - */ - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - - /** - * Alias to removeEventListener. - */ - off(eventMap: any, context?: any): IEventPowered; - - /** - * Alias to fireEvent. - */ - fire(type: string, data?: any): IEventPowered; - - } - - export interface LeafletEvent { - /** - * The event type (e.g. 'click'). - */ - type: string; - - /** - * The object that fired the event. - */ - target: any; - - } - - export interface LeafletMouseEvent { - /** - * The geographical point where the mouse event occured. - */ - latlng: LatLng; - - /** - * Pixel coordinates of the point where the mouse event occured relative to - * the map layer. - */ - layerPoint: Point; - - /** - * Pixel coordinates of the point where the mouse event occured relative to - * the map сontainer. - */ - containerPoint: Point; - - /** - * The original DOM mouse event fired by the browser. - */ - originalEvent: MouseEvent; - - } - - export interface LeafletLocationEvent { - /** - * Detected geographical location of the user. - */ - latlng: LatLng; - - /** - * Geographical bounds of the area user is located in (with respect to the accuracy - * of location). - */ - bounds: LatLngBounds; - - /** - * Accuracy of location in meters. - */ - accuracy: number; - - } - - export interface LeafletErrorEvent { - /** - * Error message. - */ - message: string; - - /** - * Error code (if applicable). - */ - code: number; - - } - - export interface LeafletLayerEvent { - /** - * The layer that was added or removed. - */ - layer: ILayer; - - } - - export interface LeafletTileEvent { - /** - * The tile element (image). - */ - tile: HTMLElement; - - /** - * The source URL of the tile. - */ - url: string; - - } - - export interface LeafletGeoJSONEvent { - /** - * The layer for the GeoJSON feature that is being added to the map. - */ - layer: ILayer; - - /** - * GeoJSON properties of the feature. - */ - properties: any; - - /** - * GeoJSON geometry type of the feature. - */ - geometryType: string; - - /** - * GeoJSON ID of the feature (if present). - */ - id: string; - - } - - export interface LeafletPopupEvent { - /** - * The popup that was opened or closed. - */ - popup: Popup; - - } - - export class Class { - } - - export class Browser { - /** - * true for all Internet Explorer versions. - */ - static ie: boolean; - - /** - * true for Internet Explorer 6. - */ - static ie6: boolean; - - /** - * true for Internet Explorer 6. - */ - static ie7: boolean; - - /** - * true for webkit-based browsers like Chrome and Safari (including mobile - * versions). - */ - static webkit: boolean; - - /** - * true for webkit-based browsers that support CSS 3D transformations. - */ - static webkit3d: boolean; - - /** - * true for Android mobile browser. - */ - static android: boolean; - - /** - * true for old Android stock browsers (2 and 3). - */ - static android23: boolean; - - /** - * true for modern mobile browsers (including iOS Safari and different Android - * browsers). - */ - static mobile: boolean; - - /** - * true for mobile webkit-based browsers. - */ - static mobileWebkit: boolean; - - /** - * true for mobile Opera. - */ - static mobileOpera: boolean; - - /** - * true for all browsers on touch devices. - */ - static touch: boolean; - - /** - * true for browsers with Microsoft touch model (e.g. IE10). - */ - static msTouch: boolean; - - /** - * true for devices with Retina screens. - */ - static retina: boolean; - - } - - export class Util { - /** - * Merges the properties of the src object (or multiple objects) into dest object - * and returns the latter. Has an L.extend shortcut. - */ - static extend(dest: any, ...sources: any[]): any; - - /** - * Returns a function which executes function fn with the given scope obj (so - * that this keyword refers to obj inside the function code). Has an L.bind shortcut. - */ - static bind(fn: Function, obj: any): Function; - - /** - * Applies a unique key to the object and returns that key. Has an L.stamp shortcut. - */ - static stamp(obj: any): string; - - /** - * Returns a wrapper around the function fn that makes sure it's called not more - * often than a certain time interval time, but as fast as possible otherwise - * (for example, it is used for checking and requesting new tiles while dragging - * the map), optionally passing the scope (context) in which the function will - * be called. - */ - static limitExecByInterval(fn: Function, time: number, context?: any): Function; - - /** - * Returns a function which always returns false. - */ - static falseFn(): () => boolean; - - /** - * Returns the number num rounded to digits decimals. - */ - static formatNum(num: number, digits: number): number; - - /** - * Trims and splits the string on whitespace and returns the array of parts. - */ - static splitWords(str: string): string[]; - - /** - * Merges the given properties to the options of the obj object, returning the - * resulting options. See Class options. Has an L.setOptions shortcut. - */ - static setOptions(obj: any, options: any): any; - - /** - * Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} - * translates to '?a=foo&b=bar'. - */ - static getParamString(obj: any): string; - - /** - * Simple templating facility, creates a string by applying the values of the - * data object of a form {a: 'foo', b: 'bar', …} to a template string of the form - * 'Hello {a}, {b}' — in this example you will get 'Hello foo, bar'. - */ - static template(str: string, data: any): string; - - /** - * Returns true if the given object is an array. - */ - static isArray(obj: any): boolean; - - /** - * Data URI string containing a base64-encoded empty GIF image. Used as a hack - * to free memory from unused images on WebKit-powered mobile devices (by setting - * image src to this string). - */ - static emptyImageUrl: string; - - } - - export class Transformation { - /** - * Creates a transformation object with the given coefficients. - */ - constructor(a: number, b: number, c: number, d: number); - - /** - * Returns a transformed point, optionally multiplied by the given scale. - * Only accepts real L.Point instances, not arrays. - */ - transform(point: Point, scale?: number): Point; - - /** - * Returns the reverse transformation of the given point, optionally divided - * by the given scale. Only accepts real L.Point instances, not arrays. - */ - untransform(point: Point, scale?: number): Point; - - } - - export class LineUtil { - /** - * Dramatically reduces the number of points in a polyline while retaining - * its shape and returns a new array of simplified points. Used for a huge performance - * boost when processing/displaying Leaflet polylines for each zoom level - * and also reducing visual noise. tolerance affects the amount of simplification - * (lesser value means higher quality but slower and with more points). Also - * released as a separated micro-library Simplify.js. - */ - static simplify(points: Point[], tolerance: number): Point[]; - - /** - * Returns the distance between point p and segment p1 to p2. - */ - static pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; - - /** - * Returns the closest point from a point p on a segment p1 to p2. - */ - static closestPointOnSegment(p: Point, p1: Point, p2: Point): number; - - /** - * Clips the segment a to b by rectangular bounds (modifying the segment points - * directly!). Used by Leaflet to only show polyline points that are on the screen - * or near, increasing performance. - */ - static clipSegment(a: Point, b: Point, bounds: Bounds): void; - + noClip?: boolean; } +} + +declare module L { export class PolyUtil { + /** * Clips the polygon geometry defined by the given points by rectangular bounds. * Used by Leaflet to only show polygon points that are on the screen or near, @@ -2556,291 +3273,194 @@ declare module L { * for clipping than polyline, so there's a seperate method for it. */ static clipPolygon(points: Point[], bounds: Bounds): Point[]; - } +} + +declare module L { - export class DomEvent { - /** - * Adds a listener fn to the element's DOM event of the specified type. this keyword - * inside the listener will point to context, or to the element if not specified. - */ - static addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; + /** + * Instantiates a Popup object given an optional options object that describes + * its appearance and location and an optional object that is used to tag the + * popup with a reference to the source object to which it refers. + */ + function popup(options?: PopupOptions, source?: any): Popup; + + export class Popup extends Class implements ILayer { /** - * Removes an event listener from the element. + * Instantiates a Popup object given an optional options object that describes + * its appearance and location and an optional object that is used to tag the + * popup with a reference to the source object to which it refers. */ - static removeListener(el: HTMLElement, type: string, fn: (e: Event) => void): DomEvent; + constructor(options?: PopupOptions, source?: any); + + /** + * Adds the popup to the map. + */ + addTo(map: Map): Popup; + + /** + * Adds the popup to the map and closes the previous one. The same as map.openPopup(popup). + */ + openOn(map: Map): Popup; + + /** + * Sets the geographical point where the popup will open. + */ + setLatLng(latlng: LatLng): Popup; + + /** + * Sets the HTML content of the popup. + */ + setContent(html: string): Popup; /** - * Stop the given event from propagation to parent elements. Used inside the - * listener functions: - * L.DomEvent.addListener(div, 'click', function - * (e) { - * L.DomEvent.stopPropagation(e); - * }); + * Sets the HTML content of the popup. */ - static stopPropagation(e: Event): DomEvent; - - /** - * Prevents the default action of the event from happening (such as following - * a link in the href of the a element, or doing a POST request with page reload - * when form is submitted). Use it inside listener functions. - */ - static preventDefault(e: Event): DomEvent; - - /** - * Does stopPropagation and preventDefault at the same time. - */ - static stop(e: Event): DomEvent; - - /** - * Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' - * and 'touchstart' events. - */ - static disableClickPropagation(el: HTMLElement): DomEvent; - - /** - * Gets normalized mouse position from a DOM event relative to the container - * or to the whole page if not specified. - */ - static getMousePosition(e: Event, container?: HTMLElement): Point; - - /** - * Gets normalized wheel delta from a mousewheel DOM event. - */ - static getWheelDelta(e: Event): number; - - } - - export class DomUtil { - /** - * Returns an element with the given id if a string was passed, or just returns - * the element if it was passed directly. - */ - static get(id: string): HTMLElement; - - /** - * Returns the value for a certain style attribute on an element, including - * computed values or values set through CSS. - */ - static getStyle(el: HTMLElement, style: string): string; - - /** - * Returns the offset to the viewport for the requested element. - */ - static getViewportOffset(el: HTMLElement): Point; - - /** - * Creates an element with tagName, sets the className, and optionally appends - * it to container element. - */ - static create(tagName: string, className: string, container?: HTMLElement): HTMLElement; - - /** - * Makes sure text cannot be selected, for example during dragging. - */ - static disableTextSelection(): void; - - /** - * Makes text selection possible again. - */ - static enableTextSelection(): void; - - /** - * Returns true if the element class attribute contains name. - */ - static hasClass(el: HTMLElement, name: string): boolean; - - /** - * Adds name to the element's class attribute. - */ - static addClass(el: HTMLElement, name: string): void; - - /** - * Removes name from the element's class attribute. - */ - static removeClass(el: HTMLElement, name: string): void; - - /** - * Set the opacity of an element (including old IE support). Value must be from - * 0 to 1. - */ - static setOpacity(el: HTMLElement, value: number): void; - - /** - * Goes through the array of style names and returns the first name that is a valid - * style name for an element. If no such name is found, it returns false. Useful - * for vendor-prefixed styles like transform. - */ - static testProp(props: String[]): string; - - /** - * Returns a CSS transform string to move an element by the offset provided in - * the given point. Uses 3D translate on WebKit for hardware-accelerated transforms - * and 2D on other browsers. - */ - static getTranslateString(point: Point): string; - - /** - * Returns a CSS transform string to scale an element (with the given scale origin). - */ - static getScaleString(scale: number, origin: Point): string; - - /** - * Sets the position of an element to coordinates specified by point, using - * CSS translate or top/left positioning depending on the browser (used by - * Leaflet internally to position its layers). Forces top/left positioning - * if disable3D is true. - */ - static setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void; - - /** - * Returns the coordinates of an element previously positioned with setPosition. - */ - static getPosition(el: HTMLElement): Point; - - /** - * Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). - */ - static TRANSITION: string; - - /** - * Vendor-prefixed transform style name. - */ - static TRANSFORM: string; - - } - - export class PosAnimation implements IEventPowered { - /** - * Creates a PosAnimation object. - */ - constructor(); - - /** - * Run an animation of a given element to a new position, optionally setting - * duration in seconds (0.25 by default) and easing linearity factor (3rd argument - * of the cubic bezier curve, 0.5 by default) - */ - run(element: HTMLElement, newPos: Point, duration?: number, easeLinearity?: number): PosAnimation; + setContent(el: HTMLElement): Popup; //////////// - //// IEventPowered members //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; - hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; - } - - export class Draggable implements IEventPowered { - /** - * Creates a Draggable object for moving the given element when you start dragging - * the dragHandle element (equals the element itself by default). - */ - constructor(element: HTMLElement, dragHandle?: HTMLElement); - - /** - * Enables the dragging ability. - */ - enable(): void; - - /** - * Disables the dragging ability. - */ - disable(): void; - - //////////// - //// IEventPowered members - //////////// - - addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - addEventListener(eventMap: any, context?: any): IEventPowered; - removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - removeEventListener(eventMap: any, context?: any): IEventPowered; - hasEventListeners(type: string): boolean; - fireEvent(type: string, data?: any): IEventPowered; - on(type: string, fn: (e: LeafletEvent) => void, context?: any): IEventPowered; - on(eventMap: any, context?: any): IEventPowered; - off(type: string, fn?: (e: LeafletEvent) => void, context?: any): IEventPowered; - off(eventMap: any, context?: any): IEventPowered; - fire(type: string, data?: any): IEventPowered; - } - - export interface IHandler { - /** - * Enables the handler. - */ - enable(): void; - - /** - * Disables the handler. - */ - disable(): void; - - /** - * Returns true if the handler is enabled. - */ - enabled(): boolean; - - } - - export interface ILayer { /** * Should contain code that creates DOM elements for the overlay, adds them * to map panes where they should belong and puts listeners on relevant map events. * Called on map.addLayer(layer). */ onAdd(map: Map): void; - + /** * Should contain all clean up code that removes the overlay's elements from * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). */ onRemove(map: Map): void; - } +} + +declare module L { - export interface IControl { - /** - * Should contain code that creates all the neccessary DOM elements for the - * control, adds listeners on relevant map events, and returns the element - * containing the control. Called on map.addControl(control) or control.addTo(map). - */ - onAdd(map: Map): HTMLElement; + export interface PopupOptions { /** - * Optional, should contain all clean up code (e.g. removes control's event - * listeners). Called on map.removeControl(control) or control.removeFrom(map). - * The control's DOM container is removed automatically. + * Max width of the popup. + * + * Default value: 300. */ - onRemove(map: Map): void; + maxWidth?: number; + + /** + * Min width of the popup. + * + * Default value: 50. + */ + minWidth?: number; + + /** + * If set, creates a scrollable container of the given height inside a popup + * if its content exceeds it. + */ + maxHeight?: number; + + /** + * Set it to false if you don't want the map to do panning animation to fit the opened + * popup. + * + * Default value: true. + */ + autoPan?: boolean; + + /** + * Controls the presense of a close button in the popup. + * + * Default value: true. + */ + closeButton?: boolean; + + /** + * The offset of the popup position. Useful to control the anchor of the popup + * when opening it on some overlays. + * + * Default value: new Point(0, 6). + */ + offset?: Point; + + /** + * The margin between the popup and the edges of the map view after autopanning + * was performed. + * + * Default value: new Point(5, 5). + */ + autoPanPadding?: Point; + + /** + * Whether to animate the popup on zoom. Disable it if you have problems with + * Flash content inside popups. + * + * Default value: true. + */ + zoomAnimation?: boolean; + /** + * Set it to false if you want to override the default behavior of the popup + * closing when user clicks the map (set globally by the Map closePopupOnClick + * option). + */ + closeOnClick?: boolean; } +} + +declare module L { + + export class PosAnimation extends Class implements IEventPowered { + + /** + * Creates a PosAnimation object. + */ + constructor(); + + /** + * Run an animation of a given element to a new position, optionally setting + * duration in seconds (0.25 by default) and easing linearity factor (3rd argument + * of the cubic bezier curve, 0.5 by default) + */ + run(element: HTMLElement, newPos: Point, duration?: number, easeLinearity?: number): PosAnimation; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): PosAnimation; + hasEventListeners(type: string): boolean; + fireEvent(type: string, data?: any): PosAnimation; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): PosAnimation; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): PosAnimation; + fire(type: string, data?: any): PosAnimation; + addEventListener(eventMap: any, context?: any): PosAnimation; + removeEventListener(eventMap?: any, context?: any): PosAnimation; + clearAllEventListeners(): PosAnimation + on(eventMap: any, context?: any): PosAnimation; + off(eventMap?: any, context?: any): PosAnimation; + } +} + +declare module L { export class Projection { + /** * Spherical Mercator projection — the most common projection for online maps, * used by almost all free and commercial tile providers. Assumes that Earth * is a sphere. Used by the EPSG:3857 CRS. */ static SphericalMercator: IProjection; - + /** * Elliptical Mercator projection — more complex than Spherical Mercator. * Takes into account that Earth is a geoid, not a perfect sphere. Used by the * EPSG:3395 CRS. */ static Mercator: IProjection; - + /** * Equirectangular, or Plate Carree projection — the most simple projection, * mostly used by GIS enthusiasts. Directly maps x as longitude, and y as latitude. @@ -2848,108 +3468,539 @@ declare module L { * CRS. */ static LonLat: IProjection; - } - - export interface IProjection { - /** - * Projects geographical coordinates into a 2D point. - */ - project(latlng: LatLng): Point; - - /** - * The inverse of project. Projects a 2D point into geographical location. - */ - unproject(point: Point): LatLng; - - } - - export class CRS { - /** - * The most common CRS for online maps, used by almost all free and commercial - * tile providers. Uses Spherical Mercator projection. Set in by default in - * Map's crs option. - */ - static EPSG3857: ICRS; - - /** - * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. - */ - static EPSG4326: ICRS; - - /** - * Rarely used by some commercial tile providers. Uses Elliptical Mercator - * projection. - */ - static EPSG3395: ICRS; - - /** - * A simple CRS that maps longitude and latitude into x and y directly. May be - * used for maps of flat surfaces (e.g. game maps). Note that the y axis should - * still be inverted (going from bottom to top). - */ - static Simple: ICRS; - - } - - export interface ICRS { - /** - * Projection that this CRS uses. - */ - projection: IProjection; - - /** - * Transformation that this CRS uses to turn projected coordinates into screen - * coordinates for a particular tile service. - */ - transformation: Transformation; - - /** - * Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857'). - */ - code: string; - - /** - * Projects geographical coordinates on a given zoom into pixel coordinates. - */ - latLngToPoint(latlng: LatLng, zoom: number): Point; - - /** - * The inverse of latLngToPoint. Projects pixel coordinates on a given zoom - * into geographical coordinates. - */ - pointToLatLng(point: Point, zoom: number): LatLng; - - /** - * Projects geographical coordinates into coordinates in units accepted - * for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). - */ - project(latlng: LatLng): Point; - - /** - * Returns the scale used when transforming projected coordinates into pixel - * coordinates for a particular zoom. For example, it returns 256 * 2^zoom for - * Mercator-based CRS. - */ - scale(zoom: number): number; - - } - - /** - * This method restores the L global variale to the original value it had - * before Leaflet inclusion, and returns the real Leaflet namespace. - */ - export var noConflict: () => typeof L; - - /** - * A constant that represents the Leaflet version in use. - */ - export var version: string; } + +declare module L { + /** + * Instantiates a rectangle object with the given geographical bounds and + * optionally an options object. + */ + function rectangle(bounds: LatLngBounds, options?: PathOptions): Rectangle; + + export class Rectangle extends Polygon { + + /** + * Instantiates a rectangle object with the given geographical bounds and + * optionally an options object. + */ + constructor(bounds: LatLngBounds, options?: PathOptions); + + /** + * Redraws the rectangle with the passed bounds. + */ + setBounds(bounds: LatLngBounds): Rectangle; + } +} + + +declare module L { + + export interface ScaleOptions { + + /** + * The position of the control (one of the map corners). See control positions. + * Default value: 'bottomleft'. + */ + position?: string; + + /** + * Maximum width of the control in pixels. The width is set dynamically to show + * round values (e.g. 100, 200, 500). + * Default value: 100. + */ + maxWidth?: number; + + /** + * Whether to show the metric scale line (m/km). + * Default value: true. + */ + metric?: boolean; + + /** + * Whether to show the imperial scale line (mi/ft). + * Default value: true. + */ + imperial?: boolean; + + /** + * If true, the control is updated on moveend, otherwise it's always up-to-date + * (updated on move). + * Default value: false. + */ + updateWhenIdle?: boolean; + } +} + +declare module L { + + export class TileLayer implements ILayer, IEventPowered { + + /** + * Instantiates a tile layer object given a URL template and optionally an options + * object. + */ + constructor(urlTemplate: string, options?: TileLayerOptions); + + /** + * Adds the layer to the map. + */ + addTo(map: Map): TileLayer; + + /** + * Brings the tile layer to the top of all tile layers. + */ + bringToFront(): TileLayer; + + /** + * Brings the tile layer to the bottom of all tile layers. + */ + bringToBack(): TileLayer; + + /** + * Changes the opacity of the tile layer. + */ + setOpacity(opacity: number): TileLayer; + + /** + * Sets the zIndex of the tile layer. + */ + setZIndex(zIndex: number): TileLayer; + + /** + * Causes the layer to clear all the tiles and request them again. + */ + redraw(): TileLayer; + + /** + * Updates the layer's URL template and redraws it. + */ + setUrl(urlTemplate: string): TileLayer; + + /** + * Returns the HTML element that contains the tiles for this layer. + */ + getContainer(): HTMLElement; + + //////////// + //////////// + /** + * Should contain code that creates DOM elements for the overlay, adds them + * to map panes where they should belong and puts listeners on relevant map events. + * Called on map.addLayer(layer). + */ + onAdd(map: Map): void; + + /** + * Should contain all clean up code that removes the overlay's elements from + * the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer). + */ + onRemove(map: Map): void; + + //////////////// + //////////////// + addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer; + addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer; + removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): TileLayer; + hasEventListeners(type: string): boolean; + fireEvent(type: string, data?: any): TileLayer; + on(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer; + once(type: string, fn: (e: LeafletEvent) => void, context?: any): TileLayer; + off(type: string, fn?: (e: LeafletEvent) => void, context?: any): TileLayer; + fire(type: string, data?: any): TileLayer; + addEventListener(eventMap: any, context?: any): TileLayer; + removeEventListener(eventMap?: any, context?: any): TileLayer; + clearAllEventListeners(): TileLayer + on(eventMap: any, context?: any): TileLayer; + off(eventMap?: any, context?: any): TileLayer; + } + + module TileLayer { + + export class WMS { + + /** + * Instantiates a WMS tile layer object given a base URL of the WMS service and + * a WMS parameters/options object. + */ + constructor(baseUrl: string, options: WMSOptions); + + /** + * Merges an object with the new parameters and re-requests tiles on the current + * screen (unless noRedraw was set to true). + */ + setParams(params: WMS, noRedraw?: boolean): WMS; + } + + export class Canvas { + + /** + * Instantiates a Canvas tile layer object given an options object (optionally). + */ + constructor(options?: TileLayerOptions); + + /** + * You need to define this method after creating the instance to draw tiles; + * canvas is the actual canvas tile on which you can draw, tilePoint represents + * the tile numbers, and zoom is the current zoom. + */ + drawTile(canvas: HTMLCanvasElement, tilePoint: Point, zoom: number): Canvas; + + /** + * Calling redraw will cause the drawTile method to be called for all tiles. + * May be used for updating dynamic content drawn on the Canvas + */ + redraw(): Canvas; + } + } + + export class tileLayer { + + /** + * Instantiates a tile layer object given a URL template and optionally an options + * object. + */ + function (urlTemplate: string, options?: TileLayerOptions): TileLayer; + + /** + * Instantiates a WMS tile layer object given a base URL of the WMS service and + * a WMS parameters/options object. + */ + static wms(baseUrl: string, options: WMSOptions): L.TileLayer.WMS; + + /** + * Instantiates a Canvas tile layer object given an options object (optionally). + */ + static canvas(options?: TileLayerOptions): L.TileLayer.Canvas; + } +} + +declare module L { + + export interface TileLayerOptions { + + /** + * Minimum zoom number. + * + * Default value: 0. + */ + minZoom?: number; + + /** + * Maximum zoom number. + * + * Default value: 18. + */ + maxZoom?: number; + + /** + * Tile size (width and height in pixels, assuming tiles are square). + * + * Default value: 256. + */ + tileSize?: number; + + /** + * Subdomains of the tile service. Can be passed in the form of one string (where + * each letter is a subdomain name) or an array of strings. + * + * Default value: 'abc'. + */ + subdomains?: string[]; + + /** + * URL to the tile image to show in place of the tile that failed to load. + * + * Default value: ''. + */ + errorTileUrl?: string; + + /** + * e.g. "© CloudMade" — the string used by the attribution control, describes + * the layer data. + * + * Default value: ''. + */ + attribution?: string; + + /** + * If true, inverses Y axis numbering for tiles (turn this on for TMS services). + * + * Default value: false. + */ + tms?: boolean; + + /** + * If set to true, the tile coordinates won't be wrapped by world width (-180 + * to 180 longitude) or clamped to lie within world height (-90 to 90). Use this + * if you use Leaflet for maps that don't reflect the real world (e.g. game, indoor + * or photo maps). + * + * Default value: false. + */ + continuousWorld?: boolean; + + /** + * If set to true, the tiles just won't load outside the world width (-180 to 180 + * longitude) instead of repeating. + * + * Default value: false. + */ + noWrap?: boolean; + + /** + * The zoom number used in tile URLs will be offset with this value. + * + * Default value: 0. + */ + zoomOffset?: number; + + /** + * If set to true, the zoom number used in tile URLs will be reversed (maxZoom + * - zoom instead of zoom) + * + * Default value: false. + */ + zoomReverse?: boolean; + + /** + * The opacity of the tile layer. + * + * Default value: 1.0. + */ + opacity?: number; + + /** + * The explicit zIndex of the tile layer. Not set by default. + */ + zIndex?: number; + + /** + * If true, all the tiles that are not visible after panning are removed (for + * better performance). true by default on mobile WebKit, otherwise false. + */ + unloadInvisibleTiles?: boolean; + + /** + * If false, new tiles are loaded during panning, otherwise only after it (for + * better performance). true by default on mobile WebKit, otherwise false. + */ + updateWhenIdle?: boolean; + + /** + * If true and user is on a retina display, it will request four tiles of half the + * specified size and a bigger zoom level in place of one to utilize the high resolution. + * + * Default value: false. + */ + detectRetina?: boolean; + + /** + * If true, all the tiles that are not visible after panning are placed in a reuse + * queue from which they will be fetched when new tiles become visible (as opposed + * to dynamically creating new ones). This will in theory keep memory usage + * low and eliminate the need for reserving new memory whenever a new tile is + * needed. + * + * Default value: false. + */ + reuseTiles?: boolean; + } +} + +declare module L { + + export class Transformation { + + /** + * Creates a transformation object with the given coefficients. + */ + constructor(a: number, b: number, c: number, d: number); + + /** + * Returns a transformed point, optionally multiplied by the given scale. + * Only accepts real L.Point instances, not arrays. + */ + transform(point: Point, scale?: number): Point; + + /** + * Returns the reverse transformation of the given point, optionally divided + * by the given scale. Only accepts real L.Point instances, not arrays. + */ + untransform(point: Point, scale?: number): Point; + } +} + +declare module L { + + export class Util { + + /** + * Merges the properties of the src object (or multiple objects) into dest object + * and returns the latter. Has an L.extend shortcut. + */ + static extend(dest: any, ...sources: any[]): any; + + /** + * Returns a function which executes function fn with the given scope obj (so + * that this keyword refers to obj inside the function code). Has an L.bind shortcut. + */ + static bind(fn: T, obj: any): T; + + /** + * Applies a unique key to the object and returns that key. Has an L.stamp shortcut. + */ + static stamp(obj: any): string; + + /** + * Returns a wrapper around the function fn that makes sure it's called not more + * often than a certain time interval time, but as fast as possible otherwise + * (for example, it is used for checking and requesting new tiles while dragging + * the map), optionally passing the scope (context) in which the function will + * be called. + */ + static limitExecByInterval(fn: T, time: number, context?: any): T; + + /** + * Returns a function which always returns false. + */ + static falseFn(): () => boolean; + + /** + * Returns the number num rounded to digits decimals. + */ + static formatNum(num: number, digits: number): number; + + /** + * Trims and splits the string on whitespace and returns the array of parts. + */ + static splitWords(str: string): string[]; + + /** + * Merges the given properties to the options of the obj object, returning the + * resulting options. See Class options. Has an L.setOptions shortcut. + */ + static setOptions(obj: any, options: any): any; + + /** + * Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} + * translates to '?a=foo&b=bar'. + */ + static getParamString(obj: any): string; + + /** + * Simple templating facility, creates a string by applying the values of the + * data object of a form {a: 'foo', b: 'bar', …} to a template string of the form + * 'Hello {a}, {b}' — in this example you will get 'Hello foo, bar'. + */ + static template(str: string, data: any): string; + + /** + * Returns true if the given object is an array. + */ + static isArray(obj: any): boolean; + + /** + * Trims the whitespace from both ends of the string and returns the result. + */ + static trim(str: string): boolean; + + /** + * Data URI string containing a base64-encoded empty GIF image. Used as a hack + * to free memory from unused images on WebKit-powered mobile devices (by setting + * image src to this string). + */ + static emptyImageUrl: string; + } +} + + +declare module L { + + export interface WMSOptions { + + /** + * (required) Comma-separated list of WMS layers to show. + * + * Default value: ''. + */ + layers?: string; + + /** + * Comma-separated list of WMS styles. + * + * Default value: 'image/jpeg'. + */ + styles?: string; + + /** + * WMS image format (use 'image/png' for layers with transparency). + * + * Default value: false. + */ + format?: string; + + /** + * If true, the WMS service will return images with transparency. + * + * Default value: '1.1.1'. + */ + transparent?: boolean; + + /** + * Version of the WMS service to use. + */ + version?: string; + + } +} + + +declare module L { + + export interface ZoomOptions { + + /** + * The position of the control (one of the map corners). See control positions. + * + * Default value: 'topright'. + */ + position?: string; + } +} + +declare module L { + + export interface ZoomPanOptions { + + /** + * If true, the map view will be completely reset (without any animations). + * + * Default value: false. + */ + reset?: boolean; + + /** + * Sets the options for the panning (without the zoom change) if it occurs. + */ + pan?: PanOptions; + + /** + * Sets the options for the zoom change if it occurs. + */ + zoom?: ZoomOptions; + + /** + * An equivalent of passing animate to both zoom and pan options (see below). + */ + animate?: boolean; + } +} + /** - * Forces Leaflet to use the Canvas back-end (if available) for vector layers - * instead of SVG. This can increase performance considerably in some cases + * Forces Leaflet to use the Canvas back-end (if available) for vector layers + * instead of SVG. This can increase performance considerably in some cases * (e.g. many thousands of circle markers on the map). */ declare var L_PREFER_CANVAS: boolean; @@ -2960,7 +4011,8 @@ declare var L_PREFER_CANVAS: boolean; declare var L_NO_TOUCH: boolean; /** - * Forces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning + * Forces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning * (which may cause glitches in some rare environments) even if they're supported. */ declare var L_DISABLE_3D: boolean; + diff --git a/less/less-tests.ts.tscparams b/less/less-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/less/less-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/less/less.d.ts.tscparams b/less/less.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/less/less.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/levelup/levelup-tests.ts.tscparams b/levelup/levelup-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/levelup/levelup-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/levelup/levelup.d.ts.tscparams b/levelup/levelup.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/levelup/levelup.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/libxmljs/libxmljs-tests.ts.tscparams b/libxmljs/libxmljs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/libxmljs/libxmljs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/libxmljs/libxmljs.d.ts.tscparams b/libxmljs/libxmljs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/libxmljs/libxmljs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/linq/linq-tests.ts.tscparams b/linq/linq-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/linq/linq-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/linq/linq.3.0.3-Beta4.d.ts.tscparams b/linq/linq.3.0.3-Beta4.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/linq/linq.3.0.3-Beta4.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/linq/linq.d.ts.tscparams b/linq/linq.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/linq/linq.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/linq/linq.jquery.d.ts.tscparams b/linq/linq.jquery.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/linq/linq.jquery.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mCustomScrollbar/mCustomScrollbar-tests.ts.tscparams b/mCustomScrollbar/mCustomScrollbar-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/mCustomScrollbar/mCustomScrollbar-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mapsjs/mapsjs.d.ts b/mapsjs/mapsjs.d.ts new file mode 100644 index 000000000..c43fd5d56 --- /dev/null +++ b/mapsjs/mapsjs.d.ts @@ -0,0 +1,2639 @@ +/** + * Mapsjs 9.6.0 Copyright (c) 2013 ISC. All Rights Reserved. +*/ + +declare module 'mapsjs' { + + /** + * Clusters a set of points. + * @param {object} options An options object which specifies the clustering algorithm. + * @returns {object} An array of clustered points. + */ + export function clusterPoints(options: { + data: {}[]; + pointKey: string; + valueFunction?: (row: any) => number; + radiusFunction: (row: any) => number; + aggregateFunction?: (srcRow: any, cmpRow: any, aggRow: any) => void; + mapUnitsPerPixel: number; + marginPixels?: number; + }): {}[]; + + /** + * An immutable envelope + * @class envelope + */ + export class envelope { + constructor(minX: number, minY: number, maxX: number, maxY: number); + + /** + * Gets the minimum x coordinate of the envelope. + * @returns {number} The minimum x coordinate. + */ + getMinX(): number; + + /** + * Gets the minimum y coordinate of the envelope + * @returns {number} The minimum y coordinate. + */ + getMinY(): number; + + /** + * Gets the maximum x coordinate of the envelope + * @returns {number} The maximum x coordinate. + */ + getMaxX(): number; + + /** + * Gets the maximum y coordinate of the envelope + * @returns {number} The maximum y coordinate. + */ + getMaxY(): number; + + /** + * Creates a new envelope from this as deep copy. + * @returns {envelope} The new cloned envelope. + */ + clone(): envelope; + + /** + * Creates a new envelope from this one plus x and y margins. + * @param {number} marginX The x margin. + * @param {number} marginY The y margin. + * @returns {envelope} A new envelope. + */ + createFromMargins(marginX: number, marginY: number): envelope; + + /** + * Create a new envelope from this one plus a bleed ratio. + * @param {number} bleed The bleed ratio. + * @returns {envelope} A new envelope. + */ + createFromBleed(bleed: number): envelope; + + /** + * Gets the center point of the envelope. + * @returns {point} Center as a point. + */ + getCenter(): point; + + /** + * Gets the width of the envelope. + * @returns {number} Width of the envelope. + */ + getWidth(): number; + + /** + * Gets height of the envelope. + * @returns {number} Height of the envelope. + */ + getHeight(): number; + + /** + * Gets area of the envelope. + * @return {number} Area of the envelope. + */ + getArea(): number; + + /** + * Returns the minimum and maximum coordinates of this envelope as an envObject. + * @returns {envObject} Representaton of this envelope as an envObject. + */ + toObject(): envObject; + + /** + * Gets upper left coordinate of this envelope. + * @returns {point} A new point. + */ + getUL(): point; + + /** + * Gets upper right of this envelope. + * @returns {point} A new point. + */ + getUR(): point; + + /** + * Gets lower left of this envelope. + * @returns {point} A new point. + */ + getLL(): point; + + /** + * Gets lower right of this envelope. + * @returns {point} A new point. + */ + getLR(): point; + + /** + * Gets the aspect of the envelope. + * @returns {number} Width-to-height ratio. + */ + getAspect(): number; + + /** + * Equality comparer between this and another envelope. + * @param {envelope} env Envelope to compare. + * @return {boolean} Result of equality comparison. + */ + equals(env: envelope): boolean; + + /** + * Method for casting this envelope as a string. + * @returns {string} String of the form 'minX,minY,maxX,maxY'. + */ + toString(): string; + + /** + * Create a closed geometry from this envelope. + * @returns {geometry} A new closed path geometry. + */ + toGeometry(): geometry; + + /** + * Tests whether the given point is contained within this envelope. + * @param {point} pt Point to test. + * @returns {boolean} Result of containment test. + */ + contains(pt: point): boolean; + } + + /** + * Exposes static functions that act on or return envelopes. + * @module envelope + */ + export module envelope { + + /** + * Creates a new envelope from MapDotNet XML. + * @param {string} xml A MapDotNet XML string of the envelope. + * @returns {envelope} A new envelope + */ + export function createFromMdnXml(xml: string): envelope; + + /** + * Creates new envelope from two corner points. + * @param {point} pt1 Corner point + * @param {point} pt2 Opposite corner point + * @returns {envelope} A new envelope + */ + export function createFromPoints(pt1: point, pt2: point): envelope; + + /** + * Creates a new envelope from the x and y coordinates of the center + * point and x and y margins from the center point. + * @param {number} centerPtX The center x coordinate. + * @param {number} centerPtY The center y coordinate. + * @param {number} marginX The margin from center x coordinate. + * @param {number} marginY The margin from center y coordinate. + * @returns {envelope} A new envelope + */ + export function createFromCenterAndMargins(centerPtX: number, centerPtY: number, marginX: number, marginY: number): envelope; + + /** + * Tests whether two given envelopes intersect. + * @param {envelope} env1 First envelope to test. + * @param {envelope} env2 Second envelope to test. + * @returns {boolean} Result of the intersection test. + */ + export function intersects(env1: envelope, env2: envelope): boolean; + + /** + * Creates a new envelope from the union of two given envelopes. + * @param {envelope} env1 The first enevelope to unite. + * @param {envelope} env2 The second envelope to unite. + * @returns {envelope} A new envelope. + */ + export function union(env1: envelope, env2: envelope): envelope; + } + + /** + * A general geometry which can represent a point, line, polygon, + * mulitpoint, multilinestring + * @class geometry + */ + export class geometry { + constructor(isPath?: boolean, isClosed?: boolean); + + /** + * Creates a new polygon or polyline form the geometry according to + * whether the geometry is closed. + * @returns {any} A new polyline or polygon geometry. + */ + factoryPoly(): any; + + /** + * Creates a deep copy of this geometry. + * @returns {geometry} The new cloned geometry. + */ + clone(): geometry; + + /** + * Iterates every vertex in the geometry and passes to the supplied + * callback. Return true from in the callback will break the iteration. + * @param {function} action Callback with the signature action(setIdx, idx, x, y, set). + */ + foreachVertex(action: (setIdx: number, idx: number, x: number, y: number, s: number[]) => void): void; + + /** + * Returns the geometry's bounding box as an envelope. + * @returns {envelope} The bounding box of the geometry as an envelope. + */ + getBounds(): envelope; + + /** + * Checks whether or not this geometry is closed. + * @returns {boolean} Result of the path check. + */ + getIsPath(): boolean; + + /** + * Checks whether or not this geometry is closed. + * @returns {boolean} Result of the closed check. + */ + getIsClosed(): boolean; + + /** + * Gets the number of sets in this geometry. + * @returns {number} Number of sets. + */ + getSetCount(): number; + + /** + * Gets a set from this geometry's set collection by index, or, if no + * index is provided, gets the last set. Note: for polygons, first set + * is primary ring and subsequent ones are holes. + * @param {number} [idx] Index of the set to return. + * @returns {number[]} A set as an array of points in the form [xn,yn]. + */ + getSet(idx: number): number[]; + + /** + * Adds a new set to this geometry's collection of sets. + * @param {number[]} s Set to add as an array of points in the form [xn,yn]. + */ + pushSet(s: number[]): void; + + /** + * Gets the last set in the geometry's set collection and removes it + * from the collection. + * @returns {number} Set removed as an array of points in the form [xn,yn]. + */ + popSet(): number[]; + + /** + * Creates SVG path data from this geometry if it is a path. + * @returns {string} String of the SVG path or null the geometry is not a path. + */ + toSvgPathData(): string; + + /** + * Adds point to the last set in geometry's set collection. If the + * geometry is empty, a new set is added to the geometry first. + * @param {point} pt The point to add. + * @returns {object} Object of the form {setIdx, idx} where setIdx is + * the 0-based index of the set the point was added to and idx is the + * 0-based index of the point in its set. + */ + addPointToLastSet(pt: point): { setIdx: number; idx: number; }; + + /** + * Tests the validity of this geometry. An open path geometry is valid + * if it has at least one set with at least two points. A closed + * geometry is valid if it has at least one set with at least three + * points. A point (non-path) geometry is always valid. + * @returns {geometry} valid geometry is true, otherwise false. + */ + isValid(): boolean; + + /** + * Creates a wkt string from this geometry. + * @returns {string} A string of well known text. + */ + toString(): string; + toWkt(): string; + + /** + * Finds the point in this geometry nearest to the given point. + * @param {point} pt Reference point. + * @returns {object} An object of the form {setIdx, ptIdx, pt, distance} + * where setIdx is the index of the set the point is in, ptIdx is the + * index of the point in the set, pt is the point object, and distance + * is the distance of the point to the reference point in map units. + */ + findNearestVertex(pt: point): { setIdx: number; ptIdx: number; pt: point; distance: number; }; + + /** + * Finds point along boundary of geometry nearest to the given point + * @param {point} pt Reference point. + * @param {boolean} [close] Flag to indicate whether this geometry + * should be treated as a closed geometry. + * @returns {object} An object of the form {setIdx, ptIdx, pt, distance} + * where setIdx is the index of the set the point is in, ptIdx is the + * index of the point in the set, pt is the point object, and distance + * is the distance of the point to the reference point in map units. + */ + findNearestSegment(pt: point, close?: boolean): { setIdx: number; ptIdx: number; pt: point; distance: number; }; + + /** + * Finds coordinates in map units of the midpoint of this geometry. If + * this geometry is an open path, the midpoint is the midpoint of the + * path. If this geometry is a closed path, the midpoint is the centroid + * of the polygon. If a set index is not provided, finds the labeling + * point for the last set in this geometry's set collection. + * @param {number} [idx] Index of set for which to find the labeling point. + * @returns {point} Midpoint of this geometry. + */ + getLabelingPoint(idx?: number): point; + + /** + * Tests whether this geometry contains a given point/ + * @param {point} pt The reference point. + * @returns {boolean} Result of the containment test. + */ + contains(pt: point): boolean; + } + + /** + * Exposes static functions that act on or return geometries, including + * constructors for specific geometries such as polygon and polyline. + * @module geometry + */ + export module geometry { + + /** + * A polyline object which is an open path geometry with one or more paths. + * @class polyline + */ + class polyline extends geometry { + constructor(geom: geometry); + + /** + * Gets the underlying geometry of the polyline. + * @returns {geometry} The polyline's underlying geometry object. + */ + getGeometry(): geometry; + + /** + * Creates a new polyline object from a deep copy of the underlying geometry. + * @returns {polyline} Thew new cloned polyline. + */ + clone(): polyline; + + /** + * Gets number of lines in this polyline. + * @returns {number} Number of lines. + */ + getLineCount(): number; + + /** + * Gets a line from this polyline's liune collection by index, or, + * if no index is provided, gets the last line. + * @param {number} [idx] Index of the line to return. + * @returns {number[]} A line as an array of points in the form [xn,yn]. + */ + getLine(idx: number): number[]; + + /** + * Adds a new line to this polyline's line collection. + * @param {number[]} s Line to add as an array of points in the form [xn,yn]. + */ + pushLine(s: number[]): void; + + /** + * Gets the last line in the polyline's set collection and removes it + * from the collection. + * @returns {number} Line removed as an array of points in the form [xn,yn]. + */ + popLine(): number[]; + + /** + * Calculates distance of a line in a polyline by index according + * to projected map cooordinates. If no index is provided, uses + * the last line in the polyline's set collection. + * @param {number} [idx] Index of the line for which to compute the distance. + * @returns {number} Length in projected units of the distance of the line. + */ + getProjectedDistance(idx: number): number; + + /** + * Calculates distance of a line in a polyline by index according + * to actual distance. If no index is provided, uses the last line + * in the polyline's set collection. + * @param {number} [idx] Index of the line for which to compute the distance. + * @returns {number} Distance in meters of the line. + */ + getActualDistance(idx: number): number; + + /** + * Determines whether this polyline intersects a given geometry. + * @param {geometry} geom Geometry to test against. + * @returns {boolean} Result of the intersection test. + */ + intersects(geom: geometry): boolean; + } + + /** + * A polyline object which is a closed path geometry with one or more paths. + * @class polygon + */ + class polygon extends geometry { + constructor(geom: geometry); + + /** + * Gets the underlying geometry of the polygon. + * @returns {geometry} The polygon's underlying geometry object. + */ + getGeometry(): geometry; + + /** + * Creates a new polygon object from a deep copy of the underlying geometry. + * @returns {polygon} Thew new cloned polygon. + */ + clone(): polygon; + + /** + * Gets number of rings in this polygon. + * @returns {number} Number of rings. + */ + getRingCount(): number; + + /** + * Gets a ring from this polygon's set collection by index, or, + * if no index is provided, gets the last ring. + * @param {number} [idx] Index of the ring to return. + * @returns {number[]} A ring as an array of points in the form [xn,yn]. + */ + getRing(idx: number): number[]; + + /** + * Adds a new ring to this polygon's ring collection. + * @param {number[]} s Ring to add as an array of points in the form [xn,yn]. + */ + pushRing(s: number[]): void; + + /** + * Gets the last ring in the polygon's ring collection and removes it + * from the collection. + * @returns {number} Ring removed as an array of points in the form [xn,yn]. + */ + popRing(): number[]; + + /** + * Calculates area of a ring in a polygon by index according + * to projected map cooordinates. If no index is provided, uses + * the last ring in the polygon's ring collection. + * @param {number} [idx] Index of the ring for which to compute the area. + * @returns {number} Area in square projected units of the ring. + */ + getProjectedArea(idx: number): number; + + /** + * Calculates perimeter of a ring in a polygon by index according + * to projected map cooordinates. If no index is provided, uses + * the last ring in the polygon's ring collection. + * @param {number} [idx] Index of the ring for which to compute the perimeter. + * @returns {number} Length in projected units of the distance of the ring. + */ + getProjectedPerimeter(idx: number): number; + + /** + * Calculates area of a ring in a polygon by index according + * to the actual area. If no index is provided, uses the last ring + * in the polygon's ring collection. + * @param {number} [idx] Index of the ring for which to compute the area. + * @returns {number} Area in square meters of the ring. + */ + getActualArea(idx: number): number; + + /** + * Calculates perimeter of a ring in a polygon by index according + * to actual distance. If no index is provided, uses the last ring + * in the polygon's ring collection. + * @param {number} [idx] Index of the ring for which to compute the perimeter. + * @returns {number} Length in meters of the perimeter of the ring. + */ + getActualPerimeter(idx: number): number; + + /** + * Determines whether this polygon intersects a given geometry. + * @param {geometry} geom Geometry to test against. + * @returns {boolean} Result of the intersection test. + */ + intersects(geom: geometry): boolean; + + /** + * Determines whether this polyline overlaps a given geometry. + * @param {geometry} geom Geometry to test against. + * @returns {boolean} Result of the intersection test. + */ + overlaps(poly: polygon): boolean; + + /** + * Convert this polygon into an array of OGC compliant polygons where + * the first set is a ring and all subsequent contained sets are holes. + * @returns {polygon[]} An array of OGC polygons. + */ + toMultiPolygon(): polygon[]; + } + } + + /** + * A style specification for geometry objects. + * @class geometryStyle + */ + export class geometryStyle { + constructor(); + + /** + * Gets path outline thickness in pixels. + * @returns {number} Thickness of path outline. + */ + getOutlineThicknessPix(): number; + + /** + * Sets path outline thickness in pixels. + * @param {number} t Desired thickness. + */ + setOutlineThicknessPix(t: number): void; + + /** + * Gets path outline color as a CSS style string. + * @returns {string} Outline color as a CSS style string. + */ + getOutlineColor(): string; + + /** + * Sets path outline color from a CSS style string. + * @param {string} c Outline color as a CSS style string. + */ + setOutlineColor(c: string): void; + + /** + * Gets path outline opacity in decimal format. + * @returns {number} Outline opacity. + */ + getOutlineOpacity(): number; + + /** + * Set path outline opacity to a decimal between 0 and 1. + * @param {number} o Outline opacity. + */ + setOutlineOpacity(o: number): void; + + /** + * Gets fill color as a CSS style string. + * @returns {string} Fill color as a CSS style string. + */ + getFillColor(): string; + + /** + * Sets fill color as a CSS style string. + * @param {string} c Fill color as a CSS style string. + */ + setFillColor(c: string): void; + + /** + * Gets fill opacity in decimal format. + * @returns {number} Fill opacity. + */ + getFillOpacity(): number; + + /** + * Sets fill opacity to a decimal between 0 and 1. + * @param {number} o Fill opacity. + */ + setFillOpacity(o: number): void; + + /** + * Gets the dash array as a string. + * @returns {string} Dash array as astring. + */ + getDashArray(): string; + + /** + * Sets dash array string from a CSS style string. Defaults to solid + * stroke if no dash array string is provided. + * @param {string} [da] Dash array as a CSS style string. + */ + setDashArray(da: string): void; + } + + /** + * Gets the mapsjs license. + * @returns {string} The license. + */ + export var license: string; + + /** + * A simple point class with x and y coordinates. + * @class point + */ + export class point { + + constructor(x: number, y: number); + + /** + * Returns the x coordinate. + * @returns {number} The x coordinate. + */ + getX(): number; + + /** + * Returns the y coordinate. + * @returns {number} The y coordinate. + */ + getY(): number; + + /** + * Returns the x and y coordinates of this point as a pointObject. + * @returns {pointObject} Representaton of this point as an pointObject. + */ + toProps(): pointObject; + + /** + * Equality comparer between this point and a given reference point. + * @param {point} pt Reference point. + * @returns {boolean} Result of the equality test. + */ + equals(pt: point): boolean; + + /** + * Creates a point from this point offset by a given x and y distance. + * @param {number} dx The x offset. + * @param {number} dy The y offset. + * @returns {point} The offset point. + */ + createOffsetBy(dx: number, dy: number): point; + + /** + * Creates new n-sided polygon around this point. + * @param {number} sides Number of polygon sides. + * @param {number} radius Distance to polygon points. + * @returns {polygon} The generated polygon. + */ + convertToPoly(side: number, radius: number): geometry.polygon; + + /** + * Gets the wkt representation of this point. + * @returns {string} The well known text for this point. + */ + toString(): string; + + /** + * Creates a deep copy of this point. + * @returns {point} The new cloned point. + */ + clone(): point; + + /** + * Returns this point's bounding box. + * @returns {envelope} The bounding box of the point as an envelope. + */ + getBounds(): envelope; + + /** + * Computes distance between this point and a given point in projected + * map units. + * @param {point} pt Point to which to compute distance. + * @returns {number} Distance from this point to the given point in + * projected map units. + */ + distanceTo(pt: point): number; + } + + /** + * Exposes static functions that act on points. + * @module point + */ + export module point { + + /** + * Computes the distance between two points in coordinate units. + * @param {number} x1 The x coordinate for the first point. + * @param {number} y1 The y coordinate for the first point. + * @param {number} x2 The x coordinate for the second point. + * @param {number} y2 The y coordinate for the second point. + * @returns {number} Distance in coordinate units. + */ + export function distance(x1: number, y1: number, x2: number, y2: number): number; + + /** + * Computes the midpoint of two points. + * @param {number} x1 The x coordinate for the first point. + * @param {number} y1 The y coordinate for the first point. + * @param {number} x2 The x coordinate for the second point. + * @param {number} y2 The y coordinate for the second point. + * @return {point} Midpoint point. + */ + export function midpoint(x1: number, y1: number, x2: number, y2: number): point; + } + + /** + * Exposes static functions related to the Spherical Mercator projection. + * @module sphericalMercator + */ + export module sphericalMercator { + + /** + * Gets the EPSG number for Spherical Mercator. + * @return {number} ESPG number. + */ + export function getEpsg(): number; + + /** + * Gets the minimum zoom level for this projection. + * @returns {number} Minimum zoom level. + */ + export function getMinZoomLevel(): number; + + /** + * Sets the minimum zoom level for this projection. Normally this is + * set to 1.0 and should not be altered. + * @param {number} minZ Desired minimum zoom level. + */ + export function setMinZoomLevel(minZ: number): void; + + /** + * Gets the maxmimum zoom level for this projection. + * @returns {number} Maximum zoom level. + */ + export function getMaxZoomLevel(): number; + + /** + * Sets the maximum zoom level for this projection. Normally this is + * set to 20.0 and should not be altered. + * @param {number} maxZ1 Desired maximum zoom level. + */ + export function setMaxZoomLevel(maxZ: number): void; + + /** + * Gets the tile height and width in pixels. + * @returns {number} The height and width of the tiles in pixels. + */ + export function getTileSizePix(): number; + + /** + * Gets the display DPI, which defaults to 96. Note: The dpi is + * recomputed on page load complete. + * @returns {number} Dots per inch on display. + */ + export function getDpi(): number; + + /** + * Set the display DPI, which defaults to 96. Note: The DPI is + * recomputed on page load complete. + * @param {number} dpi Dots per inch on display. + */ + export function setDpi(dpi: number): void; + + /** + * Return the equitorial radius in meters for this projection. + * @returns {number} Equitorial radius in meters. + */ + export function getRadius(): number; + + /** + * Returns equitorial circumference in meters for this projection + * @returns {number} Equitorial circumference in meters. + */ + export function getCircumference(): number; + + /** + * Returns half the equitorial circumference in meters for this projection + * @returns {number} Half of the equitorial circumference in meters. + */ + export function getHalfCircumference(): number; + + /** + * Get the envelope in map units for a given quadtree node, i.e. tile, + * based on the given x, y, and z quadtree coordinates. + * @param {number} x The x coordinate. + * @param {number} y The y coordinate. + * @param {number} z The z coordinate. + * @returns {envelope} Envelope of the tile in map units. + */ + export function getQuadTreeNodeToMapEnvelope(x: number, y: number, z: number): envelope; + + /** + * Gets the envelope in map units of tiles in the quadtree from an + * evelope in map units and a zoom level. + * @param {envelope} env Envelope for which to find intersecting tiles. + * @param {number} z Zoom level with which to test for intersection. + * @returns {envelope} The envelope in map units of the tiles. + */ + export function getQuadTreeNodeRangeFromEnvelope(env: envelope, z: number): envelope; + + /** + * Gets projected map units per pixel for a given zoom level. + * @param {number} zoomLevel Reference zoom level. + * @returns {number} Projection units per pixel. + */ + export function getProjectionUnitsPerPixel(zoomLevel: number): number; + + /** + * Gets the required scale transform to apply to shapes so distance + * and area computations yield actual Earth-geodesic units instead of + * projected map units. + * @param {number} mapPtY Reference latitude for the computation. + * @returns {number} Scale transform multiplier. + */ + export function getActualShapeScaleTransform(mapPtY: number): number; + + /** + * Gets actual, on-the-ground meters per pixel for a given zoom level + * and map point in map units. + * @param {point} mapPt Reference location for the computation. + * @param {number} z Reference zoom level. + * @returns {number} Meters per pixel multiplier. + */ + export function getActualUnitsPerPixel(mapPt: point, zoomLevel: number): number; + + /** + * Gets the optimal zoom level for a given envelope in map units + * based on the envelope of visible device area in pixels. + * @param {envelope} envelopeMap Envelope in map units to display. + * @param {envelope} envelopeDevice Envelope in pixels of visible area. + * @returns {number} Optimal zoom level for viewing envelopeMap. + */ + export function getBestFitZoomLevelByExtents(envelopeMap: envelope, envelopeDevice: envelope): number; + + /** + * Gets a quad-key from x, y, and z coordinates. + * @param {number} x The x coordinate. + * @param {number} y The y coordinate. + * @param {number} z The z coordinate. + * @returns {string} Quad-key string. + */ + export function getQuadKeyFromXYZ(x: number, y: number, z: number): string; + + /** + * Gets x, y, and z coordinates as an object from a given quad-key. + * @param {string} key Reference quad-key. + * @return {object} JavaScript object of the form {x,y,z}. + */ + export function getXYZFromQuadKey(key: string): { x: number; y: number; z: number; }; + + /** + * Project a point from latitude/longitude to Spherical Mercator. + * @param {point} lonLat Point object in latitude/longitude. + * @returns {point} The same point in Spherical Mercator. + */ + export function projectFromLatLon(lonLat: point): point; + + /** + * Project a point from Spherical Mercator to latitude/longitude. + * @param {point} mapPt Point object in Spherical Mercator. + * @returns {point} The same point in latitude/longitude. + */ + export function deprojectToLatLon(mapPt: point): point; + } + + /** + * A geometry object decorated with a geometry style object + * @class styledGeometry + */ + export class styledGeometry { + constructor(geom: geometry, gStyle: geometryStyle); + + /** + * Set this styledGeometry's geometryStyle. + * @param {geometryStyle} gs A new styledGeometry. + */ + setGeometryStyle(gs: geometryStyle): void; + + /** + * Gets the styledGeometry's underlying geometry object. + * @returns {geometry} The underlying geometry. + */ + getGeometry(): geometry; + + /** + * Gets path outline thickness in pixels. + * @returns {number} Thickness in pixels. + */ + getOutlineThicknessPix(): number; + + /** + * Sets path outline thickness in pixels. + * @param {number} t Thickness in pixels. + */ + setOutlineThicknessPix(t: number): void; + + /** + * Gets path outline color as a CSS style string. + * @returns {string} Outline color as a CSS style string. + */ + getOutlineColor(): string; + + /** + * Gets path outline opacity in decimal format. + * @returns {number} Outline opacity. + */ + setOutlineColor(c: string): void; + + /** + * Gets path outline opacity in decimal format. + * @returns {number} Outline opacity. + */ + getOutlineOpacity(): number; + + /** + * Set path outline opacity to a decimal between 0 and 1. + * @param {number} o Outline opacity. + */ + setOutlineOpacity(o: number): void; + + /** + * Gets fill color as a CSS style string. + * @returns {string} Fill color as a CSS style string. + */ + getFillColor(): string; + + /** + * Sets fill color as a CSS style string. + * @param {string} c Fill color as a CSS style string. + */ + setFillColor(c: string): void; + + /** + * Gets fill opacity in decimal format. + * @returns {number} Fill opacity. + */ + getFillOpacity(): number; + + /** + * Sets fill opacity to a decimal between 0 and 1. + * @param {number} o Fill opacity. + */ + setFillOpacity(o: number): void; + + /** + * Gets the dash array as a string. + * @returns {string} Dash array as astring. + */ + getDashArray(): string; + + /** + * Sets dash array string from a CSS style string. Defaults to solid + * stroke if no dash array string is provided. + * @param {string} [da] Dash array as a CSS style string. + */ + setDashArray(da: string): void; + + /** + * Gets optional animation function called when SVG node is created. + * @returns {function} Function with the signature animation(pathElement, loopback). + */ + getAnimation(): (pathElement: HTMLElement, loopback: () => void) => void; + + /** + * You can use the loopback parameter on complete to call itself and + * create repeating animation. + * @param {function} Function with the signature animation(pathElement, loopback). + */ + setAnimation(action: (pathElement: HTMLElement, loopback: () => void) => void): void; + + /** + * Renders this geometry as an SVG path. Note: We attach original + * geometry bounds to svg doc as an expando. + * @param {string} key Identifer to keep track of the SVG DOM element. + * @param {number} mupp Map units per pixel with which to create the SVG element. + * @returns {HTMLElement} A new SVG document root. + */ + createSvgPathElement(key: string, mapUnitsPerPix: number): HTMLElement; + + /** + * Renders this to a canvas context. + * @param {CanvasRenderingContext2D} ctx Canvas context to which to render. + */ + renderPathToCanvasContext(ctx: CanvasRenderingContext2D): void; + } + + /** + * The mapjs version. + */ + export var version: string; + + /** + * Exposes static functions for working with well known text. + * @module wkt + */ + export module wkt { + + /** + * Parses WKT as a point. + * @param {string} w A WKT string. + * @returns {point} The parsed point. + */ + export function parsePoint(wkt: string): point; + + /** + * Parses WKT as a multipoint. + * @param [string} w A WKT string. + * @retuns {geometry} The parsed multipoint geometry. + */ + export function parseMultiPoint(wkt: string): geometry; + + /** + * Parses WKT as an open path geometry with a single set. + * @param {string} w A WKT string. + * @returns {geometry} The parsed open path geometry. + */ + export function parseLineString(wkt: string): geometry; + + /** + * Parses WKT as an open path geometry with multiple sets. + * @param {string} w A WKT string. + * @returns {geometry} The parsed open path geometry. + */ + export function parseMultiLineString(wkt: string): geometry; + + /** + * Parses WKT as a closed path geometry with a single set. + * @param {string} w A WKT string. + * @returns {geometry} The parsed closed path geometry. + */ + export function parsePolygon(wkt: string): geometry; + + /** + * Parses WKT as a closed path geometry with multiple sets. + * @param {string} w A WKT string. + * @returns {geometry} The parsed closed path geometry. + */ + export function parseMultiPolygon(wkt: string): geometry; + + /** + * Parses WKT as a geometry and determines its type from the string. + * @param {string} w The WKT string. + * @returns {any} The parsed shape, a point, geometry, or an array of + * polygons depending on the WKT. + */ + export function parse(wkt: string): any; + + /** + * Converts an array of polygons to an OGC compliant multipolygon WKT string. + * @param {polygon[]} polys Set of polygons to parse into WKT. + * @returns {geometry} The OGC compliant WKT for the polygons. + */ + export function toMultiPolygonString(polys: geometry.polygon[]): string; + } + + /** + * Exposes various tile-related constructors, including layers, descriptors, + * and requestors. + * @module tile + */ + export module tile { + + /** + * A tile layer is a view on the map containing an array of rectangular content. + * @class layer + */ + export class layer { + constructor(id: string, useBackdrop?: boolean, maxConcurrentRequests?: number); + + /** + * @param {number} m - number for margin in pixels + */ + // setContentExtentsMarginInPixels(m: number): void; + + /** + * Gets ID associated with this tile layer. + * @returns {string} ID of the layer. + */ + getId(): string; + + /** + * Determines whether this tile layer uses a backdrop. + * @returns {boolean} Whether or not the layer uses a backdrop. + */ + getUseBackdrop(): boolean; + + /** + * Returns the tile layer's descriptor, which describes how + * requested content is rendered or styled. + * @returns {object} The tile layer's descriptor. + */ + getDescriptor(): any; + + /** + * Sets the tile layer's descriptor, which describes how requested + * content is rendered or styled. + * @param {function} d A descriptor for this tile layer. + */ + setDescriptor(d: any): void; + + /** + * Notifies the tile layer to check for changes to its descriptor. + */ + notifyDescriptorChange(): void; + + /** + * Returns this tile layer's requestor which defines what kind of + * content to get and where to get it. + * @returns {requestor} This tile layer's requestor. + */ + getRequestor(): tile.requestor; + + /** + * Sets this tile layer's requestor, which defines what kind of + * content to get and where to get it. + * @param {tile.requestor} req A requestor object. + * @param {tile.requestor} [desc] Descriptor object so that both + * can be set in one call and incur only one content change event. + */ + setRequestor(req: tile.requestor, desc?: any): void; + + /** + * Returns this tile layer's renderer if it exists, which defines + * how geometry data for a quadView is rendered. + * @returns {renderer} The renderer object. + */ + getRenderer(): tile.renderer; + + /** + * Sets optional renderer which defines how geometry data for + * quadView is rendered. + * @param {renderer} r The renderer delegate function with + * signature renderer(quadview). + */ + setRenderer(r: tile.renderer): void; + + /** + * Notifies the tile layer to check for changes to its renderer. + */ + notifyRendererChange(): void; + + /** + * Gets the visibility state of this tile layer. + * @returns {boolean} Whether or not this layer is visible. + */ + getIsVisible(): boolean; + + /** + * Sets visibility state of this tile layer. + * @param {boolean} v Whether this layer should be visible or not. + */ + setIsVisible(v: boolean): void; + + /** + * Gets the opacity of this tile layer. + * @returns {number} Opacity as a decimal. + */ + getOpacity(): number; + + /** + * Sets opacity of this tile layer. + * @param {number} o Opacity as a decimal. + */ + setOpacity(o: number): void; + + /** + * Gets minimum zoom level where this tile layer is visible. + * @returns {number} The minimum zoom level. + */ + getMinZoomLevel(): number; + + /** + * Sets minimum zoom level where this tile layer is visible. + * @param {number} minZ The desired minimum zoom level. + */ + setMinZoomLevel(minZ: number): void; + + /** + * Gets maximum zoom level where this tile layer is visible. + * @returns {number} The maximum zoom level. + */ + getMaxZoomLevel(): number; + + /** + * Sets maximum zoom level where this tile layer is visible. + * @param {number} maxZ The desired maximum zoom level. + */ + setMaxZoomLevel(maxZ: number): void; + + /** + * Sets pixel bleed on quadTiles, which defaults to 1. Setting this + * to zero for overlay layers with translucent polygon fills is + * recommended. Bleed overlap can create faint lines at tile + * boundries when fill is not opaque. + * @param {number} bleed The number of pixels to bleed. + */ + setTileBleedPix(bleed: number): void; + + /** + * Sets whether or not to retain and display previous level tile + * content as you change tile levels to provide a nice zoom level + * change effect. Once the next level is loaded the old level + * content is always discarded. This should be set to false if there + * is translucent content to display. Defaults to true (prior to + * version 9.0.0001 this value had the same state as useBackdrop.) + * @param {boolean} ret Whether or not to retain interlevel content. + */ + setRetainInterlevelContent(retain: boolean): void; + + /** + * Enables or disables the fade in on tile content, which defaults to enabled. + * @param {boolean} fadeIn Whether or not fade in on tile content + * should be enabled. + */ + setEnableTileFadeIn(fadeIn: boolean): void; + + /** + * Sets the default action to take on error. + * @param {function} action Function to execute on error. + */ + setNotifyErrorAction(action: () => void): void; + + /** + * Sets an optional function to be called when the tile loading + * queue for this layer has emptied. + * @param {function} action Callback function. + */ + setNotifyLoadingQueueHasEmptiedAction(action: () => void): void; + + /** + * Sets the optional function to be called by this layer's tile + * loader during processing. The supplied progress function takes + * tiles loaded and tiles total parameters. + * @param {function} action Callback of the signature action(tileLoaded, tilesTotal). + */ + setNotifyLoadingQueueProgressAction(action: (tilesLoaded: number, tilesTotal: number) => void): void; + + /** + * Sets optional request processor for this tile layer. This is + * an advanced feature allowing developers to tap into tile + * request pipeline for purposes of customizing requests or manage + * custom caching. This is also the mechanism used for offline + * apps with frameworks such as phonegap. + * @param {function} Processor function with signature + * processor(requestor, descriptor, quad, timeoutMs, complete, error) + */ + setRequestProcessor(processorFunc: ( + requestor: tile.requestor, + descriptor: any, + quad: tile.quad, + timeoutMs: number, + completeAction: (img: HTMLElement) => void, + errorAction: (msg: string) => void) => void): void; + + /** + * Instructs the tile loader to populate a specified tile pyramid. + * This is used to fetch content (e.g. bitmap tiles) and preload + * it into the browser cache. + * @param {envelope} extents Envelope for which to fetch content. + * @param {number} startZoomLevel Minimum zoom level for which to + * fetch content. + * @param {number} endZoomLevel Maximum zoom level for which to + * fetch content. + */ + preload(extents: envelope, startZoomLevel: number, endZoomLevel: number): void; + + /** + * Composes an array of quadtiles with composition information and + * requestor endpoints. This can be used to create static images + * or print-ready versions of this tile layer at arbitrary extents + * (both source and target) For example: If you needed a 5x3 inch + * 300 dpi output you can specify extents in device units to be + * 1500x900. This function determines the correct zoom level so + * that the source extents fits in the target extents to the + * nearest integer zoom level. + * @param {envelope} extentsMapUnits Source extents in map units. + * @param {envelope} extentsDeviceUnits Target extents in pixels. + * @returns {object} Composed object in the form + * {quadCollection, endpointCollection, idxMinX, idxMinY, ulX, ulY } + * where quadCollection is an array of quad objects, endpointCollection + * is an array of REST endpoints from which to obtain the tiled content, + * idxMinX and idxMinY are the minimum x and y tile indicies of the + * collection respectively, and ulX and ulY are the offset in pixels + * of the upper left tile from the upper left target extents. + */ + compose(extentsMapUnits: envelope, extentsDeviceUnits: envelope): { + quadCollection: tile.quad[]; + endpointCollection: string[]; + idxMinX: number; + idxMinY: number; + ulX: number; + ulY: number; + }; + } + + /** + * A layerOptions object is a method for constructing a tile layer for + * immediate use, for example by passing it to the jQuery widget or + * in the knockout binding. + * @class layerOptions + */ + export class layerOptions { + constructor(id: string, options: { + useBackdrop?: boolean; + maxConcurrentRequests?: number; + requestor?: tile.requestor; + descriptor?: any; + renderer?: tile.renderer; + requestProcessor?: any; + visible?: boolean; + opacity?: number; + minZoomLevel?: number; + maxZoomLevel?: number; + tileBleedPix?: number; + retainInterlevelContent?: boolean; + enableTileFadeIn?: boolean; + notifyErrorAction?: (msg?: string) => void; + notifyLoadingQueueHasEmptiedAction?: () => void; + }); + + /** + * Returns the underlying tile layer. + * @returns {layer} The underlying tile layer. + */ + getTileLayer(): tile.layer; + + /** + * Gets ID associated with the underlying tile layer. + * @returns {string} ID of the layer. + */ + getId(): string; + + /** + * Gets this layerOptions object as a JavaScript object. + */ + getOptions(): any; + } + + /** + * The quad class represents a quad tile within three dimensional + * coordinate space. + * @class quad + */ + export class quad { + + /** + * Gets the x coodinate of this quad tile. + * @returns {number} The x coordinate of this quad tile. + */ + getX(): number; + + /** + * Gets the y coordinate of this quad tile. + * @returns {number} The y coordinate of this quad tile. + */ + getY(): number; + + /** + * Gets the z coordinate of this quad tile, or depth. + * @returns {number} The z coordinate of this quad tile. + */ + getLevel(): number; + + /** + * Gets the envelope in map units which encompasses this quad tile. + * @returns {envelope} The encompassing envelope of this quad tile. + */ + getEnvelope(): envelope; + + /** + * Gets the string representation of this quad tile as a quad key. + * @returns {string} Quad key for this quad tile as a string. + */ + toString(): string; + + /** + * Gets the quad key for this quad tile as a string. + * @returns {string} Quad key for this quad tile as a string. + */ + getKey(): string; + + /** + * Compares this quad tile with another quad tile and determines + * whether or not they are equal. + * @param {quad} Quad tile with which to check for equality with this quad tile. + * @returns {boolean} Result of the equality test. + */ + equals(q: quad): boolean; + + /** + * Generates the quad tile which is a given number of levels above + * this tile in the pyramid and in which this quad tile is contained. + * @param {number} ancestorsBack Number of levels above this tile the + * generated tile should be. + * @returns {quad} The generated parent tile. + */ + factoryParent(ancestorsBack: number): quad; + } + + /** + * Exposes static functions for generating and handling quad tiles. + * @module quad + */ + export module quad { + + /** + * Generates a new quad tile based on a given quad key. + * @param {string} key The quad key from which to generate the quad tile. + * @returns The generated quad tile. + */ + export function factoryQuadFromKey(key: string): quad; + } + + /** + * A tile renderer handles converting JSON vector content loaded from the + * MapDotNet REST feature service into a canvas rendering on a tile. + * @class renderer + */ + export class renderer { + constructor(options? : { + renderPoint?: (pt: point, context: CanvasRenderingContext2D) => void; + renderGeometry?: (shape: geometry, context: CanvasRenderingContext2D) => void; + renderBitmap?: (img: HTMLElement, context: CanvasRenderingContext2D, contextSize: number, bleed: number) => void; + }); + + /** + * Sets the render point function which takes a point and canvas + * context and renders the point to the canvas. The points passed + * in are transformed to pixel units and offset to context origin. + * @param {function} func Function of the form func(shape, context) + * where shape is the point object to be rendered and context is the + * canvas context on which to render. + */ + setRenderPoint(func: (pt: point, context: CanvasRenderingContext2D) => void): void ; + + /** + * Sets render geometry function which takes a geometry and canvas + * context and renders the geometry to the canvas context. The + * geometries passed in are transformed to pixel units and offset + * to the context origin. + * @param {function} func Function with signature func(shape, context) + * where shape is the geometry to render and context is the canvas + * context on which to render. + */ + setRenderGeometry(func: (shape: geometry, context: CanvasRenderingContext2D) => void): void; + + /** + * Sets the render bitmap function which takes a bitmap image and + * a canvas context and renders the image to the canvas context. + * @param {function} func Function with the signature + * func(img, context, contextSize, bleed) where img is the bitmap + * image to render, context is the canvas context on which to + * render the image, contextSize is the size of the canvas context + * in pixels and bleed is the margin around each tile to bleed. + */ + setRenderBitmap(func: (img: HTMLElement, context: CanvasRenderingContext2D, contextSize: number, bleed: number) => void): void; + } + + /** + * An auto-ranging density map renderer. + * @class rendererDensityMap + */ + export class rendererDensityMap { + + constructor(); + + /** + * Sets the bleed ratio, which is the sets the percentage of the + * margin around each tile to use in the tile's computation. Note: + * some bleed (i.e., greater than 1) is required since a heat map + * relies on adjacent data. + * @param {number} bleed The desired bleed ratio. + */ + setBleed(bleed: number): void; + + /** + * Sets the number of rows and columns of cells to be used for + * computation within the grid. + * @param {number} gridSize Number of rows and columns used in + * the grid. + */ + setGridSize(gridSize: number): void; + + /** + * Sets filter radius corresponding to standard deviations. The + * filter radius is the cutoff point at which adjacent cells no + * longer contribute to a cell's calculation. + * @param {number} filterStdDevRadius Number of standard deviations + * from the mean of a normal distribution to which to give positive + * weight. + */ + setFilterStdDevRadius(filterStdDevRadius: number): void; + + /** + * Sets color ranges from cold to hot for the renderer. + * @param {number[][]} matrix Array of arrrays of numbers, each + * of the form [r,g,b,a], where each array represents a color and + * colors range from cold to hot. Note: Typically, a dozen colors + * is sufficient. + */ + setColorMatrix(matrix: number[][]): void; + + /** + * Sets the minimum required cell value for a cell to receive + * a color. Default minimum value is 0. + * @param {number} mcv The minimum cell value for painting. + */ + setMinCellValue(min: number): void; + + /** + * Sets an optional action to perform on each row. This enables + * processing the values on one or more columns for each row for + * use in the density map computations. + * @param {action} ra Function to call on each row with signature + * action(row). The value returned from the function will is added + * to the cell's value. + */ + setRowAction(action: (row: any) => number): void; + + /** + * Tells renderer to re-render density map and recompute ranges. + * This should be called if the data changes or if, due to extent + * changes, the density changes. + */ + notifyRecompute(): void; + } + + /** + * This is a base requestor class. + * @class requestor + */ + export class requestor { + + constructor(); + + /** + * Gets formatted endpoint using the supplied quadtile and a descriptor. + * @param {quad} quad Quadtile for which to fetch the endpoint. + * @returns {string} The requested URI string. + */ + getFormattedEndpoint(quad: quad, descriptor: any): string; + + /** + * Gets data locally if the requestor supports it. + * @param {quad} quad Quadtile for which to fetch the endpoint. + * @returns {string} The requested JSON data. + */ + getLocalData(quad: quad, descriptor: any): string; + + /** + * Creates unique sha1 hash from this requestor and the supplied + * descriptor. This is useful in creating a unique key or folder + * for tile caching. This combined with a tile's quad-key can + * efficiently and uniquely identify a particular tile. + * @params {descriptor} The descriptor for which to create the hash. + * @returns {string} The generated sha1 hash. + */ + hash(descriptor: any): string; + + /** + * Determines whether or not this requestor returns bitmap images. + * @returns {boolean} Whether or not this requestor returns bitmap + * images. + */ + getIsRestImage(): boolean; + + /** + * Sets whether this requestor should return bitmap images. + * @param {boolean} flag Whether or not this requestor should return + * bitmap images. + */ + setIsRestImage(flag: boolean): void; + + /** + * Determines whether or not this requestor uses an endpoint + * rather than local data. + * @returns {boolean} Whether or not this requestor gets data from + * an endpoint. + */ + getUsesEndpoint(): boolean; + + /** + * Sets whether or not this requestor uses an endpoint rather than + * local data. + * @param {boolean} Whether or not this requestor should get data + * from an endpoint. + */ + setUsesEndpoint(flag: boolean): void; + + /** + * Gets format of data returned by REST service. + * @returns {string} Data format returned by the REST service. + */ + getDataFormat(): string; + + /** + * Sets format of data that should be returned by REST service. + * @param {string} df Name of the data format the REST service + * should use. + */ + setDataFormat(df: string): void; + + /** + * Returns whether or not caching is enabled for vector-based + * requestors. + * @returns {boolean} Whether or not caching is enabled. + */ + getCacheEnabled(): boolean; + + /** + * Sets whether or not caching is enabled for vector-beased requestors. + * @param {boolean} flagce - true (default) if caching is enabled + */ + setCacheEnabled(flag: boolean): void; + + /** + * Gets requestor timeout in miliseconds. + * @returns {number} Requestor timeout in miliseconds. + */ + getTimeoutMs(): number; + + /** + * Sets requestor timeout in miliseconds. + * @param {number} ms Desired requestor timeout in miliseconds. + */ + setTimeoutMs(ms: number): void; + + /** ??? + * Gets the additional + * @returns {object[]} + */ + getKeyVals(): {}[]; + + /** Set any key/value pairs that are attached to the ajax call (such as username and password) + */ + setKeyVals(options: {}[]): void; + + /** + * Gets maximum available zoom level content that can be retrieved + * from the endpoint this requestor consumes. + * @returns {number} The maximum available zoom level for this requestor. + */ + getMaxAvailableZoomLevel(): number; + + /** + * Sets maximum available zoom level content that can be retrieved + * from the endpoint this requestor consumes. Note: This defaults + * to the projection's maximum available zoom level, which is 20 + * in spherical mercator. + * @param {number} max The maximum available zoom level for this requestor. + */ + setMaxAvailableZoomLevel(max: number): void; + } + + /** + * A tile requestor for Microsoft Bing maps. + * @class requestorBing + */ + export class requestorBing extends requestor { + + constructor(options?: { + dataFormat?: string; + timeoutMs?: number; + maxAvailableZoomLevel?: number; + }); + + /** + * Gets the formatted endpoint uri for Bing maps, e.g. + * ecn.t{0}.tiles.virtualearth.net/tiles/{1}{2}{3}?g={4}&mkt={5}&shading=hill. + * @returns {string} endpoint to Bing tile server as a formatted string + */ + getEndpoint(): string; + + /** + * Gets the protocol for the endpoint, either 'http' or 'https'. + * @returns {string} The endpoint protocol. + */ + getScheme(): string; + + /** + * Sets endpoint protocol to either 'http' or 'https'. + * @param {string} s Protocol to use in endpoints. + */ + setScheme(s: string): void; + + /** + * Gets Bing tile generation + * @returns {string} the tile generation as an integer + */ + getGeneration(): string; + + /** + * Sets Bing tile generation + * @param {string} g - generation as an integer + */ + setGeneration(g: string): void; + + /** + * Gets the language code for which the tiles are rendered. The + * default code is 'en-US'. + * @returns {string} The language code for which tiles are rendered. + */ + getMarket(): string; + + /** + * Sets language code for which to render tiles. For example, + * 'en-US'. + * @param {string} m Language code for which to render tiles. + */ + setMarket(m: string): void; + + /** + * Gets the Bing key associated with this requestor. + * @returns {string} The Bing key for this requestor. + */ + getBingKey(): string; + + /** + * Sets Bing key which then calls Microsoft metadata service and + * automatically configures content endpoint. + * @param {string} key Bing key. + */ + setBingKey(key: string): void; + } + + /** + * The bitmap or vector tile requestor using MapDotNet REST services. + * @class requestorMDN + */ + export class requestorMDN extends requestor { + constructor(endpoint: string, options?: { + dataFormat?: string; + timeoutMs?: number; + maxAvailableZoomLevel?: number; + }); + + /** + * Gets uri endpoint for the MapDotNet REST service. + * @returns {string} Uri endpoint for the MapDotNet REST service. + */ + getEndpoint(): string; + } + + /** + * Creates an instance of a descriptor for describing content from a + * MapDotNet UX REST map service. + * @class descriptorMDNRestMap + */ + export class descriptorMDNRestMap { + constructor(mapId: string, options?: { + version?: string; + imageType?: string; + bleedRatio?: number; + mapCacheOption?: string; + mapCacheName?: string; + useQuadKeyForMapCacheName?: boolean; + backgroundColorStr?: string; + layerVisibility?: {}; + layerOutline?: {}; + layerFill?: {}; + layerWhere?: {}; + tag?: string; + }); + + /** + * Sets the flag to suspend descriptor change notifications. If + * set true, all changes to this descriptor will not cause the map + * to redraw. Setting to false will enable redraws and immediately + * force a redraw. + * @param {boolean} flag Whether or not descriptor change notifications + * should be enabled. + */ + setSuspendDescriptorChangeNotifications(flag: boolean): void; + + /** + * Gets the map ID. + * @returns {string} The map ID. + */ + getMapId(): string; + + /** + * Gets the REST service version. + * @returns {string} The REST service version. + */ + getVersion(): string; + + /** + * Sets the REST service version. + * @param {string} v The version number. + */ + setVersion(v: string): void; + + /** + * Gets image type associated with this descriptor, either 'png', + * 'png8', or 'jpg'. + * @returns {string} The image type associated with this descriptor. + */ + getImageType(): string; + + /** + * Gets image type associated with this descriptor to one of 'png', + * 'png8', or 'jpg'. + * @param {string} t The image type associated which should be + * associated with this descriptor. + */ + setImageType(t: string): void; + + /** + * Gets bleed ratio for the layer associated with this descriptor. + * @returns {number} The bleed ratio. + */ + getBleedRatio(): number; + + /** + * Sets the bleed ratio. Bleeds greater than 1.0 will fetch content + * beyond the edge of the tile extents (this is useful for point + * features). + * @param {number} br The desired bleed ratio, between 1.0 and 2.0. + */ + setBleedRatio(br: number): void; + + /** + * Gets the map's cache setting, which is one of 'None', + * 'ReadOnly', 'ReadWrite', 'ForceWrite', and 'Default.' + * @returns {string} The map's cache setting. + */ + getMapCacheOption(): string; + + /** + * Gets the map's cache setting to one of 'None', + * 'ReadOnly', 'ReadWrite', 'ForceWrite', and 'Default.' + * @param {string} mco The desired cache setting for the map. + */ + setMapCacheOption(mco: string): void; + + /** + * Gets the optional map cache name. + * @returns {string} The map cache name. + */ + getMapCacheName(): string; + + /** + * Sets the optional map cache name. + * @param {string} mcn The desired map cache name. + */ + setMapCacheName(mcn: string): void; + + /** + * Determines whether the map is flagged to use the quadkey as its + * map cache name. + * @returns {boolean} Whether or not the map has been flagged to + * use the quadkey as its map cache name. + */ + getUseQuadKeyForMapCacheName(): boolean; + + /** + * Sets the flag that uses the quadkey as its map cache name. + * @param {boolean} flag Whether or not the map should be flagged + * to use the quadkey as its map cache name. + */ + setUseQuadKeyForMapCacheName(flag: boolean): void; + + /** + * Gets map image background color. + * @returns {string} CSS style string for the map image background color. + */ + getBackgroundColorStr(): string; + + /** + * Sets the map image background color. + * @param {number} a Alpha level. + * @param {number} r Red level. + * @param {number} g Green level. + * @param {number} b Blue level. + */ + setBackgroundColor(a: number, r: number, g:number, b:number): void; + + /** + * Checks whether or not the map background is transparent. + * @returns {boolean} Whether or not the map background is transparent. + */ + getIsBackgroundTransparent(): boolean; + + /** + * Sets a layer's visibility. + * @param {string} layerId The MapDotNet map layer ID. + * @param {boolean} isVisible Whether or not the layer should be visible. + */ + setLayerVisibility(layerId: string, isVisible: boolean): void; + + /** + * Gets a layer's visibility. + * @param {string} layerId The MapDotNet map layer ID. + * @returns {boolean} Whether or not the layer is visible. + */ + getLayerVisibility(layerId: string): boolean; + + /** + * Sets a layer's outline color and thickness. + * @param {string} layerId The MapDotNet map layer ID. + * @param {number} a Alpha level. + * @param {number} r Red level. + * @param {number} g Green level. + * @param {number} b Blue level. + * @param {number} thk Outline thickness in pixels. + */ + setLayerOutline(layerId: string, a: number, r: number, g: number, b: number, thk: number): void; + + /** + * Gets a layer's outline color and thickness. + * @param {string} layerId The MapDotNet map layer ID. + * @returns {object} JavaScript object of the form {color, thickness} + * where color is the CSS style string of the outline color and + * thickness is the outline thickness in pixels. + */ + getLayerOutline(layerId: string): { color: string; thickness: number; }; + + /** + * Sets a layer's fill color. + * @param {string} layerId The MapDotNet map layer ID. + * @param {number} a Alpha level. + * @param {number} r Red level. + * @param {number} g Green level. + * @param {number} b Blue level. + */ + setLayerFill(layerId: string, a: number, r: number, g: number, b: number): void; + + /** + * Sets a layer's fill color as a SQL expression. + * @param {string} layerId The MapDotNet map layer ID. + * @param {string} exp The SQL expression to select a row's fill color. + */ + setLayerFillAsExpression(layerId: string, exp: string): void; + + /** + * Gets a layer's fill color as a CSS style string or as a SQL expression. + * @param {string} layerId The MapDotNet map layer ID. + * @returns {string} Either the CSS style string or the SQL expression, + * according to how the layer's fill color was set. + */ + getLayerFill(layerId: string): string; + + /** + * Add or replace the where clause for a layer. The where clause + * is a SQL expression used to filter rows. + * @param {string} layerId The MapDotNet map layer ID. + * @param {string} where The desired SQL where expression. + * @param {boolean} [merge] Whether to merge the new where clause + * with the existing where clause using a SQL AND or to replace + * the existing where clause with the new one. Defaults to true (merge). + */ + setLayerWhere(layerId: string, where: string, merge: boolean): void; + + /** + * Sets a separator character for the layer where clause expression + * in the query string. This is set to ',' by default, which is + * consistent with SQL. + * @param {string} sep The desired seperator, which should be a + * single character. + */ + setLayerWhereSep(sep: string): void; + + /** + * Returns the current separator for the layer where clause in the + * query string. + * @returns {string} The current seperator. + */ + getLayerWhereSep(): string; + + /** + * Gets the current layer where clause. + * @param {string} layerId The MapDotNet map layer ID. + * @returns {string} The current where clause. If no where clause + * is in use, this will return an empty string. + */ + getLayerWhere(layerId: string): string; + + /** + * Gets a tag which is used to modify the request URIs to avoid + * browser caching + * @returns {string} The map's tag. + */ + getTag(): string; + + /** + * Sets the map's tag, which is used modify request URIs to avoid + * browser caching. + * @param {string} tag The desired tag. + */ + setTag(tag: string): void; + } + + /** + * Creates an instance of a descriptor for describing content from + * a MapDotNet REST feature service. + * @class descriptorMDNRestFeature + */ + export class descriptorMDNRestFeature { + constructor(mapId: string, layerId: string, options?: { + version?: string; + bleedRatio?: number; + fieldNames?: string[]; + clipToRenderBounds?: boolean; + simplifyEnabled?: boolean; + }); + + /** + * Gets the map ID. + * @returns {string} The map ID. + */ + getMapId(): string; + + /** + * Gets the layer's ID. + * @returns {string} The layer's ID. + */ + getLayerId(): string; + + /** + * Gets the version of the REST service. + * @returns {string} The REST service version. + */ + getVersion(): string; + + /** + * Sets the REST service version number. + * @param {string} v The version number to set. + */ + setVersion(v: string): void; + + /** + * Gets the bleed ratio. + * @returns {number} The current bleed ratio. + */ + getBleedRatio(): number; + + /** + * Sets the bleed ratio. Bleeds greater than 1.0 will fetch content + * beyond the edge of the tile extents (this is useful for point features). + * @param {number} br The desired bleed ratio, a number between 1.0 and 2.0. + */ + setBleedRatio(br: number): void; + + /** + * Gets the optional field names to query. This attribute data may + * be used in dynamic client-side rendering. + * @returns {string[]} An array of field names as strings. + */ + getFieldNames(): string[]; + + /** + * Sets the optional field names to query. This attribute data may be used in + * dynamic client-side rendering. + * @param {string} names - array of strings for each field to query + */ + setFieldNames(names: string[]): void; + + /** + * Checks the flag whether to clip geometry fetched at the bounds + * of the request. + * @returns {boolean} The value of the flag. + */ + getClipToRenderBounds(): boolean; + + /** + * Sets the flag whether to clip geometry fetched at the bounds + * of the request. This can greatly improve performance with large + * complex geometries. Only supported when back-end store is SQL + * 2008/2012 or PostGIS. + * @param {boolean} flag Whether or not to clip geometries fetched + * at the bounds of the request. + */ + setClipToRenderBounds(flag: boolean): void; + + /** + * Checks the flag whether to simplify paths based on the units per + * pixel for the quad tile being requested. + * @returns {boolean} The value of the flag. + */ + getSimplifyEnabled(): boolean; + + /** + * Sets the flag whether to simplify paths based on the units per + * pixel for the quad tile being requested. + * @param {boolean} flag Whether or not to simply paths based on + * the units per pixel. + */ + setSimplifyEnabled(flag: boolean): void; + + /** + * Sets the action to perform on descriptor change. + * @param {function} action Function with signature action(). + */ + setNotifyDescriptorChangeAction(action: () => void): void; + } + + /** + * This is a generic tile requestor suitable for several third-party + * tile servers. These include open street map, map quest, cloudmade, + * Nokia, etc. + * @class requestorOpen + */ + export class requestorOpen extends requestor { + constructor(endpoint: string, subdomains: string[], options?: { + dataFormat?: string; + timeoutMs?: number; + maxAvailableZoomLevel?: number; + }); + } + + /** + * This is a requestor for local collections of data. These local collections may + * originate from inlined code or from datasources other than a MapDotNet REST + * feature service. + * @class requestorLocal + */ + export class requestorLocal extends requestor { + constructor(options?: { + dataFormat?: string; + timeoutMs?: number; + maxAvailableZoomLevel?: number; + data: {}[]; + }); + + /** + * Gets the unparsed source data. + * @returns {object} Array of source data objects. + */ + getSource(): {}[]; + + /** + * Sets source data. + * @param {object} data An array of JavaScript objects to use as + * the requestor source data. + */ + setSource(data: {}[]): void; + + /** + * Returns your source data parsed into theformat { Shapes: [], + * Values: [], Bounds: [] } This may be useful for doing client-side + * queries on the local data where all of the WKT has been parsed + * into points and geometry. There is also a bounds collection to + * do a quick spatial check for complex polygons. + * @returns {object} Parsed data object in the form {Shapes, Values, Bounds}. + */ + getParsedData(): { + Shapes: any[]; + Values: any[]; + Bounds: envelope[]; + }; + } + + /** + * Local descriptor object for describing source data when the source + * data is fecthed by a local requestor. + * @class descriptorLocal + */ + export class descriptorLocal { + constructor(options: { + valueFieldNames: string[]; + geometryFieldName: string; + bleedRatio?: number; + }); + } + } + + interface pointObject { + x: number; + y: number; + } + + interface envObject { + + /** + * @returns {number} minX as integer + */ + minX: number; + + /** + * @returns {number} minY coord as integer + */ + minY: number; + + /** + * @returns {number} maxX coord as integer + */ + maxX: number; + + /** + * @returns {number} maxY coord as integer + */ + maxY: number; + } + + interface mapsjsWidget { + + /** + * Gets the center of the map in spherical mercator. Use + * sphericalMercator.deprojectToLatLon static function to convert to a lat/lon. + * @return {point} A point map center + */ + getMapCenter(): point; + + /** + * Sets the center of the map in spherical mercator. Use + * sphericalMercator.projectFromLatLon static function to convert from a lat/lon. + * @param {point} center The map center as a point + */ + setMapCenter(center: point): void; + + /** + * Same as setMapCenter except will animate from current map center to the + * specified location + * @param {point} center The map center as a point. + * @param {number} [durationMs] Duration in miliseconds. + * @param {function} [completeAction] Callback to perform on animaton complete. + */ + setMapCenterAnimate(center: point, durationMs?: number, completeAction?: () => void): void; + + /** + * Sets the map center to the current geolocation if supported. The map is + * animated to the new location. + * @param {number} [durationMs] Duration in miliseconds. + * @param {function} [completeAction] Callback to perform on animaton complete. + */ + setMapCenterToGeolocationAnimate(durationMs?: number, completeAction?: () => void): void; + + /** + * Gets the current zoom level. + * @returns {number} The current zoom level. + */ + getZoomLevel(): number; + + /** + * Sets the current zoom level. + * @param {number} z1 The desired zoom level. + */ + setZoomLevel(zl: number): void; + + /** + * Sets the minimum zoom level for the map. + * @param {number} zl Desired minimum zoom level. + */ + setMinZoomLevel(zl: number): void; + + /** + * Sets the maximum zoom level for the map. + * @param {number} z1 The desired maximum zoom level. + */ + setMaxZoomLevel(zl: number): void; + + /** + * Animates the map from the current zoom level to the given zoom level. + * @param {number} zl The desired zoom level. + * @param {number} [durationMs] The duration in miliseconds. + * @param {function} [completeAction] Function to call when the animation + * completes with signature completeAction(). + */ + setZoomLevelAnimate(zl: number, durationMs?: number, completeAction?: () => void): void; + + /** + * Changes the current zoom level. + * @param {number} delta Change to be added to the current zoom level. + */ + zoomDelta(delta: number): void; + + /** + * Animates a change to the current zoom level. + * @param {number} delta Change to be added to the current zoom level. + * @param {number} [durationMs] Duration in miliseconds. + */ + zoomDeltaAnimate(delta: number, durationMs?: number): void; + + /** + * Animates parabolically from the current map center and zoom level + * to the given map center and zoom level. + * @param {point} center Desired map center as a point. + * @param {number} zl Desired zoom level. + * @param {number} [durationMs] Animation duration in miliseconds. + * @param {function} [completeAction] Function to call after the animation + * completes with signature completeAction(). + */ + flyTo(center: point, zl: number, durationMs?: number, completeAction?: () => void): void; + + /** + * Gets the current map extents in spherical mercator units. + * @return {envelope} envelope The current map extents. + */ + getMapExtents(): envelope; + + /** + * Gets the current map units per pixel. + * @returns {number} Map units (meters) per pixel. + */ + getMapUnitsPerPixel(): number; + + /** + * Gets the map extents' width and height in pixels. + * @returns {object} JavaScript object of the form {w, h} where w is + * the current extents' width in pixels and h is the current extents' + * height in pixels. + */ + getViewExtentsInPix(): { w: number; h: number; }; + + /** + * Gets the current projected map scale. This is the ratio of units on + * the screen to map units depicted. + * @returns {number} Ratio of screen units to map units. + */ + getProjectedMapScale(): number; + + /** + * Gets the current actual map scale. This is the ratio of units on + * the screen to actual units on the earth's surface at the latitude + * of the current map center. + * @returns {number} The ratio of screen units to actual meters. + */ + getActualMapScale(): number; + + /** + * Gets the best fit zoom level based on the supplied map extents for + * the current display extents in pixels. + * @param {envelope} extentsNew New map extents to fit. + * @returns {number} The zoom level which best fits the extents. + */ + getBestFitZoomLevelByExtents(extentsNew: envelope): number; + + /** + * Forces the map to redraw the currently loaded tile and geometry + * content. You should not have to call this as redraws are automatically + * handled during programatic state changes. This would be for edge cases + * where the developer is affecting internal state in an undocumented way. + */ + redraw(): void; + + /** + * Updates the map to the size of its container. This updates internal + * parameters for computing map extents and handling the amount of tile + * content to download. This is handled automatically if the browser + * window is resized. But if you are sizing the map programatically + * (e.g. resizable panel or slider) then call this after the parent + * container has resized. + */ + resize(): void; + + /** + * Pushes a supplied tile layer onto the top of the display stack. + * @param {tile.layer} tl The desired tile layer. + */ + pushTileLayer(tl: tile.layer): void; + + /** + * Removes a tile layer off the top of the display stack + * @returns {tile.layer} The removed tile layer. + */ + popTileLayer(): tile.layer; + + /** + * Removes a tile layer off the display stack by reference + * @param {tile.layer} tl - a tile layer + */ + removeTileLayer(tl: tile.layer): void; + + /** + * Removes all tile layers off the display stack + */ + removeAllTileLayers(): void; + + /** + * Gets the current number of tile layers in the display stack. + * @returns {number} The number of tile layers in the display stack. + */ + getTileLayerCount(): number; + + /** + * Gets a tile layer from the display stack by its key. + * @param {string} key The desired tile layer's key. + * @returns {tile.layer} The tile layer associated with the key, or null + * if no tile layer is associated with the key. + */ + getTileLayer(key: string): tile.layer; + + /** + * Gets a point in map units from supplied coordinates pixel units + * with respect to the currently displayed extents. + * @param {number} x The x coordinate in pixels. + * @param {number} y The y coordinate in pixels. + * @returns {point} The generated point in map units. + */ + computeMapPointFromPixelLocation(x: number, y: number): point; + + /** + * Flags whether or not map extent changes can occur through gestures + * like mouse or touch drag, mouse wheel, or pinch zoom. + * @param {boolean} flag Whether or not gestures should affect map + * extent changes. + */ + setSuspendMapExtentChangesByGestures(flag: boolean): void; + + /** + * Sets the z-order of drawn content in relation to the gesture capture + * panel. The default behavior (false) is to have fixed content and + * geometry underneath the gesture panel in the DOM. If false, all + * pointer events are handled by the gesture capture panel and + * optionally parents of the map control. If true, drawn content will + * receive pointer events first and will block gestures to the map. If + * true, digitizing will not function and polygons will block map + * navigation. In some scenarios you may want to set this to true if you + * are placing fixed content (such as point features) on the map and + * need to handle gestures on the placed content. You can call this + * function at any time to change the order. + * @param {boolean} flag Whether or not the fixed content layer should + * reside above the gesture layer. + */ + setDrawnContentZorderToTop(flag: boolean): void; + + /** + * Add a fixed element to the content area which resides at a z-level + * above tiled map content. These elements do not scale with the map + * scale. This is used to place markers or callouts on the map + * @param {HTMLElement} element Any html that can be added to the DOM. + * @param {number} mapUnitsX The x coordinate of the insertion point in map units. + * @param {number} mapUnitsY The y coordinate of the insertion point in map units. + * @param {function} [addAction] Callback function called after the + * DOM element has been placed with signature addAction(element). + * @param {object} dragOptions JavaScript object of the form {dragEnabled, + * useElementInsteadOfNewGestureOverlay, downAction, moveAction, upAction, + * wheelAction } where dragEnabled flags whether dragging should be + * enabled on the element, and downAction, moveAction, upAction, and + * wheelAction are callback functions invoked on mousedown, mousemove, + * mouseup, and scroll events respectively. + */ + addFixedContentElement( + element: HTMLElement, + mapUnitsX: number, + mapUnitsY: number, + addAction?: (ele: HTMLElement) => void, + dragOptions?: { + dragEnabled: boolean; + useElementInsteadOfNewGestureOverlay: boolean; + downAction?: (downPoint: point) => any; + moveAction?: (movePoint: point) => void; + upAction?: (upPoint: point) => void; + wheelAction?: (delta: number) => void; + } + ): void; + + /** + * Move an existing fixed content element. + * @param {HTMLElement} element The existing DOM element to move. + * @param {number} mapUnitsX The new x coordinate in map units. + * @param {number} mapUnitsY The new y coordinate in map units. + */ + moveFixedContentElement(element: HTMLElement, mapUnitsX: number, mapUnitsY: number): void; + + /** + * Removes a fixed content element. + * @param {HTMLElement} element The DOM element to remove. Note: This + * must be the same element added by addFixedContentElement. + */ + removeFixedContentElement(element: HTMLElement): void; + + /** + * Add a styled path geometry to the content area which resides at a z-level + * above tiled map content. The geometry is converted to SVG and added to the + * content area DOM. If an attempt to add a geometry is made with the same + * key, the geometry is swapped out. You must remove using removePathGeometry + * for resource cleanup. + * @param {styleGeometry} styledGeom THe styledGeometry to render. + * @param {string} key String used to tie a geometry to its SVG + * rendering in the DOM. + * @returns {element} The SVG element which was added to the DOM. + */ + addPathGeometry(styledGeom: styledGeometry, key: string): void; + + /** + * Updates an existing path geometry to reflect a style change. + * @param {geometryStyle} styleNew The new geometryStyle. + * @param {string} key The key of the geometry to receive the new style. + */ + updatePathGeometryStyle(styleNew: geometryStyle, key: string): void; + + /** + * Removes a styledGeometry from display. + * @param {string} key The key of the geometry to remove. + */ + removePathGeometry(key: string): void; + + /** + * Initiates digitization on the map control. This creates a new + * geometry and adds verticies to the geometry accord to mouse + * click locations. + * @param {object} options JavaScript object of the form { key, + * shapeType, geometryStyle, nodeTapAndHoldAction, nodeMoveAction, + * shapeChangeAction, envelopeEndAction, supressNodeAdd, leavePath } + * where key is a a string associated with this geometry, shapeType + * is the type of shape this geometry is, one of 'point', 'path', or + * 'polygon', geometryStyle is a geometryStyle which should be applied + * to the digitized geometry, nodeTapAndHoldAction is a callback invoked + * when any point in the geometry is clicked and held and has the + * signature nodeTapAndHoldAction(setIdx, idx), nodeMoveAction is a + * callback invoked after any node is dragged to a new location and + * has signature nodeMoveAction(x, y, actionType), shapeChangeAction + * is a callback that is invoked after the geometry shape changes and, + * has signature shapeChangeAction(), envelopeEndAction is a callback + * invoked after an envelope is created and has signature envelopeEndAction(envelope), + * and leavePath is a flag that indicates whether the digitized shape + * should be left on the map after digitization is complete. + */ + beginDigitize(options: { + key?: string; + shapeType: string; + geometryStyle?: geometryStyle; + nodeTapAndHoldAction?: (setIdx: number, idx: number) => boolean; + nodeMoveAction?: (x: number, y: number, actionType: string) => any; + shapeChangeAction?: () => void; + envelopeEndAction?: (env: envelope) => void; + suppressNodeAdd?: boolean; + leavePath?: boolean; + }): void; + endDigitize(): void; + + /** + * Gets a snapshot copy of the currently digitizing path. + * @returns {geometry} The currently digitizing path. + */ + getDigitizeSnapshot(): geometry; + + /** + * Forces additional digitized points to be pushed to a new set of the + * currently digitizing geometry. + */ + pushSetOnDigitizePath(): void; + + /** + * Removes the last set from the currently digitizing path. + * @return {number[]} The last set from the currently digitizing path + * in the form [xn,yn]. + */ + popSetFromDigitizePath(): number[]; + + /** + * Programmatically delete a node from the currently digitizing path. + * @param {number} setIdx The index of the set from which to remove the node. + * @param {number} nodeIdx The index of the node to remove. + */ + deleteNodeOnDigitizePath(setIdx: number, nodeIdx: number): void; + + /** + * Determines whether a shape is currently being digitized. + * @returns {boolean} Whether or not a shape is being digitized. + */ + isDigitizingEnabled(): boolean; + + /** + * Set the function called when the map extents have stopped changing + * (e.g. after an animated pan or zoom). + * @param {function} action The function to call when the extents + * finish changing with signature action(object) where object is of + * the form { centerX, centerY, centerLat, centerLon, zoomLevel, mapScale, + * mapScaleProjected, mapUnitsPerPixel, extents }. + */ + setExtentChangeCompleteAction(action: (vals: {}) => void): void; + + /** + * Set the function called when map content (map tiles and fixed elements) are + * re-positioned in the DOM. This is done automatically as the map is panned + * beyond existing content and zoomed to a new level requiring content. + * @param {function} action The function to call when the map content + * completes repositioning with signature action(object) where object + * is of the form { centerX, centerY, zoomLevel, mapUnitsPerPixel }. + */ + setContentRepositionAction(action: (vals: {}) => void): void; + + /** + * Sets function called when map is clicked or tapped. + * @param {function} action The function to call on mouse click or tap + * with signature action(point). + */ + setPointerClickAction(action: (pt: point) => void): void; + + /** + * Sets function called when the map pointer hovers over the map. + * @param {function} action The function to call on mouse hover with + * signature action(point). + */ + setPointerHoverAction(action: (pt: point) => void): void; + + /** + * Sets the margin around the map in pixels for extra content fetched so that tile + * rebuilding of the display is minimized. This is an advanced property and does not + * generally need to be adjusted. The default is 128 pixels, or half the width + * of a tile. This should be increased for maps which are very large in pixels + * or where panning is constant. This should be decreased for very small maps, + * such as on mobile devices, or where panning is minimal. + * @param {number} cem The content extent margin in pixels. + */ + setContentExtentsMarginInPixels(cem: number): void; + + /** + * Sets the background color of the map using a css color string + * @param {number} b- a css color string + */ + setBackground(b: string): void; + } +} + +interface JQuery { + + rimMap(): JQuery; + rimMap(command: any, param?: any, param2?: any, param3?: any, param4?: any, param5?: any): JQuery; + getMapsjs(): any; +} diff --git a/mapsjs/mapsjs.d.ts.tscparams b/mapsjs/mapsjs.d.ts.tscparams new file mode 100644 index 000000000..3cc762b55 --- /dev/null +++ b/mapsjs/mapsjs.d.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file diff --git a/marionette/marionette.d.ts.tscparams b/marionette/marionette.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/marionette/marionette.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/meteor/meteor-tests.ts.tscparams b/meteor/meteor-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/meteor/meteor-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/meteor/meteor.d.ts.tscparams b/meteor/meteor.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/meteor/meteor.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index 53c8e5720..5c8f34099 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -1,5 +1,7 @@ /// +var mocha: Mocha; + function test_describe() { describe('something', () => { }); @@ -49,4 +51,85 @@ function test_afterEach() { afterEach(() => { }); afterEach((done) => { done(); }); -} \ No newline at end of file +} + +function test_reporter_string(){ + mocha.reporter('html'); +} + +function test_reporter_function(){ + mocha.reporter(function(){}); +} + +function test_setup_slow_option(){ + mocha.setup({slow: 25}); +} + +function test_setup_timeout_option(){ + mocha.setup({timeout: 25}); +} + +function test_setup_globals_option(){ + mocha.setup({globals: ['mocha']}); +} + +function test_setup_ui_option(){ + mocha.setup({ui: 'bdd'}); +} + +function test_setup_reporter_string_option(){ + mocha.setup({reporter: 'html'}); +} + +function test_setup_reporter_function_option(){ + mocha.setup({reporter: function(){}}); +} + +function test_setup_bail_option(){ + mocha.setup({bail: false}); +} + +function test_setup_ignore_leaks_option(){ + mocha.setup({ignoreLeaks: false}); +} + +function test_setup_grep_string_option(){ + mocha.setup({grep: "describe"}); +} + +function test_setup_grep_regex_option(){ + mocha.setup({grep: new RegExp('describe')}); +} + +function test_setup_grep_regex_literal_option(){ + mocha.setup({grep: /(expect|should)/i }); +} + +function test_setup_all_options(){ + mocha.setup({ + slow: 25, + timeout: 25, + ui: 'bdd', + globals: ['mocha'], + reporter: 'html', + bail: true, + ignoreLeaks: true, + grep: 'test' + }); +} + +function test_run(){ + mocha.run(function(){}) +} + +function test_growl(){ + mocha.growl(); +} + +function test_chaining(){ + mocha + .setup({slow:25}) + .growl() + .reporter('html') + .reporter(function(){}); +} diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index 8c1167def..5ea4237fc 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -4,14 +4,52 @@ // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped interface Mocha { - setup(options: MochaSetupOptions): void; - run(callback: () => void): void; + // Setup mocha with the given setting options. + setup(options: MochaSetupOptions): Mocha; + + //Run tests and invoke `fn()` when complete. + run(callback?: () => void): void; + + // Set reporter as function + reporter(reporter: () => void): Mocha; + + // Set reporter, defaults to "dot" + reporter(reporter: string): Mocha; + + // Enable growl support. + growl(): Mocha } interface MochaSetupOptions { - slow: number; - timeout: number; - ui: string; + //milliseconds to wait before considering a test slow + slow?: number; + + // timeout in milliseconds + timeout?: number; + + // ui name "bdd", "tdd", "exports" etc + ui?: string; + + //array of accepted globals + globals?: Array; + + // reporter instance (function or string), defaults to `mocha.reporters.Dot` + reporter?: any; + + // bail on the first test failure + bail?: Boolean; + + // ignore global leaks + ignoreLeaks?: Boolean; + + // grep string or regexp to filter tests with + grep?: any; +} + +declare module mocha { + interface Done { + (error?: Error): void; + } } declare var describe : { @@ -23,27 +61,27 @@ declare var describe : { declare var it: { (expectation: string, assertion?: () => void): void; - (expectation: string, assertion?: (done: (error?: Error) => void) => void): void; + (expectation: string, assertion?: (done: mocha.Done) => void): void; only(expectation: string, assertion?: () => void): void; - only(expectation: string, assertion?: (done: (error?: Error) => void) => void): void; + only(expectation: string, assertion?: (done: mocha.Done) => void): void; skip(expectation: string, assertion?: () => void): void; - skip(expectation: string, assertion?: (done: (error?: Error) => void) => void): void; + skip(expectation: string, assertion?: (done: mocha.Done) => void): void; timeout(ms: number): void; }; declare function before(action: () => void): void; -declare function before(action: (done: (error?: Error) => void) => void): void; +declare function before(action: (done: mocha.Done) => void): void; declare function after(action: () => void): void; -declare function after(action: (done: (error?: Error) => void) => void): void; +declare function after(action: (done: mocha.Done) => void): void; declare function beforeEach(action: () => void): void; -declare function beforeEach(action: (done: (error?: Error) => void) => void): void; +declare function beforeEach(action: (done: mocha.Done) => void): void; declare function afterEach(action: () => void): void; -declare function afterEach(action: (done: (error?: Error) => void) => void): void; +declare function afterEach(action: (done: mocha.Done) => void): void; diff --git a/modernizr/modernizr-tests.ts b/modernizr/modernizr-tests.ts index abb175293..86355a310 100644 --- a/modernizr/modernizr-tests.ts +++ b/modernizr/modernizr-tests.ts @@ -47,4 +47,8 @@ $(function () { var elem; Modernizr.hasEvent('gesturestart', elem); + + if (!Modernizr.autofocus) { + $("[autofocus]").focus(); + } }); diff --git a/modernizr/modernizr-tests.ts.tscparams b/modernizr/modernizr-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/modernizr/modernizr-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/modernizr/modernizr.d.ts b/modernizr/modernizr.d.ts index fd8f5291f..4de482aec 100644 --- a/modernizr/modernizr.d.ts +++ b/modernizr/modernizr.d.ts @@ -47,6 +47,7 @@ interface InputTypesboolean { } interface ModernizrStatic { + autofocus: boolean; fontface: boolean; backgroundsize: boolean; borderimage: boolean; @@ -91,9 +92,9 @@ interface ModernizrStatic { touch: boolean; webgl: boolean; - load(resources: Array); - load(resourceObject: any); - load(resourceString: string); + load(resources: Array): void; + load(resourceObject: any): void; + load(resourceString: string): void; prefixed(): boolean; prefixed(property: string): boolean; @@ -101,11 +102,11 @@ interface ModernizrStatic { mq(mediaQuery: string): boolean; - addTest(feature: string, test: () => any); - addTest(feature: string, test: boolean); - addTest(feature: any); + addTest(feature: string, test: () => any): void; + addTest(feature: string, test: boolean): void; + addTest(feature: any): void; - testStyles(rule: string, callback: (element, rule) => void, nodes?: number, testnames?: string[]): boolean; + testStyles(rule: string, callback: (element: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean; testProp(property: string): boolean; testAllProps(property: string, prefix?: string): boolean; testAllProps(property: string, obj: any, element: any): boolean; diff --git a/modernizr/modernizr.d.ts.tscparams b/modernizr/modernizr.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/modernizr/modernizr.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mongodb/mongodb-tests.ts.tscparams b/mongodb/mongodb-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/mongodb/mongodb-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mongodb/mongodb.d.ts.tscparams b/mongodb/mongodb.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/mongodb/mongodb.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/msnodesql/msnodesql-tests.ts.tscparams b/msnodesql/msnodesql-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/msnodesql/msnodesql-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/msnodesql/msnodesql.d.ts.tscparams b/msnodesql/msnodesql.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/msnodesql/msnodesql.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mustache/mustache-tests.ts.tscparams b/mustache/mustache-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/mustache/mustache-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/mustache/mustache.d.ts.tscparams b/mustache/mustache.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/mustache/mustache.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/noVNC/noVNC-tests.ts.tscparams b/noVNC/noVNC-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/noVNC/noVNC-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/noVNC/noVNC.d.ts.tscparams b/noVNC/noVNC.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/noVNC/noVNC.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node-azure/azure-tests.ts.tscparams b/node-azure/azure-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node-azure/azure-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node-azure/azure.d.ts.tscparams b/node-azure/azure.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node-azure/azure.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node-ffi/node-ffi-tests.ts.tscparams b/node-ffi/node-ffi-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node-ffi/node-ffi-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node-ffi/node-ffi.d.ts.tscparams b/node-ffi/node-ffi.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node-ffi/node-ffi.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node-fibers/node-fibers-tests.ts.tscparams b/node-fibers/node-fibers-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node-fibers/node-fibers-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node-fibers/node-fibers.d.ts.tscparams b/node-fibers/node-fibers.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node-fibers/node-fibers.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 251772123..f796dfb1c 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -156,7 +156,7 @@ interface NodeBuffer { write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; length: number; - copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): void; + copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): NodeBuffer; readUInt8(offset: number, noAsset?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; diff --git a/node/node-0.8.8.d.ts.tscparams b/node/node-0.8.8.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node/node-0.8.8.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node/node.d.ts b/node/node.d.ts index 5bdda94ee..0198b06b5 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -68,14 +68,14 @@ declare var Buffer: { ************************************************/ interface EventEmitter { - addListener(event: string, listener: Function): void; - on(event: string, listener: Function): void; - once(event: string, listener: Function): void; - removeListener(event: string, listener: Function): void; - removeAllListeners(event?: string): void; + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; - emit(event: string, arg1?: any, arg2?: any): void; + emit(event: string, arg1?: any, arg2?: any): boolean; } interface WritableStream extends EventEmitter { @@ -161,7 +161,7 @@ interface NodeBuffer { write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; length: number; - copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): void; + copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): NodeBuffer; readUInt8(offset: number, noAsset?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; @@ -209,25 +209,25 @@ declare module "querystring" { declare module "events" { export interface NodeEventEmitter { - addListener(event: string, listener: Function): void; - on(event: string, listener: Function): any; - once(event: string, listener: Function): void; - removeListener(event: string, listener: Function): void; - removeAllListeners(event?: string): void; + addListener(event: string, listener: Function): NodeEventEmitter; + on(event: string, listener: Function): NodeEventEmitter; + once(event: string, listener: Function): NodeEventEmitter; + removeListener(event: string, listener: Function): NodeEventEmitter; + removeAllListeners(event?: string): NodeEventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; - emit(event: string, arg1?: any, arg2?: any): void; + emit(event: string, arg1?: any, arg2?: any): boolean; } export class EventEmitter implements NodeEventEmitter { - addListener(event: string, listener: Function): void; - on(event: string, listener: Function): any; - once(event: string, listener: Function): void; - removeListener(event: string, listener: Function): void; - removeAllListeners(event?: string): void; + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; - emit(event: string, arg1?: any, arg2?: any): void; + emit(event: string, arg1?: any, arg2?: any): boolean; } } diff --git a/node_redis/node_redis-tests.ts.tscparams b/node_redis/node_redis-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node_redis/node_redis-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/node_redis/node_redis.d.ts.tscparams b/node_redis/node_redis.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/node_redis/node_redis.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/nodemailer/nodemailer-tests.ts.tscparams b/nodemailer/nodemailer-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/nodemailer/nodemailer-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/nodemailer/nodemailer.d.ts.tscparams b/nodemailer/nodemailer.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/nodemailer/nodemailer.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/nprogress/NProgress-tests.ts b/nprogress/NProgress-tests.ts new file mode 100644 index 000000000..d7ad68b39 --- /dev/null +++ b/nprogress/NProgress-tests.ts @@ -0,0 +1,32 @@ +/// + +function test_basics() { + NProgress.start(); + NProgress.inc(); + NProgress.done(); + NProgress.set(0.5); + + var status = NProgress.status; + var version = NProgress.version; +} + +function test_configuration() { + NProgress.configure({ + speed: 0.3 + }); + + NProgress.configure({ + trickle: false + }); + + NProgress.configure({ + ease: 'ease', + minimum: 0.09, + showSpinner: false, + speed: 420, + template: "
blah
", + trickle: false, + trickleRate: 0.42, + trickleSpeed: 42 + }); +} \ No newline at end of file diff --git a/nprogress/NProgress.d.ts b/nprogress/NProgress.d.ts new file mode 100644 index 000000000..a86558aae --- /dev/null +++ b/nprogress/NProgress.d.ts @@ -0,0 +1,105 @@ +// Type definitions for NProgress +// Project: https://github.com/rstacruz/nprogress +// Definitions by: Judah Gabriel Himango +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface NProgressStatic { + /** + * Shows the progress bar and begins trickling progress. + * @returns {NProgressConfigureOptions} The current NProgress object, useful for chaining. + */ + start(): NProgressStatic; + + /** + * Finishes loading by transitioning it to 100%, then fading out. + * @param {boolean} forceShow Forces the progress bar to show, even if it's not being shown. (The default behavior is that .done() will not do anything if .start() isn't called.) + * @returns {NProgressConfigureOptions} The current NProgress object, useful for chaining. + */ + done(forceShow?: boolean): NProgressStatic; + + /** + * Increments the progress bar with a random amount. This will never get to 100%: use it for every image load (or similar). + * @returns {NProgressConfigureOptions} The current NProgress object, useful for chaining. + */ + inc(): NProgressStatic; + + /** + * Removes the progress indicator. + */ + remove(): void; + + /** + * Sets the progress percentage. + * @param {number} progressPercent A number between 0.0 and 1.0 that represents the progress percentage. + * @returns {NProgressConfigureOptions} The current NProgress object, useful for chaining. + */ + set(progressPercent: number): NProgressStatic; + + /** + * Configures the progress indicator. + * @param {NProgressConfigureOptions} options An object containing the configuration options. + * @returns {NProgressConfigureOptions} The current NProgress object, useful for chaining. + */ + configure(options: NProgressConfigureOptions): NProgressStatic; + + /** + * Gets the NProgress version. + */ + version: string; + + /** + * Gets the status. If started, it will be the last progress number set. + */ + status: any; + + /** + * Gets whether progress has been started. + * @returns {boolean} Whether the progress has started. + */ + isStarted(): boolean; +} + +interface NProgressConfigureOptions { + + /** + * The minimum progress percentage. Default is 0.08. + */ + minimum?: number; + + /** + * How much to increase per trickle. Example: .02. Default is true. + */ + trickleRate?: number; + + /** + * How often to trickle, in milliseconds. Default is 800. + */ + trickleSpeed?: number; + + /** + * Whether to show the spinner. Defaults to true. Default is true. + */ + showSpinner?: boolean; + + /** + * Whether to enable trickling the progress. Default is true. + */ + trickle?: boolean; + + /** + * The CSS easing animation to use. Default is 'ease'. + */ + ease?: string; + + /** + * The animation speed in milliseconds. Default is 200. + */ + speed?: number; + + /** + * The HTML markup inserted for the progress indicator. To keep the progress bar working, keep an element with role='bar' in there. + */ + template?: string; +} + +declare var NProgress: NProgressStatic; \ No newline at end of file diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts new file mode 100644 index 000000000..39355bb4e --- /dev/null +++ b/openlayers/openlayers.d.ts @@ -0,0 +1,4856 @@ +// Type definitions for OpenLayers.js 2.10 +// Project: https://github.com/openlayers/openlayers +// Definitions by: Ilya Bolkhovsky +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module OpenLayers { + + export interface MapOptions { + + projection?: string; + + maxExtend?: Bounds; + + center?: LonLat; + } + + export interface DistanceOptions { + /** + * Return details from the distance calculation. Default is false. + */ + details?: boolean; + + /** + * Calculate the distance from this geometry to the nearest edge of the target geometry. Default is true. If true, calling distanceTo from a geometry that is wholly contained within the target will result in a non-zero distance. If false, whenever geometries intersect, calling distanceTo will return 0. If false, details cannot be returned. + */ + edge?: boolean; + } + + export interface BoundsOptions { + /** + * Whether or not to include the border. Default is true. + */ + inclusive?: boolean; + + /** + * If a worldBounds is provided, the + * ll will be considered as contained if it exceeds the world bounds, + * but can be wrapped around the dateline so it is contained by this + * bounds. + */ + worldBounds?: Bounds; + } + + export interface WrapDateLineOptions { + /** + * Allow for a margin of error + * with the 'left' value of this + * bound. + * Default is 0. + */ + leftTolerance?: number; + + /** + * Allow for a margin of error + * with the 'right' value of this + * bound. + * Default is 0. + */ + rightTolerance?: number; + } + + export interface LayerOptions { + + } + + export class Animation { + // TODO + } + + export class String { + // TODO + } + + export class Number { + // TODO + } + + export class Function { + // TODO + } + + export class Array { + // TODO + } + + export class Console { + // TODO + } + + export class Control { + // TODO + } + + export class Event { + // TODO + } + + export class Events { + // TODO + } + + export class Feature { + // TODO + } + + export class Filter { + // TODO + } + + export class Format { + // TODO + } + + export class Handler { + // TODO + } + + export class Icon { + // TODO + } + + export class Kinetic { + // TODO + } + + export class Lang { + // TODO + } + + export class Layer { + /** + * + */ + id: string; + + /** + * + */ + name: string; + + /** + * + */ + div: HTMLElement; + + /** + * The layer's opacity. Float number between 0.0 and 1.0. + */ + opacity: number; + + /** + * If a layer's display should not be scale-based, this should + * be set to true. This will cause the layer, as an overlay, to always + * be 'active', by always returning true from the calculateInRange() + * function. + * + * If not explicitly specified for a layer, its value will be + * determined on startup in initResolutions() based on whether or not + * any scale-specific properties have been set as options on the + * layer. If no scale-specific options have been set on the layer, we + * assume that it should always be in range. + */ + alwaysInRange: boolean; + + /** + * The properties that are used for calculating resolutions information. + */ + RESOLUTION_PROPERTIES: string[]; + + /** + * APIProperty: events + * {} + * + * Register a listener for a particular event with the following syntax: + * (code) + * layer.events.register(type, obj, listener); + * (end) + * + * Listeners will be called with a reference to an event object. The + * properties of this event depends on exactly what happened. + * + * All event objects have at least the following properties: + * object - {Object} A reference to layer.events.object. + * element - {DOMElement} A reference to layer.events.element. + * + * Supported map event types: + * loadstart - Triggered when layer loading starts. When using a Vector + * layer with a Fixed or BBOX strategy, the event object includes + * a *filter* property holding the OpenLayers.Filter used when + * calling read on the protocol. + * loadend - Triggered when layer loading ends. When using a Vector layer + * with a Fixed or BBOX strategy, the event object includes a + * *response* property holding an OpenLayers.Protocol.Response object. + * visibilitychanged - Triggered when the layer's visibility property is + * changed, e.g. by turning the layer on or off in the layer switcher. + * Note that the actual visibility of the layer can also change if it + * gets out of range (see ). If you also want to catch + * these cases, register for the map's 'changelayer' event instead. + * move - Triggered when layer moves (triggered with every mousemove + * during a drag). + * moveend - Triggered when layer is done moving, object passed as + * argument has a zoomChanged boolean property which tells that the + * zoom has changed. + * added - Triggered after the layer is added to a map. Listeners will + * receive an object with a *map* property referencing the map and a + * *layer* property referencing the layer. + * removed - Triggered after the layer is removed from the map. Listeners + * will receive an object with a *map* property referencing the map and + * a *layer* property referencing the layer. + */ + events: Events; + + /** + * This variable is set when the layer is added to + * the map, via the accessor function setMap() + */ + map: Map; + + /** + * Whether or not the layer is a base layer. This should be set + * individually by all subclasses. Default is false + */ + isBaseLayer: boolean; + + /** + * The layer's images have an alpha channel. Default is false. + */ + alpha: boolean; + + /** + * Display the layer's name in the layer switcher. Default is true + */ + displayInLayerSwitcher: boolean; + + /** + * The layer should be displayed in the map. Default is true. + */ + visibility: boolean; + + /** + * Attribution string, displayed when an + * has been added to the map. + */ + attribution: string; + + /** + * The current map resolution is within the layer's min/max + * range. This is set in whenever the zoom + * changes. + */ + inRange: boolean; + + /** + * For layers with a gutter, the image is larger than + * the tile by twice the gutter in each dimension. + */ + imageSize: Size; + + /** + * An optional object whose properties will be set on the layer. + * Any of the layer properties can be set as a property of the options + * object and sent to the constructor when the layer is created. + */ + options: Object; + + /** + * An optional object whose properties will be set on the layer. + * Any of the layer properties can be set as a property of the options + * object and sent to the constructor when the layer is created. + */ + eventListeners: Object; + + /** + * Determines the width (in pixels) of the gutter around image + * tiles to ignore. By setting this property to a non-zero value, + * images will be requested that are wider and taller than the tile + * size by a value of 2 x gutter. This allows artifacts of rendering + * at tile edges to be ignored. Set a gutter value that is equal to + * half the size of the widest symbol that needs to be displayed. + * Defaults to zero. Non-tiled layers always have zero gutter. + */ + gutter: number; + + /** + * Specifies the projection of the layer. + * Can be set in the layer options. If not specified in the layer options, + * it is set to the default projection specified in the map, + * when the layer is added to the map. + * Projection along with default maxExtent and resolutions + * are set automatically with commercial baselayers in EPSG:3857, + * such as Google, Bing and OpenStreetMap, and do not need to be specified. + * Otherwise, if specifying projection, also set maxExtent, + * maxResolution or resolutions as appropriate. + * When using vector layers with strategies, layer projection should be set + * to the projection of the source data if that is different from the map default. + */ + projection: Projection; + + /** + * The layer map units. Defaults to null. Possible values + * are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'. + * Normally taken from the projection. + * Only required if both map and layers do not define a projection, + * or if they define a projection which does not define units. + */ + units: string; + + /** + * An array of map scales in descending order. The values in the + * array correspond to the map scale denominator. Note that these + * values only make sense if the display (monitor) resolution of the + * client is correctly guessed by whomever is configuring the + * application. In addition, the units property must also be set. + * Use instead wherever possible. + */ + scales: Array; + + /** + * A list of map resolutions (map units per pixel) in descending + * order. If this is not set in the layer constructor, it will be set + * based on other resolution related properties (maxExtent, + * maxResolution, maxScale, etc.). + */ + resolutions: Array; + + /** + * The maximum extent for the layer. Defaults to null. + */ + maxExtent: Bounds; + + /** + * The minimum extent for the layer. Defaults to null. + */ + minExtent: Bounds; + + /** + * Default max is 360 deg / 256 px, which corresponds to + * zoom level 0 on gmaps. Specify a different value in the layer + * options if you are not using the default + * and displaying the whole world. + */ + maxResolution: number; + + /** + * + */ + minResolution: number; + + /** + * + */ + numZoomLevels: number; + + /** + * + */ + minScale: number; + + /** + * + */ + maxScale: number; + + /** + * Request map tiles that are completely outside of the max + * extent for this layer. Defaults to false. + */ + displayOutsideMaxExtent: boolean; + + /** + * Wraps the world at the international dateline, so the map can + * be panned infinitely in longitudinal direction. Only use this on the + * base layer, and only if the layer's maxExtent equals the world bounds. + */ + wrapDateLine: boolean; + + /** + * This object can be used to store additional information on a + * layer object. + */ + metadata: Object; + + /** + * Constructor: OpenLayers.Layer + * + * Parameters: + * name - {String} The layer name + * options - {Object} Hashtable of extra options to tag onto the layer + */ + constructor(name: string, options: LayerOptions); + + /** + * Method: destroy + * Destroy is a destructor: this is to alleviate cyclic references which + * the Javascript garbage cleaner can not take care of on its own. + * + * Parameters: + * setNewBaseLayer - {Boolean} Set a new base layer when this layer has + * been destroyed. Default is true. + */ + destroy(setNewBaseLayer?: boolean): void; + + /** + * Method: clone + * + * Parameters: + * obj - {} The layer to be cloned + * + * Returns: + * {} An exact clone of this + */ + clone(): Layer; + + /** + * Method: getOptions + * Extracts an object from the layer with the properties that were set as + * options, but updates them with the values currently set on the + * instance. + * + * Returns: + * {Object} the of the layer, representing the current state. + */ + private getOptions(): LayerOptions; + + /** + * APIMethod: setName + * Sets the new layer name for this layer. Can trigger a changelayer event + * on the map. + * + * Parameters: + * newName - {String} The new name. + */ + setName(newName: string): void; + + /** + * APIMethod: addOptions + * + * Parameters: + * newOptions - {Object} + * reinitialize - {Boolean} If set to true, and if resolution options of the + * current baseLayer were changed, the map will be recentered to make + * sure that it is displayed with a valid resolution, and a + * changebaselayer event will be triggered. + */ + addOptions(newOptions: LayerOptions, reinitialize: boolean): void; + + /** + * This function can be implemented by subclasses + */ + onMapResize(): void; + + /** + * APIMethod: redraw + * Redraws the layer. Returns true if the layer was redrawn, false if not. + * + * Returns: + * {Boolean} The layer was redrawn. + */ + redraw(): void; + + /** + * Method: moveTo + * + * Parameters: + * bounds - {} + * zoomChanged - {Boolean} Tells when zoom has changed, as layers have to + * do some init work in that case. + * dragging - {Boolean} + */ + moveTo(bounds: Bounds, zoomChanged: boolean, dragging: boolean): void; + + /** + * Method: moveByPx + * Move the layer based on pixel vector. To be implemented by subclasses. + * + * Parameters: + * dx - {Number} The x coord of the displacement vector. + * dy - {Number} The y coord of the displacement vector. + */ + moveByPx(dx: number, dy: number): void; + + /** + * Method: setMap + * Set the map property for the layer. This is done through an accessor + * so that subclasses can override this and take special action once + * they have their map variable set. + * + * Here we take care to bring over any of the necessary default + * properties from the map. + * + * Parameters: + * map - {} + */ + setMap(map: Map): void; + + /** + * Method: afterAdd + * Called at the end of the map.addLayer sequence. At this point, the map + * will have a base layer. To be overridden by subclasses. + */ + private afterAdd(): void; + + /** + * APIMethod: removeMap + * Just as setMap() allows each layer the possibility to take a + * personalized action on being added to the map, removeMap() allows + * each layer to take a personalized action on being removed from it. + * For now, this will be mostly unused, except for the EventPane layer, + * which needs this hook so that it can remove the special invisible + * pane. + * + * Parameters: + * map - {} + */ + removeMap(map: Map): void; + + /** + * APIMethod: getImageSize + * + * Parameters: + * bounds - {} optional tile bounds, can be used + * by subclasses that have to deal with different tile sizes at the + * layer extent edges (e.g. Zoomify) + * + * Returns: + * {} The size that the image should be, taking into + * account gutters. + */ + getImageSize(bounds: Bounds): Size; + + /** + * APIMethod: setTileSize + * Set the tile size based on the map size. This also sets layer.imageSize + * or use by Tile.Image. + * + * Parameters: + * size - {} + */ + setTileSize(size: Size): void; + + /** + * APIMethod: getVisibility + * + * Returns: + * {Boolean} The layer should be displayed (if in range). + */ + getVisibility(): boolean; + + /** + * APIMethod: setVisibility + * Set the visibility flag for the layer and hide/show & redraw + * accordingly. Fire event unless otherwise specified + * + * Note that visibility is no longer simply whether or not the layer's + * style.display is set to "block". Now we store a 'visibility' state + * property on the layer class, this allows us to remember whether or + * not we *desire* for a layer to be visible. In the case where the + * map's resolution is out of the layer's range, this desire may be + * subverted. + * + * Parameters: + * visibility - {Boolean} Whether or not to display the layer (if in range) + */ + setVisibility(visibility: boolean): void; + + /** + * APIMethod: display + * Hide or show the Layer. This is designed to be used internally, and + * is not generally the way to enable or disable the layer. For that, + * use the setVisibility function instead.. + * + * Parameters: + * display - {Boolean} + */ + display(display: boolean): void; + + /** + * APIMethod: calculateInRange + * + * Returns: + * {Boolean} The layer is displayable at the current map's current + * resolution. Note that if 'alwaysInRange' is true for the layer, + * this function will always return true. + */ + calculateInRange(): boolean; + + /** + * APIMethod: setIsBaseLayer + * + * Parameters: + * isBaseLayer - {Boolean} + */ + setIsBaseLayer(isBaseLayer: boolean): void; + + /********************************************************/ + /* */ + /* Baselayer Functions */ + /* */ + /********************************************************/ + + /** + * Method: initResolutions + * This method's responsibility is to set up the 'resolutions' array + * for the layer -- this array is what the layer will use to interface + * between the zoom levels of the map and the resolution display + * of the layer. + * + * The user has several options that determine how the array is set up. + * + * For a detailed explanation, see the following wiki from the + * openlayers.org homepage: + * http://trac.openlayers.org/wiki/SettingZoomLevels + */ + private initResolutions(): void; + + /** + * Method: resolutionsFromScales + * Derive resolutions from scales. + * + * Parameters: + * scales - {Array(Number)} Scales + * + * Returns + * {Array(Number)} Resolutions + */ + private resolutionsFromScales(scales: number[]): number[]; + + /** + * Method: calculateResolutions + * Calculate resolutions based on the provided properties. + * + * Parameters: + * props - {Object} Properties + * + * Returns: + * {Array({Number})} Array of resolutions. + */ + private calculateResolutions(props: Object): number[]; + + /** + * APIMethod: getResolution + * + * Returns: + * {Float} The currently selected resolution of the map, taken from the + * resolutions array, indexed by current zoom level. + */ + getResolution(): number; + + /** + * APIMethod: getExtent + * + * Returns: + * {} A Bounds object which represents the lon/lat + * bounds of the current viewPort. + */ + getExtent(): Bounds; + + /** + * APIMethod: getZoomForExtent + * + * Parameters: + * extent - {} + * closest - {Boolean} Find the zoom level that most closely fits the + * specified bounds. Note that this may result in a zoom that does + * not exactly contain the entire extent. + * Default is false. + * + * Returns: + * {Integer} The index of the zoomLevel (entry in the resolutions array) + * for the passed-in extent. We do this by calculating the ideal + * resolution for the given extent (based on the map size) and then + * calling getZoomForResolution(), passing along the 'closest' + * parameter. + */ + getZoomForExtent(extent: Bounds, closest?: boolean): number; + + /** + * Method: getDataExtent + * Calculates the max extent which includes all of the data for the layer. + * This function is to be implemented by subclasses. + * + * Returns: + * {} + */ + private getDataExtent(): Bounds; + + /** + * APIMethod: getResolutionForZoom + * + * Parameters: + * zoom - {Float} + * + * Returns: + * {Float} A suitable resolution for the specified zoom. + */ + getResolutionForZoom(zoom: number): number; + + /** + * APIMethod: getZoomForResolution + * + * Parameters: + * resolution - {Float} + * closest - {Boolean} Find the zoom level that corresponds to the absolute + * closest resolution, which may result in a zoom whose corresponding + * resolution is actually smaller than we would have desired (if this + * is being called from a getZoomForExtent() call, then this means that + * the returned zoom index might not actually contain the entire + * extent specified... but it'll be close). + * Default is false. + * + * Returns: + * {Integer} The index of the zoomLevel (entry in the resolutions array) + * that corresponds to the best fit resolution given the passed in + * value and the 'closest' specification. + */ + getZoomForResolution(resolution: number, closest?: boolean): number; + + /** + * APIMethod: getLonLatFromViewPortPx + * + * Parameters: + * viewPortPx - {|Object} An OpenLayers.Pixel or + * an object with a 'x' + * and 'y' properties. + * + * Returns: + * {} An OpenLayers.LonLat which is the passed-in + * view port , translated into lon/lat by the layer. + */ + getLonLatFromViewPortPx(viewPortPx: Pixel): LonLat; + + /** + * APIMethod: getViewPortPxFromLonLat + * Returns a pixel location given a map location. This method will return + * fractional pixel values. + * + * Parameters: + * lonlat - {|Object} An OpenLayers.LonLat or + * an object with a 'lon' + * and 'lat' properties. + * + * Returns: + * {} An which is the passed-in + * lonlat translated into view port pixels. + */ + getViewPortPxFromLonLat(lonlat: LonLat, resolution: number): Pixel; + + /** + * APIMethod: setOpacity + * Sets the opacity for the entire layer (all images) + * + * Parameters: + * opacity - {Float} + */ + setOpacity(opacity: number): void; + + /** + * Method: getZIndex + * + * Returns: + * {Integer} the z-index of this layer + */ + private getZIndex(): number; + + /** + * Method: setZIndex + * + * Parameters: + * zIndex - {Integer} + */ + private setZIndex(zIndex: number): void; + + /** + * Method: adjustBounds + * This function will take a bounds, and if wrapDateLine option is set + * on the layer, it will return a bounds which is wrapped around the + * world. We do not wrap for bounds which *cross* the + * maxExtent.left/right, only bounds which are entirely to the left + * or entirely to the right. + * + * Parameters: + * bounds - {} + */ + private adjustBounds(bounds: Bounds): Bounds; + + static CLASS_NAME: string; + } + + export class Marker { + // TODO + } + + export class Popup { + // TODO + } + + export class Protocol { + // TODO + } + + export class Renderer { + // TODO + } + + export class Request { + // TODO + } + + export class Rule { + // TODO + } + + export class SingleFile { + // TODO + } + + export class Spherical { + // TODO + } + + export class Strategy { + // TODO + } + + export class Style { + // TODO + } + + export class Style2 { + // TODO + } + + export class StyleMap { + // TODO + } + + export class Symbolizer { + // TODO + } + + export class Tile { + // TODO + } + + export class TileManager { + // TODO + } + + export class Tween { + // TODO + } + + export class Util { + // TODO + } + + export class WPSClient { + // TODO + } + + export class WPSProcess { + // TODO + } + + export class Geometry { + /** + * A unique identifier for this geometry. + */ + id: string; + + /** + * This is set when a Geometry is added as component + * of another geometry + */ + parent: Geometry; + + /** + * The bounds of this geometry + */ + bounds: Bounds; + + /** + * A Geometry is a description of a geographic object. + */ + constructor(); + + /** + * Destroy this geometry. + */ + destroy(): void; + + /** + * Create a clone of this geometry. Does not set any non-standard properties of the cloned geometry. + */ + clone(): Geometry; + + /** + * Set the bounds for this Geometry. + */ + setBounds(bounds: Bounds): void; + + /** + * Nullify this components bounds and that of its parent as well. + */ + clearBounds(): void; + + /** + * Extend the existing bounds to include the new bounds. + * If geometry's bounds is not yet set, then set a new Bounds. + */ + extendBounds(newBounds: Bounds): void; + + /** + * Get the bounds for this Geometry. If bounds is not set, it is calculated again, this makes queries faster. + */ + getBounds(): Bounds; + + /** + * Calculate the closest distance between two geometries (on the x-y plane). + */ + distanceTo(geometry: Geometry, options: Object): Object; + + /** + * Return a list of all points in this geometry. + */ + getVertices(nodes: boolean): Array; + + /** + * Return whether or not the geometry is at the specified location + */ + atPoint(lonlat: LonLat, toleranceLon?: number, toleranceLat?: number): boolean; + + /** + * Returns the length of the collection by summing its parts + */ + getLength(): number; + + /** + * Returns the area of the collection by summing its parts + */ + getArea(): number; + + /** + * Returns a text representation of the geometry. If the WKT format is + * included in a build, this will be the Well-Known Text + * representation. + */ + toString(): string; + + /** + * Calculate the centroid of this geometry. This method is defined in subclasses. + */ + getCentroid(): Geometry.Point; + + static CLASS_NAME: string; + } + + export class Projection { + /** + * This class offers several methods for interacting with a wrapped pro4js projection object. + */ + constructor(projCode: string, options?: any); + + /** + * Get the string SRS code. + */ + getCode(): string; + + /** + * Get the units string for the projection -- returns null if proj4js is not available. + */ + getUnits(): string; + + /** + * Set a custom transform method between two projections. Use this method in cases where the proj4js lib is not available or where custom projections need to be handled. + */ + addTransform(from: string, to: string, method: () => void): void; + + /** + * Transform a point coordinate from one projection to another. Note that the input point is transformed in place. + */ + transform(point: Geometry.Point, source: Projection, dest: OpenLayers.Projection): Object; + + /** + * Transform a point coordinate from one projection to another. Note that the input point is transformed in place. + */ + transform(point: Object, source: Projection, dest: OpenLayers.Projection): Object; + + /** + * A null transformation useful for defining projection aliases when proj4js is not available: + */ + nullTransform(point: Object): Function; + } + + export class Bounds { + /** + * Minimum horizontal coordinate. + */ + left: number; + + /** + * Minimum vertical coordinate. + */ + bottom: number; + + /** + * Maximum horizontal coordinate. + */ + right: number; + + /** + * Maximum vertical coordinate. + */ + top: number; + + /** + * Construct a new bounds object. Coordinates can either be passed as four + * arguments, or as a single argument. + */ + constructor(left: number, bottom: number, right: number, top: number); + + /** + * Construct a new bounds object. Coordinates can either be passed as four + * arguments, or as a single argument. + */ + constructor(bounds: number[]); + + /** + * Create a cloned instance of this bounds. + */ + clone(): Bounds; + + /** + * Test a two bounds for equivalence. + */ + equals(bounds: Bounds): boolean; + + /** + * Returns a string representation of the bounds object. + */ + toString(): string; + + /** + * Returns an array representation of the bounds object. + */ + toArray(reverseAxisOrder?: boolean): number[]; + + /** + * Returns a boundingbox-string representation of the bounds object. + */ + toBBOX(decimal?: number, reverseAxisOrder?: boolean): string; + + /** + * Create a new polygon geometry based on this bounds. + */ + toGeometry(): OpenLayers.Geometry.Polygon; + + /** + * Returns the width of the bounds. + */ + getWidth(): number; + + /** + * Returns the height of the bounds. + */ + getHeight(): number; + + /** + * + */ + getSize(): Size; + + /** + * Returns the Pixel object which represents the center of the bounds. + */ + getCenterPixel(): Pixel; + + /** + * Returns the LonLat object which represents the center of the bounds. + */ + getCenterLonLat(): LonLat; + + /** + * Scales the bounds around a pixel or lonlat. Note that the new + * bounds may return non-integer properties, even if a pixel + * is passed. + */ + scale(ratio: number, origin?: Pixel): void; + + /** + * Scales the bounds around a pixel or lonlat. Note that the new + * bounds may return non-integer properties, even if a pixel + * is passed. + */ + scale(ratio: number, origin?: LonLat): void; + + /** + * Shifts the coordinates of the bound by the given horizontal and vertical + * deltas. + */ + add(x: number, y: number): Bounds; + + /** + * Extend the bounds. + */ + extend(object: LonLat): void; + + /** + * Extend the bounds. + */ + extend(object: Geometry.Point): void; + + /** + * Extend the bounds. + */ + extend(object: Bounds): void; + + /** + * + */ + extendXY(x: number, y: number): void; + + /** + * Returns whether the bounds object contains the given . + */ + containsLonLat(ll: LonLat, options: BoundsOptions): boolean; + + /** + * Returns whether the bounds object contains the given . + */ + containsLonLat(ll: Object, options: BoundsOptions): boolean; + + /** + * Returns whether the bounds object contains the given . + */ + containsPixel(px: Pixel, inclusive: boolean): boolean; + + /** + * Returns whether the bounds object contains the given x and y. + */ + contains(x: number, y: number, inclusive?: boolean): boolean; + + /** + * Determine whether the target bounds intersects this bounds. Bounds are + * considered intersecting if any of their edges intersect or if one + * bounds contains the other. + */ + intersectsBounds(bounds: Bounds, options: BoundsOptions): boolean; + + /** + * Returns whether the bounds object contains the given . + */ + containsBounds(bounds: Bounds, partial: boolean, inclusive: boolean): boolean; + + /** + * Returns the the quadrant ("br", "tr", "tl", "bl") in which the given + * lies. + */ + determineQuadrant(lonlat: LonLat): string; + + /** + * Transform the Bounds object from source to dest. + */ + transform(source: Projection, dest: Projection): Bounds; + + /** + * Wraps the bounds object around the dateline. + */ + wrapDateLine(maxExtent: Bounds, options: WrapDateLineOptions): Bounds; + + static CLASS_NAME: string; + + /** + * Alternative constructor that builds a new OpenLayers.Bounds from a + * parameter string. + */ + static fromString(str: string, reverseAxisOrder: boolean): Bounds; + + /** + * Alternative constructor that builds a new OpenLayers.Bounds from an array. + */ + static fromArray(bbox: number[], reverseAxisOrder: boolean): Bounds; + + /** + * Alternative constructor that builds a new OpenLayers.Bounds from a size. + */ + static fromSize(size: Size): Bounds; + + /** + * Get the opposite quadrant for a given quadrant string. + */ + static oppositeQuadrant(quadrant: string): string; + } + + export class LonLat { + /** + * Create a new map location. Coordinates can be passed either as two arguments, or as a single argument. + */ + constructor(lon: number, lat: number); + + /** + * Create a new map location. Coordinates can be passed either as two arguments, or as a single argument. + */ + constructor(lonlat: number[]); + + /** + * Shortened String representation of OpenLayers.LonLat object. + */ + toShortString(): string; + + /** + * New OpenLayers.LonLat object with the same lon and lat values + */ + clone(): LonLat; + + /** + * A new OpenLayers.LonLat object with the lon and lat passed-in added to this’s. + */ + add(lon: number, lat: number): LonLat; + + /** + * Boolean value indicating whether the passed-in OpenLayers.LonLat object has the same lon and lat components as this. Note: if ll passed in is null, returns false. + */ + equals(ll: LonLat): boolean; + + /** + * Transform the LonLat object from source to dest. This transformation is in place: if you want a new lonlat, use .clone() first. + */ + transform(source: Projection, dest: Projection): LonLat; + + /** + * Returns a copy of this lonlat, but wrapped around the "dateline" (as specified by the borders of maxExtent). + */ + wrapDateLine(maxExtend: Bounds): LonLat; + } + + export class Map { + /** + * Unique identifier for the map + */ + id: string; + + /** + * For a base layer that supports it, allow the map resolution + * to be set to a value between one of the values in the resolutions + * array. Default is false. + */ + fractionalZoom: boolean; + + /** + * An events object that handles all + * events on the map + */ + events: Events; + + /** + * Allow the map to function with "overlays" only. Defaults to + * false. If true, the lowest layer in the draw order will act as + * the base layer. In addition, if set to true, all layers will + * have isBaseLayer set to false when they are added to the map. + */ + allOverlays: boolean; + + /** + * The element that contains the map (or an id for that element). + */ + div: Object; + + /** + * The map is currently being dragged. + */ + dragging: boolean; + + /** + * Size of the main div (this.div) + */ + size: Size; + + /** + * The element that represents the map viewport + */ + viewPortDiv: HTMLDivElement; + + /** + * The lonlat at which the later container was re-initialized (on-zoom) + */ + layerContainerOrigin: LonLat; + + /** + * The element that contains the layers. + */ + layerContainerDiv: HTMLDivElement; + + /** + * Ordered list of layers in the map + */ + layers: Layer[]; + + /** + * List of controls associated with the map. + */ + controls: Control[]; + + /** + * List of popups associated with the map + */ + popups: Popup[]; + + /** + * The currently selected base layer. This determines + * min/max zoom level, projection, etc. + */ + baseLayer: Layer; + + /** + * The current center of the map + */ + center: LonLat; + + /** + * The resolution of the map. + */ + resolution: number; + + /** + * The current zoom level of the map + */ + zoom: number; + + /** + * The ratio of the current extent within which panning will tween. + */ + panRatio: number; + + /** + * The options object passed to the class constructor. Read-only. + */ + options: Object; + + /** + * Set in the map options to override the default tile size for this map. + */ + tileSize: Size; + + /** + * Set in the map options to specify the default projection + * for layers added to this map. When using a projection other than EPSG:4326 + * (CRS:84, Geographic) or EPSG:3857 (EPSG:900913, Web Mercator), + * also set maxExtent, maxResolution or resolutions. Default is "EPSG:4326". + * Note that the projection of the map is usually determined + * by that of the current baseLayer (see and ). + */ + projection: string; + + /** + * The map units. Possible values are 'degrees' (or 'dd'), 'm', + * 'ft', 'km', 'mi', 'inches'. Normally taken from the projection. + * Only required if both map and layers do not define a projection, + * or if they define a projection which does not define units + */ + units: string; + + /** + * A list of map resolutions (map units per pixel) in + * descending order. If this is not set in the layer constructor, it + * will be set based on other resolution related properties + * (maxExtent, maxResolution, maxScale, etc.). + */ + resolutions: number[]; + + /** + * Required if you are not displaying the whole world on a tile + * with the size specified in . + */ + maxResolution: number; + + /** + * APIProperty: minResolution + * {Float} + */ + minResolution: number; + + /** + * APIProperty: maxScale + * {Float} + */ + maxScale: number; + + /** + * APIProperty: minScale + * {Float} + */ + minScale: number; + + /** + * APIProperty: maxExtent + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * The maximum extent for the map. + * Default depends on projection; if this is one of those defined in OpenLayers.Projection.defaults + * (EPSG:4326 or web mercator), maxExtent will be set to the value defined there; + * else, defaults to null. + * To restrict user panning and zooming of the map, use instead. + * The value for will change calculations for tile URLs. + */ + maxExtent: Bounds; + + /** + * APIProperty: minExtent + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * The minimum extent for the map. Defaults to null. + */ + minExtent: Bounds; + + /** + * APIProperty: restrictedExtent + * Limit map navigation to this extent where possible. + * If a non-null restrictedExtent is set, panning will be restricted + * to the given bounds. In addition, zooming to a resolution that + * displays more than the restricted extent will center the map + * on the restricted extent. If you wish to limit the zoom level + * or resolution, use maxResolution. + */ + restrictedExtent: Bounds; + + /** + * APIProperty: numZoomLevels + * {Integer} Number of zoom levels for the map. Defaults to 16. Set a + * different value in the map options if needed. + */ + numZoomLevels: number; + + /** + * APIProperty: theme + * {String} Relative path to a CSS file from which to load theme styles. + * Specify null in the map options (e.g. {theme: null}) if you + * want to get cascading style declarations - by putting links to + * stylesheets or style declarations directly in your page. + */ + theme: string; + + /** + * APIProperty: displayProjection + * {} Requires proj4js support for projections other + * than EPSG:4326 or EPSG:900913/EPSG:3857. Projection used by + * several controls to display data to user. If this property is set, + * it will be set on any control which has a null displayProjection + * property at the time the control is added to the map. + */ + displayProjection: Projection; + + /** + * APIProperty: fallThrough + * {Boolean} Should OpenLayers allow events on the map to fall through to + * other elements on the page, or should it swallow them? (#457) + * Default is to swallow. + */ + fallThrough: boolean; + + /** + * APIProperty: autoUpdateSize + * {Boolean} Should OpenLayers automatically update the size of the map + * when the resize event is fired. Default is true. + */ + autoUpdateSize: boolean; + + /** + * APIProperty: eventListeners + * {Object} If set as an option at construction, the eventListeners + * object will be registered with . Object + * structure must be a listeners object as shown in the example for + * the events.on method. + */ + eventListeners: Object; + + /** + * Property: panTween + * {} Animated panning tween object, see panTo() + */ + panTween: Tween; + + /** + * APIProperty: panMethod + * {Function} The Easing function to be used for tweening. Default is + * OpenLayers.Easing.Expo.easeOut. Setting this to 'null' turns off + * animated panning. + */ + panMethod: () => void; + + /** + * Property: panDuration + * {Integer} The number of steps to be passed to the + * OpenLayers.Tween.start() method when the map is + * panned. + * Default is 50. + */ + panDuration: number; + + /** + * Property: zoomTween + * {} Animated zooming tween object, see zoomTo() + */ + zoomTween: Tween; + + /** + * APIProperty: zoomMethod + * {Function} The Easing function to be used for tweening. Default is + * OpenLayers.Easing.Quad.easeOut. Setting this to 'null' turns off + * animated zooming. + */ + zoomMethod: () => void; + + /** + * Property: zoomDuration + * {Integer} The number of steps to be passed to the + * OpenLayers.Tween.start() method when the map is zoomed. + * Default is 20. + */ + zoomDuration: number; + + /** + * Property: paddingForPopups + * {} Outside margin of the popup. Used to prevent + * the popup from getting too close to the map border. + */ + paddingForPopups: Bounds; + + /** + * Property: layerContainerOriginPx + * {Object} Cached object representing the layer container origin (in pixels). + */ + layerContainerOriginPx: Object; + + /** + * Property: minPx + * {Object} An object with a 'x' and 'y' values that is the lower + * left of maxExtent in viewport pixel space. + * Used to verify in moveByPx that the new location we're moving to + * is valid. It is also used in the getLonLatFromViewPortPx function + * of Layer. + */ + minPx: { x: number; y: number }; + + /** + * Property: maxPx + * {Object} An object with a 'x' and 'y' values that is the top + * right of maxExtent in viewport pixel space. + * Used to verify in moveByPx that the new location we're moving to + * is valid. + */ + maxPx: { x: number; y: number }; + + /** + * Constructor: OpenLayers.Map + * Constructor for a new OpenLayers.Map instance. There are two possible + * ways to call the map constructor. See the examples below. + * + * Parameters: + * div - {DOMElement|String} The element or id of an element in your page + * that will contain the map. May be omitted if the
option is + * provided or if you intend to call the method later. + * options - {Object} Optional object with properties to tag onto the map. + * + * Valid options (in addition to the listed API properties): + * center - {|Array} The default initial center of the map. + * If provided as array, the first value is the x coordinate, + * and the 2nd value is the y coordinate. + * Only specify if is provided. + * Note that if an ArgParser/Permalink control is present, + * and the querystring contains coordinates, center will be set + * by that, and this option will be ignored. + * zoom - {Number} The initial zoom level for the map. Only specify if + * is provided. + * Note that if an ArgParser/Permalink control is present, + * and the querystring contains a zoom level, zoom will be set + * by that, and this option will be ignored. + * + * Examples: + * (code) + * // create a map with default options in an element with the id "map1" + * var map = new OpenLayers.Map("map1"); + * + * // create a map with non-default options in an element with id "map2" + * var options = { + * projection: "EPSG:3857", + * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000), + * center: new OpenLayers.LonLat(-12356463.476333, 5621521.4854095) + * }; + * var map = new OpenLayers.Map("map2", options); + * + * // map with non-default options - same as above but with a single argument, + * // a restricted extent, and using arrays for bounds and center + * var map = new OpenLayers.Map({ + * div: "map_id", + * projection: "EPSG:3857", + * maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146], + * restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962], + * center: [-12356463.476333, 5621521.4854095] + * }); + * + * // create a map without a reference to a container - call render later + * var map = new OpenLayers.Map({ + * projection: "EPSG:3857", + * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000) + * }); + * (end) + */ + constructor(id: HTMLElement, options?: MapOptions); + constructor(id: string, options?: MapOptions); + + /** + * APIMethod: getViewport + * Get the DOMElement representing the view port. + * + * Returns: + * {DOMElement} + */ + getViewport(): HTMLElement; + + /** + * APIMethod: render + * Render the map to a specified container. + * + * Parameters: + * div - {String|DOMElement} The container that the map should be rendered + * to. If different than the current container, the map viewport + * will be moved from the current to the new container. + */ + render(div: string): void; + render(div: HTMLElement): void; + + /** + * Method: unloadDestroy + * Function that is called to destroy the map on page unload. stored here + * so that if map is manually destroyed, we can unregister this. + */ + private unloadDestroy(): () => void; + + /** + * Method: updateSizeDestroy + * When the map is destroyed, we need to stop listening to updateSize + * events: this method stores the function we need to unregister in + * non-IE browsers. + */ + private updateSizeDestroy: () => void; + + /** + * APIMethod: destroy + * Destroy this map. + * Note that if you are using an application which removes a container + * of the map from the DOM, you need to ensure that you destroy the + * map *before* this happens; otherwise, the page unload handler + * will fail because the DOM elements that map.destroy() wants + * to clean up will be gone. (See + * http://trac.osgeo.org/openlayers/ticket/2277 for more information). + * This will apply to GeoExt and also to other applications which + * modify the DOM of the container of the OpenLayers Map. + */ + destroy(): void; + + /** + * APIMethod: setOptions + * Change the map options + * + * Parameters: + * options - {Object} Hashtable of options to tag to the map + */ + setOptions(options: {}): void; + + /** + * APIMethod: getTileSize + * Get the tile size for the map + * + * Returns: + * {} + */ + getTileSize(): Size; + + /** + * APIMethod: getBy + * Get a list of objects given a property and a match item. + * + * Parameters: + * array - {String} A property on the map whose value is an array. + * property - {String} A property on each item of the given array. + * match - {String | Object} A string to match. Can also be a regular + * expression literal or object. In addition, it can be any object + * with a method named test. For reqular expressions or other, if + * match.test(map[array][i][property]) evaluates to true, the item will + * be included in the array returned. If no items are found, an empty + * array is returned. + * + * Returns: + * {Array} An array of items where the given property matches the given + * criteria. + */ + getBy(array: string, property: string, match: string): Array; + getBy(array: string, property: string, match: Object): Array; + + /** + * APIMethod: getLayersBy + * Get a list of layers with properties matching the given criteria. + * + * Parameters: + * property - {String} A layer property to be matched. + * match - {String | Object} A string to match. Can also be a regular + * expression literal or object. In addition, it can be any object + * with a method named test. For reqular expressions or other, if + * match.test(layer[property]) evaluates to true, the layer will be + * included in the array returned. If no layers are found, an empty + * array is returned. + * + * Returns: + * {Array()} A list of layers matching the given criteria. + * An empty array is returned if no matches are found. + */ + getLayersBy(property: string, match: string): Layer[]; + getLayersBy(property: string, match: Object): Layer[]; + + /** + * APIMethod: getLayersByName + * Get a list of layers with names matching the given name. + * + * Parameters: + * match - {String | Object} A layer name. The name can also be a regular + * expression literal or object. In addition, it can be any object + * with a method named test. For reqular expressions or other, if + * name.test(layer.name) evaluates to true, the layer will be included + * in the list of layers returned. If no layers are found, an empty + * array is returned. + * + * Returns: + * {Array()} A list of layers matching the given name. + * An empty array is returned if no matches are found. + */ + getLayersByName(match: string): Layer[]; + getLayersByName(match: Object): Layer[]; + + /** + * APIMethod: getLayersByClass + * Get a list of layers of a given class (CLASS_NAME). + * + * Parameters: + * match - {String | Object} A layer class name. The match can also be a + * regular expression literal or object. In addition, it can be any + * object with a method named test. For reqular expressions or other, + * if type.test(layer.CLASS_NAME) evaluates to true, the layer will + * be included in the list of layers returned. If no layers are + * found, an empty array is returned. + * + * Returns: + * {Array()} A list of layers matching the given class. + * An empty array is returned if no matches are found. + */ + getLayersByClass(match: string): Layer[]; + getLayersByClass(match: Object): Layer[]; + + /** + * APIMethod: getControlsBy + * Get a list of controls with properties matching the given criteria. + * + * Parameters: + * property - {String} A control property to be matched. + * match - {String | Object} A string to match. Can also be a regular + * expression literal or object. In addition, it can be any object + * with a method named test. For reqular expressions or other, if + * match.test(layer[property]) evaluates to true, the layer will be + * included in the array returned. If no layers are found, an empty + * array is returned. + * + * Returns: + * {Array()} A list of controls matching the given + * criteria. An empty array is returned if no matches are found. + */ + getControlsBy(property: string, match: string): Control[]; + getControlsBy(property: string, match: Object): Control[]; + + /** + * APIMethod: getControlsByClass + * Get a list of controls of a given class (CLASS_NAME). + * + * Parameters: + * match - {String | Object} A control class name. The match can also be a + * regular expression literal or object. In addition, it can be any + * object with a method named test. For reqular expressions or other, + * if type.test(control.CLASS_NAME) evaluates to true, the control will + * be included in the list of controls returned. If no controls are + * found, an empty array is returned. + * + * Returns: + * {Array()} A list of controls matching the given class. + * An empty array is returned if no matches are found. + */ + getControlsByClass(match: string): Control[]; + getControlsByClass(match: Object): Control[]; + + /** + * APIMethod: getLayer + * Get a layer based on its id + * + * Parameters: + * id - {String} A layer id + * + * Returns: + * {} The Layer with the corresponding id from the map's + * layer collection, or null if not found. + */ + getLayer(id: string): Layer; + + /** + * Method: setLayerZIndex + * + * Parameters: + * layer - {} + * zIdx - {int} + */ + private setLayerZIndex(layer: Layer, zIdx: number): void; + + /** + * Method: resetLayersZIndex + * Reset each layer's z-index based on layer's array index + */ + private resetLayersZIndex(): void; + + /** + * APIMethod: addLayer + * + * Parameters: + * layer - {} + * + * Returns: + * {Boolean} True if the layer has been added to the map. + */ + addLayer(layer: Layer): boolean; + + /** + * APIMethod: addLayers + * + * Parameters: + * layers - {Array()} + */ + addLayers(layers: Layer[]): void; + + /** + * APIMethod: removeLayer + * Removes a layer from the map by removing its visual element (the + * layer.div property), then removing it from the map's internal list + * of layers, setting the layer's map property to null. + * + * a "removelayer" event is triggered. + * + * very worthy of mention is that simply removing a layer from a map + * will not cause the removal of any popups which may have been created + * by the layer. this is due to the fact that it was decided at some + * point that popups would not belong to layers. thus there is no way + * for us to know here to which layer the popup belongs. + * + * A simple solution to this is simply to call destroy() on the layer. + * the default OpenLayers.Layer class's destroy() function + * automatically takes care to remove itself from whatever map it has + * been attached to. + * + * The correct solution is for the layer itself to register an + * event-handler on "removelayer" and when it is called, if it + * recognizes itself as the layer being removed, then it cycles through + * its own personal list of popups, removing them from the map. + * + * Parameters: + * layer - {} + * setNewBaseLayer - {Boolean} Default is true + */ + removeLayer(layer: Layer, setNewBaseLayer?: boolean): void; + + /** + * APIMethod: getNumLayers + * + * Returns: + * {Int} The number of layers attached to the map. + */ + getNumLayers(): number; + + /** + * APIMethod: getLayerIndex + * + * Parameters: + * layer - {} + * + * Returns: + * {Integer} The current (zero-based) index of the given layer in the map's + * layer stack. Returns -1 if the layer isn't on the map. + */ + getLayerIndex(layer: Layer): number; + + /** + * APIMethod: setLayerIndex + * Move the given layer to the specified (zero-based) index in the layer + * list, changing its z-index in the map display. Use + * map.getLayerIndex() to find out the current index of a layer. Note + * that this cannot (or at least should not) be effectively used to + * raise base layers above overlays. + * + * Parameters: + * layer - {} + * idx - {int} + */ + setLayerIndex(layer: Layer, idx: number): void; + + /** + * APIMethod: raiseLayer + * Change the index of the given layer by delta. If delta is positive, + * the layer is moved up the map's layer stack; if delta is negative, + * the layer is moved down. Again, note that this cannot (or at least + * should not) be effectively used to raise base layers above overlays. + * + * Paremeters: + * layer - {} + * delta - {int} + */ + raiseLayer(layer: Layer, delta: number): void; + + /** + * APIMethod: setBaseLayer + * Allows user to specify one of the currently-loaded layers as the Map's + * new base layer. + * + * Parameters: + * newBaseLayer - {} + */ + setBaseLayer(newBaseLayer: Layer): void; + + /** + * APIMethod: addControl + * Add the passed over control to the map. Optionally + * position the control at the given pixel. + * + * Parameters: + * control - {} + * px - {} + */ + addControl(control: Control, px: Pixel): void; + + /** + * APIMethod: addControls + * Add all of the passed over controls to the map. + * You can pass over an optional second array + * with pixel-objects to position the controls. + * The indices of the two arrays should match and + * you can add null as pixel for those controls + * you want to be autopositioned. + * + * Parameters: + * controls - {Array()} + * pixels - {Array()} + */ + addControls(controls: Control[], pixels: Pixel[]): void; + + /** + * Method: addControlToMap + * + * Parameters: + * + * control - {} + * px - {} + */ + private addControlToMap(control: Control, px: Pixel): void; + + /** + * APIMethod: getControl + * + * Parameters: + * id - {String} ID of the control to return. + * + * Returns: + * {} The control from the map's list of controls + * which has a matching 'id'. If none found, + * returns null. + */ + getControl(id: string): Control; + + /** + * APIMethod: removeControl + * Remove a control from the map. Removes the control both from the map + * object's internal array of controls, as well as from the map's + * viewPort (assuming the control was not added outsideViewport) + * + * Parameters: + * control - {} The control to remove. + */ + removeControl(control: Control): void; + + /** + * APIMethod: addPopup + * + * Parameters: + * popup - {} + * exclusive - {Boolean} If true, closes all other popups first + */ + addPopup(popup: Popup, exclusive: boolean): void; + + /** + * APIMethod: removePopup + * + * Parameters: + * popup - {} + */ + removePopup(popup: Popup): void; + + /** + * APIMethod: getSize + * + * Returns: + * {} An object that represents the + * size, in pixels, of the div into which OpenLayers + * has been loaded. + * Note - A clone() of this locally cached variable is + * returned, so as not to allow users to modify it. + */ + getSize(): Size; + + /** + * APIMethod: updateSize + * This function should be called by any external code which dynamically + * changes the size of the map div (because mozilla wont let us catch + * the "onresize" for an element) + */ + updateSize(): void; + + /** + * Method: getCurrentSize + * + * Returns: + * {} A new object with the dimensions + * of the map div + */ + private getCurrentSize(): Size; + + /** + * Method: calculateBounds + * + * Parameters: + * center - {} Default is this.getCenter() + * resolution - {float} Default is this.getResolution() + * + * Returns: + * {} A bounds based on resolution, center, and + * current mapsize. + */ + calculateBounds(center?: LonLat, resolution?: number): Bounds; + + /** + * APIMethod: getCenter + * + * Returns: + * {} + */ + getCenter(): LonLat; + + /** + * APIMethod: getZoom + * + * Returns: + * {Integer} + */ + getZoom(): number; + + /** + * APIMethod: pan + * Allows user to pan by a value of screen pixels + * + * Parameters: + * dx - {Integer} + * dy - {Integer} + * options - {Object} Options to configure panning: + * - *animate* {Boolean} Use panTo instead of setCenter. Default is true. + * - *dragging* {Boolean} Call setCenter with dragging true. Default is + * false. + */ + pan(dx: number, dy: number, options?: { animate?: boolean; dragging?: boolean }): void; + + /** + * APIMethod: panTo + * Allows user to pan to a new lonlat + * If the new lonlat is in the current extent the map will slide smoothly + * + * Parameters: + * lonlat - {} + */ + panTo(lonlat: LonLat): void; + + /** + * APIMethod: setCenter + * Set the map center (and optionally, the zoom level). + * + * Parameters: + * lonlat - {|Array} The new center location. + * If provided as array, the first value is the x coordinate, + * and the 2nd value is the y coordinate. + * zoom - {Integer} Optional zoom level. + * dragging - {Boolean} Specifies whether or not to trigger + * movestart/end events + * forceZoomChange - {Boolean} Specifies whether or not to trigger zoom + * change events (needed on baseLayer change) + */ + setCenter(lonlat: LonLat, zoom?: number, dragging?: boolean, forceZoomChange?: boolean): void; + setCenter(lonlat: number[], zoom?: number, dragging?: boolean, forceZoomChange?: boolean): void; + + /** + * APIMethod: getMinZoom + * Returns the minimum zoom level for the current map view. If the base + * layer is configured with set to true, this will be the + * first zoom level that shows no more than one world width in the current + * map viewport. Components that rely on this value (e.g. zoom sliders) + * should also listen to the map's "updatesize" event and call this method + * in the "updatesize" listener. + * + * Returns: + * {Number} Minimum zoom level that shows a map not wider than its + * 's maxExtent. This is an Integer value, unless the map is + * configured with set to true. + */ + getMinZoom(): number; + + /** + * APIMethod: getProjection + * This method returns a string representing the projection. In + * the case of projection support, this will be the srsCode which + * is loaded -- otherwise it will simply be the string value that + * was passed to the projection at startup. + * + * Returns: + * {String} The Projection string from the base layer or null. + */ + getProjection(): string; + + /** + * APIMethod: getProjectionObject + * Returns the projection obect from the baselayer. + * + * Returns: + * {} The Projection of the base layer. + */ + getProjectionObject(): Projection; + + /** + * APIMethod: getMaxResolution + * + * Returns: + * {String} The Map's Maximum Resolution + */ + getMaxResolution(): string; + + /** + * APIMethod: getMaxExtent + * + * Parameters: + * options - {Object} + * + * Allowed Options: + * restricted - {Boolean} If true, returns restricted extent (if it is + * available.) + * + * Returns: + * {} The maxExtent property as set on the current + * baselayer, unless the 'restricted' option is set, in which case + * the 'restrictedExtent' option from the map is returned (if it + * is set). + */ + getMaxExtent(options: { restricted: boolean }): Bounds; + + /** + * APIMethod: getNumZoomLevels + * + * Returns: + * {Integer} The total number of zoom levels that can be displayed by the + * current baseLayer. + */ + getNumZoomLevels(): number; + + /** + * APIMethod: getExtent + * + * Returns: + * {} A Bounds object which represents the lon/lat + * bounds of the current viewPort. + * If no baselayer is set, returns null. + */ + getExtent(): Bounds; + + /** + * APIMethod: getResolution + * + * Returns: + * {Float} The current resolution of the map. + * If no baselayer is set, returns null. + */ + getResolution(): number; + + /** + * APIMethod: getUnits + * + * Returns: + * {Float} The current units of the map. + * If no baselayer is set, returns null. + */ + getUnits(): number; + + /** + * APIMethod: getScale + * + * Returns: + * {Float} The current scale denominator of the map. + * If no baselayer is set, returns null. + */ + getScale(): number; + + /** + * APIMethod: getZoomForExtent + * + * Parameters: + * bounds - {} + * closest - {Boolean} Find the zoom level that most closely fits the + * specified bounds. Note that this may result in a zoom that does + * not exactly contain the entire extent. + * Default is false. + * + * Returns: + * {Integer} A suitable zoom level for the specified bounds. + * If no baselayer is set, returns null. + */ + getZoomForExtent(bounds: Bounds, closest?: boolean): number; + + /** + * APIMethod: getResolutionForZoom + * + * Parameters: + * zoom - {Float} + * + * Returns: + * {Float} A suitable resolution for the specified zoom. If no baselayer + * is set, returns null. + */ + getResolutionForZoom(zoom: number): number; + + /** + * APIMethod: getZoomForResolution + * + * Parameters: + * resolution - {Float} + * closest - {Boolean} Find the zoom level that corresponds to the absolute + * closest resolution, which may result in a zoom whose corresponding + * resolution is actually smaller than we would have desired (if this + * is being called from a getZoomForExtent() call, then this means that + * the returned zoom index might not actually contain the entire + * extent specified... but it'll be close). + * Default is false. + * + * Returns: + * {Integer} A suitable zoom level for the specified resolution. + * If no baselayer is set, returns null. + */ + getZoomForResolution(resolution: number, closest?: boolean): number; + + /** + * APIMethod: zoomTo + * Zoom to a specific zoom level. Zooming will be animated unless the map + * is configured with {zoomMethod: null}. To zoom without animation, use + * without a lonlat argument. + * + * Parameters: + * zoom - {Integer} + */ + zoomTo(zoom: number, px: Pixel): void; + + /** + * APIMethod: zoomIn + * + */ + zoomIn(): void; + + /** + * APIMethod: zoomOut + * + */ + zoomOut(): void; + + /** + * APIMethod: zoomToExtent + * Zoom to the passed in bounds, recenter + * + * Parameters: + * bounds - {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * closest - {Boolean} Find the zoom level that most closely fits the + * specified bounds. Note that this may result in a zoom that does + * not exactly contain the entire extent. + * Default is false. + * + */ + zoomToExtent(bounds: Bounds, closest?: boolean): void; + zoomToExtent(bounds: number[], closest?: boolean): void; + + /** + * APIMethod: zoomToMaxExtent + * Zoom to the full extent and recenter. + * + * Parameters: + * options - {Object} + * + * Allowed Options: + * restricted - {Boolean} True to zoom to restricted extent if it is + * set. Defaults to true. + */ + zoomToMaxExtent(options?: { restricted: boolean }): void; + + /** + * APIMethod: zoomToScale + * Zoom to a specified scale + * + * Parameters: + * scale - {float} + * closest - {Boolean} Find the zoom level that most closely fits the + * specified scale. Note that this may result in a zoom that does + * not exactly contain the entire extent. + * Default is false. + * + */ + zoomToScale(scale: number, closest: boolean): void; + + /** + * APIMethod: getViewPortPxFromLonLat + * + * Parameters: + * lonlat - {} + * + * Returns: + * {} An OpenLayers.Pixel which is the passed-in + * , translated into view port + * pixels by the current base layer. + */ + getViewPortPxFromLonLat(lonlat: LonLat): Pixel; + + /** + * APIMethod: getLonLatFromPixel + * + * Parameters: + * px - {|Object} An OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * + * Returns: + * {} An OpenLayers.LonLat corresponding to the given + * OpenLayers.Pixel, translated into lon/lat by the + * current base layer + */ + getLonLatFromPixel(px: Pixel): LonLat; + getLonLatFromPixel(px: { x: number; y: number }): LonLat; + + /** + * APIMethod: getPixelFromLonLat + * Returns a pixel location given a map location. The map location is + * translated to an integer pixel location (in viewport pixel + * coordinates) by the current base layer. + * + * Parameters: + * lonlat - {} A map location. + * + * Returns: + * {} An OpenLayers.Pixel corresponding to the + * translated into view port pixels by the current + * base layer. + */ + getPixelFromLonLat(lonlat: LonLat): Pixel; + + /** + * APIMethod: getViewPortPxFromLayerPx + * + * Parameters: + * layerPx - {} + * + * Returns: + * {} Layer Pixel translated into ViewPort Pixel + * coordinates + */ + getViewPortPxFromLayerPx(layerPx: Pixel): Pixel; + + /** + * APIMethod: getLayerPxFromViewPortPx + * + * Parameters: + * viewPortPx - {} + * + * Returns: + * {} ViewPort Pixel translated into Layer Pixel + * coordinates + */ + getLayerPxFromViewPortPx(viewPortPx: Pixel): Pixel; + + /** + * APIMethod: getLayerPxFromLonLat + * + * Parameters: + * lonlat - {} lonlat + * + * Returns: + * {} An OpenLayers.Pixel which is the passed-in + * , translated into layer pixels + * by the current base layer + */ + getLayerPxFromLonLat(lonlat: LonLat): Pixel; + + static TILE_WIDTH: string; + + static TILE_HEIGHT: string; + } + + export class Class { + + } + + export class Date { + /** + * APIProperty: dateRegEx + * The regex to be used for validating dates. You can provide your own + * regex for instance for adding support for years before BC. Default + * value is: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/ + */ + dateRegEx: string; + + /** + * APIMethod: toISOString + * Generates a string representing a date. The format of the string follows + * the profile of ISO 8601 for date and time on the Internet (see + * http://tools.ietf.org/html/rfc3339). If the toISOString method is + * available on the Date prototype, that is used. The toISOString + * method for Date instances is defined in ECMA-262. + * + * Parameters: + * date - {Date} A date object. + * + * Returns: + * {String} A string representing the date (e.g. + * "2010-08-07T16:58:23.123Z"). If the date does not have a valid time + * (i.e. isNaN(date.getTime())) this method returns the string "Invalid + * Date". The ECMA standard says the toISOString method should throw + * RangeError in this case, but Firefox returns a string instead. For + * best results, use isNaN(date.getTime()) to determine date validity + * before generating date strings. + */ + toISOString(date: Date): string; + + /** + * APIMethod: parse + * Generate a date object from a string. The format for the string follows + * the profile of ISO 8601 for date and time on the Internet (see + * http://tools.ietf.org/html/rfc3339). We don't call the native + * Date.parse because of inconsistency between implmentations. In + * Chrome, calling Date.parse with a string that doesn't contain any + * indication of the timezone (e.g. "2011"), the date is interpreted + * in local time. On Firefox, the assumption is UTC. + * + * Parameters: + * str - {String} A string representing the date (e.g. + * "2010", "2010-08", "2010-08-07", "2010-08-07T16:58:23.123Z", + * "2010-08-07T11:58:23.123-06"). + * + * Returns: + * {Date} A date object. If the string could not be parsed, an invalid + * date is returned (i.e. isNaN(date.getTime())). + */ + parse(str: string): Date; + } + + export class Element { + /** + * APIFunction: visible + * + * Parameters: + * element - {DOMElement} + * + * Returns: + * {Boolean} Is the element visible? + */ + visible(element: HTMLElement): boolean; + + /** + * APIFunction: toggle + * Toggle the visibility of element(s) passed in + * + * Parameters: + * element - {DOMElement} Actually user can pass any number of elements + */ + toggle(element: HTMLElement): void; + + /** + * APIFunction: remove + * Remove the specified element from the DOM. + * + * Parameters: + * element - {DOMElement} + */ + remove(element: HTMLElement): void; + + /** + * APIFunction: getHeight + * + * Parameters: + * element - {DOMElement} + * + * Returns: + * {Integer} The offset height of the element passed in + */ + getHeight(element: HTMLElement): number; + + /** + * Function: hasClass + * Tests if an element has the given CSS class name. + * + * Parameters: + * element - {DOMElement} A DOM element node. + * name - {String} The CSS class name to search for. + * + * Returns: + * {Boolean} The element has the given class name. + */ + hasClass(element: HTMLElement, name: string): boolean; + + /** + * Function: addClass + * Add a CSS class name to an element. Safe where element already has + * the class name. + * + * Parameters: + * element - {DOMElement} A DOM element node. + * name - {String} The CSS class name to add. + * + * Returns: + * {DOMElement} The element. + */ + addClass(element: HTMLElement, name: string): HTMLElement; + + /** + * Function: removeClass + * Remove a CSS class name from an element. Safe where element does not + * have the class name. + * + * Parameters: + * element - {DOMElement} A DOM element node. + * name - {String} The CSS class name to remove. + * + * Returns: + * {DOMElement} The element. + */ + removeClass(element: HTMLElement, name: string): HTMLElement; + + /** + * Function: toggleClass + * Remove a CSS class name from an element if it exists. Add the class name + * if it doesn't exist. + * + * Parameters: + * element - {DOMElement} A DOM element node. + * name - {String} The CSS class name to toggle. + * + * Returns: + * {DOMElement} The element. + */ + toggleClass(element: HTMLElement, name: string): HTMLElement; + + /** + * APIFunction: getStyle + * + * Parameters: + * element - {DOMElement} + * style - {?} + * + * Returns: + * {?} + */ + getStyle(element: HTMLElement, style: any): any; + } + + export class Pixel { + /** + * APIProperty: x + * {Number} The x coordinate + */ + x: number; + + /** + * APIProperty: y + * {Number} The y coordinate + */ + y: number; + + /** + * Constructor: OpenLayers.Pixel + * Create a new OpenLayers.Pixel instance + * + * Parameters: + * x - {Number} The x coordinate + * y - {Number} The y coordinate + * + * Returns: + * An instance of OpenLayers.Pixel + */ + constructor(x: number, y: number); + + /** + * APIMethod: clone + * Return a clone of this pixel object + * + * Returns: + * {} A clone pixel + */ + clone(): Pixel; + + /** + * APIMethod: equals + * Determine whether one pixel is equivalent to another + * + * Parameters: + * px - {|Object} An OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * + * Returns: + * {Boolean} The point passed in as parameter is equal to this. Note that + * if px passed in is null, returns false. + */ + equals(px: Pixel): boolean; + equals(px: { x: number; y: number }): boolean; + + /** + * APIMethod: distanceTo + * Returns the distance to the pixel point passed in as a parameter. + * + * Parameters: + * px - {} + * + * Returns: + * {Float} The pixel point passed in as parameter to calculate the + * distance to. + */ + distanceTo(px: Pixel): number; + + /** + * APIMethod: add + * + * Parameters: + * x - {Integer} + * y - {Integer} + * + * Returns: + * {} A new Pixel with this pixel's x&y augmented by the + * values passed in. + */ + add(x: number, y: number): Pixel; + + /** + * APIMethod: offset + * + * Parameters + * px - {|Object} An OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * + * Returns: + * {} A new Pixel with this pixel's x&y augmented by the + * x&y values of the pixel passed in. + */ + offset(px: Pixel): Pixel; + offset(px: { x: number; y: number }): Pixel; + + CLASS_NAME: string; + } + + export class Size { + /** + * APIProperty: w + * {Number} width + */ + w: number; + + /** + * APIProperty: h + * {Number} height + */ + h: number; + + /** + * Constructor: OpenLayers.Size + * Create an instance of OpenLayers.Size + * + * Parameters: + * w - {Number} width + * h - {Number} height + */ + constructor(w: number, h: number); + + /** + * Method: toString + * Return the string representation of a size object + * + * Returns: + * {String} The string representation of OpenLayers.Size object. + * (e.g. "w=55,h=66") + */ + toString(): string; + + /** + * APIMethod: clone + * Create a clone of this size object + * + * Returns: + * {} A new OpenLayers.Size object with the same w and h + * values + */ + clone(): Size; + + /** + * + * APIMethod: equals + * Determine where this size is equal to another + * + * Parameters: + * sz - {|Object} An OpenLayers.Size or an object with + * a 'w' and 'h' properties. + * + * Returns: + * {Boolean} The passed in size has the same h and w properties as this one. + * Note that if sz passed in is null, returns false. + */ + equals(sz: Size): boolean; + + CLASS_NAME: string; + } + + module Geometry { + + export class Collection extends Geometry { + /** + * The component parts of this geometry + */ + components: Geometry[]; + + /** + * An array of class names representing the types of + * components that the collection can include. A null value means the + * component types are not restricted. + */ + componentTypes: string[]; + + /** + * Creates a Geometry Collection -- a list of geoms. + */ + constructor(components: Geometry[]); + + /** + * Destroy this geometry. + */ + destroy(): void; + + /** + * Clone this geometry. + */ + clone(): Collection; + + /** + * Get a string representing the components for this collection + */ + getComponentsString(): string; + + /** + * Recalculate the bounds by iterating through the components and + * calling calling extendBounds() on each item. + */ + calculateBounds(): void; + + /** + * Add components to this geometry. + */ + addComponents(components: Geometry[]): void; + + /** + * Add a new component (geometry) to the collection. If this.componentTypes + * is set, then the component class name must be in the componentTypes array. + */ + addComponent(component: Geometry, index: number): boolean; + + /** + * Remove components from this geometry. + */ + removeComponents(components: Geometry[]): boolean; + + /** + * Remove a component from this geometry. + */ + removeComponent(component: Geometry): boolean; + + /** + * Calculate the length of this geometry + */ + getLength(): number; + + /** + * Calculate the area of this geometry. Note how this function is overridden + * in . + */ + getArea(): number; + + /** + * Calculate the approximate area of the polygon were it projected onto + * the earth. + */ + getGeodesicArea(projection: Projection): number; + + /** + * Compute the centroid for this geometry collection. + */ + getCentroid(weighted?: boolean): Point; + + /** + * Calculate the approximate length of the geometry were it projected onto + * the earth. + */ + getGeodesicLength(projection: Projection): number; + + /** + * Moves a geometry by the given displacement along positive x and y axes. + * This modifies the position of the geometry and clears the cached + * bounds. + */ + move(x: number, y: number): void; + + /** + * Rotate a geometry around some origin + */ + rotate(angle: number, origin: Point): void; + + /** + * Resize a geometry relative to some origin. Use this method to apply + * a uniform scaling to a geometry. + */ + resize(scale: number, origin: Point, ratio: number): Geometry; + + /** + * Calculate the closest distance between two geometries (on the x-y plane). + */ + distanceTo(geometry: Geometry, options: DistanceOptions): Object; + + /** + * Determine whether another geometry is equivalent to this one. Geometries + * are considered equivalent if all components have the same coordinates. + */ + equals(geometry: Geometry): boolean; + + /** + * Reproject the components geometry from source to dest. + */ + transform(source: Projection, dest: Projection): Geometry; + + /** + * Determine if the input geometry intersects this one. + */ + intersects(geometry: Geometry): boolean; + + /** + * Return a list of all points in this geometry. + */ + getVertices(nodes: boolean): Array; + + static CLASS_NAME: string; + } + + export class Point extends Geometry { + + x: number; + + y: number; + + /** + * Construct a point geometry. + */ + constructor(x: number, y: number); + + /** + * Create a clone of this geometry. + */ + clone(): Geometry; + + /** + * An exact clone of this OpenLayers.Geometry.Point + */ + clone(obj: Point): Point; + + /** + * Calculate the closest distance between two geometries (on the x-y plane). + */ + distanceTo(geometry: Geometry, options: DistanceOptions): Object; + + /** + * Determine whether another geometry is equivalent to this one. Geometries are considered equivalent if all components have the same coordinates. + */ + equals(geom: Point): boolean; + + /** + * Moves a geometry by the given displacement along positive x and y axes. This modifies the position of the geometry and clears the cached bounds. + */ + move(x: number, y: number): void; + + /** + * Rotate a point around another. + */ + rotate(angle: number, origin: Point): void; + + /** + * Resize a point relative to some origin. For points, this has the effect of scaling a vector (from the origin to the point). This method is more useful on geometry collection subclasses. + */ + resize(scale: number, origin: Point, ratio: number): Geometry; + + /** + * Determine if the input geometry intersects this one. + */ + intersects(geometry: Geometry): boolean; + + /** + * Translate the x,y properties of the point from source to dest. + */ + transform(source: Projection, dest: Projection): Geometry; + + /** + * Return a list of all points in this geometry. + */ + getVertices(nodes: boolean): Array; + } + + export class Curve extends Geometry.MultiPoint { + + // TODO + + } + + export class LineString extends Geometry.Curve { + + // TODO + + } + + export class LinearRing extends Geometry.LineString { + + // TODO + + } + + export class MultiLineString extends Geometry.Collection { + + // TODO + + } + + export class MultiPoint extends Geometry.Collection { + + } + // TODO + + + export class MultiPolygon extends Geometry.Collection { + + // TODO + + } + + export class Polygon extends Geometry.Collection { + + // TODO + + } + } + + module Control { + export class ArgParser { + + // TODO + + } + + export class Attribution { + + // TODO + + } + + export class Button { + + // TODO + + } + + export class CacheRead { + + // TODO + + } + + export class CacheWrite { + + // TODO + + } + + export class DragFeature { + + // TODO + + } + + export class DragPan { + + // TODO + + } + + export class DrawFeature { + + // TODO + + } + + export class EditingToolbar { + + // TODO + + } + + export class Geolocate { + + // TODO + + } + + export class GetFeature { + + // TODO + + } + + export class Graticule { + + // TODO + + } + + export class KeyboardDefaults { + + // TODO + + } + + export class LayerSwitcher { + + // TODO + + } + + export class Measure { + + // TODO + + } + + export class ModifyFeature { + + // TODO + + } + + export class MousePosition { + + // TODO + + } + + export class NavToolbar { + + // TODO + + } + + export class Navigation { + + // TODO + + } + + export class NavigationHistory { + + // TODO + + } + + export class OverviewMap { + + // TODO + + } + + export class Pan { + + // TODO + + } + + export class PanPanel { + + // TODO + + } + + export class PanZoom { + + // TODO + + } + + export class PanZoomBar { + + // TODO + + } + + export class Panel { + + // TODO + + } + + export class Permalink { + + // TODO + + } + + export class PinchZoom { + + // TODO + + } + + export class SLDSelect { + + } + + export class Scale { + + // TODO + + } + + export class ScaleLine { + + // TODO + + } + + export class SelectFeature { + + // TODO + + } + + export class Snapping { + + // TODO + + } + + export class Split { + + // TODO + + } + + export class TextButtonPanel { + + // TODO + + } + + export class TouchNavigation { + + // TODO + + } + + export class TransformFeature { + + // TODO + + } + + export class UTFGrid { + + // TODO + + } + + export class WMSGetFeatureInfo { + + // TODO + + } + + export class WMTSGetFeatureInfo { + + // TODO + + } + + export class Zoom { + + // TODO + + } + + export class ZoomBox { + + // TODO + + } + + export class ZoomIn { + + // TODO + + } + + export class ZoomOut { + + // TODO + + } + + export class ZoomPanel { + + // TODO + + } + + export class ZoomToMaxExtent { + + // TODO + + } + } + + module Events { + export class buttonclick extends OpenLayers.Class { + + // TODO + + } + + export class featureclick extends OpenLayers.Class { + + // TODO + + } + } + + module Feature { + export class Vector { + + // TODO + + } + } + + module Filter { + export class Comparison { + + // TODO + + } + + export class FeatureId { + + // TODO + + } + + export class Function { + + // TODO + + } + + export class Logical { + + // TODO + + } + + export class Spatial { + + // TODO + + } + } + + module Format { + export class ArcXML { + constructor(); + } + + export class Atom { + + // TODO + + } + + export class CQL { + + // TODO + + } + + export class CSWGetDomain { + + // TODO + + } + + export class CSWGetRecords { + + // TODO + + } + + export class Context { + // TODO + } + export class EncodedPolyline { + // TODO + } + export class Filter { + // TODO + } + export class GML { + // TODO + } + export class GPX { + // TODO + } + export class GeoJSON { + // TODO + } + export class GeoRSS { + // TODO + } + export class JSON { + // TODO + } + export class KML { + // TODO + } + export class OGCExceptionReport { + // TODO + } + export class OSM { + // TODO + } + export class OWSCommon { + // TODO + } + export class OWSContext { + // TODO + } + export class QueryStringFilter { + // TODO + } + export class SLD { + // TODO + } + export class SOSCapabilities { + // TODO + } + export class SOSGetFeatureOfInterest { + // TODO + } + export class SOSGetObservation { + // TODO + } + export class TMSCapabilities { + // TODO + } + export class Text { + // TODO + } + export class WCSCapabilities { + // TODO + } + export class WCSDescribeCoverage { + // TODO + } + export class WCSGetCoverage { + // TODO + } + export class WFS { + // TODO + } + export class WFSCapabilities { + // TODO + } + export class WFSDescribeFeatureType { + // TODO + } + export class WFST { + // TODO + } + export class WKT { + // TODO + } + export class WMC { + // TODO + } + export class WMSCapabilities { + // TODO + } + export class WMSDescribeLayer { + // TODO + } + export class WMSGetFeatureInfo { + // TODO + } + export class WMTSCapabilities { + // TODO + } + export class WPSCapabilities { + // TODO + } + export class WPSDescribeProcess { + // TODO + } + export class WPSExecute { + // TODO + } + export class XLS { + // TODO + } + export class XML { + // TODO + } + + module ArcXML { + export class Features extends OpenLayers.Class { + + // TODO + + } + } + + module CSWGetDomain { + export class v2_0_2 { + // TODO + } + } + + module CSWGetRecords { + export class v2_0_2 { + // TODO + } + } + + module Filter { + + // TODO + + } + + module GML { + + // TODO + + } + + module OWSCommon { + + // TODO + + } + + module OWSContext { + + // TODO + + } + + module SLD { + + // TODO + + } + + module SOSCapabilities { + + // TODO + + } + + module WCSCapabilities { + + // TODO + + } + + module WCSDescribeCoverage { + + // TODO + + } + + module WFSCapabilities { + + // TODO + + } + + module WFST { + + // TODO + + } + + module WMC { + + // TODO + + } + + module WMSCapabilities { + + // TODO + + + } + + module WMSDescribeLayer { + + // TODO + + } + + module WMTSCapabilities { + + // TODO + + } + + module WPSCapabilities { + + // TODO + + } + + module XLS { + + // TODO + + } + + module XML { + + // TODO + + } + } + + module Handler { + export class Box { + + // TODO + + } + + export class Click { + + // TODO + + } + + export class Drag { + + // TODO + + } + + export class Feature { + + // TODO + + } + + export class Hover { + + // TODO + + } + + export class Keyboard { + + // TODO + + } + + export class MouseWheel { + + // TODO + + } + + export class Path { + + // TODO + + } + + export class Pinch { + + // TODO + + } + + export class Point { + + // TODO + + } + + export class Polygon { + + // TODO + + } + + export class RegularPolygon { + + // TODO + + } + } + + module Lang { + + } + + module Layer { + export interface WMSGetMapParams { + version?: string; + exceptions?: string; + transparent?: string; + format?: string; + styles?: string; + layers: string; + service?: string; + } + + export interface WMSOptions { + opacity?: number; + singleTile?: boolean; + isBaseLayer?: boolean; + encodeBBOX?: boolean; + noMagic?: boolean; + yx?: Object; + } + + export interface TileOptions { + crossOriginKeyword?: string; + } + + export class ArcGIS93Rest { } + export class ArcGISCache { } + export class ArcIMS { } + export class Bing { } + export class Boxes { } + export class EventPane { } + export class FixedZoomLevels { } + export class GeoRSS { } + export class Google { } + + export class Grid extends HTTPRequest { + /** + * APIProperty: tileSize + * {} + */ + tileSize: Size; + + /** + * Property: tileOriginCorner + * {String} If the property is not provided, the tile origin + * will be derived from the layer's . The corner of the + * used is determined by this property. Acceptable values + * are "tl" (top left), "tr" (top right), "bl" (bottom left), and "br" + * (bottom right). Default is "bl". + */ + tileOriginCorner: string; + + /** + * APIProperty: tileOrigin + * {} Optional origin for aligning the grid of tiles. + * If provided, requests for tiles at all resolutions will be aligned + * with this location (no tiles shall overlap this location). If + * not provided, the grid of tiles will be aligned with the layer's + * . Default is ``null``. + */ + tileOrigin: LonLat; + + /** APIProperty: tileOptions + * {Object} optional configuration options for instances + * created by this Layer, if supported by the tile class. + */ + tileOptions: Object; + + /** + * APIProperty: tileClass + * {} The tile class to use for this layer. + * Defaults is OpenLayers.Tile.Image. + */ + tileClass: OpenLayers.Tile; + + /** + * Property: grid + * {Array(Array())} This is an array of rows, each row is + * an array of tiles. + */ + grid: OpenLayers.Tile[][]; + + /** + * APIProperty: singleTile + * {Boolean} Moves the layer into single-tile mode, meaning that one tile + * will be loaded. The tile's size will be determined by the 'ratio' + * property. When the tile is dragged such that it does not cover the + * entire viewport, it is reloaded. + */ + singleTile: boolean; + + /** APIProperty: ratio + * {Float} Used only when in single-tile mode, this specifies the + * ratio of the size of the single tile to the size of the map. + * Default value is 1.5. + */ + ratio: number; + + /** + * APIProperty: buffer + * {Integer} Used only when in gridded mode, this specifies the number of + * extra rows and columns of tiles on each side which will + * surround the minimum grid tiles to cover the map. + * For very slow loading layers, a larger value may increase + * performance somewhat when dragging, but will increase bandwidth + * use significantly. + */ + buffer: number; + + /** + * APIProperty: transitionEffect + * {String} The transition effect to use when the map is zoomed. + * Two posible values: + * + * "resize" - Existing tiles are resized on zoom to provide a visual + * effect of the zoom having taken place immediately. As the + * new tiles become available, they are drawn on top of the + * resized tiles (this is the default setting). + * "map-resize" - Existing tiles are resized on zoom and placed below the + * base layer. New tiles for the base layer will cover existing tiles. + * This setting is recommended when having an overlay duplicated during + * the transition is undesirable (e.g. street labels or big transparent + * fills). + * null - No transition effect. + * + * Using "resize" on non-opaque layers can cause undesired visual + * effects. Set transitionEffect to null in this case. + */ + transitionEffect: string; + + /** + * APIProperty: numLoadingTiles + * {Integer} How many tiles are still loading? + */ + numLoadingTiles: number; + + /** + * Property: serverResolutions + * {Array(Number}} This property is documented in subclasses as + * an API property. + */ + serverResolutions: number[]; + + /** + * Property: loading + * {Boolean} Indicates if tiles are being loaded. + */ + loading: boolean; + + /** + * Property: backBuffer + * {DOMElement} The back buffer. + */ + backBuffer: HTMLElement; + + /** + * Property: gridResolution + * {Number} The resolution of the current grid. Used for backbuffer and + * client zoom. This property is updated every time the grid is + * initialized. + */ + gridResolution: number; + + /** + * Property: backBufferResolution + * {Number} The resolution of the current back buffer. This property is + * updated each time a back buffer is created. + */ + backBufferResolution: number; + + /** + * Property: backBufferLonLat + * {Object} The top-left corner of the current back buffer. Includes lon + * and lat properties. This object is updated each time a back buffer + * is created. + */ + backBufferLonLat: { lon: number; lat: number }; + + /** + * Property: backBufferTimerId + * {Number} The id of the back buffer timer. This timer is used to + * delay the removal of the back buffer, thereby preventing + * flash effects caused by tile animation. + */ + backBufferTimerId: number; + + /** + * APIProperty: removeBackBufferDelay + * {Number} Delay for removing the backbuffer when all tiles have finished + * loading. Can be set to 0 when no css opacity transitions for the + * olTileImage class are used. Default is 0 for layers, + * 2500 for tiled layers. See for more information on + * tile animation. + */ + removeBackBufferDelay: number; + + /** + * APIProperty: className + * {String} Name of the class added to the layer div. If not set in the + * options passed to the constructor then className defaults to + * "olLayerGridSingleTile" for single tile layers (see ), + * and "olLayerGrid" for non single tile layers. + * + * Note: + * + * The displaying of tiles is not animated by default for single tile + * layers - OpenLayers' default theme (style.css) includes this: + * (code) + * .olLayerGrid .olTileImage { + * -webkit-transition: opacity 0.2s linear; + * -moz-transition: opacity 0.2s linear; + * -o-transition: opacity 0.2s linear; + * transition: opacity 0.2s linear; + * } + * (end) + * To animate tile displaying for any grid layer the following + * CSS rule can be used: + * (code) + * .olTileImage { + * -webkit-transition: opacity 0.2s linear; + * -moz-transition: opacity 0.2s linear; + * -o-transition: opacity 0.2s linear; + * transition: opacity 0.2s linear; + * } + * (end) + * In that case, to avoid flash effects, + * should not be zero. + */ + className: string; + + /** + * Property: gridLayout + * {Object} Object containing properties tilelon, tilelat, startcol, + * startrow + */ + gridLayout: { tilelon: number; tilelat: number; startcol: number; startrow: number; }; + + /** + * Property: rowSign + * {Number} 1 for grids starting at the top, -1 for grids starting at the + * bottom. This is used for several grid index and offset calculations. + */ + rowSign: number; + + /** + * Property: transitionendEvents + * {Array} Event names for transitionend + */ + transitionendEvents: string[]; + + /** + * Constructor: OpenLayers.Layer.Grid + * Create a new grid layer + * + * Parameters: + * name - {String} + * url - {String} + * params - {Object} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + constructor(name: string, url: string, params: {}, options: {}); + + /** + * Method: initProperties + * Set any properties that depend on the value of singleTile. + * Currently sets removeBackBufferDelay and className + */ + private initProperties(): void; + + /** + * Method: setMap + * + * Parameters: + * map - {} The map. + */ + setMap(map: Map): void; + + /** + * Method: removeMap + * Called when the layer is removed from the map. + * + * Parameters: + * map - {} The map. + */ + removeMap(map: Map): void; + + /** + * APIMethod: destroy + * Deconstruct the layer and clear the grid. + */ + destroy(): void; + + /** + * Method: clearGrid + * Go through and remove all tiles from the grid, calling + * destroy() on each of them to kill circular references + */ + private clearGrid(): void; + + /** + * APIMethod: addOptions + * + * Parameters: + * newOptions - {Object} + * reinitialize - {Boolean} If set to true, and if resolution options of the + * current baseLayer were changed, the map will be recentered to make + * sure that it is displayed with a valid resolution, and a + * changebaselayer event will be triggered. + */ + addOptions(newOptions: {}, reinitialize: boolean): void; + + /** + * APIMethod: clone + * Create a clone of this layer + * + * Parameters: + * obj - {Object} Is this ever used? + * + * Returns: + * {} An exact clone of this OpenLayers.Layer.Grid + */ + clone(obj?: Object): Layer.Grid; + + /** + * Method: moveTo + * This function is called whenever the map is moved. All the moving + * of actual 'tiles' is done by the map, but moveTo's role is to accept + * a bounds and make sure the data that that bounds requires is pre-loaded. + * + * Parameters: + * bounds - {} + * zoomChanged - {Boolean} + * dragging - {Boolean} + */ + moveTo(bounds: Bounds, zoomChanged: boolean, dragging: boolean): void; + + /** + * Method: getTileData + * Given a map location, retrieve a tile and the pixel offset within that + * tile corresponding to the location. If there is not an existing + * tile in the grid that covers the given location, null will be + * returned. + * + * Parameters: + * loc - {} map location + * + * Returns: + * {Object} Object with the following properties: tile ({}), + * i ({Number} x-pixel offset from top left), and j ({Integer} y-pixel + * offset from top left). + */ + private getTileData(loc: LonLat): { tile: Tile; i: number; j: number }; + + /** + * Method: destroyTile + * + * Parameters: + * tile - {} + */ + private destroyTile(tile: Tile): void; + + /** + * Method: getServerResolution + * Return the closest server-supported resolution. + * + * Parameters: + * resolution - {Number} The base resolution. If undefined the + * map resolution is used. + * + * Returns: + * {Number} The closest server resolution value. + */ + private getServerResolution(resolution: number): number; + + /** + * Method: getServerZoom + * Return the zoom value corresponding to the best matching server + * resolution, taking into account and . + * + * Returns: + * {Number} The closest server supported zoom. This is not the map zoom + * level, but an index of the server's resolutions array. + */ + private getServerZoom(): number; + + /** + * Method: applyBackBuffer + * Create, insert, scale and position a back buffer for the layer. + * + * Parameters: + * resolution - {Number} The resolution to transition to. + */ + private applyBackBuffer(resolution: number): void; + + /** + * Method: createBackBuffer + * Create a back buffer. + * + * Returns: + * {DOMElement} The DOM element for the back buffer, undefined if the + * grid isn't initialized yet. + */ + private createBackBuffer(): HTMLElement; + + /** + * Method: removeBackBuffer + * Remove back buffer from DOM. + */ + private removeBackBuffer(): void; + + /** + * Method: moveByPx + * Move the layer based on pixel vector. + * + * Parameters: + * dx - {Number} + * dy - {Number} + */ + moveByPx(dx: number, dy: number): void; + + /** + * APIMethod: setTileSize + * Check if we are in singleTile mode and if so, set the size as a ratio + * of the map size (as specified by the layer's 'ratio' property). + * + * Parameters: + * size - {} + */ + setTileSize(size: Size): void; + + /** + * APIMethod: getTilesBounds + * Return the bounds of the tile grid. + * + * Returns: + * {} A Bounds object representing the bounds of all the + * currently loaded tiles (including those partially or not at all seen + * onscreen). + */ + getTilesBounds(): Bounds; + + /** + * Method: initSingleTile + * + * Parameters: + * bounds - {} + */ + private initSingleTile(bounds: Bounds); + + /** + * Method: calculateGridLayout + * Generate parameters for the grid layout. + * + * Parameters: + * bounds - {|Object} OpenLayers.Bounds or an + * object with a 'left' and 'top' properties. + * origin - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. + * resolution - {Number} + * + * Returns: + * {Object} Object containing properties tilelon, tilelat, startcol, + * startrow + */ + private calculateGridLayout(bounds: Bounds, origin: LonLat, resolution: number): { tilelon: number; tilelat: number; startcol: number; startrow: number }; + + getImageSize(): Size; + + /** + * Method: getTileOrigin + * Determine the origin for aligning the grid of tiles. If a + * property is supplied, that will be returned. Otherwise, the origin + * will be derived from the layer's property. In this case, + * the tile origin will be the corner of the given by the + * property. + * + * Returns: + * {} The tile origin. + */ + private getTileOrigin(): LonLat; + + /** + * Method: getTileBoundsForGridIndex + * + * Parameters: + * row - {Number} The row of the grid + * col - {Number} The column of the grid + * + * Returns: + * {} The bounds for the tile at (row, col) + */ + private getTileBoundsForGridIndex(row: number, col: number): Bounds; + + /** + * Method: initGriddedTiles + * + * Parameters: + * bounds - {} + */ + private initGriddedTiles(bounds: Bounds): void; + + /** + * Method: getMaxExtent + * Get this layer's maximum extent. (Implemented as a getter for + * potential specific implementations in sub-classes.) + * + * Returns: + * {} + */ + private getMaxExtent(): Bounds; + + /** + * APIMethod: addTile + * Create a tile, initialize it, and add it to the layer div. + * + * Parameters + * bounds - {} + * position - {} + * + * Returns: + * {} The added OpenLayers.Tile + */ + addTile(bounds: Bounds, position: number): Tile; + + /** + * Method: addTileMonitoringHooks + * This function takes a tile as input and adds the appropriate hooks to + * the tile so that the layer can keep track of the loading tiles. + * + * Parameters: + * tile - {} + */ + private addTileMonitoringHooks(tile: Tile): void; + + /** + * Method: removeTileMonitoringHooks + * This function takes a tile as input and removes the tile hooks + * that were added in addTileMonitoringHooks() + * + * Parameters: + * tile - {} + */ + private removeTileMonitoringHooks(tile: Tile): void; + + /** + * Method: moveGriddedTiles + */ + private moveGriddedTiles(): void; + + /** + * Method: shiftRow + * Shifty grid work + * + * Parameters: + * prepend - {Boolean} if true, prepend to beginning. + * if false, then append to end + * tileSize - {Object} rendered tile size; object with w and h properties + */ + private shiftRow(prepend: boolean, tileSize: { w: number; h: number }): void; + + /** + * Method: shiftColumn + * Shift grid work in the other dimension + * + * Parameters: + * prepend - {Boolean} if true, prepend to beginning. + * if false, then append to end + * tileSize - {Object} rendered tile size; object with w and h properties + */ + private shiftColumn(prepend: boolean, tileSize: { w: number; h: number }): void; + + /** + * Method: removeExcessTiles + * When the size of the map or the buffer changes, we may need to + * remove some excess rows and columns. + * + * Parameters: + * rows - {Integer} Maximum number of rows we want our grid to have. + * columns - {Integer} Maximum number of columns we want our grid to have. + */ + private removeExcessTiles(rows: number, columns: number): void; + + /** + * Method: onMapResize + * For singleTile layers, this will set a new tile size according to the + * dimensions of the map pane. + */ + onMapResize(): void; + + /** + * APIMethod: getTileBounds + * Returns The tile bounds for a layer given a pixel location. + * + * Parameters: + * viewPortPx - {} The location in the viewport. + * + * Returns: + * {} Bounds of the tile at the given pixel location. + */ + getTileBounds(viewPortPx: Pixel): Bounds; + } + + export class HTTPRequest extends Layer { + /** + * Constant: URL_HASH_FACTOR + * {Float} Used to hash URL param strings for multi-WMS server selection. + * Set to the Golden Ratio per Knuth's recommendation. + */ + static URL_HASH_FACTOR: number; + + /** + * Property: url + * {Array(String) or String} This is either an array of url strings or + * a single url string. + */ + url: string[]; + + /** + * Property: params + * {Object} Hashtable of key/value parameters + */ + params: Object; + + /** + * APIProperty: reproject + * *Deprecated*. See http://docs.openlayers.org/library/spherical_mercator.html + * for information on the replacement for this functionality. + * {Boolean} Whether layer should reproject itself based on base layer + * locations. This allows reprojection onto commercial layers. + * Default is false: Most layers can't reproject, but layers + * which can create non-square geographic pixels can, like WMS. + */ + reproject: boolean; + + /** + * Constructor: OpenLayers.Layer.HTTPRequest + * + * Parameters: + * name - {String} + * url - {Array(String) or String} + * params - {Object} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + constructor(name: string, url: string, params: Object, options: Object); + constructor(name: string, url: string[], params: Object, options: Object); + + /** + * APIMethod: destroy + */ + destroy(): void; + + /** + * APIMethod: clone + * + * Parameters: + * obj - {Object} + * + * Returns: + * {} An exact clone of this + * + */ + clone(obj?: Object): HTTPRequest; + + /** + * APIMethod: setUrl + * + * Parameters: + * newUrl - {String} + */ + setUrl(newUrl: string): void; + + /** + * APIMethod: mergeNewParams + * + * Parameters: + * newParams - {Object} + * + * Returns: + * redrawn: {Boolean} whether the layer was actually redrawn. + */ + mergeNewParams(newParams: Object): boolean; + + /** + * APIMethod: redraw + * Redraws the layer. Returns true if the layer was redrawn, false if not. + * + * Parameters: + * force - {Boolean} Force redraw by adding random parameter. + * + * Returns: + * {Boolean} The layer was redrawn. + */ + redraw(force?: boolean): boolean; + + /** + * Method: selectUrl + * selectUrl() implements the standard floating-point multiplicative + * hash function described by Knuth, and hashes the contents of the + * given param string into a float between 0 and 1. This float is then + * scaled to the size of the provided urls array, and used to select + * a URL. + * + * Parameters: + * paramString - {String} + * urls - {Array(String)} + * + * Returns: + * {String} An entry from the urls array, deterministically selected based + * on the paramString. + */ + private selectUrl(paramString: string, urls: string[]): string; + + /** + * Method: getFullRequestString + * Combine url with layer's params and these newParams. + * + * does checking on the serverPath variable, allowing for cases when it + * is supplied with trailing ? or &, as well as cases where not. + * + * return in formatted string like this: + * "server?key1=value1&key2=value2&key3=value3" + * + * WARNING: The altUrl parameter is deprecated and will be removed in 3.0. + * + * Parameters: + * newParams - {Object} + * altUrl - {String} Use this as the url instead of the layer's url + * + * Returns: + * {String} + */ + getFullRequestString(newParams: Object, altUrl: string): string; + } + + export class Image { + // TODO + } + export class KaMap { + // TODO + } + export class KaMapCache { + // TODO + } + export class MapGuide { + // TODO + } + export class MapServer { + // TODO + } + export class Markers { + // TODO + } + + export class OSM extends Layer.XYZ { + /** + * The layer name. Defaults to "OpenStreetMap" if the first + * argument to the constructor is null or undefined. + */ + name: string; + + /** + * The tileset URL scheme. Defaults to + * : http://[a|b|c].tile.openstreetmap.org/${z}/${x}/${y}.png + * (the official OSM tileset) if the second argument to the constructor + * is null or undefined. To use another tileset you can have something + * like this: + * new OpenLayers.Layer.OSM("OpenCycleMap", + * ["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", + * "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", + * "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"]); + */ + url: string[]; + + /** + * The layer attribution. + */ + attribution: string; + + sphericalMercator: boolean; + + wrapDateLine: boolean; + + /** + * optional configuration options for instances + * created by this Layer. + */ + tileOptions: TileOptions; + + constructor(); + + constructor(name: string, url: string, options: TileOptions); + + /** + * Create a clone of this layer + */ + clone(obj?: Object): Layer.OSM; + + static CLASS_NAME: string; + } + + export class PointGrid { + // TODO + } + export class PointTrack { + // TODO + } + export class SphericalMercator { + // TODO + } + export class TMS { + // TODO + } + export class Text { + // TODO + } + export class TileCache { + // TODO + } + export class UTFGrid { + // TODO + } + export class Vector { + // TODO + } + + export class WMS extends Layer.Grid { + /** + * Default is true for WMS layer + */ + isBaseLayer: boolean; + + /** + * Should the BBOX commas be encoded? The WMS spec says 'no', + * but some services want it that way. Default false. + */ + encodeBBOX: boolean; + + /** + * If true, the image format will not be automagicaly switched + * from image/jpeg to image/png or image/gif when using + * TRANSPARENT=TRUE. Also isBaseLayer will not changed by the + * constructor. Default false. + */ + noMagic: boolean; + + /** + * Keys in this object are EPSG codes for which the axis order + * is to be reversed (yx instead of xy, LatLon instead of LonLat), with + * true as value. This is only relevant for WMS versions >= 1.3.0, and + * only if yx is not set in for the + * used projection. + */ + yx: Object; + + /** + * Constructor: OpenLayers.Layer.WMS + * Create a new WMS layer object + * + * Examples: + * + * The code below creates a simple WMS layer using the image/jpeg format. + * (code) + * var wms = new OpenLayers.Layer.WMS("NASA Global Mosaic", + * "http://wms.jpl.nasa.gov/wms.cgi", + * {layers: "modis,global_mosaic"}); + * (end) + * Note the 3rd argument (params). Properties added to this object will be + * added to the WMS GetMap requests used for this layer's tiles. The only + * mandatory parameter is "layers". Other common WMS params include + * "transparent", "styles" and "format". Note that the "srs" param will + * always be ignored. Instead, it will be derived from the baseLayer's or + * map's projection. + * + * The code below creates a transparent WMS layer with additional options. + * (code) + * var wms = new OpenLayers.Layer.WMS("NASA Global Mosaic", + * "http://wms.jpl.nasa.gov/wms.cgi", + * { + * layers: "modis,global_mosaic", + * transparent: true + * }, { + * opacity: 0.5, + * singleTile: true + * }); + * (end) + * Note that by default, a WMS layer is configured as baseLayer. Setting + * the "transparent" param to true will apply some magic (see ). + * The default image format changes from image/jpeg to image/png, and the + * layer is not configured as baseLayer. + * + * Parameters: + * name - {String} A name for the layer + * url - {String} Base url for the WMS + * (e.g. http://wms.jpl.nasa.gov/wms.cgi) + * params - {Object} An object with key/value pairs representing the + * GetMap query string parameters and parameter values. + * options - {Object} Hashtable of extra options to tag onto the layer. + * These options include all properties listed above, plus the ones + * inherited from superclasses. + */ + constructor(name: string, url: string, params: WMSGetMapParams, options: WMSOptions); + + /** + * Create a clone of this layer + */ + clone(): Layer.WMS; + + /** + * Returns true if the axis order is reversed for the WMS version and + * projection of the layer. + */ + reverseAxisOrder(): boolean; + + /** + * Return a GetMap query string for this layer + */ + getURL(bounds: Bounds): string; + + /** + * Catch changeParams and uppercase the new params to be merged in + * before calling changeParams on the super class. + * Once params have been changed, the tiles will be reloaded with + * the new parameters. + */ + mergeNewParams(newParams: Object): boolean; + + /** + * Combine the layer's url with its params and these newParams. + * + * Add the SRS parameter from projection -- this is probably + * more eloquently done via a setProjection() method, but this + * works for now and always. + */ + getFullRequestString(newParams: Object, altUrl: string): string; + + static CLASS_NAME: string; + } + + export class WMTS { + // TODO + } + + export class WorldWind { + // TODO + } + + export class XYZ extends Layer.Grid { + /** + * APIProperty: isBaseLayer + * Default is true, as this is designed to be a base tile source. + */ + isBaseLayer: boolean; + + /** + * APIProperty: sphericalMercator + * Whether the tile extents should be set to the defaults for + * spherical mercator. Useful for things like OpenStreetMap. + * Default is false, except for the OSM subclass. + */ + sphericalMercator: boolean; + + /** + * APIProperty: zoomOffset + * {Number} If your cache has more zoom levels than you want to provide + * access to with this layer, supply a zoomOffset. This zoom offset + * is added to the current map zoom level to determine the level + * for a requested tile. For example, if you supply a zoomOffset + * of 3, when the map is at the zoom 0, tiles will be requested from + * level 3 of your cache. Default is 0 (assumes cache level and map + * zoom are equivalent). Using is an alternative to + * setting if you only want to expose a subset + * of the server resolutions. + */ + zoomOffset: number; + + /** + * APIProperty: serverResolutions + * {Array} A list of all resolutions available on the server. Only set this + * property if the map resolutions differ from the server. This + * property serves two purposes. (a) can include + * resolutions that the server supports and that you don't want to + * provide with this layer; you can also look at , which is + * an alternative to for that specific purpose. + * (b) The map can work with resolutions that aren't supported by + * the server, i.e. that aren't in . When the + * map is displayed in such a resolution data for the closest + * server-supported resolution is loaded and the layer div is + * stretched as necessary. + */ + serverResolutions: number[]; + + /** + * Constructor: OpenLayers.Layer.XYZ + * + * Parameters: + * name - {String} + * url - {String} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + constructor(name: number, url: string, options: {}); + + /** + * APIMethod: clone + * Create a clone of this layer + * + * Parameters: + * obj - {Object} Is this ever used? + * + * Returns: + * {} An exact clone of this OpenLayers.Layer.XYZ + */ + clone(obj?: Object): Layer.XYZ; + + /** + * Method: getURL + * + * Parameters: + * bounds - {} + * + * Returns: + * {String} A string with the layer's url and parameters and also the + * passed-in bounds and appropriate tile size specified as + * parameters + */ + private getURL(bounds: Bounds): string; + + /** + * Method: getXYZ + * Calculates x, y and z for the given bounds. + * + * Parameters: + * bounds - {} + * + * Returns: + * {Object} - an object with x, y and z properties. + */ + private getXYZ(bounds: Bounds): { x: number; y: number; z: number }; + + /* APIMethod: setMap + * When the layer is added to a map, then we can fetch our origin + * (if we don't have one.) + * + * Parameters: + * map - {} + */ + setMap(map: Map): void; + } + + export class Zoomify { + // TODO + } + + module Google { + export class v3 { + // TODO + } + } + + module Vector { + export class RootContainer { + // TODO + } + } + } + + module Marker { + export class Box { + // TODO + } + } + + module Popup { + export class Anchored { + // TODO + } + export class Framed { + // TODO + } + export class FramedCloud { + // TODO + } + } + + module Protocol { + export class CSW { + // TODO + } + export class HTTP { + // TODO + } + export class SOS { + // TODO + } + export class Script { + // TODO + } + export class WFS { + // TODO + } + + module CSW { + export class v2_0_2 { + // TODO + } + } + + module SOS { + export class v1_0_0 { + // TODO + } + } + + module WFS { + export class v2_0_0 { + // TODO + } + } + } + + module Renderer { + export class Canvas { + // TODO + } + export class Elements { + // TODO + } + export class SVG { + // TODO + } + export class VML { + // TODO + } + } + + module Request { + export class XMLHttpRequest { + // TODO + } + } + + module Strategy { + export class BBOX { + // TODO + } + export class Cluster { + // TODO + } + export class Filter { + // TODO + } + export class Fixed { + // TODO + } + export class Paging { + // TODO + } + export class Refresh { + // TODO + } + export class Save { + // TODO + } + } + + module Symbolizer { + export class Line { + // TODO + } + export class Point { + // TODO + } + export class Polygon { + // TODO + } + export class Raster { + // TODO + } + export class Text { + // TODO + } + } + + module Tile { + export class Image { + // TODO + } + export class UTFGrid { + // TODO + } + + module Image { + export class IFrame { + // TODO + } + } + } + + module Util { + export class vendorPrefix { + // TODO + } + } +} + diff --git a/parallel/parallel-tests.ts.tscparams b/parallel/parallel-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/parallel/parallel-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/pdf/pdf-tests.ts.tscparams b/pdf/pdf-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/pdf/pdf-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/pdf/pdf.d.ts.tscparams b/pdf/pdf.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/pdf/pdf.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/persona/persona-tests.ts.tscparams b/persona/persona-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/persona/persona-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/persona/persona.d.ts.tscparams b/persona/persona.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/persona/persona.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/phantomjs/phantomjs.d.ts.tscparams b/phantomjs/phantomjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/phantomjs/phantomjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/phonegap/phonegap-tests.ts.tscparams b/phonegap/phonegap-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/phonegap/phonegap-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/phonegap/phonegap.d.ts.tscparams b/phonegap/phonegap.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/phonegap/phonegap.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/pixi/pixi-tests.ts.tscparams b/pixi/pixi-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/pixi/pixi-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/pixi/pixi.d.ts.tscparams b/pixi/pixi.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/pixi/pixi.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/popcorn/popcorn.d.ts.tscparams b/popcorn/popcorn.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/popcorn/popcorn.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/pouchDB/pouch-tests.ts.tscparams b/pouchDB/pouch-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/pouchDB/pouch-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/pouchDB/pouch.d.ts.tscparams b/pouchDB/pouch.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/pouchDB/pouch.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/q/Q-tests.ts.tscparams b/q/Q-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/q/Q-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/q/Q.d.ts b/q/Q.d.ts index a8b4b3e33..a9126c007 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -8,10 +8,10 @@ declare function Q(promise: Q.IPromise): Q.Promise; declare module Q { interface IPromise { - then(onFulfill: (value: T) => U, onReject?: (reason) => U): IPromise; - then(onFulfill: (value: T) => IPromise, onReject?: (reason) => U): IPromise; - then(onFulfill: (value: T) => U, onReject?: (reason) => IPromise): IPromise; - then(onFulfill: (value: T) => IPromise, onReject?: (reason) => IPromise): IPromise; + then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => IPromise): IPromise; + then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => U): IPromise; + then(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise): IPromise; + then(onFulfill: (value: T) => U, onReject?: (reason: any) => U): IPromise; } interface Deferred { @@ -19,28 +19,28 @@ declare module Q { resolve(value: T): void; reject(reason: any): void; notify(value: any): void; - makeNodeResolver(): (reason, value: T) => void; + makeNodeResolver(): (reason: any, value: T) => void; } interface Promise { fin(finallyCallback: () => any): Promise; finally(finallyCallback: () => any): Promise; - then(onFulfill: (value: T) => U, onReject?: (reason) => U, onProgress?: Function): Promise; - then(onFulfill: (value: T) => IPromise, onReject?: (reason) => U, onProgress?: Function): Promise; - then(onFulfill: (value: T) => U, onReject?: (reason) => IPromise, onProgress?: Function): Promise; - then(onFulfill: (value: T) => IPromise, onReject?: (reason) => IPromise, onProgress?: Function): Promise; + then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => IPromise, onProgress?: Function): Promise; + then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => U, onProgress?: Function): Promise; + then(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise, onProgress?: Function): Promise; + then(onFulfill: (value: T) => U, onReject?: (reason: any) => U, onProgress?: Function): Promise; spread(onFulfilled: Function, onRejected?: Function): Promise; - fail(onRejected: (reason) => U): Promise; - fail(onRejected: (reason) => IPromise): Promise; - catch(onRejected: (reason) => U): Promise; - catch(onRejected: (reason) => IPromise): Promise; + fail(onRejected: (reason: any) => U): Promise; + fail(onRejected: (reason: any) => IPromise): Promise; + catch(onRejected: (reason: any) => U): Promise; + catch(onRejected: (reason: any) => IPromise): Promise; - progress(onProgress: (progress) => any): Promise; + progress(onProgress: (progress: any) => any): Promise; - done(onFulfilled?: (value: T) => any, onRejected?: (reason) => any, onProgress?: (progress) => any): void; + done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void; get(propertyName: String): Promise; set(propertyName: String, value: any): Promise; @@ -71,24 +71,24 @@ declare module Q { } // if no fulfill, reject, or progress provided, returned promise will be of same type - export function when(value: T): Promise; export function when(value: IPromise): Promise; + export function when(value: T): Promise; // If a non-promise value is provided, it will not reject or progress - export function when(value: T, onFulfilled: (val: T) => U): Promise; export function when(value: T, onFulfilled: (val: T) => IPromise): Promise; + export function when(value: T, onFulfilled: (val: T) => U): Promise; - export function when(value: IPromise, onFulfilled: (val: T) => U, onRejected?: (reason) => U, onProgress?: (progress) => any): Promise; - export function when(value: IPromise, onFulfilled: (val: T) => IPromise, onRejected?: (reason) => U, onProgress?: (progress) => any): Promise; - export function when(value: IPromise, onFulfilled: (val: T) => U, onRejected?: (reason) => IPromise, onProgress?: (progress) => any): Promise; - export function when(value: IPromise, onFulfilled: (val: T) => IPromise, onRejected?: (reason) => IPromise, onProgress?: (progress) => any): Promise; + export function when(value: IPromise, onFulfilled: (val: T) => IPromise, onRejected?: (reason: any) => IPromise, onProgress?: (progress: any) => any): Promise; + export function when(value: IPromise, onFulfilled: (val: T) => IPromise, onRejected?: (reason: any) => U, onProgress?: (progress: any) => any): Promise; + export function when(value: IPromise, onFulfilled: (val: T) => U, onRejected?: (reason: any) => IPromise, onProgress?: (progress: any) => any): Promise; + export function when(value: IPromise, onFulfilled: (val: T) => U, onRejected?: (reason: any) => U, onProgress?: (progress: any) => any): Promise; //export function try(method: Function, ...args: any[]): Promise; // <- This is broken currently - not sure how to fix. - export function fbind(method: (...args: any[]) => T, ...args: any[]): (...args: any[]) => Promise; export function fbind(method: (...args: any[]) => IPromise, ...args: any[]): (...args: any[]) => Promise; + export function fbind(method: (...args: any[]) => T, ...args: any[]): (...args: any[]) => Promise; - export function fcall(method: (...args) => T, ...args: any[]): Promise; + export function fcall(method: (...args: any[]) => T, ...args: any[]): Promise; export function send(obj: any, functionName: string, ...args: any[]): Promise; export function invoke(obj: any, functionName: string, ...args: any[]): Promise; @@ -110,14 +110,15 @@ declare module Q { export function allResolved(promises: any[]): Promise[]>; export function allResolved(promises: IPromise[]): Promise[]>; - export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected: (reason) => U): Promise; - export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected: (reason) => U): Promise; - export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected: (reason) => IPromise): Promise; - export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected: (reason) => IPromise): Promise; - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected: (reason) => U): Promise; - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected: (reason) => U): Promise; - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected: (reason) => IPromise): Promise; - export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected: (reason) => IPromise): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => IPromise, onRejected: (reason: any) => U): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: any[], onFulfilled: (...args: any[]) => U, onRejected: (reason: any) => U): Promise; + + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => IPromise, onRejected: (reason: any) => U): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected: (reason: any) => IPromise): Promise; + export function spread(promises: IPromise[], onFulfilled: (...args: T[]) => U, onRejected: (reason: any) => U): Promise; export function timeout(promise: Promise, ms: number, message?: string): Promise; @@ -130,25 +131,25 @@ declare module Q { export function defer(): Deferred; - export function reject(reason?): Promise; + export function reject(reason?: any): Promise; - export function promise(resolver: (resolve: (val: T) => void , reject: (reason) => void , notify: (progress) => void ) => void ): Promise; - export function promise(resolver: (resolve: (val: IPromise) => void , reject: (reason) => void , notify: (progress) => void ) => void ): Promise; + export function promise(resolver: (resolve: (val: IPromise) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise; + export function promise(resolver: (resolve: (val: T) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise; - export function promised(callback: (...any) => T): (...any) => Promise; + export function promised(callback: (...args: any[]) => T): (...args: any[]) => Promise; - export function isPromise(object): boolean; - export function isPromiseAlike(object): boolean; - export function isPending(object): boolean; + export function isPromise(object: any): boolean; + export function isPromiseAlike(object: any): boolean; + export function isPending(object: any): boolean; - export function async(generatorFunction: any): (...args) => Promise; + export function async(generatorFunction: any): (...args: any[]) => Promise; export function nextTick(callback: Function): void; export var oneerror: () => void; export var longStackSupport: boolean; - export function resolve(object: T): Promise; export function resolve(object: IPromise): Promise; + export function resolve(object: T): Promise; } declare module "q" { diff --git a/q/Q.d.ts.tscparams b/q/Q.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/q/Q.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/qunit/qunit-tests.ts.tscparams b/qunit/qunit-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/qunit/qunit-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/qunit/qunit.d.ts b/qunit/qunit.d.ts index a5ff281a9..ee923c59c 100644 --- a/qunit/qunit.d.ts +++ b/qunit/qunit.d.ts @@ -134,11 +134,17 @@ interface Config { current: Object; reorder: boolean; requireExpects: boolean; - testTimeout: number; - urlConfig: Array; + testTimeout: number; + urlConfig: Array; done: any; } +interface URLConfigItem { + id: string; + label: string; + tooltip: string; +} + interface LifecycleObject { /** * Runs before each test diff --git a/qunit/qunit.d.ts.tscparams b/qunit/qunit.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/qunit/qunit.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/raphael/raphael-tests.ts.tscparams b/raphael/raphael-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/raphael/raphael-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/raphael/raphael.d.ts.tscparams b/raphael/raphael.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/raphael/raphael.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index b00c6b1cd..89c6f97f6 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -1,26 +1,26 @@ -/* +/* require-2.1.8.d.ts may be freely distributed under the MIT license. Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ @@ -70,9 +70,9 @@ interface RequireConfig { // The root path to use for all module lookups. baseUrl?: string; - // Path mappings for module names not found directly under + // Path mappings for module names not found directly under // baseUrl. - paths?: { [key: string]: string; }; + paths?: { [key: string]: any; }; // Dictionary of Shim's. // does not cover case of key->string[] @@ -223,6 +223,13 @@ interface Require { **/ config(config: RequireConfig): Require; + /** + * CommonJS require call + * @param module Module to load + * @return The loaded module + */ + (module: string): any; + /** * Start the main app logic. * Callback is optional. @@ -235,7 +242,7 @@ interface Require { * @see Require() * @param ready Called when required modules are ready. **/ - (modules: string[], ready: (...modules: any[]) => void ): void; + (modules: string[], ready: Function): void; /** * Generate URLs from require module diff --git a/restangular/restangular-tests.ts.tscparams b/restangular/restangular-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/restangular/restangular-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/restangular/restangular.d.ts.tscparams b/restangular/restangular.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/restangular/restangular.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/restify/restify-tests.ts.tscparams b/restify/restify-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/restify/restify-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/restify/restify.d.ts.tscparams b/restify/restify.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/restify/restify.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rethinkdb/rethinkdb-tests.ts b/rethinkdb/rethinkdb-tests.ts new file mode 100644 index 000000000..4e6d78449 --- /dev/null +++ b/rethinkdb/rethinkdb-tests.ts @@ -0,0 +1,24 @@ +/// + +import r = require("rethinkdb") + +r.connect({host:"localhost", port: 28015}, function(err, conn) { + console.log("HI", err, conn) + var testDb = r.db('test') + testDb.tableCreate('users').run(conn, function(err, stuff) { + var users = testDb.table('users') + + users.insert({name: "bob"}).run(conn, function() {}) + + users.filter(function(doc) { + return doc("henry").eq("bob") + }) + .between("james", "beth") + .limit(4) + .run(conn, function() { + + }) + + + }) +}) \ No newline at end of file diff --git a/rethinkdb/rethinkdb-tests.ts.tscparams b/rethinkdb/rethinkdb-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rethinkdb/rethinkdb-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts new file mode 100644 index 000000000..da6355094 --- /dev/null +++ b/rethinkdb/rethinkdb.d.ts @@ -0,0 +1,219 @@ +// Type definitions for Rethinkdb 1.10.0 +// Project: http://rethinkdb.com/ +// Definitions by: Sean Hess +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Reference: http://www.rethinkdb.com/api/#js +// TODO: Document manipulation and below + +declare module "rethinkdb" { + + export function connect(host:ConnectionOptions, cb:(err:Error, conn:Connection)=>void); + + export function dbCreate(name:string):Operation; + export function dbDrop(name:string):Operation; + export function dbList():Operation; + + export function db(name:string):Db; + export function table(name:string, options?:{useOutdated:boolean}):Table; + + export function asc(property:string):Sort; + export function desc(property:string):Sort; + + export var count:Aggregator; + export function sum(prop:string):Aggregator; + export function avg(prop:string):Aggregator; + + export function row(name:string):Expression; + export function expr(stuff:any):Expression; + + export class Cursor { + hasNext():boolean; + each(cb:(err:Error, row:any)=>void, done?:()=>void); + each(cb:(err:Error, row:any)=>boolean, done?:()=>void); // returning false stops iteration + next(cb:(err:Error, row:any) => void); + toArray(cb:(err:Error, rows:any[]) => void); + close(); + } + + interface ConnectionOptions { + host:string; + port:number; + db?:string; + authKey?:string; + } + + interface Connection { + close(); + reconnect(cb:(err:Error, conn:Connection)=>void); + use(dbName:string); + addListener(event:string, cb:Function); + on(event:string, cb:Function); + } + + interface Db { + tableCreate(name:string, options?:TableOptions):Operation; + tableDrop(name:string):Operation; + tableList():Operation; + table(name:string, options?:GetTableOptions):Table; + } + + interface TableOptions { + primary_key?:string; // 'id' + durability?:string; // 'soft' + cache_size?:number; + datacenter?:string; + } + + interface GetTableOptions { + useOutdated: boolean; + } + + interface Writeable { + update(obj:Object, options?:UpdateOptions):Operation; + replace(obj:Object, options?:UpdateOptions):Operation; + replace(expr:ExpressionFunction):Operation; + delete(options?:UpdateOptions):Operation; + } + + interface Table extends Sequence { + indexCreate(name:string, index?:ExpressionFunction):Operation; + indexDrop(name:string):Operation; + indexList():Operation; + + insert(obj:any[], options?:InsertOptions):Operation; + insert(obj:any, options?:InsertOptions):Operation; + + get(key:string):Expression; // primary key + getAll(key:string, index?:Index):Selection; // without index defaults to primary key + getAll(...keys:string[]):Selection; + } + + interface Sequence extends Operation, Writeable { + + between(lower:any, upper:any, index?:Index):Sequence; + filter(rql:ExpressionFunction):Sequence; + filter(rql:Expression):Sequence; + filter(obj:{[key:string]:any}):Sequence; + + + // Join + // these return left, right + innerJoin(sequence:Sequence, join:ExpressionFunction):Sequence; + outerJoin(sequence:Sequence, join:ExpressionFunction):Sequence; + eqJoin(leftAttribute:string, rightSequence:Sequence, index?:Index):Sequence; + eqJoin(leftAttribute:ExpressionFunction, rightSequence:Sequence, index?:Index):Sequence; + zip():Sequence; + + // Transform + map(transform:ExpressionFunction):Sequence; + withFields(...selectors:any[]):Sequence; + concatMap(transform:ExpressionFunction):Sequence; + orderBy(...keys:string[]):Sequence; + orderBy(...sorts:Sort[]):Sequence; + skip(n:number):Sequence; + limit(n:number):Sequence; + slice(start:number, end?:number):Sequence; + nth(n:number):Expression; + indexesOf(obj:any):Sequence; + isEmpty():Expression; + union(sequence:Sequence):Sequence; + sample(n:number):Sequence; + + // Aggregate + reduce(r:Reduce, base?:any):Expression; + count():Expression; + distinct():Sequence; + groupedMapReduce(group:ExpressionFunction, map:ExpressionFunction, reduce:Reduce, base?:any):Expression; + groupBy(...aggregators:Aggregator[]):Expression; // TODO: reduction object + contains(prop:string):Expression; + + // Manipulation + pluck(...props:string[]):Sequence; + without(...props:string[]):Sequence; + } + + interface ExpressionFunction { + (...docs:Expression[]):Expression; + } + + interface Reduce { + (acc:any, val:any):any; + } + + interface InsertOptions { + upsert: boolean; // true + durability: string; // 'soft' + return_vals: boolean; // false + } + + interface UpdateOptions { + non_atomic: boolean; + durability: string; // 'soft' + return_vals: boolean; // false + } + + interface WriteResult { + inserted: number; + replaced: number; + unchanged: number; + errors: number; + deleted: number; + skipped: number; + first_error: Error; + generated_keys: string[]; // only for insert + } + + interface JoinResult { + left:any; + right:any; + } + + interface CreateResult { + created: number; + } + + interface DropResult { + dropped: number; + } + + interface Index { + index: string; + left_bound: string; // 'closed' + right_bound: string; // 'open' + } + + interface Expression extends Writeable, Operation { + (prop:string):Expression; + merge(query:Expression):Expression; + append(prop:string):Expression; + contains(prop:string):Expression; + + and(b:boolean):Expression; + or(b:boolean):Expression; + eq(v:any):Expression; + ne(v:any):Expression; + not():Expression; + + gt(value:T):Expression; + ge(value:T):Expression; + lt(value:T):Expression; + le(value:T):Expression; + + add(n:number):Expression; + sub(n:number):Expression; + mul(n:number):Expression; + div(n:number):Expression; + mod(n:number):Expression; + } + + interface Operation { + run(conn:Connection, cb:(err:Error, result:T)=>void); + } + + interface Aggregator {} + interface Sort {} + + + // http://www.rethinkdb.com/api/#js + // TODO control structures +} diff --git a/rethinkdb/rethinkdb.d.ts.tscparams b/rethinkdb/rethinkdb.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rethinkdb/rethinkdb.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/reveal/reveal-tests.ts.tscparams b/reveal/reveal-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/reveal/reveal-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/reveal/reveal.d.ts.tscparams b/reveal/reveal.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/reveal/reveal.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/routie/routie.d.ts.tscparams b/routie/routie.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/routie/routie.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/royalslider/royalslider-tests.ts.tscparams b/royalslider/royalslider-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/royalslider/royalslider-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.aggregates.d.ts.tscparams b/rx.js/rx.js.aggregates.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.aggregates.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.binding.d.ts b/rx.js/rx.js.binding.d.ts index 7f34fcb01..b1f7c687a 100644 --- a/rx.js/rx.js.binding.d.ts +++ b/rx.js/rx.js.binding.d.ts @@ -15,14 +15,26 @@ declare module Rx { new (bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject; } + var ReplaySubject: { + new (bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject; + } + interface BehaviorSubject extends ISubject { new (initialValue: T): BehaviorSubject; } + var BehaviorSubject: { + new (initialValue: T): BehaviorSubject; + } + interface ConnectableObservable extends IObservable{ connect(): _IDisposable; refCount(): IObservable; - } + } + + var ConnectableObservable: { + new (): ConnectableObservable; + } interface IObservable { diff --git a/rx.js/rx.js.binding.d.ts.tscparams b/rx.js/rx.js.binding.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.binding.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.coincidence.d.ts.tscparams b/rx.js/rx.js.coincidence.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.coincidence.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.d.ts b/rx.js/rx.js.d.ts index dbb7adb5c..cda048cf1 100644 --- a/rx.js/rx.js.d.ts +++ b/rx.js/rx.js.d.ts @@ -430,13 +430,13 @@ declare module Rx { dispose(): void; } - export interface Subject { - create(observer?: IObserver, observable?: IObservable): ISubject; - } + export interface Subject extends ISubject { + create(observer?: IObserver, observable?: IObservable): ISubject; + } - var Subject: { - new (): ISubject; - } + var Subject: { + new (): Subject; + } interface IAsyncSubject extends IObservable, IObserver { isDisposed: boolean; diff --git a/rx.js/rx.js.d.ts.tscparams b/rx.js/rx.js.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.joinpatterns.d.ts.tscparams b/rx.js/rx.js.joinpatterns.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.joinpatterns.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.jquery.d.ts.tscparams b/rx.js/rx.js.jquery.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.jquery.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/rx.js/rx.js.time.d.ts.tscparams b/rx.js/rx.js.time.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/rx.js/rx.js.time.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/sammyjs/sammyjs-tests.ts.tscparams b/sammyjs/sammyjs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sammyjs/sammyjs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/sammyjs/sammyjs.d.ts.tscparams b/sammyjs/sammyjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sammyjs/sammyjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/scroller/scroller-tests.ts.tscparams b/scroller/scroller-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/scroller/scroller-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/select2/select2-tests.ts.tscparams b/select2/select2-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/select2/select2-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/select2/select2.d.ts b/select2/select2.d.ts index 886ae6d34..842b75ef7 100644 --- a/select2/select2.d.ts +++ b/select2/select2.d.ts @@ -47,7 +47,7 @@ interface Select2Options { closeOnSelect?: boolean; openOnEnter?: boolean; id?: (object: any) => string; - matcher?: (term: string, text: string, option: JQuery) => boolean; + matcher?: (term: string, text: string, option: any) => boolean; formatSelection?: (object: any, container: JQuery) => string; formatResult?: (object: any, container: JQuery, query: any) => string; formatResultCssClass?: (object: any) => string; @@ -71,7 +71,19 @@ interface Select2Options { escapeMarkup?: (markup: string) => string; } +interface Select2JQueryEventObject extends JQueryEventObject { + val: any; + added: any; + removed: any; +} + interface JQuery { + off(events?: "change", selector?: any, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + + on(events: "change", selector?: string, data?: any, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "change", selector?: string, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + on(events: "change", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery; + select2(): JQuery; select2(it: IdTextPair): JQuery; select2(options: Select2Options): JQuery; diff --git a/sharepoint/SharePoint-tests.ts.tscparams b/sharepoint/SharePoint-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sharepoint/SharePoint-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 0ce535fa3..4671ba19e 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -3,6 +3,8 @@ // Definitions by: Stanislav Vyshchepan and Andrey Markeev // Definitions: https://github.com/borisyankov/DefinitelyTyped + + declare module Sys { export class EventArgs { static Empty: Sys.EventArgs; @@ -25,11 +27,39 @@ declare module Sys { initialize(): void; updated(): void; } + + export interface IContainer { + addComponent(component: Component): void; + findComponent(id: string): Component; + getComponents(): Component[]; + removeComponent(component: Component); + } + + export class Application extends Component implements IContainer { + addComponent(component: Component): void; + findComponent(id: string): Component; + getComponents(): Component[]; + removeComponent(component: Component); + + static add_load(handler: (sender: Application, eventArgs: ApplicationLoadEventArgs) => void); + static remove_load(handler: (sender: Application, eventArgs: ApplicationLoadEventArgs) => void); + } + + export class ApplicationLoadEventArgs { + constructor(components: Component[], isPartialLoad: boolean); + public components: Component[]; + public isPartialLoad: boolean; + } + module UI { - export class Control { } + export class Control extends Component { } export class DomEvent { - static addHandler(element: HTMLElement, eventName: string, handler: (e: Event) => void ); - static removeHandler(element: HTMLElement, eventName: string, handler: (e: Event) => void ); + static addHandler(element: HTMLElement, eventName: string, handler: (e: Event) => void); + static removeHandler(element: HTMLElement, eventName: string, handler: (e: Event) => void); + } + + export class DomElement { + static getBounds(element: HTMLElement): { x: number; y: number; width: number; height: number; }; } } module Net { @@ -52,8 +82,8 @@ declare module Sys { invoke(): void; completed(args: Sys.EventArgs): void; - add_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; - remove_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + add_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void): void; + remove_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void): void; } export class WebRequestExecutor { @@ -84,11 +114,11 @@ declare module Sys { static get_defaultTimeout(): number; static set_defaultTimeout(value: number): void; - static executeRequest(request: WebRequest):void; - static add_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; - static remove_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; - static add_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs) => void ): void; - static remove_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs ) => void ): void; + static executeRequest(request: WebRequest): void; + static add_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void): void; + static remove_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void): void; + static add_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs) => void): void; + static remove_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs) => void): void; } export class WebServiceProxy { @@ -97,8 +127,8 @@ declare module Sys { methodName: string, useGet?: boolean, params?: any, - onSuccess?: (result: string, eventArgs: EventArgs) => void , - onFailure?: (error: WebServiceError) => void , + onSuccess?: (result: string, eventArgs: EventArgs) => void, + onFailure?: (error: WebServiceError) => void, userContext?: any, timeout?: number, enableJsonp?: boolean, @@ -121,20 +151,20 @@ declare module Sys { } declare var $get: { (id: string): HTMLElement; }; -declare var $addHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void ): void; }; -declare var $removeHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void ): void; }; +declare var $addHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void): void; }; +declare var $removeHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void): void; }; declare module SP { export class SOD { static execute(fileName: string, functionName: string, ...args: any[]): void; - static executeFunc(fileName: string, typeName: string, fn: () => void ): void; + static executeFunc(fileName: string, typeName: string, fn: () => void): void; static executeOrDelayUntilEventNotified(func: Function, eventName: string): boolean; - static executeOrDelayUntilScriptLoaded(func: () => void , depScriptFileName: string): boolean; + static executeOrDelayUntilScriptLoaded(func: () => void, depScriptFileName: string): boolean; static notifyScriptLoadedAndExecuteWaitingJobs(scriptFileName: string): void; static notifyEventAndExecuteWaitingJobs(eventName: string, args?: any[]): void; static registerSod(fileName: string, url: string): void; static registerSodDep(fileName: string, dependentFileName: string): void; - static loadMultiple(keys: string[], fn: () => void , bSync?: boolean): void; + static loadMultiple(keys: string[], fn: () => void, bSync?: boolean): void; static delayUntilEventNotified(func: Function, eventName: string): void; static get_prefetch(): boolean; @@ -148,7 +178,7 @@ declare module SP { } /** Register function to rerun on partial update in MDS-enabled site.*/ -declare function RegisterModuleInit(scriptFileName: string, initFunc: () => void ): void; +declare function RegisterModuleInit(scriptFileName: string, initFunc: () => void): void; /** Provides access to url and query string parts.*/ declare class JSRequest { @@ -216,8 +246,8 @@ declare module SP { set_formDigestHandlingEnabled(value: boolean): void; get_iFrameSourceUrl(): string; set_iFrameSourceUrl(value: string): void; - executeAsync(requestInfo:RequestInfo): void; - attemptLogin(returnUrl:string, success: (response: ResponseInfo) => void , error?: (response: ResponseInfo, error: RequestExecutorErrors, statusText: string) => void): void; + executeAsync(requestInfo: RequestInfo): void; + attemptLogin(returnUrl: string, success: (response: ResponseInfo) => void, error?: (response: ResponseInfo, error: RequestExecutorErrors, statusText: string) => void): void; } export interface RequestInfo { @@ -257,8 +287,7 @@ declare module SP { createWebRequestExecutor(): ProxyWebRequestExecutor; } } -interface MQuery -{ +interface MQuery { (selector: string, context?: any): MQueryResultSetElements; (element: HTMLElement): MQueryResultSetElements; (object: MQueryResultSetElements): MQueryResultSetElements; @@ -292,7 +321,7 @@ interface MQuery isObject(obj: any): boolean; isEmptyObject(obj: any): boolean; - ready(callback: () => void ): void; + ready(callback: () => void): void; contains(container: HTMLElement, contained: HTMLElement): boolean; proxy(fn: (...args: any[]) => any, context: any, ...args: any[]): Function; @@ -330,21 +359,21 @@ interface MQuery data(element: HTMLElement, key: string): any; data(element: HTMLElement): any; - removeData(element: HTMLElement, name?: string): MQueryResultSet; + removeData(element: HTMLElement, name?: string): MQueryResultSetElements; hasData(element: HTMLElement): boolean; } -interface MQueryResultSetElements extends MQueryResultSet{ +interface MQueryResultSetElements extends MQueryResultSet { append(node: HTMLElement): MQueryResultSetElements; append(mQuerySet: MQueryResultSetElements): MQueryResultSetElements; append(html: string): MQueryResultSetElements; bind(eventType: string, handler: (eventObject: MQueryEvent) => any): MQueryResultSetElements; unbind(eventType: string, handler: (eventObject: MQueryEvent) => any): MQueryResultSetElements; - trigger(eventType: string): MQueryResultSet; + trigger(eventType: string): MQueryResultSetElements; one(eventType: string, handler: (eventObject: MQueryEvent) => any): MQueryResultSetElements; - detach(): MQueryResultSet; + detach(): MQueryResultSetElements; find(selector: string): MQueryResultSetElements; closest(selector: string, context?: any): MQueryResultSetElements; @@ -550,12 +579,12 @@ declare class CalloutAction { render(): void; isEnabled(): boolean; isVisible(): boolean; - set (options: CalloutActionOptions): void; + set(options: CalloutActionOptions): void; } declare class Callout { /** Sets options for the callout. Not all options can be changed for the callout after its creation. */ - set (options: CalloutOptions); + set(options: CalloutOptions); /** Adds event handler to the callout. @param eventName one of the following: "opened", "opening", "closing", "closed" */ addEventCallback(eventName: string, callback: (callout: Callout) => void); @@ -755,9 +784,8 @@ declare module SPClientTemplates { /** Returns string representation of a number that represents the current value for the "List Throttle Limit" web application setting. Only appears if Throttled property is true, i.e. the target lookup list is throttled. */ MaxQueryResult: string; - /** List of choices for this field. - For a lookup field, contains array of possible values pulled from the target lookup list. */ - Choices: string[]; + /** List of choices for this field. */ + Choices: { LookupId: number; LookupValue: string; }[]; /** Number of choices. Appears only for Lookup field. */ ChoiceCount: number; @@ -1212,7 +1240,7 @@ declare module SPClientTemplates { export interface TemplateOverrides { View?: (renderContext: any) => string; // TODO: determine appropriate context type and purpose of this template - Body?: (renderContext: any) => string; // TODO: determine appropriate context type and purpose of this template + Body?: (renderContext: any) => string; // TODO: determine appropriate context type and purpose of this template /** Defines templates for rendering groups (aggregations). */ Group?: GroupCallback; /** Defines templates for list items rendering. */ @@ -1236,10 +1264,10 @@ declare module SPClientTemplates { /** �allbacks called after rendered html inserted into DOM. Can be function (ctx: RenderContext) => void or array of functions.*/ OnPostRender?: any; - /** View style (SPView.StyleID) for which the templates should be applied. + /** View style (SPView.StyleID) for which the templates should be applied. If not defined, the templates will be applied only to default view style. */ ViewStyle?: number; - /** List template type (SPList.BaseTemplate) for which the template should be applied. + /** List template type (SPList.BaseTemplate) for which the template should be applied. If not defined, the templates will be applied to all lists. */ ListTemplateType?: number; /** Base view ID (SPView.BaseViewID) for which the template should be applied. @@ -1321,13 +1349,13 @@ declare module SPClientTemplates { EnableVesioning: boolean; Id: string; }; - registerInitCallback(fieldname: string, callback: () => void ): void; - registerFocusCallback(fieldname: string, callback: () => void ): void; - registerValidationErrorCallback(fieldname: string, callback: (error: any) => void ): void; + registerInitCallback(fieldname: string, callback: () => void): void; + registerFocusCallback(fieldname: string, callback: () => void): void; + registerValidationErrorCallback(fieldname: string, callback: (error: any) => void): void; registerGetValueCallback(fieldname: string, callback: () => any): void; updateControlValue(fieldname: string, value: any): void; registerClientValidator(fieldname: string, validator: SPClientForms.ClientValidation.ValidatorSet): void; - registerHasValueChangedCallback(fieldname: string, callback: (eventArg?: any) => void ); + registerHasValueChangedCallback(fieldname: string, callback: (eventArg?: any) => void); } } @@ -1406,23 +1434,23 @@ declare module SPAnimation { GetDataIndex(attributeId: Attribute): number } - export class Object{ - constructor(animationID: ID, delay: number, element: HTMLElement, finalState: State, finishFunc?: (data: any) => void , data?: any); - constructor(animationID: ID, delay: number, element: HTMLElement[], finalState: State, finishFunc?: (data: any) => void , data?: any); + export class Object { + constructor(animationID: ID, delay: number, element: HTMLElement, finalState: State, finishFunc?: (data: any) => void, data?: any); + constructor(animationID: ID, delay: number, element: HTMLElement[], finalState: State, finishFunc?: (data: any) => void, data?: any); RunAnimation(): void; } } -declare module SPAnimationUtility{ +declare module SPAnimationUtility { export class BasicAnimator { - static FadeIn(element: HTMLElement, finishFunc?: (data: any) => void , data?: any): void; - static FadeOut (element: HTMLElement, finishFunc?: (data: any) => void , data?: any): void; - static Move(element: HTMLElement, posX:number, posY:number, finishFunc?: (data: any) => void , data?: any): void; - static StrikeThrough(element: HTMLElement, strikeThroughWidth: number, finishFunc?: (data: any) => void , data?: any): void; - static Resize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void , data?: any): void; - static CommonResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: (data: any) => void , data: any, animationId:SPAnimation.ID): void; - static QuickResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void , data?: any): void; - static ResizeContainerAndFillContent(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: () => void , fAddToEnd: boolean): void; + static FadeIn(element: HTMLElement, finishFunc?: (data: any) => void, data?: any): void; + static FadeOut(element: HTMLElement, finishFunc?: (data: any) => void, data?: any): void; + static Move(element: HTMLElement, posX: number, posY: number, finishFunc?: (data: any) => void, data?: any): void; + static StrikeThrough(element: HTMLElement, strikeThroughWidth: number, finishFunc?: (data: any) => void, data?: any): void; + static Resize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void, data?: any): void; + static CommonResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: (data: any) => void, data: any, animationId: SPAnimation.ID): void; + static QuickResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void, data?: any): void; + static ResizeContainerAndFillContent(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: () => void, fAddToEnd: boolean): void; static GetWindowScrollPosition(): { x: number; y: number; }; static GetLeftOffset(element: HTMLElement): number; static GetTopOffset(element: HTMLElement): number; @@ -1669,13 +1697,13 @@ declare module SP { get_expectedContentType(): string; set_expectedContentType(value: string): void; post(body: string): void; - get (): void; - static doPost(url: string, body: string, expectedContentType: string, succeededHandler: (sender: any, args: SP.PageRequestSucceededEventArgs) => void , failedHandler: (sender: any, args: SP.PageRequestFailedEventArgs) => void ): void; - static doGet(url: string, expectedContentType: string, succeededHandler: (sender: any, args: SP.PageRequestSucceededEventArgs) => void , failedHandler: (sender: any, args: SP.PageRequestFailedEventArgs) => void ): void; - add_succeeded(value: (sender: any, args: SP.PageRequestSucceededEventArgs) => void ): void; - remove_succeeded(value: (sender: any, args: SP.PageRequestSucceededEventArgs) => void ): void; - add_failed(value: (sender: any, args: SP.PageRequestFailedEventArgs) => void ): void; - remove_failed(value: (sender: any, args: SP.PageRequestFailedEventArgs) => void ): void; + get(): void; + static doPost(url: string, body: string, expectedContentType: string, succeededHandler: (sender: any, args: SP.PageRequestSucceededEventArgs) => void, failedHandler: (sender: any, args: SP.PageRequestFailedEventArgs) => void): void; + static doGet(url: string, expectedContentType: string, succeededHandler: (sender: any, args: SP.PageRequestSucceededEventArgs) => void, failedHandler: (sender: any, args: SP.PageRequestFailedEventArgs) => void): void; + add_succeeded(value: (sender: any, args: SP.PageRequestSucceededEventArgs) => void): void; + remove_succeeded(value: (sender: any, args: SP.PageRequestSucceededEventArgs) => void): void; + add_failed(value: (sender: any, args: SP.PageRequestFailedEventArgs) => void): void; + remove_failed(value: (sender: any, args: SP.PageRequestFailedEventArgs) => void): void; constructor(); } export class ResResources { @@ -1929,10 +1957,10 @@ declare module SP { export class ClientRequest { static get_nextSequenceId(): number; get_webRequest(): Sys.Net.WebRequest; - add_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; - remove_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; - add_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; - remove_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; + add_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void): void; + remove_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void): void; + add_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void): void; + remove_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void): void; get_navigateWhenServerRedirect(): boolean; set_navigateWhenServerRedirect(value: boolean): void; } @@ -1967,18 +1995,18 @@ declare module SP { set_webRequestExecutorFactory(value: SP.IWebRequestExecutorFactory): void; get_pendingRequest(): SP.ClientRequest; get_hasPendingRequest(): boolean; - add_executingWebRequest(value: (sender: any, args: SP.WebRequestEventArgs) => void ): void; - remove_executingWebRequest(value: (sender: any, args: SP.WebRequestEventArgs) => void ): void; - add_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; - remove_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; - add_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; - remove_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; - add_beginningRequest(value: (sender: any, args: SP.ClientRequestEventArgs) => void ): void; - remove_beginningRequest(value: (sender: any, args: SP.ClientRequestEventArgs) => void ): void; + add_executingWebRequest(value: (sender: any, args: SP.WebRequestEventArgs) => void): void; + remove_executingWebRequest(value: (sender: any, args: SP.WebRequestEventArgs) => void): void; + add_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void): void; + remove_requestSucceeded(value: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void): void; + add_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void): void; + remove_requestFailed(value: (sender: any, args: SP.ClientRequestFailedEventArgs) => void): void; + add_beginningRequest(value: (sender: any, args: SP.ClientRequestEventArgs) => void): void; + remove_beginningRequest(value: (sender: any, args: SP.ClientRequestEventArgs) => void): void; get_requestTimeout(): number; set_requestTimeout(value: number): void; - executeQueryAsync(succeededCallback: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void , failedCallback: (sender: any, args: SP.ClientRequestFailedEventArgs) => void ): void; - executeQueryAsync(succeededCallback: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void ): void; + executeQueryAsync(succeededCallback: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void, failedCallback: (sender: any, args: SP.ClientRequestFailedEventArgs) => void): void; + executeQueryAsync(succeededCallback: (sender: any, args: SP.ClientRequestSucceededEventArgs) => void): void; executeQueryAsync(): void; get_staticObjects(): any; castTo(obj: SP.ClientObject, type: any): SP.ClientObject; @@ -2249,8 +2277,8 @@ declare module SP { get_versionString(): string; } export class AppCatalog { - static getAppInstances(context: SP.ClientRuntimeContext, web: SP.Web): SP.ClientObjectList; - static getDeveloperSiteAppInstancesByIds(context: SP.ClientRuntimeContext, site: SP.Site, appInstanceIds: SP.Guid[]): SP.ClientObjectList; + static getAppInstances(context: SP.ClientRuntimeContext, web: SP.Web): SP.ClientObjectList; + static getDeveloperSiteAppInstancesByIds(context: SP.ClientRuntimeContext, site: SP.Site, appInstanceIds: SP.Guid[]): SP.ClientObjectList; static isAppSideloadingEnabled(context: SP.ClientRuntimeContext): SP.BooleanResult; } export class AppContextSite extends SP.ClientObject { @@ -2271,7 +2299,7 @@ declare module SP { get_status(): SP.AppInstanceStatus; get_title(): string; get_webId(): SP.Guid; - getErrorDetails(): SP.ClientObjectList; + getErrorDetails(): SP.ClientObjectList; uninstall(): SP.GuidResult; upgrade(appPackageStream: any[]): void; cancelAllJobs(): SP.BooleanResult; @@ -2357,7 +2385,7 @@ declare module SP { constructor(); } export class BasePermissions extends SP.ClientValueObject { - set (perm: SP.PermissionKind): void; + set(perm: SP.PermissionKind): void; clear(perm: SP.PermissionKind): void; clearAll(): void; has(perm: SP.PermissionKind): boolean; @@ -2402,12 +2430,12 @@ declare module SP { /** Specifies a Collaborative Application Markup Language (CAML) query on a list. */ export class CamlQuery extends SP.ClientValueObject { constructor(); - /** This method creates a Collaborative Application Markup Language (CAML) string - that can be used to recursively get all of the items in a list, including + /** This method creates a Collaborative Application Markup Language (CAML) string + that can be used to recursively get all of the items in a list, including the items in the subfolders. */ static createAllItemsQuery(): SP.CamlQuery; - /** This method creates a Collaborative Application Markup Language (CAML) string - that can be used to recursively get all of the folders in a list, including + /** This method creates a Collaborative Application Markup Language (CAML) string + that can be used to recursively get all of the folders in a list, including the subfolders. */ static createAllFoldersQuery(): SP.CamlQuery; /** Returns true if the query returns dates in Coordinated Universal Time (UTC) format. */ @@ -3921,7 +3949,7 @@ declare module SP { get_isSharedWithMany(): boolean; get_isSharedWithSecurityGroup(): boolean; get_pendingAccessRequestsLink(): string; - getSharedWithUsers(): SP.ClientObjectList; + getSharedWithUsers(): SP.ClientObjectList; static getListItemSharingInformation(context: SP.ClientRuntimeContext, listID: SP.Guid, itemID: number, excludeCurrentUser: boolean, excludeSiteAdmin: boolean, excludeSecurityGroups: boolean, retrieveAnonymousLinks: boolean, retrieveUserInfoDetails: boolean, checkForAccessRequests: boolean): SP.ObjectSharingInformation; static getWebSharingInformation(context: SP.ClientRuntimeContext, excludeCurrentUser: boolean, excludeSiteAdmin: boolean, excludeSecurityGroups: boolean, retrieveAnonymousLinks: boolean, retrieveUserInfoDetails: boolean, checkForAccessRequests: boolean): SP.ObjectSharingInformation; static getObjectSharingInformation(context: SP.ClientRuntimeContext, securableObject: SP.SecurableObject, excludeCurrentUser: boolean, excludeSiteAdmin: boolean, excludeSecurityGroups: boolean, retrieveAnonymousLinks: boolean, retrieveUserInfoDetails: boolean, checkForAccessRequests: boolean, retrievePermissionLevels: boolean): SP.ObjectSharingInformation; @@ -4120,7 +4148,7 @@ declare module SP { get_value(): string; static newObject(context: SP.ClientRuntimeContext): SP.RequestVariable; append(value: string): void; - set (value: string): void; + set(value: string): void; } export class RoleAssignment extends SP.ClientObject { get_member(): SP.Principal; @@ -4193,7 +4221,7 @@ declare module SP { editor, } export class ServerSettings { - static getAlternateUrls(context: SP.ClientRuntimeContext): SP.ClientObjectList; + static getAlternateUrls(context: SP.ClientRuntimeContext): SP.ClientObjectList; static getGlobalInstalledLanguages(context: SP.ClientRuntimeContext, compatibilityLevel: number): SP.Language[]; } export class Site extends SP.ClientObject { @@ -4644,7 +4672,7 @@ declare module SP { getAppBdcCatalog(): SP.BusinessData.AppBdcCatalog; getSubwebsForCurrentUser(query: SP.SubwebQuery): SP.WebCollection; getAppInstanceById(appInstanceId: SP.Guid): SP.AppInstance; - getAppInstancesByProductId(productId: SP.Guid): SP.ClientObjectList; + getAppInstancesByProductId(productId: SP.Guid): SP.ClientObjectList; loadAndInstallAppInSpecifiedLocale(appPackageStream: any[], installationLocaleLCID: number): SP.AppInstance; loadApp(appPackageStream: any[], installationLocaleLCID: number): SP.AppInstance; loadAndInstallApp(appPackageStream: any[]): SP.AppInstance; @@ -4813,8 +4841,8 @@ declare module SP { set_moreColorsPicker(value: SP.Application.UI.MoreColorsPicker): void; } export class ThemeWebPage extends Sys.UI.Control { - add_themeDisplayUpdated(value: (sender: any, e: Sys.EventArgs) => void ): void; - remove_themeDisplayUpdated(value: (sender: any, e: Sys.EventArgs) => void ): void; + add_themeDisplayUpdated(value: (sender: any, e: Sys.EventArgs) => void): void; + remove_themeDisplayUpdated(value: (sender: any, e: Sys.EventArgs) => void): void; constructor(e: HTMLElement); initialize(): void; dispose(): void; @@ -5000,11 +5028,11 @@ declare module Microsoft.SharePoint.Client.Search { getQuerySuggestionsWithResults: (iNumberOfQuerySuggestions: number, - iNumberOfResultSuggestions: number, - fPreQuerySuggestions: boolean, - fHitHighlighting: boolean, - fCapitalizeFirstLetters: boolean, - fPrefixMatchAllTerms: boolean) => QuerySuggestionResults; + iNumberOfResultSuggestions: number, + fPreQuerySuggestions: boolean, + fHitHighlighting: boolean, + fCapitalizeFirstLetters: boolean, + fPrefixMatchAllTerms: boolean) => QuerySuggestionResults; } @@ -5050,15 +5078,15 @@ declare module Microsoft.SharePoint.Client.Search { executeQuery: (query: Query) => SP.JsonObjectResult; executeQueries: (queryIds: string[], queries: Query[], handleExceptions: boolean) => SP.JsonObjectResult; recordPageClick: ( - pageInfo: string, - clickType: string, - blockType: number, - clickedResultId: string, - subResultIndex: number, - immediacySourceId: string, - immediacyQueryString: string, - immediacyTitle: string, - immediacyUrl: string) => void; + pageInfo: string, + clickType: string, + blockType: number, + clickedResultId: string, + subResultIndex: number, + immediacySourceId: string, + immediacyQueryString: string, + immediacyTitle: string, + immediacyUrl: string) => void; exportPopularQueries: (web: SP.Web, sourceId: SP.Guid) => SP.JsonObjectResult; } @@ -5364,14 +5392,14 @@ declare module Microsoft.SharePoint.Client.Search { export class DocumentCrawlLog extends SP.ClientObject { constructor(context: SP.ClientContext, site: SP.Site); getCrawledUrls: (getCountOnly: boolean, - maxRows: { High: number; Low: number; }, - queryString: string, - isLike: boolean, - contentSourceID: number, - errorLevel: number, - errorID: number, - startDateTime: Date, - endDateTime: Date) => SP.JsonObjectResult; + maxRows: { High: number; Low: number; }, + queryString: string, + isLike: boolean, + contentSourceID: number, + errorLevel: number, + errorID: number, + startDateTime: Date, + endDateTime: Date) => SP.JsonObjectResult; } export class SearchObjectOwner extends SP.ClientObject { @@ -5819,7 +5847,7 @@ declare module SP { /** Contains information about an actor retrieved from server. An actor is a user, document, site, or tag. */ export class SocialActor extends SP.ClientValueObject { - /** The AccountName property returns the user account name. + /** The AccountName property returns the user account name. This property is only available for social actors of type "user". */ get_accountName(): string; /** Identifies whether the actor is a user, document, site, or tag. */ @@ -5850,7 +5878,7 @@ declare module SP { get_personalSiteUri(): string; /** Represents the status of retrieving the actor */ get_status(): SocialStatusCode; - /** The StatusText property returns the most recent post of the user. + /** The StatusText property returns the most recent post of the user. This property is only available for social actors of type "user". */ get_statusText(): string; /** Returns the GUID of the tag. @@ -5865,10 +5893,10 @@ declare module SP { /** Identifies an actor to the server. An actor can be a user, document, site, or tag. */ export class SocialActorInfo extends SP.ClientValueObject { - /** User account name. + /** User account name. This property is only available for social actors of type "user". */ get_accountName(): string; - /** User account name. + /** User account name. This property is only available for social actors of type "user". */ set_accountName(value: string): string; /** Identifies whether the actor is a user, document, site, or tag. */ @@ -5979,7 +6007,7 @@ declare module SP { } /** Provides information about an overlay. - An overlay is a substring in a post that represents a user, document, site, tag, or link. + An overlay is a substring in a post that represents a user, document, site, tag, or link. The SocialPost class contains an array of SocialDataOverlay objects. Each of the SocialDataOverlay objects specifies a link or one or more actors. */ export class SocialDataOverlay extends SP.ClientValueObject { @@ -6016,8 +6044,8 @@ declare module SP { The most recent post that was requested can be removed from the feed if the current user does not have access to it. Consequently, the feed does not always contain the post with the date specified in this property. */ get_newestProcessed(): string; - /** The OldestProcessed property returns the date-time of the oldest post that was requested. - The oldest post that was requested can be removed from the feed if the current user does not have access to it. + /** The OldestProcessed property returns the date-time of the oldest post that was requested. + The oldest post that was requested can be removed from the feed if the current user does not have access to it. Consequently, the feed does not always contain the post with the date specified in this property */ get_oldestProcessed(): string; /** Contains the social threads in the feed. */ @@ -6034,7 +6062,7 @@ declare module SP { get_owner(): SocialActor; /** Specifies the URI of the personal site portal. */ get_personalSitePortalUri(): string; - /** Creates a post in the current user's newsfeed, in the specified user's feed, or in the specified thread. + /** Creates a post in the current user's newsfeed, in the specified user's feed, or in the specified thread. This method returns a new or a modified thread. @param targetId Optional, specifies the target of the post. If this parameter is null, the post is created as a root post in the current user's feed. @@ -6067,19 +6095,19 @@ declare module SP { getFullThread(threadId: string): SocialThread; /** Returns a feed containing mention reference threads from the current user's personal feed. */ getMentions(clearUnreadMentions: boolean, options: SocialFeedOptions): SocialFeed; - /** Returns the server's count of unread mentions of the current user. - The server maintains a count of unread mentions in posts, but does not track which mentions have been read. - When a new mention is stored on the server, it increments the unread mention for the user specified by the mention. + /** Returns the server's count of unread mentions of the current user. + The server maintains a count of unread mentions in posts, but does not track which mentions have been read. + When a new mention is stored on the server, it increments the unread mention for the user specified by the mention. The unread mention count is cleared by the GetMentions method. */ getUnreadMentionCount(): SP.IntResult; - /** Specifies that the current user likes the specified post. - Returns a digest thread containing the specified post. + /** Specifies that the current user likes the specified post. + Returns a digest thread containing the specified post. A digest thread contains the root post and a selection of reply posts */ likePost(postId: string): SocialThread; - /** Specifies that the current user does not like the specified post. + /** Specifies that the current user does not like the specified post. Returns a digest thread containing the specified post. */ unlikePost(postId: string): SocialThread; - /** Prevents any user from adding a new reply post to the specified thread. + /** Prevents any user from adding a new reply post to the specified thread. Once a thread is locked, no new reply posts can be added until after the thread has been unlocked with the unlockThread method. This method returns a digest of the locked thread */ lockThread(threadId: string): SocialThread; @@ -6105,7 +6133,7 @@ declare module SP { set_newerThan(value: string): string; get_olderThan(): string; set_olderThan(value: string): string; - get_sortOrder():SocialFeedSortOrder; + get_sortOrder(): SocialFeedSortOrder; set_sortOrder(value: SocialFeedSortOrder): SocialFeedSortOrder; } @@ -6119,9 +6147,9 @@ declare module SP { get_followedSitesUri(): string; /** Adds the specified actor to the current user's list of followed items. Returns one of the following values, wrapped into the SP.IntResult object: - 0 = ok, - 1 = alreadyFollowing, - 2 = limitReached, + 0 = ok, + 1 = alreadyFollowing, + 2 = limitReached, 3 = internalError */ follow(actor: SocialActorInfo): SP.IntResult; stopFollowing(actor: SocialActorInfo): SP.BooleanResult; @@ -6254,10 +6282,10 @@ declare module SP { get_text(): string; /** Specifies the text that is substituted for the placeholder */ set_text(value: string): string; - /** Specifies the URI of the document, site, or link. + /** Specifies the URI of the document, site, or link. This property is only available if the ItemType property specifies that the item is a Document, Link, or Site. */ get_uri(): string; - /** Specifies the URI of the document, site, or link. + /** Specifies the URI of the document, site, or link. This property is only available if the ItemType property specifies that the item is a Document, Link, or Site. */ set_uri(value: string): string; } @@ -6727,7 +6755,7 @@ declare module SP { get_selectedEntities(): any; set_selectedEntities(value: any): void; get_callback(): (sender: any, e: Sys.EventArgs) => void; - set_callback(value: (sender: any, e: Sys.EventArgs) => void ): void; + set_callback(value: (sender: any, e: Sys.EventArgs) => void): void; get_scopeKey(): string; get_componentType(): SP.UI.ApplicationPages.SelectorType; revertTo(ent: SP.UI.ApplicationPages.ResolveEntity): void; @@ -6745,7 +6773,7 @@ declare module SP { static instance(): SP.UI.ApplicationPages.CalendarSelector; registerSelector(selector: SP.UI.ApplicationPages.ISelectorComponent): void; getSelector(type: SP.UI.ApplicationPages.SelectorType, scopeKey: string): SP.UI.ApplicationPages.ISelectorComponent; - addHandler(scopeKey: string, people: boolean, resource: boolean, handler: (sender: any, selection: SP.UI.ApplicationPages.SelectorSelectionEventArgs) => void ): void; + addHandler(scopeKey: string, people: boolean, resource: boolean, handler: (sender: any, selection: SP.UI.ApplicationPages.SelectorSelectionEventArgs) => void): void; revertTo(scopeKey: string, ent: SP.UI.ApplicationPages.ResolveEntity): void; removeEntity(scopeKey: string, ent: SP.UI.ApplicationPages.ResolveEntity): void; constructor(); @@ -6757,7 +6785,7 @@ declare module SP { get_selectedEntities(): any; set_selectedEntities(value: any): void; get_callback(): (sender: any, e: Sys.EventArgs) => void; - set_callback(value: (sender: any, e: Sys.EventArgs) => void ): void; + set_callback(value: (sender: any, e: Sys.EventArgs) => void): void; revertTo(ent: SP.UI.ApplicationPages.ResolveEntity): void; removeEntity(ent: SP.UI.ApplicationPages.ResolveEntity): void; setEntity(ent: SP.UI.ApplicationPages.ResolveEntity): void; @@ -6889,8 +6917,8 @@ declare module SP { OnNotificationCountChanged, } export class SPNotification { - constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string, onclickHandler: () => void , extraData: any); - constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string, onclickHandler: () => void ); + constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string, onclickHandler: () => void, extraData: any); + constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string, onclickHandler: () => void); constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean, strTooltip: string); constructor(containerId: SP.UI.ContainerID, strHtml: string, bSticky: boolean); constructor(containerId: SP.UI.ContainerID, strHtml: string); @@ -6915,8 +6943,8 @@ declare module SP { constructor(); } export class Workspace { - static add_resized(handler: () => void ): void; - static remove_resized(handler: () => void ): void; + static add_resized(handler: () => void): void; + static remove_resized(handler: () => void): void; } export class Menu { static create(id: string): SP.UI.Menu; @@ -7062,6 +7090,93 @@ declare module SP { } } +declare module SP { + export module UI { + export module Controls { + + export interface INavigationOptions { + assetId?: string; + siteTitle?: string; + siteUrl?: string; + appTitle?: string; + appTitleIconUrl?: string; + rightToLeft?: boolean; + appStartPage?: string; + appIconUrl?: string; + appHelpPageUrl?: string; + appHelpPageOnClick?: string; + settingsLinks?: ISettingsLink[]; + language?: string; + clientTag?: string; + appWebUrl?: string; + onCssLoaded?: string; + + + bottomHeaderVisible?: boolean; + topHeaderVisible?: boolean; + } + + export class NavigationOptions implements INavigationOptions { } + + + export interface ISettingsLink { + linkUrl: string; + displayName: string; + } + + export class SettingsLink implements ISettingsLink { + linkUrl: string; + displayName: string; + } + + + export class Navigation { + constructor(placeholderDOMElementId: string, options: INavigationOptions); + public get_assetId(): string; + public get_siteTitle(): string; + public get_siteUrl(): string; + + public get_appTitle(): string; + public set_appTitle(value: string): string; + + public get_appTitleIconUrl(): string; + public set_appTitleIconUrl(value: string): string; + + public get_rightToLeft(): boolean; + public set_rightToLeft(value: boolean): boolean; + + public get_appStartPage(): string; + public set_appStartPage(value: string): string; + + public get_appIconUrl(): string; + public set_appIconUrl(value: string): string; + + public get_appHelpPageUrl(): string; + public set_appHelpPageUrl(value: string): string; + + public get_appHelpPageOnClick(): string; + public set_appHelpPageOnClick(value: string): string; + + public get_settingsLinks(): ISettingsLink[]; + public set_settingsLinks(value: ISettingsLink[]): ISettingsLink[]; + + public setVisible(value: boolean): void; + + public setTopHeaderVisible(value: boolean): void; + public setBottomHeaderVisible(value: boolean): void; + public remove(): void; + + static getVersionedLayoutsUrl(pageName: string): string; + } + + + export class ControlManager { + static getControl(placeHolderId: string): any; + } + } + } +} + declare module SP { export module UserProfiles { @@ -7134,7 +7249,7 @@ declare module SP { /** Gets suggestions for who the current user might want to follow. Note: The recommended API to use for this task is SocialFollowingManager.getSuggestions. Returns list of PersonProperties objects */ - getMySuggestions(): SP.ClientObjectList; + getMySuggestions(): SP.ClientObjectList; /** Removes the specified user from the user's list of suggested people to follow. */ hideSuggestion(accountName: string): void; follow(accountName: string): void; @@ -7146,10 +7261,10 @@ declare module SP { @param tagId GUID of the tag to stop following. */ stopFollowingTag(tagId: string): void; amIFollowing(accountName: string): SP.BooleanResult; - getPeopleFollowedByMe(): SP.ClientObjectList; - getPeopleFollowedBy(accountName: string): SP.ClientObjectList; - getMyFollowers(): SP.ClientObjectList; - getFollowersFor(accountName: string): SP.ClientObjectList; + getPeopleFollowedByMe(): SP.ClientObjectList; + getPeopleFollowedBy(accountName: string): SP.ClientObjectList; + getMyFollowers(): SP.ClientObjectList; + getFollowersFor(accountName: string): SP.ClientObjectList; amIFollowedBy(accountName: string): SP.BooleanResult; /** Uploads and sets the user profile picture. Pictures in bmp, jpg and png formats and up to 5,000,000 bytes are supported. @@ -7225,7 +7340,7 @@ declare module SP { /** Specifies the person's title. */ get_title(): string; /** Represents all user profile properties including custom. - The privacy settings affect which properties can be retrieved. + The privacy settings affect which properties can be retrieved. Multiple values are delimited by the vertical bar "|". Null values are specified as empty strings. */ get_userProfileProperties(): { [name: string]: string; }; @@ -7314,7 +7429,7 @@ declare module SP { /** Updates the properties for followed item with specified URL. @param url URL that identifies the followed item. The url parameter can identify an existing document or site using the url property of the original item. - The url parameter can also identify a document with the following format: http://host/site?listId=&itemId= + The url parameter can also identify a document with the following format: http://host/site?listId=&itemId= @param data Application-defined data stored with the followed item. */ updateData(url: string, data: FollowedItemData): void; /** Returns the refreshed item that is being pointed to in the Social list. @@ -7384,11 +7499,11 @@ declare module SP { /** Specifies the site identification (GUID) in the Content database for this item if this item is a site, or for its parent site if this item is not a site. */ set_siteId(value: string): string; /** Specifies the subtype of this item. - If the ItemType is Site, the Subtype specifies the web template identification. + If the ItemType is Site, the Subtype specifies the web template identification. If the ItemType is Document, the Subtype has a value of 1. */ get_subtype(): number; /** Specifies the subtype of this item. - If the ItemType is Site, the Subtype specifies the web template identification. + If the ItemType is Site, the Subtype specifies the web template identification. If the ItemType is Document, the Subtype has a value of 1. */ set_subtype(value: number): number; /** Specifies the item of this item */ @@ -7502,7 +7617,7 @@ declare module SP { static getLayoutsPageUrl(pageName: string): string; static getImageUrl(imageName: string): string; static createWikiPageInContextWeb(context: SP.ClientRuntimeContext, parameters: SP.Utilities.WikiPageCreationInformation): SP.File; - static localizeWebPartGallery(context: SP.ClientRuntimeContext, items: SP.ListItemCollection): SP.ClientObjectList; + static localizeWebPartGallery(context: SP.ClientRuntimeContext, items: SP.ListItemCollection): SP.ClientObjectList; static getAppLicenseInformation(context: SP.ClientRuntimeContext, productId: SP.Guid): SP.AppLicenseCollection; static importAppLicense(context: SP.ClientRuntimeContext, licenseTokenToImport: string, contentMarket: string, billingMarket: string, appName: string, iconUrl: string, providerName: string, appSubtype: number): void; static getAppLicenseDeploymentId(context: SP.ClientRuntimeContext): SP.GuidResult; @@ -8116,12 +8231,12 @@ declare module SP.WorkflowServices { } -declare class SPClientAutoFill{ - static MenuOptionType : { +declare class SPClientAutoFill { + static MenuOptionType: { Option: number; Footer: number; Separator: number; - Loading:number; + Loading: number; } static KeyProperty: string; //= 'AutoFillKey'; @@ -8134,7 +8249,7 @@ declare class SPClientAutoFill{ static GetAutoFillObjFromContainer(elmChild: HTMLElement): SPClientAutoFill; static GetAutoFillMenuItemFromOption(elmChild: HTMLElement): HTMLElement; - constructor(elmTextId: string, elmContainerId: string, fnPopulateAutoFill: (targetElement: HTMLInputElement) => void ); + constructor(elmTextId: string, elmContainerId: string, fnPopulateAutoFill: (targetElement: HTMLInputElement) => void); public TextElementId: string; public AutoFillContainerId: string; public AutoFillMenuId: string; @@ -8145,16 +8260,16 @@ declare class SPClientAutoFill{ public AutoFillCallbackTimeoutID: string; public FuncOnAutoFillClose: (elmTextId: string, ojData: ISPClientAutoFillData) => void; public FuncPopulateAutoFill: (targetElement: HTMLElement) => void; - public AllOptionData: { [key:string]: ISPClientAutoFillData }; + public AllOptionData: { [key: string]: ISPClientAutoFillData }; - PopulateAutoFill(jsonObjSuggestions: ISPClientAutoFillData[], fnOnAutoFillCloseFuncName: (elmTextId: string, objData:ISPClientAutoFillData) => void ): void; + PopulateAutoFill(jsonObjSuggestions: ISPClientAutoFillData[], fnOnAutoFillCloseFuncName: (elmTextId: string, objData: ISPClientAutoFillData) => void): void; IsAutoFillOpen(): boolean; SetAutoFillHeight(): void; - SelectAutoFillOption(elemOption:HTMLElement): void; - FocusAutoFill() :void; + SelectAutoFillOption(elemOption: HTMLElement): void; + FocusAutoFill(): void; BlurAutoFill(): void; CloseAutoFill(ojData: ISPClientAutoFillData): void; - UpdateAutoFillMenuFocus(bMoveNextLink:boolean): void; + UpdateAutoFillMenuFocus(bMoveNextLink: boolean): void; UpdateAutoFillPosition(): void; } @@ -8166,3 +8281,164 @@ interface ISPClientAutoFillData { AutoFillMenuOptionType?: number; } +declare class SPClientPeoplePicker { + static ValueName: string; // = 'Key'; + static DisplayTextName: string; // = 'DisplayText'; + static SubDisplayTextName: string; // = 'Title'; + static DescriptionName: string; // = 'Description'; + static SIPAddressName: string; // = 'SIPAddress'; + static SuggestionsName: string; // = 'MultipleMatches'; + static UnvalidatedEmailAddressKey: string; // = "UNVALIDATED_EMAIL_ADDRESS"; + static KeyProperty: string; // = 'AutoFillKey'; + static DisplayTextProperty: string; // = 'AutoFillDisplayText'; + static SubDisplayTextProperty: string; // = 'AutoFillSubDisplayText'; + static TitleTextProperty: string; // = 'AutoFillTitleText'; + static DomainProperty: string; // = 'DomainText'; + + static SPClientPeoplePickerDict: { + [pickerIelementId: string]: SPClientPeoplePicker; + }; + + static InitializeStandalonePeoplePicker(clientId: string, value: ISPClientPeoplePickerEntity[], schema: ISPClientPeoplePickerSchema): void; + + public TopLevelElementId: string;// '', + public EditorElementId: string;//'', + public AutoFillElementId: string;//'', + public ResolvedListElementId: string;//'', + public InitialHelpTextElementId: string;//'', + public WaitImageId: string;//'', + public HiddenInputId: string;//'', + public AllowEmpty: boolean;//true, + public ForceClaims: boolean;//false, + public AutoFillEnabled: boolean;//true, + public AllowMultipleUsers: boolean;//false, + public OnValueChangedClientScript: (pickerElementId: string, users: ISPClientPeoplePickerEntity[]) => void; + public OnUserResolvedClientScript: (pickerElementId: string, users: ISPClientPeoplePickerEntity[]) => void; + public OnControlValidateClientScript: (pickerElementId: string, users: ISPClientPeoplePickerEntity[]) => void; + public UrlZone: string;//null, + public AllUrlZones: boolean;//false, + public SharePointGroupID: number;//0, + public AllowEmailAddresses: boolean;//false, + public PPMRU: SPClientPeoplePickerMRU; + public UseLocalSuggestionCache: boolean;//true, + public CurrentQueryStr: string;//'', + public LatestSearchQueryStr: string;// '', + public InitialSuggestions: ISPClientPeoplePickerEntity[]; + public CurrentLocalSuggestions: ISPClientPeoplePickerEntity[]; + public CurrentLocalSuggestionsDict: ISPClientPeoplePickerEntity; + public VisibleSuggestions: number;//5, + public PrincipalAccountType: string;//'', + public PrincipalAccountTypeEnum: SP.Utilities.PrincipalType; + public EnabledClaimProviders: string;//'', + public SearchPrincipalSource: SP.Utilities.PrincipalSource;//null, + public ResolvePrincipalSource: SP.Utilities.PrincipalSource;//null, + public MaximumEntitySuggestions: number;//30, + public EditorWidthSet: boolean;//false, + public QueryScriptInit: boolean;//false, + public AutoFillControl: string;//null, + public TotalUserCount: number;//0, + public UnresolvedUserCount: number;//0, + public UserQueryDict: ISPClientPeoplePickerEntity; + public ProcessedUserList: ISPClientPeoplePickerEntity; + public HasInputError: boolean;//false, + public HasServerError: boolean;//false, + public ShowUserPresence: boolean;//true, + public TerminatingCharacter: string;//';', + public UnresolvedUserElmIdToReplace: string;//'', + public WebApplicationID: SP.Guid;//'{00000000-0000-0000-0000-000000000000}', + + public GetAllUserInfo(): ISPClientPeoplePickerEntity[]; +} + +interface ISPClientPeoplePickerSchema { + TopLevelElementId?: string; + EditorElementId?: string; + AutoFillElementId?: string; + ResolvedListElementId?: string; + InitialHelpTextElementId?: string; + WaitImageId?: string; + HiddenInputId?: string; + + AllowMultipleValues?: boolean; + Required?: boolean; + AutoFillEnabled?: boolean; + ForceClaims?: boolean; + AllowEmailAddresses?: boolean; + AllUrlZones?: boolean; + UseLocalSuggestionCache?: boolean; + UserNoQueryPermission?: boolean; + + VisibleSuggestions?: number; + MaximumEntitySuggestions?: number; + + ErrorMessage?: string; + InitialHelpText?: string; + + InitialSuggestions?: ISPClientPeoplePickerEntity[]; + + + UrlZone?: SP.UrlZone; + WebApplicationID?: SP.Guid; + SharePointGroupID?: number; + + /** Specify User, DL, SecGroup or SPGroup*/ + PrincipalAccountType?: string; + + EnabledClaimProvider?: string; + ResolvePrincipalSource?: SP.Utilities.PrincipalSource; + SearchPrincipalSource?: SP.Utilities.PrincipalSource; + + OnUserResolvedClientScript?: (pickerElementId: string, users: ISPClientPeoplePickerEntity[]) => void; + OnValueChangedClientScript?: (pickerElementId: string, users: ISPClientPeoplePickerEntity[]) => void; + + /** Number or '100%'*/ + Width?: any; + + Rows?: number; + +} + +declare class SPClientPeoplePickerMRU { + static PPMRUVersion: number;// = 1; + static MaxPPMRUItems: number;// = 200; + static PPMRUDomLocalStoreKey: string;// = "ClientPeoplePickerMRU"; + static GetSPClientPeoplePickerMRU(): SPClientPeoplePickerMRU; + + GetItems(strKey: string): Object[]; + SetItem(strSearchTerm: string, objEntity: Object): void; + ResetCache(): void; +} + +interface ISPClientPeoplePickerEntity { + Key?: string; + Description?: string; + DisplayText?: string; + EntityType?: string; + ProviderDisplayName?: string; + ProviderName?: string; + IsResolved?: boolean; + EntityData?: { + Title: string; + MobilePhone: string; + Department: string; + Email: string; + }; + MultipleMatches: Object[]; + DomainText?: string; + [key: string]: any; +} + +declare module Microsoft { + export module Office { + export module Server { + export module ReputationModel { + export class Reputation { + constructor(); + static setLike(context: SP.ClientContext, listId: string, itemId: number, like: boolean); + static setRating(context: SP.ClientContext, listId: string, itemId: number, rating: number); + } + } + } + } +} + diff --git a/sharepoint/SharePoint.d.ts.tscparams b/sharepoint/SharePoint.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sharepoint/SharePoint.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/siesta/siesta-tests.ts.tscparams b/siesta/siesta-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/siesta/siesta-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/siesta/siesta.d.ts.tscparams b/siesta/siesta.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/siesta/siesta.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/signalr/signalr-tests.ts.tscparams b/signalr/signalr-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/signalr/signalr-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/signalr/signalr.d.ts.tscparams b/signalr/signalr.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/signalr/signalr.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/sinon-chai/sinon-chai-tests.ts.tscparams b/sinon-chai/sinon-chai-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sinon-chai/sinon-chai-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/sinon-chai/sinon-chai.d.ts.tscparams b/sinon-chai/sinon-chai.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sinon-chai/sinon-chai.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/slickgrid/SlickGrid-tests.ts.tscparams b/slickgrid/SlickGrid-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/slickgrid/SlickGrid-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/slickgrid/SlickGrid.d.ts b/slickgrid/SlickGrid.d.ts index bc45c4dff..8459fbd9e 100644 --- a/slickgrid/SlickGrid.d.ts +++ b/slickgrid/SlickGrid.d.ts @@ -87,7 +87,7 @@ declare module Slick { * @method subscribe * @param fn {Function} Event handler. */ - public subscribe(fn: (eventData: EventData, data: T) => any ): void; + public subscribe(fn: (eventData: EventData, data: T) => any ): void; /*** * Removes an event handler added with subscribe(fn). @@ -1529,7 +1529,7 @@ declare module Slick { public getGroups(): Group[]; public getIdxById(): string; public getRowById(): T; - public getItemById(): T; + public getItemById(id: any): T; public getItemByIdx(): T; public mapRowsToIds(rowArray: T[]): string[]; public setRefreshHints(hints: RefreshHints): void; diff --git a/slickgrid/SlickGrid.d.ts.tscparams b/slickgrid/SlickGrid.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/slickgrid/SlickGrid.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/socket.io/socket.io-tests.ts.tscparams b/socket.io/socket.io-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/socket.io/socket.io-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/socket.io/socket.io.d.ts.tscparams b/socket.io/socket.io.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/socket.io/socket.io.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/soundjs/soundjs-tests.ts.tscparams b/soundjs/soundjs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/soundjs/soundjs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/soundjs/soundjs.d.ts.tscparams b/soundjs/soundjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/soundjs/soundjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/spin/spin-tests.ts.tscparams b/spin/spin-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/spin/spin-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/spin/spin.d.ts.tscparams b/spin/spin.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/spin/spin.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/stripe/stripe.d.ts.tscparams b/stripe/stripe.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/stripe/stripe.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 98a5c7705..b96d10bea 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -2813,7 +2813,12 @@ interface Array { * ['a','b'].subtract('b','c') -> ['a'] **/ subtract(...args: T[]): T[]; - + + /** + * @see subtract + **/ + subtract(args: T[]): T[]; + /** * Sums all values in the array. * @param map Property on each element in the array or callback function to sum up the elements. diff --git a/swiper/swiper-tests.ts.tscparams b/swiper/swiper-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/swiper/swiper-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/swiper/swiper.d.ts.tscparams b/swiper/swiper.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/swiper/swiper.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/swipeview/swipeview-tests.ts.tscparams b/swipeview/swipeview-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/swipeview/swipeview-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/teechart/teechart.d.ts.tscparams b/teechart/teechart.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/teechart/teechart.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/threejs/three-r55.d.ts.tscparams b/threejs/three-r55.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/threejs/three-r55.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/threejs/three-tests.ts.tscparams b/threejs/three-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/threejs/three-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/threejs/three.d.ts.tscparams b/threejs/three.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/threejs/three.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/through/through-tests.ts.tscparams b/through/through-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/through/through-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/through/through.d.ts.tscparams b/through/through.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/through/through.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/titanium/titanium-tests.ts.tscparams b/titanium/titanium-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/titanium/titanium-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/toastr/toastr-tests.ts.tscparams b/toastr/toastr-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/toastr/toastr-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/tween.js/tween.js.d.ts.tscparams b/tween.js/tween.js.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/tween.js/tween.js.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/tweenjs/tweenjs-tests.ts.tscparams b/tweenjs/tweenjs-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/tweenjs/tweenjs-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/underscore-ko/underscore-ko.d.ts.tscparams b/underscore-ko/underscore-ko.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/underscore-ko/underscore-ko.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/underscore/underscore-tests.ts.tscparams b/underscore/underscore-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/underscore/underscore-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index fb4d87e17..3da42ecba 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -382,7 +382,7 @@ declare module _ { **/ export function pluck( list: Collection, - propertyName: string): T[]; + propertyName: string): any[]; /** * Returns the maximum value in list. @@ -839,7 +839,7 @@ declare module _ { start: number, stop: number, step?: number): number[]; - + /** * @see _.range * @param stop Stop here. @@ -900,7 +900,7 @@ declare module _ { **/ export function memoize( fn: Function, - hashFn?: (n: any) => string): Function; + hashFn?: (...args: any[]) => string): Function; /** * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, @@ -1624,7 +1624,7 @@ declare class _ { * @see _.shuffle **/ shuffle(): T[]; - + /** * Wrapped type `any[]`. * @see _.sample diff --git a/unity-webapi/unity-webapi-tests.ts.tscparams b/unity-webapi/unity-webapi-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/unity-webapi/unity-webapi-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/unity-webapi/unity-webapi.d.ts.tscparams b/unity-webapi/unity-webapi.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/unity-webapi/unity-webapi.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/urijs/URI.d.ts.tscparams b/urijs/URI.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/urijs/URI.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/viewporter/viewporter-tests.ts.tscparams b/viewporter/viewporter-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/viewporter/viewporter-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/vimeo/froogaloop.d.ts.tscparams b/vimeo/froogaloop.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/vimeo/froogaloop.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webaudioapi/waa-nightly.d.ts.tscparams b/webaudioapi/waa-nightly.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webaudioapi/waa-nightly.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webaudioapi/waa-tests.ts.tscparams b/webaudioapi/waa-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webaudioapi/waa-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webaudioapi/waa.d.ts.tscparams b/webaudioapi/waa.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webaudioapi/waa.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webrtc/MediaStream-tests.ts.tscparams b/webrtc/MediaStream-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webrtc/MediaStream-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webrtc/MediaStream.d.ts.tscparams b/webrtc/MediaStream.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webrtc/MediaStream.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webrtc/RTCPeerConnection-tests.ts.tscparams b/webrtc/RTCPeerConnection-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webrtc/RTCPeerConnection-tests.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/webrtc/RTCPeerConnection.d.ts.tscparams b/webrtc/RTCPeerConnection.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/webrtc/RTCPeerConnection.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/winjs/winjs.d.ts.tscparams b/winjs/winjs.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/winjs/winjs.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/youtube/youtube.d.ts.tscparams b/youtube/youtube.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/youtube/youtube.d.ts.tscparams @@ -0,0 +1 @@ +"" diff --git a/zepto/zepto-tests.ts.tscparams b/zepto/zepto-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/zepto/zepto-tests.ts.tscparams @@ -0,0 +1 @@ +""