diff --git a/.gitignore b/.gitignore
index 656f1cda5..a111d5647 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@ Properties
*~
# test folder
+!_infrastructure/*.js
!_infrastructure/tests/*
!_infrastructure/tests/*.js
!_infrastructure/tests/*/*.js
diff --git a/README.md b/README.md
index 83e4ffbca..2943452fd 100755
--- a/README.md
+++ b/README.md
@@ -63,6 +63,7 @@ List of Definitions
* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei))
* [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/))
* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz))
* [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt))
@@ -99,6 +100,7 @@ List of Definitions
* [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov))
* [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/))
* [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/))
+* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb))
* [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/))
* [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/))
* [jQuery.timeago](http://timeago.yarp.com/) (by [François Guillot](http://fguillot.developpez.com/))
@@ -111,6 +113,7 @@ List of Definitions
* [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/))
+* [jStorage](http://www.jstorage.info/) (by [Danil Flores](https://github.com/dflor003/))
* [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/))
* [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/))
* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit))
@@ -123,8 +126,9 @@ List of Definitions
* [KoLite](https://github.com/CodeSeven/kolite) (by [Boris Yankov](https://github.com/borisyankov))
* [Leaflet](https://github.com/Leaflet/Leaflet) (by [Vladimir](https://github.com/rgripper))
* [Libxmljs](https://github.com/polotek/libxmljs) (by [François de Campredon](https://github.com/fdecampredon))
+* [ladda](https://github.com/hakimel/Ladda) (by [Danil Flores](https://github.com/dflor003))
* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder))
-* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone] (https://github.com/vbortone))
+* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone))
* [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr))
* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/))
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js
new file mode 100644
index 000000000..8b1ff53dd
--- /dev/null
+++ b/_infrastructure/tests/runner.js
@@ -0,0 +1,1058 @@
+var ExecResult = (function () {
+ function ExecResult() {
+ this.stdout = "";
+ this.stderr = "";
+ }
+ return ExecResult;
+})();
+
+var WindowsScriptHostExec = (function () {
+ function WindowsScriptHostExec() {
+ }
+ WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
+ var result = new ExecResult();
+ var shell = new ActiveXObject('WScript.Shell');
+ try {
+ var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
+ } catch (e) {
+ result.stderr = e.message;
+ result.exitCode = 1;
+ handleResult(result);
+ return;
+ }
+
+ while (process.Status != 0) {
+ }
+
+ result.exitCode = process.ExitCode;
+ if (!process.StdOut.AtEndOfStream)
+ result.stdout = process.StdOut.ReadAll();
+ if (!process.StdErr.AtEndOfStream)
+ result.stderr = process.StdErr.ReadAll();
+
+ handleResult(result);
+ };
+ return WindowsScriptHostExec;
+})();
+
+var NodeExec = (function () {
+ function NodeExec() {
+ }
+ NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
+ var nodeExec = require('child_process').exec;
+
+ var result = new ExecResult();
+ result.exitCode = null;
+ var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
+
+ var process = nodeExec(cmdLine, function (error, stdout, stderr) {
+ result.stdout = stdout;
+ result.stderr = stderr;
+ result.exitCode = error ? error.code : 0;
+ handleResult(result);
+ });
+ };
+ return NodeExec;
+})();
+
+var Exec = (function () {
+ var global = Function("return this;").call(null);
+ if (typeof global.ActiveXObject !== "undefined") {
+ return new WindowsScriptHostExec();
+ } else {
+ return new NodeExec();
+ }
+})();
+var IOUtils;
+(function (IOUtils) {
+ function createDirectoryStructure(ioHost, dirName) {
+ if (ioHost.directoryExists(dirName)) {
+ return;
+ }
+
+ var parentDirectory = ioHost.dirName(dirName);
+ if (parentDirectory != "") {
+ createDirectoryStructure(ioHost, parentDirectory);
+ }
+ ioHost.createDirectory(dirName);
+ }
+
+ function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
+ var path = ioHost.resolvePath(fileName);
+ var dirName = ioHost.dirName(path);
+ createDirectoryStructure(ioHost, dirName);
+ return ioHost.createFile(path, useUTF8);
+ }
+ IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
+
+ function throwIOError(message, error) {
+ var errorMessage = message;
+ if (error && error.message) {
+ errorMessage += (" " + error.message);
+ }
+ throw new Error(errorMessage);
+ }
+ IOUtils.throwIOError = throwIOError;
+})(IOUtils || (IOUtils = {}));
+
+var IO = (function () {
+ function getWindowsScriptHostIO() {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ var streamObjectPool = [];
+
+ function getStreamObject() {
+ if (streamObjectPool.length > 0) {
+ return streamObjectPool.pop();
+ } else {
+ return new ActiveXObject("ADODB.Stream");
+ }
+ }
+
+ function releaseStreamObject(obj) {
+ streamObjectPool.push(obj);
+ }
+
+ var args = [];
+ for (var i = 0; i < WScript.Arguments.length; i++) {
+ args[i] = WScript.Arguments.Item(i);
+ }
+
+ return {
+ readFile: function (path) {
+ try {
+ var streamObj = getStreamObject();
+ streamObj.Open();
+ streamObj.Type = 2;
+ streamObj.Charset = 'x-ansi';
+ streamObj.LoadFromFile(path);
+ var bomChar = streamObj.ReadText(2);
+ streamObj.Position = 0;
+ if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) {
+ streamObj.Charset = 'unicode';
+ } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) {
+ streamObj.Charset = 'utf-8';
+ }
+
+ var str = streamObj.ReadText(-1);
+ streamObj.Close();
+ releaseStreamObject(streamObj);
+ return str;
+ } catch (err) {
+ IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
+ }
+ },
+ writeFile: function (path, contents) {
+ var file = this.createFile(path);
+ file.Write(contents);
+ file.Close();
+ },
+ fileExists: function (path) {
+ return fso.FileExists(path);
+ },
+ resolvePath: function (path) {
+ return fso.GetAbsolutePathName(path);
+ },
+ dirName: function (path) {
+ return fso.GetParentFolderName(path);
+ },
+ findFile: function (rootPath, partialFilePath) {
+ var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
+
+ while (true) {
+ if (fso.FileExists(path)) {
+ try {
+ var content = this.readFile(path);
+ return { content: content, path: path };
+ } catch (err) {
+ }
+ } else {
+ rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
+
+ if (rootPath == "") {
+ return null;
+ } else {
+ path = fso.BuildPath(rootPath, partialFilePath);
+ }
+ }
+ }
+ },
+ deleteFile: function (path) {
+ try {
+ if (fso.FileExists(path)) {
+ fso.DeleteFile(path, true);
+ }
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
+ }
+ },
+ createFile: function (path, useUTF8) {
+ try {
+ var streamObj = getStreamObject();
+ streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
+ streamObj.Open();
+ return {
+ Write: function (str) {
+ streamObj.WriteText(str, 0);
+ },
+ WriteLine: function (str) {
+ streamObj.WriteText(str, 1);
+ },
+ Close: function () {
+ try {
+ streamObj.SaveToFile(path, 2);
+ } catch (saveError) {
+ IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
+ } finally {
+ if (streamObj.State != 0) {
+ streamObj.Close();
+ }
+ releaseStreamObject(streamObj);
+ }
+ }
+ };
+ } catch (creationError) {
+ IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
+ }
+ },
+ directoryExists: function (path) {
+ return fso.FolderExists(path);
+ },
+ createDirectory: function (path) {
+ try {
+ if (!this.directoryExists(path)) {
+ fso.CreateFolder(path);
+ }
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
+ }
+ },
+ dir: function (path, spec, options) {
+ options = options || {};
+ function filesInFolder(folder, root) {
+ var paths = [];
+ var fc;
+
+ if (options.recursive) {
+ fc = new Enumerator(folder.subfolders);
+
+ for (; !fc.atEnd(); fc.moveNext()) {
+ paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
+ }
+ }
+
+ fc = new Enumerator(folder.files);
+
+ for (; !fc.atEnd(); fc.moveNext()) {
+ if (!spec || fc.item().Name.match(spec)) {
+ paths.push(root + "/" + fc.item().Name);
+ }
+ }
+
+ return paths;
+ }
+
+ var folder = fso.GetFolder(path);
+ var paths = [];
+
+ return filesInFolder(folder, path);
+ },
+ print: function (str) {
+ WScript.StdOut.Write(str);
+ },
+ printLine: function (str) {
+ WScript.Echo(str);
+ },
+ arguments: args,
+ stderr: WScript.StdErr,
+ stdout: WScript.StdOut,
+ watchFile: null,
+ run: function (source, filename) {
+ try {
+ eval(source);
+ } catch (e) {
+ IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
+ }
+ },
+ getExecutingFilePath: function () {
+ return WScript.ScriptFullName;
+ },
+ quit: function (exitCode) {
+ if (typeof exitCode === "undefined") { exitCode = 0; }
+ try {
+ WScript.Quit(exitCode);
+ } catch (e) {
+ }
+ }
+ };
+ }
+ ;
+
+ function getNodeIO() {
+ var _fs = require('fs');
+ var _path = require('path');
+ var _module = require('module');
+
+ return {
+ readFile: function (file) {
+ try {
+ var buffer = _fs.readFileSync(file);
+ switch (buffer[0]) {
+ case 0xFE:
+ if (buffer[1] == 0xFF) {
+ var i = 0;
+ while ((i + 1) < buffer.length) {
+ var temp = buffer[i];
+ buffer[i] = buffer[i + 1];
+ buffer[i + 1] = temp;
+ i += 2;
+ }
+ return buffer.toString("ucs2", 2);
+ }
+ break;
+ case 0xFF:
+ if (buffer[1] == 0xFE) {
+ return buffer.toString("ucs2", 2);
+ }
+ break;
+ case 0xEF:
+ if (buffer[1] == 0xBB) {
+ return buffer.toString("utf8", 3);
+ }
+ }
+
+ return buffer.toString();
+ } catch (e) {
+ IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
+ }
+ },
+ writeFile: _fs.writeFileSync,
+ deleteFile: function (path) {
+ try {
+ _fs.unlinkSync(path);
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
+ }
+ },
+ fileExists: function (path) {
+ return _fs.existsSync(path);
+ },
+ createFile: function (path, useUTF8) {
+ function mkdirRecursiveSync(path) {
+ var stats = _fs.statSync(path);
+ if (stats.isFile()) {
+ IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
+ } else if (stats.isDirectory()) {
+ return;
+ } else {
+ mkdirRecursiveSync(_path.dirname(path));
+ _fs.mkdirSync(path, 0775);
+ }
+ }
+
+ mkdirRecursiveSync(_path.dirname(path));
+
+ try {
+ var fd = _fs.openSync(path, 'w');
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
+ }
+ return {
+ Write: function (str) {
+ _fs.writeSync(fd, str);
+ },
+ WriteLine: function (str) {
+ _fs.writeSync(fd, str + '\r\n');
+ },
+ Close: function () {
+ _fs.closeSync(fd);
+ fd = null;
+ }
+ };
+ },
+ dir: function dir(path, spec, options) {
+ options = options || {};
+
+ function filesInFolder(folder, deep) {
+ var paths = [];
+
+ var files = _fs.readdirSync(folder);
+ for (var i = 0; i < files.length; i++) {
+ var stat = _fs.statSync(folder + "/" + files[i]);
+ if (options.recursive && stat.isDirectory()) {
+ if (deep < (options.deep || 100)) {
+ paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
+ }
+ } else if (stat.isFile() && (!spec || files[i].match(spec))) {
+ paths.push(folder + "/" + files[i]);
+ }
+ }
+
+ return paths;
+ }
+
+ return filesInFolder(path, 0);
+ },
+ createDirectory: function (path) {
+ try {
+ if (!this.directoryExists(path)) {
+ _fs.mkdirSync(path);
+ }
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
+ }
+ },
+ directoryExists: function (path) {
+ return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
+ },
+ resolvePath: function (path) {
+ return _path.resolve(path);
+ },
+ dirName: function (path) {
+ return _path.dirname(path);
+ },
+ findFile: function (rootPath, partialFilePath) {
+ var path = rootPath + "/" + partialFilePath;
+
+ while (true) {
+ if (_fs.existsSync(path)) {
+ try {
+ var content = this.readFile(path);
+ return { content: content, path: path };
+ } catch (err) {
+ }
+ } else {
+ var parentPath = _path.resolve(rootPath, "..");
+
+ if (rootPath === parentPath) {
+ return null;
+ } else {
+ rootPath = parentPath;
+ path = _path.resolve(rootPath, partialFilePath);
+ }
+ }
+ }
+ },
+ print: function (str) {
+ process.stdout.write(str);
+ },
+ printLine: function (str) {
+ process.stdout.write(str + '\n');
+ },
+ arguments: process.argv.slice(2),
+ stderr: {
+ Write: function (str) {
+ process.stderr.write(str);
+ },
+ WriteLine: function (str) {
+ process.stderr.write(str + '\n');
+ },
+ Close: function () {
+ }
+ },
+ stdout: {
+ Write: function (str) {
+ process.stdout.write(str);
+ },
+ WriteLine: function (str) {
+ process.stdout.write(str + '\n');
+ },
+ Close: function () {
+ }
+ },
+ watchFile: function (filename, callback) {
+ var firstRun = true;
+ var processingChange = false;
+
+ var fileChanged = function (curr, prev) {
+ if (!firstRun) {
+ if (curr.mtime < prev.mtime) {
+ return;
+ }
+
+ _fs.unwatchFile(filename, fileChanged);
+ if (!processingChange) {
+ processingChange = true;
+ callback(filename);
+ setTimeout(function () {
+ processingChange = false;
+ }, 100);
+ }
+ }
+ firstRun = false;
+ _fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged);
+ };
+
+ fileChanged();
+ return {
+ filename: filename,
+ close: function () {
+ _fs.unwatchFile(filename, fileChanged);
+ }
+ };
+ },
+ run: function (source, filename) {
+ require.main.filename = filename;
+ require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
+ require.main._compile(source, filename);
+ },
+ getExecutingFilePath: function () {
+ return process.mainModule.filename;
+ },
+ quit: process.exit
+ };
+ }
+ ;
+
+ if (typeof ActiveXObject === "function")
+ return getWindowsScriptHostIO(); else if (typeof require === "function")
+ return getNodeIO(); else
+ return null;
+})();
+var DefinitelyTyped;
+(function (DefinitelyTyped) {
+ (function (TestManager) {
+ var path = require('path');
+
+ function endsWith(str, suffix) {
+ return str.indexOf(suffix, str.length - suffix.length) !== -1;
+ }
+
+ var Iterator = (function () {
+ function Iterator(list) {
+ this.list = list;
+ this.index = -1;
+ }
+ Iterator.prototype.next = function () {
+ this.index++;
+ return this.list[this.index];
+ };
+
+ Iterator.prototype.hasNext = function () {
+ return this.list[1 + this.index] != null;
+ };
+ return Iterator;
+ })();
+
+ var Tsc = (function () {
+ function Tsc() {
+ }
+ Tsc.run = function (tsfile, callback) {
+ Exec.exec('node ./_infrastructure/tests/typescript/tsc.js ', [tsfile], function (ExecResult) {
+ callback(ExecResult);
+ });
+ };
+ return Tsc;
+ })();
+
+ var Test = (function () {
+ function Test(tsfile) {
+ this.tsfile = tsfile;
+ }
+ Test.prototype.run = function (callback) {
+ Tsc.run(this.tsfile, callback);
+ };
+ return Test;
+ })();
+
+ var Typing = (function () {
+ function Typing(name, baseDir) {
+ this.name = name;
+ this.fileHandler = new FileHandler(baseDir + '/' + name + '/', /.\.ts/g);
+ }
+ return Typing;
+ })();
+
+ var FileHandler = (function () {
+ function FileHandler(path, pattern) {
+ this.path = path;
+ this.files = [];
+ this.typings = [];
+ this.files = IO.dir(path, pattern, { recursive: true });
+ }
+ FileHandler.prototype.allTS = function () {
+ return this.files;
+ };
+
+ FileHandler.prototype.allTests = function () {
+ 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;
+ };
+
+ FileHandler.prototype.allTypings = function () {
+ 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;
+ };
+ return FileHandler;
+ })();
+
+ var Timer = (function () {
+ function Timer() {
+ this.time = 0;
+ }
+ Timer.prettyDate = function (date1, date2) {
+ 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 + " secconds") || 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");
+ };
+
+ Timer.prototype.start = function () {
+ this.time = 0;
+ this.startTime = this.now();
+ };
+
+ Timer.prototype.now = function () {
+ return Date.now();
+ };
+
+ Timer.prototype.end = function () {
+ this.time = (this.now() - this.startTime) / 1000;
+ this.asString = Timer.prettyDate(this.startTime, this.now());
+ };
+ return Timer;
+ })();
+
+ var Print = (function () {
+ function Print(version, typings, tsFiles) {
+ this.version = version;
+ this.typings = typings;
+ this.tsFiles = tsFiles;
+ }
+ Print.prototype.out = function (s) {
+ process.stdout.write(s);
+ };
+
+ Print.prototype.printHeader = function () {
+ this.out('=============================================================================\n');
+ this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.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');
+ };
+
+ Print.prototype.printSyntaxCheking = function () {
+ this.out('============================ \33[34m\33[1mSyntax cheking\33[0m =================================\n');
+ };
+
+ Print.prototype.printTypingTests = function () {
+ this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n');
+ };
+
+ Print.prototype.printSuccess = function () {
+ this.out('\33[36m\33[1m.\33[0m');
+ };
+
+ Print.prototype.printFailure = function () {
+ this.out('x');
+ };
+
+ Print.prototype.printDiv = function () {
+ this.out('-----------------------------------------------------------------------------\n');
+ };
+
+ Print.prototype.printfilesWithSintaxErrorMessage = function () {
+ this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n');
+ };
+
+ Print.prototype.printFailedTestMessage = function () {
+ this.out(' \33[36m\33[1mFailed tests\33[0m\n');
+ };
+
+ Print.prototype.printTypingsWithoutTestsMessage = function () {
+ this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
+ };
+
+ Print.prototype.printTotalMessage = function () {
+ this.out(' \33[36m\33[1mTotal\33[0m\n');
+ };
+
+ Print.prototype.printErrorFile = function (file) {
+ this.out(' - ' + file + '\n');
+ };
+
+ Print.prototype.printTypingsWithoutTest = function (file) {
+ this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
+ };
+
+ Print.prototype.breack = function () {
+ this.out('\n');
+ };
+
+ Print.prototype.printSuccessCount = function (current, total) {
+ this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ };
+
+ Print.prototype.printFailedCount = function (current, total) {
+ this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ };
+
+ Print.prototype.printElapsedTime = function (time, s) {
+ this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
+ };
+
+ Print.prototype.printSyntaxErrorCount = function (current, total) {
+ this.out(' \33[36m\33[1mSyntaxe error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ };
+
+ Print.prototype.printTestErrorCount = function (current, total) {
+ this.out(' \33[36m\33[1mFailed tests :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ };
+
+ Print.prototype.printWithoutTestCount = function (current, total) {
+ this.out(' \33[36m\33[1mWithout tests :\33[0m \33[33m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ };
+ return Print;
+ })();
+
+ var File = (function () {
+ function File(name, hasError) {
+ this.name = name;
+ this.hasError = hasError;
+ }
+ File.prototype.formatName = function (baseDir) {
+ 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;
+ };
+ return File;
+ })();
+
+ var SyntaxCheking = (function () {
+ function SyntaxCheking(fielHandler, out) {
+ this.fielHandler = fielHandler;
+ this.out = out;
+ this.files = [];
+ this.timer = new Timer();
+ }
+ SyntaxCheking.prototype.getFailedFiles = function () {
+ var list = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (this.files[i].hasError) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ };
+
+ SyntaxCheking.prototype.getSuccessFiles = function () {
+ var list = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (!this.files[i].hasError) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ };
+
+ SyntaxCheking.prototype.printStats = function () {
+ 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);
+ };
+
+ SyntaxCheking.prototype.printFailedFiles = function () {
+ 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.fielHandler.path));
+ }
+ }
+ };
+
+ SyntaxCheking.prototype.run = function (it, file, len, maxLen, callback) {
+ var _this = this;
+ if (!endsWith(file, '-tests.ts')) {
+ new Test(file).run(function (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);
+ }
+ };
+
+ SyntaxCheking.prototype.start = function (callback) {
+ this.timer.start();
+
+ var tsFiles = this.fielHandler.allTS();
+
+ var it = new Iterator(tsFiles);
+
+ var len = 0;
+ var maxLen = 76;
+
+ if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ }
+ };
+ return SyntaxCheking;
+ })();
+
+ var TestEval = (function () {
+ function TestEval(fielHandler, out) {
+ this.fielHandler = fielHandler;
+ this.out = out;
+ this.files = [];
+ this.timer = new Timer();
+ }
+ TestEval.prototype.getFailedFiles = function () {
+ var list = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (this.files[i].hasError) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ };
+
+ TestEval.prototype.getSuccessFiles = function () {
+ var list = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (!this.files[i].hasError) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ };
+
+ TestEval.prototype.printStats = function () {
+ 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);
+ };
+
+ TestEval.prototype.printFailedFiles = function () {
+ 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.fielHandler.path));
+ }
+ }
+ };
+
+ TestEval.prototype.run = function (it, file, len, maxLen, callback) {
+ var _this = this;
+ if (endsWith(file, '-tests.ts')) {
+ new Test(file).run(function (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);
+ }
+ };
+
+ TestEval.prototype.start = function (callback) {
+ this.timer.start();
+
+ var tsFiles = this.fielHandler.allTS();
+
+ var it = new Iterator(tsFiles);
+
+ var len = 0;
+ var maxLen = 76;
+
+ if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ }
+ };
+ return TestEval;
+ })();
+
+ var TestRunner = (function () {
+ function TestRunner(dtPath) {
+ this.dtPath = dtPath;
+ this.typings = [];
+ this.fh = new FileHandler(dtPath, /.\.ts/g);
+ this.out = new Print('0.9.0.0', this.fh.allTypings().length, this.fh.allTS().length);
+ this.sc = new SyntaxCheking(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));
+ }
+ }
+ TestRunner.prototype.printTypingsWithoutTest = function () {
+ 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;
+ };
+
+ TestRunner.prototype.run = function () {
+ var _this = this;
+ var timer = new Timer();
+ timer.start();
+
+ this.out.printHeader();
+ this.out.printSyntaxCheking();
+
+ this.sc.start(function (syntaxFailedCount, syntaxTotal) {
+ _this.out.printTypingTests();
+ _this.te.start(function (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);
+ }
+ });
+ });
+ };
+ return TestRunner;
+ })();
+ TestManager.TestRunner = TestRunner;
+ })(DefinitelyTyped.TestManager || (DefinitelyTyped.TestManager = {}));
+ var TestManager = DefinitelyTyped.TestManager;
+})(DefinitelyTyped || (DefinitelyTyped = {}));
+
+var dtPath = __dirname + '/../..';
+
+var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath);
+runner.run();
diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts
new file mode 100644
index 000000000..175194755
--- /dev/null
+++ b/_infrastructure/tests/runner.ts
@@ -0,0 +1,557 @@
+///
+///
+
+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) {
+ Exec.exec('node ./_infrastructure/tests/typescript/tsc.js ', [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 });
+ }
+
+ 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 + " secconds") ||
+ 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.2.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 printSyntaxCheking() {
+ this.out('============================ \33[34m\33[1mSyntax cheking\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[1mSyntaxe 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 SyntaxCheking {
+
+ 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 fielHandler: 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.fielHandler.path));
+ }
+ }
+ }
+
+ private run(it, file, len, maxLen, callback: Function) {
+ if (!endsWith(file, '-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.printStats();
+ this.printFailedFiles();
+
+ callback(this.getFailedFiles().length, this.files.length);
+ }
+ }
+
+ public start(callback: Function) {
+ this.timer.start();
+
+ var tsFiles = this.fielHandler.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 fielHandler: 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.fielHandler.path));
+ }
+ }
+ }
+
+ private run(it, file, len, maxLen, callback: Function) {
+ if (endsWith(file, '-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.fielHandler.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: SyntaxCheking;
+ 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.0.0', this.fh.allTypings().length, this.fh.allTS().length);
+ this.sc = new SyntaxCheking(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.printSyntaxCheking();
+
+ 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);
+ }
+ });
+ });
+ }
+ }
+ }
+}
+
+declare var __dirname: any;
+
+var dtPath = __dirname + '/../..';
+
+var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath);
+runner.run();
diff --git a/_infrastructure/tests/src/exec.js b/_infrastructure/tests/src/exec.js
index 8c18ab42d..f6c3d257c 100644
--- a/_infrastructure/tests/src/exec.js
+++ b/_infrastructure/tests/src/exec.js
@@ -1,65 +1,65 @@
-var ExecResult = (function () {
- function ExecResult() {
- this.stdout = "";
- this.stderr = "";
- }
- return ExecResult;
-})();
-
-var WindowsScriptHostExec = (function () {
- function WindowsScriptHostExec() {
- }
- WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
- var result = new ExecResult();
- var shell = new ActiveXObject('WScript.Shell');
- try {
- var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
- } catch (e) {
- result.stderr = e.message;
- result.exitCode = 1;
- handleResult(result);
- return;
- }
-
- while (process.Status != 0) {
- }
-
- result.exitCode = process.ExitCode;
- if (!process.StdOut.AtEndOfStream)
- result.stdout = process.StdOut.ReadAll();
- if (!process.StdErr.AtEndOfStream)
- result.stderr = process.StdErr.ReadAll();
-
- handleResult(result);
- };
- return WindowsScriptHostExec;
-})();
-
-var NodeExec = (function () {
- function NodeExec() {
- }
- NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
- var nodeExec = require('child_process').exec;
-
- var result = new ExecResult();
- result.exitCode = null;
- var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
-
- var process = nodeExec(cmdLine, function (error, stdout, stderr) {
- result.stdout = stdout;
- result.stderr = stderr;
- result.exitCode = error ? error.code : 0;
- handleResult(result);
- });
- };
- return NodeExec;
-})();
-
-var Exec = (function () {
- var global = Function("return this;").call(null);
- if (typeof global.ActiveXObject !== "undefined") {
- return new WindowsScriptHostExec();
- } else {
- return new NodeExec();
- }
-})();
+var ExecResult = (function () {
+ function ExecResult() {
+ this.stdout = "";
+ this.stderr = "";
+ }
+ return ExecResult;
+})();
+
+var WindowsScriptHostExec = (function () {
+ function WindowsScriptHostExec() {
+ }
+ WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
+ var result = new ExecResult();
+ var shell = new ActiveXObject('WScript.Shell');
+ try {
+ var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
+ } catch (e) {
+ result.stderr = e.message;
+ result.exitCode = 1;
+ handleResult(result);
+ return;
+ }
+
+ while (process.Status != 0) {
+ }
+
+ result.exitCode = process.ExitCode;
+ if (!process.StdOut.AtEndOfStream)
+ result.stdout = process.StdOut.ReadAll();
+ if (!process.StdErr.AtEndOfStream)
+ result.stderr = process.StdErr.ReadAll();
+
+ handleResult(result);
+ };
+ return WindowsScriptHostExec;
+})();
+
+var NodeExec = (function () {
+ function NodeExec() {
+ }
+ NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
+ var nodeExec = require('child_process').exec;
+
+ var result = new ExecResult();
+ result.exitCode = null;
+ var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
+
+ var process = nodeExec(cmdLine, function (error, stdout, stderr) {
+ result.stdout = stdout;
+ result.stderr = stderr;
+ result.exitCode = error ? error.code : 0;
+ handleResult(result);
+ });
+ };
+ return NodeExec;
+})();
+
+var Exec = (function () {
+ var global = Function("return this;").call(null);
+ if (typeof global.ActiveXObject !== "undefined") {
+ return new WindowsScriptHostExec();
+ } else {
+ return new NodeExec();
+ }
+})();
diff --git a/_infrastructure/tests/src/io.js b/_infrastructure/tests/src/io.js
index 772e97c02..0058d59f9 100644
--- a/_infrastructure/tests/src/io.js
+++ b/_infrastructure/tests/src/io.js
@@ -1,443 +1,445 @@
-var IOUtils;
-(function (IOUtils) {
- function createDirectoryStructure(ioHost, dirName) {
- if (ioHost.directoryExists(dirName)) {
- return;
- }
-
- var parentDirectory = ioHost.dirName(dirName);
- if (parentDirectory != "") {
- createDirectoryStructure(ioHost, parentDirectory);
- }
- ioHost.createDirectory(dirName);
- }
-
- function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
- var path = ioHost.resolvePath(fileName);
- var dirName = ioHost.dirName(path);
- createDirectoryStructure(ioHost, dirName);
- return ioHost.createFile(path, useUTF8);
- }
- IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
-
- function throwIOError(message, error) {
- var errorMessage = message;
- if (error && error.message) {
- errorMessage += (" " + error.message);
- }
- throw new Error(errorMessage);
- }
- IOUtils.throwIOError = throwIOError;
-})(IOUtils || (IOUtils = {}));
-
-var IO = (function () {
- function getWindowsScriptHostIO() {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var streamObjectPool = [];
-
- function getStreamObject() {
- if (streamObjectPool.length > 0) {
- return streamObjectPool.pop();
- } else {
- return new ActiveXObject("ADODB.Stream");
- }
- }
-
- function releaseStreamObject(obj) {
- streamObjectPool.push(obj);
- }
-
- var args = [];
- for (var i = 0; i < WScript.Arguments.length; i++) {
- args[i] = WScript.Arguments.Item(i);
- }
-
- return {
- readFile: function (path) {
- try {
- var streamObj = getStreamObject();
- streamObj.Open();
- streamObj.Type = 2;
- streamObj.Charset = 'x-ansi';
- streamObj.LoadFromFile(path);
- var bomChar = streamObj.ReadText(2);
- streamObj.Position = 0;
- if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) {
- streamObj.Charset = 'unicode';
- } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) {
- streamObj.Charset = 'utf-8';
- }
-
- var str = streamObj.ReadText(-1);
- streamObj.Close();
- releaseStreamObject(streamObj);
- return str;
- } catch (err) {
- IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
- }
- },
- writeFile: function (path, contents) {
- var file = this.createFile(path);
- file.Write(contents);
- file.Close();
- },
- fileExists: function (path) {
- return fso.FileExists(path);
- },
- resolvePath: function (path) {
- return fso.GetAbsolutePathName(path);
- },
- dirName: function (path) {
- return fso.GetParentFolderName(path);
- },
- findFile: function (rootPath, partialFilePath) {
- var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
-
- while (true) {
- if (fso.FileExists(path)) {
- try {
- var content = this.readFile(path);
- return { content: content, path: path };
- } catch (err) {
- }
- } else {
- rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
-
- if (rootPath == "") {
- return null;
- } else {
- path = fso.BuildPath(rootPath, partialFilePath);
- }
- }
- }
- },
- deleteFile: function (path) {
- try {
- if (fso.FileExists(path)) {
- fso.DeleteFile(path, true);
- }
- } catch (e) {
- IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
- }
- },
- createFile: function (path, useUTF8) {
- try {
- var streamObj = getStreamObject();
- streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
- streamObj.Open();
- return {
- Write: function (str) {
- streamObj.WriteText(str, 0);
- },
- WriteLine: function (str) {
- streamObj.WriteText(str, 1);
- },
- Close: function () {
- try {
- streamObj.SaveToFile(path, 2);
- } catch (saveError) {
- IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
- } finally {
- if (streamObj.State != 0) {
- streamObj.Close();
- }
- releaseStreamObject(streamObj);
- }
- }
- };
- } catch (creationError) {
- IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
- }
- },
- directoryExists: function (path) {
- return fso.FolderExists(path);
- },
- createDirectory: function (path) {
- try {
- if (!this.directoryExists(path)) {
- fso.CreateFolder(path);
- }
- } catch (e) {
- IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
- }
- },
- dir: function (path, spec, options) {
- options = options || {};
- function filesInFolder(folder, root) {
- var paths = [];
- var fc;
-
- if (options.recursive) {
- fc = new Enumerator(folder.subfolders);
-
- for (; !fc.atEnd(); fc.moveNext()) {
- paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
- }
- }
-
- fc = new Enumerator(folder.files);
-
- for (; !fc.atEnd(); fc.moveNext()) {
- if (!spec || fc.item().Name.match(spec)) {
- paths.push(root + "/" + fc.item().Name);
- }
- }
-
- return paths;
- }
-
- var folder = fso.GetFolder(path);
- var paths = [];
-
- return filesInFolder(folder, path);
- },
- print: function (str) {
- WScript.StdOut.Write(str);
- },
- printLine: function (str) {
- WScript.Echo(str);
- },
- arguments: args,
- stderr: WScript.StdErr,
- stdout: WScript.StdOut,
- watchFile: null,
- run: function (source, filename) {
- try {
- eval(source);
- } catch (e) {
- IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
- }
- },
- getExecutingFilePath: function () {
- return WScript.ScriptFullName;
- },
- quit: function (exitCode) {
- if (typeof exitCode === "undefined") { exitCode = 0; }
- try {
- WScript.Quit(exitCode);
- } catch (e) {
- }
- }
- };
- }
- ;
-
- function getNodeIO() {
- var _fs = require('fs');
- var _path = require('path');
- var _module = require('module');
-
- return {
- readFile: function (file) {
- try {
- var buffer = _fs.readFileSync(file);
- switch (buffer[0]) {
- case 0xFE:
- if (buffer[1] == 0xFF) {
- var i = 0;
- while ((i + 1) < buffer.length) {
- var temp = buffer[i];
- buffer[i] = buffer[i + 1];
- buffer[i + 1] = temp;
- i += 2;
- }
- return buffer.toString("ucs2", 2);
- }
- break;
- case 0xFF:
- if (buffer[1] == 0xFE) {
- return buffer.toString("ucs2", 2);
- }
- break;
- case 0xEF:
- if (buffer[1] == 0xBB) {
- return buffer.toString("utf8", 3);
- }
- }
-
- return buffer.toString();
- } catch (e) {
- IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
- }
- },
- writeFile: _fs.writeFileSync,
- deleteFile: function (path) {
- try {
- _fs.unlinkSync(path);
- } catch (e) {
- IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
- }
- },
- fileExists: function (path) {
- return _fs.existsSync(path);
- },
- createFile: function (path, useUTF8) {
- function mkdirRecursiveSync(path) {
- var stats = _fs.statSync(path);
- if (stats.isFile()) {
- IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
- } else if (stats.isDirectory()) {
- return;
- } else {
- mkdirRecursiveSync(_path.dirname(path));
- _fs.mkdirSync(path, 0775);
- }
- }
-
- mkdirRecursiveSync(_path.dirname(path));
-
- try {
- var fd = _fs.openSync(path, 'w');
- } catch (e) {
- IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
- }
- return {
- Write: function (str) {
- _fs.writeSync(fd, str);
- },
- WriteLine: function (str) {
- _fs.writeSync(fd, str + '\r\n');
- },
- Close: function () {
- _fs.closeSync(fd);
- fd = null;
- }
- };
- },
- dir: function dir(path, spec, options) {
- options = options || {};
-
- function filesInFolder(folder) {
- var paths = [];
-
- var files = _fs.readdirSync(folder);
- for (var i = 0; i < files.length; i++) {
- var stat = _fs.statSync(folder + "/" + files[i]);
- if (options.recursive && stat.isDirectory()) {
- paths = paths.concat(filesInFolder(folder + "/" + files[i]));
- } else if (stat.isFile() && (!spec || files[i].match(spec))) {
- paths.push(folder + "/" + files[i]);
- }
- }
-
- return paths;
- }
-
- return filesInFolder(path);
- },
- createDirectory: function (path) {
- try {
- if (!this.directoryExists(path)) {
- _fs.mkdirSync(path);
- }
- } catch (e) {
- IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
- }
- },
- directoryExists: function (path) {
- return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
- },
- resolvePath: function (path) {
- return _path.resolve(path);
- },
- dirName: function (path) {
- return _path.dirname(path);
- },
- findFile: function (rootPath, partialFilePath) {
- var path = rootPath + "/" + partialFilePath;
-
- while (true) {
- if (_fs.existsSync(path)) {
- try {
- var content = this.readFile(path);
- return { content: content, path: path };
- } catch (err) {
- }
- } else {
- var parentPath = _path.resolve(rootPath, "..");
-
- if (rootPath === parentPath) {
- return null;
- } else {
- rootPath = parentPath;
- path = _path.resolve(rootPath, partialFilePath);
- }
- }
- }
- },
- print: function (str) {
- process.stdout.write(str);
- },
- printLine: function (str) {
- process.stdout.write(str + '\n');
- },
- arguments: process.argv.slice(2),
- stderr: {
- Write: function (str) {
- process.stderr.write(str);
- },
- WriteLine: function (str) {
- process.stderr.write(str + '\n');
- },
- Close: function () {
- }
- },
- stdout: {
- Write: function (str) {
- process.stdout.write(str);
- },
- WriteLine: function (str) {
- process.stdout.write(str + '\n');
- },
- Close: function () {
- }
- },
- watchFile: function (filename, callback) {
- var firstRun = true;
- var processingChange = false;
-
- var fileChanged = function (curr, prev) {
- if (!firstRun) {
- if (curr.mtime < prev.mtime) {
- return;
- }
-
- _fs.unwatchFile(filename, fileChanged);
- if (!processingChange) {
- processingChange = true;
- callback(filename);
- setTimeout(function () {
- processingChange = false;
- }, 100);
- }
- }
- firstRun = false;
- _fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged);
- };
-
- fileChanged();
- return {
- filename: filename,
- close: function () {
- _fs.unwatchFile(filename, fileChanged);
- }
- };
- },
- run: function (source, filename) {
- require.main.filename = filename;
- require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
- require.main._compile(source, filename);
- },
- getExecutingFilePath: function () {
- return process.mainModule.filename;
- },
- quit: process.exit
- };
- }
- ;
-
- if (typeof ActiveXObject === "function")
- return getWindowsScriptHostIO(); else if (typeof require === "function")
- return getNodeIO(); else
- return null;
-})();
+var IOUtils;
+(function (IOUtils) {
+ function createDirectoryStructure(ioHost, dirName) {
+ if (ioHost.directoryExists(dirName)) {
+ return;
+ }
+
+ var parentDirectory = ioHost.dirName(dirName);
+ if (parentDirectory != "") {
+ createDirectoryStructure(ioHost, parentDirectory);
+ }
+ ioHost.createDirectory(dirName);
+ }
+
+ function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
+ var path = ioHost.resolvePath(fileName);
+ var dirName = ioHost.dirName(path);
+ createDirectoryStructure(ioHost, dirName);
+ return ioHost.createFile(path, useUTF8);
+ }
+ IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
+
+ function throwIOError(message, error) {
+ var errorMessage = message;
+ if (error && error.message) {
+ errorMessage += (" " + error.message);
+ }
+ throw new Error(errorMessage);
+ }
+ IOUtils.throwIOError = throwIOError;
+})(IOUtils || (IOUtils = {}));
+
+var IO = (function () {
+ function getWindowsScriptHostIO() {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ var streamObjectPool = [];
+
+ function getStreamObject() {
+ if (streamObjectPool.length > 0) {
+ return streamObjectPool.pop();
+ } else {
+ return new ActiveXObject("ADODB.Stream");
+ }
+ }
+
+ function releaseStreamObject(obj) {
+ streamObjectPool.push(obj);
+ }
+
+ var args = [];
+ for (var i = 0; i < WScript.Arguments.length; i++) {
+ args[i] = WScript.Arguments.Item(i);
+ }
+
+ return {
+ readFile: function (path) {
+ try {
+ var streamObj = getStreamObject();
+ streamObj.Open();
+ streamObj.Type = 2;
+ streamObj.Charset = 'x-ansi';
+ streamObj.LoadFromFile(path);
+ var bomChar = streamObj.ReadText(2);
+ streamObj.Position = 0;
+ if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) {
+ streamObj.Charset = 'unicode';
+ } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) {
+ streamObj.Charset = 'utf-8';
+ }
+
+ var str = streamObj.ReadText(-1);
+ streamObj.Close();
+ releaseStreamObject(streamObj);
+ return str;
+ } catch (err) {
+ IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
+ }
+ },
+ writeFile: function (path, contents) {
+ var file = this.createFile(path);
+ file.Write(contents);
+ file.Close();
+ },
+ fileExists: function (path) {
+ return fso.FileExists(path);
+ },
+ resolvePath: function (path) {
+ return fso.GetAbsolutePathName(path);
+ },
+ dirName: function (path) {
+ return fso.GetParentFolderName(path);
+ },
+ findFile: function (rootPath, partialFilePath) {
+ var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
+
+ while (true) {
+ if (fso.FileExists(path)) {
+ try {
+ var content = this.readFile(path);
+ return { content: content, path: path };
+ } catch (err) {
+ }
+ } else {
+ rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
+
+ if (rootPath == "") {
+ return null;
+ } else {
+ path = fso.BuildPath(rootPath, partialFilePath);
+ }
+ }
+ }
+ },
+ deleteFile: function (path) {
+ try {
+ if (fso.FileExists(path)) {
+ fso.DeleteFile(path, true);
+ }
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
+ }
+ },
+ createFile: function (path, useUTF8) {
+ try {
+ var streamObj = getStreamObject();
+ streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
+ streamObj.Open();
+ return {
+ Write: function (str) {
+ streamObj.WriteText(str, 0);
+ },
+ WriteLine: function (str) {
+ streamObj.WriteText(str, 1);
+ },
+ Close: function () {
+ try {
+ streamObj.SaveToFile(path, 2);
+ } catch (saveError) {
+ IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
+ } finally {
+ if (streamObj.State != 0) {
+ streamObj.Close();
+ }
+ releaseStreamObject(streamObj);
+ }
+ }
+ };
+ } catch (creationError) {
+ IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
+ }
+ },
+ directoryExists: function (path) {
+ return fso.FolderExists(path);
+ },
+ createDirectory: function (path) {
+ try {
+ if (!this.directoryExists(path)) {
+ fso.CreateFolder(path);
+ }
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
+ }
+ },
+ dir: function (path, spec, options) {
+ options = options || {};
+ function filesInFolder(folder, root) {
+ var paths = [];
+ var fc;
+
+ if (options.recursive) {
+ fc = new Enumerator(folder.subfolders);
+
+ for (; !fc.atEnd(); fc.moveNext()) {
+ paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
+ }
+ }
+
+ fc = new Enumerator(folder.files);
+
+ for (; !fc.atEnd(); fc.moveNext()) {
+ if (!spec || fc.item().Name.match(spec)) {
+ paths.push(root + "/" + fc.item().Name);
+ }
+ }
+
+ return paths;
+ }
+
+ var folder = fso.GetFolder(path);
+ var paths = [];
+
+ return filesInFolder(folder, path);
+ },
+ print: function (str) {
+ WScript.StdOut.Write(str);
+ },
+ printLine: function (str) {
+ WScript.Echo(str);
+ },
+ arguments: args,
+ stderr: WScript.StdErr,
+ stdout: WScript.StdOut,
+ watchFile: null,
+ run: function (source, filename) {
+ try {
+ eval(source);
+ } catch (e) {
+ IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
+ }
+ },
+ getExecutingFilePath: function () {
+ return WScript.ScriptFullName;
+ },
+ quit: function (exitCode) {
+ if (typeof exitCode === "undefined") { exitCode = 0; }
+ try {
+ WScript.Quit(exitCode);
+ } catch (e) {
+ }
+ }
+ };
+ }
+ ;
+
+ function getNodeIO() {
+ var _fs = require('fs');
+ var _path = require('path');
+ var _module = require('module');
+
+ return {
+ readFile: function (file) {
+ try {
+ var buffer = _fs.readFileSync(file);
+ switch (buffer[0]) {
+ case 0xFE:
+ if (buffer[1] == 0xFF) {
+ var i = 0;
+ while ((i + 1) < buffer.length) {
+ var temp = buffer[i];
+ buffer[i] = buffer[i + 1];
+ buffer[i + 1] = temp;
+ i += 2;
+ }
+ return buffer.toString("ucs2", 2);
+ }
+ break;
+ case 0xFF:
+ if (buffer[1] == 0xFE) {
+ return buffer.toString("ucs2", 2);
+ }
+ break;
+ case 0xEF:
+ if (buffer[1] == 0xBB) {
+ return buffer.toString("utf8", 3);
+ }
+ }
+
+ return buffer.toString();
+ } catch (e) {
+ IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
+ }
+ },
+ writeFile: _fs.writeFileSync,
+ deleteFile: function (path) {
+ try {
+ _fs.unlinkSync(path);
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
+ }
+ },
+ fileExists: function (path) {
+ return _fs.existsSync(path);
+ },
+ createFile: function (path, useUTF8) {
+ function mkdirRecursiveSync(path) {
+ var stats = _fs.statSync(path);
+ if (stats.isFile()) {
+ IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
+ } else if (stats.isDirectory()) {
+ return;
+ } else {
+ mkdirRecursiveSync(_path.dirname(path));
+ _fs.mkdirSync(path, 0775);
+ }
+ }
+
+ mkdirRecursiveSync(_path.dirname(path));
+
+ try {
+ var fd = _fs.openSync(path, 'w');
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
+ }
+ return {
+ Write: function (str) {
+ _fs.writeSync(fd, str);
+ },
+ WriteLine: function (str) {
+ _fs.writeSync(fd, str + '\r\n');
+ },
+ Close: function () {
+ _fs.closeSync(fd);
+ fd = null;
+ }
+ };
+ },
+ dir: function dir(path, spec, options) {
+ options = options || {};
+
+ function filesInFolder(folder, deep) {
+ var paths = [];
+
+ var files = _fs.readdirSync(folder);
+ for (var i = 0; i < files.length; i++) {
+ var stat = _fs.statSync(folder + "/" + files[i]);
+ if (options.recursive && stat.isDirectory()) {
+ if (deep < (options.deep || 100)) {
+ paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
+ }
+ } else if (stat.isFile() && (!spec || files[i].match(spec))) {
+ paths.push(folder + "/" + files[i]);
+ }
+ }
+
+ return paths;
+ }
+
+ return filesInFolder(path, 0);
+ },
+ createDirectory: function (path) {
+ try {
+ if (!this.directoryExists(path)) {
+ _fs.mkdirSync(path);
+ }
+ } catch (e) {
+ IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
+ }
+ },
+ directoryExists: function (path) {
+ return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
+ },
+ resolvePath: function (path) {
+ return _path.resolve(path);
+ },
+ dirName: function (path) {
+ return _path.dirname(path);
+ },
+ findFile: function (rootPath, partialFilePath) {
+ var path = rootPath + "/" + partialFilePath;
+
+ while (true) {
+ if (_fs.existsSync(path)) {
+ try {
+ var content = this.readFile(path);
+ return { content: content, path: path };
+ } catch (err) {
+ }
+ } else {
+ var parentPath = _path.resolve(rootPath, "..");
+
+ if (rootPath === parentPath) {
+ return null;
+ } else {
+ rootPath = parentPath;
+ path = _path.resolve(rootPath, partialFilePath);
+ }
+ }
+ }
+ },
+ print: function (str) {
+ process.stdout.write(str);
+ },
+ printLine: function (str) {
+ process.stdout.write(str + '\n');
+ },
+ arguments: process.argv.slice(2),
+ stderr: {
+ Write: function (str) {
+ process.stderr.write(str);
+ },
+ WriteLine: function (str) {
+ process.stderr.write(str + '\n');
+ },
+ Close: function () {
+ }
+ },
+ stdout: {
+ Write: function (str) {
+ process.stdout.write(str);
+ },
+ WriteLine: function (str) {
+ process.stdout.write(str + '\n');
+ },
+ Close: function () {
+ }
+ },
+ watchFile: function (filename, callback) {
+ var firstRun = true;
+ var processingChange = false;
+
+ var fileChanged = function (curr, prev) {
+ if (!firstRun) {
+ if (curr.mtime < prev.mtime) {
+ return;
+ }
+
+ _fs.unwatchFile(filename, fileChanged);
+ if (!processingChange) {
+ processingChange = true;
+ callback(filename);
+ setTimeout(function () {
+ processingChange = false;
+ }, 100);
+ }
+ }
+ firstRun = false;
+ _fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged);
+ };
+
+ fileChanged();
+ return {
+ filename: filename,
+ close: function () {
+ _fs.unwatchFile(filename, fileChanged);
+ }
+ };
+ },
+ run: function (source, filename) {
+ require.main.filename = filename;
+ require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
+ require.main._compile(source, filename);
+ },
+ getExecutingFilePath: function () {
+ return process.mainModule.filename;
+ },
+ quit: process.exit
+ };
+ }
+ ;
+
+ if (typeof ActiveXObject === "function")
+ return getWindowsScriptHostIO(); else if (typeof require === "function")
+ return getNodeIO(); else
+ return null;
+})();
diff --git a/_infrastructure/tests/src/io.ts b/_infrastructure/tests/src/io.ts
index 3c68154a1..9c5345136 100644
--- a/_infrastructure/tests/src/io.ts
+++ b/_infrastructure/tests/src/io.ts
@@ -25,11 +25,11 @@ interface IFileWatcher {
interface IIO {
readFile(path: string): string;
writeFile(path: string, contents: string): void;
- createFile(path: string, useUTF8?: boolean): ITextWriter;
+ createFile(path: string, useUTF8?: bool): ITextWriter;
deleteFile(path: string): void;
- dir(path: string, re?: RegExp, options?: { recursive?: boolean; }): string[];
- fileExists(path: string): boolean;
- directoryExists(path: string): boolean;
+ dir(path: string, re?: RegExp, options?: { recursive?: bool; deep?: number; }): string[];
+ fileExists(path: string): bool;
+ directoryExists(path: string): bool;
createDirectory(path: string): void;
resolvePath(path: string): string;
dirName(path: string): string;
@@ -60,7 +60,7 @@ module IOUtils {
}
// Creates a file including its directory structure if not already present
- export function createFileAndFolderStructure(ioHost: IIO, fileName: string, useUTF8?: boolean) {
+ export function createFileAndFolderStructure(ioHost: IIO, fileName: string, useUTF8?: bool) {
var path = ioHost.resolvePath(fileName);
var dirName = ioHost.dirName(path);
createDirectoryStructure(ioHost, dirName);
@@ -78,13 +78,13 @@ module IOUtils {
// Declare dependencies needed for all supported hosts
declare class Enumerator {
- public atEnd(): boolean;
+ public atEnd(): bool;
public moveNext();
public item(): any;
constructor (o: any);
}
declare function setTimeout(callback: () =>void , ms?: number);
-declare var require: any;
+//declare var require: any;
declare module process {
export var argv: string[];
export var platform: string;
@@ -160,7 +160,7 @@ var IO = (function() {
file.Close();
},
- fileExists: function(path: string): boolean {
+ fileExists: function(path: string): bool {
return fso.FileExists(path);
},
@@ -236,7 +236,7 @@ var IO = (function() {
},
directoryExists: function(path) {
- return fso.FolderExists(path);
+ return fso.FolderExists(path);
},
createDirectory: function(path) {
@@ -250,7 +250,7 @@ var IO = (function() {
},
dir: function(path, spec?, options?) {
- options = options || <{ recursive?: boolean; }>{};
+ options = options || <{ recursive?: bool; deep?: number; }>{};
function filesInFolder(folder, root): string[]{
var paths = [];
var fc: Enumerator;
@@ -365,7 +365,7 @@ var IO = (function() {
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
}
},
- fileExists: function(path): boolean {
+ fileExists: function(path): bool {
return _fs.existsSync(path);
},
createFile: function(path, useUTF8?) {
@@ -395,16 +395,18 @@ var IO = (function() {
};
},
dir: function dir(path, spec?, options?) {
- options = options || <{ recursive?: boolean; }>{};
+ options = options || <{ recursive?: bool; deep?: number; }>{};
- function filesInFolder(folder: string): string[]{
+ function filesInFolder(folder: string, deep?: number): string[]{
var paths = [];
var files = _fs.readdirSync(folder);
for (var i = 0; i < files.length; i++) {
var stat = _fs.statSync(folder + "/" + files[i]);
if (options.recursive && stat.isDirectory()) {
- paths = paths.concat(filesInFolder(folder + "/" + files[i]));
+ if (deep < (options.deep || 100)) {
+ paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
+ }
} else if (stat.isFile() && (!spec || files[i].match(spec))) {
paths.push(folder + "/" + files[i]);
}
@@ -413,7 +415,7 @@ var IO = (function() {
return paths;
}
- return filesInFolder(path);
+ return filesInFolder(path, 0);
},
createDirectory: function(path: string): void {
try {
@@ -425,7 +427,7 @@ var IO = (function() {
}
},
- directoryExists: function(path: string): boolean {
+ directoryExists: function(path: string): bool {
return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
},
resolvePath: function(path: string): string {
diff --git a/_infrastructure/tests/testRunner.js b/_infrastructure/tests/testRunner.js
deleted file mode 100644
index a2f54dd5f..000000000
--- a/_infrastructure/tests/testRunner.js
+++ /dev/null
@@ -1,619 +0,0 @@
-var ExecResult = (function () {
- function ExecResult() {
- this.stdout = "";
- this.stderr = "";
- }
- return ExecResult;
-})();
-var WindowsScriptHostExec = (function () {
- function WindowsScriptHostExec() { }
- WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
- var result = new ExecResult();
- var shell = new ActiveXObject('WScript.Shell');
- try {
- var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
- } catch (e) {
- result.stderr = e.message;
- result.exitCode = 1;
- handleResult(result);
- return;
- }
- while(process.Status != 0) {
- }
- result.exitCode = process.ExitCode;
- if(!process.StdOut.AtEndOfStream) {
- result.stdout = process.StdOut.ReadAll();
- }
- if(!process.StdErr.AtEndOfStream) {
- result.stderr = process.StdErr.ReadAll();
- }
- handleResult(result);
- };
- return WindowsScriptHostExec;
-})();
-var NodeExec = (function () {
- function NodeExec() { }
- NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
- var nodeExec = require('child_process').exec;
- var result = new ExecResult();
- result.exitCode = null;
- var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
- var process = nodeExec(cmdLine, function (error, stdout, stderr) {
- result.stdout = stdout;
- result.stderr = stderr;
- result.exitCode = error ? error.code : 0;
- handleResult(result);
- });
- };
- return NodeExec;
-})();
-var Exec = (function () {
- var global = Function("return this;").call(null);
- if(typeof global.ActiveXObject !== "undefined") {
- return new WindowsScriptHostExec();
- } else {
- return new NodeExec();
- }
-})();
-var IOUtils;
-(function (IOUtils) {
- function createDirectoryStructure(ioHost, dirName) {
- if(ioHost.directoryExists(dirName)) {
- return;
- }
- var parentDirectory = ioHost.dirName(dirName);
- if(parentDirectory != "") {
- createDirectoryStructure(ioHost, parentDirectory);
- }
- ioHost.createDirectory(dirName);
- }
- function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
- var path = ioHost.resolvePath(fileName);
- var dirName = ioHost.dirName(path);
- createDirectoryStructure(ioHost, dirName);
- return ioHost.createFile(path, useUTF8);
- }
- IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
- function throwIOError(message, error) {
- var errorMessage = message;
- if(error && error.message) {
- errorMessage += (" " + error.message);
- }
- throw new Error(errorMessage);
- }
- IOUtils.throwIOError = throwIOError;
-})(IOUtils || (IOUtils = {}));
-
-var IO = (function () {
- function getWindowsScriptHostIO() {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var streamObjectPool = [];
- function getStreamObject() {
- if(streamObjectPool.length > 0) {
- return streamObjectPool.pop();
- } else {
- return new ActiveXObject("ADODB.Stream");
- }
- }
- function releaseStreamObject(obj) {
- streamObjectPool.push(obj);
- }
- var args = [];
- for(var i = 0; i < WScript.Arguments.length; i++) {
- args[i] = WScript.Arguments.Item(i);
- }
- return {
- readFile: function (path) {
- try {
- var streamObj = getStreamObject();
- streamObj.Open();
- streamObj.Type = 2;
- streamObj.Charset = 'x-ansi';
- streamObj.LoadFromFile(path);
- var bomChar = streamObj.ReadText(2);
- streamObj.Position = 0;
- if((bomChar.charCodeAt(0) == 254 && bomChar.charCodeAt(1) == 255) || (bomChar.charCodeAt(0) == 255 && bomChar.charCodeAt(1) == 254)) {
- streamObj.Charset = 'unicode';
- } else if(bomChar.charCodeAt(0) == 239 && bomChar.charCodeAt(1) == 187) {
- streamObj.Charset = 'utf-8';
- }
- var str = streamObj.ReadText(-1);
- streamObj.Close();
- releaseStreamObject(streamObj);
- return str;
- } catch (err) {
- IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
- }
- },
- writeFile: function (path, contents) {
- var file = this.createFile(path);
- file.Write(contents);
- file.Close();
- },
- fileExists: function (path) {
- return fso.FileExists(path);
- },
- resolvePath: function (path) {
- return fso.GetAbsolutePathName(path);
- },
- dirName: function (path) {
- return fso.GetParentFolderName(path);
- },
- findFile: function (rootPath, partialFilePath) {
- var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
- while(true) {
- if(fso.FileExists(path)) {
- try {
- var content = this.readFile(path);
- return {
- content: content,
- path: path
- };
- } catch (err) {
- }
- } else {
- rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
- if(rootPath == "") {
- return null;
- } else {
- path = fso.BuildPath(rootPath, partialFilePath);
- }
- }
- }
- },
- deleteFile: function (path) {
- try {
- if(fso.FileExists(path)) {
- fso.DeleteFile(path, true);
- }
- } catch (e) {
- IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
- }
- },
- createFile: function (path, useUTF8) {
- try {
- var streamObj = getStreamObject();
- streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
- streamObj.Open();
- return {
- Write: function (str) {
- streamObj.WriteText(str, 0);
- },
- WriteLine: function (str) {
- streamObj.WriteText(str, 1);
- },
- Close: function () {
- try {
- streamObj.SaveToFile(path, 2);
- } catch (saveError) {
- IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
- }finally {
- if(streamObj.State != 0) {
- streamObj.Close();
- }
- releaseStreamObject(streamObj);
- }
- }
- };
- } catch (creationError) {
- IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
- }
- },
- directoryExists: function (path) {
- return fso.FolderExists(path);
- },
- createDirectory: function (path) {
- try {
- if(!this.directoryExists(path)) {
- fso.CreateFolder(path);
- }
- } catch (e) {
- IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
- }
- },
- dir: function (path, spec, options) {
- options = options || {
- };
- function filesInFolder(folder, root) {
- var paths = [];
- var fc;
- if(options.recursive) {
- fc = new Enumerator(folder.subfolders);
- for(; !fc.atEnd(); fc.moveNext()) {
- paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
- }
- }
- fc = new Enumerator(folder.files);
- for(; !fc.atEnd(); fc.moveNext()) {
- if(!spec || fc.item().Name.match(spec)) {
- paths.push(root + "/" + fc.item().Name);
- }
- }
- return paths;
- }
- var folder = fso.GetFolder(path);
- var paths = [];
- return filesInFolder(folder, path);
- },
- print: function (str) {
- WScript.StdOut.Write(str);
- },
- printLine: function (str) {
- WScript.Echo(str);
- },
- arguments: args,
- stderr: WScript.StdErr,
- stdout: WScript.StdOut,
- watchFile: null,
- run: function (source, filename) {
- try {
- eval(source);
- } catch (e) {
- IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
- }
- },
- getExecutingFilePath: function () {
- return WScript.ScriptFullName;
- },
- quit: function (exitCode) {
- if (typeof exitCode === "undefined") { exitCode = 0; }
- try {
- WScript.Quit(exitCode);
- } catch (e) {
- }
- }
- };
- }
- ;
- function getNodeIO() {
- var _fs = require('fs');
- var _path = require('path');
- var _module = require('module');
- return {
- readFile: function (file) {
- try {
- var buffer = _fs.readFileSync(file);
- switch(buffer[0]) {
- case 254:
- if(buffer[1] == 255) {
- var i = 0;
- while((i + 1) < buffer.length) {
- var temp = buffer[i];
- buffer[i] = buffer[i + 1];
- buffer[i + 1] = temp;
- i += 2;
- }
- return buffer.toString("ucs2", 2);
- }
- break;
- case 255:
- if(buffer[1] == 254) {
- return buffer.toString("ucs2", 2);
- }
- break;
- case 239:
- if(buffer[1] == 187) {
- return buffer.toString("utf8", 3);
- }
- }
- return buffer.toString();
- } catch (e) {
- IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
- }
- },
- writeFile: _fs.writeFileSync,
- deleteFile: function (path) {
- try {
- _fs.unlinkSync(path);
- } catch (e) {
- IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
- }
- },
- fileExists: function (path) {
- return _fs.existsSync(path);
- },
- createFile: function (path, useUTF8) {
- function mkdirRecursiveSync(path) {
- var stats = _fs.statSync(path);
- if(stats.isFile()) {
- IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
- } else if(stats.isDirectory()) {
- return;
- } else {
- mkdirRecursiveSync(_path.dirname(path));
- _fs.mkdirSync(path, 775);
- }
- }
- mkdirRecursiveSync(_path.dirname(path));
- try {
- var fd = _fs.openSync(path, 'w');
- } catch (e) {
- IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
- }
- return {
- Write: function (str) {
- _fs.writeSync(fd, str);
- },
- WriteLine: function (str) {
- _fs.writeSync(fd, str + '\r\n');
- },
- Close: function () {
- _fs.closeSync(fd);
- fd = null;
- }
- };
- },
- dir: function dir(path, spec, options) {
- options = options || {
- };
- function filesInFolder(folder, deep) {
- var paths = [];
- var files = _fs.readdirSync(folder);
- for(var i = 0; i < files.length; i++) {
- var stat = _fs.statSync(folder + "/" + files[i]);
- if(options.recursive && stat.isDirectory()) {
- if(deep < (options.deep || 100)) {
- paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
- }
- } else if(stat.isFile() && (!spec || files[i].match(spec))) {
- paths.push(folder + "/" + files[i]);
- }
- }
- return paths;
- }
- return filesInFolder(path, 0);
- },
- createDirectory: function (path) {
- try {
- if(!this.directoryExists(path)) {
- _fs.mkdirSync(path);
- }
- } catch (e) {
- IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
- }
- },
- directoryExists: function (path) {
- return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
- },
- resolvePath: function (path) {
- return _path.resolve(path);
- },
- dirName: function (path) {
- return _path.dirname(path);
- },
- findFile: function (rootPath, partialFilePath) {
- var path = rootPath + "/" + partialFilePath;
- while(true) {
- if(_fs.existsSync(path)) {
- try {
- var content = this.readFile(path);
- return {
- content: content,
- path: path
- };
- } catch (err) {
- }
- } else {
- var parentPath = _path.resolve(rootPath, "..");
- if(rootPath === parentPath) {
- return null;
- } else {
- rootPath = parentPath;
- path = _path.resolve(rootPath, partialFilePath);
- }
- }
- }
- },
- print: function (str) {
- process.stdout.write(str);
- },
- printLine: function (str) {
- process.stdout.write(str + '\n');
- },
- arguments: process.argv.slice(2),
- stderr: {
- Write: function (str) {
- process.stderr.write(str);
- },
- WriteLine: function (str) {
- process.stderr.write(str + '\n');
- },
- Close: function () {
- }
- },
- stdout: {
- Write: function (str) {
- process.stdout.write(str);
- },
- WriteLine: function (str) {
- process.stdout.write(str + '\n');
- },
- Close: function () {
- }
- },
- watchFile: function (filename, callback) {
- var firstRun = true;
- var processingChange = false;
- var fileChanged = function (curr, prev) {
- if(!firstRun) {
- if(curr.mtime < prev.mtime) {
- return;
- }
- _fs.unwatchFile(filename, fileChanged);
- if(!processingChange) {
- processingChange = true;
- callback(filename);
- setTimeout(function () {
- processingChange = false;
- }, 100);
- }
- }
- firstRun = false;
- _fs.watchFile(filename, {
- persistent: true,
- interval: 500
- }, fileChanged);
- };
- fileChanged();
- return {
- filename: filename,
- close: function () {
- _fs.unwatchFile(filename, fileChanged);
- }
- };
- },
- run: function (source, filename) {
- require.main.filename = filename;
- require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
- require.main._compile(source, filename);
- },
- getExecutingFilePath: function () {
- return process.mainModule.filename;
- },
- quit: process.exit
- };
- }
- ;
- if(typeof ActiveXObject === "function") {
- return getWindowsScriptHostIO();
- } else if(typeof require === "function") {
- return getNodeIO();
- } else {
- return null;
- }
-})();
-var cfg = {
- root: '.',
- pattern: /.\-tests\.ts/g,
- tsc: 'node ./_infrastructure/tests/typescript/tsc.js ',
- exclude: {
- '.git': true,
- '.gitignore': true,
- 'package.json': true,
- '_infrastructure': true,
- '.travis.yml': true,
- 'LICENSE': true,
- 'README.md': true,
- '_ReSharper.DefinitelyTyped': true,
- 'obj': true,
- 'bin': true,
- 'Properties': true,
- 'DefinitelyTyped.csproj': true,
- 'DefinitelyTyped.csproj.user': true,
- 'DefinitelyTyped.sln': true,
- 'DefinitelyTyped.v11.suo': true
- }
-};
-if(process.argv.length > 2) {
- cfg.root = process.argv[2];
-}
-var TestFile = (function () {
- function TestFile() {
- this.errors = [];
- }
- return TestFile;
-})();
-var Test = (function () {
- function Test(lib) {
- this.lib = lib;
- this.files = [];
- }
- return Test;
-})();
-var Tests = (function () {
- function Tests() {
- this.tests = [];
- }
- return Tests;
-})();
-function getLibDirectory(file) {
- return file.substr(cfg.root.length).split('/')[1];
-}
-function getErrorList(out) {
- var splitContentByNewlines = function (content) {
- var lines = content.split('\r\n');
- if(lines.length === 1) {
- lines = content.split('\n');
- }
- return lines;
- };
- var result = [];
- var lines = splitContentByNewlines(out);
- for(var i = 0; i < lines.length; i++) {
- if(lines[i]) {
- result.push(lines[i]);
- }
- }
- return result;
-}
-function runTests(testFiles) {
- var tests = new Tests();
- Exec.exec(cfg.tsc, [
- testFiles[testIndex]
- ], function (ExecResult) {
- var lib = getLibDirectory(testFiles[testIndex]);
- cache_visited_libs[lib] = true;
- var testFile = new TestFile();
- testFile.name = testFiles[testIndex];
- testFile.errors = getErrorList(ExecResult.stderr);
- if(testFile.errors.length == 0) {
- total_success++;
- } else {
- total_failure++;
- }
- console.log(' [\033[36m' + lib + '\033[0m] ' + testFiles[testIndex].substr(cfg.root.length) + ' - ' + (testFile.errors.length == 0 ? '\033[32msuccess\033[0m' : '\033[31mfailure\033[0m'));
- var test = new Test(lib);
- test.files.push(testFile);
- tests.tests.push(test);
- testIndex++;
- if(testIndex < totalTest) {
- Exec.exec(cfg.tsc, [
- testFiles[testIndex]
- ], arguments.callee);
- } else {
- var withoutTests = {
- };
- for(var k = 0; k < allFiles.length; k++) {
- var rootFolder = allFiles[k].substr(cfg.root.length).split('/')[1];
- if(!(rootFolder in cfg.exclude)) {
- if(!(rootFolder in cache_visited_libs)) {
- withoutTests[rootFolder] = true;
- }
- }
- }
- var withoutTestsCount = 0;
- for(var attr in withoutTests) {
- var test = new Test(attr);
- tests.tests.push(test);
- console.log(' [\033[36m' + attr + '\033[0m] without tests');
- withoutTestsCount++;
- }
- console.log('\n> ' + (total_failure + total_success + withoutTestsCount) + ' tests. ' + '\033[32m' + total_success + ' tests success\033[0m, ' + '\033[31m' + total_failure + ' tests failed\033[0m and ' + withoutTestsCount + ' definitions without tests.\n');
- if(total_failure > 0) {
- process.exit(1);
- }
- }
- });
-}
-var testFiles = IO.dir(cfg.root, cfg.pattern, {
- recursive: true,
- deep: 1
-});
-var allFiles = IO.dir(cfg.root, null, {
- recursive: true
-});
-var totalTest = testFiles.length;
-var testIndex = 0;
-var cache_visited_libs = {
-};
-var total_failure = 0;
-var total_success = 0;
-var tscVersion = '?.?.?';
-Exec.exec(cfg.tsc, [
- '-version'
-], function (ExecResult) {
- tscVersion = ExecResult.stdout;
- console.log('$ tsc -version');
- console.log(tscVersion);
- runTests(testFiles);
-});
diff --git a/_infrastructure/tests/testRunner.ts b/_infrastructure/tests/testRunner.ts
deleted file mode 100644
index c70da8d3c..000000000
--- a/_infrastructure/tests/testRunner.ts
+++ /dev/null
@@ -1,168 +0,0 @@
-///
-///
-
-var cfg = {
- root: '.',
- pattern: /.\-tests\.ts/g,
- tsc: 'node ./_infrastructure/tests/typescript/tsc.js ',
- exclude: {
- '.git': true,
- '.gitignore': true,
- 'package.json': true,
- '_infrastructure': true,
- '.travis.yml': true,
- 'LICENSE': true,
- 'README.md': true,
- '_ReSharper.DefinitelyTyped': true,
- 'obj': true,
- 'bin': true,
- 'Properties': true,
- 'DefinitelyTyped.csproj': true,
- 'DefinitelyTyped.csproj.user': true,
- 'DefinitelyTyped.sln': true,
- 'DefinitelyTyped.v11.suo': true
- }
-};
-
-if (process.argv.length > 2) {
- cfg.root = process.argv[2];
-}
-
-class TestFile {
- public name: string;
- public errors: string[] = [];
-}
-
-class Test {
- public files: TestFile[] = [];
- constructor(public lib: string) { }
-}
-
-class Tests {
- public tests: Test[] = [];
-}
-
-function getLibDirectory(file: string) {
- return file.substr(cfg.root.length).split('/')[1];
-}
-
-function getErrorList(out): string[] {
- var splitContentByNewlines = function (content: string) {
- var lines = content.split('\r\n');
- if (lines.length === 1) {
- lines = content.split('\n');
- }
- return lines;
- }
-
- var result: string[] = [];
-
- var lines = splitContentByNewlines(out);
-
- for (var i = 0; i < lines.length; i++) {
- if (lines[i]) {
- result.push(lines[i]);
- }
- }
-
- return result;
-}
-
-function runTests(testFiles) {
- var tests = new Tests();
-
- Exec.exec(
- cfg.tsc,
- [testFiles[testIndex]],
- (ExecResult) => {
- var lib = getLibDirectory(testFiles[testIndex]);
-
- cache_visited_libs[lib] = true;
-
- var testFile = new TestFile();
- testFile.name = testFiles[testIndex];
- testFile.errors = getErrorList(ExecResult.stderr);
-
- if (testFile.errors.length == 0) {
- total_success++;
- } else {
- total_failure++;
- }
-
- console.log(' [\033[36m' + lib + '\033[0m] ' + testFiles[testIndex].substr(cfg.root.length)
- + ' - ' + (testFile.errors.length == 0 ? '\033[32msuccess\033[0m' : '\033[31mfailure\033[0m'));
-
- var test = new Test(lib);
- test.files.push(testFile);
- tests.tests.push(test);
-
- testIndex++;
- if (testIndex < totalTest) {
- Exec.exec(
- cfg.tsc,
- [testFiles[testIndex]],
- <(ExecResult) => any>arguments.callee);
- } else {
- var withoutTests = {};
- for (var k = 0; k < allFiles.length; k++) {
- var rootFolder = allFiles[k].substr(cfg.root.length).split('/')[1];
- if (!(rootFolder in cfg.exclude)) {
- if (!(rootFolder in cache_visited_libs)) {
- withoutTests[rootFolder] = true;
- }
- }
- }
-
- var withoutTestsCount = 0;
- for (var attr in withoutTests) {
-
- var test = new Test(attr);
- tests.tests.push(test);
-
- console.log(' [\033[36m' + attr + '\033[0m] without tests');
- withoutTestsCount++;
- }
-
- console.log('\n> ' + (total_failure + total_success + withoutTestsCount)
- + ' tests. '
- + '\033[32m' + total_success + ' tests success\033[0m, '
- + '\033[31m' + total_failure + ' tests failed\033[0m and '
- + withoutTestsCount + ' definitions without tests.\n');
-
- if (total_failure > 0) {
- process.exit(1);
- }
- }
- });
-}
-
-////// GLOBAL VARS
-
-// get all files: "*-tests.ts"
-var testFiles = IO.dir(cfg.root, cfg.pattern, { recursive: true, deep: 1 });
-
-// get all proect files
-var allFiles = IO.dir(cfg.root, null, { recursive: true });
-
-var totalTest = testFiles.length;
-var testIndex = 0;
-var cache_visited_libs = {};
-
-// total
-var total_failure = 0;
-var total_success = 0;
-
-// var to have current typescript version
-var tscVersion = '?.?.?';
-
-////// END GLOBAL VARS
-
-// entry point
-Exec.exec(cfg.tsc, ['-version'], (ExecResult) => {
- tscVersion = ExecResult.stdout;
-
- console.log('$ tsc -version');
- console.log(tscVersion);
-
- runTests(testFiles);
-});
\ No newline at end of file
diff --git a/ace/ace.d.ts b/ace/ace.d.ts
index fe31dcc20..6a8e81625 100644
--- a/ace/ace.d.ts
+++ b/ace/ace.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Diullei Gomes
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-module AceAjax {
+declare module AceAjax {
export interface Delta {
action: string;
@@ -75,7 +75,7 @@ module AceAjax {
onTextInput(text);
}
- declare var KeyBinding: {
+ var KeyBinding: {
new(editor: Editor): KeyBinding;
}
@@ -184,7 +184,7 @@ module AceAjax {
**/
detach();
}
- declare var Anchor: {
+ var Anchor: {
/**
* Creates a new `Anchor` and associates it with a document.
* @param doc The document to associate with the anchor
@@ -248,7 +248,7 @@ module AceAjax {
**/
getState(row: number): string;
}
- declare var BackgroundTokenizer: {
+ var BackgroundTokenizer: {
/**
* Creates a new `BackgroundTokenizer` object.
* @param tokenizer The tokenizer to use
@@ -435,7 +435,7 @@ module AceAjax {
**/
positionToIndex(pos: Position, startRow: number): number;
}
- declare var Document: {
+ var Document: {
/**
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
* @param text The starting text
@@ -1011,7 +1011,7 @@ module AceAjax {
**/
getScreenLength(): number;
}
- declare var EditSession: {
+ var EditSession: {
/**
* Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`.
* @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam}
@@ -1702,7 +1702,7 @@ module AceAjax {
}
- declare var Editor: {
+ var Editor: {
/**
* Creates a new `Editor` object.
* @param renderer Associated `VirtualRenderer` that draws everything
@@ -1761,7 +1761,7 @@ module AceAjax {
**/
cancel();
}
- declare var PlaceHolder: {
+ var PlaceHolder: {
/**
* - @param session (Document): The document to associate with the anchor
* - @param length (Number): The starting row position
@@ -1995,7 +1995,7 @@ module AceAjax {
* @param endRow The ending row
* @param endColumn The ending column
**/
- declare var Range: {
+ var Range: {
fromPoints(pos1: Position, pos2: Position): Range;
new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
}
@@ -2005,7 +2005,7 @@ module AceAjax {
////////////////
export interface RenderLoop { }
- declare var RenderLoop: {
+ var RenderLoop: {
new(): RenderLoop;
}
@@ -2047,7 +2047,7 @@ module AceAjax {
**/
setScrollTop(scrollTop: number);
}
- declare var ScrollBar: {
+ var ScrollBar: {
/**
* Creates a new `ScrollBar`. `parent` is the owner of the scroll bar.
* @param parent A DOM element
@@ -2102,7 +2102,7 @@ module AceAjax {
**/
replace(input: string, replacement: string): string;
}
- declare var Search: {
+ var Search: {
/**
* Creates a new `Search` object. The following search options are avaliable:
* - `needle`: The string or regular expression you're looking for
@@ -2371,7 +2371,7 @@ module AceAjax {
**/
moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean);
}
- declare var Selection: {
+ var Selection: {
/**
* Creates a new `Selection` object.
* @param session The session to use
@@ -2459,7 +2459,7 @@ module AceAjax {
**/
resize();
}
- declare var Split: {
+ var Split: {
new(): Split;
}
@@ -2497,7 +2497,7 @@ module AceAjax {
**/
getCurrentTokenColumn(): number;
}
- declare var TokenIterator: {
+ var TokenIterator: {
/**
* Creates a new token iterator object. The inital token index is set to the provided row and column coordinates.
* @param session The session to associate with
@@ -2522,7 +2522,7 @@ module AceAjax {
**/
getLineTokens(): any;
}
- declare var Tokenizer: {
+ var Tokenizer: {
/**
* Constructs a new tokenizer based on the given rules and flags.
* @param rules The highlighting rules
@@ -2576,7 +2576,7 @@ module AceAjax {
hasRedo(): boolean;
}
- declare var UndoManager: {
+ var UndoManager: {
/**
* Resets the current undo state and creates a new `UndoManager`.
**/
@@ -2924,7 +2924,7 @@ module AceAjax {
destroy();
}
- declare var VirtualRenderer: {
+ var VirtualRenderer: {
/**
* Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`.
* @param container The root element of the editor
diff --git a/ace/tests/ace-anchor-tests.ts b/ace/tests/ace-anchor-tests.ts
index 40e81600a..08ca8f43f 100644
--- a/ace/tests/ace-anchor-tests.ts
+++ b/ace/tests/ace-anchor-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
"test create anchor" : function() {
var doc = new AceAjax.Document("juhu");
diff --git a/ace/tests/ace-background_tokenizer-tests.ts b/ace/tests/ace-background_tokenizer-tests.ts
index 8c29358a4..8f54bae51 100644
--- a/ace/tests/ace-background_tokenizer-tests.ts
+++ b/ace/tests/ace-background_tokenizer-tests.ts
@@ -1,5 +1,7 @@
///
+var assert: any;
+
function forceTokenize(session) {
for (var i = 0, l = session.getLength(); i < l; i++)
session.getTokens(i)
@@ -11,7 +13,7 @@ function testStates(session, states) {
assert.ok(l == states.length)
}
-exports = {
+var exports = {
"test background tokenizer update on session change": function() {
var doc = new AceAjax.EditSession([
diff --git a/ace/tests/ace-default-tests.ts b/ace/tests/ace-default-tests.ts
index dcd1ab103..f8a280c1a 100644
--- a/ace/tests/ace-default-tests.ts
+++ b/ace/tests/ace-default-tests.ts
@@ -1,5 +1,6 @@
///
+var assert: any;
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
diff --git a/ace/tests/ace-document-tests.ts b/ace/tests/ace-document-tests.ts
index 1f3e0a9a2..7fc342f74 100644
--- a/ace/tests/ace-document-tests.ts
+++ b/ace/tests/ace-document-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
"test: insert text in line": function() {
var doc = new AceAjax.Document(["12", "34"]);
diff --git a/ace/tests/ace-edit_session-tests.ts b/ace/tests/ace-edit_session-tests.ts
index 12a3ce5bf..caa2f1729 100644
--- a/ace/tests/ace-edit_session-tests.ts
+++ b/ace/tests/ace-edit_session-tests.ts
@@ -1,6 +1,7 @@
///
var lang: any;
+var assert: any;
function createFoldTestSession() {
var lines = [
@@ -26,7 +27,7 @@ function assertArray(a, b) {
}
}
-exports = {
+var exports = {
"test: find matching opening bracket in Text mode": function() {
var session = new AceAjax.EditSession(["(()(", "())))"]);
diff --git a/ace/tests/ace-editor1-tests.ts b/ace/tests/ace-editor1-tests.ts
index ed8b3b3e8..78d3aff04 100644
--- a/ace/tests/ace-editor1-tests.ts
+++ b/ace/tests/ace-editor1-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
setUp: function(next) {
this.session1 = new AceAjax.EditSession(["abc", "def"]);
diff --git a/ace/tests/ace-editor_highlight_selected_word-tests.ts b/ace/tests/ace-editor_highlight_selected_word-tests.ts
index 7e06c8c50..e02f32366 100644
--- a/ace/tests/ace-editor_highlight_selected_word-tests.ts
+++ b/ace/tests/ace-editor_highlight_selected_word-tests.ts
@@ -27,10 +27,13 @@ function callHighlighterUpdate(session: AceAjax.IEditSession, firstRow: number,
return rangeCount;
}
-exports = {
+var assert: any;
+var renderer: AceAjax.VirtualRenderer;
+
+var exports = {
setUp: function(next) {
var session = new AceAjax.EditSession(lipsum);
- editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
var selection = session.getSelection();
next();
} ,
@@ -38,7 +41,7 @@ exports = {
"test: highlight selected words by default": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
assert.equal(editor.getHighlightSelectedWord(), true);
} ,
@@ -46,7 +49,7 @@ exports = {
"test: highlight a word": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 9);
selection.selectWord();
@@ -63,7 +66,7 @@ exports = {
"test: highlight a word and clear highlight": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 8);
selection.selectWord();
@@ -79,7 +82,7 @@ exports = {
"test: highlight another word": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.moveCursorTo(0, 14);
selection.selectWord();
@@ -92,7 +95,7 @@ exports = {
"test: no selection, no highlight": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.clearSelection();
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
@@ -101,7 +104,7 @@ exports = {
"test: select a word, no highlight": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.moveCursorTo(0, 14);
selection.selectWord();
@@ -116,7 +119,7 @@ exports = {
"test: select a word with no matches": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.setHighlightSelectedWord(true);
@@ -143,7 +146,7 @@ exports = {
"test: partial word selection 1": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.moveCursorTo(0, 14);
selection.selectWord();
@@ -157,7 +160,7 @@ exports = {
"test: partial word selection 2": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.moveCursorTo(0, 13);
selection.selectWord();
@@ -171,7 +174,7 @@ exports = {
"test: partial word selection 3": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.moveCursorTo(0, 14);
selection.selectWord();
@@ -186,7 +189,7 @@ exports = {
"test: select last word": function () {
var selection = session.getSelection();
var session = new AceAjax.EditSession(lipsum);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
selection.moveCursorTo(0, 1);
diff --git a/ace/tests/ace-editor_navigation-tests.ts b/ace/tests/ace-editor_navigation-tests.ts
index c97ee0cd2..b68ae9b9d 100644
--- a/ace/tests/ace-editor_navigation-tests.ts
+++ b/ace/tests/ace-editor_navigation-tests.ts
@@ -1,6 +1,8 @@
///
-exports = {
+var assert: any;
+var renderer: AceAjax.VirtualRenderer;
+var exports = {
createEditSession: function (rows, cols) {
var line = new Array(cols + 1).join("a");
var text = new Array(rows).join(line + "\n") + line;
@@ -9,7 +11,7 @@ exports = {
"test: navigate to end of file should scroll the last line into view": function () {
var doc = this.createEditSession(200, 10);
- var editor = new AceAjax.Editor(new MockRenderer(), doc);
+ var editor = new AceAjax.Editor(renderer, doc);
editor.navigateFileEnd();
var cursor = editor.getCursorPosition();
@@ -20,7 +22,7 @@ exports = {
"test: navigate to start of file should scroll the first row into view": function () {
var doc = this.createEditSession(200, 10);
- var editor = new AceAjax.Editor(new MockRenderer(), doc);
+ var editor = new AceAjax.Editor(renderer, doc);
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
editor.navigateFileStart();
@@ -29,7 +31,7 @@ exports = {
},
"test: goto hidden line should scroll the line into the middle of the viewport": function () {
- var editor = new AceAjax.Editor(new MockRenderer(), this.createEditSession(200, 5));
+ var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5));
editor.navigateTo(0, 0);
editor.gotoLine(101);
@@ -63,7 +65,7 @@ exports = {
},
"test: goto visible line should only move the cursor and not scroll": function () {
- var editor = new AceAjax.Editor(new MockRenderer(), this.createEditSession(200, 5));
+ var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5));
editor.navigateTo(0, 0);
editor.gotoLine(12);
@@ -77,7 +79,7 @@ exports = {
},
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function () {
- var editor = new AceAjax.Editor(new MockRenderer(), new AceAjax.EditSession(["123456", "1"]));
+ var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "1"]));
editor.navigateTo(0, 6);
assert.position(editor.getCursorPosition(), 0, 6);
@@ -90,7 +92,7 @@ exports = {
},
"test: reset desired column on navigate left or right": function () {
- var editor = new AceAjax.Editor(new MockRenderer(), new AceAjax.EditSession(["123456", "12"]));
+ var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "12"]));
editor.navigateTo(0, 6);
assert.position(editor.getCursorPosition(), 0, 6);
@@ -106,7 +108,7 @@ exports = {
},
"test: typing text should update the desired column": function () {
- var editor = new AceAjax.Editor(new MockRenderer(), new AceAjax.EditSession(["1234", "1234567890"]));
+ var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["1234", "1234567890"]));
editor.navigateTo(0, 3);
editor.insert("juhu");
diff --git a/ace/tests/ace-editor_text_edit-tests.ts b/ace/tests/ace-editor_text_edit-tests.ts
index 9d618acc6..623183016 100644
--- a/ace/tests/ace-editor_text_edit-tests.ts
+++ b/ace/tests/ace-editor_text_edit-tests.ts
@@ -1,9 +1,12 @@
///
-exports = {
+var assert: any;
+var renderer: AceAjax.VirtualRenderer;
+var mode: any;
+var exports = {
"test: delete line from the middle": function () {
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.removeLines();
@@ -29,7 +32,7 @@ exports = {
"test: delete multiple selected lines": function () {
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.getSelection().selectDown();
@@ -41,7 +44,7 @@ exports = {
"test: delete first line": function () {
var session = new AceAjax.EditSession(["a", "b", "c"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.removeLines();
@@ -51,7 +54,7 @@ exports = {
"test: delete last should also delete the new line of the previous line": function () {
var session = new AceAjax.EditSession(["a", "b", "c", ""].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(3, 0);
@@ -66,7 +69,7 @@ exports = {
"test: indent block": function () {
var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 3);
editor.getSelection().selectDown();
@@ -84,7 +87,7 @@ exports = {
"test: indent selected lines": function () {
var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.getSelection().selectDown();
@@ -94,8 +97,8 @@ exports = {
},
"test: no auto indent if cursor is before the {": function () {
- var session = new AceAjax.EditSession("{", new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession("{",mode);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 0);
editor.onTextInput("\n");
@@ -104,7 +107,7 @@ exports = {
"test: outdent block": function () {
var session = new AceAjax.EditSession([" a12345", " b12345", " c12345"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 5);
editor.getSelection().selectDown();
@@ -129,7 +132,7 @@ exports = {
"test: outent without a selection should update cursor": function () {
var session = new AceAjax.EditSession(" 12");
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 3);
editor.blockOutdent(" ");
@@ -139,8 +142,8 @@ exports = {
},
"test: comment lines should perserve selection": function () {
- var session = new AceAjax.EditSession([" abc", "cde"].join("\n"), new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession([" abc", "cde"].join("\n"),mode);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 2);
editor.getSelection().selectDown();
@@ -154,8 +157,8 @@ exports = {
},
"test: uncomment lines should perserve selection": function () {
- var session = new AceAjax.EditSession(["// abc", "//cde"].join("\n"), new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession(["// abc", "//cde"].join("\n"),mode);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 1);
editor.getSelection().selectDown();
@@ -169,8 +172,8 @@ exports = {
},
"test: toggle comment lines twice should return the original text": function () {
- var session = new AceAjax.EditSession([" abc", "cde", "fg"], new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession([" abc", "cde", "fg"], mode);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 0);
editor.getSelection().selectDown();
@@ -185,8 +188,8 @@ exports = {
"test: comment lines - if the selection end is at the line start it should stay there": function () {
//select down
- var session = new AceAjax.EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 0);
editor.getSelection().selectDown();
@@ -195,8 +198,8 @@ exports = {
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
// select up
- var session = new AceAjax.EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.getSelection().selectUp();
@@ -207,7 +210,7 @@ exports = {
"test: move lines down should select moved lines": function () {
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(0, 1);
editor.getSelection().selectDown();
@@ -234,7 +237,7 @@ exports = {
"test: move lines up should select moved lines": function () {
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(2, 1);
editor.getSelection().selectDown();
@@ -254,7 +257,7 @@ exports = {
"test: move line without active selection should not move cursor relative to the moved line": function () {
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.clearSelection();
@@ -272,7 +275,7 @@ exports = {
"test: copy lines down should select lines and place cursor at the selection start": function () {
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.getSelection().selectDown();
@@ -287,7 +290,7 @@ exports = {
"test: copy lines up should select lines and place cursor at the selection start": function () {
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.getSelection().selectDown();
@@ -302,7 +305,7 @@ exports = {
"test: input a tab with soft tab should convert it to spaces": function () {
var session = new AceAjax.EditSession("");
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
session.setTabSize(2);
session.setUseSoftTabs(true);
@@ -317,7 +320,7 @@ exports = {
"test: input tab without soft tabs should keep the tab character": function () {
var session = new AceAjax.EditSession("");
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
session.setUseSoftTabs(false);
@@ -331,7 +334,7 @@ exports = {
session.setUndoManager(undoManager);
var initialText = session.toString();
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.removeLines();
var step1 = session.toString();
@@ -361,7 +364,7 @@ exports = {
"test: remove left should remove character left of the cursor": function () {
var session = new AceAjax.EditSession(["123", "456"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.remove("left");
assert.equal(session.toString(), "123\n56");
@@ -370,7 +373,7 @@ exports = {
"test: remove left should remove line break if cursor is at line start": function () {
var session = new AceAjax.EditSession(["123", "456"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.remove("left");
assert.equal(session.toString(), "123456");
@@ -381,7 +384,7 @@ exports = {
session.setUseSoftTabs(true);
session.setTabSize(4);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 8);
editor.remove("left");
assert.equal(session.toString(), "123\n 456");
@@ -390,7 +393,7 @@ exports = {
"test: transpose at line start should be a noop": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.transposeLetters();
@@ -400,7 +403,7 @@ exports = {
"test: transpose in line should swap the charaters before and after the cursor": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 2);
editor.transposeLetters();
@@ -410,7 +413,7 @@ exports = {
"test: transpose at line end should swap the last two characters": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 4);
editor.transposeLetters();
@@ -420,7 +423,7 @@ exports = {
"test: transpose with non empty selection should be a noop": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 1);
editor.getSelection().selectRight();
editor.transposeLetters();
@@ -431,7 +434,7 @@ exports = {
"test: transpose should move the cursor behind the last swapped character": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 2);
editor.transposeLetters();
assert.position(editor.getCursorPosition(), 1, 3);
@@ -440,7 +443,7 @@ exports = {
"test: remove to line end": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 2);
editor.removeToLineEnd();
assert.equal(session.getValue(), ["123", "45", "89"].join("\n"));
@@ -449,7 +452,7 @@ exports = {
"test: remove to line end at line end should remove the new line": function () {
var session = new AceAjax.EditSession(["123", "4567", "89"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 4);
editor.removeToLineEnd();
assert.position(editor.getCursorPosition(), 1, 4);
@@ -459,7 +462,7 @@ exports = {
"test: transform selection to uppercase": function () {
var session = new AceAjax.EditSession(["ajax", "dot", "org"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.getSelection().selectLineEnd();
editor.toUpperCase()
@@ -469,7 +472,7 @@ exports = {
"test: transform word to uppercase": function () {
var session = new AceAjax.EditSession(["ajax", "dot", "org"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.toUpperCase()
assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n"));
@@ -479,7 +482,7 @@ exports = {
"test: transform selection to lowercase": function () {
var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.getSelection().selectLineEnd();
editor.toLowerCase()
@@ -489,7 +492,7 @@ exports = {
"test: transform word to lowercase": function () {
var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]);
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
editor.moveCursorTo(1, 0);
editor.toLowerCase()
assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n"));
diff --git a/ace/tests/ace-multi_select-tests.ts b/ace/tests/ace-multi_select-tests.ts
index ade1493e2..68c7d1af9 100644
--- a/ace/tests/ace-multi_select-tests.ts
+++ b/ace/tests/ace-multi_select-tests.ts
@@ -1,5 +1,8 @@
///
+var assert: any;
+var editor: any;
+var renderer: any;
var exec = function (name?, times?, args?) {
do {
editor.commands.exec(name, editor, args);
@@ -9,7 +12,7 @@ var testRanges = function (str) {
assert.equal(editor.selection.getAllRanges() + "", str + "");
}
-exports = {
+var exports = {
name: "ACE multi_select.js",
@@ -19,7 +22,7 @@ exports = {
" wtt.w",
" wtt.w"
]);
- editor = new AceAjax.Editor(new MockRenderer(), doc);
+ editor = new AceAjax.Editor(renderer, doc);
editor.navigateFileEnd();
exec("selectMoreBefore", 3);
@@ -45,7 +48,7 @@ exports = {
" wtt.w",
" wtt.we"
]);
- editor = new AceAjax.Editor(new MockRenderer(), doc);
+ editor = new AceAjax.Editor(renderer, doc);
editor.selectMoreLines(1);
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
@@ -67,7 +70,7 @@ exports = {
" wtt.w",
" wtt.w"
]);
- editor = new AceAjax.Editor(new MockRenderer(), doc);
+ editor = new AceAjax.Editor(renderer, doc);
editor.selectMoreLines(1)
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
@@ -87,7 +90,7 @@ exports = {
" wtt.w",
" wtt.w"
]);
- editor = new AceAjax.Editor(new MockRenderer(), doc);
+ editor = new AceAjax.Editor(renderer, doc);
var selection = editor.selection;
diff --git a/ace/tests/ace-placeholder-tests.ts b/ace/tests/ace-placeholder-tests.ts
index 124554cf7..b9693da37 100644
--- a/ace/tests/ace-placeholder-tests.ts
+++ b/ace/tests/ace-placeholder-tests.ts
@@ -1,10 +1,13 @@
///
-exports = {
+var assert: any;
+var renderer: AceAjax.VirtualRenderer;
+var mode: any;
+var exports = {
"test: simple at the end appending of text": function () {
- var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
+ var editor = new AceAjax.Editor(renderer, session);
new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
@@ -20,8 +23,8 @@ exports = {
},
"test: inserting text outside placeholder": function () {
- var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);\n", new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);\n", mode);
+ var editor = new AceAjax.Editor(renderer, session);
new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
@@ -31,8 +34,8 @@ exports = {
},
"test: insertion at the beginning": function (next) {
- var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
+ var editor = new AceAjax.Editor(renderer, session);
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
@@ -49,8 +52,8 @@ exports = {
},
"test: detaching placeholder": function () {
- var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
+ var editor = new AceAjax.Editor(renderer, session);
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
@@ -63,8 +66,8 @@ exports = {
},
"test: events": function () {
- var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
+ var editor = new AceAjax.Editor(renderer, session);
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
var entered = false;
@@ -86,9 +89,9 @@ exports = {
},
"test: cancel": function (next) {
- var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
+ var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
session.setUndoManager(new AceAjax.UndoManager());
- var editor = new AceAjax.Editor(new MockRenderer(), session);
+ var editor = new AceAjax.Editor(renderer, session);
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
editor.moveCursorTo(0, 5);
diff --git a/ace/tests/ace-range-tests.ts b/ace/tests/ace-range-tests.ts
index 8a1b1ccc6..8e560e8d2 100644
--- a/ace/tests/ace-range-tests.ts
+++ b/ace/tests/ace-range-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
name: "ACE range.js",
diff --git a/ace/tests/ace-range_list-tests.ts b/ace/tests/ace-range_list-tests.ts
index 83f3c8a91..3a531579e 100644
--- a/ace/tests/ace-range_list-tests.ts
+++ b/ace/tests/ace-range_list-tests.ts
@@ -1,5 +1,6 @@
///
+var assert: any;
function flatten(rangeList) {
var points = [];
rangeList.ranges.forEach(function (r) {
@@ -11,7 +12,7 @@ function testRangeList(rangeList, points) {
assert.equal("" + flatten(rangeList), "" + points);
}
-exports = {
+var exports = {
name: "ACE range_list.js",
diff --git a/ace/tests/ace-search-tests.ts b/ace/tests/ace-search-tests.ts
index c30139d65..14b53397b 100644
--- a/ace/tests/ace-search-tests.ts
+++ b/ace/tests/ace-search-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
"test: configure the search object": function () {
var search = new AceAjax.Search();
search.set({
diff --git a/ace/tests/ace-selection-tests.ts b/ace/tests/ace-selection-tests.ts
index 030cdff66..884631085 100644
--- a/ace/tests/ace-selection-tests.ts
+++ b/ace/tests/ace-selection-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
createSession: function (rows, cols) {
var line = new Array(cols + 1).join("a");
var text = new Array(rows).join(line + "\n") + line;
diff --git a/ace/tests/ace-token_iterator-tests.ts b/ace/tests/ace-token_iterator-tests.ts
index 75260e95a..892d781b9 100644
--- a/ace/tests/ace-token_iterator-tests.ts
+++ b/ace/tests/ace-token_iterator-tests.ts
@@ -1,6 +1,8 @@
///
-exports = {
+var assert: any;
+var mode: any;
+var exports = {
"test: token iterator initialization in JavaScript document": function () {
var lines = [
"function foo(items) {",
@@ -9,7 +11,7 @@ exports = {
" } // Real Tab.",
"}"
];
- var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
+ var session = new AceAjax.EditSession(lines.join("\n"),mode);
var iterator = new AceAjax.TokenIterator(session, 0, 0);
assert.equal(iterator.getCurrentToken().value, "function");
@@ -96,7 +98,7 @@ exports = {
" } // Real Tab.",
"}"
];
- var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
+ var session = new AceAjax.EditSession(lines.join("\n"),mode);
var tokens = [];
var len = session.getLength();
@@ -118,7 +120,7 @@ exports = {
" } // Real Tab.",
"}"
];
- var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
+ var session = new AceAjax.EditSession(lines.join("\n"),mode);
var tokens = [];
var len = session.getLength();
@@ -140,7 +142,7 @@ exports = {
" } // Real Tab.",
"}"
];
- var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
+ var session = new AceAjax.EditSession(lines.join("\n"),mode);
var iterator = new AceAjax.TokenIterator(session, 0, 0);
diff --git a/ace/tests/ace-virtual_renderer-tests.ts b/ace/tests/ace-virtual_renderer-tests.ts
index 83372ad34..51f349dad 100644
--- a/ace/tests/ace-virtual_renderer-tests.ts
+++ b/ace/tests/ace-virtual_renderer-tests.ts
@@ -1,6 +1,7 @@
///
-exports = {
+var assert: any;
+var exports = {
"test: screen2text the column should be rounded to the next character edge": function () {
var el = document.createElement("div");
diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts
index 6354e188c..3ea1371f4 100644
--- a/angularjs/angular-tests.ts
+++ b/angularjs/angular-tests.ts
@@ -142,7 +142,7 @@ module HttpAndRegularPromiseTests {
// Test for AngularJS Syntac
module My.Namespace {
-
+ export var x; // need to export something for module to kick in
}
// IModule Registering Test
@@ -150,7 +150,7 @@ 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', function ($scope: ng.IScope) {})
mod.directive('name', ['$scope', function($scope : ng.IScope) {}])
mod.directive(My.Namespace);
mod.factory('name', function($scope : ng.IScope) {})
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 10fb67a3f..8e5e2a007 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -173,7 +173,7 @@ declare module ng {
// see http://docs.angularjs.org/api/ng.$rootScope.Scope
///////////////////////////////////////////////////////////////////////////
interface IScope {
- // Documentation says exp is optional, but actual implementaton counts on it
+ $apply(): any;
$apply(exp: string): any;
$apply(exp: (scope: IScope) => any): any;
diff --git a/async/async-tests.ts b/async/async-tests.ts
index e7b57a1f8..fefc3fd2a 100644
--- a/async/async-tests.ts
+++ b/async/async-tests.ts
@@ -18,10 +18,10 @@ async.series([
function () { }
]);
-var data;
-function asyncProcess() { }
+var data = [];
+function asyncProcess(item, callback) { }
async.map(data, asyncProcess, function (err, results) {
- alert(results);
+ console.log(results);
});
var openFiles = ['file1', 'file2'];
diff --git a/async/async.d.ts b/async/async.d.ts
index 835c10777..6c06348d5 100644
--- a/async/async.d.ts
+++ b/async/async.d.ts
@@ -1,67 +1,71 @@
-// Type definitions for Async 0.1
+// Type definitions for Async 0.1.23
// Project: https://github.com/caolan/async
// Definitions by: Boris Yankov
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+interface AsyncMultipleResultsCallback { (err: string, results: T[]): any; }
+interface AsyncSingleResultCallback { (err: string, result: T): any; }
+interface AsyncTimesCallback { (n: number, callback: AsyncMultipleResultsCallback): void; }
+interface AsyncIterator { (item: T, callback: AsyncMultipleResultsCallback): void; }
+interface AsyncMemoIterator { (memo: T, item: T, callback: AsyncSingleResultCallback): void; }
+interface AsyncWorker { (task: T, callback: Function): void; }
-interface AsyncCallback { (err: string, results: any): any; }
-interface AsyncIterator { (item, callback: AsyncCallback): void; }
-interface AsyncMemoIterator { (memo: any, item: any, callback: AsyncCallback): void; }
-interface AsyncWorker { (task: any, callback: Function): void; }
-
-interface AsyncQueue {
+interface AsyncQueue {
length(): number;
concurrency: number;
- push(task: any, callback: AsyncCallback): void;
- saturated: AsyncCallback;
- empty: AsyncCallback;
- drain: AsyncCallback;
+ push(task: T, callback: AsyncMultipleResultsCallback): void;
+ saturated: AsyncMultipleResultsCallback;
+ empty: AsyncMultipleResultsCallback;
+ drain: AsyncMultipleResultsCallback;
}
interface Async {
// Collections
- forEach(arr: any[], iterator: AsyncIterator, callback: AsyncCallback): void;
- forEachSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback): void;
- forEachLimit(arr: any[], limit: number, iterator: AsyncIterator, callback: AsyncCallback): void;
- map(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- mapSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- filter(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- select(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- filterSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- selectSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- reject(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- rejectSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- reduce(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
- inject(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
- foldl(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
- reduceRight(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
- foldr(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
- detect(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- detectSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- sortBy(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- some(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- any(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- every(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- all(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- concat(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
- concatSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
+ forEach(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
+ forEachSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
+ forEachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
+ map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ select(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ filterSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ selectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ reject(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ rejectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ reduce(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback);
+ inject(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback);
+ foldl(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback);
+ reduceRight(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback);
+ foldr(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback);
+ detect(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ detectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ sortBy(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ some(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ any(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ every(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any);
+ all(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any);
+ concat(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
+ concatSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback);
// Control Flow
- series(tasks: any[], callback?: AsyncCallback): void;
- series(tasks: any, callback?: AsyncCallback): void;
- parallel(tasks: any[], callback?: AsyncCallback): void;
- parallel(tasks: any, callback?: AsyncCallback): void;
- whilst(test: Function, fn: Function, callback: AsyncCallback): void;
- until(test: Function, fn: Function, callback: AsyncCallback): void;
- waterfall(tasks: any[], callback?: AsyncCallback): void;
- waterfall(tasks: any, callback?: AsyncCallback): void;
- queue(worker: AsyncWorker, concurrency: number): AsyncQueue;
- //auto(tasks: any[], callback?: AsyncCallback): void;
- auto(tasks: any, callback?: AsyncCallback): void;
- iterator(tasks): Function;
+ series(tasks: T[], callback?: AsyncMultipleResultsCallback): void;
+ series(tasks: T, callback?: AsyncMultipleResultsCallback): void;
+ parallel(tasks: T[], callback?: AsyncMultipleResultsCallback): void;
+ parallel(tasks: T, callback?: AsyncMultipleResultsCallback): void;
+ whilst(test: Function, fn: Function, callback: Function): void;
+ until(test: Function, fn: Function, callback: Function): void;
+ waterfall(tasks: T[], callback?: AsyncMultipleResultsCallback): void;
+ waterfall(tasks: T, callback?: AsyncMultipleResultsCallback): void;
+ queue(worker: AsyncWorker, concurrency: number): AsyncQueue;
+ // auto(tasks: any[], callback?: AsyncMultipleResultsCallback): void;
+ auto(tasks: any, callback?: AsyncMultipleResultsCallback): void;
+ iterator(tasks: Function[]): Function;
apply(fn: Function, ...arguments: any[]): void;
- nextTick(callback: AsyncCallback): void;
+ nextTick(callback: Function): void;
+
+ times (n: number, callback: AsyncTimesCallback): void;
+ timesSeries (n: number, callback: AsyncTimesCallback): void;
// Utils
memoize(fn: Function, hasher?: Function): Function;
diff --git a/azure-mobile-services-client/AzureMobileServicesClient-tests.ts b/azure-mobile-services-client/AzureMobileServicesClient-tests.ts
index b557a2baf..f381c0809 100644
--- a/azure-mobile-services-client/AzureMobileServicesClient-tests.ts
+++ b/azure-mobile-services-client/AzureMobileServicesClient-tests.ts
@@ -32,8 +32,8 @@ tableTodoItems.read()
//define simple handler used in callback calls for insert/update and delete
-function handlerInsUpd(e, i) => { if (!e) data.push( i); };
-function handlerDelErr(e) => { if (e) alert("ERROR: " + e); }
+function handlerInsUpd(e, i) { if (!e) data.push( i); };
+function handlerDelErr(e) { if (e) alert("ERROR: " + e); }
//insert one data passing info in POST + custom data in QueryString + simple callback handler
diff --git a/azure-mobile-services-client/AzureMobileServicesClient.d.ts b/azure-mobile-services-client/AzureMobileServicesClient.d.ts
index 1dcf9e5a6..09d0efb7c 100644
--- a/azure-mobile-services-client/AzureMobileServicesClient.d.ts
+++ b/azure-mobile-services-client/AzureMobileServicesClient.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Morosinotto Daniele
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-module Microsoft.WindowsAzure {
+declare module Microsoft.WindowsAzure {
// MobileServiceClient object based on Microsoft Azure documentation: http://msdn.microsoft.com/en-us/library/windowsazure/jj554219.aspx
interface MobileServiceClient {
diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts
index 92ff102dc..2a4a60819 100644
--- a/backbone/backbone.d.ts
+++ b/backbone/backbone.d.ts
@@ -1,6 +1,7 @@
-// Type definitions for Backbone 0.9.10
+// Type definitions for Backbone 1.0.0
// Project: http://backbonejs.org/
// Definitions by: Boris Yankov
+// Definitions by: Natan Vivo
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -8,61 +9,61 @@
declare module Backbone {
- export interface AddOptions extends Silenceable {
+ interface AddOptions extends Silenceable {
at: number;
}
- export interface HistoryOptions extends Silenceable {
- pushState?: bool;
+ interface HistoryOptions extends Silenceable {
+ pushState?: boolean;
root?: string;
}
- export interface NavigateOptions {
- trigger: bool;
+ interface NavigateOptions {
+ trigger: boolean;
}
- export interface RouterOptions {
+ interface RouterOptions {
routes: any;
}
- export interface Silenceable {
- silent?: bool;
+ interface Silenceable {
+ silent?: boolean;
}
interface Validable {
- validate?: bool;
+ validate?: boolean;
}
interface Waitable {
- wait?: bool;
+ wait?: boolean;
}
interface Parseable {
parse?: any;
}
- export interface PersistenceOptions {
+ interface PersistenceOptions {
url?: string;
beforeSend?: (jqxhr: JQueryXHR) => void;
success?: (modelOrCollection?: any, response?: any, options?: any) => void;
error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
}
- export interface ModelSetOptions extends Silenceable extends Validable {
+ interface ModelSetOptions extends Silenceable, Validable {
}
- export interface ModelFetchOptions extends PersistenceOptions extends ModelSetOptions extends Parseable {
+ interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable {
}
- export interface ModelSaveOptions extends Silenceable extends Waitable extends Validable extends Parseable extends PersistenceOptions {
- patch?: bool;
+ interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions {
+ patch?: boolean;
}
- export interface ModelDestroyOptions extends Waitable extends PersistenceOptions {
+ interface ModelDestroyOptions extends Waitable, PersistenceOptions {
}
- export interface CollectionFetchOptions extends PersistenceOptions extends Parseable {
- reset?: bool;
+ interface CollectionFetchOptions extends PersistenceOptions, Parseable {
+ reset?: boolean;
}
interface on { (eventName: string, callback: (...args: any[]) => void, context?: any): any; }
@@ -71,7 +72,7 @@ declare module Backbone {
interface bind { (eventName: string, callback: (...args: any[]) => void, context?: any): any; }
interface unbind { (eventName?: string, callback?: (...args: any[]) => void, context?: any): any; }
- declare class Events {
+ class Events {
on(eventName: string, callback: (...args:any[]) => void, context?: any): any;
off(eventName?: string, callback?: (...args:any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
@@ -84,7 +85,7 @@ declare module Backbone {
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void ): any;
}
- export class ModelBase extends Events {
+ class ModelBase extends Events {
url: any;
parse(response, options?: any);
toJSON(options?: any): any;
@@ -92,7 +93,7 @@ declare module Backbone {
}
- export class Model extends ModelBase {
+ class Model extends ModelBase {
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
@@ -120,10 +121,10 @@ declare module Backbone {
defaults(): any;
destroy(options?: ModelDestroyOptions);
escape(attribute: string);
- has(attribute: string): bool;
- hasChanged(attribute?: string): bool;
- isNew(): bool;
- isValid(): bool;
+ has(attribute: string): boolean;
+ hasChanged(attribute?: string): boolean;
+ isNew(): boolean;
+ isValid(): boolean;
previous(attribute: string): any;
previousAttributes(): any[];
save(attributes?: any, options?: ModelSaveOptions);
@@ -131,7 +132,7 @@ declare module Backbone {
validate(attributes: any, options?: any): any;
}
- export class Collection extends ModelBase {
+ class Collection extends ModelBase {
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
@@ -164,34 +165,34 @@ declare module Backbone {
unshift(model: Model, options?: AddOptions);
where(properies: any): Model[];
- all(iterator: (element: Model, index: number) => bool, context?: any): bool;
- any(iterator: (element: Model, index: number) => bool, context?: any): bool;
+ all(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
+ any(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
collect(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[];
chain(): any;
compact(): Model[];
- contains(value: any): bool;
+ contains(value: any): boolean;
countBy(iterator: (element: Model, index: number) => any): any[];
countBy(attribute: string): any[];
- detect(iterator: (item: any) => bool, context?: any): any; // ???
+ detect(iterator: (item: any) => boolean, context?: any): any; // ???
difference(...model: Model[]): Model[];
drop(): Model;
drop(n: number): Model[];
each(iterator: (element: Model, index: number, list?: any) => void, context?: any);
- every(iterator: (element: Model, index: number) => bool, context?: any): bool;
- filter(iterator: (element: Model, index: number) => bool, context?: any): Model[];
- find(iterator: (element: Model, index: number) => bool, context?: any): Model;
+ every(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
+ filter(iterator: (element: Model, index: number) => boolean, context?: any): Model[];
+ find(iterator: (element: Model, index: number) => boolean, context?: any): Model;
first(): Model;
first(n: number): Model[];
- flatten(shallow?: bool): Model[];
+ flatten(shallow?: boolean): Model[];
foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
forEach(iterator: (element: Model, index: number, list?: any) => void, context?: any);
- include(value: any): bool;
- indexOf(element: Model, isSorted?: bool): number;
+ include(value: any): boolean;
+ indexOf(element: Model, isSorted?: boolean): number;
initial(): Model;
initial(n: number): Model[];
inject(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
intersection(...model: Model[]): Model[];
- isEmpty(object: any): bool;
+ isEmpty(object: any): boolean;
invoke(methodName: string, arguments?: any[]);
last(): Model;
last(n: number): Model[];
@@ -204,26 +205,26 @@ declare module Backbone {
select(iterator: any, context?: any): any[];
size(): number;
shuffle(): any[];
- some(iterator: (element: Model, index: number) => bool, context?: any): bool;
+ some(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
sortBy(iterator: (element: Model, index: number) => number, context?: any): Model[];
sortBy(attribute: string, context?: any): Model[];
sortedIndex(element: Model, iterator?: (element: Model, index: number) => number): number;
range(stop: number, step?: number);
range(start: number, stop: number, step?: number);
reduceRight(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any[];
- reject(iterator: (element: Model, index: number) => bool, context?: any): Model[];
+ reject(iterator: (element: Model, index: number) => boolean, context?: any): Model[];
rest(): Model;
rest(n: number): Model[];
tail(): Model;
tail(n: number): Model[];
toArray(): any[];
union(...model: Model[]): Model[];
- uniq(isSorted?: bool, iterator?: (element: Model, index: number) => bool): Model[];
+ uniq(isSorted?: boolean, iterator?: (element: Model, index: number) => boolean): Model[];
without(...values: any[]): Model[];
zip(...model: Model[]): Model[];
}
- export class Router extends Events {
+ class Router extends Events {
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
@@ -233,20 +234,20 @@ declare module Backbone {
initialize (options?: RouterOptions);
route(route: string, name: string, callback?: (...parameter: any[]) => void);
navigate(fragment: string, options?: NavigateOptions);
- navigate(fragment: string, trigger?: bool);
+ navigate(fragment: string, trigger?: boolean);
}
- export var history: History;
- export class History {
+ var history: History;
+ class History {
start(options?: HistoryOptions);
navigate(fragment: string, options: any);
pushSate();
- getFragment(fragment?: string, forcePushState?: bool): string;
+ getFragment(fragment?: string, forcePushState?: boolean): string;
getHash(window?: Window): string;
- started: bool;
+ started: boolean;
}
- export interface ViewOptions {
+ interface ViewOptions {
model?: Backbone.Model;
collection?: Backbone.Collection;
el?: any;
@@ -256,7 +257,7 @@ declare module Backbone {
attributes?: any[];
}
- export class View extends Events {
+ class View extends Events {
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
@@ -267,7 +268,7 @@ declare module Backbone {
collection: Collection;
template: (data?: any) => string;
make(tagName: string, attrs?, opts?): View;
- setElement(element: HTMLElement, delegate?: bool);
+ setElement(element: HTMLElement, delegate?: boolean);
id: string;
className: string;
tagName: string;
@@ -288,10 +289,16 @@ declare module Backbone {
// SYNC
function sync(method, model, options?: JQueryAjaxSettings);
- var emulateHTTP: bool;
- var emulateJSONBackbone: bool;
+ var emulateHTTP: boolean;
+ var emulateJSONBackbone: boolean;
// Utility
- function noConflict(): Backbone;
+
+ // 0.9 cannot return modules anymore, and "typeof " is not compiling for some reason
+ // returning "any" until this is fixed
+
+ //function noConflict(): typeof Backbone;
+ function noConflict(): any;
+
function setDomLibrary(jQueryNew);
}
diff --git a/chai-jquery/chai-jquery-tests.ts b/chai-jquery/chai-jquery-tests.ts
index fbd05480e..97ed7a36a 100644
--- a/chai-jquery/chai-jquery-tests.ts
+++ b/chai-jquery/chai-jquery-tests.ts
@@ -1,5 +1,5 @@
-///
-///
+///
+///
declare var $;
var expect = chai.expect;
diff --git a/chai/chai-assert-test.ts b/chai/chai-assert-tests.ts
similarity index 99%
rename from chai/chai-assert-test.ts
rename to chai/chai-assert-tests.ts
index b4a5a15be..19429b4c9 100644
--- a/chai/chai-assert-test.ts
+++ b/chai/chai-assert-tests.ts
@@ -330,7 +330,7 @@ suite('assert', function () {
test('isArray', function () {
assert.isArray([]);
- assert.isArray(new Array);
+ assert.isArray(new Array());
err(function () {
assert.isArray({});
@@ -345,7 +345,7 @@ suite('assert', function () {
}, "expected [] not to be an array");
err(function () {
- assert.isNotArray(new Array);
+ assert.isNotArray(new Array());
}, "expected [] not to be an array");
});
diff --git a/chai/chai-assert.d.ts b/chai/chai-assert.d.ts
index b31b7bde5..ab1a23d14 100644
--- a/chai/chai-assert.d.ts
+++ b/chai/chai-assert.d.ts
@@ -107,7 +107,7 @@ declare module chai
ifError(val:any, msg?:string);
}
//node module
- declare var assert:Assert;
+ var assert:Assert;
}
//browser global
declare var assert:chai.Assert;
\ No newline at end of file
diff --git a/chai/chai.d.ts b/chai/chai.d.ts
index df9e12382..6a9010322 100644
--- a/chai/chai.d.ts
+++ b/chai/chai.d.ts
@@ -33,9 +33,9 @@ declare module chai {
(expected: RegExp, message?: string);
}
- interface TypeComparison {
+ interface TypeComparison {
(type: string, message?: string): bool;
- instanceof(type: Object, ): bool;
+ instanceof(type: Object): bool;
}
interface NumericComparison {
@@ -116,7 +116,6 @@ declare module chai {
to: To;
}
- var expect : {
- (target: any): ExpectMatchers;
- }
-}
\ No newline at end of file
+ function expect(target: any): chai.ExpectMatchers;
+}
+
diff --git a/cheerio/cheerio-test.ts b/cheerio/cheerio-tests.ts
similarity index 93%
rename from cheerio/cheerio-test.ts
rename to cheerio/cheerio-tests.ts
index b2a5d84f3..00cc95ee8 100644
--- a/cheerio/cheerio-test.ts
+++ b/cheerio/cheerio-tests.ts
@@ -1,65 +1,65 @@
-///
-
-import cheerio = module("cheerio");
-
-var $ = cheerio.load("");
-var $el = $('selector');
-var $multiEl = $('seletor', 'selector', 'selector');
-
-$el.addClass("class").addClass("test");
-$el.hasClass("test");
-$el.removeClass("class").removeClass("test");
-
-$el.attr('class');
-$el.attr('class', 'test');
-$el.removeAttr("class").removeAttr("test");
-
-$el.find("ul").find("> li");
-
-$el.parent().parent();
-$el.next().next();
-$el.prev().prev();
-$el.siblings().siblings();
-
-$el.children().children();
-$el.children("li").children("a");
-
-$el.children().each((index, element) => {
- $(element).find('t');
-});
-
-$el.children().map((index, element) => {
- return $(element).find('t');
-});
-
-$el.children().filter((index) => {
- return $el.children().eq(index).find('t');
-});
-
-$el.filter('span').filter('li');
-
-$el.first().last().find('t');
-
-$('div').eq(0).find('b');
-
-$('#id').append("test html", "other html").find('a');
-$('#id').prepend("test html", "other html").find('a');
-$('#id').after("test html", "other html").find('a');
-$('#id').before("test html", "other html").find('a');
-
-$el.remove('div').remove('a');
-
-$('#id').replaceWith('some html').parent();
-$('#id').empty().parent();
-
-$el.html();
-$el.html("").find('div');
-
-$el.text();
-$el.text('some text');
-
-$el.toArray();
-$el.clone().find('a').parent();
-$el.root().find('a');
-
-$el.dom();
+///
+
+import cheerio = module("cheerio");
+
+var $ = cheerio.load("");
+var $el = $('selector');
+var $multiEl = $('seletor', 'selector', 'selector');
+
+$el.addClass("class").addClass("test");
+$el.hasClass("test");
+$el.removeClass("class").removeClass("test");
+
+$el.attr('class');
+$el.attr('class', 'test');
+$el.removeAttr("class").removeAttr("test");
+
+$el.find("ul").find("> li");
+
+$el.parent().parent();
+$el.next().next();
+$el.prev().prev();
+$el.siblings().siblings();
+
+$el.children().children();
+$el.children("li").children("a");
+
+$el.children().each((index, element) => {
+ return $(element).find('t');
+});
+
+$el.children().map((index, element) => {
+ return $(element).find('t');
+});
+
+$el.children().filter((index) => {
+ return $el.children().eq(index).find('t');
+});
+
+$el.filter('span').filter('li');
+
+$el.first().last().find('t');
+
+$('div').eq(0).find('b');
+
+$('#id').append("test html", "other html").find('a');
+$('#id').prepend("test html", "other html").find('a');
+$('#id').after("test html", "other html").find('a');
+$('#id').before("test html", "other html").find('a');
+
+$el.remove('div').remove('a');
+
+$('#id').replaceWith('some html').parent();
+$('#id').empty().parent();
+
+$el.html();
+$el.html("").find('div');
+
+$el.text();
+$el.text('some text');
+
+$el.toArray();
+$el.clone().find('a').parent();
+$el.root().find('a');
+
+$el.dom();
diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts
index cbf9e12da..8bb7307c0 100644
--- a/cheerio/cheerio.d.ts
+++ b/cheerio/cheerio.d.ts
@@ -4,7 +4,7 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare interface Cheerio {
+interface Cheerio {
addClass(classNames: string): Cheerio;
hasClass(className: string): bool;
@@ -65,13 +65,13 @@ declare interface Cheerio {
}
-declare interface CheerioOptionsInterface {
+interface CheerioOptionsInterface {
ignoreWhitespace?: bool;
xmlMode?: bool;
lowerCaseTags?: bool;
}
-declare interface CheerioStatic {
+interface CheerioStatic {
(...selectors: any[]): Cheerio;
(): Cheerio;
}
diff --git a/colors/colors.test.ts b/colors/colors-test.ts
similarity index 100%
rename from colors/colors.test.ts
rename to colors/colors-test.ts
diff --git a/colors/colors.d.ts b/colors/colors.d.ts
index 99388e69d..c87112d7c 100644
--- a/colors/colors.d.ts
+++ b/colors/colors.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Bart van der Schoor
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare interface String {
+interface String {
bold:string;
italic:string;
underline:string;
diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts
index 1581cdb71..872432f34 100644
--- a/d3/d3-tests.ts
+++ b/d3/d3-tests.ts
@@ -48,7 +48,7 @@ function testPieChart() {
}
//Example from http://bl.ocks.org/3887051
-function groupedBarChart() => {
+function groupedBarChart() {
var margin = { top: 20, right: 20, bottom: 30, left: 40 },
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
@@ -105,7 +105,7 @@ function groupedBarChart() => {
.style("text-anchor", "end")
.text("Population");
- var state = svg.selectAll(".state")
+ var state = svg.selectAll(".state")
.data(data)
.enter().append("g")
.attr("class", "g")
@@ -487,7 +487,7 @@ function callenderView() {
}
// example from http://bl.ocks.org/3883245
-function lineChart {
+function lineChart() {
var margin = { top: 20, right: 20, bottom: 30, left: 50 },
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
@@ -550,7 +550,7 @@ function lineChart {
}
//example from http://bl.ocks.org/3884914
-function bivariateAreaChart {
+function bivariateAreaChart() {
var margin = { top: 20, right: 20, bottom: 30, left: 50 },
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
@@ -590,7 +590,7 @@ function bivariateAreaChart {
});
x.domain(d3.extent(data, function (d) { return d.date; }));
- y.domain([d3.min(data, function (d) { return d.low; }), d3.max(data, function (d) { return d.high; })]);
+ y.domain([d3.min(data, function (d) { return d.low; }), d3.max(data, function (d) { return d.high; })]);
svg.append("path")
.datum(data)
@@ -610,12 +610,12 @@ function bivariateAreaChart {
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
- .text("Temperature (ºF)");
+ .text("Temperature (ºF)");
});
}
//Example from http://bl.ocks.org/mbostock/1557377
-function dragMultiples {
+function dragMultiples() {
var width = 238,
height = 123,
radius = 20;
@@ -644,7 +644,7 @@ function dragMultiples {
}
//Example from http://bl.ocks.org/mbostock/3892919
-function panAndZoom {
+function panAndZoom() {
var margin = { top: 20, right: 20, bottom: 30, left: 40 },
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
@@ -729,3 +729,1331 @@ function chainedTransitions() {
};
}
}
+
+//Example from http://bl.ocks.org/mbostock/4062085
+function populationPyramid() {
+ var margin = { top: 20, right: 40, bottom: 30, left: 20 },
+ width = 960 - margin.left - margin.right,
+ height = 500 - margin.top - margin.bottom,
+ barWidth = Math.floor(width / 19) - 1;
+
+ var x = d3.scale.linear()
+ .range([barWidth / 2, width - barWidth / 2]);
+
+ var y = d3.scale.linear()
+ .range([height, 0]);
+
+ var yAxis = d3.svg.axis()
+ .scale(y)
+ .orient("right")
+ .tickSize(-width)
+ .tickFormat(function (d) { return Math.round(d / 1e6) + "M"; } );
+
+ // An SVG element with a bottom-right origin.
+ var svg = d3.select("body").append("svg")
+ .attr("width", width + margin.left + margin.right)
+ .attr("height", height + margin.top + margin.bottom)
+ .append("g")
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+ // A sliding container to hold the bars by birthyear.
+ var birthyears = svg.append("g")
+ .attr("class", "birthyears");
+
+ // A label for the current year.
+ var title = svg.append("text")
+ .attr("class", "title")
+ .attr("dy", ".71em")
+ .text(2000);
+
+ d3.csv("population.csv", function (error, data) {
+
+ // Convert strings to numbers.
+ data.forEach(function (d) {
+ d.people = +d.people;
+ d.year = +d.year;
+ d.age = +d.age;
+ } );
+
+ // Compute the extent of the data set in age and years.
+ var age1 = d3.max(data, function (d) { return d.age; } ),
+ year0 = d3.min(data, function (d) { return d.year; } ),
+ year1 = d3.max(data, function (d) { return d.year; } ),
+ year = year1;
+
+ // Update the scale domains.
+ x.domain([year1 - age1, year1]);
+ y.domain([0, d3.max(data, function (d) { return d.people; } )]);
+
+ // Produce a map from year and birthyear to [male, female].
+ data = d3.nest()
+ .key(function (d) { return d.year; } )
+ .key(function (d) { return d.year - d.age; } )
+ .rollup(function (v) { return v.map(function (d) { return d.people; } ); } )
+ .map(data);
+
+ // Add an axis to show the population values.
+ svg.append("g")
+ .attr("class", "y axis")
+ .attr("transform", "translate(" + width + ",0)")
+ .call(yAxis)
+ .selectAll("g")
+ .filter(function (value) { return !value; } )
+ .classed("zero", true);
+
+ // Add labeled rects for each birthyear (so that no enter or exit is required).
+ var birthyear = birthyears.selectAll(".birthyear")
+ .data(d3.range(year0 - age1, year1 + 1, 5))
+ .enter().append("g")
+ .attr("class", "birthyear")
+ .attr("transform", function (birthyear) { return "translate(" + x(birthyear) + ",0)"; } );
+
+ birthyear.selectAll("rect")
+ .data(function (birthyear) { return data[year][birthyear] || [0, 0]; } )
+ .enter().append("rect")
+ .attr("x", -barWidth / 2)
+ .attr("width", barWidth)
+ .attr("y", y)
+ .attr("height", function (value) { return height - y(value); } );
+
+ // Add labels to show birthyear.
+ birthyear.append("text")
+ .attr("y", height - 4)
+ .text(function (birthyear) { return birthyear; } );
+
+ // Add labels to show age (separate; not animated).
+ svg.selectAll(".age")
+ .data(d3.range(0, age1 + 1, 5))
+ .enter().append("text")
+ .attr("class", "age")
+ .attr("x", function (age) { return x(year - age); } )
+ .attr("y", height + 4)
+ .attr("dy", ".71em")
+ .text(function (age) { return age; } );
+
+ // Allow the arrow keys to change the displayed year.
+ window.focus();
+ d3.select(window).on("keydown", function () {
+ switch (d3.event.keyCode) {
+ case 37: year = Math.max(year0, year - 10); break;
+ case 39: year = Math.min(year1, year + 10); break;
+ }
+ update();
+ } );
+
+ function update() {
+ if (!(year in data)) return;
+ title.text(year);
+
+ birthyears.transition()
+ .duration(750)
+ .attr("transform", "translate(" + (x(year1) - x(year)) + ",0)");
+
+ birthyear.selectAll("rect")
+ .data(function (birthyear) { return data[year][birthyear] || [0, 0]; } )
+ .transition()
+ .duration(750)
+ .attr("y", y)
+ .attr("height", function (value) { return height - y(value); } );
+ }
+ } );
+}
+
+//Example from http://bl.ocks.org/MoritzStefaner/1377729
+function forcedBasedLabelPlacemant() {
+ var w = 960, h = 500;
+
+ var labelDistance = 0;
+
+ var vis = d3.select("body").append("svg:svg").attr("width", w).attr("height", h);
+
+ var nodes = [];
+ var labelAnchors = [];
+ var labelAnchorLinks = [];
+ var links = [];
+
+ for (var i = 0; i < 30; i++) {
+ var nodeLabel = {
+ label: "node " + i
+ };
+ nodes.push(nodeLabel);
+ labelAnchors.push({
+ node: nodeLabel
+ });
+ labelAnchors.push({
+ node: nodeLabel
+ });
+ };
+
+ for (var i = 0; i < nodes.length; i++) {
+ for (var j = 0; j < i; j++) {
+ if (Math.random() > .95)
+ links.push({
+ source: i,
+ target: j,
+ weight: Math.random()
+ });
+ }
+ labelAnchorLinks.push({
+ source: i * 2,
+ target: i * 2 + 1,
+ weight: 1
+ });
+ };
+
+ var force = d3.layout.force().size([w, h]).nodes(nodes).links(links).gravity(1).linkDistance(50).charge(-3000).linkStrength(function (x) {
+ return x.weight * 10
+ } );
+
+
+ force.start();
+
+ var force2 = d3.layout.force().nodes(labelAnchors).links(labelAnchorLinks).gravity(0).linkDistance(0).linkStrength(8).charge(-100).size([w, h]);
+ force2.start();
+
+ var link = vis.selectAll("line.link").data(links).enter().append("svg:line").attr("class", "link").style("stroke", "#CCC");
+
+ var node = vis.selectAll("g.node").data(force.nodes()).enter().append("svg:g").attr("class", "node");
+ node.append("svg:circle").attr("r", 5).style("fill", "#555").style("stroke", "#FFF").style("stroke-width", 3);
+ node.call(force.drag);
+
+
+ var anchorLink = vis.selectAll("line.anchorLink").data(labelAnchorLinks)//.enter().append("svg:line").attr("class", "anchorLink").style("stroke", "#999");
+
+ var anchorNode = vis.selectAll("g.anchorNode").data(force2.nodes()).enter().append("svg:g").attr("class", "anchorNode");
+ anchorNode.append("svg:circle").attr("r", 0).style("fill", "#FFF");
+ anchorNode.append("svg:text").text(function (d, i) {
+ return i % 2 == 0 ? "" : d.node.label
+ } ).style("fill", "#555").style("font-family", "Arial").style("font-size", 12);
+
+ var updateLink = function () {
+ this.attr("x1", function (d) {
+ return d.source.x;
+ } ).attr("y1", function (d) {
+ return d.source.y;
+ } ).attr("x2", function (d) {
+ return d.target.x;
+ } ).attr("y2", function (d) {
+ return d.target.y;
+ } );
+
+ }
+
+ var updateNode = function () {
+ this.attr("transform", function (d) {
+ return "translate(" + d.x + "," + d.y + ")";
+ } );
+
+ }
+
+ force.on("tick", function () {
+
+ force2.start();
+
+ node.call(updateNode);
+
+ anchorNode.each(function (d, i) {
+ if (i % 2 == 0) {
+ d.x = d.node.x;
+ d.y = d.node.y;
+ } else {
+ var b = this.childNodes[1].getBBox();
+
+ var diffX = d.x - d.node.x;
+ var diffY = d.y - d.node.y;
+
+ var dist = Math.sqrt(diffX * diffX + diffY * diffY);
+
+ var shiftX = b.width * (diffX - dist) / (dist * 2);
+ shiftX = Math.max(-b.width, Math.min(0, shiftX));
+ var shiftY = 5;
+ this.childNodes[1].setAttribute("transform", "translate(" + shiftX + "," + shiftY + ")");
+ }
+ } );
+
+
+ anchorNode.call(updateNode);
+
+ link.call(updateLink);
+ anchorLink.call(updateLink);
+
+ } );
+}
+
+//Example from http://bl.ocks.org/mbostock/1125997
+function forceCollapsable() {
+ var w = 1280,
+ h = 800,
+ node,
+ link,
+ root;
+
+ var force = d3.layout.force()
+ .on("tick", tick)
+ .charge(function (d) { return d._children ? -d.size / 100 : -30; } )
+ .linkDistance(function (d) { return d.target._children ? 80 : 30; } )
+ .size([w, h - 160]);
+
+ var vis = d3.select("body").append("svg:svg")
+ .attr("width", w)
+ .attr("height", h);
+
+ d3.json("flare.json", function (json) {
+ root = json;
+ root.fixed = true;
+ root.x = w / 2;
+ root.y = h / 2 - 80;
+ update();
+ } );
+
+ function update() {
+ var nodes = flatten(root),
+ links = d3.layout.tree().links(nodes);
+
+ // Restart the force layout.
+ force
+ .nodes(nodes)
+ .links(links)
+ .start();
+
+ // Update the links…
+ link = vis.selectAll("line.link")
+ .data(links, function (d) { return d.target.id; } );
+
+ // Enter any new links.
+ link.enter().insert("svg:line", ".node")
+ .attr("class", "link")
+ .attr("x1", function (d) { return d.source.x; } )
+ .attr("y1", function (d) { return d.source.y; } )
+ .attr("x2", function (d) { return d.target.x; } )
+ .attr("y2", function (d) { return d.target.y; } );
+
+ // Exit any old links.
+ link.exit().remove();
+
+ // Update the nodes…
+ node = vis.selectAll("circle.node")
+ .data(nodes, function (d) { return d.id; } )
+ .style("fill", color);
+
+ node.transition()
+ .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } );
+
+ // Enter any new nodes.
+ node.enter().append("svg:circle")
+ .attr("class", "node")
+ .attr("cx", function (d) { return d.x; } )
+ .attr("cy", function (d) { return d.y; } )
+ .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } )
+ .style("fill", color)
+ .on("click", click)
+ .call(force.drag);
+
+ // Exit any old nodes.
+ node.exit().remove();
+ }
+
+ function tick() {
+ link.attr("x1", function (d) { return d.source.x; } )
+ .attr("y1", function (d) { return d.source.y; } )
+ .attr("x2", function (d) { return d.target.x; } )
+ .attr("y2", function (d) { return d.target.y; } );
+
+ node.attr("cx", function (d) { return d.x; } )
+ .attr("cy", function (d) { return d.y; } );
+ }
+
+ // Color leaf nodes orange, and packages white or blue.
+ function color(d) {
+ return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c";
+ }
+
+ // Toggle children on click.
+ function click(d) {
+ if (d.children) {
+ d._children = d.children;
+ d.children = null;
+ } else {
+ d.children = d._children;
+ d._children = null;
+ }
+ update();
+ }
+
+ // Returns a list of all nodes under the root.
+ function flatten(root) {
+ var nodes = [], i = 0;
+
+ function recurse(node) {
+ if (node.children) node.size = node.children.reduce(function (p, v) { return p + recurse(v); } , 0);
+ if (!node.id) node.id = ++i;
+ nodes.push(node);
+ return node.size;
+ }
+
+ root.size = recurse(root);
+ return nodes;
+ }
+}
+
+//Example from http://bl.ocks.org/mbostock/3757110
+function azimuthalEquidistant() {
+ var width = 960,
+ height = 960;
+ var topojson: any;
+
+ var projection = d3.geo.azimuthalEquidistant()
+ .scale(150)
+ .translate([width / 2, height / 2])
+ .clipAngle(180 - 1e-3)
+ .precision(.1);
+
+ var path = d3.geo.path()
+ .projection(projection);
+
+ var graticule = d3.geo.graticule();
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height);
+
+ svg.append("defs").append("path")
+ .datum({ type: "Sphere" })
+ .attr("id", "sphere")
+ .attr("d", path);
+
+ svg.append("use")
+ .attr("class", "stroke")
+ .attr("xlink:href", "#sphere");
+
+ svg.append("use")
+ .attr("class", "fill")
+ .attr("xlink:href", "#sphere");
+
+ svg.append("path")
+ .datum(graticule)
+ .attr("class", "graticule")
+ .attr("d", path);
+
+ d3.json("/mbostock/raw/4090846/world-50m.json", function (error, world) {
+ svg.insert("path", ".graticule")
+ .datum(topojson.feature(world, world.objects.land))
+ .attr("class", "land")
+ .attr("d", path);
+
+ svg.insert("path", ".graticule")
+ .datum(topojson.mesh(world, world.objects.countries, function (a, b) { return a !== b; } ))
+ .attr("class", "boundary")
+ .attr("d", path);
+ } );
+
+ d3.select(self.frameElement).style("height", height + "px");
+}
+
+//Example from http://bl.ocks.org/mbostock/4060366
+function voroniTesselation() {
+ var width = 960,
+ height = 500;
+
+ var vertices = >d3.range(100).map(function (d) {
+ return [Math.random() * width, Math.random() * height];
+ } );
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height)
+ .attr("class", "PiYG")
+ .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } );
+
+ var path = svg.append("g").selectAll("path");
+
+ svg.selectAll("circle")
+ .data(vertices.slice(1))
+ .enter().append("circle")
+ .attr("transform", function (d) { return "translate(" + d + ")"; } )
+ .attr("r", 2);
+
+ redraw();
+
+ function redraw() {
+ path = path.data(d3.geom.voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String);
+ path.exit().remove();
+ path.enter().append("path").attr("class", function (d, i) { return "q" + (i % 9) + "-9"; } ).attr("d", String);
+ path.order();
+ }
+}
+
+//Example from http://bl.ocks.org/mbostock/4341156
+function delaunayTesselation() {
+ var width = 960,
+ height = 500;
+
+ var vertices = >d3.range(100).map(function (d) {
+ return [Math.random() * width, Math.random() * height];
+ } );
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height)
+ .attr("class", "PiYG")
+ .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } );
+
+ var path = svg.append("g").selectAll("path");
+
+ svg.selectAll("circle")
+ .data(vertices.slice(1))
+ .enter().append("circle")
+ .attr("transform", function (d) { return "translate(" + d + ")"; } )
+ .attr("r", 2);
+
+ redraw();
+
+ function redraw() {
+ path = path.data(d3.geom.delaunay(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String);
+ path.exit().remove();
+ path.enter().append("path").attr("class", function (d, i) { return "q" + (i % 9) + "-9"; } ).attr("d", String);
+ }
+}
+
+//Example from http://bl.ocks.org/mbostock/4343214
+function quadtree() {
+ var width = 960,
+ height = 500;
+
+ var data = d3.range(5000).map(function () {
+ return { x: Math.random() * width, y: Math.random() * width };
+ } );
+
+ var quadtree = d3.geom.quadtree(data, -1, -1, width + 1, height + 1);
+
+ var brush = d3.svg.brush()
+ .x(d3.scale.identity().domain([0, width]))
+ .y(d3.scale.identity().domain([0, height]))
+ .on("brush", brushed)
+ .extent([[100, 100], [200, 200]]);
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height);
+
+ svg.selectAll(".node")
+ .data(nodes(quadtree))
+ .enter().append("rect")
+ .attr("class", "node")
+ .attr("x", function (d) { return d.x; } )
+ .attr("y", function (d) { return d.y; } )
+ .attr("width", function (d) { return d.width; } )
+ .attr("height", function (d) { return d.height; } );
+
+ var point = svg.selectAll(".point")
+ .data(data)
+ .enter().append("circle")
+ .attr("class", "point")
+ .attr("cx", function (d) { return d.x; } )
+ .attr("cy", function (d) { return d.y; } )
+ .attr("r", 4);
+
+ svg.append("g")
+ .attr("class", "brush")
+ .call(brush);
+
+ brushed();
+
+ function brushed() {
+ var extent = brush.extent();
+ point.each(function (d) { d.scanned = d.selected = false; } );
+ search(quadtree, extent[0][0], extent[0][1], extent[1][0], extent[1][1]);
+ point.classed("scanned", function (d) { return d.scanned; } );
+ point.classed("selected", function (d) { return d.selected; } );
+ }
+
+ // Collapse the quadtree into an array of rectangles.
+ function nodes(quadtree) {
+ var nodes = [];
+ quadtree.visit(function (node, x1, y1, x2, y2) {
+ nodes.push({ x: x1, y: y1, width: x2 - x1, height: y2 - y1 });
+ } );
+ return nodes;
+ }
+
+ // Find the nodes within the specified rectangle.
+ function search(quadtree, x0, y0, x3, y3) {
+ quadtree.visit(function (node, x1, y1, x2, y2) {
+ var p = node.point;
+ if (p) {
+ p.scanned = true;
+ p.selected = (p.x >= x0) && (p.x < x3) && (p.y >= y0) && (p.y < y3);
+ }
+ return x1 >= x3 || y1 >= y3 || x2 < x0 || y2 < y0;
+ } );
+ }
+}
+
+//Example from http://bl.ocks.org/mbostock/4341699
+function convexHull() {
+ var width = 960,
+ height = 500;
+
+ var randomX = d3.random.normal(width / 2, 60),
+ randomY = d3.random.normal(height / 2, 60),
+ vertices = d3.range(100).map(function () { return [randomX(), randomY()]; } );
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height)
+ .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } )
+ .on("click", function () { vertices.push(d3.mouse(this)); redraw(); } );
+
+ svg.append("rect")
+ .attr("width", width)
+ .attr("height", height);
+
+ var hull = svg.append("path")
+ .attr("class", "hull");
+
+ var circle = svg.selectAll("circle");
+
+ redraw();
+
+ function redraw() {
+ hull.datum(d3.geom.hull(vertices)).attr("d", function (d) { return "M" + d.join("L") + "Z"; } );
+ circle = circle.data(vertices);
+ circle.enter().append("circle").attr("r", 3);
+ circle.attr("transform", function (d) { return "translate(" + d + ")"; } );
+ }
+}
+
+// example from http://bl.ocks.org/mbostock/1044242
+function hierarchicalEdgeBundling() {
+ var diameter = 960,
+ radius = diameter / 2,
+ innerRadius = radius - 120;
+
+ var cluster = d3.layout.cluster()
+ .size([360, innerRadius])
+ .sort(null)
+ .value(function (d) { return d.size; } );
+
+ var bundle = d3.layout.bundle();
+
+ var line = d3.svg.line.radial()
+ .interpolate("bundle")
+ .tension(.85)
+ .radius(function (d) { return d.y; } )
+ .angle(function (d) { return d.x / 180 * Math.PI; } );
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", diameter)
+ .attr("height", diameter)
+ .append("g")
+ .attr("transform", "translate(" + radius + "," + radius + ")");
+
+ d3.json("readme-flare-imports.json", function (error, classes) {
+ var nodes = cluster.nodes(packages.root(classes)),
+ links = packages.imports(nodes);
+
+ svg.selectAll(".link")
+ .data(bundle(links))
+ .enter().append("path")
+ .attr("class", "link")
+ .attr("d", line);
+
+ svg.selectAll(".node")
+ .data(nodes.filter(function (n) { return !n.children; } ))
+ .enter().append("g")
+ .attr("class", "node")
+ .attr("transform", function (d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; } )
+ .append("text")
+ .attr("dx", function (d) { return d.x < 180 ? 8 : -8; } )
+ .attr("dy", ".31em")
+ .attr("text-anchor", function (d) { return d.x < 180 ? "start" : "end"; } )
+ .attr("transform", function (d) { return d.x < 180 ? null : "rotate(180)"; } )
+ .text(function (d) { return d.key; } );
+ } );
+
+ d3.select(self.frameElement).style("height", diameter + "px");
+
+ var packages = {
+
+ // Lazily construct the package hierarchy from class names.
+ root: function (classes) {
+ var map = {};
+
+ function find(name, data?) {
+ var node = map[name], i;
+ if (!node) {
+ node = map[name] = data || { name: name, children: [] };
+ if (name.length) {
+ node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
+ node.parent.children.push(node);
+ node.key = name.substring(i + 1);
+ }
+ }
+ return node;
+ }
+
+ classes.forEach(function (d) {
+ find(d.name, d);
+ } );
+
+ return map[""];
+ } ,
+
+ // Return a list of imports for the given array of nodes.
+ imports: function (nodes) {
+ var map = {},
+ imports = [];
+
+ // Compute a map from name to node.
+ nodes.forEach(function (d) {
+ map[d.name] = d;
+ } );
+
+ // For each import, construct a link from the source to target node.
+ nodes.forEach(function (d) {
+ if (d.imports) d.imports.forEach(function (i) {
+ imports.push({ source: map[d.name], target: map[i] });
+ } );
+ } );
+
+ return imports;
+ }
+ };
+}
+
+// example from http://bl.ocks.org/mbostock/1123639
+function roundedRectangles() {
+ var mouse = [480, 250],
+ count = 0;
+
+ var svg = d3.select("body").append("svg:svg")
+ .attr("width", 960)
+ .attr("height", 500);
+
+ var g = svg.selectAll("g")
+ .data(d3.range(25))
+ .enter().append("svg:g")
+ .attr("transform", "translate(" + mouse + ")");
+
+ g.append("svg:rect")
+ .attr("rx", 6)
+ .attr("ry", 6)
+ .attr("x", -12.5)
+ .attr("y", -12.5)
+ .attr("width", 25)
+ .attr("height", 25)
+ .attr("transform", function (d, i) { return "scale(" + (1 - d / 25) * 20 + ")"; } )
+ .style("fill", d3.scale.category20c());
+
+ g.map(function (d) {
+ return { center: [0, 0], angle: 0 };
+ } );
+
+ svg.on("mousemove", function () {
+ mouse = d3.mouse(this);
+ } );
+
+ d3.timer(function () {
+ count++;
+ g.attr("transform", function (d, i) {
+ d.center[0] += (mouse[0] - d.center[0]) / (i + 5);
+ d.center[1] += (mouse[1] - d.center[1]) / (i + 5);
+ d.angle += Math.sin((count + i) / 10) * 7;
+ return "translate(" + d.center + ")rotate(" + d.angle + ")";
+ } );
+ return true;
+ } );
+}
+
+// example from http://bl.ocks.org/mbostock/4060954
+function streamGraph() {
+ var n = 20, // number of layers
+ m = 200, // number of samples per layer
+ stack = d3.layout.stack().offset("wiggle"),
+ layers0 = stack(d3.range(n).map(function () { return bumpLayer(m); } )),
+ layers1 = stack(d3.range(n).map(function () { return bumpLayer(m); } ));
+
+ var width = 960,
+ height = 500;
+
+ var x = d3.scale.linear()
+ .domain([0, m - 1])
+ .range([0, width]);
+
+ var y = d3.scale.linear()
+ .domain([0, d3.max(layers0.concat(layers1), function (layer) { return d3.max(layer, function (d) { return d.y0 + d.y; } ); } )])
+ .range([height, 0]);
+
+ var color = d3.scale.linear()
+ .range(["#aad", "#556"]);
+
+ var area = d3.svg.area()
+ .x(function (d) { return x(d.x); } )
+ .y0(function (d) { return y(d.y0); } )
+ .y1(function (d) { return y(d.y0 + d.y); } );
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height);
+
+ svg.selectAll("path")
+ .data(layers0)
+ .enter().append("path")
+ .attr("d", area)
+ .style("fill", function () { return color(Math.random()); } );
+
+ function transition() {
+ d3.selectAll("path")
+ .data(function () {
+ var d = layers1;
+ layers1 = layers0;
+ return layers0 = d;
+ } )
+ .transition()
+ .duration(2500)
+ .attr("d", area);
+ }
+
+ // Inspired by Lee Byron's test data generator.
+ function bumpLayer(n) {
+
+ function bump(a) {
+ var x = 1 / (.1 + Math.random()),
+ y = 2 * Math.random() - .5,
+ z = 10 / (.1 + Math.random());
+ for (var i = 0; i < n; i++) {
+ var w = (i / n - y) * z;
+ a[i] += x * Math.exp(-w * w);
+ }
+ }
+
+ var a = [], i;
+ for (i = 0; i < n; ++i) a[i] = 0;
+ for (i = 0; i < 5; ++i) bump(a);
+ return a.map(function (d, i) { return { x: i, y: Math.max(0, d) }; } );
+ }
+}
+
+// example from http://mbostock.github.io/d3/talk/20111116/force-collapsible.html
+function forceCollapsable2() {
+ var w = 1280,
+ h = 800,
+ node,
+ link,
+ root;
+
+ var force = d3.layout.force()
+ .on("tick", tick)
+ .charge(function (d) { return d._children ? -d.size / 100 : -30; } )
+ .linkDistance(function (d) { return d.target._children ? 80 : 30; } )
+ .size([w, h - 160]);
+
+ var vis = d3.select("body").append("svg:svg")
+ .attr("width", w)
+ .attr("height", h);
+
+ d3.json("flare.json", function (json) {
+ root = json;
+ root.fixed = true;
+ root.x = w / 2;
+ root.y = h / 2 - 80;
+ update();
+ } );
+
+ function update() {
+ var nodes = flatten(root),
+ links = d3.layout.tree().links(nodes);
+
+ // Restart the force layout.
+ force
+ .nodes(nodes)
+ .links(links)
+ .start();
+
+ // Update the links…
+ link = vis.selectAll("line.link")
+ .data(links, function (d) { return d.target.id; } );
+
+ // Enter any new links.
+ link.enter().insert("svg:line", ".node")
+ .attr("class", "link")
+ .attr("x1", function (d) { return d.source.x; } )
+ .attr("y1", function (d) { return d.source.y; } )
+ .attr("x2", function (d) { return d.target.x; } )
+ .attr("y2", function (d) { return d.target.y; } );
+
+ // Exit any old links.
+ link.exit().remove();
+
+ // Update the nodes…
+ node = vis.selectAll("circle.node")
+ .data(nodes, function (d) { return d.id; } )
+ .style("fill", color);
+
+ node.transition()
+ .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } );
+
+ // Enter any new nodes.
+ node.enter().append("svg:circle")
+ .attr("class", "node")
+ .attr("cx", function (d) { return d.x; } )
+ .attr("cy", function (d) { return d.y; } )
+ .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } )
+ .style("fill", color)
+ .on("click", click)
+ .call(force.drag);
+
+ // Exit any old nodes.
+ node.exit().remove();
+ }
+
+ function tick() {
+ link.attr("x1", function (d) { return d.source.x; } )
+ .attr("y1", function (d) { return d.source.y; } )
+ .attr("x2", function (d) { return d.target.x; } )
+ .attr("y2", function (d) { return d.target.y; } );
+
+ node.attr("cx", function (d) { return d.x; } )
+ .attr("cy", function (d) { return d.y; } );
+ }
+
+ // Color leaf nodes orange, and packages white or blue.
+ function color(d) {
+ return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c";
+ }
+
+ // Toggle children on click.
+ function click(d) {
+ if (d.children) {
+ d._children = d.children;
+ d.children = null;
+ } else {
+ d.children = d._children;
+ d._children = null;
+ }
+ update();
+ }
+
+ // Returns a list of all nodes under the root.
+ function flatten(root) {
+ var nodes = [], i = 0;
+
+ function recurse(node) {
+ if (node.children) node.size = node.children.reduce(function (p, v) { return p + recurse(v); } , 0);
+ if (!node.id) node.id = ++i;
+ nodes.push(node);
+ return node.size;
+ }
+
+ root.size = recurse(root);
+ return nodes;
+ }
+}
+
+//exapmle from http://bl.ocks.org/mbostock/4062006
+function chordDiagram() {
+ var matrix = [
+ [11975, 5871, 8916, 2868],
+ [1951, 10048, 2060, 6171],
+ [8010, 16145, 8090, 8045],
+ [1013, 990, 940, 6907]
+ ];
+
+ var chord = d3.layout.chord()
+ .padding(.05)
+ .sortSubgroups(d3.descending)
+ .matrix(matrix);
+
+ var width = 960,
+ height = 500,
+ innerRadius = Math.min(width, height) * .41,
+ outerRadius = innerRadius * 1.1;
+
+ var fill = d3.scale.ordinal()
+ .domain(d3.range(4))
+ .range(["#000000", "#FFDD89", "#957244", "#F26223"]);
+
+ var svg = d3.select("body").append("svg")
+ .attr("width", width)
+ .attr("height", height)
+ .append("g")
+ .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
+
+ svg.append("g").selectAll("path")
+ .data(chord.groups)
+ .enter().append("path")
+ .style("fill", function (d) { return fill(d.index); } )
+ .style("stroke", function (d) { return fill(d.index); } )
+ .attr("d", d3.svg.arc().innerRadius(innerRadius).outerRadius(outerRadius))
+ .on("mouseover", fade(.1))
+ .on("mouseout", fade(1));
+
+ var ticks = svg.append("g").selectAll("g")
+ .data(chord.groups)
+ .enter().append("g").selectAll("g")
+ .data(groupTicks)
+ .enter().append("g")
+ .attr("transform", function (d) {
+ return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")"
+ + "translate(" + outerRadius + ",0)";
+ } );
+
+ ticks.append("line")
+ .attr("x1", 1)
+ .attr("y1", 0)
+ .attr("x2", 5)
+ .attr("y2", 0)
+ .style("stroke", "#000");
+
+ ticks.append("text")
+ .attr("x", 8)
+ .attr("dy", ".35em")
+ .attr("transform", function (d) { return d.angle > Math.PI ? "rotate(180)translate(-16)" : null; } )
+ .style("text-anchor", function (d) { return d.angle > Math.PI ? "end" : null; } )
+ .text(function (d) { return d.label; } );
+
+ svg.append("g")
+ .attr("class", "chord")
+ .selectAll("path")
+ .data(chord.chords)
+ .enter().append("path")
+ .attr("d", d3.svg.chord().radius(innerRadius))
+ .style("fill", function (d) { return fill(d.target.index); } )
+ .style("opacity", 1);
+
+ // Returns an array of tick angles and labels, given a group.
+ function groupTicks(d) {
+ var k = (d.endAngle - d.startAngle) / d.value;
+ return d3.range(0, d.value, 1000).map(function (v, i) {
+ return {
+ angle: v * k + d.startAngle,
+ label: i % 5 ? null : v / 1000 + "k"
+ };
+ } );
+ }
+
+ // Returns an event handler for fading a given chord group.
+ function fade(opacity) {
+ return function (g, i) {
+ svg.selectAll(".chord path")
+ .filter(function (d) { return d.source.index != i && d.target.index != i; } )
+ .transition()
+ .style("opacity", opacity);
+ };
+ }
+}
+
+//example from http://mbostock.github.io/d3/talk/20111116/iris-parallel.html
+function irisParallel() {
+ var species = ["setosa", "versicolor", "virginica"],
+ traits = ["sepal length", "petal length", "sepal width", "petal width"];
+
+ var m = [80, 160, 200, 160],
+ w = 1280 - m[1] - m[3],
+ h = 800 - m[0] - m[2];
+
+ var x = d3.scale.ordinal().domain(traits).rangePoints([0, w]),
+ y = {};
+
+ var line = d3.svg.line(),
+ axis = d3.svg.axis().orient("left"),
+ foreground;
+
+ var svg = d3.select("body").append("svg:svg")
+ .attr("width", w + m[1] + m[3])
+ .attr("height", h + m[0] + m[2])
+ .append("svg:g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
+
+ d3.csv("iris.csv", function (flowers) {
+
+ // Create a scale and brush for each trait.
+ traits.forEach(function (d) {
+ // Coerce values to numbers.
+ flowers.forEach(function (p) { p[d] = +p[d]; } );
+
+ y[d] = d3.scale.linear()
+ .domain(d3.extent(flowers, function (p) { return p[d]; } ))
+ .range([h, 0]);
+
+ y[d].brush = d3.svg.brush()
+ .y(y[d])
+ .on("brush", brush);
+ } );
+
+ // Add a legend.
+ var legend = svg.selectAll("g.legend")
+ .data(species)
+ .enter().append("svg:g")
+ .attr("class", "legend")
+ .attr("transform", function (d, i) { return "translate(0," + (i * 20 + 584) + ")"; } );
+
+ legend.append("svg:line")
+ .attr("class", String)
+ .attr("x2", 8);
+
+ legend.append("svg:text")
+ .attr("x", 12)
+ .attr("dy", ".31em")
+ .text(function (d) { return "Iris " + d; } );
+
+ // Add foreground lines.
+ foreground = svg.append("svg:g")
+ .attr("class", "foreground")
+ .selectAll("path")
+ .data(flowers)
+ .enter().append("svg:path")
+ .attr("d", path)
+ .attr("class", function (d) { return d.species; } );
+
+ // Add a group element for each trait.
+ var g = svg.selectAll(".trait")
+ .data(traits)
+ .enter().append("svg:g")
+ .attr("class", "trait")
+ .attr("transform", function (d) { return "translate(" + x(d) + ")"; } )
+ .call(d3.behavior.drag()
+ .origin(function (d) { return { x: x(d) }; } )
+ .on("dragstart", dragstart)
+ .on("drag", drag)
+ .on("dragend", dragend));
+
+ // Add an axis and title.
+ g.append("svg:g")
+ .attr("class", "axis")
+ .each(function (d) { d3.select(this).call(axis.scale(y[d])); } )
+ .append("svg:text")
+ .attr("text-anchor", "middle")
+ .attr("y", -9)
+ .text(String);
+
+ // Add a brush for each axis.
+ g.append("svg:g")
+ .attr("class", "brush")
+ .each(function (d) { d3.select(this).call(y[d].brush); } )
+ .selectAll("rect")
+ .attr("x", -8)
+ .attr("width", 16);
+
+ function dragstart(d, i?) {
+ i = traits.indexOf(d);
+ }
+
+ function drag(d, i?) {
+ x.range()[i] = d3.event.x;
+ traits.sort(function (a, b) { return x(a) - x(b); } );
+ g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } );
+ foreground.attr("d", path);
+ }
+
+ function dragend(d) {
+ x.domain(traits).rangePoints([0, w]);
+ var t = d3.transition().duration(500);
+ t.selectAll(".trait").attr("transform", function (d) { return "translate(" + x(d) + ")"; } );
+ t.selectAll(".foreground path").attr("d", path);
+ }
+ } );
+
+ // Returns the path for a given data point.
+ function path(d) {
+ return line(traits.map(function (p) { return [x(p), y[p](d[p])]; } ));
+ }
+
+ // Handles a brush event, toggling the display of foreground lines.
+ function brush() {
+ var actives = traits.filter(function (p) { return !y[p].brush.empty(); } ),
+ extents = actives.map(function (p) { return y[p].brush.extent(); } );
+ foreground.classed("fade", function (d) {
+ return !actives.every(function (p, i) {
+ return extents[i][0] <= d[p] && d[p] <= extents[i][1];
+ } );
+ } );
+ }
+}
+
+//example from
+function healthAndWealth() {
+ // Various accessors that specify the four dimensions of data to visualize.
+ function x(d) { return d.income; }
+ function y(d) { return d.lifeExpectancy; }
+ function radius(d) { return d.population; }
+ function color(d) { return d.region; }
+ function key(d) { return d.name; }
+
+ // Chart dimensions.
+ var margin = { top: 19.5, right: 19.5, bottom: 19.5, left: 39.5 },
+ width = 960 - margin.right,
+ height = 500 - margin.top - margin.bottom;
+
+ // Various scales. These domains make assumptions of data, naturally.
+ var xScale = d3.scale.log().domain([300, 1e5]).range([0, width]),
+ yScale = d3.scale.linear().domain([10, 85]).range([height, 0]),
+ radiusScale = d3.scale.sqrt().domain([0, 5e8]).range([0, 40]),
+ colorScale = d3.scale.category10();
+
+ // The x & y axes.
+ var xAxis = d3.svg.axis().orient("bottom").scale(xScale).ticks(12, d3.format(",d")),
+ yAxis = d3.svg.axis().scale(yScale).orient("left");
+
+ // Create the SVG container and set the origin.
+ var svg = d3.select("#chart").append("svg")
+ .attr("width", width + margin.left + margin.right)
+ .attr("height", height + margin.top + margin.bottom)
+ .append("g")
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+ // Add the x-axis.
+ svg.append("g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + height + ")")
+ .call(xAxis);
+
+ // Add the y-axis.
+ svg.append("g")
+ .attr("class", "y axis")
+ .call(yAxis);
+
+ // Add an x-axis label.
+ svg.append("text")
+ .attr("class", "x label")
+ .attr("text-anchor", "end")
+ .attr("x", width)
+ .attr("y", height - 6)
+ .text("income per capita, inflation-adjusted (dollars)");
+
+ // Add a y-axis label.
+ svg.append("text")
+ .attr("class", "y label")
+ .attr("text-anchor", "end")
+ .attr("y", 6)
+ .attr("dy", ".75em")
+ .attr("transform", "rotate(-90)")
+ .text("life expectancy (years)");
+
+ // Add the year label; the value is set on transition.
+ var label = svg.append("text")
+ .attr("class", "year label")
+ .attr("text-anchor", "end")
+ .attr("y", height - 24)
+ .attr("x", width)
+ .text(1800);
+
+ // Load the data.
+ d3.json("nations.json", function (nations) {
+
+ // A bisector since many nation's data is sparsely-defined.
+ var bisect = d3.bisector(function (d) { return d[0]; } );
+
+ // Add a dot per nation. Initialize the data at 1800, and set the colors.
+ var dot = svg.append("g")
+ .attr("class", "dots")
+ .selectAll(".dot")
+ .data(interpolateData(1800))
+ .enter().append("circle")
+ .attr("class", "dot")
+ .style("fill", function (d) { return colorScale(color(d)); } )
+ .call(position)
+ .sort(order);
+
+ // Add a title.
+ dot.append("title")
+ .text(function (d) { return d.name; } );
+
+ // Add an overlay for the year label.
+ var box = label.node().getBBox();
+
+ var overlay = svg.append("rect")
+ .attr("class", "overlay")
+ .attr("x", box.x)
+ .attr("y", box.y)
+ .attr("width", box.width)
+ .attr("height", box.height)
+ .on("mouseover", enableInteraction);
+
+ // Start a transition that interpolates the data based on year.
+ svg.transition()
+ .duration(30000)
+ .ease("linear")
+ .tween("year", tweenYear)
+ .each("end", enableInteraction);
+
+ // Positions the dots based on data.
+ function position(dot) {
+ dot.attr("cx", function (d) { return xScale(x(d)); } )
+ .attr("cy", function (d) { return yScale(y(d)); } )
+ .attr("r", function (d) { return radiusScale(radius(d)); } );
+ }
+
+ // Defines a sort order so that the smallest dots are drawn on top.
+ function order(a, b) {
+ return radius(b) - radius(a);
+ }
+
+ // After the transition finishes, you can mouseover to change the year.
+ function enableInteraction() {
+ var yearScale = d3.scale.linear()
+ .domain([1800, 2009])
+ .range([box.x + 10, box.x + box.width - 10])
+ .clamp(true);
+
+ // Cancel the current transition, if any.
+ svg.transition().duration(0);
+
+ overlay
+ .on("mouseover", mouseover)
+ .on("mouseout", mouseout)
+ .on("mousemove", mousemove)
+ .on("touchmove", mousemove);
+
+ function mouseover() {
+ label.classed("active", true);
+ }
+
+ function mouseout() {
+ label.classed("active", false);
+ }
+
+ function mousemove() {
+ displayYear(yearScale.invert(d3.mouse(this)[0]));
+ }
+ }
+
+ // Tweens the entire chart by first tweening the year, and then the data.
+ // For the interpolated data, the dots and label are redrawn.
+ function tweenYear() {
+ var year = d3.interpolateNumber(1800, 2009);
+ return function (t) { displayYear(year(t)); };
+ }
+
+ // Updates the display to show the specified year.
+ function displayYear(year) {
+ dot.data(interpolateData(year), key).call(position).sort(order);
+ label.text(Math.round(year));
+ }
+
+ // Interpolates the dataset for the given (fractional) year.
+ function interpolateData(year) {
+ return nations.map(function (d) {
+ return {
+ name: d.name,
+ region: d.region,
+ income: interpolateValues(d.income, year),
+ population: interpolateValues(d.population, year),
+ lifeExpectancy: interpolateValues(d.lifeExpectancy, year)
+ };
+ } );
+ }
+
+ // Finds (and possibly interpolates) the value for the specified year.
+ function interpolateValues(values, year) {
+ var i = bisect.left(values, year, 0, values.length - 1),
+ a = values[i];
+ if (i > 0) {
+ var b = values[i - 1],
+ t = (year - a[0]) / (b[0] - a[0]);
+ return a[1] * (1 - t) + b[1] * t;
+ }
+ return a[1];
+ }
+ } );
+}
diff --git a/d3/d3.d.ts b/d3/d3.d.ts
index 2f60ad1dc..a79bbd8e9 100644
--- a/d3/d3.d.ts
+++ b/d3/d3.d.ts
@@ -4,7 +4,7 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module D3 {
- interface Selectors {
+ export interface Selectors {
/**
* Select an element from the current document
*/
@@ -42,145 +42,7 @@ declare module D3 {
};
}
- interface Behavior {
- /**
- * Constructs a new drag behaviour
- */
- drag: () => Drag;
- /**
- * Constructs a new zoom behaviour
- */
- zoom: () => Zoom;
- }
-
- interface Zoom {
- /**
- * Execute zoom method
- */
- (): any;
-
- /**
- * Registers a listener to receive events
- *
- * @param type Enent name to attach the listener to
- * @param listener Function to attach to event
- */
- on: (type: string, listener: (data: any, index?: number) => any) => Zoom;
-
- /**
- * Gets or set the current zoom scale
- */
- scale: {
- /**
- * Get the current current zoom scale
- */
- (): number;
- /**
- * Set the current current zoom scale
- *
- * @param origin Zoom scale
- */
- (scale: number): Zoom;
- };
-
- /**
- * Gets or set the current zoom translation vector
- */
- translate: {
- /**
- * Get the current zoom translation vector
- */
- (): number[];
- /**
- * Set the current zoom translation vector
- *
- * @param translate Tranlation vector
- */
- (translate: number[]): Zoom;
- };
-
- /**
- * Gets or set the allowed scale range
- */
- scaleExtent: {
- /**
- * Get the current allowed zoom range
- */
- (): number[];
- /**
- * Set the allowable zoom range
- *
- * @param extent Allowed zoom range
- */
- (extent: number[]): Zoom;
- };
-
- /**
- * Gets or set the X-Scale that should be adjusted when zooming
- */
- x: {
- /**
- * Get the X-Scale
- */
- (): Scale;
- /**
- * Set the X-Scale to be adjusted
- *
- * @param x The X Scale
- */
- (x: Scale): Zoom;
-
- };
-
- /**
- * Gets or set the Y-Scale that should be adjusted when zooming
- */
- y: {
- /**
- * Get the Y-Scale
- */
- (): Scale;
- /**
- * Set the Y-Scale to be adjusted
- *
- * @param y The Y Scale
- */
- (y: Scale): Zoom;
- };
- }
-
- interface Drag {
- /**
- * Execute drag method
- */
- (): any;
-
- /**
- * Registers a listener to receive events
- *
- * @param type Enent name to attach the listener to
- * @param listener Function to attach to event
- */
- on: (type: string, listener: (data: any, index?: number) => any) => Drag;
-
- /**
- * Gets or set the current origin accessor function
- */
- origin: {
- /**
- * Get the current origin accessor function
- */
- (): any;
- /**
- * Set the origin accessor function
- *
- * @param origin Accessor function
- */
- (origin?: any): Drag;
- };
- }
-
- interface Event {
+ export interface Event {
dx: number;
dy: number;
clientX: number;
@@ -190,79 +52,78 @@ declare module D3 {
sourceEvent: Event;
x: number;
y: number;
+ keyCode: number;
altKey: any;
}
- interface Base extends Selectors {
+ export interface Base extends Selectors {
/**
* Create a behaviour
*/
- behavior: Behavior;
+ behavior: Behaviour.Behavior;
/**
* Access the current user event for interaction
*/
event: Event;
-
+
/**
* Compare two values for sorting.
* Returns -1 if a is less than b, or 1 if a is greater than b, or 0
*
- * @param a First number
- * @param b Second number
+ * @param a First value
+ * @param b Second value
*/
- ascending: (a: number, b: number) => number;
+ ascending(a: T, b: T): number;
/**
* Compare two values for sorting.
* Returns -1 if a is greater than b, or 1 if a is less than b, or 0
*
- * @param a First number
- * @param b Second number
+ * @param a First value
+ * @param b Second value
*/
- descending: (a: number, b: number) => number;
+ descending(a: T, b: T): number;
/**
* Find the minimum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
- min: (arr: number[], map?: (v: any) => any) => number;
+ min(arr: T[], map?: (v: T) => number): number;
/**
* Find the maximum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
- max: (arr: any[], map?: (v: any) => number) => number;
-
-
+ max(arr: T[], map?: (v: T) => number): number;
/**
* Find the minimum and maximum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
- extent: (arr: number[], map?: (v: any) => any) => number[];
+ extent(arr: T[], map?: (v: T) => number): number[];
/**
* Compute the sum of an array of numbers
*
* @param arr Array to search
* @param map Accsessor function
*/
- sum: (arr: number[], map?: (v: any) => any) => number;
+ sum(arr: T[], map?: (v: T) => number): number;
/**
* Compute the arithmetic mean of an array of numbers
*
* @param arr Array to search
* @param map Accsessor function
*/
- mean: (arr: number[], map?: (v: any) => any) => number;
+ mean(arr: T[], map?: (v: T) => number): number;
/**
* Compute the median of an array of numbers (the 0.5-quantile).
*
* @param arr Array to search
* @param map Accsessor function
*/
- median: (arr: number[], map?: (v: any) => any) => number;
+ median(arr: T[], map?: (v: T) => number): number;
/**
* Compute a quantile for a sorted array of numbers.
*
@@ -278,7 +139,7 @@ declare module D3 {
* @param low Minimum value of array subset
* @param hihg Maximum value of array subset
*/
- bisect: (arr: any[], x: any, low?: number, high?: number) => number;
+ bisect(arr: T[], x: T, low?: number, high?: number): number;
/**
* Locate the insertion point for x in array to maintain sorted order
*
@@ -287,7 +148,7 @@ declare module D3 {
* @param low Minimum value of array subset
* @param high Maximum value of array subset
*/
- bisectLeft: (arr: any[], x: any, low?: number, high?: number) => number;
+ bisectLeft(arr: T[], x: T, low?: number, high?: number): number;
/**
* Locate the insertion point for x in array to maintain sorted order
*
@@ -296,7 +157,7 @@ declare module D3 {
* @param low Minimum value of array subset
* @param high Maximum value of array subset
*/
- bisectRight: (arr: any[], x: any, low?: number, high?: number) => number;
+ bisectRight(arr: T[], x: T, low?: number, high?: number): number;
/**
* Bisect using an accessor.
*
@@ -308,7 +169,7 @@ declare module D3 {
*
* @param arr Array to randomise
*/
- shuffle(arr: any[]): any[];
+ shuffle(arr: T[]): T[];
/**
* Reorder an array of elements according to an array of indexes
*
@@ -376,7 +237,6 @@ declare module D3 {
* Create new nest operator
*/
nest(): Nest;
-
/**
* Request a resource using XMLHttpRequest.
*/
@@ -423,7 +283,7 @@ declare module D3 {
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
- json: (url: string, callback?: (response: any) => void ) => Xhr;
+ json: (url: string, callback?: (error: any, data: any) => void ) => Xhr;
/**
* Request an HTML document fragment.
*/
@@ -454,163 +314,213 @@ declare module D3 {
/**
* Request a comma-separated values (CSV) file.
*/
- csv: {
- /**
- * Request a comma-separated values (CSV) file.
- *
- * @param url Url to request
- * @param callback Function to invoke when resource is loaded or the request fails
- */
- (url: string, callback?: (error: any, response: any[]) => void ): Xhr;
- /**
- * Parse a CSV string into objects using the header row.
- *
- * @param string CSV formatted string to parse
- */
- parse(string: string): any[];
- /**
- * Parse a CSV string into tuples, ignoring the header row.
- *
- * @param string CSV formatted string to parse
- */
- parseRows(string: string, accessor: (row: any[], index: number) => any): any;
- /**
- * Format an array of tuples into a CSV string.
- *
- * @param rows Array to convert to a CSV string
- */
- format(rows: any[]): string;
- };
+ csv: Dsv;
/**
* Request a tab-separated values (TSV) file
*/
- tsv: {
- /**
- * Request a tab-separated values (TSV) file
- *
- * @param url Url to request
- * @param callback Function to invoke when resource is loaded or the request fails
- */
- (url: string, callback?: (error: any, response: any[]) => void ): Xhr;
- /**
- * Parse a TSV string into objects using the header row.
- *
- * @param string TSV formatted string to parse
- */
- parse(string: string): any[];
- /**
- * Parse a TSV string into tuples, ignoring the header row.
- *
- * @param string TSV formatted string to parse
- */
- parseRows(string: string, accessor: (row: any[], index: number) => any): any;
- /**
- * Format an array of tuples into a TSV string.
- *
- * @param rows Array to convert to a TSV string
- */
- format(rows: any[]): string;
- };
-
+ tsv: Dsv;
/**
* Time Functions
*/
- time: Time;
-
+ time: Time.Time;
/**
* Scales
*/
- scale: {
- /**
- * Construct a linear quantitative scale.
- */
- linear(): LinearScale;
- /*
- * Construct an ordinal scale.
- */
- ordinal(): OrdinalScale;
- /**
- * Construct a linear quantitative scale with a discrete output range.
- */
- quantize(): QuantizeScale;
- /*
- * Construct an ordinal scale with ten categorical colors.
- */
- category10(): OrdinalScale;
- /*
- * Construct an ordinal scale with twenty categorical colors
- */
- category20(): OrdinalScale;
- /*
- * Construct an ordinal scale with twenty categorical colors
- */
- category20b(): OrdinalScale;
- /*
- * Construct an ordinal scale with twenty categorical colors
- */
- category20c(): OrdinalScale;
- };
+ scale: Scale.ScaleBase;
/*
* Interpolate two values
*/
- interpolate: BaseInterpolate;
+ interpolate: Transition.BaseInterpolate;
/*
* Interpolate two numbers
*/
- interpolateNumber: BaseInterpolate;
+ interpolateNumber: Transition.BaseInterpolate;
/*
* Interpolate two integers
*/
- interpolateRound: BaseInterpolate;
+ interpolateRound: Transition.BaseInterpolate;
/*
* Interpolate two strings
*/
- interpolateString: BaseInterpolate;
+ interpolateString: Transition.BaseInterpolate;
/*
* Interpolate two RGB colours
*/
- interpolateRgb: BaseInterpolate;
+ interpolateRgb: Transition.BaseInterpolate;
/*
* Interpolate two HSL colours
*/
- interpolateHsl: BaseInterpolate;
+ interpolateHsl: Transition.BaseInterpolate;
+ /*
+ * Interpolate two HCL colours
+ */
+ interpolateHcl: Transition.BaseInterpolate;
+ /*
+ * Interpolate two L*a*b* colors
+ */
+ interpolateLab: Transition.BaseInterpolate;
/*
* Interpolate two arrays of values
*/
- interpolateArray: BaseInterpolate;
+ interpolateArray: Transition.BaseInterpolate;
/*
* Interpolate two arbitary objects
*/
- interpolateObject: BaseInterpolate;
+ interpolateObject: Transition.BaseInterpolate;
/*
* Interpolate two 2D matrix transforms
*/
- interpolateTransform: BaseInterpolate;
-
+ interpolateTransform: Transition.BaseInterpolate;
+ /*
+ * The array of built-in interpolator factories
+ */
+ interpolators: Array;
/**
* Layouts
*/
- layout: Layout;
-
+ layout: Layout.Layout;
/**
* Svg's
*/
- svg: Svg;
-
+ svg: Svg.Svg;
/**
* Random number generators
*/
random: Random;
-
/**
* Create a function to format a number as a string
*
* @param specifier The format specifier to use
*/
format(specifier: string): (value: number) => string;
+ /**
+ * Returns the SI prefix for the specified value at the specified precision
+ */
+ formatPrefix(value: number, precision?: number): MetricPrefix;
+ /**
+ * The version of the d3 library
+ */
+ version: string;
+ /**
+ * Returns the root selection
+ */
+ selection(): Selection;
+ ns: {
+ /**
+ * The map of registered namespace prefixes
+ */
+ prefix: {
+ svg: string;
+ xhtml: string;
+ xlink: string;
+ xml: string;
+ xmlns: string;
+ };
+ /**
+ * Qualifies the specified name
+ */
+ qualify(name: string): { space: string; local: string; };
+ };
+ /**
+ * Returns a built-in easing function of the specified type
+ */
+ ease: (type: string, ...arrs: any[]) => Transition;
+ /**
+ * Constructs a new RGB color.
+ */
+ rgb: {
+ /**
+ * Constructs a new RGB color with the specified r, g and b channel values
+ */
+ (r: number, g: number, b: number): D3.Color.RGBColor;
+ /**
+ * Constructs a new RGB color by parsing the specified color string
+ */
+ (color: string): D3.Color.RGBColor;
+ };
+ /**
+ * Constructs a new HCL color.
+ */
+ hcl: {
+ /**
+ * Constructs a new HCL color.
+ */
+ (h: number, c: number, l: number): Color.HCLColor;
+ /**
+ * Constructs a new HCL color by parsing the specified color string
+ */
+ (color: string): Color.HCLColor;
+ };
+ /**
+ * Constructs a new HSL color.
+ */
+ hsl: {
+ /**
+ * Constructs a new HSL color with the specified hue h, saturation s and lightness l
+ */
+ (h: number, s: number, l: number): Color.HSLColor;
+ /**
+ * Constructs a new HSL color by parsing the specified color string
+ */
+ (color: string): Color.HSLColor;
+ };
+ /**
+ * Constructs a new RGB color.
+ */
+ lab: {
+ /**
+ * Constructs a new LAB color.
+ */
+ (l: number, a: number, b: number): Color.LABColor;
+ /**
+ * Constructs a new LAB color by parsing the specified color string
+ */
+ (color: string): Color.LABColor;
+ };
+ geo: Geo.Geo;
+ geom: Geom.Geom;
+ /**
+ * gets the mouse position relative to a specified container.
+ */
+ mouse(container: any): Array;
+ /**
+ * gets the touch positions relative to a specified container.
+ */
+ touches(container: any): Array;
+ functor(value: T): T;
+ functor(value: () => T): T;
+ map(object?: any): Map;
+ set(array?: Array): Set;
+ dispatch(...types: Array): Dispatch;
+ rebind(target: any, source: any, ...names: Array): any;
+ requote(str: string): string;
+ timer: {
+ (funct: () => boolean, delay?: number, mark?: number): void;
+ flush(): void;
+ }
+ transition(): Transition.Transition;
}
- interface Xhr {
+ export interface Dispatch {
+ [event: string]: any;
+ on: {
+ (type: string): any;
+ (type: string, listener: any): any;
+ }
+ }
+
+ export interface MetricPrefix {
+ /**
+ * the scale function, for converting numbers to the appropriate prefixed scale.
+ */
+ scale: (d: number) => number;
+ /**
+ * the prefix symbol
+ */
+ symbol: string;
+ }
+
+ export interface Xhr {
/**
* Get or set request header
*/
@@ -657,14 +567,14 @@ declare module D3 {
*
* @param value The function used to map the response to a data value
*/
- (value: (xhr: XMLHttpRequest) => any ): Xhr;
+ (value: (xhr: XMLHttpRequest) => any): Xhr;
};
/**
* Issue the request using the GET method
*
* @param callback Function to invoke on completion of request
*/
- get (callback?: (xhr: XMLHttpRequest) => void ): Xhr;
+ get(callback?: (xhr: XMLHttpRequest) => void ): Xhr;
/**
* Issue the request using the POST method
*/
@@ -716,7 +626,35 @@ declare module D3 {
on: (type: string, listener: (data: any, index?: number) => any) => Xhr;
}
- interface Selection extends Selectors {
+ export interface Dsv {
+ /**
+ * Request a delimited values file
+ *
+ * @param url Url to request
+ * @param callback Function to invoke when resource is loaded or the request fails
+ */
+ (url: string, callback?: (error: any, response: any[]) => void ): Xhr;
+ /**
+ * Parse a delimited string into objects using the header row.
+ *
+ * @param string delimited formatted string to parse
+ */
+ parse(string: string): any[];
+ /**
+ * Parse a delimited string into tuples, ignoring the header row.
+ *
+ * @param string delimited formatted string to parse
+ */
+ parseRows(string: string, accessor: (row: any[], index: number) => any): any;
+ /**
+ * Format an array of tuples into a delimited string.
+ *
+ * @param rows Array to convert to a delimited string
+ */
+ format(rows: any[]): string;
+ }
+
+ export interface Selection extends Selectors, Array {
attr: {
(name: string): string;
(name: string, value: any): Selection;
@@ -768,617 +706,68 @@ declare module D3 {
};
filter: {
- (filter: (data: any, index: number) => bool): UpdateSelection;
- (filter: string): UpdateSelection;
+ (filter: (data: any, index: number) => boolean, thisArg?: any): UpdateSelection;
+ //(filter: string): UpdateSelection;
};
call(callback: (selection: Selection) => void ): Selection;
each(eachFunction: (data: any, index: number) => any): Selection;
on: {
(type: string): (data: any, index: number) => any;
- (type: string, listener: (data: any, index: number) => any, capture?: bool): Selection;
+ (type: string, listener: (data: any, index: number) => any, capture?: boolean): Selection;
};
- transition: () => Transition;
+ transition(): Transition.Transition;
+ /**
+ * sort elements in the document based on data.
+ *
+ * params comparator the specified comparator function
+ */
+ sort(comparator?: (a: T, b: T) => number): Selection;
+ order: () => Selection;
+ node: () => SVGLocatable;
}
- interface EnterSelection {
+ export interface EnterSelection {
append: (name: string) => Selection;
insert: (name: string, before: string) => Selection;
select: (selector: string) => Selection;
empty: () => bool;
- node: () => Node;
+ node: () => HTMLElementSVGLocatable;
}
- interface UpdateSelection extends Selection {
+ export interface UpdateSelection extends Selection {
enter: () => EnterSelection;
update: () => Selection;
exit: () => Selection;
}
- interface Transition {
- duration: {
- (duration: number): Transition;
- (duration: (data: any, index: number) => any): Transition;
- };
- delay: {
- (delay: number): Transition;
- (delay: (data: any, index: number) => any): Transition;
- };
- attr: {
- (name: string): string;
- (name: string, value: any): Transition;
- (name: string, valueFunction: (data: any, index: number) => any): Transition;
- };
-
- style: {
- (name: string): string;
- (name: string, value: any, priority?: string): Transition;
- (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Transition;
- };
-
- call(callback: (selection: Selection) => void ): Transition;
-
- select: (selector: string) => Transition;
- selectAll: (selector: string) => Transition;
-
- each: (type?: string, eachFunction?: (data: any, index: number) => any) => Transition;
- transition: () => Transition;
- ease: (value: string, ...arrs: any[]) => Transition;
- remove: () => Transition;
- }
-
- interface Nest {
+ export interface Nest {
key(keyFunction: (data: any, index: number) => any): Nest;
rollup(rollupFunction: (data: any, index: number) => any): Nest;
map(values: any[]): Nest;
}
- interface Time {
- second: Interval;
- minute: Interval;
- hour: Interval;
- day: Interval;
- week: Interval;
- sunday: Interval;
- monday: Interval;
- tuesday: Interval;
- wednesday: Interval;
- thursday: Interval;
- friday: Interval;
- saturday: Interval;
- month: Interval;
- year: Interval;
-
- seconds: Range;
- minutes: Range;
- hours: Range;
- days: Range;
- weeks: Range;
- months: Range;
- years: Range;
-
- sundays: Range;
- mondays: Range;
- tuesdays: Range;
- wednesdays: Range;
- thursdays: Range;
- fridays: Range;
- saturdays: Range;
- format: {
-
- (specifier: string): TimeFormat;
- utc: (specifier: string) => TimeFormat;
- iso: TimeFormat;
- };
-
- scale(): TimeScale;
+ export interface Map{
+ has(key: string): boolean;
+ get(key: string): any;
+ set(key: string, value: T): T;
+ remove(key: string): boolean;
+ keys(): Array;
+ values(): Array;
+ entries(): Array;
+ forEach(func: (key: string, value: any) => void ): void;
}
- interface Range {
- (start: Date, end: Date, step?: number): Date[];
+ export interface Set{
+ has(value: any): boolean;
+ Add(value: any): any;
+ remove(value: any): boolean;
+ values(): Array;
+ forEach(func: (value: any) => void ): void;
}
- interface Interval {
- (date: Date): Date;
- floor: (date: Date) => Date;
- round: (date: Date) => Date;
- ceil: (date: Date) => Date;
- range: Range;
- offset: (date: Date, step: number) => Date;
- utc: Interval;
- }
-
- interface TimeFormat {
- (date: Date): string;
- parse: (string: string) => Date;
- }
-
- interface Scale {
- (value: any): any;
- domain: {
- (values: any[]): Scale;
- (): any[];
- };
- range: {
- (values: any[]): Scale;
- (): any[];
- };
- copy(): Scale;
- }
-
- interface LinearScale extends Scale {
- (value: number): number;
- invert(value: number): number;
- domain: {
- (values: any[]): LinearScale;
- (): any[];
- };
- range: {
- (values: any[]): LinearScale;
- (): any[];
- };
- rangeRound: (values: any[]) => LinearScale;
- interpolate: {
- (): Interpolate;
- (factory: Interpolate): LinearScale;
- };
- clamp(clamp: bool): LinearScale;
- nice(): LinearScale;
- ticks(count: number): any[];
- tickFormat(count: number): (n: number) => string;
- copy(): LinearScale;
- }
-
- interface OrdinalScale extends Scale {
- (value: any): any;
- domain: {
- (values: any[]): OrdinalScale;
- (): any[];
- };
- range: {
- (values: any[]): OrdinalScale;
- (): any[];
- };
- rangePoints(interval: any[], padding?: number): OrdinalScale;
- rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
- rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
- rangeBand(): number;
- rangeExtent(): any[];
- copy(): OrdinalScale;
- }
-
- interface QuantizeScale extends Scale {
- (value: any): any;
- domain: {
- (values: number[]): QuantizeScale;
- (): any[];
- };
- range: {
- (values: any[]): QuantizeScale;
- (): any[];
- };
- copy(): QuantizeScale;
- }
-
- interface TimeScale extends Scale {
- (value: Date): number;
- invert(value: number): Date;
- domain: {
- (values: any[]): TimeScale;
- (): any[];
- };
- range: {
- (values: any[]): TimeScale;
- (): any[];
- };
- rangeRound: (values: any[]) => TimeScale;
- interpolate: {
- (): Interpolate;
- (factory: InterpolateFactory): TimeScale;
- };
- clamp(clamp: bool): TimeScale;
- ticks: {
- (count: number): any[];
- (range: Range, count: number): any[];
- };
- tickFormat(count: number): (n: number) => string;
- copy(): TimeScale;
- }
-
- interface InterpolateFactory {
- (a: any, b: any): BaseInterpolate;
- }
- interface BaseInterpolate {
- (a: any, b: any): Interpolate;
- }
-
- interface Interpolate {
- (t: number): number;
- }
-
- interface Layout {
- stack(): StackLayout;
- pie(): PieLayout;
- force(): ForceLayout;
- tree(): TreeLayout;
- }
-
- interface StackLayout {
- (layers: any[], index?: number): any[];
- values(accessor?: (d: any) => any): StackLayout;
- offset(offset: string): StackLayout;
- }
-
- interface PieLayout {
- (values: any[], index?: number): ArcDescriptor[];
- value: {
- (): (d: any, index: number) => number;
- (accessor: (d: any, index: number) => number): PieLayout;
- };
- sort: {
- (): (d1: any, d2: any) => number;
- (comparator: (d1: any, d2: any) => number): PieLayout;
- };
- startAngle: {
- (): number;
- (angle: number): Arc;
- (angle: () => number): Arc;
- };
- endAngle: {
- (): number;
- (angle: number): Arc;
- (angle: () => number): Arc;
- };
- }
-
- interface ArcDescriptor {
- value: any;
- data: any;
- startAngle: number;
- endAngle: number;
- }
-
- interface Symbol {
- type: (string) => Symbol;
- size: (number) => Symbol;
- }
-
-
-
- interface ProjectionPoint
- {
- x: number;
- y: number;
- }
-
- interface Projector
- {
- (d: ProjectionPoint): ProjectionPoint;
- }
-
- interface Diagonal
- {
- (): () => Diagonal;
- (projectionPoint): Diagonal;
- projection:
- {
- (projector): Diagonal;
- (): Projector;
- };
-
- }
-
- interface Svg {
- /**
- * Create a new symbol generator
- */
- symbol: () => Symbol;
- /**
- * Create a new axis generator
- */
- axis(): Axis;
- /**
- * Create a new arc generator
- */
- arc(): Arc;
- /**
- * Create a new line generator
- */
- line(): Line;
- /**
- * Create a new area generator
- */
- area(): Area;
- /**
- * Constructs a new diagonal generator with the default accessor functions
- */
- diagonal(): Diagonal;
-
- }
-
- interface Axis {
- (selection: Selection): void;
- scale: {
- (): any;
- (scale: any): Axis;
- };
-
- orient: {
- (): string;
- (orientation: string): Axis;
- };
-
- ticks: {
- (count: number): Axis;
- (range: Range, count?: number): Axis;
- };
-
- tickSubdivide(count: number): Axis;
- tickSize(major?: number, minor?: number, end?: number): Axis;
- tickFormat(formatter: (value: any) => string): Axis;
- }
-
- interface Arc {
- (options?: ArcOptions): string;
- innerRadius: {
- (): number;
- (radius: number): Arc;
- (radius: () => number): Arc;
- };
- outerRadius: {
- (): number;
- (radius: number): Arc;
- (radius: () => number): Arc;
- };
- startAngle: {
- (): number;
- (angle: number): Arc;
- (angle: () => number): Arc;
- };
- endAngle: {
- (): number;
- (angle: number): Arc;
- (angle: () => number): Arc;
- };
- centroid(options?: ArcOptions): number[];
- }
-
- interface ArcOptions {
- innerRadius?: number;
- outerRadius?: number;
- startAngle?: number;
- endAngle?: number;
- }
-
- interface Line {
- /**
- * Returns the path data string
- *
- * @param data Array of data elements
- * @param index Optional index
- */
- (data: any[], index?: number): string;
- /**
- * Get or set the x-coordinate accessor.
- */
- x: {
- /**
- * Get the x-coordinate accessor.
- */
- (): (data: any) => any;
- /**
- * Set the x-coordinate accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Line;
- };
- /**
- * Get or set the y-coordinate accessor.
- */
- y: {
- /**
- * Get the y-coordinate accessor.
- */
- (): (data: any) => any;
- /**
- * Set the y-coordinate accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Line;
- };
- /**
- * Get or set the interpolation mode.
- */
- interpolate: {
- /**
- * Get the interpolation accessor.
- */
- (): string;
- /**
- * Set the interpolation accessor.
- *
- * @param interpolate The interpolation mode
- */
- (interpolate: string): Line;
- };
- /**
- * Get or set the cardinal spline tension.
- */
- tension: {
- /**
- * Get the cardinal spline accessor.
- */
- (): number;
- /**
- * Set the cardinal spline accessor.
- *
- * @param tension The Cardinal spline interpolation tension
- */
- (tension: number): Line;
- };
- /**
- * Control whether the line is defined at a given point.
- */
- defined: {
- /**
- * Get the accessor function that controls where the line is defined.
- */
- (): (data: any) => any;
- /**
- * Set the accessor function that controls where the area is defined.
- *
- * @param defined The new accessor function
- */
- (defined: (data: any) => any): Line;
- };
- }
-
- interface Area {
- /**
- * Generate a piecewise linear area, as in an area chart.
- */
- (data: any[], index?: number): string;
- /**
- * Get or set the x-coordinate accessor.
- */
- x: {
- /**
- * Get the x-coordinate accessor.
- */
- (): (data: any) => any;
- /**
- * Set the x-coordinate accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Area;
- };
- /**
- * Get or set the x0-coordinate (baseline) accessor.
- */
- x0: {
- /**
- * Get the x0-coordinate (baseline) accessor.
- */
- (): (data: any) => any;
- /**
- * Set the x0-coordinate (baseline) accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Area;
- };
- /**
- * Get or set the x1-coordinate (topline) accessor.
- */
- x1: {
- /**
- * Get the x1-coordinate (topline) accessor.
- */
- (): (data: any) => any;
- /**
- * Set the x1-coordinate (topline) accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Area;
- };
- /**
- * Get or set the y-coordinate accessor.
- */
- y: {
- /**
- * Get the y-coordinate accessor.
- */
- (): (data: any) => any;
- /**
- * Set the y-coordinate accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Area;
- };
- /**
- * Get or set the y0-coordinate (baseline) accessor.
- */
- y0: {
- /**
- * Get the y0-coordinate (baseline) accessor.
- */
- (): (data: any) => any;
- /**
- * Set the y0-coordinate (baseline) accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Area;
- };
- /**
- * Get or set the y1-coordinate (topline) accessor.
- */
- y1: {
- /**
- * Get the y1-coordinate (topline) accessor.
- */
- (): (data: any) => any;
- /**
- * Set the y1-coordinate (topline) accessor.
- *
- * @param accessor The new accessor function
- */
- (accessor: (data: any) => any): Area;
- };
- /**
- * Get or set the interpolation mode.
- */
- interpolate: {
- /**
- * Get the interpolation accessor.
- */
- (): string;
- /**
- * Set the interpolation accessor.
- *
- * @param interpolate The interpolation mode
- */
- (interpolate: string): Area;
- };
- /**
- * Get or set the cardinal spline tension.
- */
- tension: {
- /**
- * Get the cardinal spline accessor.
- */
- (): number;
- /**
- * Set the cardinal spline accessor.
- *
- * @param tension The Cardinal spline interpolation tension
- */
- (tension: number): Area;
- };
- /**
- * Control whether the area is defined at a given point.
- */
- defined: {
- /**
- * Get the accessor function that controls where the area is defined.
- */
- (): (data: any) => any;
- /**
- * Set the accessor function that controls where the area is defined.
- *
- * @param defined The new accessor function
- */
- (defined: (data: any) => any): Area;
- };
- }
-
- interface Random {
+ export interface Random {
/**
* Returns a function for generating random numbers with a normal distribution
*
@@ -1400,167 +789,2234 @@ declare module D3 {
*/
irwinHall(count: number): () => number;
}
-
- // force layout definitions
- export interface TwoDGraphPoint {
- id: number;
- index: number;
- name: string;
- px: number;
- py: number;
- size: number;
- weight: number;
- x: number;
- y: number;
- x0: number;
- y0: number;
+
+ // Transitions
+ export module Transition {
+ export interface Transition {
+ duration: {
+ (duration: number): Transition;
+ (duration: (data: any, index: number) => any): Transition;
+ };
+ delay: {
+ (delay: number): Transition;
+ (delay: (data: any, index: number) => any): Transition;
+ };
+ attr: {
+ (name: string): string;
+ (name: string, value: any): Transition;
+ (name: string, valueFunction: (data: any, index: number) => any): Transition;
+ };
+ style: {
+ (name: string): string;
+ (name: string, value: any, priority?: string): Transition;
+ (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Transition;
+ };
+ call(callback: (selection: Selection) => void ): Transition;
+ /**
+ * Select an element from the current document
+ */
+ select: {
+ /**
+ * Selects the first element that matches the specified selector string
+ *
+ * @param selector Selection String to match
+ */
+ (selector: string): Transition;
+ /**
+ * Selects the specified node
+ *
+ * @param element Node element to select
+ */
+ (element: EventTarget): Transition;
+ };
+
+ /**
+ * Select multiple elements from the current document
+ */
+ selectAll: {
+ /**
+ * Selects all elements that match the specified selector
+ *
+ * @param selector Selection String to match
+ */
+ (selector: string): Transition;
+ /**
+ * Selects the specified array of elements
+ *
+ * @param elements Array of node elements to select
+ */
+ (elements: EventTarget[]): Transition;
+ }
+ each: (type?: string, eachFunction?: (data: any, index: number) => any) => Transition;
+ transition: () => Transition;
+ ease: (value: string, ...arrs: any[]) => Transition;
+ attrTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate): Transition;
+ styleTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate, priority?: string): Transition;
+ text: {
+ (text: string): Transition;
+ (text: (d: any, i: number) => string): Transition;
+ }
+ tween(name: string, factory: InterpolateFactory): Transition;
+ filter: {
+ (selector: string): Transition;
+ (selector: (data: any, index: number) => boolean): Transition;
+ };
+ remove(): Transition;
+ }
+
+ export interface InterpolateFactory {
+ (a?: any, b?: any): BaseInterpolate;
+ }
+
+ export interface BaseInterpolate {
+ (a: any, b?: any): any;
+ }
+
+ export interface Interpolate {
+ (t: any): any;
+ }
}
- export interface LayoutNode extends TwoDGraphPoint {
- fixed: bool;
- parent: LayoutNode;
- depth: number;
- children: LayoutNode[];
- _children: LayoutNode[];
+ //Time
+ export module Time {
+ export interface Time {
+ second: Interval;
+ minute: Interval;
+ hour: Interval;
+ day: Interval;
+ week: Interval;
+ sunday: Interval;
+ monday: Interval;
+ tuesday: Interval;
+ wednesday: Interval;
+ thursday: Interval;
+ friday: Interval;
+ saturday: Interval;
+ month: Interval;
+ year: Interval;
+
+ seconds: Range;
+ minutes: Range;
+ hours: Range;
+ days: Range;
+ weeks: Range;
+ months: Range;
+ years: Range;
+
+ sundays: Range;
+ mondays: Range;
+ tuesdays: Range;
+ wednesdays: Range;
+ thursdays: Range;
+ fridays: Range;
+ saturdays: Range;
+ format: {
+
+ (specifier: string): TimeFormat;
+ utc: (specifier: string) => TimeFormat;
+ iso: TimeFormat;
+ };
+
+ scale(): Scale.TimeScale;
+ }
+
+ export interface Range {
+ (start: Date, end: Date, step?: number): Date[];
+ }
+
+ export interface Interval {
+ (date: Date): Date;
+ floor: (date: Date) => Date;
+ round: (date: Date) => Date;
+ ceil: (date: Date) => Date;
+ range: Range;
+ offset: (date: Date, step: number) => Date;
+ utc: Interval;
+ }
+
+ export interface TimeFormat {
+ (date: Date): string;
+ parse: (string: string) => Date;
+ }
}
- export interface LayoutLink {
- source: LayoutNode;
- target: LayoutNode;
- }
+ // Layout
+ export module Layout {
+ export interface Layout {
+ /**
+ * Creates a new Stack layout
+ */
+ stack(): StackLayout;
+ /**
+ * Creates a new pie layout
+ */
+ pie(): PieLayout;
+ /**
+ * Creates a new force layout
+ */
+ force(): ForceLayout;
+ /**
+ * Creates a new tree layout
+ */
+ tree(): TreeLayout;
+ bundle(): BundleLayout;
+ chord(): ChordLayout;
+ cluster(): ClusterLayout;
+ hierarchy(): HierarchyLayout;
+ histogram(): HistogramLayout;
+ pack(): PackLayout;
+ partition(): PartitionLayout;
+ treeMap(): TreeMapLayout;
+ }
+ export interface StackLayout {
+ (layers: any[], index?: number): any[];
+ values(accessor?: (d: any) => any): StackLayout;
+ offset(offset: string): StackLayout;
+ }
- export interface ForceLayout {
- (): ForceLayout;
- size: {
- (): number;
- (mysize: number[]): ForceLayout;
- (accessor: (d: any, index: number) => {}): ForceLayout;
+ export interface TreeLayout {
+ /**
+ * Gets or sets the sort order of sibling nodes for the layout using the specified comparator function
+ */
+ sort: {
+ /**
+ * Gets the sort order function of sibling nodes for the layout
+ */
+ (): (d1: any, d2: any) => number;
+ /**
+ * Sets the sort order of sibling nodes for the layout using the specified comparator function
+ */
+ (comparator: (d1: any, d2: any) => number): TreeLayout;
+ };
+ /**
+ * Gets or sets the specified children accessor function
+ */
+ children: {
+ /**
+ * Gets the children accessor function
+ */
+ (): (d: any) => any;
+ /**
+ * Sets the specified children accessor function
+ */
+ (children: (d: any) => any): TreeLayout;
+ };
+ /**
+ * Runs the tree layout
+ */
+ nodes(root: GraphNode): TreeLayout;
+ /**
+ * Given the specified array of nodes, such as those returned by nodes, returns an array of objects representing the links from parent to child for each node
+ */
+ links(nodes: Array): Array;
+ /**
+ * If separation is specified, uses the specified function to compute separation between neighboring nodes. If separation is not specified, returns the current separation function
+ */
+ seperation: {
+ /**
+ * Gets the current separation function
+ */
+ (): (a: GraphNode, b: GraphNode) => number;
+ /**
+ * Sets the specified function to compute separation between neighboring nodes
+ */
+ (seperation: (a: GraphNode, b: GraphNode) => number): TreeLayout;
+ };
+ /**
+ * Gets or sets the available layout size
+ */
+ size: {
+ /**
+ * Gets the available layout size
+ */
+ (): Array;
+ /**
+ * Sets the available layout size
+ */
+ (size: Array): TreeLayout;
+ };
+ }
- };
+ export interface PieLayout {
+ (values: any[], index?: number): ArcDescriptor[];
+ value: {
+ (): (d: any, index: number) => number;
+ (accessor: (d: any, index: number) => number): PieLayout;
+ };
+ sort: {
+ (): (d1: any, d2: any) => number;
+ (comparator: (d1: any, d2: any) => number): PieLayout;
+ };
+ startAngle: {
+ (): number;
+ (angle: number): D3.Svg.Arc;
+ (angle: () => number): D3.Svg.Arc;
+ };
+ endAngle: {
+ (): number;
+ (angle: number): D3.Svg.Arc;
+ (angle: () => number): D3.Svg.Arc;
+ };
+ }
- linkDistance: {
- (): number;
- (number): ForceLayout;
- (accessor: (d: any, index: number) => number): ForceLayout;
- };
+ export interface ArcDescriptor {
+ value: any;
+ data: any;
+ startAngle: number;
+ endAngle: number;
+ index: number;
+ }
- linkStrength:
+ export interface GraphNode {
+ id: number;
+ index: number;
+ name: string;
+ px: number;
+ py: number;
+ size: number;
+ weight: number;
+ x: number;
+ y: number;
+ subindex: number;
+ startAngle: number;
+ endAngle: number;
+ value: number;
+ fixed: bool;
+ children: GraphNode[];
+ _children: GraphNode[];
+ parent: GraphNode;
+ depth: number;
+ }
+
+ export interface GraphLink {
+ source: GraphNode;
+ target: GraphNode;
+ }
+
+ export interface ForceLayout {
+ (): ForceLayout;
+ size: {
+ (): number;
+ (mysize: number[]): ForceLayout;
+ (accessor: (d: any, index: number) => {}): ForceLayout;
+
+ };
+ linkDistance: {
+ (): number;
+ (number): ForceLayout;
+ (accessor: (d: any, index: number) => number): ForceLayout;
+ };
+ linkStrength:
{
(): number;
(number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
-
- friction:
- {
- (): number;
- (number): ForceLayout;
- (accessor: (d: any, index: number) => number): ForceLayout;
- };
-
-
- alpha: {
- (): number;
- (number): ForceLayout;
- (accessor: (d: any, index: number) => number): ForceLayout;
- };
- charge: {
- (): number;
- (number): ForceLayout;
- (accessor: (d: any, index: number) => number): ForceLayout;
- };
-
- theta: {
- (): number;
- (number): ForceLayout;
- (accessor: (d: any, index: number) => number): ForceLayout;
- };
-
- gravity: {
- (): number;
- (number): ForceLayout;
- (accessor: (d: any, index: number) => number): ForceLayout;
- };
-
- links: {
- (): LayoutLink[];
- (arLinks: LayoutLink[]): ForceLayout;
-
- };
- nodes:
- {
- (): LayoutNode[];
- (arNodes: LayoutNode[]): ForceLayout;
-
- };
- start(): ForceLayout;
- resume(): ForceLayout;
- stop(): ForceLayout;
- tick(): ForceLayout;
- on(type: string, listener: () => void ): ForceLayout;
- drag(): ForceLayout;
- }
-
- // tree layout
-
-
- interface Comparator
- {
- (a: LayoutNode, b: LayoutNode): () => any;
-
- }
-
- interface ObjectWithChildrenArray
- {
- children: ObjectWithChildrenArray[];
- }
-
- interface ChildrenAccessorFunction
- {
- (d: ObjectWithChildrenArray): ()=> any;
- }
-
- interface CalculateSeparation
- {
- (a: any, b: any): () => number;
-
- }
-
-
- export interface TreeLayout
- {
- (): TreeLayout;
- size: {
- (): number;
- (mysize: number[]): TreeLayout;
- (accessor: (d: any, index: number) => {}): TreeLayout;
-
- };
- nodes: (LayoutNode) => LayoutNode[];
- links: (nodes: LayoutNode[]) => LayoutLink[];
-
-
- sort:
+ friction:
{
- (): () => Comparator;
- (Comparator): (comp) => Comparator;
+ (): number;
+ (number): ForceLayout;
+ (accessor: (d: any, index: number) => number): ForceLayout;
+ };
+ alpha: {
+ (): number;
+ (number): ForceLayout;
+ (accessor: (d: any, index: number) => number): ForceLayout;
+ };
+ charge: {
+ (): number;
+ (number): ForceLayout;
+ (accessor: (d: any, index: number) => number): ForceLayout;
};
-
- children:
- {
- (): () => ChildrenAccessorFunction;
- (ObjectWithChildrenArray): () => ObjectWithChildrenArray;
+ theta: {
+ (): number;
+ (number): ForceLayout;
+ (accessor: (d: any, index: number) => number): ForceLayout;
};
- separation:
- {
- (): CalculateSeparation;
- (CalculateSeparation): () => number;
- };
+ gravity: {
+ (): number;
+ (number): ForceLayout;
+ (accessor: (d: any, index: number) => number): ForceLayout;
+ };
+
+ links: {
+ (): GraphLink[];
+ (arLinks: GraphLink[]): ForceLayout;
+
+ };
+ nodes:
+ {
+ (): GraphNode[];
+ (arNodes: GraphNode[]): ForceLayout;
+
+ };
+ start(): ForceLayout;
+ resume(): ForceLayout;
+ stop(): ForceLayout;
+ tick(): ForceLayout;
+ on(type: string, listener: () => void ): ForceLayout;
+ drag(): ForceLayout;
+ }
+
+ export interface BundleLayout{
+ (links: Array): Array;
+ }
+
+ export interface ChordLayout {
+ matrix: {
+ (): Array>;
+ (matrix: Array>): ChordLayout;
+ }
+ padding: {
+ (): number;
+ (padding: number): ChordLayout;
+ }
+ sortGroups: {
+ (): Array;
+ (comparator: (a: number, b: number) => number): ChordLayout;
+ }
+ sortSubgroups: {
+ (): Array;
+ (comparator: (a: number, b: number) => number): ChordLayout;
+ }
+ sortChords: {
+ (): Array;
+ (comparator: (a: number, b: number) => number): ChordLayout;
+ }
+ chords(): Array;
+ groups(): Array;
+ }
+
+ export interface ClusterLayout{
+ sort: {
+ (): (a: GraphNode, b: GraphNode) => number;
+ (comparator: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
+ }
+ children: {
+ (): (d: any, i?: number) => Array;
+ (children: (d: any, i?: number) => Array): ClusterLayout;
+ }
+ nodes(root: GraphNode): Array;
+ links(nodes: Array): Array;
+ seperation: {
+ (): (a: GraphNode, b: GraphNode) => number;
+ (seperation: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
+ }
+ size: {
+ (): Array;
+ (size: Array): ClusterLayout;
+ }
+ value: {
+ (): (node: GraphNode) => number;
+ (value: (node: GraphNode) => number): ClusterLayout;
+ }
+ }
+
+ export interface HierarchyLayout {
+ sort: {
+ (): (a: GraphNode, b: GraphNode) => number;
+ (comparator: (a: GraphNode, b: GraphNode) => number): HierarchyLayout;
+ }
+ children: {
+ (): (d: any, i?: number) => Array;
+ (children: (d: any, i?: number) => Array): HierarchyLayout;
+ }
+ nodes(root: GraphNode): Array;
+ links(nodes: Array): Array;
+ value: {
+ (): (node: GraphNode) => number;
+ (value: (node: GraphNode) => number): HierarchyLayout;
+ }
+ reValue(root: GraphNode): HierarchyLayout;
+ }
+
+ export interface Bin extends Array {
+ x: number;
+ dx: number;
+ y: number;
+ }
+
+ export interface HistogramLayout {
+ (values: Array, index?: number): Array;
+ value: {
+ (): (value: any) => any;
+ (accessor: (value: any) => any): HistogramLayout
+ }
+ range: {
+ (): (value: any, index: number) => Array;
+ (range: (value: any, index: number) => Array): HistogramLayout;
+ (range: Array): HistogramLayout;
+ }
+ bins: {
+ (): (range: Array, index: number) => Array;
+ (bins: (range: Array, index: number) => Array): HistogramLayout;
+ (bins: number): HistogramLayout;
+ (bins: Array): HistogramLayout;
+ }
+ frequency: {
+ (): boolean;
+ (frequency: boolean): HistogramLayout;
+ }
+ }
+
+ export interface PackLayout {
+ sort: {
+ (): (a: GraphNode, b: GraphNode) => number;
+ (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout;
+ }
+ children: {
+ (): (d: any, i?: number) => Array;
+ (children: (d: any, i?: number) => Array): PackLayout;
+ }
+ nodes(root: GraphNode): Array;
+ links(nodes: Array): Array;
+ value: {
+ (): (node: GraphNode) => number;
+ (value: (node: GraphNode) => number): PackLayout;
+ }
+ size: {
+ (): Array;
+ (size: Array): PackLayout;
+ }
+ padding: {
+ (): number;
+ (padding: number): PackLayout;
+ }
+ }
+
+ export interface PartitionLayout {
+ sort: {
+ (): (a: GraphNode, b: GraphNode) => number;
+ (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout;
+ }
+ children: {
+ (): (d: any, i?: number) => Array;
+ (children: (d: any, i?: number) => Array): PackLayout;
+ }
+ nodes(root: GraphNode): Array;
+ links(nodes: Array): Array;
+ value: {
+ (): (node: GraphNode) => number;
+ (value: (node: GraphNode) => number): PackLayout;
+ }
+ size: {
+ (): Array;
+ (size: Array): PackLayout;
+ }
+ }
+
+ export interface TreeMapLayout {
+ sort: {
+ (): (a: GraphNode, b: GraphNode) => number;
+ (comparator: (a: GraphNode, b: GraphNode) => number): TreeMapLayout;
+ }
+ children: {
+ (): (d: any, i?: number) => Array;
+ (children: (d: any, i?: number) => Array): TreeMapLayout;
+ }
+ nodes(root: GraphNode): Array;
+ links(nodes: Array): Array;
+ value: {
+ (): (node: GraphNode) => number;
+ (value: (node: GraphNode) => number): TreeMapLayout;
+ }
+ size: {
+ (): Array;
+ (size: Array): TreeMapLayout;
+ }
+ padding: {
+ (): number;
+ (padding: number): TreeMapLayout;
+ }
+ round: {
+ (): boolean;
+ (round: boolean): TreeMapLayout;
+ }
+ sticky: {
+ (): boolean;
+ (sticky: boolean): TreeMapLayout;
+ }
+ mode: {
+ (): string;
+ (mode: string): TreeMapLayout;
+ }
+ }
}
+ // Colour
+ export module Color {
+ export interface Color {
+ /**
+ * increase lightness by some exponential factor (gamma)
+ */
+ brighter(k: number): Color;
+ /**
+ * decrease lightness by some exponential factor (gamma)
+ */
+ darker(k: number): Color;
+ /**
+ * convert the color to a string.
+ */
+ toString(): Color;
+ }
+
+ export interface RGBColor extends Color{
+ /**
+ * convert from RGB to HSL.
+ */
+ hsl(): HSLColor;
+ }
+
+ export interface HSLColor extends Color{
+ /**
+ * convert from HSL to RGB.
+ */
+ rgb(): RGBColor;
+ }
+
+ export interface LABColor extends Color{
+ /**
+ * convert from LAB to RGB.
+ */
+ rgb(): RGBColor;
+ }
+
+ export interface HCLColor extends Color{
+ /**
+ * convert from HCL to RGB.
+ */
+ rgb(): RGBColor;
+ }
+ }
+
+ // SVG
+ export module Svg {
+ export interface Svg {
+ /**
+ * Create a new symbol generator
+ */
+ symbol(): Symbol;
+ /**
+ * Create a new axis generator
+ */
+ axis(): Axis;
+ /**
+ * Create a new arc generator
+ */
+ arc(): Arc;
+ /**
+ * Create a new line generator
+ */
+ line: {
+ (): Line;
+ radial(): LineRadial;
+ }
+ /**
+ * Create a new area generator
+ */
+ area: {
+ (): Area;
+ radial(): AreaRadial;
+ }
+ /**
+ * Create a new brush generator
+ */
+ brush(): Brush;
+ /**
+ * Create a new chord generator
+ */
+ chord(): Chord;
+ /**
+ * Create a new diagonal generator
+ */
+ diagonal: {
+ (): Diagonal;
+ radial(): Diagonal;
+ }
+ /**
+ * The array of supported symbol types.
+ */
+ symbolTypes: Array;
+ }
+
+ export interface Symbol {
+ type: (string) => Symbol;
+ size: (number) => Symbol;
+ }
+
+ export interface Brush {
+ /**
+ * Draws or redraws this brush into the specified selection of elements
+ */
+ (selection: Selection): void;
+ /**
+ * Gets or sets the x-scale associated with the brush
+ */
+ x: {
+ /**
+ * Gets the x-scale associated with the brush
+ */
+ (): D3.Scale.Scale;
+ /**
+ * Sets the x-scale associated with the brush
+ *
+ * @param accessor The new Scale
+ */
+ (scale: D3.Scale.Scale): Brush;
+ };
+ /**
+ * Gets or sets the x-scale associated with the brush
+ */
+ y: {
+ /**
+ * Gets the x-scale associated with the brush
+ */
+ (): D3.Scale.Scale;
+ /**
+ * Sets the x-scale associated with the brush
+ *
+ * @param accessor The new Scale
+ */
+ (scale: D3.Scale.Scale): Brush;
+ };
+ /**
+ * Gets or sets the current brush extent
+ */
+ extent: {
+ /**
+ * Gets the current brush extent
+ */
+ (): Array>;
+ /**
+ * Sets the current brush extent
+ */
+ (values: Array>): Brush;
+ };
+ /**
+ * Clears the extent, making the brush extent empty.
+ */
+ clear(): Brush;
+ /**
+ * Returns true if and only if the brush extent is empty
+ */
+ empty(): boolean;
+ /**
+ * Gets or sets the listener for the specified event type
+ */
+ on: {
+ /**
+ * Gets the listener for the specified event type
+ */
+ (type: string): (data: any, index: number) => any;
+ /**
+ * Sets the listener for the specified event type
+ */
+ (type: string, listener: (data: any, index: number) => any, capture?: boolean): Brush;
+ };
+ }
+
+ export interface Axis {
+ (selection: Selection): void;
+ scale: {
+ (): any;
+ (scale: any): Axis;
+ };
+
+ orient: {
+ (): string;
+ (orientation: string): Axis;
+ };
+
+ ticks: {
+ (): any[];
+ (...arguments: any[]): Axis;
+ };
+
+ tickSubdivide(count: number): Axis;
+ tickSize(major?: number, minor?: number, end?: number): Axis;
+ tickFormat(formatter: (value: any) => string): Axis;
+ }
+
+ export interface Arc {
+ (options?: ArcOptions): string;
+ innerRadius: {
+ (): number;
+ (radius: number): Arc;
+ (radius: () => number): Arc;
+ };
+ outerRadius: {
+ (): number;
+ (radius: number): Arc;
+ (radius: () => number): Arc;
+ };
+ startAngle: {
+ (): number;
+ (angle: number): Arc;
+ (angle: () => number): Arc;
+ };
+ endAngle: {
+ (): number;
+ (angle: number): Arc;
+ (angle: () => number): Arc;
+ };
+ centroid(options?: ArcOptions): number[];
+ }
+
+ export interface ArcOptions {
+ innerRadius?: number;
+ outerRadius?: number;
+ startAngle?: number;
+ endAngle?: number;
+ }
+
+ export interface Line {
+ /**
+ * Returns the path data string
+ *
+ * @param data Array of data elements
+ * @param index Optional index
+ */
+ (data: any[], index?: number): string;
+ /**
+ * Get or set the x-coordinate accessor.
+ */
+ x: {
+ /**
+ * Get the x-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Line;
+ };
+ /**
+ * Get or set the y-coordinate accessor.
+ */
+ y: {
+ /**
+ * Get the y-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Line;
+ };
+ /**
+ * Get or set the interpolation mode.
+ */
+ interpolate: {
+ /**
+ * Get the interpolation accessor.
+ */
+ (): string;
+ /**
+ * Set the interpolation accessor.
+ *
+ * @param interpolate The interpolation mode
+ */
+ (interpolate: string): Line;
+ };
+ /**
+ * Get or set the cardinal spline tension.
+ */
+ tension: {
+ /**
+ * Get the cardinal spline accessor.
+ */
+ (): number;
+ /**
+ * Set the cardinal spline accessor.
+ *
+ * @param tension The Cardinal spline interpolation tension
+ */
+ (tension: number): Line;
+ };
+ /**
+ * Control whether the line is defined at a given point.
+ */
+ defined: {
+ /**
+ * Get the accessor function that controls where the line is defined.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the accessor function that controls where the area is defined.
+ *
+ * @param defined The new accessor function
+ */
+ (defined: (data: any) => any): Line;
+ };
+ }
+
+ export interface LineRadial {
+ /**
+ * Returns the path data string
+ *
+ * @param data Array of data elements
+ * @param index Optional index
+ */
+ (data: any[], index?: number): string;
+ /**
+ * Get or set the x-coordinate accessor.
+ */
+ x: {
+ /**
+ * Get the x-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): LineRadial;
+ };
+ /**
+ * Get or set the y-coordinate accessor.
+ */
+ y: {
+ /**
+ * Get the y-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): LineRadial;
+ };
+ /**
+ * Get or set the interpolation mode.
+ */
+ interpolate: {
+ /**
+ * Get the interpolation accessor.
+ */
+ (): string;
+ /**
+ * Set the interpolation accessor.
+ *
+ * @param interpolate The interpolation mode
+ */
+ (interpolate: string): LineRadial;
+ };
+ /**
+ * Get or set the cardinal spline tension.
+ */
+ tension: {
+ /**
+ * Get the cardinal spline accessor.
+ */
+ (): number;
+ /**
+ * Set the cardinal spline accessor.
+ *
+ * @param tension The Cardinal spline interpolation tension
+ */
+ (tension: number): LineRadial;
+ };
+ /**
+ * Control whether the line is defined at a given point.
+ */
+ defined: {
+ /**
+ * Get the accessor function that controls where the line is defined.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the accessor function that controls where the area is defined.
+ *
+ * @param defined The new accessor function
+ */
+ (defined: (data: any) => any): LineRadial;
+ };
+ radius: {
+ (): (d: any, i: any) => number;
+ (radius: number): LineRadial;
+ (radius: (d: any, i: any) => number): LineRadial;
+ }
+ angle: {
+ (): (d: any, i: any) => number;
+ (angle: number): LineRadial;
+ (angle: (d: any, i: any) => number): LineRadial;
+ }
+ }
+
+ export interface Area {
+ /**
+ * Generate a piecewise linear area, as in an area chart.
+ */
+ (data: any[], index?: number): string;
+ /**
+ * Get or set the x-coordinate accessor.
+ */
+ x: {
+ /**
+ * Get the x-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Area;
+ };
+ /**
+ * Get or set the x0-coordinate (baseline) accessor.
+ */
+ x0: {
+ /**
+ * Get the x0-coordinate (baseline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x0-coordinate (baseline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Area;
+ };
+ /**
+ * Get or set the x1-coordinate (topline) accessor.
+ */
+ x1: {
+ /**
+ * Get the x1-coordinate (topline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x1-coordinate (topline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Area;
+ };
+ /**
+ * Get or set the y-coordinate accessor.
+ */
+ y: {
+ /**
+ * Get the y-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Area;
+ };
+ /**
+ * Get or set the y0-coordinate (baseline) accessor.
+ */
+ y0: {
+ /**
+ * Get the y0-coordinate (baseline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y0-coordinate (baseline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Area;
+ };
+ /**
+ * Get or set the y1-coordinate (topline) accessor.
+ */
+ y1: {
+ /**
+ * Get the y1-coordinate (topline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y1-coordinate (topline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): Area;
+ };
+ /**
+ * Get or set the interpolation mode.
+ */
+ interpolate: {
+ /**
+ * Get the interpolation accessor.
+ */
+ (): string;
+ /**
+ * Set the interpolation accessor.
+ *
+ * @param interpolate The interpolation mode
+ */
+ (interpolate: string): Area;
+ };
+ /**
+ * Get or set the cardinal spline tension.
+ */
+ tension: {
+ /**
+ * Get the cardinal spline accessor.
+ */
+ (): number;
+ /**
+ * Set the cardinal spline accessor.
+ *
+ * @param tension The Cardinal spline interpolation tension
+ */
+ (tension: number): Area;
+ };
+ /**
+ * Control whether the area is defined at a given point.
+ */
+ defined: {
+ /**
+ * Get the accessor function that controls where the area is defined.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the accessor function that controls where the area is defined.
+ *
+ * @param defined The new accessor function
+ */
+ (defined: (data: any) => any): Area;
+ };
+ }
+
+ export interface AreaRadial {
+ /**
+ * Generate a piecewise linear area, as in an area chart.
+ */
+ (data: any[], index?: number): string;
+ /**
+ * Get or set the x-coordinate accessor.
+ */
+ x: {
+ /**
+ * Get the x-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): AreaRadial;
+ };
+ /**
+ * Get or set the x0-coordinate (baseline) accessor.
+ */
+ x0: {
+ /**
+ * Get the x0-coordinate (baseline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x0-coordinate (baseline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): AreaRadial;
+ };
+ /**
+ * Get or set the x1-coordinate (topline) accessor.
+ */
+ x1: {
+ /**
+ * Get the x1-coordinate (topline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the x1-coordinate (topline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): AreaRadial;
+ };
+ /**
+ * Get or set the y-coordinate accessor.
+ */
+ y: {
+ /**
+ * Get the y-coordinate accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y-coordinate accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): AreaRadial;
+ };
+ /**
+ * Get or set the y0-coordinate (baseline) accessor.
+ */
+ y0: {
+ /**
+ * Get the y0-coordinate (baseline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y0-coordinate (baseline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): AreaRadial;
+ };
+ /**
+ * Get or set the y1-coordinate (topline) accessor.
+ */
+ y1: {
+ /**
+ * Get the y1-coordinate (topline) accessor.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the y1-coordinate (topline) accessor.
+ *
+ * @param accessor The new accessor function
+ */
+ (accessor: (data: any) => any): AreaRadial;
+ };
+ /**
+ * Get or set the interpolation mode.
+ */
+ interpolate: {
+ /**
+ * Get the interpolation accessor.
+ */
+ (): string;
+ /**
+ * Set the interpolation accessor.
+ *
+ * @param interpolate The interpolation mode
+ */
+ (interpolate: string): AreaRadial;
+ };
+ /**
+ * Get or set the cardinal spline tension.
+ */
+ tension: {
+ /**
+ * Get the cardinal spline accessor.
+ */
+ (): number;
+ /**
+ * Set the cardinal spline accessor.
+ *
+ * @param tension The Cardinal spline interpolation tension
+ */
+ (tension: number): AreaRadial;
+ };
+ /**
+ * Control whether the area is defined at a given point.
+ */
+ defined: {
+ /**
+ * Get the accessor function that controls where the area is defined.
+ */
+ (): (data: any) => any;
+ /**
+ * Set the accessor function that controls where the area is defined.
+ *
+ * @param defined The new accessor function
+ */
+ (defined: (data: any) => any): AreaRadial;
+ };
+ radius: {
+ (): number;
+ (radius: number): AreaRadial;
+ (radius: () => number): AreaRadial;
+ };
+ innerRadius: {
+ (): number;
+ (radius: number): AreaRadial;
+ (radius: () => number): AreaRadial;
+ };
+ outerRadius: {
+ (): number;
+ (radius: number): AreaRadial;
+ (radius: () => number): AreaRadial;
+ };
+ angle: {
+ (): number;
+ (angle: number): AreaRadial;
+ (angle: () => number): AreaRadial;
+ };
+ startAngle: {
+ (): number;
+ (angle: number): AreaRadial;
+ (angle: () => number): AreaRadial;
+ };
+ endAngle: {
+ (): number;
+ (angle: number): AreaRadial;
+ (angle: () => number): AreaRadial;
+ };
+ }
+
+ export interface Chord {
+ (datum: any, index?: number): string;
+ radius: {
+ (): number;
+ (radius: number): Chord;
+ (radius: () => number): Chord;
+ };
+ startAngle: {
+ (): number;
+ (angle: number): Chord;
+ (angle: () => number): Chord;
+ };
+ endAngle: {
+ (): number;
+ (angle: number): Chord;
+ (angle: () => number): Chord;
+ };
+ source: {
+ (): any;
+ (angle: any): Chord;
+ (angle: (d: any, i?: number) => any): Chord;
+ };
+ target: {
+ (): any;
+ (angle: any): Chord;
+ (angle: (d: any, i?: number) => any): Chord;
+ };
+ }
+
+ export interface Diagonal {
+ (datum: any, index?: number): string;
+ projection: {
+ (): Array;
+ (radius: (d: any, i?: number) => Array): Diagonal;
+ };
+ source: {
+ (): any;
+ (angle: any): Diagonal;
+ (angle: (d: any, i?: number) => any): Diagonal;
+ };
+ target: {
+ (): any;
+ (angle: any): Diagonal;
+ (angle: (d: any, i?: number) => any): Diagonal;
+ };
+ }
+ }
+
+ // Scales
+ export module Scale {
+ export interface ScaleBase {
+ /**
+ * Construct a linear quantitative scale.
+ */
+ linear(): LinearScale;
+ /*
+ * Construct an ordinal scale.
+ */
+ ordinal(): OrdinalScale;
+ /**
+ * Construct a linear quantitative scale with a discrete output range.
+ */
+ quantize(): QuantizeScale;
+ /*
+ * Construct an ordinal scale with ten categorical colors.
+ */
+ category10(): OrdinalScale;
+ /*
+ * Construct an ordinal scale with twenty categorical colors
+ */
+ category20(): OrdinalScale;
+ /*
+ * Construct an ordinal scale with twenty categorical colors
+ */
+ category20b(): OrdinalScale;
+ /*
+ * Construct an ordinal scale with twenty categorical colors
+ */
+ category20c(): OrdinalScale;
+ /*
+ * Construct a linear identity scale.
+ */
+ identity(): IdentityScale;
+ /*
+ * Construct a quantitative scale with an logarithmic transform.
+ */
+ log(): LogScale;
+ /*
+ * Construct a quantitative scale with an exponential transform.
+ */
+ pow(): PowScale;
+ /*
+ * Construct a quantitative scale mapping to quantiles.
+ */
+ quantile(): QuantileScale;
+ /*
+ * Construct a quantitative scale with a square root transform.
+ */
+ sqrt(): SqrtScale;
+ /*
+ * Construct a threshold scale with a discrete output range.
+ */
+ theshold(): ThresholdScale;
+ }
+
+ export interface Scale {
+ (value: any): any;
+ domain: {
+ (values: any[]): Scale;
+ (): any[];
+ };
+ range: {
+ (values: any[]): Scale;
+ (): any[];
+ };
+ copy(): Scale;
+ }
+
+ export interface QuantitiveScale extends Scale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: number): number;
+ /**
+ * Get the domain value corresponding to a given range value.
+ *
+ * @param value Range Value
+ */
+ invert(value: number): number;
+ /**
+ * Get or set the scale's input domain.
+ */
+ domain: {
+ /**
+ * Set the scale's input domain.
+ *
+ * @param value The input domain
+ */
+ (values: any[]): QuantitiveScale;
+ /**
+ * Get the scale's input domain.
+ */
+ (): any[];
+ };
+ /**
+ * get or set the scale's output range.
+ */
+ range: {
+ /**
+ * Set the scale's output range.
+ *
+ * @param value The output range.
+ */
+ (values: any[]): QuantitiveScale;
+ /**
+ * Get the scale's output range.
+ */
+ (): any[];
+ };
+ /**
+ * Set the scale's output range, and enable rounding.
+ *
+ * @param value The output range.
+ */
+ rangeRound: (values: any[]) => QuantitiveScale;
+ /**
+ * get or set the scale's output interpolator.
+ */
+ interpolate: {
+ (): D3.Transition.Interpolate;
+ (factory: D3.Transition.Interpolate): QuantitiveScale;
+ };
+ /**
+ * enable or disable clamping of the output range.
+ *
+ * @param clamp Enable or disable
+ */
+ clamp(clamp: boolean): QuantitiveScale;
+ /**
+ * extend the scale domain to nice round numbers.
+ */
+ nice(): QuantitiveScale;
+ /**
+ * get representative values from the input domain.
+ *
+ * @param count Aproximate representative values to return.
+ */
+ ticks(count: number): any[];
+ /**
+ * get a formatter for displaying tick values
+ *
+ * @param count Aproximate representative values to return
+ */
+ tickFormat(count: number): (n: number) => string;
+ /**
+ * create a new scale from an existing scale..
+ */
+ copy(): QuantitiveScale;
+ }
+
+ export interface LinearScale extends QuantitiveScale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: number): number;
+ }
+
+ export interface IdentityScale extends QuantitiveScale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: number): number;
+ }
+
+ export interface SqrtScale extends QuantitiveScale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: number): number;
+ }
+
+ export interface PowScale extends QuantitiveScale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: number): number;
+ }
+
+ export interface LogScale extends QuantitiveScale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: number): number;
+ }
+
+ export interface OrdinalScale extends Scale {
+ /**
+ * Get the range value corresponding to a given domain value.
+ *
+ * @param value Domain Value
+ */
+ (value: any): any;
+ /**
+ * Get or set the scale's input domain.
+ */
+ domain: {
+ /**
+ * Set the scale's input domain.
+ *
+ * @param value The input domain
+ */
+ (values: any[]): OrdinalScale;
+ /**
+ * Get the scale's input domain.
+ */
+ (): any[];
+ };
+ /**
+ * get or set the scale's output range.
+ */
+ range: {
+ /**
+ * Set the scale's output range.
+ *
+ * @param value The output range.
+ */
+ (values: any[]): OrdinalScale;
+ /**
+ * Get the scale's output range.
+ */
+ (): any[];
+ };
+ rangePoints(interval: any[], padding?: number): OrdinalScale;
+ rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
+ rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
+ rangeBand(): number;
+ rangeExtent(): any[];
+ /**
+ * create a new scale from an existing scale..
+ */
+ copy(): OrdinalScale;
+ }
+
+ export interface QuantizeScale extends Scale {
+ (value: any): any;
+ domain: {
+ (values: number[]): QuantizeScale;
+ (): any[];
+ };
+ range: {
+ (values: any[]): QuantizeScale;
+ (): any[];
+ };
+ copy(): QuantizeScale;
+ }
+
+ export interface ThresholdScale extends Scale {
+ (value: any): any;
+ domain: {
+ (values: number[]): ThresholdScale;
+ (): any[];
+ };
+ range: {
+ (values: any[]): ThresholdScale;
+ (): any[];
+ };
+ copy(): ThresholdScale;
+ }
+
+ export interface QuantileScale extends Scale {
+ (value: any): any;
+ domain: {
+ (values: number[]): QuantileScale;
+ (): any[];
+ };
+ range: {
+ (values: any[]): QuantileScale;
+ (): any[];
+ };
+ quantiles(): any[];
+ copy(): QuantileScale;
+ }
+
+ export interface TimeScale extends Scale {
+ (value: Date): number;
+ invert(value: number): Date;
+ domain: {
+ (values: any[]): TimeScale;
+ (): any[];
+ };
+ range: {
+ (values: any[]): TimeScale;
+ (): any[];
+ };
+ rangeRound: (values: any[]) => TimeScale;
+ interpolate: {
+ (): D3.Transition.Interpolate;
+ (factory: D3.Transition.InterpolateFactory): TimeScale;
+ };
+ clamp(clamp: boolean): TimeScale;
+ ticks: {
+ (count: number): any[];
+ (range: Range, count: number): any[];
+ };
+ tickFormat(count: number): (n: number) => string;
+ copy(): TimeScale;
+ }
+ }
+
+ // Behaviour
+ export module Behaviour {
+ export interface Behavior{
+ /**
+ * Constructs a new drag behaviour
+ */
+ drag(): Drag;
+ /**
+ * Constructs a new zoom behaviour
+ */
+ zoom(): Zoom;
+ }
+
+ export interface Zoom {
+ /**
+ * Execute zoom method
+ */
+ (): any;
+
+ /**
+ * Registers a listener to receive events
+ *
+ * @param type Enent name to attach the listener to
+ * @param listener Function to attach to event
+ */
+ on: (type: string, listener: (data: any, index?: number) => any) => Zoom;
+
+ /**
+ * Gets or set the current zoom scale
+ */
+ scale: {
+ /**
+ * Get the current current zoom scale
+ */
+ (): number;
+ /**
+ * Set the current current zoom scale
+ *
+ * @param origin Zoom scale
+ */
+ (scale: number): Zoom;
+ };
+
+ /**
+ * Gets or set the current zoom translation vector
+ */
+ translate: {
+ /**
+ * Get the current zoom translation vector
+ */
+ (): number[];
+ /**
+ * Set the current zoom translation vector
+ *
+ * @param translate Tranlation vector
+ */
+ (translate: number[]): Zoom;
+ };
+
+ /**
+ * Gets or set the allowed scale range
+ */
+ scaleExtent: {
+ /**
+ * Get the current allowed zoom range
+ */
+ (): number[];
+ /**
+ * Set the allowable zoom range
+ *
+ * @param extent Allowed zoom range
+ */
+ (extent: number[]): Zoom;
+ };
+
+ /**
+ * Gets or set the X-Scale that should be adjusted when zooming
+ */
+ x: {
+ /**
+ * Get the X-Scale
+ */
+ (): D3.Scale.Scale;
+ /**
+ * Set the X-Scale to be adjusted
+ *
+ * @param x The X Scale
+ */
+ (x: D3.Scale.Scale): Zoom;
+
+ };
+
+ /**
+ * Gets or set the Y-Scale that should be adjusted when zooming
+ */
+ y: {
+ /**
+ * Get the Y-Scale
+ */
+ (): D3.Scale.Scale;
+ /**
+ * Set the Y-Scale to be adjusted
+ *
+ * @param y The Y Scale
+ */
+ (y: D3.Scale.Scale): Zoom;
+ };
+ }
+
+ export interface Drag {
+ /**
+ * Execute drag method
+ */
+ (): any;
+
+ /**
+ * Registers a listener to receive events
+ *
+ * @param type Enent name to attach the listener to
+ * @param listener Function to attach to event
+ */
+ on: (type: string, listener: (data: any, index?: number) => any) => Drag;
+
+ /**
+ * Gets or set the current origin accessor function
+ */
+ origin: {
+ /**
+ * Get the current origin accessor function
+ */
+ (): any;
+ /**
+ * Set the origin accessor function
+ *
+ * @param origin Accessor function
+ */
+ (origin?: any): Drag;
+ };
+ }
+ }
+
+ // Geography
+ export module Geo {
+ export interface Geo {
+ /**
+ * create a new geographic path generator
+ */
+ path(): Path;
+ /**
+ * create a circle generator.
+ */
+ circle(): Circle;
+ /**
+ * compute the spherical area of a given feature.
+ */
+ area(feature: any): number;
+ /**
+ * compute the latitude-longitude bounding box for a given feature.
+ */
+ bounds(feature: any): Array>;
+ /**
+ * compute the spherical centroid of a given feature.
+ */
+ centroid(feature: any): Array;
+ /**
+ * compute the great-arc distance between two points.
+ */
+ distance(a: Array, b: Array): number;
+ /**
+ * interpolate between two points along a great arc.
+ */
+ interpolate(a: Array, b: Array): (t: number) => Array;
+ /**
+ * compute the length of a line string or the circumference of a polygon.
+ */
+ length(feature: any): number;
+ /**
+ * create a standard projection from a raw projection.
+ */
+ projection(raw: (lambda: any, phi: any) => any): Projection;
+ /**
+ * create a standard projection from a mutable raw projection.
+ */
+ projectionMutator(rawFactory: (lambda: number, phi: number) => Array): Projection;
+ /**
+ * the Albers equal-area conic projection.
+ */
+ albers(): Projection;
+ /**
+ * a composite Albers projection for the United States.
+ */
+ albersUsa(): Projection;
+ /**
+ * the azimuthal equal-area projection.
+ */
+ azimuthalEqualArea: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the azimuthal equidistant projection.
+ */
+ azimuthalEquidistant: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the conic conformal projection.
+ */
+ conicConformal: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the conic equidistant projection.
+ */
+ conicEquidistant: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the conic equal-area (a.k.a. Albers) projection.
+ */
+ conicEqualArea: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the equirectangular (plate carreé) projection.
+ */
+ equirectangular: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the gnomonic projection.
+ */
+ gnomonic: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the spherical Mercator projection.
+ */
+ mercator: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the azimuthal orthographic projection.
+ */
+ othographic: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the azimuthal stereographic projection.
+ */
+ stereographic: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * the transverse Mercator projection.
+ */
+ transverseMercator: {
+ (): Projection;
+ raw(): Projection;
+ }
+ /**
+ * convert a GeoJSON object to a geometry stream.
+ */
+ stream(object: GeoJSON, listener: any): Stream;
+ /**
+ *
+ */
+ graticule(): Graticule;
+ /**
+ *
+ */
+ greatArc: GreatArc;
+ /**
+ *
+ */
+ rotation(rotation: Array): Rotation;
+ }
+
+ export interface Path {
+ /**
+ * Returns the path data string for the given feature
+ */
+ (feature: any, index?: any): string;
+ /**
+ * get or set the geographic projection.
+ */
+ projection: {
+ /**
+ * get the geographic projection.
+ */
+ (): Projection;
+ /**
+ * set the geographic projection.
+ */
+ (projection: Projection): Path;
+ }
+ /**
+ * get or set the render context.
+ */
+ context: {
+ /**
+ * return an SVG path string invoked on the given feature.
+ */
+ (): string;
+ /**
+ * sets the render context and returns the path generator
+ */
+ (context: Context): Path;
+ }
+ /**
+ * Computes the projected area
+ */
+ area(feature: any);
+ /**
+ * Computes the projected centroid
+ */
+ centroid(feature: any);
+ /**
+ * Computes the projected bounding box
+ */
+ bounds(feature: any);
+ /**
+ * get or set the radius to display point features.
+ */
+ pointRadius: {
+ /**
+ * returns the current radius
+ */
+ (): number;
+ /**
+ * sets the radius used to display Point and MultiPoint features to the specified number
+ */
+ (radius: number): Path;
+ /**
+ * sets the radius used to display Point and MultiPoint features to the specified number
+ */
+ (radius: (feature: any, index: number) => number): Path;
+ }
+ }
+
+ export interface Context {
+ beginPath(): any;
+ moveTo(x: number, y: number): any;
+ lineTo(x: number, y: number): any;
+ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): any;
+ closePath(): any;
+ }
+
+ export interface Circle {
+ (...args: Array): GeoJSON;
+ origin: {
+ (): Array;
+ (origin: Array): Circle;
+ (origin: (...args: Array) => Array): Circle;
+ }
+ angle: {
+ (): number;
+ (angle: number): Circle;
+ }
+ precision: {
+ (): number;
+ (precision: number): Circle;
+ }
+ }
+
+ export interface Graticule{
+ (): GeoJSON;
+ lines(): GeoJSON;
+ outline(): GeoJSON;
+ extent: {
+ (): Array>;
+ (extent: Array>): Graticule;
+ }
+ minorExtent: {
+ (): Array>;
+ (extent: Array>): Graticule;
+ }
+ majorExtent: {
+ (): Array>;
+ (extent: Array>): Graticule;
+ }
+ step: {
+ (): Array>;
+ (extent: Array>): Graticule;
+ }
+ minorStep: {
+ (): Array>;
+ (extent: Array>): Graticule;
+ }
+ majorStep: {
+ (): Array>;
+ (extent: Array>): Graticule;
+ }
+ precision: {
+ (): number;
+ (precision: number): Graticule;
+ }
+ }
+
+ export interface GreatArc {
+ (): GeoJSON;
+ distance(): number;
+ source: {
+ (): any;
+ (source: any): GreatArc;
+ }
+ target: {
+ (): any;
+ (target: any): GreatArc;
+ }
+ precision: {
+ (): number;
+ (precision: number): GreatArc;
+ }
+ }
+
+ export interface GeoJSON {
+ coordinates: Array>;
+ type: string;
+ }
+
+ export interface Projection {
+ (coordinates: Array): Array;
+ invert(point: Array): Array;
+ rotate: {
+ (): Array;
+ (rotation: Array): Projection;
+ };
+ center: {
+ (): Array;
+ (location: Array