From 6d12ed32ba5a7b65b7ac5069f22794ae13174120 Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Sat, 8 Oct 2016 01:14:55 -0700 Subject: [PATCH 001/422] Add type definitions for koa-send. --- koa-send/koa-send-tests.ts | 23 +++++++++++++++++++++++ koa-send/koa-send.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 koa-send/koa-send-tests.ts create mode 100644 koa-send/koa-send.d.ts diff --git a/koa-send/koa-send-tests.ts b/koa-send/koa-send-tests.ts new file mode 100644 index 0000000000..630bdcbddb --- /dev/null +++ b/koa-send/koa-send-tests.ts @@ -0,0 +1,23 @@ +/// +/// + +import * as Koa from "koa"; +import * as send from "koa-send"; + +const app = new Koa(); + +app.use(async (ctx: Koa.Context) => { + const path: string = await send(ctx, 'stimpy.html'); +}); + +app.use(async (ctx: Koa.Context) => { + await send(ctx, 'stimpy.html', { + root: '../static-files', + index: 'index.html', + maxAge: 10, + hidden: true, + format: true, + gzip: true, + setHeaders: () => {}, + }); +}); diff --git a/koa-send/koa-send.d.ts b/koa-send/koa-send.d.ts new file mode 100644 index 0000000000..9ed8805412 --- /dev/null +++ b/koa-send/koa-send.d.ts @@ -0,0 +1,27 @@ +// Type definitions for koa-send v3.x +// Project: https://github.com/koajs/send +// Definitions by: Peter Safranek +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "koa-send" { + + import * as Koa from "koa"; + + interface ISendOptions { + root?: string; + index?: string; + maxAge?: number; + hidden?: boolean; + format?: boolean; + gzip?: boolean; + setHeaders?: Function; + } + + function send(ctx: Koa.Context, path: string, opts?: ISendOptions): Promise; + + namespace send {} + + export = send; +} From 462a3e448eb05053ef82c28dc825e218d67ca71e Mon Sep 17 00:00:00 2001 From: Jough Dempsey Date: Tue, 13 Dec 2016 17:13:06 -0600 Subject: [PATCH 002/422] Add ReadonlyArray as an alterative type for $inject. It may be prudent to make injected dependencies immutable, but we can't Object.freeze() or use the Readonly interfae for our dependency array if $inject only accepts a mutable array of strings. --- angular/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index 4b85c4a804..4a9445962d 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -10,7 +10,7 @@ declare var angular: angular.IAngularStatic; // Support for painless dependency injection declare global { interface Function { - $inject?: string[]; + $inject?: string[] | ReadonlyArray; } } @@ -1205,7 +1205,7 @@ declare namespace angular { debugInfoEnabled(): boolean; debugInfoEnabled(enabled: boolean): ICompileProvider; - + /** * Sets the number of times $onChanges hooks can trigger new changes before giving up and assuming that the model is unstable. * Increasing the TTL could have performance implications, so you should not change it without proper justification. @@ -1214,7 +1214,7 @@ declare namespace angular { */ onChangesTtl(): number; onChangesTtl(limit: number): ICompileProvider; - + /** * It indicates to the compiler whether or not directives on comments should be compiled. * It results in a compilation performance gain since the compiler doesn't have to check comments when looking for directives. @@ -1223,7 +1223,7 @@ declare namespace angular { */ commentDirectivesEnabled(): boolean; commentDirectivesEnabled(enabled: boolean): ICompileProvider; - + /** * It indicates to the compiler whether or not directives on element classes should be compiled. * It results in a compilation performance gain since the compiler doesn't have to check element classes when looking for directives. From 763a5e57a8e1285bbec15faba46668f2d9e747c3 Mon Sep 17 00:00:00 2001 From: cervengoc Date: Thu, 5 Jan 2017 11:11:47 +0100 Subject: [PATCH 003/422] Add ko.ignoreDependencies --- knockout/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knockout/index.d.ts b/knockout/index.d.ts index 3d1b51f249..a28d06a220 100644 --- a/knockout/index.d.ts +++ b/knockout/index.d.ts @@ -529,6 +529,8 @@ interface KnockoutStatic { renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + ignoreDependencies(callback: () => T): T; + expressionRewriting: { bindingRewriteValidators: any[]; twoWayBindings: any; From 407f94811e9a4aa1b1c1d4db9ef463c723119bec Mon Sep 17 00:00:00 2001 From: Andres David Jimenez Date: Sat, 7 Jan 2017 12:12:55 -0400 Subject: [PATCH 004/422] Loopback (#13830) Fix "Definitions by:" link --- loopback/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/index.d.ts b/loopback/index.d.ts index acaf91f169..64aac97c92 100644 --- a/loopback/index.d.ts +++ b/loopback/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Loopback 3.1 // Project: https://github.com/strongloop/loopback -// Definitions by: Andres D Jimenez +// Definitions by: Andres D Jimenez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From eab7e87d19847bcd0c36aa78b0de93c4b8097570 Mon Sep 17 00:00:00 2001 From: Andres David Jimenez Date: Sat, 7 Jan 2017 16:03:19 -0400 Subject: [PATCH 005/422] Loopback-boot (#13832) * loopback-boot module typings * loopback-boot module typings * prepare test * prepare test passed * prepare tsconfig file * prepare proyect link * prepare proyect link * re-testing --- loopback-boot/index.d.ts | 209 ++++++++++++++++++++++++++++ loopback-boot/loopback-boot-test.ts | 29 ++++ loopback-boot/tsconfig.json | 20 +++ loopback-boot/tslint.json | 1 + 4 files changed, 259 insertions(+) create mode 100644 loopback-boot/index.d.ts create mode 100644 loopback-boot/loopback-boot-test.ts create mode 100644 loopback-boot/tsconfig.json create mode 100644 loopback-boot/tslint.json diff --git a/loopback-boot/index.d.ts b/loopback-boot/index.d.ts new file mode 100644 index 0000000000..4c66af5ef8 --- /dev/null +++ b/loopback-boot/index.d.ts @@ -0,0 +1,209 @@ +// Type definitions for Loopback-boot 2.23 +// Project: https://github.com/strongloop/loopback-boot +// Definitions by: Andres D Jimenez +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/************************************************ +* * +* LoopBack-Boot v2.x API * +* * +************************************************/ + +import * as loopback from "loopback"; + +/** + * Use this API in the app.js file of your server-side Node.js application. + * ``` + * var loopback= require('loopback'); + * var boot = require('loopback-boot'); + * + * var app = module.exports = loopback(); + * + * boot(app, __dirname); + * + * ``` + * + * Initialize an application from an options object or a set of JSON and JavaScript files. + * + * NOTE: This module is primarily intended for use with LoopBack 2.0. It does work with LoopBack 1.x applications, + * but none of the LoopBack 1.x examples or generated code (scaffolding) use it. + * + * This function takes an optional argument that is either a string or an object. + * + * If the argument is a string, then it sets the application root directory based on the string value. Then it: + * Creates DataSources from the datasources.json file in the application root directory. + * + * Configures Models from the model-config.json file in the application root directory. + * + * Configures the LoopBack Application object from the config.json file in the application root directory. + * These properties can be accessed using app.get('propname'). + * + * If the argument is an object, then it looks for models, dataSources, 'config', modelsRootDir, dsRootDir, + * appConfigRootDir and appRootDir properties of the object. + * + * If the object has no appRootDir property then it sets the current working directory as the application root directory. + * + * The execution environment, {env}, is established from, in order, + * + * options.env + * process.env.NODE_ENV, + * the literal development. + * Then it: + * Creates DataSources from the options.dataSources object, if provided; otherwise, it searches for the files + * datasources.json, + * datasources.local.js or datasources.local.json (only one), + * datasources.{env}.js or datasources.{env}.json (only one) + * in the directory designated by 'options.dsRootDir', if present, or the application root directory. It merges the data source definitions from the files found. + * Creates Models from the options.models object, if provided; otherwise, it searches for the files + * model-config.json, + * model-config.local.js or model-config.local.json (only one), + * model-config.{env}.js or model-config.{env}.json (only one) + * in the directory designated by 'options.modelsRootDir', if present, or the application root directory. It merges the model definitions from the files found. + * Configures the Application object from the options.config object, if provided; otherwise, it searches for the files + * config.json, + * config.local.js or config.local.json (only one), + * config.{env}.js or config.{env}.json (only one) + * + * in the directory designated by 'options.appConfigRootDir', if present, or the application root directory. + * It merges the properties from the files found. + * + * In both cases, the function loads JavaScript files in the /boot subdirectory of the application root directory + * with require(). + * + * NOTE: The version 2.0 of loopback-boot changed the way how models are created. + * The model-config.json file contains only configuration options like dataSource and extra relations. + * To define a model, create a per-model JSON file in models/ directory. + * + * NOTE: Mixing bootLoopBackApp(app, bootConfig) and app.model(name, modelConfig) in multiple files may result in models being undefined due to race conditions. To avoid this when using bootLoopBackApp() make sure all models are passed as part of the models definition. + * Throws an error if the config object is not valid or if boot fails. + * + * @param {Loopback.LoopbackApplication} app LoopBack application created by loopback(). + * @param {string|OptionsLB} options Boot options; If String, this is the application root directory; if object, has below properties. + * @param {() => void} callback + */ + +declare function lb(app: loopback.LoopBackApplication, options: string|OptionsLB, callback?: (err: Error) => void): void; + +interface OptionsLB { + /** + * Directory to use when loading JSON and JavaScript files. + * Defaults to the current directory (process.cwd()). + */ + appRootDir: string; + + /** + * Directory to use when loading config.json. Defaults to appRootDir. + */ + appConfigRootDir: string; + + /** + * Object containing Model configurations. + */ + models: any; + + /** + * List of model definitions to use. When options.modelDefinitions is provided, + * loopback-boot does not search filesystem and use only the models provided in this argument. + */ + modelDefinitions: any[]; + + /** + * Object containing DataSource definitions. + */ + dataSources: any; + + /** + * Directory to use when loading model-config.json. Defaults to appRootDir. + */ + modelsRootDir: string; + + /** + * Directory to use when loading datasources.json. Defaults to appRootDir. + */ + dsRootDir: string; + + /** + * Directory to use when loading middleware.json. Defaults to appRootDir. + */ + middlewareRootDir: string; + + /** + * Directory to use when loading component-config.json. Defaults to appRootDir. + */ + componentRootDir: string; + + /** + * Environment type, defaults to process.env.NODE_ENV or development. + * Common values are development, staging and production; + * however the applications are free to use any names. + */ + env: string; + + /** + * List of directories where to look for files containing model definitions. + */ + modelSources: string[]; + + /** + * Middleware configuration to use instead of {appRootDir}/middleware.json + */ + middleware: any; + + /** + * Component configuration to use instead of {appRootDir}/component-config.json + */ + components: any; + + /** + * List of directories where to look for files containing model mixin definitions. + * All files (mixins) found in these directory are loaded. + */ + mixinDirs: string[]; + + /** + * List of directories where to look for files containing model mixin definitions. + * Only mixins used by application models are loaded from these directories. + */ + mixinSources: string[]; + + /** + * List of directories where to look for boot scripts. + */ + bootDirs: string[]; + + /** + * List of script files to execute on boot. + */ + bootScripts: string[]; + + /** + * Mixin normalization format: false, 'none', 'classify', 'dasherize' - defaults to 'classify'. + */ + normalization: string|boolean|any; +} + +declare namespace lb { + + /** + * compileToBrowserify + * + * Compile boot instructions and add them to a browserify bundler. + * @param {string|any} options as described in bootLoopBackApp above. + * @param {any} bundler A browserify bundler created by browserify(). + * @class + * @constructor + */ + + class compileToBrowserify { + + /** + * Application identifier used to load the correct boot configuration when + * building multiple applications using browserify. + */ + appId: string; + constructor(options: string|any, bundler: any); + } +} + +export = lb; \ No newline at end of file diff --git a/loopback-boot/loopback-boot-test.ts b/loopback-boot/loopback-boot-test.ts new file mode 100644 index 0000000000..75a0bf2ca5 --- /dev/null +++ b/loopback-boot/loopback-boot-test.ts @@ -0,0 +1,29 @@ +/// +import * as loopback from 'loopback'; +import * as boot from 'loopback-boot'; +import * as cookieParser from 'cookie-parser'; + +class Server { + app: loopback.LoopBackApplication; + + static boostrap(): Server { + return new Server(); + } + constructor() { + this.app = loopback(); + + this.app.use(cookieParser()); + + this.config(); + } + + private config(): void { + boot(this.app, __dirname, (err: Error) => { + if (err) throw err; + + // start the server if `$ node server.js` + if (require.main === module) + this.app.start(); + }); + } +} \ No newline at end of file diff --git a/loopback-boot/tsconfig.json b/loopback-boot/tsconfig.json new file mode 100644 index 0000000000..d784404acf --- /dev/null +++ b/loopback-boot/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "loopback-boot-test.ts" + ] +} \ No newline at end of file diff --git a/loopback-boot/tslint.json b/loopback-boot/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/loopback-boot/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 842e58faa140c8b103a7c2de1dc465c8a57cce1e Mon Sep 17 00:00:00 2001 From: Rowell Date: Sat, 7 Jan 2017 20:17:00 +0000 Subject: [PATCH 006/422] Highcharts No Data To Display module updated (#13703) * updated no-data-to-display to include initialisation * added module version * Updated version * single line for authors --- highcharts/index.d.ts | 2 +- highcharts/modules/no-data-to-display-tests.ts | 2 ++ highcharts/modules/no-data-to-display.d.ts | 10 +++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/highcharts/index.d.ts b/highcharts/index.d.ts index e425c0458b..f0131bebe2 100644 --- a/highcharts/index.d.ts +++ b/highcharts/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Highcharts 4.2.5 +// Type definitions for Highcharts 4.2.7 // Project: http://www.highcharts.com/ // Definitions by: Damiano Gambarotto , Dan Lewi Harkestad // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/highcharts/modules/no-data-to-display-tests.ts b/highcharts/modules/no-data-to-display-tests.ts index 84392c3bf4..e2bb453714 100644 --- a/highcharts/modules/no-data-to-display-tests.ts +++ b/highcharts/modules/no-data-to-display-tests.ts @@ -4,3 +4,5 @@ function test_NoDataToDisplay() { chart.hideNoData(); chart.showNoData("Custom no data message"); } + +HighchartsNoDataToDisplay(Highcharts); \ No newline at end of file diff --git a/highcharts/modules/no-data-to-display.d.ts b/highcharts/modules/no-data-to-display.d.ts index 0da068c413..750f8de607 100644 --- a/highcharts/modules/no-data-to-display.d.ts +++ b/highcharts/modules/no-data-to-display.d.ts @@ -1,9 +1,9 @@ -// Type definitions for Highcharts No Data to Display +// Type definitions for Highcharts No Data to Display 4.2.7 // Project: http://www.highcharts.com/ -// Definitions by: Andrey Zolotin +// Definitions by: Andrey Zolotin , Rowell Heria // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as Hc from "highcharts"; +import { Static } from "highcharts"; declare module "highcharts" { interface ChartObject { @@ -28,3 +28,7 @@ declare module "highcharts" { showNoData(message?: string): void; } } + +declare var HighchartsNoDataToDisplay: (H: Static) => Static; +export = HighchartsNoDataToDisplay; +export as namespace HighchartsNoDataToDisplay; From df8ef42bab7e8b53a5454c8dae95a2bb38bc89b6 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 7 Jan 2017 12:50:36 -0800 Subject: [PATCH 007/422] fabric: Convert to external module and use class declarations (#13833) --- fabric/fabricjs-tests.ts | 58 +- fabric/index.d.ts | 9109 +++++++++++++++++++------------------- fabric/tslint.json | 10 + scripts/lint.js | 2 - 4 files changed, 4559 insertions(+), 4620 deletions(-) create mode 100644 fabric/tslint.json diff --git a/fabric/fabricjs-tests.ts b/fabric/fabricjs-tests.ts index 6dcba48c71..d0b4ef197b 100644 --- a/fabric/fabricjs-tests.ts +++ b/fabric/fabricjs-tests.ts @@ -1,3 +1,5 @@ +import * as fabric from "fabric"; + function sample1() { var canvas = new fabric.Canvas('c', { hoverCursor: 'pointer', @@ -32,7 +34,7 @@ function sample1() { function sample2() { - var dot: fabric.ICircle, i: number, + var dot: fabric.Circle, i: number, t1: number, t2: number, startTimer = function() { t1 = new Date().getTime(); @@ -90,13 +92,13 @@ function sample3() { var $: (id: string) => HTMLElement = function(id: string) { return document.getElementById(id) }; function applyFilter(index: number, filter: any) { - var obj: fabric.IImage = canvas.getActiveObject(); + var obj: fabric.Image = canvas.getActiveObject(); obj.filters[index] = filter; obj.applyFilters(canvas.renderAll.bind(canvas)); } function applyFilterValue(index: number, prop: string, value: any) { - var obj: fabric.IImage = canvas.getActiveObject(); + var obj: fabric.Image = canvas.getActiveObject(); if (obj.filters[index]) { obj.applyFilters(canvas.renderAll.bind(canvas)); } @@ -114,7 +116,7 @@ function sample3() { for (var i = 0; i < filters.length; i++) { var checkBox = $(filters[i]); - var image = canvas.getActiveObject(); + var image = canvas.getActiveObject(); checkBox.checked = !!image.filters[i]; } }, @@ -262,17 +264,17 @@ function sample4() { } -namespace fabric { - export interface CircleWithLineInfos extends ICircle { - line1?: ILine; - line2?: ILine; - line3?: ILine; - line4?: ILine; +declare module "fabric" { + export interface CircleWithLineInfos extends Circle { + line1?: Line; + line2?: Line; + line3?: Line; + line4?: Line; } } function sample5() { - var makeCircle = function(left: number, top: number, line1?: fabric.ILine, line2?: fabric.ILine, line3?: fabric.ILine, line4?: fabric.ILine): fabric.ICircle { + var makeCircle = function(left: number, top: number, line1?: fabric.Line, line2?: fabric.Line, line3?: fabric.Line, line4?: fabric.Line): fabric.Circle { var c = new fabric.Circle({ left: left, top: top, @@ -356,8 +358,8 @@ function sample6() { }); } -namespace fabric { - export interface ImageWithInfo extends IImage { +declare module "fabric" { + export interface ImageWithInfo extends Image { movingLeft: boolean; } } @@ -419,7 +421,7 @@ function sample8() { } if (/(iPhone|iPod|iPad)/i.test(navigator.userAgent)) { - fabric.Object.prototype.cornersize = 30; + (fabric.Object.prototype as any).cornersize = 30; } var canvas = new fabric.Canvas('canvas'); @@ -866,7 +868,7 @@ function sample8() { var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - this.value = (activeObject).text; + this.value = (activeObject).text; } }; textEl.onkeyup = function(e) { @@ -876,7 +878,7 @@ function sample8() { canvas.discardActiveObject(); } else { - (activeObject).text = this.value; + (activeObject).text = this.value; } canvas.renderAll(); } @@ -887,7 +889,7 @@ function sample8() { if (cmdUnderlineBtn) { activeObjectButtons.push(cmdUnderlineBtn); cmdUnderlineBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration == 'underline' ? '' : 'underline'); this.className = activeObject.textDecoration ? 'selected' : ''; @@ -900,7 +902,7 @@ function sample8() { if (cmdLinethroughBtn) { activeObjectButtons.push(cmdLinethroughBtn); cmdLinethroughBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration == 'line-through' ? '' : 'line-through'); this.className = activeObject.textDecoration ? 'selected' : ''; @@ -913,7 +915,7 @@ function sample8() { if (cmdOverlineBtn) { activeObjectButtons.push(cmdOverlineBtn); cmdOverlineBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration == 'overline' ? '' : 'overline'); this.className = activeObject.textDecoration ? 'selected' : ''; @@ -926,7 +928,7 @@ function sample8() { if (cmdBoldBtn) { activeObjectButtons.push(cmdBoldBtn); cmdBoldBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontWeight = (activeObject.fontWeight == 'bold' ? '' : 'bold'); this.className = activeObject.fontWeight ? 'selected' : ''; @@ -939,7 +941,7 @@ function sample8() { if (cmdItalicBtn) { activeObjectButtons.push(cmdItalicBtn); cmdItalicBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontStyle = (activeObject.fontStyle == 'italic' ? '' : 'italic'); this.className = activeObject.fontStyle ? 'selected' : ''; @@ -952,7 +954,7 @@ function sample8() { if (cmdShadowBtn) { activeObjectButtons.push(cmdShadowBtn); cmdShadowBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.shadow = !activeObject.shadow ? 'rgba(0,0,0,0.2) 2px 2px 10px' : ''; this.className = activeObject.shadow ? 'selected' : ''; @@ -965,7 +967,7 @@ function sample8() { if (textAlignSwitch) { activeObjectButtons.push(textAlignSwitch); textAlignSwitch.onchange = function(this: HTMLInputElement) { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textAlign = this.value.toLowerCase(); canvas.renderAll(); @@ -977,7 +979,7 @@ function sample8() { if (fontFamilySwitch) { activeObjectButtons.push(fontFamilySwitch); fontFamilySwitch.onchange = function(this: HTMLInputElement) { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontFamily = this.value; canvas.renderAll(); @@ -988,7 +990,7 @@ function sample8() { var bgColorField = document.getElementById('text-bg-color'); if (bgColorField) { bgColorField.onchange = function(this: HTMLInputElement) { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.backgroundColor = this.value; canvas.renderAll(); @@ -999,7 +1001,7 @@ function sample8() { var strokeColorField = document.getElementById('text-stroke-color'); if (strokeColorField) { strokeColorField.onchange = function(this: HTMLInputElement) { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.stroke = this.value; canvas.renderAll(); @@ -1022,7 +1024,7 @@ function sample8() { label.appendChild(slider); slider.title = "Line height"; slider.onchange = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.lineHeight = +this.value; canvas.renderAll(); @@ -1030,7 +1032,7 @@ function sample8() { }; canvas.on('object:selected', function(e: fabric.IEvent) { - slider.value = String((e.target).lineHeight); + slider.value = String((e.target).lineHeight); }); })(); } diff --git a/fabric/index.d.ts b/fabric/index.d.ts index 08fcdb6ec3..881be190bd 100644 --- a/fabric/index.d.ts +++ b/fabric/index.d.ts @@ -1,4598 +1,4527 @@ -// Type definitions for FabricJS v1.5.0 +// Type definitions for FabricJS 1.5 // Project: http://fabricjs.com/ // Definitions by: Oliver Klemencic , Joseph Livecchi , Michael Randolph // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/* tslint:disable:no-unused-variable */ -/* tslint:disable:whitespace */ -/* tslint:disable:typedef */ +export as namespace fabric; -// Support AMD require -declare module "fabric" { - export = fabric; +export var isLikelyNode: boolean; +export var isTouchSupported: boolean; + +///////////////////////////////////////////////////////////// +// farbic Functions +///////////////////////////////////////////////////////////// + +export function createCanvasForNode(width: number, height: number): Canvas; + +// Parse +// ---------------------------------------------------------- +/** + * Creates markup containing SVG referenced elements like patterns, gradients etc. + * @param {fabric.Canvas} canvas instance of fabric.Canvas + */ +export function createSVGRefElementsMarkup(canvas: StaticCanvas): string; +/** + * Creates markup containing SVG font faces + * @param {Array} objects Array of fabric objects + */ +export function createSVGFontFacesMarkup(objects: Object[]): string; +/** + * Takes string corresponding to an SVG document, and parses it into a set of fabric objects + * @param {String} string + * @param {Function} callback + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + */ +export function loadSVGFromString(string: string, callback: (results: Object[], options: any) => void, reviver?: Function): void; +/** + * Takes url corresponding to an SVG document, and parses it into a set of fabric objects. + * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy) + * @param {String} url + * @param {Function} callback + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + */ +export function loadSVGFromURL(url: string, callback: (results: Object[], options: any) => void, reviver?: Function): void; +/** + * Returns CSS rules for a given SVG document + * @param {SVGDocument} doc SVG document to parse + */ +export function getCSSRules(doc: SVGElement): any; + +export function parseElements(elements: any[], callback: Function, options: any, reviver?: Function): void; +/** + * Parses "points" attribute, returning an array of values + * @param {String} points points attribute string + */ +export function parsePointsAttribute(points: string): any[]; +/** + * Parses "style" attribute, retuning an object with values + * @param {SVGElement} element Element to parse + */ +export function parseStyleAttribute(element: SVGElement): any; +/** + * Transforms an array of svg elements to corresponding fabric.* instances + * @param {Array} elements Array of elements to parse + * @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements) + * @param {Object} [options] Options object + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + */ +export function parseElements(elements: any[], callback: Function, options?: any, reviver?: Function): void; +/** + * Returns an object of attributes' name/value, given element and an array of attribute names; + * Parses parent "g" nodes recursively upwards. + * @param {DOMElement} element Element to parse + * @param {Array} attributes Array of attributes to parse + */ +export function parseAttributes(element: HTMLElement, attributes: string[], svgUid?: string): { [key: string]: string }; +/** + * Parses an SVG document, returning all of the gradient declarations found in it + * @param {SVGDocument} doc SVG document to parse + */ +export function getGradientDefs(doc: SVGElement): { [key: string]: any }; +/** + * Parses a short font declaration, building adding its properties to a style object + * @param {String} value font declaration + * @param {Object} oStyle definition + */ +export function parseFontDeclaration(value: string, oStyle: any): void; +/** + * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback + * @param {SVGDocument} doc SVG document to parse + * @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document). + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + */ +export function parseSVGDocument(doc: SVGElement, callback: (results: Object[], options: any) => void, reviver?: Function): void; +/** + * Parses "transform" attribute, returning an array of values + * @param {String} attributeValue String containing attribute value + */ +export function parseTransformAttribute(attributeValue: string): number[]; + +// fabric Log +// --------------- +/** + * Wrapper around `console.log` (when available) + */ +export function log(...values: any[]): void; +/** + * Wrapper around `console.warn` (when available) + */ +export function warn(...values: any[]): void; + +/////////////////////////////////////////////////////////////////////////////// +// Data Object Interfaces - These intrface are not specific part of fabric, +// They are just helpful for for defining function paramters +////////////////////////////////////////////////////////////////////////////// +interface IDataURLOptions { + /** + * The format of the output image. Either "jpeg" or "png" + */ + format?: string; + /** + * Quality level (0..1). Only used for jpeg + */ + quality?: number; + /** + * Multiplier to scale by + */ + multiplier?: number; + /** + * Cropping left offset. Introduced in v1.2.14 + */ + left?: number; + /** + * Cropping top offset. Introduced in v1.2.14 + */ + top?: number; + /** + * Cropping width. Introduced in v1.2.14 + */ + width?: number; + /** + * Cropping height. Introduced in v1.2.14 + */ + height?: number; } -declare namespace fabric { - - var isLikelyNode: boolean; - var isTouchSupported: boolean; - - ///////////////////////////////////////////////////////////// - // farbic Functions - ///////////////////////////////////////////////////////////// - - function createCanvasForNode(width: number, height: number): ICanvas; - - // Parse - // ---------------------------------------------------------- - /** - * Creates markup containing SVG referenced elements like patterns, gradients etc. - * @param {fabric.Canvas} canvas instance of fabric.Canvas - */ - function createSVGRefElementsMarkup(canvas: IStaticCanvas): string; - /** - * Creates markup containing SVG font faces - * @param {Array} objects Array of fabric objects - */ - function createSVGFontFacesMarkup(objects: IObject[]): string; - /** - * Takes string corresponding to an SVG document, and parses it into a set of fabric objects - * @param {String} string - * @param {Function} callback - * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. - */ - function loadSVGFromString(string: string, callback: (results: IObject[], options: any) => void, reviver?: Function): void; - /** - * Takes url corresponding to an SVG document, and parses it into a set of fabric objects. - * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy) - * @param {String} url - * @param {Function} callback - * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. - */ - function loadSVGFromURL(url: string, callback: (results: IObject[], options: any) => void, reviver?: Function): void; - /** - * Returns CSS rules for a given SVG document - * @param {SVGDocument} doc SVG document to parse - */ - function getCSSRules(doc: SVGElement): any; - - function parseElements(elements: any[], callback: Function, options: any, reviver?: Function): void; - /** - * Parses "points" attribute, returning an array of values - * @param {String} points points attribute string - */ - function parsePointsAttribute(points: string): any[]; - /** - * Parses "style" attribute, retuning an object with values - * @param {SVGElement} element Element to parse - */ - function parseStyleAttribute(element: SVGElement): any; - /** - * Transforms an array of svg elements to corresponding fabric.* instances - * @param {Array} elements Array of elements to parse - * @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements) - * @param {Object} [options] Options object - * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. - */ - function parseElements(elements: any[], callback: Function, options?: any, reviver?: Function): void; - /** - * Returns an object of attributes' name/value, given element and an array of attribute names; - * Parses parent "g" nodes recursively upwards. - * @param {DOMElement} element Element to parse - * @param {Array} attributes Array of attributes to parse - */ - function parseAttributes(elemen: HTMLElement, attributes: string[], svgUid?: string): { [key: string]: string } - /** - * Parses an SVG document, returning all of the gradient declarations found in it - * @param {SVGDocument} doc SVG document to parse - */ - function getGradientDefs(doc: SVGElement): { [key: string]: any }; - /** - * Parses a short font declaration, building adding its properties to a style object - * @param {String} value font declaration - * @param {Object} oStyle definition - */ - function parseFontDeclaration(value: string, oStyle: any): void; - /** - * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback - * @param {SVGDocument} doc SVG document to parse - * @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document). - * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. - */ - function parseSVGDocument(doc: SVGElement, callback: (results: IObject[], options: any) => void, reviver?: Function): void; - /** - * Parses "transform" attribute, returning an array of values - * @param {String} attributeValue String containing attribute value - */ - function parseTransformAttribute(attributeValue: string): number[]; - - // fabric Log - // --------------- - /** - * Wrapper around `console.log` (when available) - */ - function log(...values: any[]): void; - /** - * Wrapper around `console.warn` (when available) - */ - function warn(...values: any[]): void; - - //////////////////////////////////////////////////// - // Classes - //////////////////////////////////////////////////// - var Canvas: ICanvasStatic; - var StaticCanvas: IStaticCanvasStatic; - - var Color: IColorStatic; - var Pattern: IPatternStatic; - var Intersection: IIntersectionStatic; - var Point: IPointStatic; - - var Circle: ICircleStatic; - var Ellipse: IEllipseStatic; - var Group: IGroupStatic; - var Image: IImageStatic; - var Line: ILineStatic; - var Object: IObjectStatic; - var Path: IPathStatic; - var PathGroup: IPathGroupStatic; - var Polygon: IPolygonStatic; - var Polyline: IPolylineStatic; - var Rect: IRectStatic; - var Shadow: IShadowStatic; - var Text: ITextStatic; - var IText: IITextStatic; - var Triangle: ITriangleStatic; - - var util: IUtil; - - /////////////////////////////////////////////////////////////////////////////// - // Data Object Interfaces - These intrface are not specific part of fabric, - // They are just helpful for for defining function paramters - ////////////////////////////////////////////////////////////////////////////// - interface IDataURLOptions { - /** - * The format of the output image. Either "jpeg" or "png" - */ - format?: string; - /** - * Quality level (0..1). Only used for jpeg - */ - quality?: number; - /** - * Multiplier to scale by - */ - multiplier?: number; - /** - * Cropping left offset. Introduced in v1.2.14 - */ - left?: number; - /** - * Cropping top offset. Introduced in v1.2.14 - */ - top?: number; - /** - * Cropping width. Introduced in v1.2.14 - */ - width?: number; - /** - * Cropping height. Introduced in v1.2.14 - */ - height?: number; - } - - interface IEvent { - e: Event; - target?: IObject; - } - - interface IFillOptions { - /** - * options.source Pattern source - */ - source: string | HTMLImageElement; - /** - * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) - */ - repeat?: string; - /** - * Pattern horizontal offset from object's left/top corner - */ - offsetX?: number; - /** - * Pattern vertical offset from object's left/top corner - */ - offsetY?: number; - } - - interface IToSVGOptions { - /** - * If true xml tag is not included - */ - suppressPreamble: boolean; - /** - * SVG viewbox object - */ - viewBox: IViewBox; - /** - * Encoding of SVG output - */ - encoding: string; - } - - interface IViewBox { - /** - * x-cooridnate of viewbox - */ - x: number; - /** - * y-coordinate of viewbox - */ - y: number; - /** - * Width of viewbox - */ - width: number; - /** - * Height of viewbox - */ - height: number; - } - - /////////////////////////////////////////////////////////////////////////////// - // Mixins Interfaces - ////////////////////////////////////////////////////////////////////////////// - interface ICollection { - /** - * Adds objects to collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * Objects should be instances of (or inherit from) fabric.Object - * @param {...fabric.Object} object Zero or more fabric instances - */ - add(...object: IObject[]): T; - - /** - * Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`) - * An object should be an instance of (or inherit from) fabric.Object - * @param {Object} object Object to insert - * @param {Number} index Index to insert object at - * @param {Boolean} nonSplicing When `true`, no splicing (shifting) of objects occurs - * @return {Self} thisArg - * @chainable - */ - insertAt(object: IObject, index: number, nonSplicing: boolean): T; - - /** - * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * @param {...fabric.Object} object Zero or more fabric instances - * @return {Self} thisArg - * @chainable - */ - remove(...object: IObject[]): T; - - /** - * Executes given function for each object in this group - * @param {Function} callback - * @param {Object} context Context (aka thisObject) - * @return {Self} thisArg - */ - forEachObject(callback: (element: IObject, index: number, array: IObject[]) => any, context?: any): T; - - /** - * Returns an array of children objects of this instance - * Type parameter introduced in 1.3.10 - * @param {String} [type] When specified, only objects of this type are returned - * @return {Array} - */ - getObjects(type?: string): IObject[]; - - /** - * Returns object at specified index - * @param {Number} index - * @return {Self} thisArg - */ - item(index: number): T; - - /** - * Returns true if collection contains no objects - * @return {Boolean} true if collection is empty - */ - isEmpty(): boolean; - - /** - * Returns a size of a collection (i.e: length of an array containing its objects) - * @return {Number} Collection size - */ - size(): number; - - /** - * Returns true if collection contains an object - * @param {Object} object Object to check against - * @return {Boolean} `true` if collection contains an object - */ - contains(object: IObject): boolean; - - /** - * Returns number representation of a collection complexity - * @return {Number} complexity - */ - complexity(): number; - } - - interface IObservable { - /** - * Observes specified event - * @param eventName Event name (eg. 'after:render') - * @param handler Function that receives a notification when an event of the specified type occurs - */ - on(eventName: string, handler: (e: IEvent) => any): T; - - /** - * Observes specified event - * @param eventName Object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) - */ - on(eventName: {[key:string] : Function}): T; - /** - * Fires event with an optional options object - * @param {String} eventName Event name to fire - * @param {Object} [options] Options object - */ - trigger(eventName: string, options?: any): T; - /** - * Stops event observing for a particular event handler. Calling this method - * without arguments removes all handlers for all events - * @param eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) - * @param handler Function to be deleted from EventListeners - */ - off(eventName?: string|any, handler?: (e: IEvent) => any): T; - } - - // animation mixin - // ---------------------------------------------------- - interface ICanvasAnimation { - FX_DURATION: number; - /** - * Centers object horizontally with animation. - * @param {fabric.Object} object Object to center - * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - */ - fxCenterObjectH(object: IObject, callbacks?: { onComplete: Function; onChange: Function; }): T; - - /** - * Centers object vertically with animation. - * @param {fabric.Object} object Object to center - * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - */ - fxCenterObjectV(object: IObject, callbacks?: { onComplete: Function; onChange: Function; }): T; - - /** - * Same as `fabric.Canvas#remove` but animated - * @param {fabric.Object} object Object to remove - * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - * @return {fabric.Canvas} thisArg - * @chainable - */ - fxRemove(object: IObject, callbacks?: { onComplete: Function; onChange: Function; }): T; - } - interface IObjectAnimation { - /** - * Animates object's properties - * object.animate('left', ..., {duration: ...}); - * @param property Property to animate - * @param value Value to animate property - * @param options The animation options - */ - animate(property: string, value: number|string, options?: IAnimationOptions): IObject; - /** - * Animates object's properties - * object.animate({ left: ..., top: ... }, { duration: ... }); - * @param properties Properties to animate - * @param value Options object - */ - animate(properties: any, options?: IAnimationOptions): IObject; - } - interface IAnimationOptions { - /** - * Allows to specify starting value of animatable property (if we don't want current value to be used). - */ - from?: string|number; - /** - * Defaults to 500 (ms). Can be used to change duration of an animation. - */ - duration?: number; - /** - * Callback; invoked on every value change - */ - onChange?: Function; - /** - * Callback; invoked when value change is completed - */ - onComplete?: Function; - - /** - * Easing function. Default: fabric.util.ease.easeInSine - */ - easing?: Function; - /** - * Value to modify the property by, default: end - start - */ - by?: number; - } - - /////////////////////////////////////////////////////////////////////////////// - // General Fabric Interfaces - ////////////////////////////////////////////////////////////////////////////// - interface IColor { - /** - * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1]) - */ - getSource(): number[]; - - /** - * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1]) - */ - setSource(source: number[]): void; - - /** - * Returns color represenation in RGB format ex: rgb(0-255,0-255,0-255) - */ - toRgb(): string; - - /** - * Returns color represenation in RGBA format ex: rgba(0-255,0-255,0-255,0-1) - */ - toRgba(): string; - - /** - * Returns color represenation in HSL format ex: hsl(0-360,0%-100%,0%-100%) - */ - toHsl(): string; - - /** - * Returns color represenation in HSLA format ex: hsla(0-360,0%-100%,0%-100%,0-1) - */ - toHsla(): string; - - /** - * Returns color represenation in HEX format ex: FF5555 - */ - toHex(): string; - - /** - * Gets value of alpha channel for this color - */ - getAlpha(): number; - - /** - * Sets value of alpha channel for this color - * @param {Number} alpha Alpha value 0-1 - */ - setAlpha(alpha: number): void; - - /** - * Transforms color to its grayscale representation - */ - toGrayscale(): IColor; - - /** - * Transforms color to its black and white representation - * @param {Number} threshold - */ - toBlackWhite(threshold: number): IColor; - /** - * Overlays color with another color - * @param {String|fabric.Color} otherColor - */ - overlayWith(otherColor: string|IColor): IColor; - } - interface IColorStatic { - /** - * Color class - * The purpose of Color is to abstract and encapsulate common color operations; - * @param {String} color optional in hex or rgb(a) format - */ - new (color?: string): IColor; - - /** - * Returns new color object, when given a color in RGB format - * @param {String} color Color value ex: rgb(0-255,0-255,0-255) - */ - fromRgb(color: string): IColor; - /** - * Returns new color object, when given a color in RGBA format - * @param {String} color Color value ex: rgb(0-255,0-255,0-255) - */ - fromRgba(color: string): IColor; - /** - * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format - * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%) - */ - sourceFromRgb(color: string): number[]; - /** - * Returns new color object, when given a color in HSL format - * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%) - */ - fromHsl(color: string): IColor; - /** - * Returns new color object, when given a color in HSLA format - * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%) - */ - fromHsla(color: string): IColor; - /** - * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format. - * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1) - */ - sourceFromHsl(color: string): number[]; - /** - * Returns new color object, when given a color in HEX format - * @param {String} color Color value ex: FF5555 - */ - fromHex(color: string): IColor; - - /** - * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format - * @param {String} color ex: FF5555 - */ - sourceFromHex(color: string): number[]; - /** - * Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5]) - * @param {Array} source - */ - fromSource(source: number[]): IColor; - prototype: any; - } - - interface IGradientOptions { - /** - * @param {String} [options.type] Type of gradient 'radial' or 'linear' - */ - type?: string; - /** - * x-coordinate of start point - */ - x1?: number; - /** - * y-coordinate of start point - */ - y1?: number; - /** - * x-coordinate of end point - */ - x2?: number; - /** - * y-coordinate of end point - */ - y2?: number; - /** - * Radius of start point (only for radial gradients) - */ - r1?: number; - /** - * Radius of end point (only for radial gradients) - */ - r2?: number; - /** - * Color stops object eg. {0:string; 1:string; - */ - colorStops?: any; - } - interface IGradient extends IGradientOptions { - /** - * Adds another colorStop - * @param {Object} colorStop Object with offset and color - */ - addColorStop(colorStop: any): IGradient; - /** - * Returns object representation of a gradient - */ - toObject(): any; - /** - * Returns SVG representation of an gradient - * @param {Object} object Object to create a gradient for - * @param {Boolean} normalize Whether coords should be normalized - * @return {String} SVG representation of an gradient (linear/radial) - */ - toSVG(object: IObject, normalize?: boolean): string; - - /** - * Returns an instance of CanvasGradient - * @param {CanvasRenderingContext2D} ctx Context to render on - */ - toLive(ctx: CanvasRenderingContext2D, object?: IPathGroup): CanvasGradient; - } - interface IGrandientStatic { - new (options?: IGradientOptions): IGradient; - /** - * Returns instance from an SVG element - * @param {SVGGradientElement} el SVG gradient element - * @param {fabric.Object} instance - */ - fromElement(el: SVGGradientElement, instance: IObject): IGradient; - /** - * Returns instance from its object representation - * @param {Object} obj - * @param {Object} [options] Options object - */ - fromObject(obj: any, options: any[]): IGradient; - } - - interface IIntersection { - /** - * Appends a point to intersection - */ - appendPoint(point: IPoint): void; - /** - * Appends points to intersection - */ - appendPoints(points: IPoint[]): void; - } - interface IIntersectionStatic { - /** - * Intersection class - */ - new (status?: string): void; - /** - * Checks if polygon intersects another polygon - */ - intersectPolygonPolygon(points1: IPoint[], points2: IPoint[]): IIntersection; - /** - * Checks if line intersects polygon - */ - intersectLinePolygon(a1: IPoint, a2: IPoint, points: IPoint[]): IIntersection; - /** - * Checks if one line intersects another - */ - intersectLineLine(a1: IPoint, a2: IPoint, b1: IPoint, b2: IPoint): IIntersection; - /** - * Checks if polygon intersects rectangle - */ - intersectPolygonRectangle(points: IPoint[], r1: number, r2: number): IIntersection; - } - - interface IPatternOptions { - /** - * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) - */ - repeat: string; - - /** - * Pattern horizontal offset from object's left/top corner - */ - offsetX: number; - - /** - * Pattern vertical offset from object's left/top corner - */ - offsetY: number; - /** - * The source for the pattern - */ - source: string|HTMLImageElement; - } - interface IPattern extends IPatternOptions { - new (options?: IPatternOptions): IPattern; - - initialise(options?: IPatternOptions): IPattern; - /** - * Returns an instance of CanvasPattern - */ - toLive(ctx: CanvasRenderingContext2D): IPattern; - - /** - * Returns object representation of a pattern - */ - toObject(): any; - /** - * Returns SVG representation of a pattern - * @param {fabric.Object} object - */ - toSVG(object: IObject): string; - } - interface IPatternStatic { - new (options?: IPatternOptions): IPattern; - prototype: any; - } - - interface IPoint { - x: number; - y: number; - /** - * Adds another point to this one and returns another one - * @param {fabric.Point} that - */ - add(that: IPoint): IPoint; - - /** - * Adds another point to this one - * @param {fabric.Point} that - */ - addEquals(that: IPoint): IPoint; - - /** - * Adds value to this point and returns a new one - * @param {Number} scalar - */ - scalarAdd(scalar: number): IPoint; - - /** - * Adds value to this point - * @param {Number} scalar - */ - scalarAddEquals(scalar: number): IPoint; - - /** - * Subtracts another point from this point and returns a new one - * @param {fabric.Point} that - */ - subtract(that: IPoint): IPoint; - - /** - * Subtracts another point from this point - * @param {fabric.Point} that - */ - subtractEquals(that: IPoint): IPoint; - - /** - * Subtracts value from this point and returns a new one - * @param {Number} scalar - */ - scalarSubtract(scalar: number): IPoint; - - /** - * Subtracts value from this point - * @param {Number} scalar - */ - scalarSubtractEquals(scalar: number): IPoint; - - /** - * Miltiplies this point by a value and returns a new one - * @param {Number} scalar - */ - multiply(scalar: number): IPoint; - - /** - * Miltiplies this point by a value - * @param {Number} scalar - */ - multiplyEquals(scalar: number): IPoint; - - /** - * Divides this point by a value and returns a new one - * @param {Number} scalar - */ - divide(scalar: number): IPoint; - - /** - * Divides this point by a value - * @param {Number} scalar - */ - divideEquals(scalar: number): IPoint; - - /** - * Returns true if this point is equal to another one - * @param {fabric.Point} that - */ - eq(that: IPoint): IPoint; - - /** - * Returns true if this point is less than another one - * @param {fabric.Point} that - */ - lt(that: IPoint): IPoint; - - /** - * Returns true if this point is less than or equal to another one - * @param {fabric.Point} that - */ - lte(that: IPoint): IPoint; - - /** - * Returns true if this point is greater another one - * @param {fabric.Point} that - */ - gt(that: IPoint): IPoint; - - /** - * Returns true if this point is greater than or equal to another one - * @param {fabric.Point} that - */ - gte(that: IPoint): IPoint; - - /** - * Returns new point which is the result of linear interpolation with this one and another one - * @param {fabric.Point} that - * @param {Number} t - */ - lerp(that: IPoint, t: number): IPoint; - - /** - * Returns distance from this point and another one - * @param {fabric.Point} that - */ - distanceFrom(that: IPoint): number; - - /** - * Returns the point between this point and another one - * @param {fabric.Point} that - */ - midPointFrom(that: IPoint): IPoint; - - /** - * Returns a new point which is the min of this and another one - * @param {fabric.Point} that - */ - min(that: IPoint): IPoint; - - /** - * Returns a new point which is the max of this and another one - * @param {fabric.Point} that - */ - max(that: IPoint): IPoint; - - /** - * Returns string representation of this point - */ - toString(): string; - - /** - * Sets x/y of this point - * @param {Number} x - * @param {Number} y - */ - setXY(x:number, y: number): IPoint; - - /** - * Sets x/y of this point from another point - * @param {fabric.Point} that - */ - setFromPoint(that: IPoint): IPoint; - - /** - * Swaps x/y of this point and another point - * @param {fabric.Point} that - */ - swap(that: IPoint): IPoint; - } - interface IPointStatic { - new (x: number, y: number): IPoint; - prototype: any; - } - - interface IShadowOptions { - /** - * Whether the shadow should affect stroke operations - */ - affectStrike: boolean; - /** - * Shadow blur - */ - blur: number; - /** - * Shadow color - */ - color: string; - /** - * Indicates whether toObject should include default values - */ - includeDefaultValues: boolean; - /** - * Shadow horizontal offset - */ - offsetX: number; - /** - * Shadow vertical offset - */ - offsetY: number; - } - interface IShadow extends IShadowOptions { - initialize(options?: IShadowOptions|string): IShadow; - /** - * Returns object representation of a shadow - */ - toObject(): IObject; - /** - * Returns a string representation of an instance, CSS3 text-shadow declaration - */ - toString(): string; - /** - * Returns SVG representation of a shadow - * @param {fabric.Object} object - */ - toSVG(object: IObject): string; - - /** - * Regex matching shadow offsetX, offsetY and blur, Static - */ - reOffsetsAndBlur: RegExp - } - interface IShadowStatic { - new (options?: IShadowOptions): IShadow; - reOffsetsAndBlur: RegExp; - } - - /////////////////////////////////////////////////////////////////////////////// - // Canvas Interfaces - ////////////////////////////////////////////////////////////////////////////// - interface ICanvasDimensions { - /** - * Width of canvas element - */ - width: number; - /** - * Height of canvas element - */ - height: number; - } - interface ICanvasDimensionsOptions { - /** - * Set the given dimensions only as canvas backstore dimensions - */ - backstoreOnly?: boolean; - /** - * Set the given dimensions only as css dimensions - */ - cssOnly?: boolean; - } - - interface IStaticCanvasOptions { - /** - * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas - */ - allowTouchScrolling?: boolean; - /** - * Indicates whether this canvas will use image smoothing, this is on by default in browsers - */ - imageSmoothingEnabled?: boolean; - - /** - * Indicates whether objects should remain in current stack position when selected. - * When false objects are brought to top and rendered as part of the selection group - */ - preserveObjectStacking?: boolean; - - /** - * The transformation (in the format of Canvas transform) which focuses the viewport - */ - viewportTransform?: number[]; - - freeDrawingColor?: string; - freeDrawingLineWidth?: number; - - /** - * Background color of canvas instance. - * Should be set via setBackgroundColor - */ - backgroundColor?: string|IPattern; - /** - * Background image of canvas instance. - * Should be set via setBackgroundImage - * Backwards incompatibility note: The "backgroundImageOpacity" and "backgroundImageStretch" properties are deprecated since 1.3.9. - */ - backgroundImage?: IImage | string; - backgroundImageOpacity?: number; - backgroundImageStretch?: number; - /** - * Function that determines clipping of entire canvas area - * Being passed context as first argument. See clipping canvas area - */ - clipTo?: (context: CanvasRenderingContext2D) => void; - - /** - * Indicates whether object controls (borders/controls) are rendered above overlay image - */ - controlsAboveOverlay?: boolean; - - /** - * Indicates whether toObject/toDatalessObject should include default values - */ - includeDefaultValues?: boolean; - /** - * Overlay color of canvas instance. - * Should be set via setOverlayColor - */ - overlayColor?: string|IPattern; - /** - * Overlay image of canvas instance. - * Should be set via setOverlayImage - * Backwards incompatibility note: The "overlayImageLeft" and "overlayImageTop" properties are deprecated since 1.3.9. - */ - overlayImage?: IImage; - overlayImageLeft?: number; - overlayImageTop?: number; - /** - * Indicates whether add, insertAt and remove should also re-render canvas. - * Disabling this option could give a great performance boost when adding/removing a lot of objects to/from canvas at once - * (followed by a manual rendering after addition/deletion) - */ - renderOnAddRemove?: boolean; - /** - * Indicates whether objects' state should be saved - */ - stateful?: boolean; - } - interface IStaticCanvas extends IObservable, IStaticCanvasOptions, ICollection, ICanvasAnimation { - /** - * Calculates canvas element offset relative to the document - * This method is also attached as "resize" event handler of window - */ - calcOffset(): IStaticCanvas; - - /** - * Sets {@link fabric.StaticCanvas#overlayImage|overlay image} for this canvas - * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set overlay to - * @param {Function} callback callback to invoke when image is loaded and set as an overlay - * @param {Object} [options] Optional options to set for the {@link fabric.Image|overlay image}. - */ - setOverlayImage(image: IImage|string, callback: Function, options?: IObjectOptions): IStaticCanvas; - - /** - * Sets {@link fabric.StaticCanvas#backgroundImage|background image} for this canvas - * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set background to - * @param {Function} callback Callback to invoke when image is loaded and set as background - * @param {Object} [options] Optional options to set for the {@link fabric.Image|background image}. - */ - setBackgroundImage(image: IImage|string, callback: Function, options?: IObjectOptions): IStaticCanvas; - - /** - * Sets {@link fabric.StaticCanvas#overlayColor|background color} for this canvas - * @param {(String|fabric.Pattern)} overlayColor Color or pattern to set background color to - * @param {Function} callback Callback to invoke when background color is set - */ - setOverlayColor(overlayColor: string|IPattern, callback: Function): IStaticCanvas; - - /** - * Sets {@link fabric.StaticCanvas#backgroundColor|background color} for this canvas - * @param {(String|fabric.Pattern)} backgroundColor Color or pattern to set background color to - * @param {Function} callback Callback to invoke when background color is set - */ - setBackgroundColor(backgroundColor: string|IPattern, callback: Function): IStaticCanvas; - - /** - * Returns canvas width (in px) - */ - getWidth(): number; - - /** - * Returns canvas height (in px) - */ - getHeight(): number; - - /** - * Sets width of this canvas instance - * @param {Number|String} value Value to set width to - * @param {Object} [options] Options object - */ - setWidth(value: number|string, options?: ICanvasDimensionsOptions): IStaticCanvas - - /** - * Sets height of this canvas instance - * @param {Number|String} value Value to set height to - * @param {Object} [options] Options object - */ - setHeight(value: number|string, options?: ICanvasDimensionsOptions): IStaticCanvas; - - /** - * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em) - * @param {Object} dimensions Object with width/height properties - * @param {Object} [options] Options object - */ - setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): IStaticCanvas; - - /** - * Returns canvas zoom level - */ - getZoom(): number; - - /** - * Sets viewport transform of this canvas instance - * @param {Array} vpt the transform in the form of context.transform - */ - setViewportTransform(vpt: number[]): IStaticCanvas; - - /** - * Sets zoom level of this canvas instance, zoom centered around point - * @param {fabric.Point} point to zoom with respect to - * @param {Number} value to set zoom to, less than 1 zooms out - */ - zoomToPoint(point: IPoint, value: number): IStaticCanvas; - - /** - * Sets zoom level of this canvas instance - * @param {Number} value to set zoom to, less than 1 zooms out - */ - setZoom(value: number): IStaticCanvas; - - /** - * Pan viewport so as to place point at top left corner of canvas - * @param {fabric.Point} point to move to - */ - absolutePan(point: IPoint): IStaticCanvas; - - /** - * Pans viewpoint relatively - * @param {fabric.Point} point (position vector) to move by - */ - relativePan(point: IPoint): IStaticCanvas; - - /** - * Returns element corresponding to this instance - */ - getElement(): HTMLCanvasElement; - - /** - * Returns currently selected object, if any - */ - getActiveObject(): IObject; - - /** - * Returns currently selected group of object, if any - */ - getActiveGroup(): IGroup; - - /** - * Clears specified context of canvas element - * @param {CanvasRenderingContext2D} ctx Context to clear - * @chainable - */ - clearContext(ctx: CanvasRenderingContext2D): IStaticCanvas; - - /** - * Returns context of canvas where objects are drawn - */ - getContext(): CanvasRenderingContext2D; - - /** - * Clears all contexts (background, main, top) of an instance - */ - clear(): IStaticCanvas; - - /** - * Renders both the top canvas and the secondary container canvas. - * @param {Boolean} [allOnTop] Whether we want to force all images to be rendered on the top canvas - * @chainable - */ - renderAll(allOnTop?: boolean): IStaticCanvas; - - /** - * Method to render only the top canvas. - * Also used to render the group selection box. - * @chainable - */ - renderTop(): IStaticCanvas; - - /** - * Returns coordinates of a center of canvas. - * Returned value is an object with top and left properties - */ - getCenter(): { top: number; left: number; }; - /** - * Centers object horizontally. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param {fabric.Object} object Object to center horizontally - */ - centerObjectH(object: IObject): IStaticCanvas; - - /** - * Centers object vertically. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param {fabric.Object} object Object to center vertically - */ - centerObjectV(object: IObject): IStaticCanvas; - - /** - * Centers object vertically and horizontally. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param {fabric.Object} object Object to center vertically and horizontally - */ - centerObject(object: IObject): IStaticCanvas; - - /** - * Returs dataless JSON representation of canvas - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toDatalessJSON(propertiesToInclude?: any[]): string; - - /** - * Returns object representation of canvas - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toObject(propertiesToInclude?: any[]): any; - - /** - * Returns dataless object representation of canvas - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toDatalessObject(propertiesToInclude?: any[]): any; - - /** - * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, - * a zoomed canvas will then produce zoomed SVG output. - */ - svgViewportTransformation: boolean; - - /** - * Returns SVG representation of canvas - * @param {Object} [options] Options object for SVG output - * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation. - */ - toSVG(options: IToSVGOptions, reviver?: Function): string; - - /** - * Moves an object to the bottom of the stack of drawn objects - * @param {fabric.Object} object Object to send to back - * @chainable - */ - sendToBack(object: IObject): IStaticCanvas; - - /** - * Moves an object to the top of the stack of drawn objects - * @param {fabric.Object} object Object to send - * @chainable - */ - bringToFront(object: IObject): IStaticCanvas; - - /** - * Moves an object down in stack of drawn objects - * @param {fabric.Object} object Object to send - * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object - * @chainable - */ - sendBackwards(object: IObject): IStaticCanvas; - - /** - * Moves an object up in stack of drawn objects - * @param {fabric.Object} object Object to send - * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object - * @chainable - */ - bringForward(object: IObject): IStaticCanvas; - /** - * Moves an object to specified level in stack of drawn objects - * @param {fabric.Object} object Object to send - * @param {Number} index Position to move to - * @chainable - */ - moveTo(object: IObject, index: number): IStaticCanvas; - - /** - * Clears a canvas element and removes all event listeners - */ - dispose(): IStaticCanvas; - - /** - * Returns a string representation of an instance - */ - toString(): string; - - /** - * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately - * @param {Object} [options] Options object - */ - toDataURL(options?: IDataURLOptions): string; - - /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param {String} methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - * @return {Boolean | null} `true` if method is supported (or at least exists), null` if canvas element or context can not be initialized - */ - supports(methodName: string): boolean; - - /** - * Populates canvas with data from the specified JSON. - * JSON format must conform to the one of toJSON formats - * @param {String|Object} json JSON string or object - * @param {Function} callback Callback, invoked when json is parsed - * and corresponding objects (e.g: {@link fabric.Image}) - * are initialized - * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. - */ - loadFromJSON(json: string|any, callback: Function, reviver?: Function): ICanvas; - /** - * Clones canvas instance - * @param {Object} [callback] Receives cloned instance as a first argument - * @param {Array} [properties] Array of properties to include in the cloned canvas and children - */ - clone(callback: (canvas: IStaticCanvas) => any, properties?: any[]): void; - - /** - * Clones canvas instance without cloning existing data. - * This essentially copies canvas dimensions, clipping properties, etc. - * but leaves data empty (so that you can populate it with your own) - * @param {Object} [callback] Receives cloned instance as a first argument - */ - cloneWithoutData(callback: (canvas: IStaticCanvas) => any): void; - - /** - * Callback; invoked right before object is about to be scaled/rotated - */ - onBeforeScaleRotate(target: IObject): void; - - // Functions from object straighten mixin - // -------------------------------------------------------------------------------------------------------------------------------- - - /** - * Straightens object, then rerenders canvas - * @param {fabric.Object} object Object to straighten - */ - straightenObject(object: IObject): IStaticCanvas - - /** - * Same as straightenObject, but animated - * @param {fabric.Object} object Object to straighten - */ - fxStraightenObject(object: IObject): IStaticCanvas - } - interface IStaticCanvasStatic { - /** - * Constructor - * @param {HTMLElement|String} element element to initialize instance on - * @param {Object} [options] Options object - */ - new (element: HTMLCanvasElement|string, options?: ICanvasOptions): IStaticCanvas; - - EMPTY_JSON: string; - /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param {String} methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - */ - supports(methodName: string): boolean; - prototype: any; - /** - * Returns JSON representation of canvas - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toJSON(propertiesToInclude?: any[]): string; - } - - interface ICanvasOptions extends IStaticCanvasOptions { - /** - * When true, objects can be transformed by one side (unproportionally) - */ - uniScaleTransform?: boolean; - - /** - * When true, objects use center point as the origin of scale transformation. - * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). - */ - centeredScaling?: boolean; - - /** - * When true, objects use center point as the origin of rotate transformation. - * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). - */ - centeredRotation?: boolean; - - /** - * Indicates that canvas is interactive. This property should not be changed. - */ - interactive?: boolean; - - /** - * Indicates whether group selection should be enabled - */ - selection?: boolean; - - /** - * Color of selection - */ - selectionColor?: string; - - /** - * Default dash array pattern - * If not empty the selection border is dashed - */ - selectionDashArray?: any[]; - - /** - * Color of the border of selection (usually slightly darker than color of selection itself) - */ - selectionBorderColor?: string; - - /** - * Width of a line used in object/group selection - */ - selectionLineWidth?: number; - - /** - * Default cursor value used when hovering over an object on canvas - */ - hoverCursor?: string; - - /** - * Default cursor value used when moving an object on canvas - */ - moveCursor?: string; - - /** - * Default cursor value used for the entire canvas - */ - defaultCursor?: string; - - /** - * Cursor value used during free drawing - */ - freeDrawingCursor?: string; - - /** - * Cursor value used for rotation point - */ - rotationCursor?: string; - - /** - * Default element class that's given to wrapper (div) element of canvas - */ - containerClass?: string; - - /** - * When true, object detection happens on per-pixel basis rather than on per-bounding-box - */ - perPixelTargetFind?: boolean; - - /** - * Number of pixels around target pixel to tolerate (consider active) during object detection - */ - targetFindTolerance?: number; - - /** - * When true, target detection is skipped when hovering over canvas. This can be used to improve performance. - */ - skipTargetFind?: boolean; - - /** - * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing. - * After mousedown, mousemove creates a shape, - * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas. - */ - isDrawingMode?: boolean; - } - interface ICanvas extends IStaticCanvas, ICanvasOptions { - _objects: IObject[]; - - /** - * Checks if point is contained within an area of given object - * @param {Event} e Event object - * @param {fabric.Object} target Object to test against - */ - containsPoint(e: Event, target: IObject): boolean; - /** - * Deactivates all objects on canvas, removing any active group or object - * @return {fabric.Canvas} thisArg - */ - deactivateAll(): ICanvas; - /** - * Deactivates all objects and dispatches appropriate events - * @param {Event} [e] Event (passed along when firing) - * @return {fabric.Canvas} thisArg - */ - deactivateAllWithDispatch(e?: Event): ICanvas; - /** - * Discards currently active group - * @param {Event} [e] Event (passed along when firing) - * @return {fabric.Canvas} thisArg - */ - discardActiveGroup(e?: Event): ICanvas; - /** - * Discards currently active object - * @param {Event} [e] Event (passed along when firing) - * @return {fabric.Canvas} thisArg - * @chainable - */ - discardActiveObject(e?: Event): ICanvas; - /** - * Draws objects' controls (borders/controls) - * @param {CanvasRenderingContext2D} ctx Context to render controls on - */ - drawControls(ctx: CanvasRenderingContext2D): void; - /** - * Method that determines what object we are clicking on - * @param {Event} e mouse event - * @param {Boolean} skipGroup when true, group is skipped and only objects are traversed through - */ - findTarget(e: MouseEvent, skipGroup: boolean): ICanvas; - /** - * Returns currently active group - * @return {fabric.Group} Current group - */ - getActiveGroup(): IGroup; - /** - * Returns currently active object - * @return {fabric.Object} active object - */ - getActiveObject(): IObject; - /** - * Returns pointer coordinates relative to canvas. - * @param {Event} e - * @return {Object} object with "x" and "y" number values - */ - getPointer(e: Event, ignoreZoom?: boolean, upperCanvasEl?: CanvasRenderingContext2D): { x: number; y: number; }; - /** - * Returns context of canvas where object selection is drawn - * @return {CanvasRenderingContext2D} - */ - getSelectionContext(): CanvasRenderingContext2D; - /** - * Returns element on which object selection is drawn - * @return {HTMLCanvasElement} - */ - getSelectionElement(): HTMLCanvasElement; - /** - * Returns true if object is transparent at a certain location - * @param {fabric.Object} target Object to check - * @param {Number} x Left coordinate - * @param {Number} y Top coordinate - */ - isTargetTransparent(target: IObject, x: number, y: number): boolean; - /** - * Sets active group to a speicified one - * @param {fabric.Group} group Group to set as a current one - * @param {Event} [e] Event (passed along when firing) - */ - setActiveGroup(group: IGroup, e?: Event): ICanvas; - /** - * Sets given object as the only active object on canvas - * @param {fabric.Object} object Object to set as an active one - * @param {Event} [e] Event (passed along when firing "object:selected") - */ - setActiveObject(object: IObject, e?: Event): ICanvas; - /** - * Set the cursor type of the canvas element - * @param {String} value Cursor type of the canvas element. - * @see http://www.w3.org/TR/css3-ui/#cursor - */ - setCursor(value: string): void; - - /** - * Removes all event listeners - */ - removeListeners(): void - } - interface ICanvasStatic { - /** - * Constructor - * @param {HTMLElement|String} element element to initialize instance on - * @param {Object} [options] Options object - */ - new (element: HTMLCanvasElement | string, options?: ICanvasOptions): ICanvas; - - EMPTY_JSON: string; - /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param {String} methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - */ - supports(methodName: string): boolean; - prototype: any; - /** - * Returns JSON representation of canvas - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toJSON(propertiesToInclude?: any[]): string; - } - - /////////////////////////////////////////////////////////////////////////////// - // Shape Interfaces - ////////////////////////////////////////////////////////////////////////////// - - interface ICircleOptions extends IObjectOptions { - /** - * Radius of this circle - */ - radius?: number; - /** - * Start angle of the circle, moving clockwise - */ - startAngle?: number; - - /** - * End angle of the circle - */ - endAngle?: number; - } - interface ICircle extends IObject, ICircleOptions { - /** - * Returns complexity of an instance - * @return {Number} complexity of this instance - */ - complexity(): number; - /** - * Returns horizontal radius of an object (according to how an object is scaled) - * @return {Number} - */ - getRadiusX(): number; - /** - * Returns vertical radius of an object (according to how an object is scaled) - * @return {Number} - */ - getRadiusY(): number; - /** - * Sets radius of an object (and updates width accordingly) - * @return {Number} - */ - setRadius(value: number): number; - - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface ICircleStatic { - /** - * List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement}) - */ - ATTRIBUTE_NAMES: string[]; - /** - * Returns Circle instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options: ICircleOptions): ICircle; - /** - * Returns Circle instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): ICircle; - /** - * Circle class - */ - new (options?: ICircleOptions): ICircle; - prototype: any; - } - - interface IEllipseOptions extends IObjectOptions { - /** - * Horizontal radius - */ - rx?: number; - /** - * Vertical radius - */ - ry?: number; - } - interface IEllipse extends IObject, IEllipseOptions { - /** - * Returns horizontal radius of an object (according to how an object is scaled) - * @return {Number} - */ - getRx(): number; - - /** - * Returns Vertical radius of an object (according to how an object is scaled) - * @return {Number} - */ - getRy(): number; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** - * Returns complexity of an instance - * @return {Number} complexity - */ - complexity(): number; - } - interface IEllipseStatic { - new (options?: IEllipseOptions): IEllipse; - /** - * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement}) - */ - ATTRIBUTE_NAMES: string[]; - - /** - * Returns Ellipse instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options?: IEllipseOptions): IEllipse; - - /** - * Returns Ellipse instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IEllipse; - } - - interface IGroup extends IObject, ICollection { - activateAllObjects(): IGroup; - /** - * Adds an object to a group; Then recalculates group's dimension, position. - * @param {Object} object - * @return {fabric.Group} thisArg - * @chainable - */ - addWithUpdate(object: IObject): IGroup; - containsPoint(point: IPoint): boolean; - /** - * Destroys a group (restoring state of its objects) - * @return {fabric.Group} thisArg - * @chainable - */ - destroy(): IGroup; - /** - * Returns requested property - * @param {String} prop Property to get - * @return {Any} - */ - get(prop: string): any; - /** - * Checks whether this group was moved (since `saveCoords` was called last) - * @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called) - */ - hasMoved(): boolean; - /** - * Removes an object from a group; Then recalculates group's dimension, position. - * @param {Object} object - * @return {fabric.Group} thisArg - * @chainable - */ - removeWithUpdate(object: IObject): IGroup; - /** - * Renders instance on a given context - * @param {CanvasRenderingContext2D} ctx context to render instance on - */ - render(ctx: CanvasRenderingContext2D): void; - /** - * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * @param {...fabric.Object} object Zero or more fabric instances - * @return {Self} thisArg - * @chainable - */ - remove(...object: IObject[]): IGroup; - /** - * Saves coordinates of this instance (to be used together with `hasMoved`) - * @saveCoords - * @return {fabric.Group} thisArg - * @chainable - */ - saveCoords(): IGroup; - /** - * Sets coordinates of all group objects - * @return {fabric.Group} thisArg - * @chainable - */ - setObjectsCoords(): IGroup; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns string represenation of a group - * @return {String} - */ - toString(): string; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface IGroupStatic { - /** - * Constructor - * @param {Object} objects Group objects - * @param {Object} [options] Options object - */ - new (items?: any[], options?: IObjectOptions): IGroup; - /** - * Returns {@link fabric.Group} instance from an object representation - * @param {Object} object Object to create a group from - * @param {Function} [callback] Callback to invoke when an group instance is created - */ - fromObject(object: any, callback: (group: IGroup) => any): void; - } - - interface IImageOptions extends IObjectOptions { - /** - * crossOrigin value (one of "", "anonymous", "allow-credentials") - */ - crossOrigin: string; - - /** - * AlignX value, part of preserveAspectRatio (one of "none", "mid", "min", "max") - * This parameter defines how the picture is aligned to its viewport when image element width differs from image width. - */ - alignX: string; - - /** - * AlignY value, part of preserveAspectRatio (one of "none", "mid", "min", "max") - * This parameter defines how the picture is aligned to its viewport when image element height differs from image height. - */ - alignY: string; - - /** - * meetOrSlice value, part of preserveAspectRatio (one of "meet", "slice"). - * if meet the image is always fully visibile, if slice the viewport is always filled with image. - * @see http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute - */ - meetOrSlice: string; - - /** - * Image filter array - */ - filters: IBaseFilter[]; - } - interface IImage extends IObject, IImageOptions { - initialize(element?: string|HTMLImageElement, options?: IImageOptions): void; - /** - * Applies filters assigned to this image (from "filters" array) - * @param {Function} callback Callback is invoked when all filters have been applied and new image is generated - */ - applyFilters(callback: Function): void; - /** - * Returns a clone of an instance - * @param {Function} callback Callback is invoked with a clone as a first argument - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - clone(callback?: Function, propertiesToInclude?: any[]): IObject; - /** - * Returns complexity of an instance - * @return {Number} complexity of this instance - */ - complexity(): number; - /** - * Returns image element which this instance if based on - * @return {HTMLImageElement} Image element - */ - getElement(): HTMLImageElement; - /** - * Returns original size of an image - * @return {Object} Object with "width" and "height" properties - */ - getOriginalSize(): { width: number; height: number; }; - /** - * Returns source of an image - * @return {String} Source of an image - */ - getSrc(): string; - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - - /** - * Sets image element for this instance to a specified one. - * If filters defined they are applied to new image. - * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area. - * @param {HTMLImageElement} element - * @param {Function} [callback] Callback is invoked when all filters have been applied and new image is generated - * @param {Object} [options] Options object - */ - setElement(element: HTMLImageElement, callback: Function, options: IImageOptions): IImage; - /** - * Sets crossOrigin value (on an instance and corresponding image element) - */ - setCrossOrigin(value: string): IImage; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} Object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns string representation of an instance - * @return {String} String representation of an instance - */ - toString(): string; - /** - * Returns SVG representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** - * Sets source of an image - * @param {String} src Source string (URL) - * @param {Function} [callback] Callback is invoked when image has been loaded (and all filters have been applied) - * @param {Object} [options] Options object - */ - setSrc(src: string, callback: Function, options: IImageOptions): IImage; - } - interface IImageStatic { - /** - * Constructor - * @param {HTMLImageElement | String} element Image element - * @param {Object} [options] Options object - */ - new (element: HTMLImageElement, objObjects: IObjectOptions): IImage; - /** - * Creates an instance of fabric.Image from an URL string - * @param {String} url URL to create an image from - * @param {Function} [callback] Callback to invoke when image is created (newly created image is passed as a first argument) - * @param {Object} [imgOptions] Options object - */ - fromURL(url: string, callback?: (image: IImage) => any, objObjects?: IObjectOptions): IImage; - /** - * Creates an instance of fabric.Image from its object representation - * @static - * @param {Object} object Object to create an instance from - * @param {Function} [callback] Callback to invoke when an image instance is created - */ - fromObject(object: any, callback: (image: IImage) => {}): void; - /** - * Returns Image instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Function} callback Callback to execute when fabric.Image object is created - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, callback: Function, options?: IImageOptions): void; - prototype: any; - /** - * Default CSS class name for canvas - */ - CSS_CANVAS: string; - - filters: IAllFilters - } - - interface ILineOptions extends IObjectOptions { - /** - * x value or first line edge - */ - x1: number; - /** - * x value or second line edge - */ - x2: number; - /** - * y value or first line edge - */ - y1: number; - /** - * y value or second line edge - */ - y2: number; - } - interface ILine extends IObject, ILineOptions { - /** - * Returns complexity of an instance - * @return {Number} complexity - */ - complexity(): number; - initialize(points?: number[], options?: ILineOptions): ILine; - /** - * Returns object representation of an instance - * @methd toObject - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude: any[]): any; - /** - * Returns SVG representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface ILineStatic { - ATTRIBUTE_NAMES: string[]; - /** - * Returns fabric.Line instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options?: ILineOptions): ILine; - /** - * Returns fabric.Line instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): ILine; - prototype: any; - /** - * Constructor - * @param {Array} [points] Array of points - * @param {Object} [options] Options object - */ - new (points?: number[], objObjects?: IObjectOptions): ILine; - } - - interface IObjectOptions { - /** - * Type of an object (rect, circle, path, etc.). - * Note that this property is meant to be read-only and not meant to be modified. - * If you modify, certain parts of Fabric (such as JSON loading) won't work correctly. - */ - type?: string; - - /** - * Horizontal origin of transformation of an object (one of "left", "right", "center") - */ - originX?: string; - - /** - * Vertical origin of transformation of an object (one of "top", "bottom", "center") - */ - originY?: string; - - /** - * Top position of an object. Note that by default it's relative to object center. You can change this by setting originY={top/center/bottom} - */ - top?: number; - - /** - * Left position of an object. Note that by default it's relative to object center. You can change this by setting originX={left/center/right} - */ - left?: number; - - /** - * Object width - */ - width?: number; - - /** - * Object height - */ - height?: number; - - /** - * Object scale factor (horizontal) - */ - scaleX?: number; - - /** - * Object scale factor (vertical) - */ - scaleY?: number; - - /** - * When true, an object is rendered as flipped horizontally - */ - flipX?: boolean; - - /** - * When true, an object is rendered as flipped vertically - */ - flipY?: boolean; - - /** - * Opacity of an object - */ - opacity?: number; - - /** - * Angle of rotation of an object (in degrees) - */ - angle?: number; - - /** - * Size of object's controlling corners (in pixels) - */ - cornerSize?: number; - - /** - * When true, object's controlling corners are rendered as transparent inside (i.e. stroke instead of fill) - */ - transparentCorners?: boolean; - - /** - * Default cursor value used when hovering over this object on canvas - */ - hoverCursor?: string; - - /** - * Padding between object and its controlling borders (in pixels) - */ - padding?: number; - - /** - * Color of controlling borders of an object (when it's active) - */ - borderColor?: string; - - /** - * Color of controlling corners of an object (when it's active) - */ - cornerColor?: string; - - /** - * When true, this object will use center point as the origin of transformation - * when being scaled via the controls. - * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). - */ - centeredScaling?: boolean; - - /** - * When true, this object will use center point as the origin of transformation - * when being rotated via the controls. - * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). - */ - centeredRotation?: boolean; - - /** - * Color of object's fill - */ - fill?: string; - - /** - * Fill rule used to fill an object - * accepted values are nonzero, evenodd - * Backwards incompatibility note: This property was used for setting globalCompositeOperation until v1.4.12, use `globalCompositeOperation` instead - */ - fillRule?: string; - - /** - * Composite rule used for canvas globalCompositeOperation - */ - globalCompositeOperation?: string; - - /** - * Background color of an object. Only works with text objects at the moment. - */ - backgroundColor?: string; - - /** - * When defined, an object is rendered via stroke and this property specifies its color - */ - stroke?: string; - - /** - * Width of a stroke used to render this object - */ - strokeWidth?: number; - - /** - * Array specifying dash pattern of an object's stroke (stroke must be defined) - */ - strokeDashArray?: any[]; - - /** - * Line endings style of an object's stroke (one of "butt", "round", "square") - */ - strokeLineCap?: string; - - /** - * Corner style of an object's stroke (one of "bevil", "round", "miter") - */ - strokeLineJoin?: string; - - /** - * Maximum miter length (used for strokeLineJoin = "miter") of an object's stroke - */ - strokeMiterLimit?: number; - - /** - * Shadow object representing shadow of this shape - */ - shadow?: IShadow|string; - - /** - * Opacity of object's controlling borders when object is active and moving - */ - borderOpacityWhenMoving?: number; - - /** - * Scale factor of object's controlling borders - */ - borderScaleFactor?: number; - - /** - * Transform matrix (similar to SVG's transform matrix) - */ - transformMatrix?: any[]; - - /** - * Minimum allowed scale value of an object - */ - minScaleLimit?: number; - - /** - * When set to `false`, an object can not be selected for modification (using either point-click-based or group-based selection). - * But events still fire on it. - */ - selectable?: boolean; - - /** - * When set to `false`, an object can not be a target of events. All events propagate through it. Introduced in v1.3.4 - */ - evented?: boolean; - - /** - * When set to `false`, an object is not rendered on canvas - */ - visible?: boolean; - - /** - * When set to `false`, object's controls are not displayed and can not be used to manipulate object - */ - hasControls?: boolean; - - /** - * When set to `false`, object's controlling borders are not rendered - */ - hasBorders?: boolean; - - /** - * When set to `false`, object's controlling rotating point will not be visible or selectable - */ - hasRotatingPoint?: boolean; - - /** - * Offset for object's controlling rotating point (when enabled via `hasRotatingPoint`) - */ - rotatingPointOffset?: number; - - /** - * When set to `true`, objects are "found" on canvas on per-pixel basis rather than according to bounding box - */ - perPixelTargetFind?: boolean; - - /** - * When `false`, default object's values are not included in its serialization - */ - includeDefaultValues?: boolean; - - /** - * Function that determines clipping of an object (context is passed as a first argument) - * Note that context origin is at the object's center point (not left/top corner) - * @type Function - */ - clipTo?: Function; - - /** - * When `true`, object horizontal movement is locked - */ - lockMovementX?: boolean; - - /** - * When `true`, object vertical movement is locked - */ - lockMovementY?: boolean; - - /** - * When `true`, object rotation is locked - */ - lockRotation?: boolean; - - /** - * When `true`, object horizontal scaling is locked - */ - lockScalingX?: boolean; - - /** - * When `true`, object vertical scaling is locked - */ - lockScalingY?: boolean; - - /** - * When `true`, object non-uniform scaling is locked - */ - lockUniScaling?: boolean; - - /** - * When `true`, object cannot be flipped by scaling into negative values - */ - lockScalingFlip?: boolean; - - /** - * Not used by fabric, just for convenience - */ - name?: string; - - /** - * Not used by fabric, just for convenience - */ - data?: any; - } - interface IObject extends IObservable, IObjectOptions, IObjectAnimation { - getCurrentWidth(): number; - getCurrentHeight(): number; - - getAngle(): number; - setAngle(value: number): IObject; - - getBorderColor(): string; - setBorderColor(value: string): IObject; - - getBorderScaleFactor(): number; - - getCornersize(): number; - setCornersize(value: number): IObject; - - getFill(): string; - setFill(value: string): IObject; - - getFillRule(): string; - setFillRule(value: string): IObject; - - getFlipX(): boolean; - setFlipX(value: boolean): IObject; - - getFlipY(): boolean; - setFlipY(value: boolean): IObject; - - getHeight(): number; - setHeight(value: number): IObject; - - getLeft(): number; - setLeft(value: number): IObject; - - getOpacity(): number; - setOpacity(value: number): IObject; - - overlayFill: string; - getOverlayFill(): string; - setOverlayFill(value: string): IObject; - - getScaleX(): number; - setScaleX(value: number): IObject; - - getScaleY(): number; - setScaleY(value: number): IObject; - - setShadow(options: any): IObject; - getShadow(): IObject; - - stateProperties: any[]; - getTop(): number; - setTop(value: number): IObject; - - getWidth(): number; - setWidth(value: number): IObject; - - /* * Sets object's properties from options - * @param {Object} [options] Options object - */ - setOptions(options: any): void; - - /** - * Transforms context when rendering an object - * @param {CanvasRenderingContext2D} ctx Context - * @param {Boolean} fromLeft When true, context is transformed to object's top/left corner. This is used when rendering text on Node - */ - transform(ctx: CanvasRenderingContext2D, fromLeft: boolean): void; - - /** - * Returns an object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toObject(propertiesToInclude?: any[]): any; - - /** - * Returns (dataless) object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toDatalessObject(propertiesToInclude?: any[]): any; - - /** - * Returns a string representation of an instance - */ - toString(): string; - - /** - * Basic getter - * @param {String} property Property name - */ - get(property: string): any; - - /** - * Sets property to a given value. - * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. - * If you need to update those, call `setCoords()`. - * @param {String} key Property name - * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one) - */ - set(key: string, value: any|Function): IObject; - /** - * Sets property to a given value. - * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. - * If you need to update those, call `setCoords()`. - * @param Object key Property object, iterate over the object properties - */ - set(key: any): IObject; - - /** - * Toggles specified property from `true` to `false` or from `false` to `true` - * @param {String} property Property to toggle - */ - toggle(property: string): IObject; - - /** - * Sets sourcePath of an object - * @param {String} value Value to set sourcePath to - */ - setSourcePath(value: string): IObject; - - /** - * Retrieves viewportTransform from Object's canvas if possible - */ - getViewportTransform(): boolean; - - /** - * Renders an object on a specified context - * @param {CanvasRenderingContext2D} ctx Context to render on - * @param {Boolean} [noTransform] When true, context is not transformed - */ - render(ctx: CanvasRenderingContext2D, noTransform?: boolean): void; - - /** - * Clones an instance - * @param {Function} callback Callback is invoked with a clone as a first argument - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - clone(callback: Function, propertiesToInclude?: any[]): IObject; - - /** - * Creates an instance of fabric.Image out of an object - * @param {Function} callback callback, invoked with an instance as a first argument - */ - cloneAsImage(callback: (image: IImage) => any): IObject; - - /** - * Converts an object into a data-url-like string - * @param options Options object - */ - toDataURL(options: IDataURLOptions): string; - - /** - * Returns true if specified type is identical to the type of an instance - * @param {String} type Type to check against - */ - isType(type: string): boolean; - - /** - * Returns complexity of an instance - */ - complexity(): number; - - /** - * Returns a JSON representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toJSON(propertiesToInclude?: any[]): any; - - /** - * Sets gradient (fill or stroke) of an object - * Backwards incompatibility note: This method was named "setGradientFill" until v1.1.0 - * @param {String} property Property name 'stroke' or 'fill' - * @param {Object} [options] Options object - */ - setGradient(property: string, options: IGradientOptions): IObject; - /** - * Sets pattern fill of an object - * @param {Object} options Options object - */ - setPatternFill(options: IFillOptions): IObject; - - /** - * Sets shadow of an object - * @param {String} [options] Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)") - */ - setShadow(options?: string): IObject; - /** - * Sets shadow of an object - * @param [options] Options object - */ - setShadow(options: IShadow): IObject; - - /** - * Sets "color" of an instance (alias of `set('fill', …)`) - * @param {String} color Color value - */ - setColor(color: string): IObject; - - /** - * Sets "angle" of an instance - * @param {Number} angle Angle value - */ - setAngle(angle: number): IObject; - - /** - * Sets "angle" of an instance - * @param {Number} angle Angle value - */ - rotate(angle: number): IObject; - - /** - * Centers object horizontally on canvas to which it was added last. - * You might need to call `setCoords` on an object after centering, to update controls area. - */ - centerH(): void; - - /** - * Centers object vertically on canvas to which it was added last. - * You might need to call `setCoords` on an object after centering, to update controls area. - */ - centerV(): void; - - /** - * Centers object vertically and horizontally on canvas to which is was added last - * You might need to call `setCoords` on an object after centering, to update controls area. - */ - center(): void; - - /** - * Removes object from canvas to which it was added last - */ - remove(): IObject; - - /** - * Returns coordinates of a pointer relative to an object - * @param {Event} e Event to operate upon - * @param {Object} [pointer] Pointer to operate upon (instead of event) - */ - getLocalPointer(e: Event, pointer: any): any; - - /** - * Sets object's properties from options - * @param {Object} [options] Options object - */ - setOptions(options: any): void; - /** - * Sets sourcePath of an object - * @param {String} value Value to set sourcePath to - */ - setSourcePath(value: string): IObject; - // functions from object svg export mixin - // ----------------------------------------------------------------------------------------------------------------------------------- - /** - * Returns styles-string for svg-export - */ - getSvgStyles(): string; - /** - * Returns transform-string for svg-export - */ - getSvgTransform(): string; - /** - * Returns transform-string for svg-export from the transform matrix of single elements - */ - getSvgTransformMatrix(): string; - - // functions from stateful mixin - // ----------------------------------------------------------------------------------------------------------------------------------- - /** - * Returns true if object state (one of its state properties) was changed - */ - hasStateChanged(): boolean; - /** - * Saves state of an object - * @param {Object} [options] Object with additional `stateProperties` array to include when saving state - * @return {fabric.Object} thisArg - */ - saveState(options?: { stateProperties: any[] }): IObject; - /** - * Setups state of an object - */ - setupState(): IObject; - // functions from object straightening mixin - // ----------------------------------------------------------------------------------------------------------------------------------- - /** - * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) - */ - straighten(): IObject; - /** - * Same as straighten but with animation - * @param {Object} callbacks Object with callback functions - * @param {Function} [callbacks.onComplete] Invoked on completion - * @param {Function} [callbacks.onChange] Invoked on every step of animation - */ - fxStraighten(callbacks: { onComplete?: Function; onChange: Function }): IObject; - - // functions from object stacking mixin - // ----------------------------------------------------------------------------------------------------------------------------------- - /** - * Moves an object up in stack of drawn objects - * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object - */ - bringForward(intersecting?: boolean): IObject; - /** - * Moves an object to the top of the stack of drawn objects - */ - bringToFront(): IObject; - /** - * Moves an object down in stack of drawn objects - * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object - */ - sendBackwards(intersecting?: boolean): IObject; - /** - * Moves an object to the bottom of the stack of drawn objects - */ - sendToBack(): IObject; - /** - * Moves an object to specified level in stack of drawn objects - * @param {Number} index New position of object - */ - moveTo(index: number): IObject; - - // functions from object origin mixin - // ----------------------------------------------------------------------------------------------------------------------------------- - /** - * Translates the coordinates from origin to center coordinates (based on the object's dimensions) - * @param {fabric.Point} point The point which corresponds to the originX and originY params - * @param {String} originX Horizontal origin: 'left', 'center' or 'right' - * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' - */ - translateToCenterPoint(point: IPoint, originX: string, originY: string): IPoint; - - /** - * Translates the coordinates from center to origin coordinates (based on the object's dimensions) - * @param {fabric.Point} center The point which corresponds to center of the object - * @param {String} originX Horizontal origin: 'left', 'center' or 'right' - * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' - */ - translateToOriginPoint(center: IPoint, originX: string, originY: string): IPoint; - /** - * Returns the real center coordinates of the object - */ - getCenterPoint(): IPoint; - - /** - * Returns the coordinates of the object as if it has a different origin - * @param {String} originX Horizontal origin: 'left', 'center' or 'right' - * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' - */ - getPointByOrigin(): IPoint; - - /** - * Returns the point in local coordinates - * @param {fabric.Point} point The point relative to the global coordinate system - * @param {String} originX Horizontal origin: 'left', 'center' or 'right' - * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' - */ - toLocalPoint(point: IPoint, originX: string, originY: string): IPoint; - - /** - * Sets the position of the object taking into consideration the object's origin - * @param {fabric.Point} pos The new position of the object - * @param {String} originX Horizontal origin: 'left', 'center' or 'right' - * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' - * @return {void} - */ - setPositionByOrigin(pos: IPoint, originX: string, originY: string): void; - - /** - * @param {String} to One of 'left', 'center', 'right' - */ - adjustPosition(to: string): void; - - // functions from interactivity mixin - // ----------------------------------------------------------------------------------------------------------------------------------- - /**- - * Draws borders of an object's bounding box. - * Requires public properties: width, height - * Requires public options: padding, borderColor - * @param {CanvasRenderingContext2D} ctx Context to draw on - */ - drawBorders(context: CanvasRenderingContext2D): IObject; - - /** - * Draws corners of an object's bounding box. - * Requires public properties: width, height - * Requires public options: cornerSize, padding - * @param {CanvasRenderingContext2D} ctx Context to draw on - */ - drawCorners(context: CanvasRenderingContext2D): IObject; - - /** - * Returns true if the specified control is visible, false otherwise. - * @param {String} controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. - */ - isControlVisible(controlName: string): boolean; - /** - * Sets the visibility of the specified control. - * @param {String} controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. - * @param {Boolean} visible true to set the specified control visible, false otherwise - */ - setControlVisible(controlName: string, visible: boolean): IObject; - - /** - * Sets the visibility state of object controls. - * @param {Object} [options] Options object - */ - setControlsVisibility(options?: { - bl?: boolean; - br?: boolean; - mb?: boolean; - ml?: boolean; - mr?: boolean; - mt?: boolean; - tl?: boolean; - tr?: boolean; - mtr?: boolean; }): IObject; - - // functions from geometry mixin - // ------------------------------------------------------------------------------------------------------------------------------- - /** - * Sets corner position coordinates based on current angle, width and height - * See https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords - */ - setCoords(): IObject; - /** - * Returns coordinates of object's bounding rectangle (left, top, width, height) - * @return {Object} Object with left, top, width, height properties - */ - getBoundingRect(): { left: number; top: number; width: number; height: number }; - /** - * Checks if object is fully contained within area of another object - * @param {Object} other Object to test - */ - isContainedWithinObject(other: IObject): boolean; - /** - * Checks if object is fully contained within area formed by 2 points - * @param {Object} pointTL top-left point of area - * @param {Object} pointBR bottom-right point of area - */ - isContainedWithinRect(pointTL: any, pointBR: any): boolean; - /** - * Checks if point is inside the object - * @param {fabric.Point} point Point to check against - */ - containsPoint(point: IPoint): boolean; - /** - * Scales an object (equally by x and y) - * @param {Number} value Scale factor - * @return {fabric.Object} thisArg - */ - scale(value: number): IObject; - /** - * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) - * @param {Number} value New height value - */ - scaleToHeight(value: number): IObject; - /** - * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) - * @param {Number} value New width value - */ - scaleToWidth(value: number): IObject; - /** - * Checks if object intersects with another object - * @param {Object} other Object to test - */ - intersectsWithObject(other: IObject): boolean; - /** - * Checks if object intersects with an area formed by 2 points - * @param {Object} pointTL top-left point of area - * @param {Object} pointBR bottom-right point of area - */ - intersectsWithRect(pointTL: any, pointBR: any): boolean; - } - interface IObjectStatic { - prototype: any; - } - - interface IPathOptions extends IObjectOptions { - /** - * Array of path points - */ - path?: any[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; - } - interface IPath extends IObject, IPathOptions { - initialize(path?: any[], options?: IPathOptions): IPath; - - /** - * Returns number representation of an instance complexity - * @return {Number} complexity of this instance - */ - complexity(): number; - - /** - * Renders path on a specified context - * @param {CanvasRenderingContext2D} ctx context to render path on - * @param {Boolean} [noTransform] When true, context is not transformed - */ - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns dataless object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toDatalessObject(propertiesToInclude?: any[]): any; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns string representation of an instance - * @return {String} string representation of an instance - */ - toString(): string; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface IPathStatic { - /** - * Creates an instance of fabric.Path from an SVG element - * @param {SVGElement} element to parse - * @param {Function} callback Callback to invoke when an fabric.Path instance is created - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, callback: (path: IPath) => any, options?: IPathOptions): void; - /** - * Creates an instance of fabric.Path from an object - * @param {Object} object - * @param {Function} callback Callback to invoke when an fabric.Path instance is created - */ - fromObject(object: any, callback: (path: IPath) => any): void; - /** - * Constructor - * @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens) - * @param {Object} [options] Options object - */ - new (path?: string|any[], options?: IPathOptions): IPath; - } - - interface IPathGroup extends IObject { - initialize(paths: IPath[], options?: IObjectOptions): void; - /** - * Returns number representation of object's complexity - * @return {Number} complexity - */ - complexity(): number; - /** - * Returns true if all paths in this group are of same color - * @return {Boolean} true if all paths are of the same color (`fill`) - */ - isSameColor(): boolean; - /** - * Renders this group on a specified context - * @param {CanvasRenderingContext2D} ctx Context to render this instance on - */ - render(ctx: CanvasRenderingContext2D): void; - /** - * Returns dataless object representation of this path group - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} dataless object representation of an instance - */ - toDatalessObject(propertiesToInclude?: any[]): any; - /** - * Returns object representation of this path group - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns a string representation of this path group - * @return {String} string representation of an object - */ - toString(): string; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** - * Returns all paths in this path group - * @return {Array} array of path objects included in this path group - */ - getObjects(): IPath[]; - } - interface IPathGroupStatic { - fromObject(object: any): IPathGroup; - /** - * Constructor - * @param {Array} paths - * @param {Object} [options] Options object - */ - new (paths: IPath[], options?: IObjectOptions): IPathGroup; - /** - * Creates fabric.PathGroup instance from an object representation - * @static - * @memberOf fabric.PathGroup - * @param {Object} object Object to create an instance from - * @param {Function} callback Callback to invoke when an fabric.PathGroup instance is created - */ - fromObject(object: any, callback: (group: IPathGroup) => any): void; - prototype: any; - } - - interface IPolygonOptions extends IObjectOptions { - /** - * Points array - */ - points?: IPoint[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; - } - interface IPolygon extends IObject, IPolygonOptions { - /** - * Returns complexity of an instance - * @return {Number} complexity of this instance - */ - complexity(): number; - - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface IPolygonStatic { - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) - */ - ATTRIBUTE_NAMES: string[]; - - /** - * Returns Polygon instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options?: IPolygonOptions): IPolygon; - /** - * Returns fabric.Polygon instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IPolygon; - /** - * Constructor - * @param {Array} points Array of points - * @param {Object} [options] Options object - */ - new (points: { x: number; y: number }[], options?: IObjectOptions, skipOffset?: boolean): IPolygon; - prototype: any; - } - - interface IPolylineOptions extends IObjectOptions { - /** - * Points array - */ - points?: IPoint[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; - } - interface IPolyline extends IObject, IPolylineOptions { - initialize(points: IPoint[], options?: IPolylineOptions): void; - /** - * Returns complexity of an instance - * @return {Number} complexity of this instance - */ - complexity(): number; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} Object representation of an instance - */ - toObject(propertiesToInclude?: any[]): any; - /** - * Returns SVG representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface IPolylineStatic { - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) - */ - ATTRIBUTE_NAMES: string[]; - - /** - * Returns Polyline instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options?: IPolylineOptions): IPolyline; - /** - * Returns fabric.Polyline instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IPolyline; - /** - * Constructor - * @param {Array} points Array of points (where each point is an object with x and y) - * @param {Object} [options] Options object - * @param {Boolean} [skipOffset] Whether points offsetting should be skipped - */ - new (points: { x: number; y: number }[], options?: IPolylineOptions): IPolyline; - prototype: any; - } - - interface IRectOptions extends IObjectOptions { - x?: number; - y?: number; - /** - * Horizontal border radius - */ - rx?: number; - - /** - * Vertical border radius - */ - ry?: number; - - } - interface IRect extends IObject, IRectOptions { - initialize(points?: number[], options?: any): IRect; - /** - * Returns complexity of an instance - * @return {Number} complexity - */ - complexity(): number; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude: any[]): any; - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface IRectStatic { - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) - */ - ATTRIBUTE_NAMES: string[]; - /** - * Returns Rect instance from an SVG element - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options?: IRectOptions): IRect; - /** - * Returns Rect instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IRect; - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: IRectOptions): IRect; - prototype: any; - } - - interface ITextOptions extends IObjectOptions { - /** - * Font size (in pixels) - */ - fontSize?: number; - /** - * Font weight (e.g. bold, normal, 400, 600, 800) - */ - fontWeight?: number|string; - /** - * Font family - */ - fontFamily?: string; - /** - * Text decoration Possible values?: "", "underline", "overline" or "line-through". - */ - textDecoration?: string; - /** - * Text alignment. Possible values?: "left", "center", or "right". - */ - textAlign?: string; - /** - * Font style . Possible values?: "", "normal", "italic" or "oblique". - */ - fontStyle?: string; - /** - * Line height - */ - lineHeight?: number; - /** - * When defined, an object is rendered via stroke and this property specifies its color. - * Backwards incompatibility note?: This property was named "strokeStyle" until v1.1.6 - */ - stroke?: string; - /** - * Shadow object representing shadow of this shape. - * Backwards incompatibility note?: This property was named "textShadow" (String) until v1.2.11 - */ - shadow?: IShadow|string; - /** - * Background color of text lines - */ - textBackgroundColor?: string; - - path?: string; - useNative?: Boolean; - text?: string; - } - interface IText extends IObject, ITextOptions { - /** - * Returns complexity of an instance - */ - complexity(): number; - /** - * Returns string representation of an instance - */ - toString(): string; - /** - * Renders text instance on a specified context - * @param {CanvasRenderingContext2D} ctx Context to render on - */ - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns object representation of an instance - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toObject(propertiesToInclude?: any[]): IObject; - /** - * Returns SVG representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - */ - toSVG(reviver?: Function): string; - /** - * Retrieves object's fontSize - */ - getFontSize(): number; - /** - * Sets object's fontSize - * @param {Number} fontSize Font size (in pixels) - */ - setFontSize(fontSize: number): IText; - /** - * Retrieves object's fontWeight - */ - getFontWeight(): number|string; - /** - * Sets object's fontWeight - * @param {(Number|String)} fontWeight Font weight - */ - setFontWeight(fontWeight: string|number): IText; - /** - * Retrieves object's fontFamily - */ - getFontFamily(): string; - /** - * Sets object's fontFamily - * @param {String} fontFamily Font family - */ - setFontFamily(fontFamily: string): IText; - /** - * Retrieves object's text - */ - getText(): string; - /** - * Sets object's text - * @param {String} text Text - */ - setText(text: string): IText; - /** - * Retrieves object's textDecoration - */ - getTextDecoration(): string; - /** - * Sets object's textDecoration - * @param {String} textDecoration Text decoration - */ - setTextDecoration(textDecoration: string): IText; - /** - * Retrieves object's fontStyle - */ - getFontStyle(): string; - /** - * Sets object's fontStyle - * @param {String} fontStyle Font style - */ - setFontStyle(fontStyle: string): IText; - /** - * Retrieves object's lineHeight - */ - getLineHeight(): number; - /** - * Sets object's lineHeight - * @param {Number} lineHeight Line height - */ - setLineHeight(lineHeight: number): IText; - /** - * Retrieves object's textAlign - */ - getTextAlign(): string; - /** - * Sets object's textAlign - * @param {String} textAlign Text alignment - */ - setTextAlign(textAlign: string): IText; - /** - * Retrieves object's textBackgroundColor - */ - getTextBackgroundColor(): string; - /** - * Sets object's textBackgroundColor - * @param {String} textBackgroundColor Text background color - */ - setTextBackgroundColor(textBackgroundColor: string): IText; - } - interface ITextStatic { - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Text.fromElement`) - */ - ATTRIBUTE_NAMES: string[]; - /** - * Default SVG font size - */ - DEFAULT_SVG_FONT_SIZE: number; - /** - * Constructor - * @param {String} text Text string - * @param {Object} [options] Options object - */ - new (text: string, options?: ITextOptions): IText; - - /** - * Returns fabric.Text instance from an SVG element (not yet implemented) - * @param {SVGElement} element Element to parse - * @param {Object} [options] Options object - */ - fromElement(element: SVGElement, options?: ITextOptions): IText; - /** - * Returns fabric.Text instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IText; - } - - interface IITextOptions extends IObjectOptions, ITextOptions { - /** - * Index where text selection starts (or where cursor is when there is no selection) - */ - selectionStart?: number; - - /** - * Index where text selection ends - */ - selectionEnd?: number; - - /** - * Color of text selection - */ - selectionColor?: string; - - /** - * Indicates whether text is in editing mode - */ - isEditing?: boolean; - - /** - * Indicates whether a text can be edited - */ - editable?: boolean; - - /** - * Border color of text object while it's in editing mode - */ - editingBorderColor?: string; - - /** - * Width of cursor (in px) - */ - cursorWidth?: number; - - /** - * Color of default cursor (when not overwritten by character style) - */ - cursorColor?: string; - - /** - * Delay between cursor blink (in ms) - */ - cursorDelay?: number; - - /** - * Duration of cursor fadein (in ms) - */ - cursorDuration?: number; - - /** - * Object containing character styles - * (where top-level properties corresponds to line number and 2nd-level properties -- to char number in a line) - */ - styles?: any; - - /** - * Indicates whether internal text char widths can be cached - */ - caching?: boolean; - } - interface IIText extends IObject, IText, IITextOptions { - /** - * Returns true if object has no styling - */ - isEmptyStyles(): boolean; - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns object representation of an instance - * @method toObject - * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return {Object} object representation of an instance - */ - toObject(propertiesToInclude?: any[]): IObject; - - setText(value: string): IText; - /** - * Sets selection start (left boundary of a selection) - * @param {Number} index Index to set selection start to - */ - setSelectionStart(index: number): void; - /** - * Sets selection end (right boundary of a selection) - * @param {Number} index Index to set selection end to - */ - setSelectionEnd(index: number): void; - /** - * Gets style of a current selection/cursor (at the start position) - * @param {Number} [startIndex] Start index to get styles at - * @param {Number} [endIndex] End index to get styles at - * @return {Object} styles Style object at a specified (or current) index - */ - getSelectionStyles(startIndex: number, endIndex: number): any; - /** - * Sets style of a current selection - * @param {Object} [styles] Styles object - * @return {fabric.IText} thisArg - * @chainable - */ - setSelectionStyles(styles: any): IText; - - /** - * Renders cursor or selection (depending on what exists) - */ - renderCursorOrSelection(): void; - - /** - * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) - * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. - */ - get2DCursorLocation(selectionStart?: number): void; - /** - * Returns complete style of char at the current cursor - * @param {Number} lineIndex Line index - * @param {Number} charIndex Char index - * @return {Object} Character style - */ - getCurrentCharStyle(lineIndex: number, charIndex: number): any; - - /** - * Returns fontSize of char at the current cursor - * @param {Number} lineIndex Line index - * @param {Number} charIndex Char index - * @return {Number} Character font size - */ - getCurrentCharFontSize(lineIndex: number, charIndex: number): number; - - /** - * Returns color (fill) of char at the current cursor - * @param {Number} lineIndex Line index - * @param {Number} charIndex Char index - * @return {String} Character color (fill) - */ - getCurrentCharColor(lineIndex: number, charIndex: number): string; - /** - * Renders cursor - * @param {Object} boundaries - */ - renderCursor(boundaries: any): void; - - /** - * Renders text selection - * @param {Array} chars Array of characters - * @param {Object} boundaries Object with left/top/leftOffset/topOffset - */ - renderSelection(chars: string[], boundaries: any): void; - - // functions from itext behavior mixin - // ------------------------------------------------------------------------------------------------------------------------ - /** - * Initializes all the interactive behavior of IText - */ - initBehavior(): void; - - /** - * Initializes "selected" event handler - */ - initSelectedHandler(): void; - - /** - * Initializes "added" event handler - */ - initAddedHandler(): void; - - initRemovedHandler(): void; - - /** - * Initializes delayed cursor - */ - initDelayedCursor(restart: boolean): void; - - /** - * Aborts cursor animation and clears all timeouts - */ - abortCursorAnimation(): void; - - /** - * Selects entire text - */ - selectAll(): void; - - /** - * Returns selected text - */ - getSelectedText(): string; - - /** - * Find new selection index representing start of current word according to current selection index - * @param {Number} startFrom Surrent selection index - * @return {Number} New selection index - */ - findWordBoundaryLeft(startFrom: number): number; - - /** - * Find new selection index representing end of current word according to current selection index - * @param {Number} startFrom Current selection index - * @return {Number} New selection index - */ - findWordBoundaryRight(startFrom: number): number; - - /** - * Find new selection index representing start of current line according to current selection index - * @param {Number} startFrom Current selection index - */ - findLineBoundaryLeft(startFrom: number): number; - - /** - * Find new selection index representing end of current line according to current selection index - * @param {Number} startFrom Current selection index - */ - findLineBoundaryRight(startFrom: number): number; - - /** - * Returns number of newlines in selected text - */ - getNumNewLinesInSelectedText(): number; - - /** - * Finds index corresponding to beginning or end of a word - * @param {Number} selectionStart Index of a character - * @param {Number} direction: 1 or -1 - */ - searchWordBoundary(selectionStart: number, direction: number): number; - - /** - * Selects a word based on the index - * @param {Number} selectionStart Index of a character - */ - selectWord(selectionStart: number): void; - /** - * Selects a line based on the index - * @param {Number} selectionStart Index of a character - */ - selectLine(selectionStart: number): void; - - /** - * Enters editing state - */ - enterEditing(): IIText; - - /** - * Initializes "mousemove" event handler - */ - initMouseMoveHandler(): void; - /** - * Exits from editing state - * @return {fabric.IText} thisArg - * @chainable - */ - exitEditing(): IIText; - - /** - * Inserts a character where cursor is (replacing selection if one exists) - * @param {String} _chars Characters to insert - */ - insertChars(_chars: string, useCopiedStyle?: boolean): void; - /** - * Inserts new style object - * @param {Number} lineIndex Index of a line - * @param {Number} charIndex Index of a char - * @param {Boolean} isEndOfLine True if it's end of line - */ - insertNewlineStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; - - /** - * Inserts style object for a given line/char index - * @param {Number} lineIndex Index of a line - * @param {Number} charIndex Index of a char - * @param {Object} [style] Style object to insert, if given - */ - insertCharStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; - - /** - * Inserts style object(s) - * @param {String} _chars Characters at the location where style is inserted - * @param {Boolean} isEndOfLine True if it's end of line - * @param {Boolean} [useCopiedStyle] Style to insert - */ - insertStyleObjects(_chars: string, isEndOfLine: boolean, useCopiedStyle?: boolean): void; - - /** - * Shifts line styles up or down - * @param {Number} lineIndex Index of a line - * @param {Number} offset Can be -1 or +1 - */ - shiftLineStyles(lineIndex: number, offset: number): void; - - /** - * Removes style object - * @param {Boolean} isBeginningOfLine True if cursor is at the beginning of line - * @param {Number} [index] Optional index. When not given, current selectionStart is used. - */ - removeStyleObject(isBeginningOfLine: boolean, index?: number): void; - /** - * Inserts new line - */ - insertNewline(): void; - - } - interface IITextStatic extends ITextStatic { - /** - * Constructor - * @param {String} text Text string - * @param {Object} [options] Options object - */ - new (text: string, options?: IITextOptions): IIText; - /** - * Returns fabric.IText instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IIText; - } - - interface ITriangleOptions extends IObjectOptions { } - interface ITriangle extends IObject { - /** - * Returns complexity of an instance - * @return {Number} complexity of this instance - */ - - complexity(): number; - /** - * Returns SVG representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - toSVG(reviver?: Function): string; - } - interface ITriangleStatic { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: ITriangleOptions): ITriangle; - /** - * Returns Triangle instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): ITriangle; - } - - //////////////////////////////////////////////////////////// - // Filters - //////////////////////////////////////////////////////////// - interface IAllFilters { - BaseFilter: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: any): IBaseFilter; - }; - Blend: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: { color?: string; mode?: string; alpha?: number; image?: IImage }): IBlendFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IBlendFilter - }; - Brightness: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Number} [options.brightness=0] Value to brighten the image up (0..255) - */ - new (options?: { brightness: number }): IBrightnessFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IBrightnessFilter - }; - Convolute: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Boolean} [options.opaque=false] Opaque value (true/false) - * @param {Array} [options.matrix] Filter matrix - */ - new (options?: { opaque?: boolean; matrix?: number[] }): IConvoluteFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IConvoluteFilter - }; - GradientTransparency: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Number} [options.threshold=100] Threshold value - */ - new (options?: { threshold?: number; }): IGradientTransparencyFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IGradientTransparencyFilter - }; - Grayscale: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: any): IGrayscaleFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IGrayscaleFilter - }; - Invert: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: any): IInvertFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IInvertFilter - }; - Mask: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {fabric.Image} [options.mask] Mask image object - * @param {Number} [options.channel=0] Rgb channel (0, 1, 2 or 3) - */ - new (options?: { mask?: IImage; channel: number; }): IMaskFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IMaskFilter - }; - Multiply: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Number} [options.color=#000000] Color to multiply the image pixels with - */ - new (options?: { color: string; }): IMultiplyFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IMultiplyFilter - }; - Noise: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Number} [options.noise=0] Noise value - */ - new (options?: { noise: number; }): INoiseFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): INoiseFilter - }; - Pixelate: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Number} [options.blocksize=4] Blocksize for pixelate - */ - new (options?: { blocksize?: number; }): IPixelateFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IPixelateFilter - }; - RemoveWhite: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {Number} [options.threshold=30] Threshold value - * @param {Number} [options.distance=20] Distance value - */ - new (options?: { threshold?: number; distance?: number; }): IRemoveWhiteFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IRemoveWhiteFilter - }; - Resize: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: any): IResizeFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): IResizeFilter - }; - Sepia2: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: any): ISepia2Filter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): ISepia2Filter - }; - Sepia: { - /** - * Constructor - * @param {Object} [options] Options object - */ - new (options?: any): ISepiaFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): ISepiaFilter - }; - Tint: { - /** - * Constructor - * @param {Object} [options] Options object - * @param {String} [options.color=#000000] Color to tint the image with - * @param {Number} [options.opacity] Opacity value that controls the tint effect's transparency (0..1) - */ - new (options?: { color?: string; opacity?: number; }): ITintFilter; - /** - * Returns filter instance from an object representation - * @param {Object} object Object to create an instance from - */ - fromObject(object: any): ITintFilter - }; - } - interface IBaseFilter { - /** - * Sets filter's properties from options - * @param {Object} [options] Options object - */ - setOptions(options?: any): void; - /** - * Returns object representation of an instance - */ - toObject(): any; - /** - * Returns a JSON representation of an instance - */ - toJSON(): string; - } - interface IBlendFilter extends IBaseFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IBrightnessFilter extends IBaseFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IConvoluteFilter extends IBaseFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IGradientTransparencyFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IGrayscaleFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IInvertFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IMaskFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IMultiplyFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface INoiseFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IPixelateFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IRemoveWhiteFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface IResizeFilter { - /** - * Resize type - */ - resizeType: string; - - /** - * Scale factor for resizing, x axis - */ - scaleX: number; - - /** - * Scale factor for resizing, y axis - */ - scaleY: number; - - /** - * LanczosLobes parameter for lanczos filter - */ - lanczosLobes: number; - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface ISepiaFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface ISepia2Filter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - interface ITintFilter { - /** - * Applies filter to canvas element - * @param {Object} canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; - } - - //////////////////////////////////////////////////////////// - // Brushes - //////////////////////////////////////////////////////////// - interface IBaseBrush { - /** - * Color of a brush - */ - color: string; - - /** - * Width of a brush - */ - width: number; - - /** - * Shadow object representing shadow of this shape. - * Backwards incompatibility note: This property replaces "shadowColor" (String), "shadowOffsetX" (Number), - * "shadowOffsetY" (Number) and "shadowBlur" (Number) since v1.2.12 - */ - shadow: IShadow|string; - /** - * Line endings style of a brush (one of "butt", "round", "square") - */ - strokeLineCap: string; - - /** - * Corner style of a brush (one of "bevil", "round", "miter") - */ - strokeLineJoin: string; - - /** - * Stroke Dash Array. - */ - strokeDashArray: any[]; - - /** - * Sets shadow of an object - * @param {Object|String} [options] Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)") - */ - setShadow(options: string|any): IBaseBrush; - - } - interface ICircleBrush extends IBaseBrush { - /** - * Width of a brush - */ - width: number; - /** - * Invoked inside on mouse down and mouse move - * @param {Object} pointer - */ - drawDot(pointer: any): void; - - /** - * @param {Object} pointer - * @return {fabric.Point} Just added pointer point - */ - addPoint(pointer: any): IPoint - } - interface ISprayBrush extends IBaseBrush { - /** - * Width of a brush - */ - width: number; - /** - * Density of a spray (number of dots per chunk) - */ - density: number; - - /** - * Width of spray dots - */ - dotWidth: number; - /** - * Width variance of spray dots - */ - dotWidthVariance: number; - - /** - * Whether opacity of a dot should be random - */ - randomOpacity: boolean; - /** - * Whether overlapping dots (rectangles) should be removed (for performance reasons) - */ - optimizeOverlapping: boolean; - /** - * @param {Object} pointer - */ - addSprayChunk(pointer: any): void - } - interface IPatternBrush extends IPencilBrush { - getPatternSrc(): HTMLCanvasElement; - - getPatternSrcFunction(): string; - - /** - * Creates "pattern" instance property - */ - getPattern(): any; - /** - * Creates path - */ - createPath(pathData: string): IPath; - } - interface IPencilBrush extends IBaseBrush { - /** - * Converts points to SVG path - * @param {Array} points Array of points - * @param {Number} minX - * @param {Number} minY - */ - convertPointsToSVGPath(points: { x: number; y: number }[], minX?: number, minY?: number): string[]; - - /** - * Creates fabric.Path object to add on canvas - * @param {String} pathData Path data - */ - createPath(pathData: string): IPath; - } - var BaseBrush: { - new (): IBaseBrush - }; - var CircleBrush: { - new (canvas: fabric.ICanvas): ICircle - }; - var SprayBrush: { - new (canvas: fabric.ICanvas): ISprayBrush - }; - var PencilBrush: { - new (canvas: fabric.ICanvas): IPencilBrush - }; - var PatternBrush: { - new (canvas: fabric.ICanvas): IPatternBrush - }; - /////////////////////////////////////////////////////////////////////////////// - // Fabric util Interface - ////////////////////////////////////////////////////////////////////////////// - interface IUtilAnimationOptions { - /** - * Starting value - */ - startValue?: number; - /** - * Ending value - */ - endValue?: number; - /** - * Value to modify the property by - */ - byValue: number; - /** - * Duration of change (in ms) - */ - duration?: number; - /** - * Callback; invoked on every value change - */ - onChange?: Function; - /** - * Callback; invoked when value change is completed - */ - onComplete?: Function; - /** - * Easing function - */ - easing?: Function; - } - interface IUtilAnimation { - /** - * Changes value from one to another within certain period of time, invoking callbacks as value is being changed. - * @param {Object} [options] Animation options - */ - animate(options?: IUtilAnimationOptions): void; - /** - * requestAnimationFrame polyfill based on http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - * In order to get a precise start time, `requestAnimFrame` should be called as an entry into the method - * @param {Function} callback Callback to invoke - */ - requestAnimFrame(callback: Function): void; - } - - interface IUtilAminEaseFunction { - (t: number, b: number, c: number, d: number): number; - } - - interface IUtilAnimEase { - easeInBack: IUtilAminEaseFunction; - easeInBounce: IUtilAminEaseFunction; - easeInCirc: IUtilAminEaseFunction; - easeInCubic: IUtilAminEaseFunction; - easeInElastic: IUtilAminEaseFunction; - easeInExpo: IUtilAminEaseFunction; - easeInOutBack: IUtilAminEaseFunction; - easeInOutBounce: IUtilAminEaseFunction; - easeInOutCirc: IUtilAminEaseFunction; - easeInOutCubic: IUtilAminEaseFunction; - easeInOutElastic: IUtilAminEaseFunction; - easeInOutExpo: IUtilAminEaseFunction; - easeInOutQuad: IUtilAminEaseFunction; - easeInOutQuart: IUtilAminEaseFunction; - easeInOutQuint: IUtilAminEaseFunction; - easeInOutSine: IUtilAminEaseFunction; - easeInQuad: IUtilAminEaseFunction; - easeInQuart: IUtilAminEaseFunction; - easeInQuint: IUtilAminEaseFunction; - easeInSine: IUtilAminEaseFunction; - easeOutBack: IUtilAminEaseFunction; - easeOutBounce: IUtilAminEaseFunction; - easeOutCirc: IUtilAminEaseFunction; - easeOutCubic: IUtilAminEaseFunction; - easeOutElastic: IUtilAminEaseFunction; - easeOutExpo: IUtilAminEaseFunction; - easeOutQuad: IUtilAminEaseFunction; - easeOutQuart: IUtilAminEaseFunction; - easeOutQuint: IUtilAminEaseFunction; - easeOutSine: IUtilAminEaseFunction; - } - - interface IUtilArc { - /** - * Draws arc - * @param {CanvasRenderingContext2D} ctx - * @param {Number} fx - * @param {Number} fy - * @param {Array} coords - */ - drawArc(ctx: CanvasRenderingContext2D, fx: number, fy: number, coords: number[]): void; - /** - * Calculate bounding box of a elliptic-arc - * @param {Number} fx start point of arc - * @param {Number} fy - * @param {Number} rx horizontal radius - * @param {Number} ry vertical radius - * @param {Number} rot angle of horizontal axe - * @param {Number} large 1 or 0, whatever the arc is the big or the small on the 2 points - * @param {Number} sweep 1 or 0, 1 clockwise or counterclockwise direction - * @param {Number} tx end point of arc - * @param {Number} ty - */ - getBoundsOfArc(fx: number, fy: number, rx: number, ry: number, rot: number, large: number, sweep: number, tx: number, ty: number): IPoint[]; - /** - * Calculate bounding box of a beziercurve - * @param {Number} x0 starting point - * @param {Number} y0 - * @param {Number} x1 first control point - * @param {Number} y1 - * @param {Number} x2 secondo control point - * @param {Number} y2 - * @param {Number} x3 end of beizer - * @param {Number} y3 - */ - getBoundsOfCurve(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): IPoint[]; - - } - - interface IUtilDomEvent { - /** - * Cross-browser wrapper for getting event's coordinates - * @param {Event} event Event object - * @param {HTMLCanvasElement} upperCanvasEl <canvas> element on which object selection is drawn - */ - getPointer(event: Event, upperCanvasEl: HTMLCanvasElement): IPoint; - - /** - * Adds an event listener to an element - * @param {HTMLElement} element - * @param {String} eventName - * @param {Function} handler - */ - addListener(element: HTMLElement, eventName: string, handler: Function): void; - - /** - * Removes an event listener from an element - * @param {HTMLElement} element - * @param {String} eventName - * @param {Function} handler - */ - removeListener(element: HTMLElement, eventName: string, handler: Function): void; - } - - interface IUtilDomMisc { - /** - * Takes id and returns an element with that id (if one exists in a document) - * @param {String|HTMLElement} id - */ - getById(id: string|HTMLElement): HTMLElement; - /** - * Converts an array-like object (e.g. arguments or NodeList) to an array - * @param {Object} arrayLike - */ - toArray(arrayLike: any): any[]; - /** - * Creates specified element with specified attributes - * @memberOf fabric.util - * @param {String} tagName Type of an element to create - * @param {Object} [attributes] Attributes to set on an element - * @return {HTMLElement} Newly created element - */ - makeElement(tagName: string, attributes?: any): HTMLElement; - /** - * Adds class to an element - * @param {HTMLElement} element Element to add class to - * @param {String} className Class to add to an element - */ - addClass(element: HTMLElement, classname: string): void; - /** - * Wraps element with another element - * @param {HTMLElement} element Element to wrap - * @param {HTMLElement|String} wrapper Element to wrap with - * @param {Object} [attributes] Attributes to set on a wrapper - */ - wrapElement(element: HTMLElement, wrapper: HTMLElement|string, attributes?: any): HTMLElement; - /** - * Returns element scroll offsets - * @param {HTMLElement} element Element to operate on - * @param {HTMLElement} upperCanvasEl Upper canvas element - */ - getScrollLeftTop(element: HTMLElement, upperCanvasEl: HTMLElement): { left: number; right: number; }; - /** - * Returns offset for a given element - * @param {HTMLElement} element Element to get offset for - */ - getElementOffset(element: HTMLElement): { left: number; right: number; }; - /** - * Returns style attribute value of a given element - * @param {HTMLElement} element Element to get style attribute for - * @param {String} attr Style attribute to get for element - */ - getElementStyle(elment: HTMLElement, attr: string): string; - /** - * Inserts a script element with a given url into a document; invokes callback, when that script is finished loading - * @memberOf fabric.util - * @param {String} url URL of a script to load - * @param {Function} callback Callback to execute when script is finished loading - */ - getScript(url: string, callback: Function): void; - /** - * Makes element unselectable - * @param {HTMLElement} element Element to make unselectable - */ - makeElementUnselectable(element: HTMLElement): HTMLElement; - /** - * Makes element selectable - * @param {HTMLElement} element Element to make selectable - */ - makeElementSelectable(element: HTMLElement): HTMLElement; - } - - interface IUtilDomRequest { - /** - * Cross-browser abstraction for sending XMLHttpRequest - * @param {String} url URL to send XMLHttpRequest to - * @param {Object} [options] Options object - * @param {String} [options.method="GET"] - * @param {Function} options.onComplete Callback to invoke when request is completed - */ - request(url: string, options?: { method?: string; onComplete: Function }): XMLHttpRequest; - } - - interface IUtilDomStyle { - /** - * Cross-browser wrapper for setting element's style - * @param {HTMLElement} element - * @param {Object} styles - */ - setStyle(element: HTMLElement, styles: any): HTMLElement; - } - - interface IUtilArray { - /** - * Invokes method on all items in a given array - * @param {Array} array Array to iterate over - * @param {String} method Name of a method to invoke - */ - invoke(array: any[], method: string): any[]; - /** - * Finds minimum value in array (not necessarily "first" one) - * @param {Array} array Array to iterate over - * @param {String} byProperty - */ - min(array: any[], byProperty: string): any; - /** - * Finds maximum value in array (not necessarily "first" one) - * @param {Array} array Array to iterate over - * @param {String} byProperty - */ - max(array: any[], byProperty: string): any; - } - - interface IUtilClass { - /** - * Helper for creation of "classes". - * @param {Function} [parent] optional "Class" to inherit from - * @param {Object} [properties] Properties shared by all instances of this class - * (be careful modifying objects defined here as this would affect all instances) - */ - createClass(parent: Function, properties?: any): void; - /** - * Helper for creation of "classes". - * @param {Object} [properties] Properties shared by all instances of this class - * (be careful modifying objects defined here as this would affect all instances) - */ - createClass(properties?: any): void; - - } - - interface IUtilObject { - /** - * Copies all enumerable properties of one object to another - * @param {Object} destination Where to copy to - * @param {Object} source Where to copy from - */ - extend(destination: any, source: any): any; - - /** - * Creates an empty object and copies all enumerable properties of another object to it - * @memberOf fabric.util.object - * @param {Object} object Object to clone - * @return {Object} - */ - clone(object: any): any - } - - interface IUtilString { - /** - * Camelizes a string - * @param {String} string String to camelize - */ - camelize(string: string): string; - - /** - * Capitalizes a string - * @param {String} string String to capitalize - * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized - * and other letters stay untouched, if false first letter is capitalized - * and other letters are converted to lowercase. - */ - capitalize(string: string, firstLetterOnly: boolean): string; - - /** - * Escapes XML in a string - * @param {String} string String to escape - */ - escapeXml(string: string): string; - } - - interface IUtilMisc { - /** - * Removes value from an array. - * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf` - * @param {Array} array - * @param {Any} value - */ - removeFromArray(array: any[], value: any): any[]; - - /** - * Returns random number between 2 specified ones. - * @param {Number} min lower limit - * @param {Number} max upper limit - */ - getRandomInt(min: number, max: number): number; - - /** - * Transforms degrees to radians. - * @param {Number} degrees value in degrees - */ - degreesToRadians(degrees: number): number; - - /** - * Transforms radians to degrees. - * @memberOf fabric.util - * @param {Number} radians value in radians - */ - radiansToDegrees(radians: number): number; - - /** - * Rotates `point` around `origin` with `radians` - * @param {fabric.Point} point The point to rotate - * @param {fabric.Point} origin The origin of the rotation - * @param {Number} radians The radians of the angle for the rotation - */ - rotatePoint(point: IPoint, origin: IPoint, radians: number): IPoint; - - /** - * Apply transform t to point p - * @param {fabric.Point} p The point to transform - * @param {Array} t The transform - * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied - */ - transformPoint(p: IPoint, t: any[], ignoreOffset?: boolean): IPoint; - - /** - * Invert transformation t - * @param {Array} t The transform - */ - invertTransform(t: any[]): any[]; - - /** - * A wrapper around Number#toFixed, which contrary to native method returns number, not string. - * @param {Number|String} number number to operate on - * @param {Number} fractionDigits number of fraction digits to "leave" - */ - toFixed(number: number, fractionDigits: number): number; - - /** - * Converts from attribute value to pixel value if applicable. - * Returns converted pixels or original value not converted. - * @param {Number|String} value number to operate on - */ - parseUnit(value: number|string, fontSize?: number): number|string; - - /** - * Function which always returns `false`. - */ - falseFunction(): boolean; - - /** - * Returns klass "Class" object of given namespace - * @param {String} type Type of object (eg. 'circle') - * @param {String} namespace Namespace to get klass "Class" object from - */ - getKlass(type: string, namespace: string): any; - - /** - * Returns object of given namespace - * @param {String} namespace Namespace string e.g. 'fabric.Image.filter' or 'fabric' - */ - resolveNamespace(namespace: string): any; - - /** - * Loads image element from given url and passes it to a callback - * @param {String} url URL representing an image - * @param {Function} callback Callback; invoked with loaded image - * @param {Any} [context] Context to invoke callback in - * @param {Object} [crossOrigin] crossOrigin value to set image element to - */ - loadImage(url: string, callback: (image: HTMLImageElement) => {}, context?: any, crossOrigin?: boolean): void; - - /** - * Creates corresponding fabric instances from their object representations - * @param {Array} objects Objects to enliven - * @param {Function} callback Callback to invoke when all objects are created - * @param {String} namespace Namespace to get klass "Class" object from - * @param {Function} reviver Method for further parsing of object elements, called after each fabric object created. - */ - enlivenObjects(objects: any[], callback: Function, namespace: string, reviver?: Function): void; - - /** - * Groups SVG elements (usually those retrieved from SVG document) - * @param {Array} elements SVG elements to group - * @param {Object} [options] Options object - */ - groupSVGElements(elements: any[], options?: any, path?: any): IPathGroup; - - /** - * Populates an object with properties of another object - * @param {Object} source Source object - * @param {Object} destination Destination object - * @param {Array} properties Propertie names to include - */ - populateWithProperties(source: any, destination: any, properties: any): void; - - /** - * Draws a dashed line between two points - * This method is used to draw dashed line around selection area. - * @param {CanvasRenderingContext2D} ctx context - * @param {Number} x start x coordinate - * @param {Number} y start y coordinate - * @param {Number} x2 end x coordinate - * @param {Number} y2 end y coordinate - * @param {Array} da dash array pattern - */ - drawDashedLine(ctx: CanvasRenderingContext2D, x: number, y: number, x2: number, y2: number, da: any[]): void; - - /** - * Creates canvas element and initializes it via excanvas if necessary - * @param {CanvasElement} [canvasEl] optional canvas element to initialize; - * when not given, element is created implicitly - */ - createCanvasElement(canvasEl?: HTMLCanvasElement): HTMLCanvasElement; - - /** - * Creates image element (works on client and node) - */ - createImage(): HTMLImageElement; - - /** - * Creates accessors (getXXX, setXXX) for a "class", based on "stateProperties" array - * @param {Object} klass "Class" to create accessors for - */ - createAccessors(klass: any): any; - - /** - * @param {fabric.Object} receiver Object implementing `clipTo` method - * @param {CanvasRenderingContext2D} ctx Context to clip - */ - clipContext(receiver: IObject, ctx: CanvasRenderingContext2D): void; - - /** - * Multiply matrix A by matrix B to nest transformations - * @param {Array} a First transformMatrix - * @param {Array} b Second transformMatrix - */ - multiplyTransformMatrices(a: any[], b: any[]): any[]; - - /** - * Returns string representation of function body - * @param {Function} fn Function to get body of - */ - getFunctionBody(fn: Function): string; - - /** - * Returns true if context has transparent pixel - * at specified location (taking tolerance into account) - * @param {CanvasRenderingContext2D} ctx context - * @param {Number} x x coordinate - * @param {Number} y y coordinate - * @param {Number} tolerance Tolerance - */ - isTransparent(ctx: CanvasRenderingContext2D, x: number, y: number, tolerance: number): boolean; - } - - interface IUtil extends IUtilAnimation, IUtilArc, IObservable, IUtilDomEvent, IUtilDomMisc, - IUtilDomRequest, IUtilDomStyle, IUtilClass, IUtilMisc { - ease: IUtilAnimEase; - array: IUtilArray; - object: IUtilObject; - string: IUtilString; - } +interface IEvent { + e: Event; + target?: Object; +} + +interface IFillOptions { + /** + * options.source Pattern source + */ + source: string | HTMLImageElement; + /** + * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) + */ + repeat?: string; + /** + * Pattern horizontal offset from object's left/top corner + */ + offsetX?: number; + /** + * Pattern vertical offset from object's left/top corner + */ + offsetY?: number; +} + +interface IToSVGOptions { + /** + * If true xml tag is not included + */ + suppressPreamble: boolean; + /** + * SVG viewbox object + */ + viewBox: IViewBox; + /** + * Encoding of SVG output + */ + encoding: string; +} + +interface IViewBox { + /** + * x-cooridnate of viewbox + */ + x: number; + /** + * y-coordinate of viewbox + */ + y: number; + /** + * Width of viewbox + */ + width: number; + /** + * Height of viewbox + */ + height: number; +} + +/////////////////////////////////////////////////////////////////////////////// +// Mixins Interfaces +////////////////////////////////////////////////////////////////////////////// +interface ICollection { + /** + * Adds objects to collection, then renders canvas (if `renderOnAddRemove` is not `false`) + * Objects should be instances of (or inherit from) fabric.Object + * @param {...fabric.Object} object Zero or more fabric instances + */ + add(...object: Object[]): T; + + /** + * Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`) + * An object should be an instance of (or inherit from) fabric.Object + * @param {Object} object Object to insert + * @param {Number} index Index to insert object at + * @param {Boolean} nonSplicing When `true`, no splicing (shifting) of objects occurs + * @return {Self} thisArg + * @chainable + */ + insertAt(object: Object, index: number, nonSplicing: boolean): T; + + /** + * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) + * @param {...fabric.Object} object Zero or more fabric instances + * @return {Self} thisArg + * @chainable + */ + remove(...object: Object[]): T; + + /** + * Executes given function for each object in this group + * @param {Function} callback + * @param {Object} context Context (aka thisObject) + * @return {Self} thisArg + */ + forEachObject(callback: (element: Object, index: number, array: Object[]) => any, context?: any): T; + + /** + * Returns an array of children objects of this instance + * Type parameter introduced in 1.3.10 + * @param {String} [type] When specified, only objects of this type are returned + * @return {Array} + */ + getObjects(type?: string): Object[]; + + /** + * Returns object at specified index + * @param {Number} index + * @return {Self} thisArg + */ + item(index: number): T; + + /** + * Returns true if collection contains no objects + * @return {Boolean} true if collection is empty + */ + isEmpty(): boolean; + + /** + * Returns a size of a collection (i.e: length of an array containing its objects) + * @return {Number} Collection size + */ + size(): number; + + /** + * Returns true if collection contains an object + * @param {Object} object Object to check against + * @return {Boolean} `true` if collection contains an object + */ + contains(object: Object): boolean; + + /** + * Returns number representation of a collection complexity + * @return {Number} complexity + */ + complexity(): number; +} + +interface IObservable { + /** + * Observes specified event + * @param eventName Event name (eg. 'after:render') + * @param handler Function that receives a notification when an event of the specified type occurs + */ + on(eventName: string, handler: (e: IEvent) => any): T; + + /** + * Observes specified event + * @param eventName Object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) + */ + on(eventName: {[key: string]: Function}): T; + /** + * Fires event with an optional options object + * @param {String} eventName Event name to fire + * @param {Object} [options] Options object + */ + trigger(eventName: string, options?: any): T; + /** + * Stops event observing for a particular event handler. Calling this method + * without arguments removes all handlers for all events + * @param eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) + * @param handler Function to be deleted from EventListeners + */ + off(eventName?: string|any, handler?: (e: IEvent) => any): T; +} + +// animation mixin +// ---------------------------------------------------- +interface ICanvasAnimation { + FX_DURATION: number; + /** + * Centers object horizontally with animation. + * @param {fabric.Object} object Object to center + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + */ + fxCenterObjectH(object: Object, callbacks?: { onComplete: Function; onChange: Function; }): T; + + /** + * Centers object vertically with animation. + * @param {fabric.Object} object Object to center + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + */ + fxCenterObjectV(object: Object, callbacks?: { onComplete: Function; onChange: Function; }): T; + + /** + * Same as `fabric.Canvas#remove` but animated + * @param {fabric.Object} object Object to remove + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxRemove(object: Object, callbacks?: { onComplete: Function; onChange: Function; }): T; +} +interface IObjectAnimation { + /** + * Animates object's properties + * object.animate('left', ..., {duration: ...}); + * @param property Property to animate + * @param value Value to animate property + * @param options The animation options + */ + animate(property: string, value: number|string, options?: IAnimationOptions): Object; + /** + * Animates object's properties + * object.animate({ left: ..., top: ... }, { duration: ... }); + * @param properties Properties to animate + * @param value Options object + */ + animate(properties: any, options?: IAnimationOptions): Object; +} +interface IAnimationOptions { + /** + * Allows to specify starting value of animatable property (if we don't want current value to be used). + */ + from?: string|number; + /** + * Defaults to 500 (ms). Can be used to change duration of an animation. + */ + duration?: number; + /** + * Callback; invoked on every value change + */ + onChange?: Function; + /** + * Callback; invoked when value change is completed + */ + onComplete?: Function; + + /** + * Easing function. Default: fabric.util.ease.easeInSine + */ + easing?: Function; + /** + * Value to modify the property by, default: end - start + */ + by?: number; +} + +/////////////////////////////////////////////////////////////////////////////// +// General Fabric Interfaces +////////////////////////////////////////////////////////////////////////////// +export class Color { + /** + * Color class + * The purpose of Color is to abstract and encapsulate common color operations; + * @param {String} color optional in hex or rgb(a) format + */ + constructor(color?: string); + + /** + * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1]) + */ + getSource(): number[]; + + /** + * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1]) + */ + setSource(source: number[]): void; + + /** + * Returns color represenation in RGB format ex: rgb(0-255,0-255,0-255) + */ + toRgb(): string; + + /** + * Returns color represenation in RGBA format ex: rgba(0-255,0-255,0-255,0-1) + */ + toRgba(): string; + + /** + * Returns color represenation in HSL format ex: hsl(0-360,0%-100%,0%-100%) + */ + toHsl(): string; + + /** + * Returns color represenation in HSLA format ex: hsla(0-360,0%-100%,0%-100%,0-1) + */ + toHsla(): string; + + /** + * Returns color represenation in HEX format ex: FF5555 + */ + toHex(): string; + + /** + * Gets value of alpha channel for this color + */ + getAlpha(): number; + + /** + * Sets value of alpha channel for this color + * @param {Number} alpha Alpha value 0-1 + */ + setAlpha(alpha: number): void; + + /** + * Transforms color to its grayscale representation + */ + toGrayscale(): Color; + + /** + * Transforms color to its black and white representation + * @param {Number} threshold + */ + toBlackWhite(threshold: number): Color; + /** + * Overlays color with another color + * @param {String|fabric.Color} otherColor + */ + overlayWith(otherColor: string|Color): Color; + + /** + * Returns new color object, when given a color in RGB format + * @param {String} color Color value ex: rgb(0-255,0-255,0-255) + */ + static fromRgb(color: string): Color; + /** + * Returns new color object, when given a color in RGBA format + * @param {String} color Color value ex: rgb(0-255,0-255,0-255) + */ + static fromRgba(color: string): Color; + /** + * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format + * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%) + */ + static sourceFromRgb(color: string): number[]; + /** + * Returns new color object, when given a color in HSL format + * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%) + */ + static fromHsl(color: string): Color; + /** + * Returns new color object, when given a color in HSLA format + * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%) + */ + static fromHsla(color: string): Color; + /** + * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format. + * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1) + */ + static sourceFromHsl(color: string): number[]; + /** + * Returns new color object, when given a color in HEX format + * @param {String} color Color value ex: FF5555 + */ + static fromHex(color: string): Color; + + /** + * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format + * @param {String} color ex: FF5555 + */ + static sourceFromHex(color: string): number[]; + /** + * Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5]) + * @param {Array} source + */ + static fromSource(source: number[]): Color; +} + +interface IGradientOptions { + /** + * @param {String} [options.type] Type of gradient 'radial' or 'linear' + */ + type?: string; + /** + * x-coordinate of start point + */ + x1?: number; + /** + * y-coordinate of start point + */ + y1?: number; + /** + * x-coordinate of end point + */ + x2?: number; + /** + * y-coordinate of end point + */ + y2?: number; + /** + * Radius of start point (only for radial gradients) + */ + r1?: number; + /** + * Radius of end point (only for radial gradients) + */ + r2?: number; + /** + * Color stops object eg. {0:string; 1:string; + */ + colorStops?: any; +} +interface IGradient extends IGradientOptions { + /** + * Adds another colorStop + * @param {Object} colorStop Object with offset and color + */ + addColorStop(colorStop: any): IGradient; + /** + * Returns object representation of a gradient + */ + toObject(): any; + /** + * Returns SVG representation of an gradient + * @param {Object} object Object to create a gradient for + * @param {Boolean} normalize Whether coords should be normalized + * @return {String} SVG representation of an gradient (linear/radial) + */ + toSVG(object: Object, normalize?: boolean): string; + + /** + * Returns an instance of CanvasGradient + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + toLive(ctx: CanvasRenderingContext2D, object?: PathGroup): CanvasGradient; +} +interface IGrandientStatic { + new (options?: IGradientOptions): IGradient; + /** + * Returns instance from an SVG element + * @param {SVGGradientElement} el SVG gradient element + * @param {fabric.Object} instance + */ + fromElement(el: SVGGradientElement, instance: Object): IGradient; + /** + * Returns instance from its object representation + * @param {Object} obj + * @param {Object} [options] Options object + */ + fromObject(obj: any, options: any[]): IGradient; +} + +export class Intersection { + constructor(status?: string); + + /** + * Appends a point to intersection + */ + appendPoint(point: Point): void; + /** + * Appends points to intersection + */ + appendPoints(points: Point[]): void; + + /** + * Checks if polygon intersects another polygon + */ + static intersectPolygonPolygon(points1: Point[], points2: Point[]): Intersection; + /** + * Checks if line intersects polygon + */ + static intersectLinePolygon(a1: Point, a2: Point, points: Point[]): Intersection; + /** + * Checks if one line intersects another + */ + static intersectLineLine(a1: Point, a2: Point, b1: Point, b2: Point): Intersection; + /** + * Checks if polygon intersects rectangle + */ + static intersectPolygonRectangle(points: Point[], r1: number, r2: number): Intersection; +} + +interface IPatternOptions { + /** + * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) + */ + repeat: string; + + /** + * Pattern horizontal offset from object's left/top corner + */ + offsetX: number; + + /** + * Pattern vertical offset from object's left/top corner + */ + offsetY: number; + /** + * The source for the pattern + */ + source: string|HTMLImageElement; +} +export interface Pattern extends IPatternOptions {} +export class Pattern { + constructor(options?: IPatternOptions); + + initialise(options?: IPatternOptions): Pattern; + /** + * Returns an instance of CanvasPattern + */ + toLive(ctx: CanvasRenderingContext2D): Pattern; + + /** + * Returns object representation of a pattern + */ + toObject(): any; + /** + * Returns SVG representation of a pattern + * @param {fabric.Object} object + */ + toSVG(object: Object): string; +} + +export class Point { + x: number; + y: number; + + constructor(x: number, y: number); + + /** + * Adds another point to this one and returns another one + * @param {fabric.Point} that + */ + add(that: Point): Point; + + /** + * Adds another point to this one + * @param {fabric.Point} that + */ + addEquals(that: Point): Point; + + /** + * Adds value to this point and returns a new one + * @param {Number} scalar + */ + scalarAdd(scalar: number): Point; + + /** + * Adds value to this point + * @param {Number} scalar + */ + scalarAddEquals(scalar: number): Point; + + /** + * Subtracts another point from this point and returns a new one + * @param {fabric.Point} that + */ + subtract(that: Point): Point; + + /** + * Subtracts another point from this point + * @param {fabric.Point} that + */ + subtractEquals(that: Point): Point; + + /** + * Subtracts value from this point and returns a new one + * @param {Number} scalar + */ + scalarSubtract(scalar: number): Point; + + /** + * Subtracts value from this point + * @param {Number} scalar + */ + scalarSubtractEquals(scalar: number): Point; + + /** + * Miltiplies this point by a value and returns a new one + * @param {Number} scalar + */ + multiply(scalar: number): Point; + + /** + * Miltiplies this point by a value + * @param {Number} scalar + */ + multiplyEquals(scalar: number): Point; + + /** + * Divides this point by a value and returns a new one + * @param {Number} scalar + */ + divide(scalar: number): Point; + + /** + * Divides this point by a value + * @param {Number} scalar + */ + divideEquals(scalar: number): Point; + + /** + * Returns true if this point is equal to another one + * @param {fabric.Point} that + */ + eq(that: Point): Point; + + /** + * Returns true if this point is less than another one + * @param {fabric.Point} that + */ + lt(that: Point): Point; + + /** + * Returns true if this point is less than or equal to another one + * @param {fabric.Point} that + */ + lte(that: Point): Point; + + /** + * Returns true if this point is greater another one + * @param {fabric.Point} that + */ + gt(that: Point): Point; + + /** + * Returns true if this point is greater than or equal to another one + * @param {fabric.Point} that + */ + gte(that: Point): Point; + + /** + * Returns new point which is the result of linear interpolation with this one and another one + * @param {fabric.Point} that + * @param {Number} t + */ + lerp(that: Point, t: number): Point; + + /** + * Returns distance from this point and another one + * @param {fabric.Point} that + */ + distanceFrom(that: Point): number; + + /** + * Returns the point between this point and another one + * @param {fabric.Point} that + */ + midPointFrom(that: Point): Point; + + /** + * Returns a new point which is the min of this and another one + * @param {fabric.Point} that + */ + min(that: Point): Point; + + /** + * Returns a new point which is the max of this and another one + * @param {fabric.Point} that + */ + max(that: Point): Point; + + /** + * Returns string representation of this point + */ + toString(): string; + + /** + * Sets x/y of this point + * @param {Number} x + * @param {Number} y + */ + setXY(x: number, y: number): Point; + + /** + * Sets x/y of this point from another point + * @param {fabric.Point} that + */ + setFromPoint(that: Point): Point; + + /** + * Swaps x/y of this point and another point + * @param {fabric.Point} that + */ + swap(that: Point): Point; +} + +interface IShadowOptions { + /** + * Whether the shadow should affect stroke operations + */ + affectStrike: boolean; + /** + * Shadow blur + */ + blur: number; + /** + * Shadow color + */ + color: string; + /** + * Indicates whether toObject should include default values + */ + includeDefaultValues: boolean; + /** + * Shadow horizontal offset + */ + offsetX: number; + /** + * Shadow vertical offset + */ + offsetY: number; +} +export interface IShadow extends IShadowOptions {} +export class IShadow { + constructor(options?: IShadowOptions); + initialize(options?: IShadowOptions|string): IShadow; + /** + * Returns object representation of a shadow + */ + toObject(): Object; + /** + * Returns a string representation of an instance, CSS3 text-shadow declaration + */ + toString(): string; + /** + * Returns SVG representation of a shadow + * @param {fabric.Object} object + */ + toSVG(object: Object): string; + + /** + * Regex matching shadow offsetX, offsetY and blur, Static + */ + reOffsetsAndBlur: RegExp; + + static reOffsetsAndBlur: RegExp; +} + +/////////////////////////////////////////////////////////////////////////////// +// Canvas Interfaces +////////////////////////////////////////////////////////////////////////////// +interface ICanvasDimensions { + /** + * Width of canvas element + */ + width: number; + /** + * Height of canvas element + */ + height: number; +} +interface ICanvasDimensionsOptions { + /** + * Set the given dimensions only as canvas backstore dimensions + */ + backstoreOnly?: boolean; + /** + * Set the given dimensions only as css dimensions + */ + cssOnly?: boolean; +} + +interface IStaticCanvasOptions { + /** + * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas + */ + allowTouchScrolling?: boolean; + /** + * Indicates whether this canvas will use image smoothing, this is on by default in browsers + */ + imageSmoothingEnabled?: boolean; + + /** + * Indicates whether objects should remain in current stack position when selected. + * When false objects are brought to top and rendered as part of the selection group + */ + preserveObjectStacking?: boolean; + + /** + * The transformation (in the format of Canvas transform) which focuses the viewport + */ + viewportTransform?: number[]; + + freeDrawingColor?: string; + freeDrawingLineWidth?: number; + + /** + * Background color of canvas instance. + * Should be set via setBackgroundColor + */ + backgroundColor?: string|Pattern; + /** + * Background image of canvas instance. + * Should be set via setBackgroundImage + * Backwards incompatibility note: The "backgroundImageOpacity" and "backgroundImageStretch" properties are deprecated since 1.3.9. + */ + backgroundImage?: Image | string; + backgroundImageOpacity?: number; + backgroundImageStretch?: number; + /** + * Function that determines clipping of entire canvas area + * Being passed context as first argument. See clipping canvas area + */ + clipTo?: (context: CanvasRenderingContext2D) => void; + + /** + * Indicates whether object controls (borders/controls) are rendered above overlay image + */ + controlsAboveOverlay?: boolean; + + /** + * Indicates whether toObject/toDatalessObject should include default values + */ + includeDefaultValues?: boolean; + /** + * Overlay color of canvas instance. + * Should be set via setOverlayColor + */ + overlayColor?: string|Pattern; + /** + * Overlay image of canvas instance. + * Should be set via setOverlayImage + * Backwards incompatibility note: The "overlayImageLeft" and "overlayImageTop" properties are deprecated since 1.3.9. + */ + overlayImage?: Image; + overlayImageLeft?: number; + overlayImageTop?: number; + /** + * Indicates whether add, insertAt and remove should also re-render canvas. + * Disabling this option could give a great performance boost when adding/removing a lot of objects to/from canvas at once + * (followed by a manual rendering after addition/deletion) + */ + renderOnAddRemove?: boolean; + /** + * Indicates whether objects' state should be saved + */ + stateful?: boolean; +} +export interface StaticCanvas extends IObservable, IStaticCanvasOptions, ICollection, ICanvasAnimation {} +export class StaticCanvas { + /** + * Constructor + * @param {HTMLElement|String} element element to initialize instance on + * @param {Object} [options] Options object + */ + constructor(element: HTMLCanvasElement|string, options?: ICanvasOptions); + + /** + * Calculates canvas element offset relative to the document + * This method is also attached as "resize" event handler of window + */ + calcOffset(): StaticCanvas; + + /** + * Sets {@link fabric.StaticCanvas#overlayImage|overlay image} for this canvas + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set overlay to + * @param {Function} callback callback to invoke when image is loaded and set as an overlay + * @param {Object} [options] Optional options to set for the {@link fabric.Image|overlay image}. + */ + setOverlayImage(image: Image|string, callback: Function, options?: IObjectOptions): StaticCanvas; + + /** + * Sets {@link fabric.StaticCanvas#backgroundImage|background image} for this canvas + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set background to + * @param {Function} callback Callback to invoke when image is loaded and set as background + * @param {Object} [options] Optional options to set for the {@link fabric.Image|background image}. + */ + setBackgroundImage(image: Image|string, callback: Function, options?: IObjectOptions): StaticCanvas; + + /** + * Sets {@link fabric.StaticCanvas#overlayColor|background color} for this canvas + * @param {(String|fabric.Pattern)} overlayColor Color or pattern to set background color to + * @param {Function} callback Callback to invoke when background color is set + */ + setOverlayColor(overlayColor: string|Pattern, callback: Function): StaticCanvas; + + /** + * Sets {@link fabric.StaticCanvas#backgroundColor|background color} for this canvas + * @param {(String|fabric.Pattern)} backgroundColor Color or pattern to set background color to + * @param {Function} callback Callback to invoke when background color is set + */ + setBackgroundColor(backgroundColor: string|Pattern, callback: Function): StaticCanvas; + + /** + * Returns canvas width (in px) + */ + getWidth(): number; + + /** + * Returns canvas height (in px) + */ + getHeight(): number; + + /** + * Sets width of this canvas instance + * @param {Number|String} value Value to set width to + * @param {Object} [options] Options object + */ + setWidth(value: number|string, options?: ICanvasDimensionsOptions): StaticCanvas + + /** + * Sets height of this canvas instance + * @param {Number|String} value Value to set height to + * @param {Object} [options] Options object + */ + setHeight(value: number|string, options?: ICanvasDimensionsOptions): StaticCanvas; + + /** + * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em) + * @param {Object} dimensions Object with width/height properties + * @param {Object} [options] Options object + */ + setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): StaticCanvas; + + /** + * Returns canvas zoom level + */ + getZoom(): number; + + /** + * Sets viewport transform of this canvas instance + * @param {Array} vpt the transform in the form of context.transform + */ + setViewportTransform(vpt: number[]): StaticCanvas; + + /** + * Sets zoom level of this canvas instance, zoom centered around point + * @param {fabric.Point} point to zoom with respect to + * @param {Number} value to set zoom to, less than 1 zooms out + */ + zoomToPoint(point: Point, value: number): StaticCanvas; + + /** + * Sets zoom level of this canvas instance + * @param {Number} value to set zoom to, less than 1 zooms out + */ + setZoom(value: number): StaticCanvas; + + /** + * Pan viewport so as to place point at top left corner of canvas + * @param {fabric.Point} point to move to + */ + absolutePan(point: Point): StaticCanvas; + + /** + * Pans viewpoint relatively + * @param {fabric.Point} point (position vector) to move by + */ + relativePan(point: Point): StaticCanvas; + + /** + * Returns element corresponding to this instance + */ + getElement(): HTMLCanvasElement; + + /** + * Returns currently selected object, if any + */ + getActiveObject(): Object; + + /** + * Returns currently selected group of object, if any + */ + getActiveGroup(): Group; + + /** + * Clears specified context of canvas element + * @param {CanvasRenderingContext2D} ctx Context to clear + * @chainable + */ + clearContext(ctx: CanvasRenderingContext2D): StaticCanvas; + + /** + * Returns context of canvas where objects are drawn + */ + getContext(): CanvasRenderingContext2D; + + /** + * Clears all contexts (background, main, top) of an instance + */ + clear(): StaticCanvas; + + /** + * Renders both the top canvas and the secondary container canvas. + * @param {Boolean} [allOnTop] Whether we want to force all images to be rendered on the top canvas + * @chainable + */ + renderAll(allOnTop?: boolean): StaticCanvas; + + /** + * Method to render only the top canvas. + * Also used to render the group selection box. + * @chainable + */ + renderTop(): StaticCanvas; + + /** + * Returns coordinates of a center of canvas. + * Returned value is an object with top and left properties + */ + getCenter(): { top: number; left: number; }; + /** + * Centers object horizontally. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @param {fabric.Object} object Object to center horizontally + */ + centerObjectH(object: Object): StaticCanvas; + + /** + * Centers object vertically. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @param {fabric.Object} object Object to center vertically + */ + centerObjectV(object: Object): StaticCanvas; + + /** + * Centers object vertically and horizontally. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @param {fabric.Object} object Object to center vertically and horizontally + */ + centerObject(object: Object): StaticCanvas; + + /** + * Returs dataless JSON representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toDatalessJSON(propertiesToInclude?: any[]): string; + + /** + * Returns object representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toObject(propertiesToInclude?: any[]): any; + + /** + * Returns dataless object representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toDatalessObject(propertiesToInclude?: any[]): any; + + /** + * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, + * a zoomed canvas will then produce zoomed SVG output. + */ + svgViewportTransformation: boolean; + + /** + * Returns SVG representation of canvas + * @param {Object} [options] Options object for SVG output + * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation. + */ + toSVG(options: IToSVGOptions, reviver?: Function): string; + + /** + * Moves an object to the bottom of the stack of drawn objects + * @param {fabric.Object} object Object to send to back + * @chainable + */ + sendToBack(object: Object): StaticCanvas; + + /** + * Moves an object to the top of the stack of drawn objects + * @param {fabric.Object} object Object to send + * @chainable + */ + bringToFront(object: Object): StaticCanvas; + + /** + * Moves an object down in stack of drawn objects + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object + * @chainable + */ + sendBackwards(object: Object): StaticCanvas; + + /** + * Moves an object up in stack of drawn objects + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object + * @chainable + */ + bringForward(object: Object): StaticCanvas; + /** + * Moves an object to specified level in stack of drawn objects + * @param {fabric.Object} object Object to send + * @param {Number} index Position to move to + * @chainable + */ + moveTo(object: Object, index: number): StaticCanvas; + + /** + * Clears a canvas element and removes all event listeners + */ + dispose(): StaticCanvas; + + /** + * Returns a string representation of an instance + */ + toString(): string; + + /** + * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately + * @param {Object} [options] Options object + */ + toDataURL(options?: IDataURLOptions): string; + + /** + * Provides a way to check support of some of the canvas methods + * (either those of HTMLCanvasElement itself, or rendering context) + * @param {String} methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" + * @return {Boolean | null} `true` if method is supported (or at least exists), null` if canvas element or context can not be initialized + */ + supports(methodName: string): boolean; + + /** + * Populates canvas with data from the specified JSON. + * JSON format must conform to the one of toJSON formats + * @param {String|Object} json JSON string or object + * @param {Function} callback Callback, invoked when json is parsed + * and corresponding objects (e.g: {@link fabric.Image}) + * are initialized + * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. + */ + loadFromJSON(json: string|any, callback: Function, reviver?: Function): Canvas; + /** + * Clones canvas instance + * @param {Object} [callback] Receives cloned instance as a first argument + * @param {Array} [properties] Array of properties to include in the cloned canvas and children + */ + clone(callback: (canvas: StaticCanvas) => any, properties?: any[]): void; + + /** + * Clones canvas instance without cloning existing data. + * This essentially copies canvas dimensions, clipping properties, etc. + * but leaves data empty (so that you can populate it with your own) + * @param {Object} [callback] Receives cloned instance as a first argument + */ + cloneWithoutData(callback: (canvas: StaticCanvas) => any): void; + + /** + * Callback; invoked right before object is about to be scaled/rotated + */ + onBeforeScaleRotate(target: Object): void; + + // Functions from object straighten mixin + // -------------------------------------------------------------------------------------------------------------------------------- + + /** + * Straightens object, then rerenders canvas + * @param {fabric.Object} object Object to straighten + */ + straightenObject(object: Object): StaticCanvas + + /** + * Same as straightenObject, but animated + * @param {fabric.Object} object Object to straighten + */ + fxStraightenObject(object: Object): StaticCanvas + + + static EMPTY_JSON: string; + /** + * Provides a way to check support of some of the canvas methods + * (either those of HTMLCanvasElement itself, or rendering context) + * @param {String} methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" + */ + static supports(methodName: string): boolean; + /** + * Returns JSON representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + static toJSON(propertiesToInclude?: any[]): string; +} + +interface ICanvasOptions extends IStaticCanvasOptions { + /** + * When true, objects can be transformed by one side (unproportionally) + */ + uniScaleTransform?: boolean; + + /** + * When true, objects use center point as the origin of scale transformation. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + */ + centeredScaling?: boolean; + + /** + * When true, objects use center point as the origin of rotate transformation. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + */ + centeredRotation?: boolean; + + /** + * Indicates that canvas is interactive. This property should not be changed. + */ + interactive?: boolean; + + /** + * Indicates whether group selection should be enabled + */ + selection?: boolean; + + /** + * Color of selection + */ + selectionColor?: string; + + /** + * Default dash array pattern + * If not empty the selection border is dashed + */ + selectionDashArray?: any[]; + + /** + * Color of the border of selection (usually slightly darker than color of selection itself) + */ + selectionBorderColor?: string; + + /** + * Width of a line used in object/group selection + */ + selectionLineWidth?: number; + + /** + * Default cursor value used when hovering over an object on canvas + */ + hoverCursor?: string; + + /** + * Default cursor value used when moving an object on canvas + */ + moveCursor?: string; + + /** + * Default cursor value used for the entire canvas + */ + defaultCursor?: string; + + /** + * Cursor value used during free drawing + */ + freeDrawingCursor?: string; + + /** + * Cursor value used for rotation point + */ + rotationCursor?: string; + + /** + * Default element class that's given to wrapper (div) element of canvas + */ + containerClass?: string; + + /** + * When true, object detection happens on per-pixel basis rather than on per-bounding-box + */ + perPixelTargetFind?: boolean; + + /** + * Number of pixels around target pixel to tolerate (consider active) during object detection + */ + targetFindTolerance?: number; + + /** + * When true, target detection is skipped when hovering over canvas. This can be used to improve performance. + */ + skipTargetFind?: boolean; + + /** + * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing. + * After mousedown, mousemove creates a shape, + * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas. + */ + isDrawingMode?: boolean; +} +export interface Canvas extends StaticCanvas {} +export interface Canvas extends ICanvasOptions {} +export class Canvas { + /** + * Constructor + * @param {HTMLElement|String} element element to initialize instance on + * @param {Object} [options] Options object + */ + constructor(element: HTMLCanvasElement | string, options?: ICanvasOptions); + + _objects: Object[]; + + /** + * Checks if point is contained within an area of given object + * @param {Event} e Event object + * @param {fabric.Object} target Object to test against + */ + containsPoint(e: Event, target: Object): boolean; + /** + * Deactivates all objects on canvas, removing any active group or object + * @return {fabric.Canvas} thisArg + */ + deactivateAll(): Canvas; + /** + * Deactivates all objects and dispatches appropriate events + * @param {Event} [e] Event (passed along when firing) + * @return {fabric.Canvas} thisArg + */ + deactivateAllWithDispatch(e?: Event): Canvas; + /** + * Discards currently active group + * @param {Event} [e] Event (passed along when firing) + * @return {fabric.Canvas} thisArg + */ + discardActiveGroup(e?: Event): Canvas; + /** + * Discards currently active object + * @param {Event} [e] Event (passed along when firing) + * @return {fabric.Canvas} thisArg + * @chainable + */ + discardActiveObject(e?: Event): Canvas; + /** + * Draws objects' controls (borders/controls) + * @param {CanvasRenderingContext2D} ctx Context to render controls on + */ + drawControls(ctx: CanvasRenderingContext2D): void; + /** + * Method that determines what object we are clicking on + * @param {Event} e mouse event + * @param {Boolean} skipGroup when true, group is skipped and only objects are traversed through + */ + findTarget(e: MouseEvent, skipGroup: boolean): Canvas; + /** + * Returns currently active group + * @return {fabric.Group} Current group + */ + getActiveGroup(): Group; + /** + * Returns currently active object + * @return {fabric.Object} active object + */ + getActiveObject(): Object; + /** + * Returns pointer coordinates relative to canvas. + * @param {Event} e + * @return {Object} object with "x" and "y" number values + */ + getPointer(e: Event, ignoreZoom?: boolean, upperCanvasEl?: CanvasRenderingContext2D): { x: number; y: number; }; + /** + * Returns context of canvas where object selection is drawn + * @return {CanvasRenderingContext2D} + */ + getSelectionContext(): CanvasRenderingContext2D; + /** + * Returns element on which object selection is drawn + * @return {HTMLCanvasElement} + */ + getSelectionElement(): HTMLCanvasElement; + /** + * Returns true if object is transparent at a certain location + * @param {fabric.Object} target Object to check + * @param {Number} x Left coordinate + * @param {Number} y Top coordinate + */ + isTargetTransparent(target: Object, x: number, y: number): boolean; + /** + * Sets active group to a speicified one + * @param {fabric.Group} group Group to set as a current one + * @param {Event} [e] Event (passed along when firing) + */ + setActiveGroup(group: Group, e?: Event): Canvas; + /** + * Sets given object as the only active object on canvas + * @param {fabric.Object} object Object to set as an active one + * @param {Event} [e] Event (passed along when firing "object:selected") + */ + setActiveObject(object: Object, e?: Event): Canvas; + /** + * Set the cursor type of the canvas element + * @param {String} value Cursor type of the canvas element. + * @see http://www.w3.org/TR/css3-ui/#cursor + */ + setCursor(value: string): void; + + /** + * Removes all event listeners + */ + removeListeners(): void + + static EMPTY_JSON: string; + /** + * Provides a way to check support of some of the canvas methods + * (either those of HTMLCanvasElement itself, or rendering context) + * @param {String} methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" + */ + static supports(methodName: string): boolean; + /** + * Returns JSON representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + static toJSON(propertiesToInclude?: any[]): string; +} + +/////////////////////////////////////////////////////////////////////////////// +// Shape Interfaces +////////////////////////////////////////////////////////////////////////////// + +interface ICircleOptions extends IObjectOptions { + /** + * Radius of this circle + */ + radius?: number; + /** + * Start angle of the circle, moving clockwise + */ + startAngle?: number; + + /** + * End angle of the circle + */ + endAngle?: number; +} +export interface Circle extends Object, ICircleOptions {} +export class Circle { + constructor(options?: ICircleOptions); + + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance + */ + complexity(): number; + /** + * Returns horizontal radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRadiusX(): number; + /** + * Returns vertical radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRadiusY(): number; + /** + * Sets radius of an object (and updates width accordingly) + * @return {Number} + */ + setRadius(value: number): number; + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement}) + */ + static ATTRIBUTE_NAMES: string[]; + /** + * Returns Circle instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options: ICircleOptions): Circle; + /** + * Returns Circle instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Circle; +} + +interface IEllipseOptions extends IObjectOptions { + /** + * Horizontal radius + */ + rx?: number; + /** + * Vertical radius + */ + ry?: number; +} +export interface Ellipse extends Object, IEllipseOptions {} +export class Ellipse { + constructor(options?: IEllipseOptions); + + /** + * Returns horizontal radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRx(): number; + + /** + * Returns Vertical radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRy(): number; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + /** + * Returns complexity of an instance + * @return {Number} complexity + */ + complexity(): number; + + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement}) + */ + static ATTRIBUTE_NAMES: string[]; + + /** + * Returns Ellipse instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options?: IEllipseOptions): Ellipse; + + /** + * Returns Ellipse instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Ellipse; +} + +export interface Group extends Object, ICollection {} +export class Group { + /** + * Constructor + * @param {Object} objects Group objects + * @param {Object} [options] Options object + */ + constructor(items?: any[], options?: IObjectOptions); + + activateAllObjects(): Group; + /** + * Adds an object to a group; Then recalculates group's dimension, position. + * @param {Object} object + * @return {fabric.Group} thisArg + * @chainable + */ + addWithUpdate(object: Object): Group; + containsPoint(point: Point): boolean; + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg + * @chainable + */ + destroy(): Group; + /** + * Returns requested property + * @param {String} prop Property to get + * @return {Any} + */ + get(prop: string): any; + /** + * Checks whether this group was moved (since `saveCoords` was called last) + * @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called) + */ + hasMoved(): boolean; + /** + * Removes an object from a group; Then recalculates group's dimension, position. + * @param {Object} object + * @return {fabric.Group} thisArg + * @chainable + */ + removeWithUpdate(object: Object): Group; + /** + * Renders instance on a given context + * @param {CanvasRenderingContext2D} ctx context to render instance on + */ + render(ctx: CanvasRenderingContext2D): void; + /** + * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) + * @param {...fabric.Object} object Zero or more fabric instances + * @return {Self} thisArg + * @chainable + */ + remove(...object: Object[]): Group; + /** + * Saves coordinates of this instance (to be used together with `hasMoved`) + * @saveCoords + * @return {fabric.Group} thisArg + * @chainable + */ + saveCoords(): Group; + /** + * Sets coordinates of all group objects + * @return {fabric.Group} thisArg + * @chainable + */ + setObjectsCoords(): Group; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns string represenation of a group + * @return {String} + */ + toString(): string; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * Returns {@link fabric.Group} instance from an object representation + * @param {Object} object Object to create a group from + * @param {Function} [callback] Callback to invoke when an group instance is created + */ + static fromObject(object: any, callback: (group: Group) => any): void; +} + +interface IImageOptions extends IObjectOptions { + /** + * crossOrigin value (one of "", "anonymous", "allow-credentials") + */ + crossOrigin: string; + + /** + * AlignX value, part of preserveAspectRatio (one of "none", "mid", "min", "max") + * This parameter defines how the picture is aligned to its viewport when image element width differs from image width. + */ + alignX: string; + + /** + * AlignY value, part of preserveAspectRatio (one of "none", "mid", "min", "max") + * This parameter defines how the picture is aligned to its viewport when image element height differs from image height. + */ + alignY: string; + + /** + * meetOrSlice value, part of preserveAspectRatio (one of "meet", "slice"). + * if meet the image is always fully visibile, if slice the viewport is always filled with image. + * @see http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute + */ + meetOrSlice: string; + + /** + * Image filter array + */ + filters: IBaseFilter[]; +} +interface Image extends Object, IImageOptions {} +export class Image { + /** + * Constructor + * @param {HTMLImageElement | String} element Image element + * @param {Object} [options] Options object + */ + constructor(element: HTMLImageElement, objObjects: IObjectOptions); + + initialize(element?: string|HTMLImageElement, options?: IImageOptions): void; + /** + * Applies filters assigned to this image (from "filters" array) + * @param {Function} callback Callback is invoked when all filters have been applied and new image is generated + */ + applyFilters(callback: Function): void; + /** + * Returns a clone of an instance + * @param {Function} callback Callback is invoked with a clone as a first argument + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + clone(callback?: Function, propertiesToInclude?: any[]): Object; + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance + */ + complexity(): number; + /** + * Returns image element which this instance if based on + * @return {HTMLImageElement} Image element + */ + getElement(): HTMLImageElement; + /** + * Returns original size of an image + * @return {Object} Object with "width" and "height" properties + */ + getOriginalSize(): { width: number; height: number; }; + /** + * Returns source of an image + * @return {String} Source of an image + */ + getSrc(): string; + render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; + + /** + * Sets image element for this instance to a specified one. + * If filters defined they are applied to new image. + * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area. + * @param {HTMLImageElement} element + * @param {Function} [callback] Callback is invoked when all filters have been applied and new image is generated + * @param {Object} [options] Options object + */ + setElement(element: HTMLImageElement, callback: Function, options: IImageOptions): Image; + /** + * Sets crossOrigin value (on an instance and corresponding image element) + */ + setCrossOrigin(value: string): Image; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns string representation of an instance + * @return {String} String representation of an instance + */ + toString(): string; + /** + * Returns SVG representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + /** + * Sets source of an image + * @param {String} src Source string (URL) + * @param {Function} [callback] Callback is invoked when image has been loaded (and all filters have been applied) + * @param {Object} [options] Options object + */ + setSrc(src: string, callback: Function, options: IImageOptions): Image; + + /** + * Creates an instance of fabric.Image from an URL string + * @param {String} url URL to create an image from + * @param {Function} [callback] Callback to invoke when image is created (newly created image is passed as a first argument) + * @param {Object} [imgOptions] Options object + */ + static fromURL(url: string, callback?: (image: Image) => any, objObjects?: IObjectOptions): Image; + /** + * Creates an instance of fabric.Image from its object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an image instance is created + */ + static fromObject(object: any, callback: (image: Image) => {}): void; + /** + * Returns Image instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Function} callback Callback to execute when fabric.Image object is created + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, callback: Function, options?: IImageOptions): void; + /** + * Default CSS class name for canvas + */ + static CSS_CANVAS: string; + + static filters: IAllFilters; +} + +interface ILineOptions extends IObjectOptions { + /** + * x value or first line edge + */ + x1: number; + /** + * x value or second line edge + */ + x2: number; + /** + * y value or first line edge + */ + y1: number; + /** + * y value or second line edge + */ + y2: number; +} +export interface Line extends Object, ILineOptions {} +export class Line { + /** + * Constructor + * @param {Array} [points] Array of points + * @param {Object} [options] Options object + */ + constructor(points?: number[], objObjects?: IObjectOptions); + /** + * Returns complexity of an instance + * @return {Number} complexity + */ + complexity(): number; + initialize(points?: number[], options?: ILineOptions): Line; + /** + * Returns object representation of an instance + * @methd toObject + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude: any[]): any; + /** + * Returns SVG representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + static ATTRIBUTE_NAMES: string[]; + /** + * Returns fabric.Line instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options?: ILineOptions): Line; + /** + * Returns fabric.Line instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Line; +} + +interface IObjectOptions { + /** + * Type of an object (rect, circle, path, etc.). + * Note that this property is meant to be read-only and not meant to be modified. + * If you modify, certain parts of Fabric (such as JSON loading) won't work correctly. + */ + type?: string; + + /** + * Horizontal origin of transformation of an object (one of "left", "right", "center") + */ + originX?: string; + + /** + * Vertical origin of transformation of an object (one of "top", "bottom", "center") + */ + originY?: string; + + /** + * Top position of an object. Note that by default it's relative to object center. You can change this by setting originY={top/center/bottom} + */ + top?: number; + + /** + * Left position of an object. Note that by default it's relative to object center. You can change this by setting originX={left/center/right} + */ + left?: number; + + /** + * Object width + */ + width?: number; + + /** + * Object height + */ + height?: number; + + /** + * Object scale factor (horizontal) + */ + scaleX?: number; + + /** + * Object scale factor (vertical) + */ + scaleY?: number; + + /** + * When true, an object is rendered as flipped horizontally + */ + flipX?: boolean; + + /** + * When true, an object is rendered as flipped vertically + */ + flipY?: boolean; + + /** + * Opacity of an object + */ + opacity?: number; + + /** + * Angle of rotation of an object (in degrees) + */ + angle?: number; + + /** + * Size of object's controlling corners (in pixels) + */ + cornerSize?: number; + + /** + * When true, object's controlling corners are rendered as transparent inside (i.e. stroke instead of fill) + */ + transparentCorners?: boolean; + + /** + * Default cursor value used when hovering over this object on canvas + */ + hoverCursor?: string; + + /** + * Padding between object and its controlling borders (in pixels) + */ + padding?: number; + + /** + * Color of controlling borders of an object (when it's active) + */ + borderColor?: string; + + /** + * Color of controlling corners of an object (when it's active) + */ + cornerColor?: string; + + /** + * When true, this object will use center point as the origin of transformation + * when being scaled via the controls. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + */ + centeredScaling?: boolean; + + /** + * When true, this object will use center point as the origin of transformation + * when being rotated via the controls. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + */ + centeredRotation?: boolean; + + /** + * Color of object's fill + */ + fill?: string; + + /** + * Fill rule used to fill an object + * accepted values are nonzero, evenodd + * Backwards incompatibility note: This property was used for setting globalCompositeOperation until v1.4.12, use `globalCompositeOperation` instead + */ + fillRule?: string; + + /** + * Composite rule used for canvas globalCompositeOperation + */ + globalCompositeOperation?: string; + + /** + * Background color of an object. Only works with text objects at the moment. + */ + backgroundColor?: string; + + /** + * When defined, an object is rendered via stroke and this property specifies its color + */ + stroke?: string; + + /** + * Width of a stroke used to render this object + */ + strokeWidth?: number; + + /** + * Array specifying dash pattern of an object's stroke (stroke must be defined) + */ + strokeDashArray?: any[]; + + /** + * Line endings style of an object's stroke (one of "butt", "round", "square") + */ + strokeLineCap?: string; + + /** + * Corner style of an object's stroke (one of "bevil", "round", "miter") + */ + strokeLineJoin?: string; + + /** + * Maximum miter length (used for strokeLineJoin = "miter") of an object's stroke + */ + strokeMiterLimit?: number; + + /** + * Shadow object representing shadow of this shape + */ + shadow?: IShadow|string; + + /** + * Opacity of object's controlling borders when object is active and moving + */ + borderOpacityWhenMoving?: number; + + /** + * Scale factor of object's controlling borders + */ + borderScaleFactor?: number; + + /** + * Transform matrix (similar to SVG's transform matrix) + */ + transformMatrix?: any[]; + + /** + * Minimum allowed scale value of an object + */ + minScaleLimit?: number; + + /** + * When set to `false`, an object can not be selected for modification (using either point-click-based or group-based selection). + * But events still fire on it. + */ + selectable?: boolean; + + /** + * When set to `false`, an object can not be a target of events. All events propagate through it. Introduced in v1.3.4 + */ + evented?: boolean; + + /** + * When set to `false`, an object is not rendered on canvas + */ + visible?: boolean; + + /** + * When set to `false`, object's controls are not displayed and can not be used to manipulate object + */ + hasControls?: boolean; + + /** + * When set to `false`, object's controlling borders are not rendered + */ + hasBorders?: boolean; + + /** + * When set to `false`, object's controlling rotating point will not be visible or selectable + */ + hasRotatingPoint?: boolean; + + /** + * Offset for object's controlling rotating point (when enabled via `hasRotatingPoint`) + */ + rotatingPointOffset?: number; + + /** + * When set to `true`, objects are "found" on canvas on per-pixel basis rather than according to bounding box + */ + perPixelTargetFind?: boolean; + + /** + * When `false`, default object's values are not included in its serialization + */ + includeDefaultValues?: boolean; + + /** + * Function that determines clipping of an object (context is passed as a first argument) + * Note that context origin is at the object's center point (not left/top corner) + * @type Function + */ + clipTo?: Function; + + /** + * When `true`, object horizontal movement is locked + */ + lockMovementX?: boolean; + + /** + * When `true`, object vertical movement is locked + */ + lockMovementY?: boolean; + + /** + * When `true`, object rotation is locked + */ + lockRotation?: boolean; + + /** + * When `true`, object horizontal scaling is locked + */ + lockScalingX?: boolean; + + /** + * When `true`, object vertical scaling is locked + */ + lockScalingY?: boolean; + + /** + * When `true`, object non-uniform scaling is locked + */ + lockUniScaling?: boolean; + + /** + * When `true`, object cannot be flipped by scaling into negative values + */ + lockScalingFlip?: boolean; + + /** + * Not used by fabric, just for convenience + */ + name?: string; + + /** + * Not used by fabric, just for convenience + */ + data?: any; +} +export interface Object extends IObservable, IObjectOptions, IObjectAnimation {} +export class Object { + getCurrentWidth(): number; + getCurrentHeight(): number; + + getAngle(): number; + setAngle(value: number): Object; + + getBorderColor(): string; + setBorderColor(value: string): Object; + + getBorderScaleFactor(): number; + + getCornersize(): number; + setCornersize(value: number): Object; + + getFill(): string; + setFill(value: string): Object; + + getFillRule(): string; + setFillRule(value: string): Object; + + getFlipX(): boolean; + setFlipX(value: boolean): Object; + + getFlipY(): boolean; + setFlipY(value: boolean): Object; + + getHeight(): number; + setHeight(value: number): Object; + + getLeft(): number; + setLeft(value: number): Object; + + getOpacity(): number; + setOpacity(value: number): Object; + + overlayFill: string; + getOverlayFill(): string; + setOverlayFill(value: string): Object; + + getScaleX(): number; + setScaleX(value: number): Object; + + getScaleY(): number; + setScaleY(value: number): Object; + + setShadow(options: any): Object; + getShadow(): Object; + + stateProperties: any[]; + getTop(): number; + setTop(value: number): Object; + + getWidth(): number; + setWidth(value: number): Object; + + /* * Sets object's properties from options + * @param {Object} [options] Options object + */ + setOptions(options: any): void; + + /** + * Transforms context when rendering an object + * @param {CanvasRenderingContext2D} ctx Context + * @param {Boolean} fromLeft When true, context is transformed to object's top/left corner. This is used when rendering text on Node + */ + transform(ctx: CanvasRenderingContext2D, fromLeft: boolean): void; + + /** + * Returns an object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toObject(propertiesToInclude?: any[]): any; + + /** + * Returns (dataless) object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toDatalessObject(propertiesToInclude?: any[]): any; + + /** + * Returns a string representation of an instance + */ + toString(): string; + + /** + * Basic getter + * @param {String} property Property name + */ + get(property: string): any; + + /** + * Sets property to a given value. + * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. + * If you need to update those, call `setCoords()`. + * @param {String} key Property name + * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one) + */ + set(key: string, value: any|Function): Object; + /** + * Sets property to a given value. + * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. + * If you need to update those, call `setCoords()`. + * @param Object key Property object, iterate over the object properties + */ + set(key: any): Object; + + /** + * Toggles specified property from `true` to `false` or from `false` to `true` + * @param {String} property Property to toggle + */ + toggle(property: string): Object; + + /** + * Sets sourcePath of an object + * @param {String} value Value to set sourcePath to + */ + setSourcePath(value: string): Object; + + /** + * Retrieves viewportTransform from Object's canvas if possible + */ + getViewportTransform(): boolean; + + /** + * Renders an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Boolean} [noTransform] When true, context is not transformed + */ + render(ctx: CanvasRenderingContext2D, noTransform?: boolean): void; + + /** + * Clones an instance + * @param {Function} callback Callback is invoked with a clone as a first argument + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + clone(callback: Function, propertiesToInclude?: any[]): Object; + + /** + * Creates an instance of fabric.Image out of an object + * @param {Function} callback callback, invoked with an instance as a first argument + */ + cloneAsImage(callback: (image: Image) => any): Object; + + /** + * Converts an object into a data-url-like string + * @param options Options object + */ + toDataURL(options: IDataURLOptions): string; + + /** + * Returns true if specified type is identical to the type of an instance + * @param {String} type Type to check against + */ + isType(type: string): boolean; + + /** + * Returns complexity of an instance + */ + complexity(): number; + + /** + * Returns a JSON representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toJSON(propertiesToInclude?: any[]): any; + + /** + * Sets gradient (fill or stroke) of an object + * Backwards incompatibility note: This method was named "setGradientFill" until v1.1.0 + * @param {String} property Property name 'stroke' or 'fill' + * @param {Object} [options] Options object + */ + setGradient(property: string, options: IGradientOptions): Object; + /** + * Sets pattern fill of an object + * @param {Object} options Options object + */ + setPatternFill(options: IFillOptions): Object; + + /** + * Sets shadow of an object + * @param {String} [options] Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)") + */ + setShadow(options?: string): Object; + /** + * Sets shadow of an object + * @param [options] Options object + */ + setShadow(options: IShadow): Object; + + /** + * Sets "color" of an instance (alias of `set('fill', …)`) + * @param {String} color Color value + */ + setColor(color: string): Object; + + /** + * Sets "angle" of an instance + * @param {Number} angle Angle value + */ + setAngle(angle: number): Object; + + /** + * Sets "angle" of an instance + * @param {Number} angle Angle value + */ + rotate(angle: number): Object; + + /** + * Centers object horizontally on canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + */ + centerH(): void; + + /** + * Centers object vertically on canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + */ + centerV(): void; + + /** + * Centers object vertically and horizontally on canvas to which is was added last + * You might need to call `setCoords` on an object after centering, to update controls area. + */ + center(): void; + + /** + * Removes object from canvas to which it was added last + */ + remove(): Object; + + /** + * Returns coordinates of a pointer relative to an object + * @param {Event} e Event to operate upon + * @param {Object} [pointer] Pointer to operate upon (instead of event) + */ + getLocalPointer(e: Event, pointer: any): any; + + /** + * Sets object's properties from options + * @param {Object} [options] Options object + */ + setOptions(options: any): void; + /** + * Sets sourcePath of an object + * @param {String} value Value to set sourcePath to + */ + setSourcePath(value: string): Object; + // functions from object svg export mixin + // ----------------------------------------------------------------------------------------------------------------------------------- + /** + * Returns styles-string for svg-export + */ + getSvgStyles(): string; + /** + * Returns transform-string for svg-export + */ + getSvgTransform(): string; + /** + * Returns transform-string for svg-export from the transform matrix of single elements + */ + getSvgTransformMatrix(): string; + + // functions from stateful mixin + // ----------------------------------------------------------------------------------------------------------------------------------- + /** + * Returns true if object state (one of its state properties) was changed + */ + hasStateChanged(): boolean; + /** + * Saves state of an object + * @param {Object} [options] Object with additional `stateProperties` array to include when saving state + * @return {fabric.Object} thisArg + */ + saveState(options?: { stateProperties: any[] }): Object; + /** + * Setups state of an object + */ + setupState(): Object; + // functions from object straightening mixin + // ----------------------------------------------------------------------------------------------------------------------------------- + /** + * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) + */ + straighten(): Object; + /** + * Same as straighten but with animation + * @param {Object} callbacks Object with callback functions + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + */ + fxStraighten(callbacks: { onComplete?: Function; onChange: Function }): Object; + + // functions from object stacking mixin + // ----------------------------------------------------------------------------------------------------------------------------------- + /** + * Moves an object up in stack of drawn objects + * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object + */ + bringForward(intersecting?: boolean): Object; + /** + * Moves an object to the top of the stack of drawn objects + */ + bringToFront(): Object; + /** + * Moves an object down in stack of drawn objects + * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object + */ + sendBackwards(intersecting?: boolean): Object; + /** + * Moves an object to the bottom of the stack of drawn objects + */ + sendToBack(): Object; + /** + * Moves an object to specified level in stack of drawn objects + * @param {Number} index New position of object + */ + moveTo(index: number): Object; + + // functions from object origin mixin + // ----------------------------------------------------------------------------------------------------------------------------------- + /** + * Translates the coordinates from origin to center coordinates (based on the object's dimensions) + * @param {fabric.Point} point The point which corresponds to the originX and originY params + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + */ + translateToCenterPoint(point: Point, originX: string, originY: string): Point; + + /** + * Translates the coordinates from center to origin coordinates (based on the object's dimensions) + * @param {fabric.Point} center The point which corresponds to center of the object + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + */ + translateToOriginPoint(center: Point, originX: string, originY: string): Point; + /** + * Returns the real center coordinates of the object + */ + getCenterPoint(): Point; + + /** + * Returns the coordinates of the object as if it has a different origin + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + */ + getPointByOrigin(): Point; + + /** + * Returns the point in local coordinates + * @param {fabric.Point} point The point relative to the global coordinate system + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + */ + toLocalPoint(point: Point, originX: string, originY: string): Point; + + /** + * Sets the position of the object taking into consideration the object's origin + * @param {fabric.Point} pos The new position of the object + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {void} + */ + setPositionByOrigin(pos: Point, originX: string, originY: string): void; + + /** + * @param {String} to One of 'left', 'center', 'right' + */ + adjustPosition(to: string): void; + + // functions from interactivity mixin + // ----------------------------------------------------------------------------------------------------------------------------------- + /**- + * Draws borders of an object's bounding box. + * Requires public properties: width, height + * Requires public options: padding, borderColor + * @param {CanvasRenderingContext2D} ctx Context to draw on + */ + drawBorders(context: CanvasRenderingContext2D): Object; + + /** + * Draws corners of an object's bounding box. + * Requires public properties: width, height + * Requires public options: cornerSize, padding + * @param {CanvasRenderingContext2D} ctx Context to draw on + */ + drawCorners(context: CanvasRenderingContext2D): Object; + + /** + * Returns true if the specified control is visible, false otherwise. + * @param {String} controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. + */ + isControlVisible(controlName: string): boolean; + /** + * Sets the visibility of the specified control. + * @param {String} controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. + * @param {Boolean} visible true to set the specified control visible, false otherwise + */ + setControlVisible(controlName: string, visible: boolean): Object; + + /** + * Sets the visibility state of object controls. + * @param {Object} [options] Options object + */ + setControlsVisibility(options?: { + bl?: boolean; + br?: boolean; + mb?: boolean; + ml?: boolean; + mr?: boolean; + mt?: boolean; + tl?: boolean; + tr?: boolean; + mtr?: boolean; }): Object; + + // functions from geometry mixin + // ------------------------------------------------------------------------------------------------------------------------------- + /** + * Sets corner position coordinates based on current angle, width and height + * See https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords + */ + setCoords(): Object; + /** + * Returns coordinates of object's bounding rectangle (left, top, width, height) + * @return {Object} Object with left, top, width, height properties + */ + getBoundingRect(): { left: number; top: number; width: number; height: number }; + /** + * Checks if object is fully contained within area of another object + * @param {Object} other Object to test + */ + isContainedWithinObject(other: Object): boolean; + /** + * Checks if object is fully contained within area formed by 2 points + * @param {Object} pointTL top-left point of area + * @param {Object} pointBR bottom-right point of area + */ + isContainedWithinRect(pointTL: any, pointBR: any): boolean; + /** + * Checks if point is inside the object + * @param {fabric.Point} point Point to check against + */ + containsPoint(point: Point): boolean; + /** + * Scales an object (equally by x and y) + * @param {Number} value Scale factor + * @return {fabric.Object} thisArg + */ + scale(value: number): Object; + /** + * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) + * @param {Number} value New height value + */ + scaleToHeight(value: number): Object; + /** + * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) + * @param {Number} value New width value + */ + scaleToWidth(value: number): Object; + /** + * Checks if object intersects with another object + * @param {Object} other Object to test + */ + intersectsWithObject(other: Object): boolean; + /** + * Checks if object intersects with an area formed by 2 points + * @param {Object} pointTL top-left point of area + * @param {Object} pointBR bottom-right point of area + */ + intersectsWithRect(pointTL: any, pointBR: any): boolean; +} + +interface IPathOptions extends IObjectOptions { + /** + * Array of path points + */ + path?: any[]; + + /** + * Minimum X from points values, necessary to offset points + */ + minX?: number; + + /** + * Minimum Y from points values, necessary to offset points + */ + minY?: number; +} +export interface IPath extends Object, IPathOptions {} +export class IPath { + /** + * Constructor + * @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens) + * @param {Object} [options] Options object + */ + constructor(path?: string|any[], options?: IPathOptions); + + initialize(path?: any[], options?: IPathOptions): IPath; + + /** + * Returns number representation of an instance complexity + * @return {Number} complexity of this instance + */ + complexity(): number; + + /** + * Renders path on a specified context + * @param {CanvasRenderingContext2D} ctx context to render path on + * @param {Boolean} [noTransform] When true, context is not transformed + */ + render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; + /** + * Returns dataless object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toDatalessObject(propertiesToInclude?: any[]): any; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns string representation of an instance + * @return {String} string representation of an instance + */ + toString(): string; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * Creates an instance of fabric.Path from an SVG element + * @param {SVGElement} element to parse + * @param {Function} callback Callback to invoke when an fabric.Path instance is created + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, callback: (path: IPath) => any, options?: IPathOptions): void; + /** + * Creates an instance of fabric.Path from an object + * @param {Object} object + * @param {Function} callback Callback to invoke when an fabric.Path instance is created + */ + static fromObject(object: any, callback: (path: IPath) => any): void; +} + +export class PathGroup extends Object { + /** + * Constructor + * @param {Array} paths + * @param {Object} [options] Options object + */ + constructor(paths: IPath[], options?: IObjectOptions); + + initialize(paths: IPath[], options?: IObjectOptions): void; + /** + * Returns number representation of object's complexity + * @return {Number} complexity + */ + complexity(): number; + /** + * Returns true if all paths in this group are of same color + * @return {Boolean} true if all paths are of the same color (`fill`) + */ + isSameColor(): boolean; + /** + * Renders this group on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render this instance on + */ + render(ctx: CanvasRenderingContext2D): void; + /** + * Returns dataless object representation of this path group + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} dataless object representation of an instance + */ + toDatalessObject(propertiesToInclude?: any[]): any; + /** + * Returns object representation of this path group + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns a string representation of this path group + * @return {String} string representation of an object + */ + toString(): string; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + /** + * Returns all paths in this path group + * @return {Array} array of path objects included in this path group + */ + getObjects(): IPath[]; + + static fromObject(object: any): PathGroup; + /** + * Creates fabric.PathGroup instance from an object representation + * @static + * @memberOf fabric.PathGroup + * @param {Object} object Object to create an instance from + * @param {Function} callback Callback to invoke when an fabric.PathGroup instance is created + */ + static fromObject(object: any, callback: (group: PathGroup) => any): void; +} + +interface IPolygonOptions extends IObjectOptions { + /** + * Points array + */ + points?: Point[]; + + /** + * Minimum X from points values, necessary to offset points + */ + minX?: number; + + /** + * Minimum Y from points values, necessary to offset points + */ + minY?: number; +} +export interface Polygon extends IPolygonOptions {} +export class Polygon extends Object { + /** + * Constructor + * @param {Array} points Array of points + * @param {Object} [options] Options object + */ + constructor(points: Array<{ x: number; y: number }>, options?: IObjectOptions, skipOffset?: boolean); + + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance + */ + complexity(): number; + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) + */ + static ATTRIBUTE_NAMES: string[]; + + /** + * Returns Polygon instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options?: IPolygonOptions): Polygon; + /** + * Returns fabric.Polygon instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Polygon; +} + +interface IPolylineOptions extends IObjectOptions { + /** + * Points array + */ + points?: Point[]; + + /** + * Minimum X from points values, necessary to offset points + */ + minX?: number; + + /** + * Minimum Y from points values, necessary to offset points + */ + minY?: number; +} +export interface Polyline extends IPolylineOptions {} +export class Polyline extends Object { + /** + * Constructor + * @param {Array} points Array of points (where each point is an object with x and y) + * @param {Object} [options] Options object + * @param {Boolean} [skipOffset] Whether points offsetting should be skipped + */ + constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions); + initialize(points: Point[], options?: IPolylineOptions): void; + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance + */ + complexity(): number; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toObject(propertiesToInclude?: any[]): any; + /** + * Returns SVG representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) + */ + static ATTRIBUTE_NAMES: string[]; + + /** + * Returns Polyline instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options?: IPolylineOptions): Polyline; + /** + * Returns fabric.Polyline instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Polyline; +} + +interface IRectOptions extends IObjectOptions { + x?: number; + y?: number; + /** + * Horizontal border radius + */ + rx?: number; + + /** + * Vertical border radius + */ + ry?: number; + +} +export interface Rect extends IRectOptions {} +export class Rect extends Object { + /** + * Constructor + * @param {Object} [options] Options object + */ + constructor(options?: IRectOptions); + initialize(points?: number[], options?: any): Rect; + /** + * Returns complexity of an instance + * @return {Number} complexity + */ + complexity(): number; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude: any[]): any; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) + */ + static ATTRIBUTE_NAMES: string[]; + /** + * Returns Rect instance from an SVG element + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options?: IRectOptions): Rect; + /** + * Returns Rect instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Rect; +} + +interface ITextOptions extends IObjectOptions { + /** + * Font size (in pixels) + */ + fontSize?: number; + /** + * Font weight (e.g. bold, normal, 400, 600, 800) + */ + fontWeight?: number|string; + /** + * Font family + */ + fontFamily?: string; + /** + * Text decoration Possible values?: "", "underline", "overline" or "line-through". + */ + textDecoration?: string; + /** + * Text alignment. Possible values?: "left", "center", or "right". + */ + textAlign?: string; + /** + * Font style . Possible values?: "", "normal", "italic" or "oblique". + */ + fontStyle?: string; + /** + * Line height + */ + lineHeight?: number; + /** + * When defined, an object is rendered via stroke and this property specifies its color. + * Backwards incompatibility note?: This property was named "strokeStyle" until v1.1.6 + */ + stroke?: string; + /** + * Shadow object representing shadow of this shape. + * Backwards incompatibility note?: This property was named "textShadow" (String) until v1.2.11 + */ + shadow?: IShadow|string; + /** + * Background color of text lines + */ + textBackgroundColor?: string; + + path?: string; + useNative?: Boolean; + text?: string; +} +export interface Text extends ITextOptions {} +export class Text extends Object { + /** + * Constructor + * @param {String} text Text string + * @param {Object} [options] Options object + */ + constructor(text: string, options?: ITextOptions); + /** + * Returns complexity of an instance + */ + complexity(): number; + /** + * Returns string representation of an instance + */ + toString(): string; + /** + * Renders text instance on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + toObject(propertiesToInclude?: any[]): Object; + /** + * Returns SVG representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + */ + toSVG(reviver?: Function): string; + /** + * Retrieves object's fontSize + */ + getFontSize(): number; + /** + * Sets object's fontSize + * @param {Number} fontSize Font size (in pixels) + */ + setFontSize(fontSize: number): Text; + /** + * Retrieves object's fontWeight + */ + getFontWeight(): number|string; + /** + * Sets object's fontWeight + * @param {(Number|String)} fontWeight Font weight + */ + setFontWeight(fontWeight: string|number): Text; + /** + * Retrieves object's fontFamily + */ + getFontFamily(): string; + /** + * Sets object's fontFamily + * @param {String} fontFamily Font family + */ + setFontFamily(fontFamily: string): Text; + /** + * Retrieves object's text + */ + getText(): string; + /** + * Sets object's text + * @param {String} text Text + */ + setText(text: string): Text; + /** + * Retrieves object's textDecoration + */ + getTextDecoration(): string; + /** + * Sets object's textDecoration + * @param {String} textDecoration Text decoration + */ + setTextDecoration(textDecoration: string): Text; + /** + * Retrieves object's fontStyle + */ + getFontStyle(): string; + /** + * Sets object's fontStyle + * @param {String} fontStyle Font style + */ + setFontStyle(fontStyle: string): Text; + /** + * Retrieves object's lineHeight + */ + getLineHeight(): number; + /** + * Sets object's lineHeight + * @param {Number} lineHeight Line height + */ + setLineHeight(lineHeight: number): Text; + /** + * Retrieves object's textAlign + */ + getTextAlign(): string; + /** + * Sets object's textAlign + * @param {String} textAlign Text alignment + */ + setTextAlign(textAlign: string): Text; + /** + * Retrieves object's textBackgroundColor + */ + getTextBackgroundColor(): string; + /** + * Sets object's textBackgroundColor + * @param {String} textBackgroundColor Text background color + */ + setTextBackgroundColor(textBackgroundColor: string): Text; + + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Text.fromElement`) + */ + static ATTRIBUTE_NAMES: string[]; + /** + * Default SVG font size + */ + static DEFAULT_SVG_FONT_SIZE: number; + + /** + * Returns fabric.Text instance from an SVG element (not yet implemented) + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, options?: ITextOptions): Text; + /** + * Returns fabric.Text instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Text; +} + +interface IITextOptions extends IObjectOptions, ITextOptions { + /** + * Index where text selection starts (or where cursor is when there is no selection) + */ + selectionStart?: number; + + /** + * Index where text selection ends + */ + selectionEnd?: number; + + /** + * Color of text selection + */ + selectionColor?: string; + + /** + * Indicates whether text is in editing mode + */ + isEditing?: boolean; + + /** + * Indicates whether a text can be edited + */ + editable?: boolean; + + /** + * Border color of text object while it's in editing mode + */ + editingBorderColor?: string; + + /** + * Width of cursor (in px) + */ + cursorWidth?: number; + + /** + * Color of default cursor (when not overwritten by character style) + */ + cursorColor?: string; + + /** + * Delay between cursor blink (in ms) + */ + cursorDelay?: number; + + /** + * Duration of cursor fadein (in ms) + */ + cursorDuration?: number; + + /** + * Object containing character styles + * (where top-level properties corresponds to line number and 2nd-level properties -- to char number in a line) + */ + styles?: any; + + /** + * Indicates whether internal text char widths can be cached + */ + caching?: boolean; +} +export interface IText extends Text, IITextOptions {} +export class IText extends Object { + /** + * Constructor + * @param {String} text Text string + * @param {Object} [options] Options object + */ + constructor(text: string, options?: IITextOptions); + /** + * Returns true if object has no styling + */ + isEmptyStyles(): boolean; + render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; + /** + * Returns object representation of an instance + * @method toObject + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject(propertiesToInclude?: any[]): Object; + + setText(value: string): Text; + /** + * Sets selection start (left boundary of a selection) + * @param {Number} index Index to set selection start to + */ + setSelectionStart(index: number): void; + /** + * Sets selection end (right boundary of a selection) + * @param {Number} index Index to set selection end to + */ + setSelectionEnd(index: number): void; + /** + * Gets style of a current selection/cursor (at the start position) + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at + * @return {Object} styles Style object at a specified (or current) index + */ + getSelectionStyles(startIndex: number, endIndex: number): any; + /** + * Sets style of a current selection + * @param {Object} [styles] Styles object + * @return {fabric.IText} thisArg + * @chainable + */ + setSelectionStyles(styles: any): Text; + + /** + * Renders cursor or selection (depending on what exists) + */ + renderCursorOrSelection(): void; + + /** + * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) + * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. + */ + get2DCursorLocation(selectionStart?: number): void; + /** + * Returns complete style of char at the current cursor + * @param {Number} lineIndex Line index + * @param {Number} charIndex Char index + * @return {Object} Character style + */ + getCurrentCharStyle(lineIndex: number, charIndex: number): any; + + /** + * Returns fontSize of char at the current cursor + * @param {Number} lineIndex Line index + * @param {Number} charIndex Char index + * @return {Number} Character font size + */ + getCurrentCharFontSize(lineIndex: number, charIndex: number): number; + + /** + * Returns color (fill) of char at the current cursor + * @param {Number} lineIndex Line index + * @param {Number} charIndex Char index + * @return {String} Character color (fill) + */ + getCurrentCharColor(lineIndex: number, charIndex: number): string; + /** + * Renders cursor + * @param {Object} boundaries + */ + renderCursor(boundaries: any): void; + + /** + * Renders text selection + * @param {Array} chars Array of characters + * @param {Object} boundaries Object with left/top/leftOffset/topOffset + */ + renderSelection(chars: string[], boundaries: any): void; + + // functions from itext behavior mixin + // ------------------------------------------------------------------------------------------------------------------------ + /** + * Initializes all the interactive behavior of IText + */ + initBehavior(): void; + + /** + * Initializes "selected" event handler + */ + initSelectedHandler(): void; + + /** + * Initializes "added" event handler + */ + initAddedHandler(): void; + + initRemovedHandler(): void; + + /** + * Initializes delayed cursor + */ + initDelayedCursor(restart: boolean): void; + + /** + * Aborts cursor animation and clears all timeouts + */ + abortCursorAnimation(): void; + + /** + * Selects entire text + */ + selectAll(): void; + + /** + * Returns selected text + */ + getSelectedText(): string; + + /** + * Find new selection index representing start of current word according to current selection index + * @param {Number} startFrom Surrent selection index + * @return {Number} New selection index + */ + findWordBoundaryLeft(startFrom: number): number; + + /** + * Find new selection index representing end of current word according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findWordBoundaryRight(startFrom: number): number; + + /** + * Find new selection index representing start of current line according to current selection index + * @param {Number} startFrom Current selection index + */ + findLineBoundaryLeft(startFrom: number): number; + + /** + * Find new selection index representing end of current line according to current selection index + * @param {Number} startFrom Current selection index + */ + findLineBoundaryRight(startFrom: number): number; + + /** + * Returns number of newlines in selected text + */ + getNumNewLinesInSelectedText(): number; + + /** + * Finds index corresponding to beginning or end of a word + * @param {Number} selectionStart Index of a character + * @param {Number} direction: 1 or -1 + */ + searchWordBoundary(selectionStart: number, direction: number): number; + + /** + * Selects a word based on the index + * @param {Number} selectionStart Index of a character + */ + selectWord(selectionStart: number): void; + /** + * Selects a line based on the index + * @param {Number} selectionStart Index of a character + */ + selectLine(selectionStart: number): void; + + /** + * Enters editing state + */ + enterEditing(): IText; + + /** + * Initializes "mousemove" event handler + */ + initMouseMoveHandler(): void; + /** + * Exits from editing state + * @return {fabric.IText} thisArg + * @chainable + */ + exitEditing(): IText; + + /** + * Inserts a character where cursor is (replacing selection if one exists) + * @param {String} _chars Characters to insert + */ + insertChars(_chars: string, useCopiedStyle?: boolean): void; + /** + * Inserts new style object + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Boolean} isEndOfLine True if it's end of line + */ + insertNewlineStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; + + /** + * Inserts style object for a given line/char index + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Object} [style] Style object to insert, if given + */ + insertCharStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; + + /** + * Inserts style object(s) + * @param {String} _chars Characters at the location where style is inserted + * @param {Boolean} isEndOfLine True if it's end of line + * @param {Boolean} [useCopiedStyle] Style to insert + */ + insertStyleObjects(_chars: string, isEndOfLine: boolean, useCopiedStyle?: boolean): void; + + /** + * Shifts line styles up or down + * @param {Number} lineIndex Index of a line + * @param {Number} offset Can be -1 or +1 + */ + shiftLineStyles(lineIndex: number, offset: number): void; + + /** + * Removes style object + * @param {Boolean} isBeginningOfLine True if cursor is at the beginning of line + * @param {Number} [index] Optional index. When not given, current selectionStart is used. + */ + removeStyleObject(isBeginningOfLine: boolean, index?: number): void; + /** + * Inserts new line + */ + insertNewline(): void; + + /** + * Returns fabric.IText instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): IText; +} + +interface ITriangleOptions extends IObjectOptions { } +export class Triangle extends Object { + /** + * Constructor + * @param {Object} [options] Options object + */ + constructor(options?: ITriangleOptions); + + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance + */ + complexity(): number; + /** + * Returns SVG representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + + /** + * Returns Triangle instance from an object representation + * @param {Object} object Object to create an instance from + */ + static fromObject(object: any): Triangle; +} + +//////////////////////////////////////////////////////////// +// Filters +//////////////////////////////////////////////////////////// +interface IAllFilters { + BaseFilter: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: any): IBaseFilter; + }; + Blend: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: { color?: string; mode?: string; alpha?: number; image?: Image }): IBlendFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IBlendFilter + }; + Brightness: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Number} [options.brightness=0] Value to brighten the image up (0..255) + */ + new (options?: { brightness: number }): IBrightnessFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IBrightnessFilter + }; + Convolute: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Boolean} [options.opaque=false] Opaque value (true/false) + * @param {Array} [options.matrix] Filter matrix + */ + new (options?: { opaque?: boolean; matrix?: number[] }): IConvoluteFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IConvoluteFilter + }; + GradientTransparency: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Number} [options.threshold=100] Threshold value + */ + new (options?: { threshold?: number; }): IGradientTransparencyFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IGradientTransparencyFilter + }; + Grayscale: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: any): IGrayscaleFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IGrayscaleFilter + }; + Invert: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: any): IInvertFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IInvertFilter + }; + Mask: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {fabric.Image} [options.mask] Mask image object + * @param {Number} [options.channel=0] Rgb channel (0, 1, 2 or 3) + */ + new (options?: { mask?: Image; channel: number; }): IMaskFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IMaskFilter + }; + Multiply: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Number} [options.color=#000000] Color to multiply the image pixels with + */ + new (options?: { color: string; }): IMultiplyFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IMultiplyFilter + }; + Noise: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Number} [options.noise=0] Noise value + */ + new (options?: { noise: number; }): INoiseFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): INoiseFilter + }; + Pixelate: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Number} [options.blocksize=4] Blocksize for pixelate + */ + new (options?: { blocksize?: number; }): IPixelateFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IPixelateFilter + }; + RemoveWhite: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {Number} [options.threshold=30] Threshold value + * @param {Number} [options.distance=20] Distance value + */ + new (options?: { threshold?: number; distance?: number; }): IRemoveWhiteFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IRemoveWhiteFilter + }; + Resize: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: any): IResizeFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): IResizeFilter + }; + Sepia2: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: any): ISepia2Filter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): ISepia2Filter + }; + Sepia: { + /** + * Constructor + * @param {Object} [options] Options object + */ + new (options?: any): ISepiaFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): ISepiaFilter + }; + Tint: { + /** + * Constructor + * @param {Object} [options] Options object + * @param {String} [options.color=#000000] Color to tint the image with + * @param {Number} [options.opacity] Opacity value that controls the tint effect's transparency (0..1) + */ + new (options?: { color?: string; opacity?: number; }): ITintFilter; + /** + * Returns filter instance from an object representation + * @param {Object} object Object to create an instance from + */ + fromObject(object: any): ITintFilter + }; +} +interface IBaseFilter { + /** + * Sets filter's properties from options + * @param {Object} [options] Options object + */ + setOptions(options?: any): void; + /** + * Returns object representation of an instance + */ + toObject(): any; + /** + * Returns a JSON representation of an instance + */ + toJSON(): string; +} +interface IBlendFilter extends IBaseFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IBrightnessFilter extends IBaseFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IConvoluteFilter extends IBaseFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IGradientTransparencyFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IGrayscaleFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IInvertFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IMaskFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IMultiplyFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface INoiseFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IPixelateFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IRemoveWhiteFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface IResizeFilter { + /** + * Resize type + */ + resizeType: string; + + /** + * Scale factor for resizing, x axis + */ + scaleX: number; + + /** + * Scale factor for resizing, y axis + */ + scaleY: number; + + /** + * LanczosLobes parameter for lanczos filter + */ + lanczosLobes: number; + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface ISepiaFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface ISepia2Filter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} +interface ITintFilter { + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; +} + +//////////////////////////////////////////////////////////// +// Brushes +//////////////////////////////////////////////////////////// +export class BaseBrush { + /** + * Color of a brush + */ + color: string; + + /** + * Width of a brush + */ + width: number; + + /** + * Shadow object representing shadow of this shape. + * Backwards incompatibility note: This property replaces "shadowColor" (String), "shadowOffsetX" (Number), + * "shadowOffsetY" (Number) and "shadowBlur" (Number) since v1.2.12 + */ + shadow: IShadow|string; + /** + * Line endings style of a brush (one of "butt", "round", "square") + */ + strokeLineCap: string; + + /** + * Corner style of a brush (one of "bevil", "round", "miter") + */ + strokeLineJoin: string; + + /** + * Stroke Dash Array. + */ + strokeDashArray: any[]; + + /** + * Sets shadow of an object + * @param {Object|String} [options] Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)") + */ + setShadow(options: string|any): BaseBrush; + +} +export class CircleBrush extends BaseBrush { + /** + * Width of a brush + */ + width: number; + /** + * Invoked inside on mouse down and mouse move + * @param {Object} pointer + */ + drawDot(pointer: any): void; + + /** + * @param {Object} pointer + * @return {fabric.Point} Just added pointer point + */ + addPoint(pointer: any): Point +} +export class SprayBrush extends BaseBrush { + /** + * Width of a brush + */ + width: number; + /** + * Density of a spray (number of dots per chunk) + */ + density: number; + + /** + * Width of spray dots + */ + dotWidth: number; + /** + * Width variance of spray dots + */ + dotWidthVariance: number; + + /** + * Whether opacity of a dot should be random + */ + randomOpacity: boolean; + /** + * Whether overlapping dots (rectangles) should be removed (for performance reasons) + */ + optimizeOverlapping: boolean; + /** + * @param {Object} pointer + */ + addSprayChunk(pointer: any): void +} +export class PatternBrush extends PencilBrush { + getPatternSrc(): HTMLCanvasElement; + + getPatternSrcFunction(): string; + + /** + * Creates "pattern" instance property + */ + getPattern(): any; + /** + * Creates path + */ + createPath(pathData: string): IPath; +} +export class PencilBrush extends BaseBrush { + /** + * Converts points to SVG path + * @param {Array} points Array of points + * @param {Number} minX + * @param {Number} minY + */ + convertPointsToSVGPath(points: Array<{ x: number; y: number }>, minX?: number, minY?: number): string[]; + + /** + * Creates fabric.Path object to add on canvas + * @param {String} pathData Path data + */ + createPath(pathData: string): IPath; +} + +/////////////////////////////////////////////////////////////////////////////// +// Fabric util Interface +////////////////////////////////////////////////////////////////////////////// +interface IUtilAnimationOptions { + /** + * Starting value + */ + startValue?: number; + /** + * Ending value + */ + endValue?: number; + /** + * Value to modify the property by + */ + byValue: number; + /** + * Duration of change (in ms) + */ + duration?: number; + /** + * Callback; invoked on every value change + */ + onChange?: Function; + /** + * Callback; invoked when value change is completed + */ + onComplete?: Function; + /** + * Easing function + */ + easing?: Function; +} +interface IUtilAnimation { + /** + * Changes value from one to another within certain period of time, invoking callbacks as value is being changed. + * @param {Object} [options] Animation options + */ + animate(options?: IUtilAnimationOptions): void; + /** + * requestAnimationFrame polyfill based on http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + * In order to get a precise start time, `requestAnimFrame` should be called as an entry into the method + * @param {Function} callback Callback to invoke + */ + requestAnimFrame(callback: Function): void; +} + +type IUtilAminEaseFunction = (t: number, b: number, c: number, d: number) => number; + +interface IUtilAnimEase { + easeInBack: IUtilAminEaseFunction; + easeInBounce: IUtilAminEaseFunction; + easeInCirc: IUtilAminEaseFunction; + easeInCubic: IUtilAminEaseFunction; + easeInElastic: IUtilAminEaseFunction; + easeInExpo: IUtilAminEaseFunction; + easeInOutBack: IUtilAminEaseFunction; + easeInOutBounce: IUtilAminEaseFunction; + easeInOutCirc: IUtilAminEaseFunction; + easeInOutCubic: IUtilAminEaseFunction; + easeInOutElastic: IUtilAminEaseFunction; + easeInOutExpo: IUtilAminEaseFunction; + easeInOutQuad: IUtilAminEaseFunction; + easeInOutQuart: IUtilAminEaseFunction; + easeInOutQuint: IUtilAminEaseFunction; + easeInOutSine: IUtilAminEaseFunction; + easeInQuad: IUtilAminEaseFunction; + easeInQuart: IUtilAminEaseFunction; + easeInQuint: IUtilAminEaseFunction; + easeInSine: IUtilAminEaseFunction; + easeOutBack: IUtilAminEaseFunction; + easeOutBounce: IUtilAminEaseFunction; + easeOutCirc: IUtilAminEaseFunction; + easeOutCubic: IUtilAminEaseFunction; + easeOutElastic: IUtilAminEaseFunction; + easeOutExpo: IUtilAminEaseFunction; + easeOutQuad: IUtilAminEaseFunction; + easeOutQuart: IUtilAminEaseFunction; + easeOutQuint: IUtilAminEaseFunction; + easeOutSine: IUtilAminEaseFunction; +} + +interface IUtilArc { + /** + * Draws arc + * @param {CanvasRenderingContext2D} ctx + * @param {Number} fx + * @param {Number} fy + * @param {Array} coords + */ + drawArc(ctx: CanvasRenderingContext2D, fx: number, fy: number, coords: number[]): void; + /** + * Calculate bounding box of a elliptic-arc + * @param {Number} fx start point of arc + * @param {Number} fy + * @param {Number} rx horizontal radius + * @param {Number} ry vertical radius + * @param {Number} rot angle of horizontal axe + * @param {Number} large 1 or 0, whatever the arc is the big or the small on the 2 points + * @param {Number} sweep 1 or 0, 1 clockwise or counterclockwise direction + * @param {Number} tx end point of arc + * @param {Number} ty + */ + getBoundsOfArc(fx: number, fy: number, rx: number, ry: number, rot: number, large: number, sweep: number, tx: number, ty: number): Point[]; + /** + * Calculate bounding box of a beziercurve + * @param {Number} x0 starting point + * @param {Number} y0 + * @param {Number} x1 first control point + * @param {Number} y1 + * @param {Number} x2 secondo control point + * @param {Number} y2 + * @param {Number} x3 end of beizer + * @param {Number} y3 + */ + getBoundsOfCurve(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): Point[]; + +} + +interface IUtilDomEvent { + /** + * Cross-browser wrapper for getting event's coordinates + * @param {Event} event Event object + * @param {HTMLCanvasElement} upperCanvasEl <canvas> element on which object selection is drawn + */ + getPointer(event: Event, upperCanvasEl: HTMLCanvasElement): Point; + + /** + * Adds an event listener to an element + * @param {HTMLElement} element + * @param {String} eventName + * @param {Function} handler + */ + addListener(element: HTMLElement, eventName: string, handler: Function): void; + + /** + * Removes an event listener from an element + * @param {HTMLElement} element + * @param {String} eventName + * @param {Function} handler + */ + removeListener(element: HTMLElement, eventName: string, handler: Function): void; +} + +interface IUtilDomMisc { + /** + * Takes id and returns an element with that id (if one exists in a document) + * @param {String|HTMLElement} id + */ + getById(id: string|HTMLElement): HTMLElement; + /** + * Converts an array-like object (e.g. arguments or NodeList) to an array + * @param {Object} arrayLike + */ + toArray(arrayLike: any): any[]; + /** + * Creates specified element with specified attributes + * @memberOf fabric.util + * @param {String} tagName Type of an element to create + * @param {Object} [attributes] Attributes to set on an element + * @return {HTMLElement} Newly created element + */ + makeElement(tagName: string, attributes?: any): HTMLElement; + /** + * Adds class to an element + * @param {HTMLElement} element Element to add class to + * @param {String} className Class to add to an element + */ + addClass(element: HTMLElement, classname: string): void; + /** + * Wraps element with another element + * @param {HTMLElement} element Element to wrap + * @param {HTMLElement|String} wrapper Element to wrap with + * @param {Object} [attributes] Attributes to set on a wrapper + */ + wrapElement(element: HTMLElement, wrapper: HTMLElement|string, attributes?: any): HTMLElement; + /** + * Returns element scroll offsets + * @param {HTMLElement} element Element to operate on + * @param {HTMLElement} upperCanvasEl Upper canvas element + */ + getScrollLeftTop(element: HTMLElement, upperCanvasEl: HTMLElement): { left: number; right: number; }; + /** + * Returns offset for a given element + * @param {HTMLElement} element Element to get offset for + */ + getElementOffset(element: HTMLElement): { left: number; right: number; }; + /** + * Returns style attribute value of a given element + * @param {HTMLElement} element Element to get style attribute for + * @param {String} attr Style attribute to get for element + */ + getElementStyle(elment: HTMLElement, attr: string): string; + /** + * Inserts a script element with a given url into a document; invokes callback, when that script is finished loading + * @memberOf fabric.util + * @param {String} url URL of a script to load + * @param {Function} callback Callback to execute when script is finished loading + */ + getScript(url: string, callback: Function): void; + /** + * Makes element unselectable + * @param {HTMLElement} element Element to make unselectable + */ + makeElementUnselectable(element: HTMLElement): HTMLElement; + /** + * Makes element selectable + * @param {HTMLElement} element Element to make selectable + */ + makeElementSelectable(element: HTMLElement): HTMLElement; +} + +interface IUtilDomRequest { + /** + * Cross-browser abstraction for sending XMLHttpRequest + * @param {String} url URL to send XMLHttpRequest to + * @param {Object} [options] Options object + * @param {String} [options.method="GET"] + * @param {Function} options.onComplete Callback to invoke when request is completed + */ + request(url: string, options?: { method?: string; onComplete: Function }): XMLHttpRequest; +} + +interface IUtilDomStyle { + /** + * Cross-browser wrapper for setting element's style + * @param {HTMLElement} element + * @param {Object} styles + */ + setStyle(element: HTMLElement, styles: any): HTMLElement; +} + +interface IUtilArray { + /** + * Invokes method on all items in a given array + * @param {Array} array Array to iterate over + * @param {String} method Name of a method to invoke + */ + invoke(array: any[], method: string): any[]; + /** + * Finds minimum value in array (not necessarily "first" one) + * @param {Array} array Array to iterate over + * @param {String} byProperty + */ + min(array: any[], byProperty: string): any; + /** + * Finds maximum value in array (not necessarily "first" one) + * @param {Array} array Array to iterate over + * @param {String} byProperty + */ + max(array: any[], byProperty: string): any; +} + +interface IUtilClass { + /** + * Helper for creation of "classes". + * @param {Function} [parent] optional "Class" to inherit from + * @param {Object} [properties] Properties shared by all instances of this class + * (be careful modifying objects defined here as this would affect all instances) + */ + createClass(parent: Function, properties?: any): void; + /** + * Helper for creation of "classes". + * @param {Object} [properties] Properties shared by all instances of this class + * (be careful modifying objects defined here as this would affect all instances) + */ + createClass(properties?: any): void; + +} + +interface IUtilObject { + /** + * Copies all enumerable properties of one object to another + * @param {Object} destination Where to copy to + * @param {Object} source Where to copy from + */ + extend(destination: any, source: any): any; + + /** + * Creates an empty object and copies all enumerable properties of another object to it + * @memberOf fabric.util.object + * @param {Object} object Object to clone + * @return {Object} + */ + clone(object: any): any; +} + +interface IUtilString { + /** + * Camelizes a string + * @param {String} string String to camelize + */ + camelize(string: string): string; + + /** + * Capitalizes a string + * @param {String} string String to capitalize + * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized + * and other letters stay untouched, if false first letter is capitalized + * and other letters are converted to lowercase. + */ + capitalize(string: string, firstLetterOnly: boolean): string; + + /** + * Escapes XML in a string + * @param {String} string String to escape + */ + escapeXml(string: string): string; +} + +interface IUtilMisc { + /** + * Removes value from an array. + * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf` + * @param {Array} array + * @param {Any} value + */ + removeFromArray(array: any[], value: any): any[]; + + /** + * Returns random number between 2 specified ones. + * @param {Number} min lower limit + * @param {Number} max upper limit + */ + getRandomInt(min: number, max: number): number; + + /** + * Transforms degrees to radians. + * @param {Number} degrees value in degrees + */ + degreesToRadians(degrees: number): number; + + /** + * Transforms radians to degrees. + * @memberOf fabric.util + * @param {Number} radians value in radians + */ + radiansToDegrees(radians: number): number; + + /** + * Rotates `point` around `origin` with `radians` + * @param {fabric.Point} point The point to rotate + * @param {fabric.Point} origin The origin of the rotation + * @param {Number} radians The radians of the angle for the rotation + */ + rotatePoint(point: Point, origin: Point, radians: number): Point; + + /** + * Apply transform t to point p + * @param {fabric.Point} p The point to transform + * @param {Array} t The transform + * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied + */ + transformPoint(p: Point, t: any[], ignoreOffset?: boolean): Point; + + /** + * Invert transformation t + * @param {Array} t The transform + */ + invertTransform(t: any[]): any[]; + + /** + * A wrapper around Number#toFixed, which contrary to native method returns number, not string. + * @param {Number|String} number number to operate on + * @param {Number} fractionDigits number of fraction digits to "leave" + */ + toFixed(number: number, fractionDigits: number): number; + + /** + * Converts from attribute value to pixel value if applicable. + * Returns converted pixels or original value not converted. + * @param {Number|String} value number to operate on + */ + parseUnit(value: number|string, fontSize?: number): number|string; + + /** + * Function which always returns `false`. + */ + falseFunction(): boolean; + + /** + * Returns klass "Class" object of given namespace + * @param {String} type Type of object (eg. 'circle') + * @param {String} namespace Namespace to get klass "Class" object from + */ + getKlass(type: string, namespace: string): any; + + /** + * Returns object of given namespace + * @param {String} namespace Namespace string e.g. 'fabric.Image.filter' or 'fabric' + */ + resolveNamespace(namespace: string): any; + + /** + * Loads image element from given url and passes it to a callback + * @param {String} url URL representing an image + * @param {Function} callback Callback; invoked with loaded image + * @param {Any} [context] Context to invoke callback in + * @param {Object} [crossOrigin] crossOrigin value to set image element to + */ + loadImage(url: string, callback: (image: HTMLImageElement) => {}, context?: any, crossOrigin?: boolean): void; + + /** + * Creates corresponding fabric instances from their object representations + * @param {Array} objects Objects to enliven + * @param {Function} callback Callback to invoke when all objects are created + * @param {String} namespace Namespace to get klass "Class" object from + * @param {Function} reviver Method for further parsing of object elements, called after each fabric object created. + */ + enlivenObjects(objects: any[], callback: Function, namespace: string, reviver?: Function): void; + + /** + * Groups SVG elements (usually those retrieved from SVG document) + * @param {Array} elements SVG elements to group + * @param {Object} [options] Options object + */ + groupSVGElements(elements: any[], options?: any, path?: any): PathGroup; + + /** + * Populates an object with properties of another object + * @param {Object} source Source object + * @param {Object} destination Destination object + * @param {Array} properties Propertie names to include + */ + populateWithProperties(source: any, destination: any, properties: any): void; + + /** + * Draws a dashed line between two points + * This method is used to draw dashed line around selection area. + * @param {CanvasRenderingContext2D} ctx context + * @param {Number} x start x coordinate + * @param {Number} y start y coordinate + * @param {Number} x2 end x coordinate + * @param {Number} y2 end y coordinate + * @param {Array} da dash array pattern + */ + drawDashedLine(ctx: CanvasRenderingContext2D, x: number, y: number, x2: number, y2: number, da: any[]): void; + + /** + * Creates canvas element and initializes it via excanvas if necessary + * @param {CanvasElement} [canvasEl] optional canvas element to initialize; + * when not given, element is created implicitly + */ + createCanvasElement(canvasEl?: HTMLCanvasElement): HTMLCanvasElement; + + /** + * Creates image element (works on client and node) + */ + createImage(): HTMLImageElement; + + /** + * Creates accessors (getXXX, setXXX) for a "class", based on "stateProperties" array + * @param {Object} klass "Class" to create accessors for + */ + createAccessors(klass: any): any; + + /** + * @param {fabric.Object} receiver Object implementing `clipTo` method + * @param {CanvasRenderingContext2D} ctx Context to clip + */ + clipContext(receiver: Object, ctx: CanvasRenderingContext2D): void; + + /** + * Multiply matrix A by matrix B to nest transformations + * @param {Array} a First transformMatrix + * @param {Array} b Second transformMatrix + */ + multiplyTransformMatrices(a: any[], b: any[]): any[]; + + /** + * Returns string representation of function body + * @param {Function} fn Function to get body of + */ + getFunctionBody(fn: Function): string; + + /** + * Returns true if context has transparent pixel + * at specified location (taking tolerance into account) + * @param {CanvasRenderingContext2D} ctx context + * @param {Number} x x coordinate + * @param {Number} y y coordinate + * @param {Number} tolerance Tolerance + */ + isTransparent(ctx: CanvasRenderingContext2D, x: number, y: number, tolerance: number): boolean; +} + +export var util: IUtil; +interface IUtil extends IUtilAnimation, IUtilArc, IObservable, IUtilDomEvent, IUtilDomMisc, + IUtilDomRequest, IUtilDomStyle, IUtilClass, IUtilMisc { + ease: IUtilAnimEase; + array: IUtilArray; + object: IUtilObject; + string: IUtilString; } diff --git a/fabric/tslint.json b/fabric/tslint.json new file mode 100644 index 0000000000..9f552c56eb --- /dev/null +++ b/fabric/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "../tslint.json", + "rules": { + "adjacent-overload-signatures": false, + "forbidden-types": false, + "interface-name": false, + "no-empty-interface": false, + "unified-signatures": false + } +} \ No newline at end of file diff --git a/scripts/lint.js b/scripts/lint.js index 69878d2521..ade9a6b719 100644 --- a/scripts/lint.js +++ b/scripts/lint.js @@ -15,8 +15,6 @@ if (pkg.includes("/")) { const cmd = `node ${tslintPath}/lib/tslint-cli --format stylish "**/*.d.ts"`; console.log(cmd); -console.log(pkg); -process.exit(0); try { // Child process writes directly to our own stdout execSync(cmd, { cwd: pkg, stdio: "inherit" }); From 83d9597309ff7eefdb32ac58db1b0ca6c838bf60 Mon Sep 17 00:00:00 2001 From: Rafael Salguero Iturrios Date: Sat, 7 Jan 2017 18:58:36 -0700 Subject: [PATCH 008/422] x y properties on Point --- leaflet/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index fdaea84934..05950dc68c 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -186,6 +186,8 @@ declare namespace L { equals(otherPoint: PointExpression): boolean; contains(otherPoint: PointExpression): boolean; toString(): string; + x: number; + y: number; } type PointExpression = Point | PointTuple; From b259e475a5fe2737925c146caaf38aad1f32e8c3 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 8 Jan 2017 05:14:37 -0800 Subject: [PATCH 009/422] update-notifier: Add `export =` declaration (#13839) --- scripts/lint.js | 2 +- update-notifier/index.d.ts | 80 +++++++++++++----------- update-notifier/tslint.json | 1 + update-notifier/update-notifier-tests.ts | 8 +-- 4 files changed, 49 insertions(+), 42 deletions(-) create mode 100644 update-notifier/tslint.json diff --git a/scripts/lint.js b/scripts/lint.js index ade9a6b719..ea3ec1d778 100644 --- a/scripts/lint.js +++ b/scripts/lint.js @@ -8,7 +8,7 @@ const path = require("path"); const symlinkedTslintPath = "../node_modules/types-publisher/node_modules/tslint" let tslintPath = existsSync(path.join(pkg, symlinkedTslintPath)) ? symlinkedTslintPath : "../node_modules/tslint"; // An older version (e.g. abs/v0) is in a nested directory, so needs to look one more level up for tslint. -if (pkg.includes("/")) { +if (pkg.includes("/") && pkg[pkg.length - 1] !== "/") { tslintPath = path.join("..", tslintPath); } diff --git a/update-notifier/index.d.ts b/update-notifier/index.d.ts index 6249f8e902..d9d6c8a4cc 100644 --- a/update-notifier/index.d.ts +++ b/update-notifier/index.d.ts @@ -1,47 +1,53 @@ -// Type definitions for update-notifier +// Type definitions for update-notifier 1.0 // Project: https://github.com/yeoman/update-notifier // Definitions by: vvakame , Noah Chen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export interface ISettings { - pkg?: IPackage; - callback?: (update?: IUpdateInfo) => any; - packageName?: string; - packageVersion?: string; - updateCheckInterval?: number; // in milliseconds, default 1000 * 60 * 60 * 24 (1 day) -} +export = UpdateNotifier; -export interface IBoxenOptions { - padding: number; - margin: number; - align: string; - borderColor: string; - borderStyle: string; -} +declare function UpdateNotifier(settings?: UpdateNotifier.Settings): UpdateNotifier.UpdateNotifier; -export interface INotifyOptions { - message: string; - defer?: boolean; - boxenOpts?: IBoxenOptions; -} +declare namespace UpdateNotifier { + class UpdateNotifier { + constructor(settings?: UpdateNotifier.Settings); -export interface IPackage { - name: string; - version: string; -} + update: UpdateNotifier.UpdateInfo; + check(): void; + checkNpm(): void; + notify(customMessage?: UpdateNotifier.NotifyOptions): void; + } -export interface IUpdateInfo { - latest: string; - current: string; - type: string; - name: string; -} + interface Settings { + pkg?: Package; + callback?: (update?: UpdateInfo) => any; + packageName?: string; + packageVersion?: string; + updateCheckInterval?: number; // in milliseconds, default 1000 * 60 * 60 * 24 (1 day) + } -export declare class UpdateNotifier { - constructor(settings?: ISettings); - - update: IUpdateInfo; - check(): void; - checkNpm(): void; - notify(customMessage?: INotifyOptions): void; + interface BoxenOptions { + padding: number; + margin: number; + align: string; + borderColor: string; + borderStyle: string; + } + + interface NotifyOptions { + message: string; + defer?: boolean; + boxenOpts?: BoxenOptions; + } + + interface Package { + name: string; + version: string; + } + + interface UpdateInfo { + latest: string; + current: string; + type: string; + name: string; + } } diff --git a/update-notifier/tslint.json b/update-notifier/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/update-notifier/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file diff --git a/update-notifier/update-notifier-tests.ts b/update-notifier/update-notifier-tests.ts index 0bca5a85ca..a39ead18ea 100644 --- a/update-notifier/update-notifier-tests.ts +++ b/update-notifier/update-notifier-tests.ts @@ -1,7 +1,6 @@ +import UpdateNotifier = require("update-notifier"); -import { UpdateNotifier } from "update-notifier"; - -var notifier = new UpdateNotifier(); +var notifier = UpdateNotifier(); if (notifier.update) { notifier.notify(); @@ -9,7 +8,8 @@ if (notifier.update) { console.log(notifier.update); -var notifier = new UpdateNotifier({ +// Also exposed as a class +var notifier = new UpdateNotifier.UpdateNotifier({ updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week }); From d67e721495d54d8908a3faa16afc34d04b3b514f Mon Sep 17 00:00:00 2001 From: Jay Anslow Date: Sun, 8 Jan 2017 20:27:11 +0000 Subject: [PATCH 010/422] Add definitions for git-remote-origin-url (#13845) --- .../git-remote-origin-url-tests.ts | 4 ++++ git-remote-origin-url/index.d.ts | 8 ++++++++ git-remote-origin-url/tsconfig.json | 20 +++++++++++++++++++ git-remote-origin-url/tslint.json | 1 + 4 files changed, 33 insertions(+) create mode 100644 git-remote-origin-url/git-remote-origin-url-tests.ts create mode 100644 git-remote-origin-url/index.d.ts create mode 100644 git-remote-origin-url/tsconfig.json create mode 100644 git-remote-origin-url/tslint.json diff --git a/git-remote-origin-url/git-remote-origin-url-tests.ts b/git-remote-origin-url/git-remote-origin-url-tests.ts new file mode 100644 index 0000000000..30b5541ab4 --- /dev/null +++ b/git-remote-origin-url/git-remote-origin-url-tests.ts @@ -0,0 +1,4 @@ +import gitRemoteOriginUrl = require('git-remote-origin-url'); + +const url1: Promise = gitRemoteOriginUrl(); +const url2: Promise = gitRemoteOriginUrl('my-custom-path'); diff --git a/git-remote-origin-url/index.d.ts b/git-remote-origin-url/index.d.ts new file mode 100644 index 0000000000..6d648dc322 --- /dev/null +++ b/git-remote-origin-url/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for git-remote-origin-url 2.0 +// Project: https://github.com/sindresorhus/git-remote-origin-url#readme +// Definitions by: Jay Anslow +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function gitRemoteOriginUrl(cwd?: string): Promise; + +export = gitRemoteOriginUrl; diff --git a/git-remote-origin-url/tsconfig.json b/git-remote-origin-url/tsconfig.json new file mode 100644 index 0000000000..2abc29a970 --- /dev/null +++ b/git-remote-origin-url/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "git-remote-origin-url-tests.ts" + ] +} diff --git a/git-remote-origin-url/tslint.json b/git-remote-origin-url/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/git-remote-origin-url/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From d33f09009e26d84eb3b61629b250fc333b51ddb3 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 9 Jan 2017 12:20:28 +1100 Subject: [PATCH 011/422] add walk and walkSync to fs-extra (#13103) * add signature for walkSync * flesh out the response definitions * added example tests * signature changes to let PathEntryStream flow --- fs-extra/fs-extra-tests.ts | 24 +++++++++++++++++++++++ fs-extra/index.d.ts | 40 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/fs-extra/fs-extra-tests.ts b/fs-extra/fs-extra-tests.ts index 0954fcaf47..896d6411f7 100644 --- a/fs-extra/fs-extra-tests.ts +++ b/fs-extra/fs-extra-tests.ts @@ -2,6 +2,7 @@ /// import fs = require('fs-extra'); +import * as Path from 'path' var src: string; var dest: string; @@ -110,3 +111,26 @@ fs.walk("my-path") .on('end', function () { console.dir(items); }); + +const ignoreHiddenFiles = (item: string): boolean => { + const basename = Path.basename(item) + return basename === '.' || basename[0] !== '.' +} + +const sortPaths = (left: string, right: string) => left.localeCompare(right); + +const options = { + filter: ignoreHiddenFiles, + pathSorter: sortPaths +} + +fs.walk(path, options) + .on('readable', function (this: fs.PathEntryStream) { + let item: fs.PathEntry | undefined + while ((item = this.read())) { + items.push(item.path) + } + }) + .on('end', function () { + + }) diff --git a/fs-extra/index.d.ts b/fs-extra/index.d.ts index a6ac95bfc8..2cc47724c8 100644 --- a/fs-extra/index.d.ts +++ b/fs-extra/index.d.ts @@ -7,8 +7,8 @@ /// -import * as stream from 'stream'; import { Stats } from "fs"; + export * from "fs"; export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void; @@ -76,6 +76,8 @@ export declare function emptyDirSync(path: string): boolean; export interface WalkEventEmitter extends NodeJS.ReadableStream { on(event: 'data', callback: (file: WalkEventFile) => void): this; + on(event: 'readable', callback: (this: PathEntryStream) => void): this; + on(event: 'error', callback: (error: Error, item: PathEntry) => void): this; on(event: 'end', callback: () => void): this; on(event: string | symbol, callback: Function): this; } @@ -85,7 +87,41 @@ export interface WalkEventFile { stats: Stats; } -export function walk(path: string, options?: {}): WalkEventEmitter; +export interface WalkOptions { + /** + * Control how results are enumerated from `readdir`: + * - 'shift' will return the first element from the array. + * - 'pop' will return the last element from the array. + * + * If not specified, the default behaviour is 'shift' + */ + queueMethod?: 'pop' | 'shift'; + /** + * Provide a function to sort the paths before they are enumerated + */ + pathSorter?: (left: string, right: string) => number; + /** + * An optional object to override the default `fs` APIs for testing purposes + */ + fs?: Object; + /** + * Provide a function to exclude certain file paths. The function should + * return true when the element should be kept, and false otherwise. + */ + filter?: (path: string, index: number, array: Array) => boolean; +} + +export type PathEntry = { + path: string; + stats: Stats; +} + +export type PathEntryStream = { + read(): PathEntry | null +} + +export function walk(path: string, options?: WalkOptions): WalkEventEmitter; +export function walkSync(path: string): ReadonlyArray; export interface CopyFilterFunction { (src: string): boolean From e446c1813102a26a7e4b7cb5363704a0713ed52e Mon Sep 17 00:00:00 2001 From: Rafael Salguero Iturrios Date: Sun, 8 Jan 2017 18:21:35 -0700 Subject: [PATCH 012/422] Missing zoom parameter on CRS.pointToLatLng method (#13847) http://leafletjs.com/reference.html#icrs-pointtolatlng --- leaflet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index fdaea84934..3e50ded6fd 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -72,7 +72,7 @@ declare namespace L { export interface CRS { latLngToPoint(latlng: LatLngExpression, zoom: number): Point; - pointToLatLng(point: PointExpression): LatLng; + pointToLatLng(point: PointExpression, zoom: number): LatLng; project(latlng: LatLngExpression): Point; unproject(point: PointExpression): LatLng; scale(zoom: number): number; From e93460bfaab9ba4be85a3d70ca05f4b973934634 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 8 Jan 2017 17:44:51 -0800 Subject: [PATCH 013/422] Add `charm` types (#13849) --- charm/charm-tests.ts | 25 +++++++ charm/index.d.ts | 154 +++++++++++++++++++++++++++++++++++++++++++ charm/tsconfig.json | 20 ++++++ charm/tslint.json | 6 ++ 4 files changed, 205 insertions(+) create mode 100644 charm/charm-tests.ts create mode 100644 charm/index.d.ts create mode 100644 charm/tsconfig.json create mode 100644 charm/tslint.json diff --git a/charm/charm-tests.ts b/charm/charm-tests.ts new file mode 100644 index 0000000000..0cdbdc8055 --- /dev/null +++ b/charm/charm-tests.ts @@ -0,0 +1,25 @@ +import getCharm = require("charm"); +const charm = getCharm(); +charm.pipe(process.stdout); +charm.reset(); + +var colors: getCharm.CharmColor[] = [ 'red', 'cyan', 'yellow', 'green', 'blue' ]; +var text = 'Always after me lucky charms.'; + +var offset = 0; +var iv = setInterval(function () { + var y = 0, dy = 1; + for (var i = 0; i < 40; i++) { + var color = colors[(i + offset) % colors.length]; + var c = text[(i + offset) % text.length]; + charm + .move(1, dy) + .foreground(color) + .write(c) + ; + y += dy; + if (y <= 0 || y >= 5) dy *= -1; + } + charm.position(0, 1); + offset ++; +}, 150); diff --git a/charm/index.d.ts b/charm/index.d.ts new file mode 100644 index 0000000000..2ce1b9e13a --- /dev/null +++ b/charm/index.d.ts @@ -0,0 +1,154 @@ +// Type definitions for Charm 1.0 +// Project: https://github.com/substack/node-charm/ +// Definitions by: Jad Sarout +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace charm { + type CharmColorName = "red" | "yellow" | "green" | "blue" | "cyan" | "magenta" | "black" | "white"; + type CharmColorHex = number; + type CharmColor = CharmColorName | CharmColorHex; + type CharmAnyStream = NodeJS.WritableStream|NodeJS.ReadableStream|NodeJS.Process; + + interface CharmInstance extends NodeJS.WritableStream { + /** Reset the entire screen, like the /usr/bin/reset command. */ + reset(): void; + + /** Emit an "end" event downstream. */ + destroy(): void; + + /** Emit an "end" event downstream. */ + end(): void; + + /** + * Pass along `msg` to the output stream. + * @param cb Unused by charm, only there to comply to the WritableStream interface + */ + write(msg: string | Buffer, cb?: Function): boolean; + write(msgs: string | Buffer, encoding?: string, cb?: Function): boolean; + + /** Set the cursor position to the absolute coordinates `x`, `y`. */ + position(x: number, y: number): void; + + /** + * Query the absolute cursor position from the input stream through the output stream + * (the shell does this automatically) and get the response back as `cb(x, y)`. + */ + position(callback: (x: number, y: number) => void): void; + + /** Move the cursor position by the relative coordinates `x`, `y`. */ + move(x: number, y: number): this; + + /** Move the cursor up by `y` rows. */ + up(y: number): this; + + /** Move the cursor down by `y` rows. */ + down(y: number): this; + + /** Move the cursor left by `x` columns. */ + left(x: number): this; + + /** Move the cursor right by `x` columns. */ + right(x: number): this; + + /** Push the cursor state and optionally the attribute state. */ + push(withAttributes?: boolean): this; + + /** Pop the cursor state and optionally the attribute state. */ + pop(withAttributes?: boolean): this; + + /** + * Erase a region defined by the string `s`. + * + * `s` can be: + * + * - end - erase from the cursor to the end of the line + * - start - erase from the cursor to the start of the line + * - line - erase the current line + * - down - erase everything below the current line + * - up - erase everything above the current line + * - screen - erase the entire screen + */ + erase(s: "end"|"start"|"line"|"down"|"up"|"screen"): this; + + /** + * Delete `'line'` or `'char'`s. delete differs from erase because it does not write over + * the deleted characters with whitesapce, but instead removes the deleted space. + * + * mode can be `'line'` or `'char'`. `n` is the number of items to be deleted. + * `n` must be a positive integer. + * + * The cursor position is not updated. + */ + delete(mode: "line"|"char", n?: number): this; + + /** + * Insert space into the terminal. `insert` is the opposite of `delete`, + * + * mode can be `'line'` or `'char'`. `n` is the number of items to be deleted. + * `n` must be a positive integer. + */ + insert(mode: "line"|"char", n: number): this; + /** + * Set the display mode with the string `attr.` + * + * `attr` can be: + * + * - reset + * - bright + * - dim + * - underscore + * - blink + * - reverse + * - hidden + */ + display(attr: "reset" | "bright" | "dim" | "underscore" | "blink" | "reverse" | "hidden"): this; + + /** + * Set the foreground color with the string `color`, which can be: + * + * - red + * - yellow + * - green + * - blue + * - cyan + * - magenta + * - black + * - white + * - or `color` can be an integer from 0 to 255, inclusive. + */ + foreground(color: CharmColor): this; + /** + * Set the background color with the string `color`, which can be: + * + * - red + * - yellow + * - green + * - blue + * - cyan + * - magenta + * - black + * - white + * - or `color` can be an integer from 0 to 255, inclusive. + */ + background(color: CharmColor): this; + + /** Set the cursor visibility with a boolean `visible`. */ + cursor(visible: boolean): any; + + /** Pipes the output of Charm to a writeable stream `stream` */ + pipe(stream: NodeJS.WritableStream): void; + } +} + +/** + * Create a new readable/writable charm stream. + * + * You can pass in readable or writable streams as parameters + * and they will be piped to or from accordingly. + * You can also pass `process` in which case + * `process.stdin` and `process.stdout` will be used. + */ +declare function charm(param?: charm.CharmAnyStream): charm.CharmInstance; +export = charm; diff --git a/charm/tsconfig.json b/charm/tsconfig.json new file mode 100644 index 0000000000..931b421062 --- /dev/null +++ b/charm/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "charm-tests.ts" + ] +} diff --git a/charm/tslint.json b/charm/tslint.json new file mode 100644 index 0000000000..f05741c59b --- /dev/null +++ b/charm/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "forbidden-types": false + } +} From b4fc6f27dc2bcf91c31d536539fe4f48becd18d1 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Mon, 9 Jan 2017 05:24:31 +0100 Subject: [PATCH 014/422] Jest update --- jest/index.d.ts | 68 +++++++++++++++++++++++++++++++++++---- jest/jest-tests.ts | 79 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 140 insertions(+), 7 deletions(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index fda6c66404..6e3d5381a8 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Jest 16.0.0 +// Type definitions for Jest 18.0.0 // Project: http://facebook.github.io/jest/ -// Definitions by: Asana , Ivo Stratev , jwbay +// Definitions by: Asana , Ivo Stratev , jwbay , Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare var beforeAll: jest.Lifecycle; declare var beforeEach: jest.Lifecycle; @@ -16,7 +17,7 @@ declare var xit: jest.It; declare var test: jest.It; declare var xtest: jest.It; -declare function expect(actual: any): jest.Matchers; +declare const expect: jest.Expect; interface NodeRequire { /** Returns the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not. */ @@ -31,8 +32,10 @@ declare namespace jest { function autoMockOff(): typeof jest; /** Enables automatic mocking in the module loader. */ function autoMockOn(): typeof jest; - /** Clears the mock.calls and mock.instances properties of all mocks. Equivalent to calling .mockClear() on every mocked function. */ + /** @deprecated */ function clearAllMocks(): typeof jest; + /** Clears the mock.calls and mock.instances properties of all mocks. Equivalent to calling .mockClear() on every mocked function. */ + function resetAllMocks(): typeof jest; /** Removes any pending timers from the timer system. If any timers have been scheduled, they will be cleared and will never have the opportunity to execute in the future. */ function clearAllTimers(): typeof jest; /** Indicates that the module system should never return a mocked version of the specified module, including all of the specificied module's dependencies. */ @@ -111,6 +114,41 @@ declare namespace jest { skip: Describe; } + interface MatcherUtils { + readonly isNot: boolean; + utils: { + readonly EXPECTED_COLOR: string; + readonly RECEIVED_COLOR: string; + ensureActualIsNumber(actual: any, matcherName?: string): void; + ensureExpectedIsNumber(actual: any, matcherName?: string): void; + ensureNoExpected(actual: any, matcherName?: string): void; + ensureNumbers(actual: any, expected: any, matcherName?: string): void; + /** get the type of a value with handling the edge cases like `typeof []` and `typeof null` */ + getType(value: any): string; + matcherHint(matcherName: string, received?: string, expected?: string, options?: { secondArgument?: string, isDirectExpectCall?: boolean }): string; + pluralize(word: string, count: number): string; + printExpected(value: any): string; + printReceived(value: any): string; + printWithType(name: string, received: any, print: (value: any) => string): string; + stringify(object: {}, maxDepth?: number): string; + } + } + + interface ExpectExtendMap { + [key: string]: (this: MatcherUtils, received: any, actual: any) => { message: () => string, pass: boolean }; + } + + interface Expect { + (actual: any): Matchers; + anything(): void; + any(cs: any): void; + arrayContaining(arr: any[]): void; + assertions(num: number): void; + extend(obj: ExpectExtendMap): void; + objectContaining(obj: {}): void; + stringMatching(str: string | RegExp): void; + } + interface Matchers { not: Matchers; lastCalledWith(...args: any[]): void; @@ -135,9 +173,11 @@ declare namespace jest { toHaveBeenCalledTimes(expected: number): boolean; toHaveBeenCalledWith(...params: any[]): boolean; toHaveBeenLastCalledWith(...params: any[]): boolean; + toHaveLength(expected: number): void; + toHaveProperty(propertyPath: string, value?: any): void; toMatch(expected: string | RegExp): void; toMatchObject(expected: {}): void; - toMatchSnapshot(): void; + toMatchSnapshot(snapshotName?: string): void; toThrow(): void; toThrowError(error?: string | Constructable | RegExp): void; toThrowErrorMatchingSnapshot(): void; @@ -147,9 +187,25 @@ declare namespace jest { new (...args: any[]): any } - interface Mock extends Function { + interface Mock extends Function, MockInstance { new (): T; (...args: any[]): any; + } + + /** + * Wrap module with mock definitions + * @example + * jest.mock("../api"); + * import { Api } from "../api"; + * + * const myApi: jest.Mocked = new Api() as any; + * myApi.myApiMethod.mockImplementation(() => "test"); + */ + type Mocked = T & { + [P in keyof T]: T[P] & MockInstance; + } & MockInstance; + + interface MockInstance { mock: MockContext; mockClear(): void; mockImplementation(fn: Function): Mock; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index 913a671fa1..e1f8fb120f 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -171,6 +171,60 @@ describe('toThrow API', function () { }); }); +describe('Assymetric matchers', function () { + it('works', function () { + expect({ + timestamp: 1480807810388, + text: 'Some text content, but we care only about *this part*' + }).toEqual({ + timestamp: expect.any(Number), + text: expect.stringMatching('*this part*') + }); + + const callback = jest.fn(); + expect(callback).toEqual(expect.any(Function)); + callback(5, "test"); + expect(callback).toBeCalledWith(expect.any(Number), expect.any(String)) + const obj = { + items: [1] + }; + expect(obj).toEqual(expect.objectContaining({ + items: expect.arrayContaining([ + expect.any(Number) + ]) + })); + + expect.assertions(4); + }); +}); + +describe('Extending extend', function () { + it('works', function () { + expect.extend({ + toBeNumber(received: any, actual: any) { + const pass = received === actual; + const message = + () => `expected ${received} ${pass ? 'not ' : ''} to be ${actual}`; + return { message, pass }; + }, + toBeTest(received: any, actual: any) { + this.utils.ensureNoExpected(received); + this.utils.ensureActualIsNumber(received); + this.utils.ensureExpectedIsNumber(actual); + this.utils.ensureNumbers(received, actual); + + return { + message: () => ` + ${this.utils.getType(received).toLowerCase()} \n\n + ${this.utils.matcherHint(".not.toBe")} ${this.utils.printExpected(actual)} ${this.utils.printReceived(received)}\n\n + `, + pass: true + }; + } + }); + }); +}); + describe('missing tests', function () { it('creates closures', function () { class Closure { @@ -208,7 +262,7 @@ describe('missing tests', function () { expect(getFruits()).toContain('Orange'); mock.mockReturnValueOnce(['Apple', 'Plum']); expect(mock()).not.toContain('Orange'); - const myBeverage: any = {delicious: true, sour: false}; + const myBeverage: any = {delicious: true, sour: false}; expect(myBeverage).toContainEqual({delicious: true, sour: false}); mock.mockReturnValue([]); //Deprecated: Use jest.fn(() => value) instead. mock.mockClear(); @@ -248,6 +302,10 @@ describe('toMatchSnapshot', function () { it('compares snapshots', function () { expect({ type: 'a', props: { href: 'https://www.facebook.com/' }, children: [ 'Facebook' ] }).toMatchSnapshot(); }); + + it('can give name to snapshot', function () { + expect({ type: 'a', props: { href: 'https://www.facebook.com/' }, children: [ 'Facebook' ] }).toMatchSnapshot('given name'); + }); }); describe('toThrowErrorMatchingSnapshot', function () { @@ -367,3 +425,22 @@ describe('strictNullChecks', function () { done(); }) }); + +interface TestApi { + testProp: boolean; + testMethod(a: number): void; +} + +describe("Mocked type", function () { + it("Works", function () { + const mock: jest.Mocked = jest.fn(() => ({ + testProp: true, + testMethod1: jest.fn(), + testMethod2: jest.fn() + })) as any; + mock.testProp; + mock.testMethod.mockImplementation(() => "test"); + mock.testMethod(5); + mock.mockClear(); + }); +}); From f2581e2b98d07073207ab3e5685dc44c5435ca32 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Mon, 9 Jan 2017 06:59:08 +0100 Subject: [PATCH 015/422] Added one more example for jest.Mocked --- jest/index.d.ts | 5 +++++ jest/jest-tests.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/jest/index.d.ts b/jest/index.d.ts index 6e3d5381a8..2f246f2bfe 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -200,6 +200,11 @@ declare namespace jest { * * const myApi: jest.Mocked = new Api() as any; * myApi.myApiMethod.mockImplementation(() => "test"); + * + * jest.mock("./func"); + * const myFuncMock: jest.Mocked = require("./func"); + * myFuncMock.mockImplementation(() => 5); + * myFuncMock(); */ type Mocked = T & { [P in keyof T]: T[P] & MockInstance; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index e1f8fb120f..f2866d1689 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -431,6 +431,8 @@ interface TestApi { testMethod(a: number): void; } +declare function mockedFunc(a: number): string; + describe("Mocked type", function () { it("Works", function () { const mock: jest.Mocked = jest.fn(() => ({ @@ -442,5 +444,9 @@ describe("Mocked type", function () { mock.testMethod.mockImplementation(() => "test"); mock.testMethod(5); mock.mockClear(); + + const funcMock: jest.Mocked = require("./mockedFunc"); + funcMock.mockImplementation(() => "test"); + funcMock(5).toUpperCase(); }); }); From 4d1c1d396e7d6ce3268e0fb5d9aacea654cbe4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Blu=CC=88m?= Date: Mon, 9 Jan 2017 08:16:02 +0100 Subject: [PATCH 016/422] DragulaOptions.copy can be a function --- dragula/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dragula/index.d.ts b/dragula/index.d.ts index 98ff1f3108..fe09c409e2 100644 --- a/dragula/index.d.ts +++ b/dragula/index.d.ts @@ -16,7 +16,7 @@ declare namespace dragula { accepts?: (el?: Element, target?: Element, source?: Element, sibling?: Element) => boolean; invalid?: (el?: Element, target?: Element) => boolean; direction?: string; - copy?: boolean; + copy?: ((el: Element, source: Element) => boolean) | boolean; revertOnSpill?: boolean; removeOnSpill?: boolean; delay?: boolean | number; From c0d65d4b72432f755cfd5a08426abe3b59ffc30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Snorre=20Magnus=20Dav=C3=B8en?= Date: Mon, 9 Jan 2017 10:56:16 +0100 Subject: [PATCH 017/422] mongoose: Change MongooseDocument.set return type Fix: Change MongooseDocument.set() return type from void to this. See http://mongoosejs.com/docs/api.html#document_Document-set Modify doc.set() examples in test file to chain the set method in order to test the "this" return type. --- mongoose/index.d.ts | 6 +++--- mongoose/mongoose-tests.ts | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index 92655b871d..56ad48e617 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -1010,9 +1010,9 @@ declare module "mongoose" { * @param type optionally specify a type for "on-the-fly" attributes * @param options optionally specify options that modify the behavior of the set */ - set(path: string, val: any, options?: Object): void; - set(path: string, val: any, type: any, options?: Object): void; - set(value: Object): void; + set(path: string, val: any, options?: Object): this; + set(path: string, val: any, type: any, options?: Object): this; + set(value: Object): this; /** * The return value of this method is used in calls to JSON.stringify(doc). diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index be63241296..c6dfe20fdc 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -449,10 +449,7 @@ doc.populate(function (err, doc) { }); }); doc.populated('path'); -doc.set('path', 999, {}); -doc.set({ - path: 999 -}); +doc.set('path', 999, {}).set({ path: 999 }); doc.toJSON({ getters: true, virtuals: false @@ -1494,4 +1491,4 @@ const extended: mongoose.Model = base.discriminator('extende const x = new extended({ username: 'hi', // required in baseSchema email: 'beddiw', // required in extededSchema -}); \ No newline at end of file +}); From 63322c7d435f6ce215134954920d2509cb8ccfdb Mon Sep 17 00:00:00 2001 From: Rafael Kr Date: Mon, 9 Jan 2017 15:13:14 +0100 Subject: [PATCH 018/422] [bcryptjs] update definitions for v2.4.0 (#13846) * [bcryptjs] update definitions for v2.4.0 * [bcryptjs] update PR based on feedback * [bcryptjs] update PR based on feedback --- bcryptjs/bcryptjs-tests.ts | 13 +++++++++++++ bcryptjs/index.d.ts | 32 ++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/bcryptjs/bcryptjs-tests.ts b/bcryptjs/bcryptjs-tests.ts index 83b67c17cc..cd91eb4896 100644 --- a/bcryptjs/bcryptjs-tests.ts +++ b/bcryptjs/bcryptjs-tests.ts @@ -3,6 +3,7 @@ import bcryptjs = require("bcryptjs"); let str: string; let num: number; let bool: boolean; +let error: Error; str = bcryptjs.genSaltSync(); str = bcryptjs.genSaltSync(10); @@ -13,6 +14,12 @@ bcryptjs.genSalt((err: Error, salt: string) => { bcryptjs.genSalt(10, (err: Error, salt: string) => { str = salt; }); +bcryptjs.genSalt() + .then(salt => str = salt) + .catch(err => error = err); +bcryptjs.genSalt(10) + .then(salt => str = salt) + .catch(err => error = err); str = bcryptjs.hashSync("string"); str = bcryptjs.hashSync("string", 10); @@ -26,6 +33,9 @@ bcryptjs.hash("string", 10, (err: Error, hash: string) => { }, (percent: number) => { num = percent; }); +bcryptjs.hash("string", 10) + .then(salt => str = salt) + .catch(err => error = err); bcryptjs.hash("string", "salt", (err: Error, hash: string) => { str = hash; @@ -46,6 +56,9 @@ bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => { }, (percent: number) => { num = percent; }); +bcryptjs.compare("string1", "string2") + .then(success => bool = success) + .catch(err => error = err); num = bcryptjs.getRounds("string"); diff --git a/bcryptjs/index.d.ts b/bcryptjs/index.d.ts index fd1c0d7903..c081ed33fd 100644 --- a/bcryptjs/index.d.ts +++ b/bcryptjs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for bcryptjs v2.3.0 +// Type definitions for bcryptjs v2.4.0 // Project: https://github.com/dcodeIO/bcrypt.js -// Definitions by: Joshua Filby +// Definitions by: Joshua Filby , Rafael Kraut // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -16,9 +16,17 @@ export declare function setRandomFallback(random: (random: number) => number[]): * Synchronously generates a salt. * @param rounds Number of rounds to use, defaults to 10 if omitted * @return Resulting salt + * @throws If a random fallback is required but not set */ export declare function genSaltSync(rounds?: number): string; +/** + * Asynchronously generates a salt. + * @param rounds Number of rounds to use, defaults to 10 if omitted + * @return Promise with resulting salt, if callback has been omitted + */ +export declare function genSalt(rounds?: number): Promise; + /** * Asynchronously generates a salt. * @param callback Callback receiving the error, if any, and the resulting salt @@ -40,6 +48,14 @@ export declare function genSalt(rounds: number, callback: (err: Error, salt: str */ export declare function hashSync(s: string, salt?: number | string): string; +/** + * Asynchronously generates a hash for the given string. + * @param s String to hash + * @param salt Salt length to generate or salt to use + * @return Promise with resulting hash, if callback has been omitted + */ +export declare function hash(s: string, salt: number | string): Promise; + /** * Asynchronously generates a hash for the given string. * @param s String to hash @@ -47,7 +63,7 @@ export declare function hashSync(s: string, salt?: number | string): string; * @param callback Callback receiving the error, if any, and the resulting hash * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms. */ -export declare function hash(s: string, salt: number | string, callback: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void): void; +export declare function hash(s: string, salt: number | string, callback?: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void): void; /** * Synchronously tests a string against a hash. @@ -57,6 +73,14 @@ export declare function hash(s: string, salt: number | string, callback: (err: E */ export declare function compareSync(s: string, hash: string): boolean; +/** + * Asynchronously compares the given data against the given hash. + * @param s Data to compare + * @param hash Data to be compared to + * @return Promise, if callback has been omitted + */ +export declare function compare(s: string, hash: string): Promise; + /** * Asynchronously compares the given data against the given hash. * @param s Data to compare @@ -64,7 +88,7 @@ export declare function compareSync(s: string, hash: string): boolean; * @param callback Callback receiving the error, if any, otherwise the result * @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms. */ -export declare function compare(s: string, hash: string, callback: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void): void; +export declare function compare(s: string, hash: string, callback?: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void): void; /** * Gets the number of rounds used to encrypt the specified hash. From d3ae5ced6d5876fa65999a62f1566ac9f6958889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Bl=C3=BCm?= Date: Mon, 9 Jan 2017 15:14:06 +0100 Subject: [PATCH 019/422] Dragula: DragulaOptions.copy can also be a function (#13761) * DragulaOptions.copy can be a function In addition to boolean, a callback function is supported. See https://github.com/bevacqua/dragula#optionscopy * Fix missing types --- dragula/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dragula/index.d.ts b/dragula/index.d.ts index 98ff1f3108..fe09c409e2 100644 --- a/dragula/index.d.ts +++ b/dragula/index.d.ts @@ -16,7 +16,7 @@ declare namespace dragula { accepts?: (el?: Element, target?: Element, source?: Element, sibling?: Element) => boolean; invalid?: (el?: Element, target?: Element) => boolean; direction?: string; - copy?: boolean; + copy?: ((el: Element, source: Element) => boolean) | boolean; revertOnSpill?: boolean; removeOnSpill?: boolean; delay?: boolean | number; From 8d3b3fbdc489c764d2e98fa5f633be8cc7ea387a Mon Sep 17 00:00:00 2001 From: Joey Marianer Date: Mon, 9 Jan 2017 07:11:57 -0800 Subject: [PATCH 020/422] Add definitions for concat-stream (#13851) --- concat-stream/concat-stream-tests.ts | 20 ++++++++++++++++++++ concat-stream/index.d.ts | 17 +++++++++++++++++ concat-stream/tsconfig.json | 20 ++++++++++++++++++++ concat-stream/tslint.json | 1 + 4 files changed, 58 insertions(+) create mode 100644 concat-stream/concat-stream-tests.ts create mode 100644 concat-stream/index.d.ts create mode 100644 concat-stream/tsconfig.json create mode 100644 concat-stream/tslint.json diff --git a/concat-stream/concat-stream-tests.ts b/concat-stream/concat-stream-tests.ts new file mode 100644 index 0000000000..6dac3129f0 --- /dev/null +++ b/concat-stream/concat-stream-tests.ts @@ -0,0 +1,20 @@ +import concat = require("concat-stream") + +import { Readable } from "stream"; + +class MyReadable extends Readable { + i: number = 1; + _read() { + if (this.i <= 100) { + this.push(this.i.toString()); + this.i++; + } else { + this.push(null); + } + } +} + +let myReadable = new MyReadable(); + +myReadable.pipe(concat((buf) => console.log(buf.toString()))); +myReadable.pipe(concat({}, (buf) => console.log(buf.toString()))); diff --git a/concat-stream/index.d.ts b/concat-stream/index.d.ts new file mode 100644 index 0000000000..578a3e48b8 --- /dev/null +++ b/concat-stream/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for concat-stream 1.6 +// Project: https://github.com/maxogden/concat-stream +// Definitions by: Joey Marianer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Writable } from "stream"; + +interface ConcatOpts { + encoding?: string; +} + +declare function concat(cb: (buf: Buffer) => void): Writable; +declare function concat(opts: ConcatOpts, cb: (buf: Buffer) => void): Writable; + +export = concat; diff --git a/concat-stream/tsconfig.json b/concat-stream/tsconfig.json new file mode 100644 index 0000000000..3e6c0e2260 --- /dev/null +++ b/concat-stream/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "concat-stream-tests.ts" + ] +} diff --git a/concat-stream/tslint.json b/concat-stream/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/concat-stream/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 52f15e0fca62b37986aaca2a58a5e6e3dea15001 Mon Sep 17 00:00:00 2001 From: Goldsmith42 Date: Mon, 9 Jan 2017 17:59:12 +0100 Subject: [PATCH 021/422] Definitions for duplexer2 (#13860) * Added definition for async-polling * async-polling tests with noImplicitAny * Definitions for xsd-schema-validator * Definitions for duplexer2. * Added noImplicitThis: true --- duplexer2/duplexer2-tests.ts | 33 ++++++++++++++++++++++++++++++ duplexer2/index.d.ts | 13 ++++++++++++ duplexer2/tsconfig.json | 20 ++++++++++++++++++ duplexer2/tslint.json | 1 + xsd-schema-validator/index.d.ts | 2 +- xsd-schema-validator/tsconfig.json | 2 +- 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 duplexer2/duplexer2-tests.ts create mode 100644 duplexer2/index.d.ts create mode 100644 duplexer2/tsconfig.json create mode 100644 duplexer2/tslint.json diff --git a/duplexer2/duplexer2-tests.ts b/duplexer2/duplexer2-tests.ts new file mode 100644 index 0000000000..d611b69144 --- /dev/null +++ b/duplexer2/duplexer2-tests.ts @@ -0,0 +1,33 @@ +import stream = require("stream"); +import duplexer2 = require("duplexer2"); + +let writable = new stream.Writable({ objectMode: true }), + readable = new stream.Readable({ objectMode: true }); + +writable.once("finish", () => { + setTimeout(() => { + readable.push(null); + }, 500); +}); + +let duplex = duplexer2(writable, readable); + +duplex.on("data", (e: any) => { + console.log("got data", JSON.stringify(e)); +}); + +duplex.on("finish", () => { + console.log("got finish event"); +}); + +duplex.on("end", () => { + console.log("got end event"); +}); + +duplex.write("oh, hi there", () => { + console.log("finished writing"); +}); + +duplex.end("", () => { + console.log("finished ending"); +}); \ No newline at end of file diff --git a/duplexer2/index.d.ts b/duplexer2/index.d.ts new file mode 100644 index 0000000000..a8b5e4c3a8 --- /dev/null +++ b/duplexer2/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for duplexer2 0.1 +// Project: https://github.com/deoxxa/duplexer2 +// Definitions by: Zlatko Andonovski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Definition file started by dts-gen + +/// + +declare function duplexer2(options: {bubbleErrors: boolean}, writable: NodeJS.WritableStream, readable: NodeJS.ReadableStream): NodeJS.ReadWriteStream; +declare function duplexer2(writable: NodeJS.WritableStream, readable: NodeJS.ReadableStream): NodeJS.ReadWriteStream; + +export = duplexer2; diff --git a/duplexer2/tsconfig.json b/duplexer2/tsconfig.json new file mode 100644 index 0000000000..61d21210f6 --- /dev/null +++ b/duplexer2/tsconfig.json @@ -0,0 +1,20 @@ +{ + "files": [ + "index.d.ts", + "duplexer2-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "noImplicitThis": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} \ No newline at end of file diff --git a/duplexer2/tslint.json b/duplexer2/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/duplexer2/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/xsd-schema-validator/index.d.ts b/xsd-schema-validator/index.d.ts index c4fd02e8f5..db867b4178 100644 --- a/xsd-schema-validator/index.d.ts +++ b/xsd-schema-validator/index.d.ts @@ -9,4 +9,4 @@ export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pa valid: boolean; messages: string[]; result: string; -}) => void): void; +}) => void): void; \ No newline at end of file diff --git a/xsd-schema-validator/tsconfig.json b/xsd-schema-validator/tsconfig.json index f41083f666..e720897bf8 100644 --- a/xsd-schema-validator/tsconfig.json +++ b/xsd-schema-validator/tsconfig.json @@ -17,4 +17,4 @@ "index.d.ts", "xsd-schema-validator-tests.ts" ] -} \ No newline at end of file +} From bd1bbf1d1549351c619769f6de72fd050fa2a8ee Mon Sep 17 00:00:00 2001 From: "Smith, Blake (bs557j)" Date: Mon, 9 Jan 2017 11:16:07 -0600 Subject: [PATCH 022/422] id is not required when creating a document. If it's not specified, ES will generate a unique ID for the document. --- elasticsearch/elasticsearch-tests.ts | 5 +++++ elasticsearch/index.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/elasticsearch/elasticsearch-tests.ts b/elasticsearch/elasticsearch-tests.ts index c9be3c01ef..98d5a6c925 100644 --- a/elasticsearch/elasticsearch-tests.ts +++ b/elasticsearch/elasticsearch-tests.ts @@ -32,6 +32,11 @@ client.indices.delete({ }, function (error) { }); +client.create({ + index: 'index', + type: 'type' +}); + client.create({ id: '123', index: 'index', diff --git a/elasticsearch/index.d.ts b/elasticsearch/index.d.ts index f3ac0992c6..6558c94f2f 100644 --- a/elasticsearch/index.d.ts +++ b/elasticsearch/index.d.ts @@ -195,7 +195,7 @@ declare module Elasticsearch { version?: number; versionType?: VersionType; pipeline?: string; - id: string; + id?: string; index: string; type: string; } From 8f1c02df74e77390b6d9ef70ce218f0efda6abd2 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 17:49:41 +0000 Subject: [PATCH 023/422] Adds SHA1 definition --- sha1/index.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sha1/index.d.ts diff --git a/sha1/index.d.ts b/sha1/index.d.ts new file mode 100644 index 0000000000..3fbc990b23 --- /dev/null +++ b/sha1/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for sha1 v1.1.1 +// Project: https://github.com/pvorb/node-sha1 +// Definitions adapted from md5 definitions by: Bill Sourour +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * js function for hashing messages with SHA1 + * + * @param {(string | Buffer)} message - a string or buffer to hash + * @returns {string} the resultant SHA1 hash of the given message + */ +declare function main(message: string | Buffer): string; +export = main; From 454c0750358973b4e5fb685f17238c5b76c459d8 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 17:58:46 +0000 Subject: [PATCH 024/422] Adds initial test --- sha/sha1-tests.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sha/sha1-tests.ts diff --git a/sha/sha1-tests.ts b/sha/sha1-tests.ts new file mode 100644 index 0000000000..4952edb6c9 --- /dev/null +++ b/sha/sha1-tests.ts @@ -0,0 +1,33 @@ +/// + +import fs = require("fs"); +import sha1 = require("sha1"); +/** + * API + * md5(message) + * message -- String or Buffer + * returns String + * + * Usage + **************************************************** + * var sha1 = require('sha1'); * + * console.log(sha1('message')); * + **************************************************** + * This will print the following + * 6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d + * + * It supports buffers, too + **************************************************** + * var fs = require('fs'); * + * var sha1 = require('sha1'); * + * * + * fs.readFile('example.txt', function(err, buf) { * + * console.log(sha1(buf)); * + * }); * + * ************************************************** + */ +console.log(sha1('message')); // should print 6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d + +fs.readFile('sha1.d.ts', function(err: Error, buf: Buffer) { + console.log(sha1(buf)); +}); From 5b76a5ecfbdcc0a82e7ec91ef181e26058279018 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 17:59:25 +0000 Subject: [PATCH 025/422] Adds tsconfig.json --- sha/tsconfig.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 sha/tsconfig.json diff --git a/sha/tsconfig.json b/sha/tsconfig.json new file mode 100644 index 0000000000..81a2585b1f --- /dev/null +++ b/sha/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sha1-tests.ts" + ] +} From 32c313fcde5335a496670e78e1e91915450eff49 Mon Sep 17 00:00:00 2001 From: Bert Verhelst Date: Mon, 9 Jan 2017 19:01:02 +0100 Subject: [PATCH 026/422] Add missing meanBy function to LodashStatic (#13862) This should resolve the issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/13861 --- lodash/index.d.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lodash/index.d.ts b/lodash/index.d.ts index 731cf801ca..89436684c1 100644 --- a/lodash/index.d.ts +++ b/lodash/index.d.ts @@ -13288,6 +13288,28 @@ declare namespace _ { ): number; } + //_.meanBy + interface LoDashStatic { + /** + * Computes the mean of the provided propties of the objects in the `array` + * + * @static + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @returns {number} Returns the mean. + * @example + * + * _.mean([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], 'n'); + * // => 5 + */ + meanBy( + collection: List, + iteratee?: DictionaryIterator + ): number; + } + interface LoDashImplicitArrayWrapper { /** * @see _.mean From 4547b99203ddde063a5d51675116e4babb8d4020 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:01:09 +0000 Subject: [PATCH 027/422] Move file --- {sha => sha1}/sha1-tests.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sha => sha1}/sha1-tests.ts (100%) diff --git a/sha/sha1-tests.ts b/sha1/sha1-tests.ts similarity index 100% rename from sha/sha1-tests.ts rename to sha1/sha1-tests.ts From ff966529061ea2b0cdb9f94aaf0a87d1887bb2f3 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:01:31 +0000 Subject: [PATCH 028/422] Move file --- {sha => sha1}/tsconfig.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sha => sha1}/tsconfig.json (100%) diff --git a/sha/tsconfig.json b/sha1/tsconfig.json similarity index 100% rename from sha/tsconfig.json rename to sha1/tsconfig.json From e28099962b7b64963e5bf11487f2408c2ac67055 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:06:22 +0000 Subject: [PATCH 029/422] Extend typings --- sha1/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sha1/index.d.ts b/sha1/index.d.ts index 3fbc990b23..58d931b26e 100644 --- a/sha1/index.d.ts +++ b/sha1/index.d.ts @@ -11,5 +11,10 @@ * @param {(string | Buffer)} message - a string or buffer to hash * @returns {string} the resultant SHA1 hash of the given message */ -declare function main(message: string | Buffer): string; +declare function main(message: string | Buffer, options?: Sha1Options): string | Uint8Array; export = main; + +interface Sha1Options { + asBytes?: boolean; + asString?: boolean; +} From 5e054896cd59a926b83108585a84e89e78991511 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:10:44 +0000 Subject: [PATCH 030/422] Add additional tests --- sha1/sha1-tests.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sha1/sha1-tests.ts b/sha1/sha1-tests.ts index 4952edb6c9..0bce4c855d 100644 --- a/sha1/sha1-tests.ts +++ b/sha1/sha1-tests.ts @@ -4,7 +4,7 @@ import fs = require("fs"); import sha1 = require("sha1"); /** * API - * md5(message) + * sha1(message) * message -- String or Buffer * returns String * @@ -28,6 +28,9 @@ import sha1 = require("sha1"); */ console.log(sha1('message')); // should print 6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d +const testTwo = sha1('message', {asString: true}); +const testThree = sha1('message', {asBytes: true}); + fs.readFile('sha1.d.ts', function(err: Error, buf: Buffer) { console.log(sha1(buf)); }); From 58af9b88072d48c222286b78812949b494e1f676 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:15:03 +0000 Subject: [PATCH 031/422] Update sha1-tests.ts --- sha1/sha1-tests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sha1/sha1-tests.ts b/sha1/sha1-tests.ts index 0bce4c855d..f2c6547f2b 100644 --- a/sha1/sha1-tests.ts +++ b/sha1/sha1-tests.ts @@ -7,7 +7,7 @@ import sha1 = require("sha1"); * sha1(message) * message -- String or Buffer * returns String - * + * * Usage **************************************************** * var sha1 = require('sha1'); * @@ -15,10 +15,10 @@ import sha1 = require("sha1"); **************************************************** * This will print the following * 6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d - * + * * It supports buffers, too - **************************************************** - * var fs = require('fs'); * + **************************************************** + * var fs = require('fs'); * * var sha1 = require('sha1'); * * * * fs.readFile('example.txt', function(err, buf) { * @@ -32,5 +32,5 @@ const testTwo = sha1('message', {asString: true}); const testThree = sha1('message', {asBytes: true}); fs.readFile('sha1.d.ts', function(err: Error, buf: Buffer) { - console.log(sha1(buf)); + console.log(sha1(buf)); }); From fea8a860b081b57040a9864fbc0938c21a4c050e Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:15:35 +0000 Subject: [PATCH 032/422] Edits JSDoc --- sha1/index.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sha1/index.d.ts b/sha1/index.d.ts index 58d931b26e..0e35adf8dd 100644 --- a/sha1/index.d.ts +++ b/sha1/index.d.ts @@ -7,14 +7,15 @@ /** * js function for hashing messages with SHA1 - * + * * @param {(string | Buffer)} message - a string or buffer to hash + * @param {Sha1Options} options - an options object * @returns {string} the resultant SHA1 hash of the given message */ declare function main(message: string | Buffer, options?: Sha1Options): string | Uint8Array; export = main; interface Sha1Options { - asBytes?: boolean; - asString?: boolean; + asBytes?: boolean; + asString?: boolean; } From f579b14ff52056f8d258ded22aaadc3eeba71a41 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:23:47 +0000 Subject: [PATCH 033/422] Update index.d.ts --- sha1/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sha1/index.d.ts b/sha1/index.d.ts index 0e35adf8dd..c792f7d585 100644 --- a/sha1/index.d.ts +++ b/sha1/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for sha1 v1.1.1 // Project: https://github.com/pvorb/node-sha1 -// Definitions adapted from md5 definitions by: Bill Sourour +// Definitions by: Bill Sourour // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 22e1bd7305fa9d76424e19b6cc62bbd54bc3d84a Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Mon, 9 Jan 2017 18:35:00 +0000 Subject: [PATCH 034/422] Update tsconfig.json --- sha1/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sha1/tsconfig.json b/sha1/tsconfig.json index 81a2585b1f..ec99de7c10 100644 --- a/sha1/tsconfig.json +++ b/sha1/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, + "noImplicitThis": true, "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ From 4e4033684590f48bb93897cffa9e258596aa1f6f Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Mon, 9 Jan 2017 13:36:08 -0500 Subject: [PATCH 035/422] Remove const enum label from node (now works with --isolatedModules) --- node/index.d.ts | 2 +- node/tsconfig.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index ba3a7685fc..ba2bbed3d6 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -3958,7 +3958,7 @@ declare module "v8" { physical_space_size: number; } - const enum DoesZapCodeSpaceFlag { + enum DoesZapCodeSpaceFlag { Disabled = 0, Enabled = 1 } diff --git a/node/tsconfig.json b/node/tsconfig.json index adc8804da6..15c5691724 100644 --- a/node/tsconfig.json +++ b/node/tsconfig.json @@ -15,6 +15,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "isolatedModules": true } } \ No newline at end of file From c77960897db7902e98b9ab49f16d23d369d58b75 Mon Sep 17 00:00:00 2001 From: Risto Keravuori Date: Mon, 9 Jan 2017 11:16:22 -0800 Subject: [PATCH 036/422] Update types for fetch-mock v5.8.1 (#13784) --- fetch-mock/fetch-mock-tests.ts | 46 +++++-- fetch-mock/index.d.ts | 221 +++++++++++++++++++++++++-------- fetch-mock/tslint.json | 1 + 3 files changed, 206 insertions(+), 62 deletions(-) create mode 100644 fetch-mock/tslint.json diff --git a/fetch-mock/fetch-mock-tests.ts b/fetch-mock/fetch-mock-tests.ts index 2f0080ebac..f16aab11c9 100644 --- a/fetch-mock/fetch-mock-tests.ts +++ b/fetch-mock/fetch-mock-tests.ts @@ -4,12 +4,13 @@ fetchMock.mock("http://test.com", 200); fetchMock.mock(/test\.com/, 200); fetchMock.mock(() => true, 200); fetchMock.mock((url, opts) => true, 200); +fetchMock.once("http://test.com", 200); fetchMock.mock(/test/, "test").mock(/test/, { a: "b" }); fetchMock.mock(/test/, { status: 200, headers: { - "test": "test" + test: "test" }, body: { a: "b" @@ -23,20 +24,39 @@ fetchMock.calls().unmatched[0][0].toUpperCase(); fetchMock.calls("http://test.com")[0][0].toUpperCase(); (fetchMock.calls("http://test.com")[0][1] as RequestInit).body; -fetchMock.called("http://test.com"); +let doneStatus: boolean = fetchMock.done(); +let doneStatusArguments: boolean = fetchMock.done("http://test.com"); + +let calledStatus: boolean = fetchMock.called(); +let calledStatusArguments = fetchMock.called("http://test.com"); (fetchMock.lastCall()[1] as RequestInit).body; -fetchMock.lastUrl(); +let lastUrl: string = fetchMock.lastUrl(); fetchMock.lastOptions(); -fetchMock.get("http://test.com", 200) -fetchMock.post("http://test.com", 200) -fetchMock.put("http://test.com", 200) -fetchMock.delete("http://test.com", 200) -fetchMock.head("http://test.com", 200) +fetchMock.get("http://test.com", 200); +fetchMock.getOnce("http://test.com", 200); +fetchMock.post("http://test.com", 200); +fetchMock.postOnce("http://test.com", 200); +fetchMock.put("http://test.com", 200); +fetchMock.putOnce("http://test.com", 200); +fetchMock.delete("http://test.com", 200); +fetchMock.deleteOnce("http://test.com", 200); +fetchMock.head("http://test.com", 200); +fetchMock.headOnce("http://test.com", 200); +fetchMock.patch("http://test.com", 200); +fetchMock.patchOnce("http://test.com", 200); -fetchMock.get("http://test.com", 200, {method: "GET"}) -fetchMock.post("http://test.com", 200, {method: "POST"}) -fetchMock.put("http://test.com", 200, {method: "PUT"}) -fetchMock.delete("http://test.com", 200, {method: "DELETE"}) -fetchMock.head("http://test.com", 200, {method: "HEAD"}) +fetchMock.get("http://test.com", 200, {method: "GET"}); +fetchMock.post("http://test.com", 200, {method: "POST"}); +fetchMock.put("http://test.com", 200, {method: "PUT"}); +fetchMock.delete("http://test.com", 200, {method: "DELETE"}); +fetchMock.head("http://test.com", 200, {method: "HEAD"}); + +fetchMock + .mock("http://test.com", 200) + .catch(503); + +fetchMock + .mock("http://test.com", 200) + .spy(); diff --git a/fetch-mock/index.d.ts b/fetch-mock/index.d.ts index cda0b2539f..4d69096845 100644 --- a/fetch-mock/index.d.ts +++ b/fetch-mock/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for fetch-mock 5.0.0 +// Type definitions for fetch-mock 5.8 // Project: https://github.com/wheresrhys/fetch-mock -// Definitions by: Alexey Svetliakov , Tamir Duberstein +// Definitions by: Alexey Svetliakov , Tamir Duberstein , Risto Keravuori // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -11,7 +11,7 @@ type MockRequest = Request | RequestInit; * @param url * @param opts */ -type MockMatcherFunction = (url: string, opts: MockRequest) => boolean +type MockMatcherFunction = (url: string, opts: MockRequest) => boolean; /** * Mock matcher. Can be one of following: * string: Either @@ -69,7 +69,7 @@ interface MockResponseObject { type MockResponse = Response | Promise | number | Promise | string | Promise - | Object | Promise + | {} | Promise<{}> | MockResponseObject | Promise; /** * Mock response function @@ -104,33 +104,41 @@ interface MockOptions { * as specified above */ response?: MockResponse | MockResponseFunction; + /** + * integer, n, limiting the number of times the matcher can be used. + If the route has already been called n times the route will be + ignored and the call to fetch() will fall through to be handled by + any other routes defined (which may eventually result in an error + if nothing matches it). + */ + times?: number; } type MockCall = [string, MockRequest]; interface MatchedRoutes { - matched: Array; - unmatched: Array; + matched: MockCall[]; + unmatched: MockCall[]; } interface MockOptionsMethodGet extends MockOptions { - method: 'GET' + method: 'GET'; } interface MockOptionsMethodPost extends MockOptions { - method: 'POST' + method: 'POST'; } interface MockOptionsMethodPut extends MockOptions { - method: 'PUT' + method: 'PUT'; } interface MockOptionsMethodDelete extends MockOptions { - method: 'DELETE' + method: 'DELETE'; } interface MockOptionsMethodHead extends MockOptions { - method: 'HEAD' + method: 'HEAD'; } interface FetchMockStatic { @@ -140,17 +148,9 @@ interface FetchMockStatic { call through to fetch(). Calls to .mock() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock */ - mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction): this; - /** - * Replaces fetch() with a stub which records its calls, grouped by - route, and optionally returns a mocked Response object or passes the - call through to fetch(). Calls to .mock() can be chained. - * @param matcher Condition for selecting which requests to mock - * @param response Configures the http response returned by the mock - * @param options Additional properties defining the route to mock - */ - mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction, options: MockOptions): this; + mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction, options?: MockOptions): this; /** * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked Response object or passes the @@ -158,65 +158,180 @@ interface FetchMockStatic { * @param options The route to mock */ mock(options: MockOptions): this; + + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() limited to being + called one time only. Calls to .once() can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Optional additional properties defining the route to mock + */ + once(matcher: MockMatcher, response: MockResponse | MockResponseFunction, options?: MockOptions): this; + /** * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked Response object or passes the call through to fetch(). Shorthand for mock() restricted to the GET - method. Calls to .mock() can be chained. + method. Calls to .get() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock * @param [options] Additional properties defining the route to mock */ get(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodGet): this; + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the GET + method and limited to being called one time only. Calls to .getOnce() + can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + getOnce(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodGet): this; + /** * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked Response object or passes the call through to fetch(). Shorthand for mock() restricted to the POST - method. Calls to .mock() can be chained. + method. Calls to .post() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock * @param [options] Additional properties defining the route to mock */ post(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodPost): this; + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the POST + method and limited to being called one time only. Calls to .postOnce() + can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + postOnce(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodPost): this; + /** * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked Response object or passes the call through to fetch(). Shorthand for mock() restricted to the PUT - method. Calls to .mock() can be chained. + method. Calls to .put() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock * @param [options] Additional properties defining the route to mock */ put(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodPut): this; + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the PUT + method and limited to being called one time only. Calls to .putOnce() + can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + putOnce(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodPut): this; + /** * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked Response object or passes the call through to fetch(). Shorthand for mock() restricted to the - DELETE method. Calls to .mock() can be chained. + DELETE method. Calls to .delete() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock * @param [options] Additional properties defining the route to mock */ delete(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodDelete): this; + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the + DELETE method and limited to being called one time only. Calls to + .deleteOnce() can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + deleteOnce(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodDelete): this; + /** * Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked Response object or passes the call through to fetch(). Shorthand for mock() restricted to the HEAD - method. Calls to .mock() can be chained. + method. Calls to .head() can be chained. * @param matcher Condition for selecting which requests to mock * @param response Configures the http response returned by the mock * @param [options] Additional properties defining the route to mock */ head(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodHead): this; + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the HEAD + method and limited to being called one time only. Calls to .headOnce() + can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + headOnce(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodHead): this; + + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the PATCH + method. Calls to .patch() can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + patch(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodHead): this; + /** + * Replaces fetch() with a stub which records its calls, grouped by + route, and optionally returns a mocked Response object or passes the + call through to fetch(). Shorthand for mock() restricted to the PATCH + method and limited to being called one time only. Calls to .patchOnce() + can be chained. + * @param matcher Condition for selecting which requests to mock + * @param response Configures the http response returned by the mock + * @param [options] Additional properties defining the route to mock + */ + patchOnce(matcher: MockMatcher, reponse: MockResponse | MockResponseFunction, options?: MockOptionsMethodHead): this; + + /** + * Chainable method that defines how to respond to calls to fetch that + don't match any of the defined mocks. It accepts the same types of + response as a normal call to .mock(matcher, response). It can also + take an arbitrary function to completely customise behaviour of + unmatched calls. If .catch() is called without any parameters then + every unmatched call will receive a 200 response. + * @param [response] Configures the http response returned by the mock + */ + catch(response?: MockResponse | MockResponseFunction): this; + + /** + * Chainable method that records the call history of unmatched calls, + but instead of responding with a stubbed response, the request is + passed through to native fetch() and is allowed to communicate + over the network. Similar to catch(). + */ + spy(response?: MockResponse | MockResponseFunction): this; + /** * Chainable method that restores fetch() to its unstubbed state and clears all data recorded for its calls. */ restore(): this; + /** * Chainable method that clears all data recorded for fetch()'s calls */ reset(): this; + /** * Returns all calls to fetch, grouped by whether fetch-mock matched them or not. @@ -225,42 +340,50 @@ interface FetchMockStatic { /** * Returns all calls to fetch matching matcherName. */ - calls(matcherName?: string): Array; + calls(matcherName?: string): MockCall[]; + /** * Returns a Boolean indicating whether fetch was called and a route - was matched. - */ - called(): boolean; - /** - * Returns a Boolean indicating whether fetch was called and a route - named matcherName was matched. + was matched (or a specific route if matcherName is passed). + * @param [matcherName] either the name of a route or equal to + matcher.toString() for any unnamed route */ called(matcherName?: string): boolean; + /** - * Returns the arguments for the last matched call to fetch - */ - lastCall(): MockCall; - /** - * Returns the arguments for the last call to fetch matching - matcherName + * Returns a Boolean indicating whether fetch was called the expected + number of times (or at least once if the route defines no expectation + is set) for every route (or for a specific route if matcherName is + passed). + * @param [matcherName] either the name of a route or equal to + matcher.toString() for any unnamed route */ - lastCall(matcherName?: string): MockCall; + done(matcherName?: string): boolean; + /** - * Returns the url for the last matched call to fetch + * Returns the arguments for the last matched call to fetch (or the + last call to specific route is matcherName is passed). + * @param [matcherName] either the name of a route or equal to + matcher.toString() for any unnamed route */ - lastUrl(): string; + lastCall(matcherName?: string): MockCall; + /** - * Returns the url for the last call to fetch matching matcherName + * Returns the url for the last matched call to fetch (or the last + call to specific route is matcherName is passed). + * @param [matcherName] either the name of a route or equal to + matcher.toString() for any unnamed route */ lastUrl(matcherName?: string): string; + /** - * Returns the options for the last matched call to fetch - */ - lastOptions(): MockRequest; - /** - * Returns the options for the last call to fetch matching matcherName + * Returns the options for the last matched call to fetch (or the + last call to a specific route is matcherName is passed). + * @param [matcherName] either the name of a route or equal to + matcher.toString() for any unnamed route */ lastOptions(matcherName?: string): MockRequest; + /** * Set some global config options, which include * sendAsJson [default `true`] - by default fetchMock will @@ -268,7 +391,7 @@ interface FetchMockStatic { for each call but for some scenarios, e.g. when dealing with a lot of array buffers, it can be useful to default to `false` */ - configure(opts: Object): void; + configure(opts: {}): void; } declare var fetchMock: FetchMockStatic; diff --git a/fetch-mock/tslint.json b/fetch-mock/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fetch-mock/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3e757ce66287de54c45ecb30945c869ce7ad9809 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Mon, 9 Jan 2017 20:26:28 +0100 Subject: [PATCH 037/422] Infer type for jest.fn() for subtypes of object --- jest/index.d.ts | 1 + jest/jest-tests.ts | 43 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index 2f246f2bfe..e81a08c1ca 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -49,6 +49,7 @@ declare namespace jest { /** Enables automatic mocking in the module loader. */ function enableAutomock(): typeof jest; /** Creates a mock function. Optionally takes a mock implementation. */ + function fn(implementation: (...args: any[]) => T): Mock; function fn(implementation?: Function): Mock; /** Use the automatic mocking system to generate a mocked version of the given module. */ function genMockFromModule(moduleName: string): T; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index f2866d1689..c42df8fef4 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -433,20 +433,53 @@ interface TestApi { declare function mockedFunc(a: number): string; -describe("Mocked type", function () { - it("Works", function () { +describe('Mocked type', function () { + it('Works', function () { const mock: jest.Mocked = jest.fn(() => ({ testProp: true, testMethod1: jest.fn(), testMethod2: jest.fn() })) as any; mock.testProp; - mock.testMethod.mockImplementation(() => "test"); + mock.testMethod.mockImplementation(() => 'test'); mock.testMethod(5); mock.mockClear(); - const funcMock: jest.Mocked = require("./mockedFunc"); - funcMock.mockImplementation(() => "test"); + const funcMock: jest.Mocked = require('./mockedFunc'); + funcMock.mockImplementation(() => 'test'); funcMock(5).toUpperCase(); }); }); + +describe('Mocks', function () { + it('jest.fn() without args is a function type', function () { + const test = jest.fn(); + test(); + new test(); + test.mock.instances[0]; + test.mockImplementation(() => { }); + }); + + it('jest.fn() with returned object infers type', function () { + const testMock = jest.fn(() => ({ a: 5, test: jest.fn() })); + + testMock(5, 5, 'a'); + testMock.mockImplementation(() => { }); + testMock.caller; + + const ins = new testMock(); + ins.a; + ins.test(); + ins.test.mockImplementation(() => 5); + ins.test.mock.calls; + + const anotherMock = jest.fn(() => { + const api: Partial = { + testMethod: jest.fn() + }; + return api; + }); + const anotherIns: jest.Mocked = new anotherMock() as any; + anotherIns.testMethod.mockImplementation(() => 1); + }); +}); From c0a3889ed815e0cece0414ef4413038a9275a277 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 9 Jan 2017 14:06:56 -0800 Subject: [PATCH 038/422] Make mocha-node unused to prevent installing @types/node for browser users (#13869) --- mocha/UNUSED_FILES.txt | 2 ++ mocha/tsconfig.json | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 mocha/UNUSED_FILES.txt diff --git a/mocha/UNUSED_FILES.txt b/mocha/UNUSED_FILES.txt new file mode 100644 index 0000000000..2c70329a00 --- /dev/null +++ b/mocha/UNUSED_FILES.txt @@ -0,0 +1,2 @@ +mocha-node.d.ts +mocha-node-tests.ts \ No newline at end of file diff --git a/mocha/tsconfig.json b/mocha/tsconfig.json index 14d99637d1..94ab1840b4 100644 --- a/mocha/tsconfig.json +++ b/mocha/tsconfig.json @@ -15,8 +15,6 @@ }, "files": [ "index.d.ts", - "mocha-tests.ts", - "mocha-node.d.ts", - "mocha-node-tests.ts" + "mocha-tests.ts" ] } \ No newline at end of file From 88fb47df28117fe9d5905d640219bf67f8b61c2a Mon Sep 17 00:00:00 2001 From: Ruslan Arkhipau Date: Mon, 9 Jan 2017 13:23:23 -0800 Subject: [PATCH 039/422] [pem] update typing info for pem 1.9.4 Introduce callback and option interfaces for better type information; enhance compliance with DefinitelyTyped best practices --- pem/index.d.ts | 408 ++++++++++++++++++++++++++++++------------------ pem/tslint.json | 1 + 2 files changed, 260 insertions(+), 149 deletions(-) create mode 100644 pem/tslint.json diff --git a/pem/index.d.ts b/pem/index.d.ts index 8a5f71b729..c523fb8fa7 100644 --- a/pem/index.d.ts +++ b/pem/index.d.ts @@ -1,155 +1,265 @@ -// Type definitions for PEM v1.8.3 +// Type definitions for PEM 1.9 // Project: https://github.com/andris9/pem -// Definitions by: Anthony Trinh +// Definitions by: Anthony Trinh , Ruslan Arkhipau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "pem" { +interface ModuleConfiguration { /** - * Creates a private key - * - * @param {Number} [keyBitsize=2048] Size of the key, defaults to 2048bit (can also be a function) - * @param {Object} [options] object of cipher and password {cipher:'aes128',password:'xxx'}, defaults empty object - * @param {Function} callback Callback function with an error object and {key} + * Path to OpenSSL binaries */ - function createPrivateKey(keyBitsize: Number, options: Object, callback: Function): void; - function createPrivateKey(keyBitsize: Number, callback: Function): void; - function createPrivateKey(options: Object, callback: Function): void; - function createPrivateKey(callback: Function): void; - - /** - * Creates a dhparam key - * - * @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit - * @param {Function} callback Callback function with an error object and {dhparam} - */ - function createDhparam(keyBitsize: Number, callback: Function): void; - function createDhparam(callback: Function): void; - - /** - * Creates a Certificate Signing Request - * - * If client key is undefined, a new key is created automatically. The used key is included - * in the callback return as clientKey - * - * @param {Object} [options] Optional options object - * @param {String} [options.clientKey] Optional client key to use - * @param {Number} [options.keyBitsize] If clientKey is undefined, bit size to use for generating a new key (defaults to 2048) - * @param {String} [options.hash] Hash function to use (either md5 sha1 or sha256, defaults to sha256) - * @param {String} [options.country] CSR country field - * @param {String} [options.state] CSR state field - * @param {String} [options.locality] CSR locality field - * @param {String} [options.organization] CSR organization field - * @param {String} [options.organizationUnit] CSR organizational unit field - * @param {String} [options.commonName='localhost'] CSR common name field - * @param {String} [options.emailAddress] CSR email address field - * @param {String} [options.csrConfigFile] CSR config file - * @param {Array} [options.altNames] is a list of subjectAltNames in the subjectAltName field - * @param {Function} callback Callback function with an error object and {csr, clientKey} - */ - function createCSR(options: Object, callback: Function): void; - function createCSR(callback: Function): void; - - /** - * Creates a certificate based on a CSR. If CSR is not defined, a new one - * will be generated automatically. For CSR generation all the options values - * can be used as with createCSR. - * - * @param {Object} [options] Optional options object - * @param {String} [options.serviceKey] Private key for signing the certificate, if not defined a new one is generated - * @param {String} [options.serviceKeyPassword] Password of the service key - * @param {Boolean} [options.selfSigned] If set to true and serviceKey is not defined, use clientKey for signing - * @param {String} [options.hash] Hash function to use (either md5 sha1 or sha256, defaults to sha256) - * @param {String} [options.csr] CSR for the certificate, if not defined a new one is generated - * @param {Number} [options.days] Certificate expire time in days - * @param {String} [options.clientKeyPassword] Password of the client key - * @param {String} [options.extFile] extension config file - without '-extensions v3_req' - * @param {String} [options.config] extension config file - with '-extensions v3_req' - * @param {Function} callback Callback function with an error object and {certificate, csr, clientKey, serviceKey} - */ - function createCertificate(options: Object, callback: Function): void; - function createCertificate(callback: Function): void; - - /** - * Reads subject data from a certificate or a CSR - * - * @param {String} certificate PEM encoded CSR or certificate - * @param {Function} callback Callback function with an error object and {country, state, locality, organization, organizationUnit, commonName, emailAddress} - */ - function readCertificateInfo(certificate: string, callback: Function): void; - function readCertificateInfo(callback: Function): void; - - /** - * Exports a public key from a private key, CSR or certificate - * - * @param {String} certificate PEM encoded private key, CSR or certificate - * @param {Function} callback Callback function with an error object and {publicKey} - */ - function getPublicKey(certificate: string, callback: Function): void; - function getPublicKey(callback: Function): void; - - /** - * Gets the fingerprint for a certificate - * - * @param {String} certificate PEM encoded certificate - * @param {String} hash Hash function to use (either md5 sha1 or sha256, defaults to sha256) - * @param {Function} callback Callback function with an error object and {fingerprint} - */ - function getFingerprint(certificate: string, hash: string, callback: Function): void; - function getFingerprint(certificate: string, callback: Function): void; - function getFingerprint(callback: Function): void; - - /** - * Gets the modulus from a certificate, a CSR or a private key - * - * @param {String} certificate PEM encoded, CSR PEM encoded, or private key - * @param {String} password password for the certificate - * @param {Function} callback Callback function with an error object and {modulus} - */ - function getModulus(certificate: string, password: string, callback: Function): void; - function getModulus(certificate: string, callback: Function): void; - - /** - * Gets the size and prime of DH parameters - * - * @param {String} dh DH parameters PEM encoded - * @param {Function} callback Callback function with an error object and {size, prime} - */ - function getDhparamInfo(dh: string, callback: Function): void; - - /** - * Exports private key and certificate to a PKCS12 keystore - * - * @param {String} key PEM encoded private key - * @param {String} certificate PEM encoded certificate - * @param {String} password Password of the result PKCS12 file - * @param {Object} [options] object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'} - * @param {Function} callback Callback function with an error object and {pkcs12} - */ - function createPkcs12(key: string, certificate: string, password: string, options: Object, callback: Function): void; - function createPkcs12(key: string, certificate: string, password: string, callback: Function): void; - - /** - * Reads private key and certificate from a PKCS12 keystore - * @param {String} bufferOrPath - * @param {Object} [options] object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'} - * @param {Function} callback Callback function with an error object and {pkcs12} - * @returns the result of the callback - */ - function readPkcs12(bufferOrPath: string, options: Object, callback: Function): any; - function readPkcs12(options: Object, callback: Function): any; - - /** - * Verifies the signing chain of the passed certificate - * - * @param {String} certificate PEM encoded certificate - * @param {Array} ca List of CA certificates - * @param {Function} callback Callback function with an error object and a boolean valid - */ - function verifySigningChain(certificate: string, ca: Array, callback: Function): void; - - /** - * config the pem module - * @param {Object} options - */ - function config(options: Object): void; + pathOpenSSL: string; } + +export type PrivateKeyCipher = "aes128" | "aes192" | "aes256" | "camellia128" | "camellia192" | "camellia256" | "des" | "des3" | "idea" | string; // allow for additions in future + +interface PrivateKeyCreationOptions { + cipher: PrivateKeyCipher; + password: string; +} + +interface Pkcs12CreationOptions { + cipher?: PrivateKeyCipher; + clientKeyPassword?: string; + certFiles?: string[]; +} + +interface Pkcs12ReadOptions { + p12Password?: string; + clientKeyPassword?: string; +} + +export type HashFunction = 'md5' | 'sha1' | 'sha256' | string; +interface CSRCreationOptions { + /** + * Optional client key to use + */ + clientKey?: string; + clientKeyPassword?: string; + /** + * If clientKey is undefined, bit size to use for generating a new key (defaults to 2048) + */ + keyBitsize?: number; + /** + * Hash function to use, defaults to sha256 + */ + hash?: HashFunction; + /** + * CSR country field + */ + country?: string; + /** + * CSR state field + */ + state?: string; + /** + * CSR locality field + */ + locality?: string; + /** + * CSR organization field + */ + organization?: string; + /** + * CSR organizational unit field + */ + organizationUnit?: string; + /** + * CSR common name field, defaults to 'localhost' + */ + commonName?: string; + /** + * CSR email address field + */ + emailAddress?: string; + /** + * CSR config file + */ + csrConfigFile?: string; + /** + * A list of subjectAltNames in the subjectAltName field + */ + altNames?: string[]; +} + +interface CertificateCreationOptions extends CSRCreationOptions { + /** + * Private key for signing the certificate, if not defined a new one is generated + */ + serviceKey?: string; + /** + * Password of the service key + */ + serviceKeyPassword?: string; + serviceCertificate?: any; + serial?: any; + /** + * If set to true and serviceKey is not defined, use clientKey for signing + */ + selfSigned?: boolean; + /** + * CSR for the certificate, if not defined a new one is generated from the provided parameters + */ + csr?: string; + /** + * Certificate expire time in days, defaults to 365 + */ + days?: number; + /** + * Password of the client key + */ + clientKeyPassword?: string; + /** + * extension config file - without '-extensions v3_req' + */ + extFile?: string; + /** + * extension config file - with '-extensions v3_req' + */ + config?: string; +} + +interface CertificateCreationResult { + certificate: any; + csr: string; + clientKey: string; + serviceKey: string; +} + +interface CertificateSubjectReadResult { + country: string; + state: string; + locality: string; + organization: string; + organizationUnit: string; + commonName: string; + emailAddress: string; +} + +type Callback = (error: any, result: T) => any; + +/** + * Creates a private key + * + * @param {number} [keyBitsize=2048] Size of the key, defaults to 2048bit (can also be a function) + * @param {PrivateKeyCreationOptions} [options] private key encryption settings, defaults to empty object (no enryption) + * @param {Callback<{ key: string }>} callback Callback function with an error object and {key} + */ +declare function createPrivateKey(keyBitsize: number, options: PrivateKeyCreationOptions, callback: Callback<{ key: string }>): void; +declare function createPrivateKey(optionsOrKeyBitsize: number | PrivateKeyCreationOptions, callback: Callback<{ key: string }>): void; +declare function createPrivateKey(callback: Callback<{ key: string }>): void; + +/** + * Creates a dhparam key + * + * @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit + * @param {Callback<{ dhparam: any }>} callback Callback function with an error object and {dhparam} + */ +declare function createDhparam(keyBitsize: number, callback: Callback<{ dhparam: any }>): void; +declare function createDhparam(callback: Callback<{ dhparam: any }>): void; + +/** + * Creates a Certificate Signing Request + * + * If options.clientKey is undefined, a new key is created automatically. The used key is included + * in the callback return as clientKey + * + * @param {CSRCreationOptions} [options] Optional options object + * @param {Callback<{ csr: string, clientKey: string }>} callback Callback function with an error object and {csr, clientKey} + */ +declare function createCSR(options: CSRCreationOptions, callback: Callback<{ csr: string, clientKey: string }>): void; +declare function createCSR(callback: Callback<{ csr: string, clientKey: string }>): void; + +/** + * Creates a certificate based on a CSR. If CSR is not defined, a new one + * will be generated automatically. For CSR generation all the options values + * can be used as with createCSR. + * + * @param {Object} [CertificateCreationOptions] Optional options object + * @param {Callback} callback Callback function with an error object and {certificate, csr, clientKey, serviceKey} + */ +declare function createCertificate(options: CertificateCreationOptions, callback: Callback): void; +declare function createCertificate(callback: Callback): void; + +/** + * Reads subject data from a certificate or a CSR + * + * @param {String} certificate PEM encoded CSR or certificate + * @param {Callback} callback Callback function with an error object and {country, state, locality, organization, organizationUnit, commonName, emailAddress} + */ +declare function readCertificateInfo(certificate: string, callback: Callback): void; +declare function readCertificateInfo(callback: Callback): void; + +/** + * Exports a public key from a private key, CSR or certificate + * + * @param {String} certificate PEM encoded private key, CSR or certificate + * @param {Callback<{ publicKey: string }>} callback Callback function with an error object and {publicKey} + */ +declare function getPublicKey(certificate: string, callback: Callback<{ publicKey: string }>): void; +declare function getPublicKey(callback: Callback<{ publicKey: string }>): void; + +/** + * Gets the fingerprint for a certificate + * + * @param {String} certificate PEM encoded certificate + * @param {HashFunction} hash Hash function to use (either md5 sha1 or sha256, defaults to sha256) + * @param {Callback<{ fingerprint: string }>} callback Callback function with an error object and {fingerprint} + */ +declare function getFingerprint(certificate: string, hash: HashFunction, callback: Callback<{ fingerprint: string }>): void; +declare function getFingerprint(certificate: string, callback: Callback<{ fingerprint: string }>): void; +declare function getFingerprint(callback: Callback<{ fingerprint: string }>): void; + +/** + * Gets the modulus from a certificate, a CSR or a private key + * + * @param {String} certificate PEM encoded, CSR PEM encoded, or private key + * @param {String} password password for the certificate + * @param {Callback<{ modulus: any }>} callback Callback function with an error object and {modulus} + */ +declare function getModulus(certificate: string, password: string, callback: Callback<{ modulus: any }>): void; +declare function getModulus(certificate: string, callback: Callback<{ modulus: any }>): void; + +/** + * Gets the size and prime of DH parameters + * + * @param {String} dh DH parameters PEM encoded + * @param {Callback<{ size: any, prime: any }>} callback Callback function with an error object and {size, prime} + */ +declare function getDhparamInfo(dh: string, callback: Callback<{ size: any, prime: any }>): void; + +/** + * Exports private key and certificate to a PKCS12 keystore + * + * @param {String} key PEM encoded private key + * @param {String} certificate PEM encoded certificate + * @param {String} password Password of the result PKCS12 file + * @param {Pkcs12CreationOptions} [options] object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'} + * @param {Callback<{ pkcs12: any }>} callback Callback function with an error object and {pkcs12} + */ +declare function createPkcs12(key: string, certificate: string, password: string, options: Pkcs12CreationOptions, callback: Callback<{ pkcs12: any }>): void; +declare function createPkcs12(key: string, certificate: string, password: string, callback: Callback<{ pkcs12: any }>): void; + +/** + * Reads private key and certificate from a PKCS12 keystore + * @param {String} bufferOrPath + * @param {Pkcs12ReadOptions} [options] + * @param {Function} callback Callback function with an error object and {pkcs12} + * @returns the result of the callback + */ +declare function readPkcs12(bufferOrPath: string, options: Pkcs12ReadOptions, callback: Callback<{ pkcs12: any }>): any; +declare function readPkcs12(bufferOrPath: string, callback: Callback<{ pkcs12: any }>): any; + +/** + * Verifies the signing chain of the passed certificate + * + * @param {String} certificate PEM encoded certificate + * @param {string[]} ca List of CA certificates + * @param {Function} callback Callback function with an error object and a boolean valid + */ +declare function verifySigningChain(certificate: string, ca: string[], callback: Callback): void; + +/** + * config the pem module + * @param {ModuleConfiguration} options + */ +declare function config(options: ModuleConfiguration): void; diff --git a/pem/tslint.json b/pem/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/pem/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 02c9c550917194ba2512b60316bab9aa2f14c003 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 03:49:01 +0100 Subject: [PATCH 040/422] Move CSSTransitionGroupProps to react module --- react-addons-css-transition-group/index.d.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/react-addons-css-transition-group/index.d.ts b/react-addons-css-transition-group/index.d.ts index b57b39ab69..77fc5c95e6 100644 --- a/react-addons-css-transition-group/index.d.ts +++ b/react-addons-css-transition-group/index.d.ts @@ -4,13 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import 'react-addons-transition-group'; -import { ComponentClass, TransitionGroupProps } from 'react'; +import { ComponentClass, TransitionGroupProps, CSSTransitionGroupProps } from 'react'; -declare var CSSTransitionGroup: CSSTransitionGroup; -type CSSTransitionGroup = ComponentClass; -export = CSSTransitionGroup; - -declare namespace CSSTransitionGroup { +declare module 'react' { interface CSSTransitionGroupTransitionName { enter: string; enterActive?: string; @@ -20,7 +16,7 @@ declare namespace CSSTransitionGroup { appearActive?: string; } - interface CSSTransitionGroupProps extends TransitionGroupProps { + export interface CSSTransitionGroupProps extends TransitionGroupProps { transitionName: string | CSSTransitionGroupTransitionName; transitionAppear?: boolean; transitionAppearTimeout?: number; @@ -30,3 +26,8 @@ declare namespace CSSTransitionGroup { transitionLeaveTimeout?: number; } } + +declare var CSSTransitionGroup: CSSTransitionGroup; +type CSSTransitionGroup = ComponentClass; +export = CSSTransitionGroup; + From 11a075529c9a10a0c2416c3c63ea54ad5c392e18 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 03:50:03 +0100 Subject: [PATCH 041/422] Bump version --- react-addons-css-transition-group/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-addons-css-transition-group/index.d.ts b/react-addons-css-transition-group/index.d.ts index 77fc5c95e6..c8ccf83ebe 100644 --- a/react-addons-css-transition-group/index.d.ts +++ b/react-addons-css-transition-group/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React (react-addons-css-transition-group) 0.14 +// Type definitions for React (react-addons-css-transition-group) 15.0 // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 9e0c7a2809eb2de8bf621a789cbc7a872a6a9f82 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 04:24:40 +0100 Subject: [PATCH 042/422] Fixed dependent module --- react-css-transition-replace/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-css-transition-replace/index.d.ts b/react-css-transition-replace/index.d.ts index 292e45e5e5..88a8d11ffd 100644 --- a/react-css-transition-replace/index.d.ts +++ b/react-css-transition-replace/index.d.ts @@ -7,7 +7,7 @@ import * as React from "react"; import * as CSSTransitionGroup from "react-addons-css-transition-group"; declare namespace CSSTransitionReplace { - interface Props extends CSSTransitionGroup.CSSTransitionGroupProps { + interface Props extends React.CSSTransitionGroupProps { overflowHidden?: boolean } } From da39e1d4fc33ae8ec2a5ee5090929f3b3b02e308 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 04:27:05 +0100 Subject: [PATCH 043/422] react-event-listener definitions --- react-event-listener/index.d.ts | 226 ++++++++++++++++++ .../react-event-listener-tests.tsx | 6 + react-event-listener/tsconfig.json | 21 ++ react-event-listener/tslint.json | 1 + 4 files changed, 254 insertions(+) create mode 100644 react-event-listener/index.d.ts create mode 100644 react-event-listener/react-event-listener-tests.tsx create mode 100644 react-event-listener/tsconfig.json create mode 100644 react-event-listener/tslint.json diff --git a/react-event-listener/index.d.ts b/react-event-listener/index.d.ts new file mode 100644 index 0000000000..5e0915b893 --- /dev/null +++ b/react-event-listener/index.d.ts @@ -0,0 +1,226 @@ +// Type definitions for react-event-listener 0.4.0 +// Project: https://github.com/oliviertassinari/react-event-listener +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from "react"; + +interface EventOptions { + /** + * @default false + */ + passive?: boolean; + /** + * @default false + */ + capture?: boolean; +} + +export function withOptions(handler: (ev: T) => any, options: EventOptions): (ev: T) => any; + +export interface EventListenerProps { + // Global events + onPointerCancel?: (ev: PointerEvent) => any; + onPointerCancelCapture?: (ev: PointerEvent) => any; + onPointerDown?: (ev: PointerEvent) => any; + onPointerDownCapture?: (ev: PointerEvent) => any; + onPointerEnter?: (ev: PointerEvent) => any; + onPointerEnterCapture?: (ev: PointerEvent) => any; + onPointerLeave?: (ev: PointerEvent) => any; + onPointerLeaveCapture?: (ev: PointerEvent) => any; + onPointerMove?: (ev: PointerEvent) => any; + onPointerMoveCapture?: (ev: PointerEvent) => any; + onPointerOut?: (ev: PointerEvent) => any; + onPointerOutCapture?: (ev: PointerEvent) => any; + onPointerOver?: (ev: PointerEvent) => any; + onPointerOverCapture?: (ev: PointerEvent) => any; + onPointerUp?: (ev: PointerEvent) => any; + onPointerUpCapture?: (ev: PointerEvent) => any; + onWheel?: (ev: WheelEvent) => any; + onWheelCapture?: (ev: WheelEvent) => any; + onAbort?: (ev: Event) => any; + onAbortCapture?: (ev: Event) => any; + onAfterPrint?: (ev: Event) => any; + onAfterPrintCapture?: (ev: Event) => any; + onBeforePrint?: (ev: Event) => any; + onBeforePrintCapture?: (ev: Event) => any; + onBeforeUnload?: (ev: BeforeUnloadEvent) => any; + onBeforeUnloadCapture?: (ev: BeforeUnloadEvent) => any; + onBlur?: (ev: FocusEvent) => any; + onBlurCapture?: (ev: FocusEvent) => any; + onCanPlay?: (ev: Event) => any; + onCanPlayCapture?: (ev: Event) => any; + onCanPlayThrough?: (ev: Event) => any; + onCanPlayThroughCapture?: (ev: Event) => any; + onChange?: (ev: Event) => any; + onChangeCapture?: (ev: Event) => any; + onClick?: (ev: MouseEvent) => any; + onClickCapture?: (ev: MouseEvent) => any; + onCompassNeedsCalibration?: (ev: Event) => any; + onCompassNeedsCalibrationCapture?: (ev: Event) => any; + onContextMenu?: (ev: PointerEvent) => any; + onContextMenuCapture?: (ev: PointerEvent) => any; + onDblClick?: (ev: MouseEvent) => any; + onDblClickCapture?: (ev: MouseEvent) => any; + onDeviceMotion?: (ev: DeviceMotionEvent) => any; + onDeviceMotionCapture?: (ev: DeviceMotionEvent) => any; + onDeviceOrientation?: (ev: DeviceOrientationEvent) => any; + onDeviceOrientationCapture?: (ev: DeviceOrientationEvent) => any; + onDrag?: (ev: DragEvent) => any; + onDragCapture?: (ev: DragEvent) => any; + onDragEnd?: (ev: DragEvent) => any; + onDragEndCapture?: (ev: DragEvent) => any; + onDragEnter?: (ev: DragEvent) => any; + onDragEnterCapture?: (ev: DragEvent) => any; + onDragLeave?: (ev: DragEvent) => any; + onDragLeaveCapture?: (ev: DragEvent) => any; + onDragOver?: (ev: DragEvent) => any; + onDragOverCapture?: (ev: DragEvent) => any; + onDragStart?: (ev: DragEvent) => any; + onDragStartCapture?: (ev: DragEvent) => any; + onDrop?: (ev: DragEvent) => any; + onDropCapture?: (ev: DragEvent) => any; + onDurationChange?: (ev: Event) => any; + onDurationChangeCapture?: (ev: Event) => any; + onEmptied?: (ev: Event) => any; + onEmptiedCapture?: (ev: Event) => any; + onEnded?: (ev: Event) => any; + onEndedCapture?: (ev: Event) => any; + onError?: ErrorEventHandler; + onErrorCapture?: ErrorEventHandler; + onFocus?: (ev: FocusEvent) => any; + onFocusCapture?: (ev: FocusEvent) => any; + onHashChange?: (ev: HashChangeEvent) => any; + onHashChangeCapture?: (ev: HashChangeEvent) => any; + onInput?: (ev: Event) => any; + onInputCapture?: (ev: Event) => any; + onKeyDown?: (ev: KeyboardEvent) => any; + onKeyDownCapture?: (ev: KeyboardEvent) => any; + onKeyPress?: (ev: KeyboardEvent) => any; + onKeyPressCapture?: (ev: KeyboardEvent) => any; + onKeyUp?: (ev: KeyboardEvent) => any; + onKeyUpCapture?: (ev: KeyboardEvent) => any; + onLoad?: (ev: Event) => any; + onLoadCapture?: (ev: Event) => any; + onLoadedData?: (ev: Event) => any; + onLoadedDataCapture?: (ev: Event) => any; + onLoadedMetadata?: (ev: Event) => any; + onLoadedMetadataCapture?: (ev: Event) => any; + onLoadStart?: (ev: Event) => any; + onLoadStartCapture?: (ev: Event) => any; + onMessage?: (ev: MessageEvent) => any; + onMessageCapture?: (ev: MessageEvent) => any; + onMouseDown?: (ev: MouseEvent) => any; + onMouseDownCapture?: (ev: MouseEvent) => any; + onMouseEnter?: (ev: MouseEvent) => any; + onMouseEnterCapture?: (ev: MouseEvent) => any; + onMouseLeave?: (ev: MouseEvent) => any; + onMouseLeaveCapture?: (ev: MouseEvent) => any; + onMouseMove?: (ev: MouseEvent) => any; + onMouseMoveCapture?: (ev: MouseEvent) => any; + onMouseOut?: (ev: MouseEvent) => any; + onMouseOutCapture?: (ev: MouseEvent) => any; + onMouseOver?: (ev: MouseEvent) => any; + onMouseOverCapture?: (ev: MouseEvent) => any; + onMouseUp?: (ev: MouseEvent) => any; + onMouseUpCapture?: (ev: MouseEvent) => any; + onMouseWheel?: (ev: MouseWheelEvent) => any; + onMouseWheelCapture?: (ev: MouseWheelEvent) => any; + onMsGestureChange?: (ev: MSGestureEvent) => any; + onMsGestureChangeCapture?: (ev: MSGestureEvent) => any; + onMsGestureDoubleTap?: (ev: MSGestureEvent) => any; + onMsGestureDoubleTapCapture?: (ev: MSGestureEvent) => any; + onMsGestureEnd?: (ev: MSGestureEvent) => any; + onMsGestureEndCapture?: (ev: MSGestureEvent) => any; + onMsGestureHold?: (ev: MSGestureEvent) => any; + onMsGestureHoldCapture?: (ev: MSGestureEvent) => any; + onMsGestureStart?: (ev: MSGestureEvent) => any; + onMsGestureStartCapture?: (ev: MSGestureEvent) => any; + onMsGestureTap?: (ev: MSGestureEvent) => any; + onMsGestureTapCapture?: (ev: MSGestureEvent) => any; + onMsInertiaStart?: (ev: MSGestureEvent) => any; + onMsInertiaStartCapture?: (ev: MSGestureEvent) => any; + onMsPointerCancel?: (ev: MSPointerEvent) => any; + onMsPointerCancelCapture?: (ev: MSPointerEvent) => any; + onMsPointerDown?: (ev: MSPointerEvent) => any; + onMsPointerDownCapture?: (ev: MSPointerEvent) => any; + onMsPointerEnter?: (ev: MSPointerEvent) => any; + onMsPointerEnterCapture?: (ev: MSPointerEvent) => any; + onMsPointerLeave?: (ev: MSPointerEvent) => any; + onMsPointerLeaveCapture?: (ev: MSPointerEvent) => any; + onMsPointerMove?: (ev: MSPointerEvent) => any; + onMsPointerMoveCapture?: (ev: MSPointerEvent) => any; + onMsPointerOut?: (ev: MSPointerEvent) => any; + onMsPointerOutCapture?: (ev: MSPointerEvent) => any; + onMsPointerOver?: (ev: MSPointerEvent) => any; + onMsPointerOverCapture?: (ev: MSPointerEvent) => any; + oNmsPointerUp?: (ev: MSPointerEvent) => any; + oNmsPointerUpCapture?: (ev: MSPointerEvent) => any; + onOffline?: (ev: Event) => any; + onOfflineCapture?: (ev: Event) => any; + onOnline?: (ev: Event) => any; + onOnlineCapture?: (ev: Event) => any; + onOrientationChange?: (ev: Event) => any; + onOrientationChangeCapture?: (ev: Event) => any; + onPageHide?: (ev: PageTransitionEvent) => any; + onPageHideCapture?: (ev: PageTransitionEvent) => any; + onPageShow?: (ev: PageTransitionEvent) => any; + onPageShowCapture?: (ev: PageTransitionEvent) => any; + onPause?: (ev: Event) => any; + onPauseCapture?: (ev: Event) => any; + onPlay?: (ev: Event) => any; + onPlayCapture?: (ev: Event) => any; + onPlaying?: (ev: Event) => any; + onPlayingCapture?: (ev: Event) => any; + onPopState?: (ev: PopStateEvent) => any; + onPopStateCapture?: (ev: PopStateEvent) => any; + onProgress?: (ev: ProgressEvent) => any; + onProgressCapture?: (ev: ProgressEvent) => any; + onRateChange?: (ev: Event) => any; + onRateChangeCapture?: (ev: Event) => any; + onReadyStateChange?: (ev: ProgressEvent) => any; + onReadyStateChangeCapture?: (ev: ProgressEvent) => any; + onReset?: (ev: Event) => any; + onResetCapture?: (ev: Event) => any; + onResize?: (ev: UIEvent) => any; + onResizeCapture?: (ev: UIEvent) => any; + onScroll?: (ev: UIEvent) => any; + onScrollCapture?: (ev: UIEvent) => any; + onSeeked?: (ev: Event) => any; + onSeekedCapture?: (ev: Event) => any; + onSeeking?: (ev: Event) => any; + onSeekingCapture?: (ev: Event) => any; + onSelect?: (ev: UIEvent) => any; + onSelectCapture?: (ev: UIEvent) => any; + onStalled?: (ev: Event) => any; + onStalledCapture?: (ev: Event) => any; + onStorage?: (ev: StorageEvent) => any; + onStorageCapture?: (ev: StorageEvent) => any; + onSubmit?: (ev: Event) => any; + onSubmitCapture?: (ev: Event) => any; + onSuspend?: (ev: Event) => any; + onSuspendCapture?: (ev: Event) => any; + onTimeUpdate?: (ev: Event) => any; + onTimeUpdateCapture?: (ev: Event) => any; + onTouchCancel?: any; + onTouchCancelCapture?: any; + onTouchEnd?: any; + onTouchEndCapture?: any; + onTouchMove?: any; + onTouchMoveCapture?: any; + onTouchStart?: any; + onTouchStartCapture?: any; + onUnload?: (ev: Event) => any; + onUnloadCapture?: (ev: Event) => any; + onVolumeChange?: (ev: Event) => any; + onVolumeChangeCapture?: (ev: Event) => any; + onWaiting?: (ev: Event) => any; + onWaitingCapture?: (ev: Event) => any; + + /** + * Target (window or document) + */ + target: Window | Document | string; +} + +export default class EventListener extends React.Component { } diff --git a/react-event-listener/react-event-listener-tests.tsx b/react-event-listener/react-event-listener-tests.tsx new file mode 100644 index 0000000000..194ab97e7f --- /dev/null +++ b/react-event-listener/react-event-listener-tests.tsx @@ -0,0 +1,6 @@ +import * as React from "react"; +import EventListener, { withOptions } from "react-event-listener"; + + { }} />; + { }, { passive: true, capture: true })} />; + { }}/> diff --git a/react-event-listener/tsconfig.json b/react-event-listener/tsconfig.json new file mode 100644 index 0000000000..619baa483a --- /dev/null +++ b/react-event-listener/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-event-listener-tests.tsx" + ] +} diff --git a/react-event-listener/tslint.json b/react-event-listener/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-event-listener/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 82a1b10c6b295321bdbbf89c0afe424e58de5adf Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 04:50:55 +0100 Subject: [PATCH 044/422] Fix version --- react-event-listener/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-event-listener/index.d.ts b/react-event-listener/index.d.ts index 5e0915b893..7fefddbe7b 100644 --- a/react-event-listener/index.d.ts +++ b/react-event-listener/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-event-listener 0.4.0 +// Type definitions for react-event-listener 0.4 // Project: https://github.com/oliviertassinari/react-event-listener // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 1fe97bbf37387bb737d1581bc18d5bdc90022a6f Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Mon, 9 Jan 2017 20:02:52 -0800 Subject: [PATCH 045/422] Add 'extensions' option. --- koa-send/index.d.ts | 3 ++- koa-send/koa-send-tests.ts | 1 + koa-send/koa-send.d.ts | 27 --------------------------- 3 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 koa-send/koa-send.d.ts diff --git a/koa-send/index.d.ts b/koa-send/index.d.ts index f8424c1a85..521e96036e 100644 --- a/koa-send/index.d.ts +++ b/koa-send/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for koa-send v3.x +// Type definitions for koa-send v3.3 // Project: https://github.com/koajs/send // Definitions by: Peter Safranek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -13,6 +13,7 @@ interface ISendOptions { format?: boolean; gzip?: boolean; setHeaders?: Function; + extensions?: string[]; } declare function send(ctx: Koa.Context, path: string, opts?: ISendOptions): Promise; diff --git a/koa-send/koa-send-tests.ts b/koa-send/koa-send-tests.ts index e231d4e6b3..88a6f16abb 100644 --- a/koa-send/koa-send-tests.ts +++ b/koa-send/koa-send-tests.ts @@ -17,5 +17,6 @@ app.use(async (ctx: Koa.Context) => { format: true, gzip: true, setHeaders: () => {}, + extensions: ['shemp'], }); }); diff --git a/koa-send/koa-send.d.ts b/koa-send/koa-send.d.ts deleted file mode 100644 index 9ed8805412..0000000000 --- a/koa-send/koa-send.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Type definitions for koa-send v3.x -// Project: https://github.com/koajs/send -// Definitions by: Peter Safranek -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare module "koa-send" { - - import * as Koa from "koa"; - - interface ISendOptions { - root?: string; - index?: string; - maxAge?: number; - hidden?: boolean; - format?: boolean; - gzip?: boolean; - setHeaders?: Function; - } - - function send(ctx: Koa.Context, path: string, opts?: ISendOptions): Promise; - - namespace send {} - - export = send; -} From 536734f6e0f47475388eac44a392cdeff250b614 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 06:12:30 +0100 Subject: [PATCH 046/422] Initial commit --- smooth-scrollbar/index.d.ts | 277 +++++++++++++++++++++ smooth-scrollbar/smooth-scrollbar-tests.ts | 31 +++ smooth-scrollbar/tsconfig.json | 20 ++ smooth-scrollbar/tslint.json | 1 + 4 files changed, 329 insertions(+) create mode 100644 smooth-scrollbar/index.d.ts create mode 100644 smooth-scrollbar/smooth-scrollbar-tests.ts create mode 100644 smooth-scrollbar/tsconfig.json create mode 100644 smooth-scrollbar/tslint.json diff --git a/smooth-scrollbar/index.d.ts b/smooth-scrollbar/index.d.ts new file mode 100644 index 0000000000..7962a4f9ee --- /dev/null +++ b/smooth-scrollbar/index.d.ts @@ -0,0 +1,277 @@ +// Type definitions for smooth-scrollbar 7.2 +// Project: https://github.com/idiotWu/smooth-scrollbar +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Scrollbar; + +export interface ScrollbarOptions { + /** + * Scrolling speed scale. + * @default 1 + */ + speed?: number; + /** + * Delta reduction damping, a float value between (0, 1), the lower the value is, the more smooth the scrolling will be. + * @default 0.1 + */ + damping?: number; + /** + * Minimal size for scrollbar thumb. + * @default 20 + */ + thumbMinSize?: number; + /** + * Execute listeners in synchronous or asynchronous. + * @default false + */ + syncCallbacks?: boolean; + /** + * Render scrolling by integer pixels, set to true to improve performance. + * @default true + */ + renderByPixels?: boolean; + /** + * Whether allow upper scrollable content to continue scrolling when current scrollbar reaches edge. + * When set to "auto", it will be enabled on nested scrollbars, and disabled on first-class scrollbars. + * @default "auto" + */ + continuousScrolling?: boolean | "auto"; + /** + * Experimental overscroll effect, "bounce" for iOS style effect and "glow" for Android style effect. + * Be careful when you enable this feature! + * @default false + */ + overscrollEffect?: boolean | "bounce" | "glow"; + /** + * Canvas paint color with 'glow' effect. + * @default "#87ceeb" + */ + overscrollEffectColor?: string; + /** + * The same as damping, but for overscrolling. + * @default 0.2 + */ + overscrollDamping?: number; +} + +export interface ScrollbarTargets { + readonly container: HTMLElement; + readonly content: HTMLElement; + readonly xAxis: { + readonly track: HTMLElement; + readonly thumb: HTMLElement; + }; + readonly yAxis: { + readonly track: HTMLElement; + readonly thumb: HTMLElement; + } +} + +interface ScrollIntoViewOptions { + /** + * scrolling stop offset to top edge of container + * @default 0 + */ + offsetTop?: number; + /** + * scrolling stop offset to left edge of container + * @default 0 + */ + offsetLeft?: number; + /** + * whether to scroll container when target element is visible + * @default false + */ + onlyScrollIfNeeded?: boolean; +} + +export interface ScrollStatusObject { + /** + * Scrolling direction + */ + direction: { + x: "none" | "right" | "left"; + y: "none" | "up" | "down"; + }; + /** + * Scrolling offset + */ + offset: { + x: number; + y: number; + }; + /** + * Max scroll distance in px + */ + limit: { + x: number; + y: number; + }; +} + +export default class Scrollbar { + /** + * Init scrollbar on given element, and returns scrollbar instance + * @param {HTMLElement} element Element to init scrollbar + * @param {ScrollbarOptions} options Scrollbar options + * @return {Scrollbar} Scrollbar instance + */ + static init(element: HTMLElement, options?: ScrollbarOptions): Scrollbar; + /** + * Automatically init scrollbar on all elements refer to selector scrollbar, [scrollbar], [data-scrollbar] + * @return {Scrollbar[]} An array of scrollbars + */ + static initAll(options?: ScrollbarOptions): Scrollbar[]; + /** + * Check if scrollbar exists on given element: + * @param {HTMLElement} element HTML element + * @return {boolean} + */ + static has(element: HTMLElement): boolean; + /** + * Get scrollbar on the given element + * @param {HTMLElement} element HTML element + * @return {Scrollbar|undefined} Scrollbar instance of undefined if element doesn't have scrollbar + */ + static get(element: HTMLElement): Scrollbar | undefined; + /** + * Get all scrollbar instances + * @return {Scrollbar[]} An array of scrollbar instances + */ + static getAll(): Scrollbar[]; + /** + * Remove scrollbar on the given element + * @param {HTMLElement} element HTML element + * @param {boolean} isRemoval + */ + static destroy(element: HTMLElement, isRemoval?: boolean): void; + /** + * Destroys all scrollbar instances + */ + static destroyAll(): void; + /** + * Current scrollbar targets + */ + public readonly targets: ScrollbarTargets; + /** + * Current scrolling offset + */ + public offset: { + x: number; + y: number; + }; + /** + * Max scrolling offset + */ + public limit: { + x: number; + y: number; + } + /** + * Alias for offset.y + */ + public scrollTop: number; + /** + * Alias for offset.x + */ + public scrollLeft: number; + + /** + * Scrollbars are automatically updated with 100ms debounce (or childList changes if MutationObserver is supported). + * You can call update() to force an update, this will be useful when you modified contents inside scrollbar + * @param {boolean} async By default, updating will operate synchronously, set to true to update asynchronously (in next frame). + */ + public update(async?: boolean): void; + /** + * Return the size of scrollbar container and scroll content + * @return {Object} Container and content dimensions + */ + public getSize(): { container: { width: number; height: number }; content: { width: number; height: number } }; + /** + * Like window.scrollTo(), scroll content will be set to the given position immediately. + * @param {number} x X position + * @param {number} y Y position + * @param {boolean} withoutCallbacks Set to true to disable callback functions temporarily. + */ + setPosition(x: number, y: number, withoutCallbacks?: boolean): void; + /** + * Scroll to given position with easing, callback will be invoked with instance after scrolling: + * @param {number} x X position + * @param {number} y Y position + * @param {number} duration description + * @param {Function} callback Callback + */ + scrollTo(x: number, y: number, duration?: number, callback?: (instance: this) => void): void; + /** + * Scroll target element into visible area of scrollbar, like DOM method element.scrollIntoView(). + * This will be helpful when you want to create some anchors. + * @param {HTMLElement} element Element to scroll into + * @param {ScrollIntoViewOptions} options Options + */ + scrollIntoView(element: HTMLElement, options?: ScrollIntoViewOptions): void; + /** + * Check if an element is visible in the current view area. + * @param {HTMLElement} element HTML element + * @return {boolean} True/false + */ + isVisible(element: HTMLElement): boolean; + /** + * Register scrolling listener to scrollbar instance, callbacks will be invoked in every small scrolling. + * @param {Function} listener A listener + */ + addListener(listener: (status: ScrollStatusObject) => void): void; + /** + * Remove the given listeneer from listeners collection, like Element.removeEventListener(). + * @param {Function} listener A listener + */ + removeListener(listener: (status: ScrollStatusObject) => void): void; + /** + * This is another useful method when you want to make infinite scrolling. + * Callbacks will be invoked with status object when you scrolling down over a threshold. + * @param {Function} listener A listener + * @param {number} threshold Threshold, default 50 + */ + infiniteScroll(listener: (status: ScrollStatusObject) => void, threshold?: number): void; + /** + * Remove DOM event handlers that match regex rules + * @param {RegExp[]} regexps regexps + * @example + * instance.unregisterEvents(/touch/, /key/); + */ + unregisterEvents(...regexps: RegExp[]): void; + /** + * Recover events that are unregistered. + * @param {RegExp[]} regexps regexps + */ + registerEvents(...regexps: RegExp[]): void; + /** + * Clear all movements and stop scrollbar immediately, will be useful when you want to stop scrollbar and set it to another position. + */ + clearMovement(): void; + /** + * Alias for clearMovement() method. + */ + stop(): void; + /** + * Remove this scrollbar instance + * @param {boolean} isRemoval Set to true if scrollbar being removed from DOM + */ + destroy(isRemoval?: boolean): void; + /** + * Get content element of the scrollbar, which contains all of your contents within scrollbar. + * In other words, all contents that you've put them into target element, will be moved here after you initialized the scrollbar. + * @return {HTMLElement} HTML content element + */ + getContentElem(): HTMLElement; + /** + * Show scrollbar track, you can choose whether 'x' or 'y' or 'both', default is 'both' which will show tracks both on x-axis and y-axis. + * @param {"x"|"y"|"both"} direction Track direction + */ + showTrack(direction?: "x" | "y" | "both"): void; + /** + * Like showTrack() method, but for hiding the track on specified direction. + * @param {"x"|"y"|"both"} direction Track direction + */ + hideTrack(direction?: "x" | "y" | "both"): void; +} diff --git a/smooth-scrollbar/smooth-scrollbar-tests.ts b/smooth-scrollbar/smooth-scrollbar-tests.ts new file mode 100644 index 0000000000..2072caa3c8 --- /dev/null +++ b/smooth-scrollbar/smooth-scrollbar-tests.ts @@ -0,0 +1,31 @@ +import Scrollbar from "smooth-scrollbar"; + +const elem = document.createElement("div"); + +const scrollbar = Scrollbar.init(elem, { + continuousScrolling: true, + damping: 5, + overscrollDamping: 5, + overscrollEffect: "glow", + overscrollEffectColor: "green", + renderByPixels: true, + speed: 10, + syncCallbacks: true, + thumbMinSize: 1 +}); + +Scrollbar.has(elem); +Scrollbar.get(elem) === scrollbar; + +scrollbar.targets.container; +scrollbar.targets.xAxis.track; + +scrollbar.update(true); +scrollbar.setPosition(10, 10); + +scrollbar.addListener(status => status.direction); +scrollbar.infiniteScroll(status => status.direction.y); + +scrollbar.hideTrack("both"); +scrollbar.showTrack("x"); +scrollbar.destroy(true); diff --git a/smooth-scrollbar/tsconfig.json b/smooth-scrollbar/tsconfig.json new file mode 100644 index 0000000000..be638b7a40 --- /dev/null +++ b/smooth-scrollbar/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "smooth-scrollbar-tests.ts" + ] +} diff --git a/smooth-scrollbar/tslint.json b/smooth-scrollbar/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/smooth-scrollbar/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 4c2595cf698b2ba92fe6b42dd1068462fbe2df99 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 06:24:01 +0100 Subject: [PATCH 047/422] initial commit --- react-smooth-scrollbar/index.d.ts | 40 +++++++++++++++++++ .../react-smooth-scrollbar-tests.tsx | 19 +++++++++ react-smooth-scrollbar/tsconfig.json | 21 ++++++++++ react-smooth-scrollbar/tslint.json | 1 + 4 files changed, 81 insertions(+) create mode 100644 react-smooth-scrollbar/index.d.ts create mode 100644 react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx create mode 100644 react-smooth-scrollbar/tsconfig.json create mode 100644 react-smooth-scrollbar/tslint.json diff --git a/react-smooth-scrollbar/index.d.ts b/react-smooth-scrollbar/index.d.ts new file mode 100644 index 0000000000..3c4d541294 --- /dev/null +++ b/react-smooth-scrollbar/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for react-smooth-scrollbar 7.2 +// Project: https://github.com/idiotWu/react-smooth-scrollbar +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from "react"; +import SmoothScrollbar, { ScrollbarOptions, ScrollStatusObject } from "smooth-scrollbar"; + +declare namespace Scrollbar { + interface ScrollbarProps extends ScrollbarOptions { + /** + * Pipe to scrollbar.addListener() + */ + onScroll?: (status: ScrollStatusObject, scrollbarInstance: SmoothScrollbar) => void; + /** + * Keep scrollbar tracks visible whether it's scrolling or not + * @default false + */ + alwaysShowTracks?: boolean; + /** + * Optional class name + */ + className?: string; + /** + * Optional style + */ + style?: React.CSSProperties; + } +} + +declare class Scrollbar extends React.Component { + /** + * Scrollbar instance + */ + public readonly scrollbar: SmoothScrollbar; + +} + +export as namespace Scrollbar; +export = Scrollbar; diff --git a/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx b/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx new file mode 100644 index 0000000000..f46efe0e62 --- /dev/null +++ b/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx @@ -0,0 +1,19 @@ +import * as React from "react"; +import * as SmoothScrollbar from "react-smooth-scrollbar"; + + { } } />; +; + +class Test extends React.Component { + public ref: SmoothScrollbar; + + public componentDidMount() { + this.ref.scrollbar.scrollTo(0, 500); + } + + public render() { + return ( + this.ref = ref} /> + ); + } +} diff --git a/react-smooth-scrollbar/tsconfig.json b/react-smooth-scrollbar/tsconfig.json new file mode 100644 index 0000000000..aef8e9bced --- /dev/null +++ b/react-smooth-scrollbar/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-smooth-scrollbar-tests.tsx" + ] +} diff --git a/react-smooth-scrollbar/tslint.json b/react-smooth-scrollbar/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-smooth-scrollbar/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 1cd1a67d9221cbe3547ae5a4efa4ee336943e845 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 06:26:24 +0100 Subject: [PATCH 048/422] Remove unnecessary public identifiers --- react-smooth-scrollbar/index.d.ts | 2 +- react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/react-smooth-scrollbar/index.d.ts b/react-smooth-scrollbar/index.d.ts index 3c4d541294..df5746f9d4 100644 --- a/react-smooth-scrollbar/index.d.ts +++ b/react-smooth-scrollbar/index.d.ts @@ -32,7 +32,7 @@ declare class Scrollbar extends React.Component { /** * Scrollbar instance */ - public readonly scrollbar: SmoothScrollbar; + readonly scrollbar: SmoothScrollbar; } diff --git a/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx b/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx index f46efe0e62..956df59f9c 100644 --- a/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx +++ b/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx @@ -5,13 +5,13 @@ import * as SmoothScrollbar from "react-smooth-scrollbar"; ; class Test extends React.Component { - public ref: SmoothScrollbar; + ref: SmoothScrollbar; - public componentDidMount() { + componentDidMount() { this.ref.scrollbar.scrollTo(0, 500); } - public render() { + render() { return ( this.ref = ref} /> ); From 1bb87209613b649c60c7788c89c3bedbb8d42afc Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 10 Jan 2017 06:27:37 +0100 Subject: [PATCH 049/422] Linting --- smooth-scrollbar/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/smooth-scrollbar/index.d.ts b/smooth-scrollbar/index.d.ts index 7962a4f9ee..f6a65ca958 100644 --- a/smooth-scrollbar/index.d.ts +++ b/smooth-scrollbar/index.d.ts @@ -65,7 +65,7 @@ export interface ScrollbarTargets { readonly yAxis: { readonly track: HTMLElement; readonly thumb: HTMLElement; - } + }; } interface ScrollIntoViewOptions { @@ -153,41 +153,41 @@ export default class Scrollbar { /** * Current scrollbar targets */ - public readonly targets: ScrollbarTargets; + readonly targets: ScrollbarTargets; /** * Current scrolling offset */ - public offset: { + offset: { x: number; y: number; }; /** * Max scrolling offset */ - public limit: { + limit: { x: number; y: number; - } + }; /** * Alias for offset.y */ - public scrollTop: number; + scrollTop: number; /** * Alias for offset.x */ - public scrollLeft: number; + scrollLeft: number; /** * Scrollbars are automatically updated with 100ms debounce (or childList changes if MutationObserver is supported). * You can call update() to force an update, this will be useful when you modified contents inside scrollbar * @param {boolean} async By default, updating will operate synchronously, set to true to update asynchronously (in next frame). */ - public update(async?: boolean): void; + update(async?: boolean): void; /** * Return the size of scrollbar container and scroll content * @return {Object} Container and content dimensions */ - public getSize(): { container: { width: number; height: number }; content: { width: number; height: number } }; + getSize(): { container: { width: number; height: number }; content: { width: number; height: number } }; /** * Like window.scrollTo(), scroll content will be set to the given position immediately. * @param {number} x X position From 0e2ece89a47c5a6dc2a40bbb9f9c3a9c0f192279 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 10 Jan 2017 06:27:28 -0800 Subject: [PATCH 050/422] chart.js: Fix spelling of "afterFooter" --- chart.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 3ef5919acf..7a7b05c714 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -62,7 +62,7 @@ declare namespace Chart { afterBody?: (item?: ChartTooltipItem[], data?: any) => void; beforeFooter?: (item?: ChartTooltipItem[], data?: any) => void; footer?: (item?: ChartTooltipItem[], data?: any) => void; - afterfooter?: (item?: ChartTooltipItem[], data?: any) => void; + afterFooter?: (item?: ChartTooltipItem[], data?: any) => void; } export interface ChartAnimationParameter { From a13492cbe3d9325dfb4fb62d9ec190ea7264e591 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 10 Jan 2017 06:29:13 -0800 Subject: [PATCH 051/422] Update comment on TS2.1 (#13883) --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0b1a79ae7c..5df5808bd1 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ Here are the [currently requested definitions](https://github.com/DefinitelyType If types are part of a web standard, they should be contributed to [TSJS-lib-generator](https://github.com/Microsoft/TSJS-lib-generator) so that they can become part of the default `lib.dom.d.ts`. -### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`? +#### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`? If default imports work in your environment, consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option. Do not change the type definition if it is accurate. @@ -214,8 +214,7 @@ For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the #### I want to use features from TypeScript 2.1. -Then you will have to add a comment to your definition header: `// TypeScript Version: 2.1`. -If it is merged before January 7, it will be published as a prerelease version, such as `4.3.0-next.0`. +Then you will have to add a comment to the last line of your definition header (after `// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped`): `// TypeScript Version: 2.1`. #### I want to add a DOM API not present in TypeScript by default. From 76a710cc945a34dcf664ded78937c9b957b3eccd Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 10 Jan 2017 06:33:06 -0800 Subject: [PATCH 052/422] Rename test files to be consistent (#13882) --- .../ace-anchor-tests.ts => test/anchor.ts} | 0 .../background_tokenizer.ts} | 0 .../ace-default-tests.ts => test/default.ts} | 0 .../document.ts} | 0 .../edit_session.ts} | 0 .../ace-editor1-tests.ts => test/editor1.ts} | 0 .../editor_highlight_selected_word.ts} | 0 .../editor_navigation.ts} | 0 .../editor_text_edit.ts} | 0 .../multi_select.ts} | 0 .../placeholder.ts} | 0 .../ace-range-tests.ts => test/range.ts} | 0 .../range_list.ts} | 0 .../ace-search-tests.ts => test/search.ts} | 0 .../selection.ts} | 0 .../token_iterator.ts} | 0 .../virtual_renderer.ts} | 0 ace/tsconfig.json | 34 +- acl/{acl-tests.ts => test/index.ts} | 0 .../mongodbBackend.ts} | 0 .../redisBackend.ts} | 0 acl/tsconfig.json | 6 +- .../angular.ts} | 0 adal/{adal-tests.ts => test/index.ts} | 0 adal/tsconfig.json | 4 +- .../{amplifyjs-tests.ts => amplify-tests.ts} | 0 amplify/tsconfig.json | 2 +- ...-tests.ts => angular-localforage-tests.ts} | 0 angular-localforage/tsconfig.json | 2 +- ...ests.ts => angular-media-queries-tests.ts} | 0 angular-media-queries/tsconfig.json | 2 +- ...-tests.ts => angularlocalstorage-tests.ts} | 0 angularlocalstorage/tsconfig.json | 2 +- .../{index-tests.ts => array-uniq-tests.ts} | 0 array-uniq/tsconfig.json | 2 +- .../explicit.ts} | 0 async/{async-tests.ts => test/index.ts} | 0 async/tsconfig.json | 4 +- ...uth0.lock-tests.ts => auth0-lock-tests.ts} | 0 auth0-lock/tsconfig.json | 2 +- ... => azure-mobile-services-client-tests.ts} | 0 azure-mobile-services-client/tsconfig.json | 2 +- .../{babylon-tests.ts => babylonjs-tests.ts} | 0 babylonjs/tsconfig.json | 2 +- ...-tests.ts => backbone.marionette-tests.ts} | 0 backbone.marionette/tsconfig.json | 2 +- backbone/backbone-with-lodash-tests.ts | 404 ------------------ backbone/tsconfig.json | 3 +- .../{bounce-tests.ts => bounce.js-tests.ts} | 0 bounce.js/tsconfig.json | 2 +- bowser/bowser-module-tests.ts | 9 - ...bowser-global-tests.ts => bowser-tests.ts} | 0 bowser/tsconfig.json | 3 +- box2d/{box2dweb-tests.ts => box2d-tests.ts} | 0 box2d/tsconfig.json | 2 +- chartjs/{chart-tests.ts => chartjs-tests.ts} | 0 chartjs/tsconfig.json | 2 +- .../chrome-app.ts} | 0 chrome/{chrome-tests.ts => test/index.ts} | 0 chrome/tsconfig.json | 4 +- .../{cldr.js-event-tests.ts => test/event.ts} | 2 - cldrjs/{cldr.js-tests.ts => test/index.ts} | 0 .../supplemental.ts} | 0 cldrjs/tsconfig.json | 6 +- .../{codemirror-tests.ts => test/index.ts} | 0 .../matchbrackets.ts} | 0 .../runmode.ts} | 0 .../searchcursor.ts} | 0 .../showhint.ts} | 0 codemirror/tsconfig.json | 10 +- ...s-md5-tests.ts => cybozulabs-md5-tests.ts} | 0 cybozulabs-md5/tsconfig.json | 2 +- ...ormat-tests.ts => date.format.js-tests.ts} | 0 date.format.js/tsconfig.json | 2 +- ...eployJava-tests.ts => deployjava-tests.ts} | 0 deployjava/tsconfig.json | 2 +- ...ocCookies-tests.ts => doccookies-tests.ts} | 0 doccookies/tsconfig.json | 2 +- electron/{electron-tests.ts => test/index.ts} | 0 .../main.ts} | 0 .../renderer.ts} | 0 electron/tsconfig.json | 6 +- .../index.ts} | 0 .../{lib/lib-tests.ts => test/lib.ts} | 0 enhanced-resolve/tsconfig.json | 6 +- fabric/{fabricjs-tests.ts => fabric-tests.ts} | 0 fabric/tsconfig.json | 2 +- .../browser.ts} | 0 falcor/{falcor-tests.ts => test/index.ts} | 0 falcor/tsconfig.json | 4 +- fb/{fbsdk-tests.ts => fb-tests.ts} | 0 fb/tsconfig.json | 2 +- ffi/{node-ffi-tests.ts => ffi-tests.ts} | 0 ffi/tsconfig.json | 2 +- ...FileSaver-tests.ts => file-saver-tests.ts} | 0 file-saver/tsconfig.json | 2 +- finch/{Finch-tests.ts => finch-tests.ts} | 0 finch/tsconfig.json | 2 +- ...rprint-tests.ts => fingerprintjs-tests.ts} | 0 fingerprintjs/tsconfig.json | 2 +- firebase/{firebase-tests.ts => test/index.ts} | 0 .../simplelogin.ts} | 0 firebase/tsconfig.json | 4 +- ...lexSlider-tests.ts => flexslider-tests.ts} | 0 flexslider/tsconfig.json | 2 +- .../index.ts} | 0 .../safe.ts} | 0 format-unicorn/tsconfig.json | 4 +- ...alendar-tests.ts => fullcalendar-tests.ts} | 0 fullcalendar/tsconfig.json | 2 +- ...alendar-tests.ts => fullcalendar-tests.ts} | 0 fullcalendar/v1/tsconfig.json | 2 +- .../{index-tests.ts => get-stdin-tests.ts} | 0 get-stdin/tsconfig.json | 2 +- git/{node-git-tests.ts => git-tests.ts} | 0 git/tsconfig.json | 2 +- go/{goJS-tests.ts => go-tests.ts} | 0 go/tsconfig.json | 2 +- ...{ga-tests.ts => google.analytics-tests.ts} | 0 google.analytics/tsconfig.json | 2 +- ...ests.ts => googlemaps.infobubble-tests.ts} | 0 googlemaps.infobubble/tsconfig.json | 2 +- ...ogle.maps-tests.ts => googlemaps-tests.ts} | 0 googlemaps/tsconfig.json | 2 +- grunt/{gruntjs-tests.ts => grunt-tests.ts} | 0 grunt/tsconfig.json | 2 +- .../clip-loader.tsx} | 0 .../fade-loader.tsx} | 0 .../pacman-loader.tsx} | 0 .../rotate-loader.tsx} | 0 halogen/tsconfig.json | 8 +- .../{heatmap-tests.ts => heatmap.js-tests.ts} | 0 heatmap.js/tsconfig.json | 2 +- .../{modules/boost-tests.ts => test/boost.ts} | 0 .../exporting-tests.ts => test/exporting.ts} | 0 .../{highstock-tests.ts => test/highstock.ts} | 0 .../{highcharts-tests.ts => test/index.ts} | 0 .../more.ts} | 0 .../no-data-to-display.ts} | 0 .../offline-exporting.ts} | 0 highcharts/tsconfig.json | 14 +- ...lightjs-tests.ts => highlight.js-tests.ts} | 0 highlight.js/tsconfig.json | 2 +- .../{history-tests.ts => history.js-tests.ts} | 0 history.js/tsconfig.json | 2 +- ...ot-pace-tests.ts => hubspot-pace-tests.ts} | 0 hubspot-pace/tsconfig.json | 2 +- i18n/{i18n-node-tests.ts => i18n-tests.ts} | 0 i18n/tsconfig.json | 2 +- ...interact-tests.ts => interact.js-tests.ts} | 0 interact.js/tsconfig.json | 2 +- ...{intercom-tests.ts => intercomjs-tests.ts} | 0 intercomjs/tsconfig.json | 2 +- ...ider-tests.ts => ion.rangeslider-tests.ts} | 0 ion.rangeslider/tsconfig.json | 10 +- ...ider-tests.ts => ion.rangeslider-tests.ts} | 0 ion.rangeslider/v1/tsconfig.json | 2 +- is/{is_js-tests.ts => is-tests.ts} | 0 is/tsconfig.json | 2 +- ix.js/{ix-tests.ts => test/index.ts} | 0 ix.js/{l2o-tests.ts => test/l2o.ts} | 2 - ix.js/tsconfig.json | 4 +- jee-jsf/{jsf-tests.ts => jee-jsf-tests.ts} | 0 jee-jsf/tsconfig.json | 2 +- jodata/{joData-tests.ts => jodata-tests.ts} | 0 jodata/tsconfig.json | 2 +- ...ockUI-tests.ts => jquery.blockui-tests.ts} | 0 jquery.blockui/tsconfig.json | 2 +- ...s.ts => jquery.clientsidelogging-tests.ts} | 0 jquery.clientsidelogging/tsconfig.json | 2 +- ...u-tests.ts => jquery.contextmenu-tests.ts} | 0 jquery.contextmenu/tsconfig.json | 2 +- ...-tests.ts => jquery.customselect-tests.ts} | 0 jquery.customselect/tsconfig.json | 2 +- ...es-tests.ts => jquery.datatables-tests.ts} | 0 jquery.datatables/tsconfig.json | 2 +- ...ster-tests.ts => jquery.gridster-tests.ts} | 0 jquery.gridster/tsconfig.json | 2 +- ...dal-tests.ts => jquery.leanmodal-tests.ts} | 0 jquery.leanmodal/tsconfig.json | 2 +- ...Bar-tests.ts => jquery.notifybar-tests.ts} | 0 jquery.notifybar/tsconfig.json | 2 +- ...sts.ts => jquery.pjax.falsandtru-tests.ts} | 0 jquery.pjax.falsandtru/tsconfig.json | 2 +- ...e-tests.ts => jquery.postmessage-tests.ts} | 0 jquery.postmessage/tsconfig.json | 2 +- ...wGrid-tests.ts => jquery.rowgrid-tests.ts} | 0 jquery.rowgrid/tsconfig.json | 2 +- ...llTo-tests.ts => jquery.scrollto-tests.ts} | 0 jquery.scrollto/tsconfig.json | 2 +- ...ts.ts => jquery.simplepagination-tests.ts} | 0 jquery.simplepagination/tsconfig.json | 2 +- ...fixtures-tests.ts => js-fixtures-tests.ts} | 0 js-fixtures/tsconfig.json | 2 +- js-md5/{md5-tests.ts => js-md5-tests.ts} | 0 js-md5/tsconfig.json | 2 +- .../knockout-tests.ts => test/index.ts} | 0 .../templatingBehaviors.ts} | 0 knockout/tsconfig.json | 4 +- .../{konami-tests.ts => konami.js-tests.ts} | 0 konami.js/tsconfig.json | 2 +- ...alForage-tests.ts => localforage-tests.ts} | 0 localforage/tsconfig.json | 2 +- ...ck-boot-test.ts => loopback-boot-tests.ts} | 0 loopback-boot/tsconfig.json | 2 +- .../{loopback-test.ts => loopback-tests.ts} | 0 loopback/tsconfig.json | 2 +- .../{makerjs-tests.ts => maker.js-tests.ts} | 0 maker.js/tsconfig.json | 2 +- ...andrill-tests.ts => mandrill-api-tests.ts} | 0 mandrill-api/tsconfig.json | 2 +- ...bar-tests.ts => mcustomscrollbar-tests.ts} | 0 mcustomscrollbar/tsconfig.json | 2 +- .../{memory-fs-tests.ts => test/index.ts} | 2 - memory-fs/{lib/join-tests.ts => test/join.ts} | 0 .../normalize-tests.ts => test/normalize.ts} | 0 memory-fs/tsconfig.json | 8 +- metric-suffix/metric-suffix-external-tests.ts | 22 - metric-suffix/tsconfig.json | 3 +- ....ajax-tests.ts => microsoft-ajax-tests.ts} | 0 microsoft-ajax/tsconfig.json | 2 +- .../global-bind.ts} | 0 .../{mousetrap-tests.ts => test/index.ts} | 0 mousetrap/tsconfig.json | 4 +- .../actionSheet.ts} | 0 .../app-version.ts} | 0 .../appAvailability.ts} | 0 ng-cordova/{badge-tests.ts => test/badge.ts} | 0 .../{camera-tests.ts => test/camera.ts} | 0 .../datepicker.ts} | 0 .../{device-tests.ts => test/device.ts} | 0 .../deviceMotion.ts} | 0 .../deviceOrientation.ts} | 0 .../{dialogs-tests.ts => test/dialogs.ts} | 0 .../emailComposer.ts} | 0 ng-cordova/{file-tests.ts => test/file.ts} | 0 .../fileTransfer.ts} | 0 .../geolocation.ts} | 0 .../{network-tests.ts => test/network.ts} | 0 ng-cordova/{toast-tests.ts => test/toast.ts} | 0 ng-cordova/tsconfig.json | 32 +- ...js-toaster-tests.ts => ngtoaster-tests.ts} | 0 ngtoaster/tsconfig.json | 2 +- novnc/{noVNC-tests.ts => novnc-tests.ts} | 0 novnc/tsconfig.json | 2 +- .../{numeraljs-tests.ts => numeral-tests.ts} | 0 numeral/tsconfig.json | 2 +- .../{node-webkit-tests.ts => nw.gui-tests.ts} | 0 nw.gui/tsconfig.json | 2 +- openui5/{ui5-tests.ts => openui5-tests.ts} | 0 openui5/tsconfig.json | 2 +- ...{parallel-tests.ts => paralleljs-tests.ts} | 0 paralleljs/tsconfig.json | 2 +- ...ests.ts => paypal-cordova-plugin-tests.ts} | 0 paypal-cordova-plugin/tsconfig.json | 2 +- .../{please-tests.ts => pleasejs-tests.ts} | 0 pleasejs/tsconfig.json | 2 +- .../{popper-tests.ts => popper.js-tests.ts} | 0 popper.js/tsconfig.json | 2 +- pouchdb/{pouch-tests.ts => pouchdb-tests.ts} | 0 pouchdb/tsconfig.json | 2 +- prismjs/{prism-tests.ts => prismjs-tests.ts} | 0 prismjs/tsconfig.json | 2 +- ...{progress-tests.ts => progressjs-tests.ts} | 0 progressjs/tsconfig.json | 2 +- .../{PubSub-tests.ts => pubsub-js-tests.ts} | 0 pubsub-js/tsconfig.json | 2 +- ...js-ambient-tests.ts => random-js-tests.ts} | 0 random-js/tsconfig.json | 2 +- .../{ravenjs-tests.ts => raven-js-tests.ts} | 0 raven-js/tsconfig.json | 2 +- .../animated.tsx} | 0 .../index.tsx} | 0 react-native/tsconfig.json | 4 +- react/{react-tests.ts => test/index.ts} | 0 react/{react-tsx-tests.tsx => test/tsx.tsx} | 0 react/tsconfig.json | 4 +- ...y-tests.ts => requirejs-domready-tests.ts} | 0 requirejs-domready/tsconfig.json | 2 +- .../{require-tests.ts => requirejs-tests.ts} | 0 requirejs/tsconfig.json | 2 +- ...x.angular-tests.ts => rx-angular-tests.ts} | 0 rx-angular/tsconfig.json | 2 +- sammy/{sammyjs-tests.ts => sammy-tests.ts} | 0 sammy/tsconfig.json | 2 +- .../{chrome-tests.ts => test/chrome.ts} | 0 .../{firefox-tests.ts => test/firefox.ts} | 0 .../{index-tests.ts => test/index.ts} | 0 selenium-webdriver/tsconfig.json | 8 +- ...haTouch-tests.ts => sencha_touch-tests.ts} | 0 sencha_touch/tsconfig.json | 2 +- ...harePoint-tests.ts => sharepoint-tests.ts} | 0 sharepoint/tsconfig.json | 2 +- .../{js-signals-tests.ts => signals-tests.ts} | 0 signals/tsconfig.json | 2 +- .../{slickgrid-tests.ts => test/index.ts} | 0 .../slick.autotooltips.ts} | 0 .../slick.checkboxselectcolumn.ts} | 4 - slickgrid/tsconfig.json | 8 +- .../{sprintf-tests.ts => sprintf-js-tests.ts} | 0 sprintf-js/tsconfig.json | 2 +- svg.js/{svgjs-tests.ts => svg.js-tests.ts} | 0 svg.js/tsconfig.json | 2 +- ...h-event-tests.ts => touch-events-tests.ts} | 0 touch-events/tsconfig.json | 2 +- uuidjs/tsconfig.json | 2 +- uuidjs/{UUID-tests.ts => uuidjs-tests.ts} | 0 vex-js/tsconfig.json | 2 +- vex-js/{vex-tests.ts => vex-js-tests.ts} | 0 vivus/tsconfig.json | 2 +- vivus/{index-tests.ts => vivus-tests.ts} | 0 .../MediaStream.ts} | 1 - .../RTCPeerConnection.ts} | 3 - webrtc/tsconfig.json | 4 +- x2js/tsconfig.json | 2 +- x2js/{xml2json-tests.ts => x2js-tests.ts} | 0 316 files changed, 200 insertions(+), 652 deletions(-) rename ace/{tests/ace-anchor-tests.ts => test/anchor.ts} (100%) rename ace/{tests/ace-background_tokenizer-tests.ts => test/background_tokenizer.ts} (100%) rename ace/{tests/ace-default-tests.ts => test/default.ts} (100%) rename ace/{tests/ace-document-tests.ts => test/document.ts} (100%) rename ace/{tests/ace-edit_session-tests.ts => test/edit_session.ts} (100%) rename ace/{tests/ace-editor1-tests.ts => test/editor1.ts} (100%) rename ace/{tests/ace-editor_highlight_selected_word-tests.ts => test/editor_highlight_selected_word.ts} (100%) rename ace/{tests/ace-editor_navigation-tests.ts => test/editor_navigation.ts} (100%) rename ace/{tests/ace-editor_text_edit-tests.ts => test/editor_text_edit.ts} (100%) rename ace/{tests/ace-multi_select-tests.ts => test/multi_select.ts} (100%) rename ace/{tests/ace-placeholder-tests.ts => test/placeholder.ts} (100%) rename ace/{tests/ace-range-tests.ts => test/range.ts} (100%) rename ace/{tests/ace-range_list-tests.ts => test/range_list.ts} (100%) rename ace/{tests/ace-search-tests.ts => test/search.ts} (100%) rename ace/{tests/ace-selection-tests.ts => test/selection.ts} (100%) rename ace/{tests/ace-token_iterator-tests.ts => test/token_iterator.ts} (100%) rename ace/{tests/ace-virtual_renderer-tests.ts => test/virtual_renderer.ts} (100%) rename acl/{acl-tests.ts => test/index.ts} (100%) rename acl/{acl-mongodbBackend-tests.ts => test/mongodbBackend.ts} (100%) rename acl/{acl-redisBackend-tests.ts => test/redisBackend.ts} (100%) rename adal/{adal-angular-tests.ts => test/angular.ts} (100%) rename adal/{adal-tests.ts => test/index.ts} (100%) rename amplify/{amplifyjs-tests.ts => amplify-tests.ts} (100%) rename angular-localforage/{angular-localForage-tests.ts => angular-localforage-tests.ts} (100%) rename angular-media-queries/{match-media-tests.ts => angular-media-queries-tests.ts} (100%) rename angularlocalstorage/{angularLocalStorage-tests.ts => angularlocalstorage-tests.ts} (100%) rename array-uniq/{index-tests.ts => array-uniq-tests.ts} (100%) rename async/{async-explicit-tests.ts => test/explicit.ts} (100%) rename async/{async-tests.ts => test/index.ts} (100%) rename auth0-lock/{auth0.lock-tests.ts => auth0-lock-tests.ts} (100%) rename azure-mobile-services-client/{AzureMobileServicesClient-tests.ts => azure-mobile-services-client-tests.ts} (100%) rename babylonjs/{babylon-tests.ts => babylonjs-tests.ts} (100%) rename backbone.marionette/{marionette-tests.ts => backbone.marionette-tests.ts} (100%) delete mode 100644 backbone/backbone-with-lodash-tests.ts rename bounce.js/{bounce-tests.ts => bounce.js-tests.ts} (100%) delete mode 100644 bowser/bowser-module-tests.ts rename bowser/{bowser-global-tests.ts => bowser-tests.ts} (100%) rename box2d/{box2dweb-tests.ts => box2d-tests.ts} (100%) rename chartjs/{chart-tests.ts => chartjs-tests.ts} (100%) rename chrome/{chrome-app-tests.ts => test/chrome-app.ts} (100%) rename chrome/{chrome-tests.ts => test/index.ts} (100%) rename cldrjs/{cldr.js-event-tests.ts => test/event.ts} (93%) rename cldrjs/{cldr.js-tests.ts => test/index.ts} (100%) rename cldrjs/{cldr.js-supplemental-tests.ts => test/supplemental.ts} (100%) rename codemirror/{codemirror-tests.ts => test/index.ts} (100%) rename codemirror/{codemirror-matchbrackets-tests.ts => test/matchbrackets.ts} (100%) rename codemirror/{codemirror-runmode-tests.ts => test/runmode.ts} (100%) rename codemirror/{searchcursor-tests.ts => test/searchcursor.ts} (100%) rename codemirror/{codemirror-showhint-tests.ts => test/showhint.ts} (100%) rename cybozulabs-md5/{CybozuLabs-md5-tests.ts => cybozulabs-md5-tests.ts} (100%) rename date.format.js/{date.format-tests.ts => date.format.js-tests.ts} (100%) rename deployjava/{deployJava-tests.ts => deployjava-tests.ts} (100%) rename doccookies/{docCookies-tests.ts => doccookies-tests.ts} (100%) rename electron/{electron-tests.ts => test/index.ts} (100%) rename electron/{github-electron-main-tests.ts => test/main.ts} (100%) rename electron/{github-electron-renderer-tests.ts => test/renderer.ts} (100%) rename enhanced-resolve/{enhanced-resolve-tests.ts => test/index.ts} (100%) rename enhanced-resolve/{lib/lib-tests.ts => test/lib.ts} (100%) rename fabric/{fabricjs-tests.ts => fabric-tests.ts} (100%) rename falcor/{falcor-browser-tests.ts => test/browser.ts} (100%) rename falcor/{falcor-tests.ts => test/index.ts} (100%) rename fb/{fbsdk-tests.ts => fb-tests.ts} (100%) rename ffi/{node-ffi-tests.ts => ffi-tests.ts} (100%) rename file-saver/{FileSaver-tests.ts => file-saver-tests.ts} (100%) rename finch/{Finch-tests.ts => finch-tests.ts} (100%) rename fingerprintjs/{fingerprint-tests.ts => fingerprintjs-tests.ts} (100%) rename firebase/{firebase-tests.ts => test/index.ts} (100%) rename firebase/{firebase-simplelogin-tests.ts => test/simplelogin.ts} (100%) rename flexslider/{flexSlider-tests.ts => flexslider-tests.ts} (100%) rename format-unicorn/{format-unicorn-tests.ts => test/index.ts} (100%) rename format-unicorn/{format-unicorn-safe-tests.ts => test/safe.ts} (100%) rename fullcalendar/{fullCalendar-tests.ts => fullcalendar-tests.ts} (100%) rename fullcalendar/v1/{fullCalendar-tests.ts => fullcalendar-tests.ts} (100%) rename get-stdin/{index-tests.ts => get-stdin-tests.ts} (100%) rename git/{node-git-tests.ts => git-tests.ts} (100%) rename go/{goJS-tests.ts => go-tests.ts} (100%) rename google.analytics/{ga-tests.ts => google.analytics-tests.ts} (100%) rename googlemaps.infobubble/{google.maps.infobubble-tests.ts => googlemaps.infobubble-tests.ts} (100%) rename googlemaps/{google.maps-tests.ts => googlemaps-tests.ts} (100%) rename grunt/{gruntjs-tests.ts => grunt-tests.ts} (100%) rename halogen/{halogen-clip-loader-tests.tsx => test/clip-loader.tsx} (100%) rename halogen/{halogen-fade-loader-tests.tsx => test/fade-loader.tsx} (100%) rename halogen/{halogen-pacman-loader-tests.tsx => test/pacman-loader.tsx} (100%) rename halogen/{halogen-rotate-loader-tests.tsx => test/rotate-loader.tsx} (100%) rename heatmap.js/{heatmap-tests.ts => heatmap.js-tests.ts} (100%) rename highcharts/{modules/boost-tests.ts => test/boost.ts} (100%) rename highcharts/{modules/exporting-tests.ts => test/exporting.ts} (100%) rename highcharts/{highstock-tests.ts => test/highstock.ts} (100%) rename highcharts/{highcharts-tests.ts => test/index.ts} (100%) rename highcharts/{highcharts-more-tests.ts => test/more.ts} (100%) rename highcharts/{modules/no-data-to-display-tests.ts => test/no-data-to-display.ts} (100%) rename highcharts/{modules/offline-exporting-tests.ts => test/offline-exporting.ts} (100%) rename highlight.js/{highlightjs-tests.ts => highlight.js-tests.ts} (100%) rename history.js/{history-tests.ts => history.js-tests.ts} (100%) rename hubspot-pace/{HubSpot-pace-tests.ts => hubspot-pace-tests.ts} (100%) rename i18n/{i18n-node-tests.ts => i18n-tests.ts} (100%) rename interact.js/{interact-tests.ts => interact.js-tests.ts} (100%) rename intercomjs/{intercom-tests.ts => intercomjs-tests.ts} (100%) rename ion.rangeslider/{ion.rangeSlider-tests.ts => ion.rangeslider-tests.ts} (100%) rename ion.rangeslider/v1/{ion.rangeSlider-tests.ts => ion.rangeslider-tests.ts} (100%) rename is/{is_js-tests.ts => is-tests.ts} (100%) rename ix.js/{ix-tests.ts => test/index.ts} (100%) rename ix.js/{l2o-tests.ts => test/l2o.ts} (99%) rename jee-jsf/{jsf-tests.ts => jee-jsf-tests.ts} (100%) rename jodata/{joData-tests.ts => jodata-tests.ts} (100%) rename jquery.blockui/{jquery.blockUI-tests.ts => jquery.blockui-tests.ts} (100%) rename jquery.clientsidelogging/{jquery.clientSideLogging-tests.ts => jquery.clientsidelogging-tests.ts} (100%) rename jquery.contextmenu/{jquery.contextMenu-tests.ts => jquery.contextmenu-tests.ts} (100%) rename jquery.customselect/{jquery.customSelect-tests.ts => jquery.customselect-tests.ts} (100%) rename jquery.datatables/{jquery.dataTables-tests.ts => jquery.datatables-tests.ts} (100%) rename jquery.gridster/{gridster-tests.ts => jquery.gridster-tests.ts} (100%) rename jquery.leanmodal/{jquery.leanModal-tests.ts => jquery.leanmodal-tests.ts} (100%) rename jquery.notifybar/{jquery.notifyBar-tests.ts => jquery.notifybar-tests.ts} (100%) rename jquery.pjax.falsandtru/{jquery.pjax-tests.ts => jquery.pjax.falsandtru-tests.ts} (100%) rename jquery.postmessage/{jquery.postMessage-tests.ts => jquery.postmessage-tests.ts} (100%) rename jquery.rowgrid/{jquery.rowGrid-tests.ts => jquery.rowgrid-tests.ts} (100%) rename jquery.scrollto/{jquery.scrollTo-tests.ts => jquery.scrollto-tests.ts} (100%) rename jquery.simplepagination/{jquery.simplePagination-tests.ts => jquery.simplepagination-tests.ts} (100%) rename js-fixtures/{fixtures-tests.ts => js-fixtures-tests.ts} (100%) rename js-md5/{md5-tests.ts => js-md5-tests.ts} (100%) rename knockout/{tests/knockout-tests.ts => test/index.ts} (100%) rename knockout/{tests/knockout-templatingBehaviors-tests.ts => test/templatingBehaviors.ts} (100%) rename konami.js/{konami-tests.ts => konami.js-tests.ts} (100%) rename localforage/{localForage-tests.ts => localforage-tests.ts} (100%) rename loopback-boot/{loopback-boot-test.ts => loopback-boot-tests.ts} (100%) rename loopback/{loopback-test.ts => loopback-tests.ts} (100%) rename maker.js/{makerjs-tests.ts => maker.js-tests.ts} (100%) rename mandrill-api/{mandrill-tests.ts => mandrill-api-tests.ts} (100%) rename mcustomscrollbar/{mCustomScrollbar-tests.ts => mcustomscrollbar-tests.ts} (100%) rename memory-fs/{memory-fs-tests.ts => test/index.ts} (89%) rename memory-fs/{lib/join-tests.ts => test/join.ts} (100%) rename memory-fs/{lib/normalize-tests.ts => test/normalize.ts} (100%) delete mode 100644 metric-suffix/metric-suffix-external-tests.ts rename microsoft-ajax/{microsoft.ajax-tests.ts => microsoft-ajax-tests.ts} (100%) rename mousetrap/{mousetrap-global-bind-tests.ts => test/global-bind.ts} (100%) rename mousetrap/{mousetrap-tests.ts => test/index.ts} (100%) rename ng-cordova/{actionSheet-tests.ts => test/actionSheet.ts} (100%) rename ng-cordova/{app-version-tests.ts => test/app-version.ts} (100%) rename ng-cordova/{appAvailability-tests.ts => test/appAvailability.ts} (100%) rename ng-cordova/{badge-tests.ts => test/badge.ts} (100%) rename ng-cordova/{camera-tests.ts => test/camera.ts} (100%) rename ng-cordova/{datepicker-tests.ts => test/datepicker.ts} (100%) rename ng-cordova/{device-tests.ts => test/device.ts} (100%) rename ng-cordova/{deviceMotion-tests.ts => test/deviceMotion.ts} (100%) rename ng-cordova/{deviceOrientation-tests.ts => test/deviceOrientation.ts} (100%) rename ng-cordova/{dialogs-tests.ts => test/dialogs.ts} (100%) rename ng-cordova/{emailComposer-tests.ts => test/emailComposer.ts} (100%) rename ng-cordova/{file-tests.ts => test/file.ts} (100%) rename ng-cordova/{fileTransfer-tests.ts => test/fileTransfer.ts} (100%) rename ng-cordova/{geolocation-tests.ts => test/geolocation.ts} (100%) rename ng-cordova/{network-tests.ts => test/network.ts} (100%) rename ng-cordova/{toast-tests.ts => test/toast.ts} (100%) rename ngtoaster/{angularjs-toaster-tests.ts => ngtoaster-tests.ts} (100%) rename novnc/{noVNC-tests.ts => novnc-tests.ts} (100%) rename numeral/{numeraljs-tests.ts => numeral-tests.ts} (100%) rename nw.gui/{node-webkit-tests.ts => nw.gui-tests.ts} (100%) rename openui5/{ui5-tests.ts => openui5-tests.ts} (100%) rename paralleljs/{parallel-tests.ts => paralleljs-tests.ts} (100%) rename paypal-cordova-plugin/{PayPal-Cordova-Plugin-tests.ts => paypal-cordova-plugin-tests.ts} (100%) rename pleasejs/{please-tests.ts => pleasejs-tests.ts} (100%) rename popper.js/{popper-tests.ts => popper.js-tests.ts} (100%) rename pouchdb/{pouch-tests.ts => pouchdb-tests.ts} (100%) rename prismjs/{prism-tests.ts => prismjs-tests.ts} (100%) rename progressjs/{progress-tests.ts => progressjs-tests.ts} (100%) rename pubsub-js/{PubSub-tests.ts => pubsub-js-tests.ts} (100%) rename random-js/{random-js-ambient-tests.ts => random-js-tests.ts} (100%) rename raven-js/{ravenjs-tests.ts => raven-js-tests.ts} (100%) rename react-native/{react-native-animated-tests.tsx => test/animated.tsx} (100%) rename react-native/{react-native-tests.tsx => test/index.tsx} (100%) rename react/{react-tests.ts => test/index.ts} (100%) rename react/{react-tsx-tests.tsx => test/tsx.tsx} (100%) rename requirejs-domready/{domready-tests.ts => requirejs-domready-tests.ts} (100%) rename requirejs/{require-tests.ts => requirejs-tests.ts} (100%) rename rx-angular/{rx.angular-tests.ts => rx-angular-tests.ts} (100%) rename sammy/{sammyjs-tests.ts => sammy-tests.ts} (100%) rename selenium-webdriver/{chrome-tests.ts => test/chrome.ts} (100%) rename selenium-webdriver/{firefox-tests.ts => test/firefox.ts} (100%) rename selenium-webdriver/{index-tests.ts => test/index.ts} (100%) rename sencha_touch/{SenchaTouch-tests.ts => sencha_touch-tests.ts} (100%) rename sharepoint/{SharePoint-tests.ts => sharepoint-tests.ts} (100%) rename signals/{js-signals-tests.ts => signals-tests.ts} (100%) rename slickgrid/{slickgrid-tests.ts => test/index.ts} (100%) rename slickgrid/{slick.autotooltips-tests.ts => test/slick.autotooltips.ts} (100%) rename slickgrid/{slick.checkboxselectcolumn-tests.ts => test/slick.checkboxselectcolumn.ts} (89%) rename sprintf-js/{sprintf-tests.ts => sprintf-js-tests.ts} (100%) rename svg.js/{svgjs-tests.ts => svg.js-tests.ts} (100%) rename touch-events/{touch-event-tests.ts => touch-events-tests.ts} (100%) rename uuidjs/{UUID-tests.ts => uuidjs-tests.ts} (100%) rename vex-js/{vex-tests.ts => vex-js-tests.ts} (100%) rename vivus/{index-tests.ts => vivus-tests.ts} (100%) rename webrtc/{MediaStream-tests.ts => test/MediaStream.ts} (97%) rename webrtc/{RTCPeerConnection-tests.ts => test/RTCPeerConnection.ts} (97%) rename x2js/{xml2json-tests.ts => x2js-tests.ts} (100%) diff --git a/ace/tests/ace-anchor-tests.ts b/ace/test/anchor.ts similarity index 100% rename from ace/tests/ace-anchor-tests.ts rename to ace/test/anchor.ts diff --git a/ace/tests/ace-background_tokenizer-tests.ts b/ace/test/background_tokenizer.ts similarity index 100% rename from ace/tests/ace-background_tokenizer-tests.ts rename to ace/test/background_tokenizer.ts diff --git a/ace/tests/ace-default-tests.ts b/ace/test/default.ts similarity index 100% rename from ace/tests/ace-default-tests.ts rename to ace/test/default.ts diff --git a/ace/tests/ace-document-tests.ts b/ace/test/document.ts similarity index 100% rename from ace/tests/ace-document-tests.ts rename to ace/test/document.ts diff --git a/ace/tests/ace-edit_session-tests.ts b/ace/test/edit_session.ts similarity index 100% rename from ace/tests/ace-edit_session-tests.ts rename to ace/test/edit_session.ts diff --git a/ace/tests/ace-editor1-tests.ts b/ace/test/editor1.ts similarity index 100% rename from ace/tests/ace-editor1-tests.ts rename to ace/test/editor1.ts diff --git a/ace/tests/ace-editor_highlight_selected_word-tests.ts b/ace/test/editor_highlight_selected_word.ts similarity index 100% rename from ace/tests/ace-editor_highlight_selected_word-tests.ts rename to ace/test/editor_highlight_selected_word.ts diff --git a/ace/tests/ace-editor_navigation-tests.ts b/ace/test/editor_navigation.ts similarity index 100% rename from ace/tests/ace-editor_navigation-tests.ts rename to ace/test/editor_navigation.ts diff --git a/ace/tests/ace-editor_text_edit-tests.ts b/ace/test/editor_text_edit.ts similarity index 100% rename from ace/tests/ace-editor_text_edit-tests.ts rename to ace/test/editor_text_edit.ts diff --git a/ace/tests/ace-multi_select-tests.ts b/ace/test/multi_select.ts similarity index 100% rename from ace/tests/ace-multi_select-tests.ts rename to ace/test/multi_select.ts diff --git a/ace/tests/ace-placeholder-tests.ts b/ace/test/placeholder.ts similarity index 100% rename from ace/tests/ace-placeholder-tests.ts rename to ace/test/placeholder.ts diff --git a/ace/tests/ace-range-tests.ts b/ace/test/range.ts similarity index 100% rename from ace/tests/ace-range-tests.ts rename to ace/test/range.ts diff --git a/ace/tests/ace-range_list-tests.ts b/ace/test/range_list.ts similarity index 100% rename from ace/tests/ace-range_list-tests.ts rename to ace/test/range_list.ts diff --git a/ace/tests/ace-search-tests.ts b/ace/test/search.ts similarity index 100% rename from ace/tests/ace-search-tests.ts rename to ace/test/search.ts diff --git a/ace/tests/ace-selection-tests.ts b/ace/test/selection.ts similarity index 100% rename from ace/tests/ace-selection-tests.ts rename to ace/test/selection.ts diff --git a/ace/tests/ace-token_iterator-tests.ts b/ace/test/token_iterator.ts similarity index 100% rename from ace/tests/ace-token_iterator-tests.ts rename to ace/test/token_iterator.ts diff --git a/ace/tests/ace-virtual_renderer-tests.ts b/ace/test/virtual_renderer.ts similarity index 100% rename from ace/tests/ace-virtual_renderer-tests.ts rename to ace/test/virtual_renderer.ts diff --git a/ace/tsconfig.json b/ace/tsconfig.json index e5a0d270c3..0a65374983 100644 --- a/ace/tsconfig.json +++ b/ace/tsconfig.json @@ -15,22 +15,22 @@ }, "files": [ "index.d.ts", - "tests/ace-anchor-tests.ts", - "tests/ace-background_tokenizer-tests.ts", - "tests/ace-default-tests.ts", - "tests/ace-document-tests.ts", - "tests/ace-edit_session-tests.ts", - "tests/ace-editor1-tests.ts", - "tests/ace-editor_highlight_selected_word-tests.ts", - "tests/ace-editor_navigation-tests.ts", - "tests/ace-editor_text_edit-tests.ts", - "tests/ace-multi_select-tests.ts", - "tests/ace-placeholder-tests.ts", - "tests/ace-range-tests.ts", - "tests/ace-range_list-tests.ts", - "tests/ace-search-tests.ts", - "tests/ace-selection-tests.ts", - "tests/ace-token_iterator-tests.ts", - "tests/ace-virtual_renderer-tests.ts" + "test/anchor.ts", + "test/background_tokenizer.ts", + "test/default.ts", + "test/document.ts", + "test/edit_session.ts", + "test/editor1.ts", + "test/editor_highlight_selected_word.ts", + "test/editor_navigation.ts", + "test/editor_text_edit.ts", + "test/multi_select.ts", + "test/placeholder.ts", + "test/range.ts", + "test/range_list.ts", + "test/search.ts", + "test/selection.ts", + "test/token_iterator.ts", + "test/virtual_renderer.ts" ] } \ No newline at end of file diff --git a/acl/acl-tests.ts b/acl/test/index.ts similarity index 100% rename from acl/acl-tests.ts rename to acl/test/index.ts diff --git a/acl/acl-mongodbBackend-tests.ts b/acl/test/mongodbBackend.ts similarity index 100% rename from acl/acl-mongodbBackend-tests.ts rename to acl/test/mongodbBackend.ts diff --git a/acl/acl-redisBackend-tests.ts b/acl/test/redisBackend.ts similarity index 100% rename from acl/acl-redisBackend-tests.ts rename to acl/test/redisBackend.ts diff --git a/acl/tsconfig.json b/acl/tsconfig.json index d4ffafa7de..d663cdaa7f 100644 --- a/acl/tsconfig.json +++ b/acl/tsconfig.json @@ -15,8 +15,8 @@ }, "files": [ "index.d.ts", - "acl-tests.ts", - "acl-mongodbBackend-tests.ts", - "acl-redisBackend-tests.ts" + "test/index.ts", + "test/mongodbBackend.ts", + "test/redisBackend.ts" ] } \ No newline at end of file diff --git a/adal/adal-angular-tests.ts b/adal/test/angular.ts similarity index 100% rename from adal/adal-angular-tests.ts rename to adal/test/angular.ts diff --git a/adal/adal-tests.ts b/adal/test/index.ts similarity index 100% rename from adal/adal-tests.ts rename to adal/test/index.ts diff --git a/adal/tsconfig.json b/adal/tsconfig.json index e8a928a6ac..cabee4eec0 100644 --- a/adal/tsconfig.json +++ b/adal/tsconfig.json @@ -15,8 +15,8 @@ }, "files": [ "index.d.ts", - "adal-tests.ts", "adal-angular.d.ts", - "adal-angular-tests.ts" + "test/index.ts", + "test/angular.ts" ] } \ No newline at end of file diff --git a/amplify/amplifyjs-tests.ts b/amplify/amplify-tests.ts similarity index 100% rename from amplify/amplifyjs-tests.ts rename to amplify/amplify-tests.ts diff --git a/amplify/tsconfig.json b/amplify/tsconfig.json index 1adb36d073..a65fb478f3 100644 --- a/amplify/tsconfig.json +++ b/amplify/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "amplifyjs-tests.ts" + "amplify-tests.ts" ] } \ No newline at end of file diff --git a/angular-localforage/angular-localForage-tests.ts b/angular-localforage/angular-localforage-tests.ts similarity index 100% rename from angular-localforage/angular-localForage-tests.ts rename to angular-localforage/angular-localforage-tests.ts diff --git a/angular-localforage/tsconfig.json b/angular-localforage/tsconfig.json index e962f64de3..fd8c932b11 100644 --- a/angular-localforage/tsconfig.json +++ b/angular-localforage/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "angular-localForage-tests.ts" + "angular-localforage-tests.ts" ] } \ No newline at end of file diff --git a/angular-media-queries/match-media-tests.ts b/angular-media-queries/angular-media-queries-tests.ts similarity index 100% rename from angular-media-queries/match-media-tests.ts rename to angular-media-queries/angular-media-queries-tests.ts diff --git a/angular-media-queries/tsconfig.json b/angular-media-queries/tsconfig.json index df6257738e..493c273a2b 100644 --- a/angular-media-queries/tsconfig.json +++ b/angular-media-queries/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "match-media-tests.ts" + "angular-media-queries-tests.ts" ] } \ No newline at end of file diff --git a/angularlocalstorage/angularLocalStorage-tests.ts b/angularlocalstorage/angularlocalstorage-tests.ts similarity index 100% rename from angularlocalstorage/angularLocalStorage-tests.ts rename to angularlocalstorage/angularlocalstorage-tests.ts diff --git a/angularlocalstorage/tsconfig.json b/angularlocalstorage/tsconfig.json index ecdf8c2a96..cc91224c3b 100644 --- a/angularlocalstorage/tsconfig.json +++ b/angularlocalstorage/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "angularLocalStorage-tests.ts" + "angularlocalstorage-tests.ts" ] } \ No newline at end of file diff --git a/array-uniq/index-tests.ts b/array-uniq/array-uniq-tests.ts similarity index 100% rename from array-uniq/index-tests.ts rename to array-uniq/array-uniq-tests.ts diff --git a/array-uniq/tsconfig.json b/array-uniq/tsconfig.json index 3d8c032420..70196adde6 100644 --- a/array-uniq/tsconfig.json +++ b/array-uniq/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "index-tests.ts" + "array-uniq-tests.ts" ] } \ No newline at end of file diff --git a/async/async-explicit-tests.ts b/async/test/explicit.ts similarity index 100% rename from async/async-explicit-tests.ts rename to async/test/explicit.ts diff --git a/async/async-tests.ts b/async/test/index.ts similarity index 100% rename from async/async-tests.ts rename to async/test/index.ts diff --git a/async/tsconfig.json b/async/tsconfig.json index 412f9b97c6..8cceeb6576 100644 --- a/async/tsconfig.json +++ b/async/tsconfig.json @@ -15,7 +15,7 @@ }, "files": [ "index.d.ts", - "async-tests.ts", - "async-explicit-tests.ts" + "test/index.ts", + "test/explicit.ts" ] } \ No newline at end of file diff --git a/auth0-lock/auth0.lock-tests.ts b/auth0-lock/auth0-lock-tests.ts similarity index 100% rename from auth0-lock/auth0.lock-tests.ts rename to auth0-lock/auth0-lock-tests.ts diff --git a/auth0-lock/tsconfig.json b/auth0-lock/tsconfig.json index 641164d8a0..21b7642137 100644 --- a/auth0-lock/tsconfig.json +++ b/auth0-lock/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "auth0.lock-tests.ts" + "auth0-lock-tests.ts" ] } \ No newline at end of file diff --git a/azure-mobile-services-client/AzureMobileServicesClient-tests.ts b/azure-mobile-services-client/azure-mobile-services-client-tests.ts similarity index 100% rename from azure-mobile-services-client/AzureMobileServicesClient-tests.ts rename to azure-mobile-services-client/azure-mobile-services-client-tests.ts diff --git a/azure-mobile-services-client/tsconfig.json b/azure-mobile-services-client/tsconfig.json index 7ad1094d69..5037dc88a1 100644 --- a/azure-mobile-services-client/tsconfig.json +++ b/azure-mobile-services-client/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "AzureMobileServicesClient-tests.ts" + "azure-mobile-services-client-tests.ts" ] } \ No newline at end of file diff --git a/babylonjs/babylon-tests.ts b/babylonjs/babylonjs-tests.ts similarity index 100% rename from babylonjs/babylon-tests.ts rename to babylonjs/babylonjs-tests.ts diff --git a/babylonjs/tsconfig.json b/babylonjs/tsconfig.json index b7a13bc9fc..185e6fda44 100644 --- a/babylonjs/tsconfig.json +++ b/babylonjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "babylon-tests.ts" + "babylonjs-tests.ts" ] } \ No newline at end of file diff --git a/backbone.marionette/marionette-tests.ts b/backbone.marionette/backbone.marionette-tests.ts similarity index 100% rename from backbone.marionette/marionette-tests.ts rename to backbone.marionette/backbone.marionette-tests.ts diff --git a/backbone.marionette/tsconfig.json b/backbone.marionette/tsconfig.json index 6fc8f27360..9dbd0a28f9 100644 --- a/backbone.marionette/tsconfig.json +++ b/backbone.marionette/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "marionette-tests.ts" + "backbone.marionette-tests.ts" ] } \ No newline at end of file diff --git a/backbone/backbone-with-lodash-tests.ts b/backbone/backbone-with-lodash-tests.ts deleted file mode 100644 index b44b2be988..0000000000 --- a/backbone/backbone-with-lodash-tests.ts +++ /dev/null @@ -1,404 +0,0 @@ -import * as Backbone from "backbone"; -import * as _ from "lodash"; - -function test_events() { - - var object = new Backbone.Events(); - object.on("alert", (eventName: string) => alert("Triggered " + eventName)); - - object.trigger("alert", "an event"); - - var onChange = () => alert('whatever'); - var context: any; - - object.off("change", onChange); - object.off("change"); - object.off(null, onChange); - object.off(null, null, context); - object.off(); -} - -class SettingDefaults extends Backbone.Model { - - // 'defaults' could be set in one of the following ways: - - defaults() { - return { - name: "Joe" - } - } - - constructor(attributes?: any, options?: any) { - super(attributes, options); // TODO error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. - this.defaults = { - name: "Joe" - } - // super has to come last - } - - // or set it like this - initialize() { - this.defaults = { - name: "Joe" - } - - } - - // same patterns could be used for setting 'Router.routes' and 'View.events' -} - -class Sidebar extends Backbone.Model { - - promptColor() { - var cssColor = prompt("Please enter a CSS color:"); - this.set({ color: cssColor }); - } -} - -class Note extends Backbone.Model { - initialize() { } - author() { } - coordinates() { } - allowedToEdit(account: any) { - return true; - } -} - -class PrivateNote extends Note { - allowedToEdit(account: any) { - return account.owns(this); - } - - set(attributes: any, options?: any): Backbone.Model { - return Backbone.Model.prototype.set.call(this, attributes, options); - } -} - -function test_models() { - - var sidebar = new Sidebar(); - sidebar.on('change:color', (model: {}, color: string) => $('#sidebar').css({ background: color })); - sidebar.set({ color: 'white' }); - sidebar.promptColor(); - - ////////// - - var note = new PrivateNote(); - - note.get("title"); - - note.set({ title: "March 20", content: "In his eyes she eclipses..." }); - - note.set("title", "A Scandal in Bohemia"); - - let strings: string[] - let value: any; - let values: any[]; - let bool: boolean; - - // underscore methods - strings = note.keys(); - values = note.values(); - values = note.pairs(); - values = note.invert(); - value = note.pick("foo"); - value = note.pick("foo", "bar"); - value = note.pick((value: any, key: any, object: any) => true); - value = note.omit("foo"); - value = note.omit("foo", "bar"); - value = note.omit((value: any, key: any, object: any) => true); - value = note.chain().pick().omit().value(); - bool = note.isEmpty(); -} - -class Employee extends Backbone.Model { - reports: EmployeeCollection; - - constructor(attributes?: any, options?: any) { - super(options); - this.reports = new EmployeeCollection(); - this.reports.url = '../api/employees/' + this.id + '/reports'; - } - - more() { - this.reports.reset(); - } -} - -class EmployeeCollection extends Backbone.Collection { - findByName(key: any) { } -} - -class Book extends Backbone.Model { - title: string; - author: string; - published: boolean; -} - -class Library extends Backbone.Collection { - // This model definition is here only to test type compatibility of the model, but it - // is not necessary in working code as it is automatically inferred through generics. - model: typeof Book; -} - -class Books extends Backbone.Collection { } - -function test_collection() { - - var books = new Books(); - - var book1: Book = new Book({ title: "Title 1", author: "Mike" }); - books.add(book1); - - // Objects can be added to collection by casting to model type. - // Compiler will check if object properties are valid for the cast. - // This gives better type checking than declaring an `any` overload. - books.add({ title: "Title 2", author: "Mikey" }); - - var model: Book = book1.collection.first(); - if (model !== book1) { - throw new Error("Error"); - } - - books.each(book => - book.get("title")); - - var titles = books.map(book => - book.get("title")); - - var publishedBooks = books.filter(book => - book.get("published") === true); - - var alphabetical = books.sortBy((book: Book): number => null); - - let one: Book; - let models: Book[]; - let bool: boolean; - let numDict: _.Dictionary; - let modelDict: _.Dictionary; - let modelsDict: _.Dictionary; - let num: number; - - models = books.slice(1); - models = books.slice(1, 3); - - // underscore methods - bool = books.all((value: Book, index: number, list: Book[]) => true); - bool = books.any((value: Book, index: number, list: Book[]) => true); - bool = books.chain().any((value: Book, index: number, list: Book[]) => true).value(); - models = books.collect((value: Book, index: number, list: Book[]) => value); - bool = books.contains(book1); - numDict = books.countBy((value: Book, index: number, list: Book[]) => true); - numDict = books.countBy("foo"); - one = books.detect((value: Book, index: number, list: Book[]) => true); - models = books.difference([book1]); - models = books.drop(); - models = books.each((value: Book, index: number, list: Book[]) => true); - bool = books.every((value: Book, index: number, list: Book[]) => true); - models = books.filter((value: Book, index: number, list: Book[]) => true); - one = books.find((value: Book, index: number, list: Book[]) => true); - num = books.findIndex((value: Book, index: number, list: Book[]) => true); - num = books.findLastIndex((value: Book, index: number, list: Book[]) => true); - one = books.first(); - models = books.first(3); - models = books.foldl((prev: Book[], curr: Book, index: number, list: Book[]) => prev, []); - models = books.foldr((prev: Book[], curr: Book, index: number, list: Book[]) => prev, []); - models = books.forEach((value: Book, index: number, list: Book[]) => true); - modelsDict = books.groupBy((value: Book, index: number, list: Book[]) => true); - modelsDict = books.groupBy("foo"); - one = books.head(); - models = books.head(3); - bool = books.include(book1); - bool = books.includes(book1); - modelDict = books.indexBy((value: Book, index: number, list: Book[]) => true); - modelDict = books.indexBy("foo"); - num = books.indexOf(book1, true); - one = books.initial(); - models = books.initial(3); - models = books.inject((prev: Book[], curr: Book, index: number, list: Book[]) => prev, []); - one = books.invoke("at", 3); - bool = books.isEmpty(); - one = books.last(); - models = books.last(3); - num = books.lastIndexOf(book1, 3); - models = books.map((value: Book, index: number, list: Book[]) => value); - one = books.max((value: Book, index: number, list: Book[]) => value); - one = books.min((value: Book, index: number, list: Book[]) => value); - [models] = books.partition((value: Book, index: number, list: Book[]) => true); - models = books.reduce((prev: Book[], curr: Book, index: number, list: Book[]) => prev, []); - models = books.reduceRight((prev: Book[], curr: Book, index: number, list: Book[]) => prev, []); - models = books.reject((value: Book, index: number, list: Book[]) => true); - models = books.rest(3); - one = books.sample(); - models = books.sample(3); - models = books.select((value: Book, index: number, list: Book[]) => true); - models = books.shuffle(); - num = books.size(); - bool = books.some((value: Book, index: number, list: Book[]) => true); - models = books.sortBy((value: Book, index: number, list: Book[]) => value); - models = books.sortBy("foo"); - models = books.tail(3); - one = books.take(); - models = books.take(3); - models = books.toArray(); - models = books.without(book1, book1); -} - -////////// - -Backbone.history.start(); - -namespace v1Changes { - namespace events { - function test_once() { - var model = new Employee; - model.once('invalid', () => { }, this); - model.once('invalid', () => { }); - } - - function test_listenTo() { - var model = new Employee; - var view = new Backbone.View(); - view.listenTo(model, 'invalid', () => { }); - } - - function test_listenToOnce() { - var model = new Employee; - var view = new Backbone.View(); - view.listenToOnce(model, 'invalid', () => { }); - } - - function test_stopListening() { - var model = new Employee; - var view = new Backbone.View(); - view.stopListening(model, 'invalid', () => { }); - view.stopListening(model, 'invalid'); - view.stopListening(model); - } - } - - namespace ModelAndCollection { - function test_url() { - Employee.prototype.url = () => '/employees'; - EmployeeCollection.prototype.url = () => '/employees'; - } - - function test_parse() { - var model = new Employee(); - model.parse('{}', {}); - var collection = new EmployeeCollection; - collection.parse('{}', {}); - } - - function test_toJSON() { - var model = new Employee(); - model.toJSON({}); - var collection = new EmployeeCollection; - collection.toJSON({}); - } - - function test_sync() { - var model = new Employee(); - model.sync(); - var collection = new EmployeeCollection; - collection.sync(); - } - } - - namespace Model { - function test_validationError() { - var model = new Employee; - if (model.validationError) { - console.log('has validation errors'); - } - } - - function test_fetch() { - var model = new Employee({ id: 1 }); - model.fetch({ - success: () => { }, - error: () => { } - }); - } - - function test_set() { - var model = new Employee; - model.set({ name: 'JoeDoe', age: 21 }, { validate: false }); - model.set('name', 'JoeDoes', { validate: false }); - } - - function test_destroy() { - var model = new Employee; - model.destroy({ - wait: true, - success: (m?, response?, options?) => { }, - error: (m?, jqxhr?, options?) => { } - }); - - model.destroy({ - success: (m?, response?, options?) => { }, - error: (m?, jqxhr?) => { } - }); - - model.destroy({ - success: () => { }, - error: (m?, jqxhr?) => { } - }); - } - - function test_save() { - var model = new Employee; - - model.save({ - name: 'Joe Doe', - age: 21 - }, - { - wait: true, - validate: false, - success: (m?, response?, options?) => { }, - error: (m?, jqxhr?, options?) => { } - }); - - model.save({ - name: 'Joe Doe', - age: 21 - }, - { - success: () => { }, - error: (m?, jqxhr?) => { } - }); - } - - function test_validate() { - var model = new Employee; - - model.validate({ name: 'JoeDoe', age: 21 }, { validateAge: false }) - } - } - - namespace Collection { - function test_fetch() { - var collection = new EmployeeCollection; - collection.fetch({ reset: true }); - } - - function test_create() { - var collection = new EmployeeCollection; - var model = new Employee; - - collection.create(model, { - validate: false - }); - } - } - - namespace Router { - function test_navigate() { - var router = new Backbone.Router; - - router.navigate('/employees', { trigger: true }); - router.navigate('/employees', true); - } - } -} diff --git a/backbone/tsconfig.json b/backbone/tsconfig.json index 43a64b9e25..b4a63b9ef0 100644 --- a/backbone/tsconfig.json +++ b/backbone/tsconfig.json @@ -15,7 +15,6 @@ }, "files": [ "index.d.ts", - "backbone-tests.ts", - "backbone-with-lodash-tests.ts" + "backbone-tests.ts" ] } \ No newline at end of file diff --git a/bounce.js/bounce-tests.ts b/bounce.js/bounce.js-tests.ts similarity index 100% rename from bounce.js/bounce-tests.ts rename to bounce.js/bounce.js-tests.ts diff --git a/bounce.js/tsconfig.json b/bounce.js/tsconfig.json index d06c697a6b..1718271ef6 100644 --- a/bounce.js/tsconfig.json +++ b/bounce.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "bounce-tests.ts" + "bounce.js-tests.ts" ] } \ No newline at end of file diff --git a/bowser/bowser-module-tests.ts b/bowser/bowser-module-tests.ts deleted file mode 100644 index 7d662b2f2b..0000000000 --- a/bowser/bowser-module-tests.ts +++ /dev/null @@ -1,9 +0,0 @@ - - -import Bowser = require('bowser'); - -Bowser.msedge === true; -Bowser.test(['msie']) === true; -Bowser.a === Bowser.c; -Bowser.osversion > 10; -Bowser.osversion === '10.1A'; \ No newline at end of file diff --git a/bowser/bowser-global-tests.ts b/bowser/bowser-tests.ts similarity index 100% rename from bowser/bowser-global-tests.ts rename to bowser/bowser-tests.ts diff --git a/bowser/tsconfig.json b/bowser/tsconfig.json index 60a6d8803f..70de6c837c 100644 --- a/bowser/tsconfig.json +++ b/bowser/tsconfig.json @@ -15,7 +15,6 @@ }, "files": [ "index.d.ts", - "bowser-module-tests.ts", - "bowser-global-tests.ts" + "bowser-tests.ts" ] } \ No newline at end of file diff --git a/box2d/box2dweb-tests.ts b/box2d/box2d-tests.ts similarity index 100% rename from box2d/box2dweb-tests.ts rename to box2d/box2d-tests.ts diff --git a/box2d/tsconfig.json b/box2d/tsconfig.json index 426500dcfd..d98f02a1c1 100644 --- a/box2d/tsconfig.json +++ b/box2d/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "box2dweb-tests.ts" + "box2d-tests.ts" ] } \ No newline at end of file diff --git a/chartjs/chart-tests.ts b/chartjs/chartjs-tests.ts similarity index 100% rename from chartjs/chart-tests.ts rename to chartjs/chartjs-tests.ts diff --git a/chartjs/tsconfig.json b/chartjs/tsconfig.json index 5d31ea6aa4..e6b3a63e91 100644 --- a/chartjs/tsconfig.json +++ b/chartjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "chart-tests.ts" + "chartjs-tests.ts" ] } \ No newline at end of file diff --git a/chrome/chrome-app-tests.ts b/chrome/test/chrome-app.ts similarity index 100% rename from chrome/chrome-app-tests.ts rename to chrome/test/chrome-app.ts diff --git a/chrome/chrome-tests.ts b/chrome/test/index.ts similarity index 100% rename from chrome/chrome-tests.ts rename to chrome/test/index.ts diff --git a/chrome/tsconfig.json b/chrome/tsconfig.json index 385e3c3ccf..33947734d9 100644 --- a/chrome/tsconfig.json +++ b/chrome/tsconfig.json @@ -16,8 +16,8 @@ "files": [ "index.d.ts", "chrome-app.d.ts", - "chrome-app-tests.ts", "chrome-cast.d.ts", - "chrome-tests.ts" + "test/index.ts", + "test/chrome-app.ts" ] } \ No newline at end of file diff --git a/cldrjs/cldr.js-event-tests.ts b/cldrjs/test/event.ts similarity index 93% rename from cldrjs/cldr.js-event-tests.ts rename to cldrjs/test/event.ts index c626e72663..92e8d51b77 100644 --- a/cldrjs/cldr.js-event-tests.ts +++ b/cldrjs/test/event.ts @@ -1,5 +1,3 @@ -/// - Cldr.on("get", (path, value) => { console.log(path); console.log(value); diff --git a/cldrjs/cldr.js-tests.ts b/cldrjs/test/index.ts similarity index 100% rename from cldrjs/cldr.js-tests.ts rename to cldrjs/test/index.ts diff --git a/cldrjs/cldr.js-supplemental-tests.ts b/cldrjs/test/supplemental.ts similarity index 100% rename from cldrjs/cldr.js-supplemental-tests.ts rename to cldrjs/test/supplemental.ts diff --git a/cldrjs/tsconfig.json b/cldrjs/tsconfig.json index f7edc6e510..2d2559c670 100644 --- a/cldrjs/tsconfig.json +++ b/cldrjs/tsconfig.json @@ -16,8 +16,8 @@ "files": [ "index.d.ts", "cldr.js-supplemental.d.ts", - "cldr.js-tests.ts", - "cldr.js-event-tests.ts", - "cldr.js-supplemental-tests.ts" + "test/index.ts", + "test/event.ts", + "test/supplemental.ts" ] } \ No newline at end of file diff --git a/codemirror/codemirror-tests.ts b/codemirror/test/index.ts similarity index 100% rename from codemirror/codemirror-tests.ts rename to codemirror/test/index.ts diff --git a/codemirror/codemirror-matchbrackets-tests.ts b/codemirror/test/matchbrackets.ts similarity index 100% rename from codemirror/codemirror-matchbrackets-tests.ts rename to codemirror/test/matchbrackets.ts diff --git a/codemirror/codemirror-runmode-tests.ts b/codemirror/test/runmode.ts similarity index 100% rename from codemirror/codemirror-runmode-tests.ts rename to codemirror/test/runmode.ts diff --git a/codemirror/searchcursor-tests.ts b/codemirror/test/searchcursor.ts similarity index 100% rename from codemirror/searchcursor-tests.ts rename to codemirror/test/searchcursor.ts diff --git a/codemirror/codemirror-showhint-tests.ts b/codemirror/test/showhint.ts similarity index 100% rename from codemirror/codemirror-showhint-tests.ts rename to codemirror/test/showhint.ts diff --git a/codemirror/tsconfig.json b/codemirror/tsconfig.json index 6b0d828cdc..01c0253447 100644 --- a/codemirror/tsconfig.json +++ b/codemirror/tsconfig.json @@ -15,14 +15,14 @@ }, "files": [ "index.d.ts", - "codemirror-tests.ts", "codemirror-matchbrackets.d.ts", - "codemirror-matchbrackets-tests.ts", "codemirror-runmode.d.ts", - "codemirror-runmode-tests.ts", "codemirror-showhint.d.ts", - "codemirror-showhint-tests.ts", "searchcursor.d.ts", - "searchcursor-tests.ts" + "test/index.ts", + "test/matchbrackets.ts", + "test/runmode.ts", + "test/searchcursor.ts", + "test/showhint.ts" ] } \ No newline at end of file diff --git a/cybozulabs-md5/CybozuLabs-md5-tests.ts b/cybozulabs-md5/cybozulabs-md5-tests.ts similarity index 100% rename from cybozulabs-md5/CybozuLabs-md5-tests.ts rename to cybozulabs-md5/cybozulabs-md5-tests.ts diff --git a/cybozulabs-md5/tsconfig.json b/cybozulabs-md5/tsconfig.json index 68a7e48345..37774f4c4e 100644 --- a/cybozulabs-md5/tsconfig.json +++ b/cybozulabs-md5/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "CybozuLabs-md5-tests.ts" + "cybozulabs-md5-tests.ts" ] } \ No newline at end of file diff --git a/date.format.js/date.format-tests.ts b/date.format.js/date.format.js-tests.ts similarity index 100% rename from date.format.js/date.format-tests.ts rename to date.format.js/date.format.js-tests.ts diff --git a/date.format.js/tsconfig.json b/date.format.js/tsconfig.json index ab30747450..794c0f0e15 100644 --- a/date.format.js/tsconfig.json +++ b/date.format.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "date.format-tests.ts" + "date.format.js-tests.ts" ] } \ No newline at end of file diff --git a/deployjava/deployJava-tests.ts b/deployjava/deployjava-tests.ts similarity index 100% rename from deployjava/deployJava-tests.ts rename to deployjava/deployjava-tests.ts diff --git a/deployjava/tsconfig.json b/deployjava/tsconfig.json index 5cf5fed9e5..ffd4d28173 100644 --- a/deployjava/tsconfig.json +++ b/deployjava/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "deployJava-tests.ts" + "deployjava-tests.ts" ] } \ No newline at end of file diff --git a/doccookies/docCookies-tests.ts b/doccookies/doccookies-tests.ts similarity index 100% rename from doccookies/docCookies-tests.ts rename to doccookies/doccookies-tests.ts diff --git a/doccookies/tsconfig.json b/doccookies/tsconfig.json index c6572494b3..ef167447be 100644 --- a/doccookies/tsconfig.json +++ b/doccookies/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "docCookies-tests.ts" + "doccookies-tests.ts" ] } \ No newline at end of file diff --git a/electron/electron-tests.ts b/electron/test/index.ts similarity index 100% rename from electron/electron-tests.ts rename to electron/test/index.ts diff --git a/electron/github-electron-main-tests.ts b/electron/test/main.ts similarity index 100% rename from electron/github-electron-main-tests.ts rename to electron/test/main.ts diff --git a/electron/github-electron-renderer-tests.ts b/electron/test/renderer.ts similarity index 100% rename from electron/github-electron-renderer-tests.ts rename to electron/test/renderer.ts diff --git a/electron/tsconfig.json b/electron/tsconfig.json index 79c504aade..8b0d4b6952 100644 --- a/electron/tsconfig.json +++ b/electron/tsconfig.json @@ -15,8 +15,8 @@ }, "files": [ "index.d.ts", - "electron-tests.ts", - "github-electron-renderer-tests.ts", - "github-electron-main-tests.ts" + "test/index.ts", + "test/main.ts", + "test/renderer.ts" ] } \ No newline at end of file diff --git a/enhanced-resolve/enhanced-resolve-tests.ts b/enhanced-resolve/test/index.ts similarity index 100% rename from enhanced-resolve/enhanced-resolve-tests.ts rename to enhanced-resolve/test/index.ts diff --git a/enhanced-resolve/lib/lib-tests.ts b/enhanced-resolve/test/lib.ts similarity index 100% rename from enhanced-resolve/lib/lib-tests.ts rename to enhanced-resolve/test/lib.ts diff --git a/enhanced-resolve/tsconfig.json b/enhanced-resolve/tsconfig.json index 5bd29396ab..b1a5b475ef 100644 --- a/enhanced-resolve/tsconfig.json +++ b/enhanced-resolve/tsconfig.json @@ -15,7 +15,6 @@ }, "files": [ "index.d.ts", - "enhanced-resolve-tests.ts", "lib/AliasFieldPlugin.d.ts", "lib/AliasPlugin.d.ts", "lib/AppendPlugin.d.ts", @@ -33,7 +32,6 @@ "lib/getPaths.d.ts", "lib/globToRegExp.d.ts", "lib/JoinRequestPlugin.d.ts", - "lib/lib-tests.ts", "lib/LogInfoPlugin.d.ts", "lib/MainFieldPlugin.d.ts", "lib/ModuleAppendPlugin.d.ts", @@ -49,6 +47,8 @@ "lib/SyncAsyncFileSystemDecorator.d.ts", "lib/TryNextPlugin.d.ts", "lib/UnsafeCachePlugin.d.ts", - "lib/UseFilePlugin.d.ts" + "lib/UseFilePlugin.d.ts", + "test/index.ts", + "test/lib.ts" ] } diff --git a/fabric/fabricjs-tests.ts b/fabric/fabric-tests.ts similarity index 100% rename from fabric/fabricjs-tests.ts rename to fabric/fabric-tests.ts diff --git a/fabric/tsconfig.json b/fabric/tsconfig.json index fe93e260b9..60921d5263 100644 --- a/fabric/tsconfig.json +++ b/fabric/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "fabricjs-tests.ts" + "fabric-tests.ts" ] } \ No newline at end of file diff --git a/falcor/falcor-browser-tests.ts b/falcor/test/browser.ts similarity index 100% rename from falcor/falcor-browser-tests.ts rename to falcor/test/browser.ts diff --git a/falcor/falcor-tests.ts b/falcor/test/index.ts similarity index 100% rename from falcor/falcor-tests.ts rename to falcor/test/index.ts diff --git a/falcor/tsconfig.json b/falcor/tsconfig.json index 1709a8a627..d81a60d4ee 100644 --- a/falcor/tsconfig.json +++ b/falcor/tsconfig.json @@ -15,7 +15,7 @@ }, "files": [ "index.d.ts", - "falcor-tests.ts", - "falcor-browser-tests.ts" + "test/index.ts", + "test/browser.ts" ] } \ No newline at end of file diff --git a/fb/fbsdk-tests.ts b/fb/fb-tests.ts similarity index 100% rename from fb/fbsdk-tests.ts rename to fb/fb-tests.ts diff --git a/fb/tsconfig.json b/fb/tsconfig.json index f99ae7bb46..a04f48e410 100644 --- a/fb/tsconfig.json +++ b/fb/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "fbsdk-tests.ts" + "fb-tests.ts" ] } \ No newline at end of file diff --git a/ffi/node-ffi-tests.ts b/ffi/ffi-tests.ts similarity index 100% rename from ffi/node-ffi-tests.ts rename to ffi/ffi-tests.ts diff --git a/ffi/tsconfig.json b/ffi/tsconfig.json index df00f708f8..45c991ece0 100644 --- a/ffi/tsconfig.json +++ b/ffi/tsconfig.json @@ -16,6 +16,6 @@ "files": [ "index.d.ts", "node-ffi-buffer.d.ts", - "node-ffi-tests.ts" + "ffi-tests.ts" ] } \ No newline at end of file diff --git a/file-saver/FileSaver-tests.ts b/file-saver/file-saver-tests.ts similarity index 100% rename from file-saver/FileSaver-tests.ts rename to file-saver/file-saver-tests.ts diff --git a/file-saver/tsconfig.json b/file-saver/tsconfig.json index 0ff18d9918..8aa772455a 100644 --- a/file-saver/tsconfig.json +++ b/file-saver/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "FileSaver-tests.ts" + "file-saver-tests.ts" ] } \ No newline at end of file diff --git a/finch/Finch-tests.ts b/finch/finch-tests.ts similarity index 100% rename from finch/Finch-tests.ts rename to finch/finch-tests.ts diff --git a/finch/tsconfig.json b/finch/tsconfig.json index 990f0265d9..1ffe7db57e 100644 --- a/finch/tsconfig.json +++ b/finch/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "Finch-tests.ts" + "finch-tests.ts" ] } \ No newline at end of file diff --git a/fingerprintjs/fingerprint-tests.ts b/fingerprintjs/fingerprintjs-tests.ts similarity index 100% rename from fingerprintjs/fingerprint-tests.ts rename to fingerprintjs/fingerprintjs-tests.ts diff --git a/fingerprintjs/tsconfig.json b/fingerprintjs/tsconfig.json index c1a7922d8f..146b0b572e 100644 --- a/fingerprintjs/tsconfig.json +++ b/fingerprintjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "fingerprint-tests.ts" + "fingerprintjs-tests.ts" ] } \ No newline at end of file diff --git a/firebase/firebase-tests.ts b/firebase/test/index.ts similarity index 100% rename from firebase/firebase-tests.ts rename to firebase/test/index.ts diff --git a/firebase/firebase-simplelogin-tests.ts b/firebase/test/simplelogin.ts similarity index 100% rename from firebase/firebase-simplelogin-tests.ts rename to firebase/test/simplelogin.ts diff --git a/firebase/tsconfig.json b/firebase/tsconfig.json index ead8399d7a..38c3bea3d5 100644 --- a/firebase/tsconfig.json +++ b/firebase/tsconfig.json @@ -16,7 +16,7 @@ "files": [ "index.d.ts", "firebase-simplelogin.d.ts", - "firebase-tests.ts", - "firebase-simplelogin-tests.ts" + "test/index.ts", + "test/simplelogin.ts" ] } \ No newline at end of file diff --git a/flexslider/flexSlider-tests.ts b/flexslider/flexslider-tests.ts similarity index 100% rename from flexslider/flexSlider-tests.ts rename to flexslider/flexslider-tests.ts diff --git a/flexslider/tsconfig.json b/flexslider/tsconfig.json index 2319b11528..e856d242c2 100644 --- a/flexslider/tsconfig.json +++ b/flexslider/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "flexSlider-tests.ts" + "flexslider-tests.ts" ] } \ No newline at end of file diff --git a/format-unicorn/format-unicorn-tests.ts b/format-unicorn/test/index.ts similarity index 100% rename from format-unicorn/format-unicorn-tests.ts rename to format-unicorn/test/index.ts diff --git a/format-unicorn/format-unicorn-safe-tests.ts b/format-unicorn/test/safe.ts similarity index 100% rename from format-unicorn/format-unicorn-safe-tests.ts rename to format-unicorn/test/safe.ts diff --git a/format-unicorn/tsconfig.json b/format-unicorn/tsconfig.json index 2c82afbd5b..45bb7c114e 100644 --- a/format-unicorn/tsconfig.json +++ b/format-unicorn/tsconfig.json @@ -16,7 +16,7 @@ "files": [ "index.d.ts", "safe.d.ts", - "format-unicorn-tests.ts", - "format-unicorn-safe-tests.ts" + "test/index.ts", + "test/safe.ts" ] } \ No newline at end of file diff --git a/fullcalendar/fullCalendar-tests.ts b/fullcalendar/fullcalendar-tests.ts similarity index 100% rename from fullcalendar/fullCalendar-tests.ts rename to fullcalendar/fullcalendar-tests.ts diff --git a/fullcalendar/tsconfig.json b/fullcalendar/tsconfig.json index b8ea18f909..2d26610a8c 100644 --- a/fullcalendar/tsconfig.json +++ b/fullcalendar/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "fullCalendar-tests.ts" + "fullcalendar-tests.ts" ] } \ No newline at end of file diff --git a/fullcalendar/v1/fullCalendar-tests.ts b/fullcalendar/v1/fullcalendar-tests.ts similarity index 100% rename from fullcalendar/v1/fullCalendar-tests.ts rename to fullcalendar/v1/fullcalendar-tests.ts diff --git a/fullcalendar/v1/tsconfig.json b/fullcalendar/v1/tsconfig.json index a589491226..bf820ac863 100644 --- a/fullcalendar/v1/tsconfig.json +++ b/fullcalendar/v1/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "fullCalendar-tests.ts" + "fullcalendar-tests.ts" ] } \ No newline at end of file diff --git a/get-stdin/index-tests.ts b/get-stdin/get-stdin-tests.ts similarity index 100% rename from get-stdin/index-tests.ts rename to get-stdin/get-stdin-tests.ts diff --git a/get-stdin/tsconfig.json b/get-stdin/tsconfig.json index 3d8c032420..2d3c1a6c70 100644 --- a/get-stdin/tsconfig.json +++ b/get-stdin/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "index-tests.ts" + "get-stdin-tests.ts" ] } \ No newline at end of file diff --git a/git/node-git-tests.ts b/git/git-tests.ts similarity index 100% rename from git/node-git-tests.ts rename to git/git-tests.ts diff --git a/git/tsconfig.json b/git/tsconfig.json index 0bc0ff5fe6..eccbc2065b 100644 --- a/git/tsconfig.json +++ b/git/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "node-git-tests.ts" + "git-tests.ts" ] } \ No newline at end of file diff --git a/go/goJS-tests.ts b/go/go-tests.ts similarity index 100% rename from go/goJS-tests.ts rename to go/go-tests.ts diff --git a/go/tsconfig.json b/go/tsconfig.json index ced78ef938..cd76eca117 100644 --- a/go/tsconfig.json +++ b/go/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "goJS-tests.ts" + "go-tests.ts" ] } \ No newline at end of file diff --git a/google.analytics/ga-tests.ts b/google.analytics/google.analytics-tests.ts similarity index 100% rename from google.analytics/ga-tests.ts rename to google.analytics/google.analytics-tests.ts diff --git a/google.analytics/tsconfig.json b/google.analytics/tsconfig.json index ddce77f25e..b954b6f821 100644 --- a/google.analytics/tsconfig.json +++ b/google.analytics/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "ga-tests.ts" + "google.analytics-tests.ts" ] } \ No newline at end of file diff --git a/googlemaps.infobubble/google.maps.infobubble-tests.ts b/googlemaps.infobubble/googlemaps.infobubble-tests.ts similarity index 100% rename from googlemaps.infobubble/google.maps.infobubble-tests.ts rename to googlemaps.infobubble/googlemaps.infobubble-tests.ts diff --git a/googlemaps.infobubble/tsconfig.json b/googlemaps.infobubble/tsconfig.json index 165f392587..42b03a0823 100644 --- a/googlemaps.infobubble/tsconfig.json +++ b/googlemaps.infobubble/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "google.maps.infobubble-tests.ts" + "googlemaps.infobubble-tests.ts" ] } \ No newline at end of file diff --git a/googlemaps/google.maps-tests.ts b/googlemaps/googlemaps-tests.ts similarity index 100% rename from googlemaps/google.maps-tests.ts rename to googlemaps/googlemaps-tests.ts diff --git a/googlemaps/tsconfig.json b/googlemaps/tsconfig.json index 0382e30210..c858dfee0c 100644 --- a/googlemaps/tsconfig.json +++ b/googlemaps/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "google.maps-tests.ts" + "googlemaps-tests.ts" ] } diff --git a/grunt/gruntjs-tests.ts b/grunt/grunt-tests.ts similarity index 100% rename from grunt/gruntjs-tests.ts rename to grunt/grunt-tests.ts diff --git a/grunt/tsconfig.json b/grunt/tsconfig.json index f4b2b816d9..ca11c8f477 100644 --- a/grunt/tsconfig.json +++ b/grunt/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "gruntjs-tests.ts" + "grunt-tests.ts" ] } \ No newline at end of file diff --git a/halogen/halogen-clip-loader-tests.tsx b/halogen/test/clip-loader.tsx similarity index 100% rename from halogen/halogen-clip-loader-tests.tsx rename to halogen/test/clip-loader.tsx diff --git a/halogen/halogen-fade-loader-tests.tsx b/halogen/test/fade-loader.tsx similarity index 100% rename from halogen/halogen-fade-loader-tests.tsx rename to halogen/test/fade-loader.tsx diff --git a/halogen/halogen-pacman-loader-tests.tsx b/halogen/test/pacman-loader.tsx similarity index 100% rename from halogen/halogen-pacman-loader-tests.tsx rename to halogen/test/pacman-loader.tsx diff --git a/halogen/halogen-rotate-loader-tests.tsx b/halogen/test/rotate-loader.tsx similarity index 100% rename from halogen/halogen-rotate-loader-tests.tsx rename to halogen/test/rotate-loader.tsx diff --git a/halogen/tsconfig.json b/halogen/tsconfig.json index 5e6c8ab8f5..c2c0018e1b 100644 --- a/halogen/tsconfig.json +++ b/halogen/tsconfig.json @@ -16,9 +16,9 @@ }, "files": [ "index.d.ts", - "halogen-clip-loader-tests.tsx", - "halogen-fade-loader-tests.tsx", - "halogen-pacman-loader-tests.tsx", - "halogen-rotate-loader-tests.tsx" + "test/clip-loader.tsx", + "test/fade-loader.tsx", + "test/pacman-loader.tsx", + "test/rotate-loader.tsx" ] } \ No newline at end of file diff --git a/heatmap.js/heatmap-tests.ts b/heatmap.js/heatmap.js-tests.ts similarity index 100% rename from heatmap.js/heatmap-tests.ts rename to heatmap.js/heatmap.js-tests.ts diff --git a/heatmap.js/tsconfig.json b/heatmap.js/tsconfig.json index b90279cd8c..e1b42b5bd1 100644 --- a/heatmap.js/tsconfig.json +++ b/heatmap.js/tsconfig.json @@ -12,6 +12,6 @@ }, "files": [ "index.d.ts", - "heatmap-tests.ts" + "heatmap.js-tests.ts" ] } \ No newline at end of file diff --git a/highcharts/modules/boost-tests.ts b/highcharts/test/boost.ts similarity index 100% rename from highcharts/modules/boost-tests.ts rename to highcharts/test/boost.ts diff --git a/highcharts/modules/exporting-tests.ts b/highcharts/test/exporting.ts similarity index 100% rename from highcharts/modules/exporting-tests.ts rename to highcharts/test/exporting.ts diff --git a/highcharts/highstock-tests.ts b/highcharts/test/highstock.ts similarity index 100% rename from highcharts/highstock-tests.ts rename to highcharts/test/highstock.ts diff --git a/highcharts/highcharts-tests.ts b/highcharts/test/index.ts similarity index 100% rename from highcharts/highcharts-tests.ts rename to highcharts/test/index.ts diff --git a/highcharts/highcharts-more-tests.ts b/highcharts/test/more.ts similarity index 100% rename from highcharts/highcharts-more-tests.ts rename to highcharts/test/more.ts diff --git a/highcharts/modules/no-data-to-display-tests.ts b/highcharts/test/no-data-to-display.ts similarity index 100% rename from highcharts/modules/no-data-to-display-tests.ts rename to highcharts/test/no-data-to-display.ts diff --git a/highcharts/modules/offline-exporting-tests.ts b/highcharts/test/offline-exporting.ts similarity index 100% rename from highcharts/modules/offline-exporting-tests.ts rename to highcharts/test/offline-exporting.ts diff --git a/highcharts/tsconfig.json b/highcharts/tsconfig.json index 4744c83cb0..5d3e9ebe3f 100644 --- a/highcharts/tsconfig.json +++ b/highcharts/tsconfig.json @@ -15,18 +15,18 @@ }, "files": [ "index.d.ts", - "highcharts-tests.ts", "modules/boost.d.ts", - "modules/boost-tests.ts", "modules/exporting.d.ts", - "modules/exporting-tests.ts", "modules/no-data-to-display.d.ts", - "modules/no-data-to-display-tests.ts", "modules/offline-exporting.d.ts", - "modules/offline-exporting-tests.ts", "highcharts-more.d.ts", - "highcharts-more-tests.ts", "highstock.d.ts", - "highstock-tests.ts" + "test/boost.ts", + "test/exporting.ts", + "test/highstock.ts", + "test/index.ts", + "test/more.ts", + "test/no-data-to-display.ts", + "test/offline-exporting.ts" ] } \ No newline at end of file diff --git a/highlight.js/highlightjs-tests.ts b/highlight.js/highlight.js-tests.ts similarity index 100% rename from highlight.js/highlightjs-tests.ts rename to highlight.js/highlight.js-tests.ts diff --git a/highlight.js/tsconfig.json b/highlight.js/tsconfig.json index 86f2eade00..4b7c3117e1 100644 --- a/highlight.js/tsconfig.json +++ b/highlight.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "highlightjs-tests.ts" + "highlight.js-tests.ts" ] } \ No newline at end of file diff --git a/history.js/history-tests.ts b/history.js/history.js-tests.ts similarity index 100% rename from history.js/history-tests.ts rename to history.js/history.js-tests.ts diff --git a/history.js/tsconfig.json b/history.js/tsconfig.json index 3ef4710368..795d9a540f 100644 --- a/history.js/tsconfig.json +++ b/history.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "history-tests.ts" + "history.js-tests.ts" ] } \ No newline at end of file diff --git a/hubspot-pace/HubSpot-pace-tests.ts b/hubspot-pace/hubspot-pace-tests.ts similarity index 100% rename from hubspot-pace/HubSpot-pace-tests.ts rename to hubspot-pace/hubspot-pace-tests.ts diff --git a/hubspot-pace/tsconfig.json b/hubspot-pace/tsconfig.json index 67b152117c..1f7464eaa2 100644 --- a/hubspot-pace/tsconfig.json +++ b/hubspot-pace/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "HubSpot-pace-tests.ts" + "hubspot-pace-tests.ts" ] } \ No newline at end of file diff --git a/i18n/i18n-node-tests.ts b/i18n/i18n-tests.ts similarity index 100% rename from i18n/i18n-node-tests.ts rename to i18n/i18n-tests.ts diff --git a/i18n/tsconfig.json b/i18n/tsconfig.json index 57a6b8ffb0..55f6a32871 100644 --- a/i18n/tsconfig.json +++ b/i18n/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "i18n-node-tests.ts" + "i18n-tests.ts" ] } \ No newline at end of file diff --git a/interact.js/interact-tests.ts b/interact.js/interact.js-tests.ts similarity index 100% rename from interact.js/interact-tests.ts rename to interact.js/interact.js-tests.ts diff --git a/interact.js/tsconfig.json b/interact.js/tsconfig.json index 9426c9e0cc..8dbabcade7 100644 --- a/interact.js/tsconfig.json +++ b/interact.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "interact-tests.ts" + "interact.js-tests.ts" ] } \ No newline at end of file diff --git a/intercomjs/intercom-tests.ts b/intercomjs/intercomjs-tests.ts similarity index 100% rename from intercomjs/intercom-tests.ts rename to intercomjs/intercomjs-tests.ts diff --git a/intercomjs/tsconfig.json b/intercomjs/tsconfig.json index 6dfa66b6a1..79163abfc4 100644 --- a/intercomjs/tsconfig.json +++ b/intercomjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "intercom-tests.ts" + "intercomjs-tests.ts" ] } \ No newline at end of file diff --git a/ion.rangeslider/ion.rangeSlider-tests.ts b/ion.rangeslider/ion.rangeslider-tests.ts similarity index 100% rename from ion.rangeslider/ion.rangeSlider-tests.ts rename to ion.rangeslider/ion.rangeslider-tests.ts diff --git a/ion.rangeslider/tsconfig.json b/ion.rangeslider/tsconfig.json index 5912868fde..aede38d763 100644 --- a/ion.rangeslider/tsconfig.json +++ b/ion.rangeslider/tsconfig.json @@ -1,8 +1,4 @@ { - "files": [ - "index.d.ts", - "ion.rangeSlider-tests.ts" - ], "compilerOptions": { "module": "commonjs", "target": "es6", @@ -16,5 +12,9 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - } + }, + "files": [ + "index.d.ts", + "ion.rangeslider-tests.ts" + ] } \ No newline at end of file diff --git a/ion.rangeslider/v1/ion.rangeSlider-tests.ts b/ion.rangeslider/v1/ion.rangeslider-tests.ts similarity index 100% rename from ion.rangeslider/v1/ion.rangeSlider-tests.ts rename to ion.rangeslider/v1/ion.rangeslider-tests.ts diff --git a/ion.rangeslider/v1/tsconfig.json b/ion.rangeslider/v1/tsconfig.json index fa756621f2..7e3532f344 100644 --- a/ion.rangeslider/v1/tsconfig.json +++ b/ion.rangeslider/v1/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "ion.rangeSlider-tests.ts" + "ion.rangeslider-tests.ts" ] } \ No newline at end of file diff --git a/is/is_js-tests.ts b/is/is-tests.ts similarity index 100% rename from is/is_js-tests.ts rename to is/is-tests.ts diff --git a/is/tsconfig.json b/is/tsconfig.json index 2e97760d50..7afa0a2de1 100644 --- a/is/tsconfig.json +++ b/is/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "is_js-tests.ts" + "is-tests.ts" ] } \ No newline at end of file diff --git a/ix.js/ix-tests.ts b/ix.js/test/index.ts similarity index 100% rename from ix.js/ix-tests.ts rename to ix.js/test/index.ts diff --git a/ix.js/l2o-tests.ts b/ix.js/test/l2o.ts similarity index 99% rename from ix.js/l2o-tests.ts rename to ix.js/test/l2o.ts index 7b35b71a9e..063e85bfd6 100644 --- a/ix.js/l2o-tests.ts +++ b/ix.js/test/l2o.ts @@ -1,5 +1,3 @@ -/// - var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string var ec_nn = (a: number, b: number) => a === b; //equality comparer on number,number var c_nn = (a: number, b: number) => a - b; //comparer on number,number diff --git a/ix.js/tsconfig.json b/ix.js/tsconfig.json index 670dba223e..7f476db666 100644 --- a/ix.js/tsconfig.json +++ b/ix.js/tsconfig.json @@ -15,7 +15,7 @@ }, "files": [ "index.d.ts", - "ix-tests.ts", - "l2o-tests.ts" + "test/index.ts", + "test/l2o.ts" ] } \ No newline at end of file diff --git a/jee-jsf/jsf-tests.ts b/jee-jsf/jee-jsf-tests.ts similarity index 100% rename from jee-jsf/jsf-tests.ts rename to jee-jsf/jee-jsf-tests.ts diff --git a/jee-jsf/tsconfig.json b/jee-jsf/tsconfig.json index 0774f560ab..e7b8594556 100644 --- a/jee-jsf/tsconfig.json +++ b/jee-jsf/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jsf-tests.ts" + "jee-jsf-tests.ts" ] } \ No newline at end of file diff --git a/jodata/joData-tests.ts b/jodata/jodata-tests.ts similarity index 100% rename from jodata/joData-tests.ts rename to jodata/jodata-tests.ts diff --git a/jodata/tsconfig.json b/jodata/tsconfig.json index 3638d1b6f6..28bcc5bb36 100644 --- a/jodata/tsconfig.json +++ b/jodata/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "joData-tests.ts" + "jodata-tests.ts" ] } \ No newline at end of file diff --git a/jquery.blockui/jquery.blockUI-tests.ts b/jquery.blockui/jquery.blockui-tests.ts similarity index 100% rename from jquery.blockui/jquery.blockUI-tests.ts rename to jquery.blockui/jquery.blockui-tests.ts diff --git a/jquery.blockui/tsconfig.json b/jquery.blockui/tsconfig.json index 0d9c7d0a03..70b0f9a8aa 100644 --- a/jquery.blockui/tsconfig.json +++ b/jquery.blockui/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.blockUI-tests.ts" + "jquery.blockui-tests.ts" ] } \ No newline at end of file diff --git a/jquery.clientsidelogging/jquery.clientSideLogging-tests.ts b/jquery.clientsidelogging/jquery.clientsidelogging-tests.ts similarity index 100% rename from jquery.clientsidelogging/jquery.clientSideLogging-tests.ts rename to jquery.clientsidelogging/jquery.clientsidelogging-tests.ts diff --git a/jquery.clientsidelogging/tsconfig.json b/jquery.clientsidelogging/tsconfig.json index 483ce592e1..0bfce0b33c 100644 --- a/jquery.clientsidelogging/tsconfig.json +++ b/jquery.clientsidelogging/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.clientSideLogging-tests.ts" + "jquery.clientsidelogging-tests.ts" ] } \ No newline at end of file diff --git a/jquery.contextmenu/jquery.contextMenu-tests.ts b/jquery.contextmenu/jquery.contextmenu-tests.ts similarity index 100% rename from jquery.contextmenu/jquery.contextMenu-tests.ts rename to jquery.contextmenu/jquery.contextmenu-tests.ts diff --git a/jquery.contextmenu/tsconfig.json b/jquery.contextmenu/tsconfig.json index 25cae340ac..4e684a80b0 100644 --- a/jquery.contextmenu/tsconfig.json +++ b/jquery.contextmenu/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.contextMenu-tests.ts" + "jquery.contextmenu-tests.ts" ] } \ No newline at end of file diff --git a/jquery.customselect/jquery.customSelect-tests.ts b/jquery.customselect/jquery.customselect-tests.ts similarity index 100% rename from jquery.customselect/jquery.customSelect-tests.ts rename to jquery.customselect/jquery.customselect-tests.ts diff --git a/jquery.customselect/tsconfig.json b/jquery.customselect/tsconfig.json index 470079177d..a82625409d 100644 --- a/jquery.customselect/tsconfig.json +++ b/jquery.customselect/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.customSelect-tests.ts" + "jquery.customselect-tests.ts" ] } \ No newline at end of file diff --git a/jquery.datatables/jquery.dataTables-tests.ts b/jquery.datatables/jquery.datatables-tests.ts similarity index 100% rename from jquery.datatables/jquery.dataTables-tests.ts rename to jquery.datatables/jquery.datatables-tests.ts diff --git a/jquery.datatables/tsconfig.json b/jquery.datatables/tsconfig.json index 486b10d9ca..edb98f9b94 100644 --- a/jquery.datatables/tsconfig.json +++ b/jquery.datatables/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.dataTables-tests.ts" + "jquery.datatables-tests.ts" ] } \ No newline at end of file diff --git a/jquery.gridster/gridster-tests.ts b/jquery.gridster/jquery.gridster-tests.ts similarity index 100% rename from jquery.gridster/gridster-tests.ts rename to jquery.gridster/jquery.gridster-tests.ts diff --git a/jquery.gridster/tsconfig.json b/jquery.gridster/tsconfig.json index 775fbfbbd8..5bae952a15 100644 --- a/jquery.gridster/tsconfig.json +++ b/jquery.gridster/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "gridster-tests.ts" + "jquery.gridster-tests.ts" ] } \ No newline at end of file diff --git a/jquery.leanmodal/jquery.leanModal-tests.ts b/jquery.leanmodal/jquery.leanmodal-tests.ts similarity index 100% rename from jquery.leanmodal/jquery.leanModal-tests.ts rename to jquery.leanmodal/jquery.leanmodal-tests.ts diff --git a/jquery.leanmodal/tsconfig.json b/jquery.leanmodal/tsconfig.json index ce5f2553ec..a9a32b6d34 100644 --- a/jquery.leanmodal/tsconfig.json +++ b/jquery.leanmodal/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.leanModal-tests.ts" + "jquery.leanmodal-tests.ts" ] } \ No newline at end of file diff --git a/jquery.notifybar/jquery.notifyBar-tests.ts b/jquery.notifybar/jquery.notifybar-tests.ts similarity index 100% rename from jquery.notifybar/jquery.notifyBar-tests.ts rename to jquery.notifybar/jquery.notifybar-tests.ts diff --git a/jquery.notifybar/tsconfig.json b/jquery.notifybar/tsconfig.json index c338f7bf5e..587dec244d 100644 --- a/jquery.notifybar/tsconfig.json +++ b/jquery.notifybar/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.notifyBar-tests.ts" + "jquery.notifybar-tests.ts" ] } \ No newline at end of file diff --git a/jquery.pjax.falsandtru/jquery.pjax-tests.ts b/jquery.pjax.falsandtru/jquery.pjax.falsandtru-tests.ts similarity index 100% rename from jquery.pjax.falsandtru/jquery.pjax-tests.ts rename to jquery.pjax.falsandtru/jquery.pjax.falsandtru-tests.ts diff --git a/jquery.pjax.falsandtru/tsconfig.json b/jquery.pjax.falsandtru/tsconfig.json index eafe636c08..7c619d7288 100644 --- a/jquery.pjax.falsandtru/tsconfig.json +++ b/jquery.pjax.falsandtru/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.pjax-tests.ts" + "jquery.pjax.falsandtru-tests.ts" ] } \ No newline at end of file diff --git a/jquery.postmessage/jquery.postMessage-tests.ts b/jquery.postmessage/jquery.postmessage-tests.ts similarity index 100% rename from jquery.postmessage/jquery.postMessage-tests.ts rename to jquery.postmessage/jquery.postmessage-tests.ts diff --git a/jquery.postmessage/tsconfig.json b/jquery.postmessage/tsconfig.json index 3e70423c66..dd298d2aa0 100644 --- a/jquery.postmessage/tsconfig.json +++ b/jquery.postmessage/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.postMessage-tests.ts" + "jquery.postmessage-tests.ts" ] } \ No newline at end of file diff --git a/jquery.rowgrid/jquery.rowGrid-tests.ts b/jquery.rowgrid/jquery.rowgrid-tests.ts similarity index 100% rename from jquery.rowgrid/jquery.rowGrid-tests.ts rename to jquery.rowgrid/jquery.rowgrid-tests.ts diff --git a/jquery.rowgrid/tsconfig.json b/jquery.rowgrid/tsconfig.json index 55ebd698c1..314bc2a671 100644 --- a/jquery.rowgrid/tsconfig.json +++ b/jquery.rowgrid/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.rowGrid-tests.ts" + "jquery.rowgrid-tests.ts" ] } \ No newline at end of file diff --git a/jquery.scrollto/jquery.scrollTo-tests.ts b/jquery.scrollto/jquery.scrollto-tests.ts similarity index 100% rename from jquery.scrollto/jquery.scrollTo-tests.ts rename to jquery.scrollto/jquery.scrollto-tests.ts diff --git a/jquery.scrollto/tsconfig.json b/jquery.scrollto/tsconfig.json index 183ea5843e..94f73774ed 100644 --- a/jquery.scrollto/tsconfig.json +++ b/jquery.scrollto/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.scrollTo-tests.ts" + "jquery.scrollto-tests.ts" ] } \ No newline at end of file diff --git a/jquery.simplepagination/jquery.simplePagination-tests.ts b/jquery.simplepagination/jquery.simplepagination-tests.ts similarity index 100% rename from jquery.simplepagination/jquery.simplePagination-tests.ts rename to jquery.simplepagination/jquery.simplepagination-tests.ts diff --git a/jquery.simplepagination/tsconfig.json b/jquery.simplepagination/tsconfig.json index 890a63616d..02376bb00c 100644 --- a/jquery.simplepagination/tsconfig.json +++ b/jquery.simplepagination/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "jquery.simplePagination-tests.ts" + "jquery.simplepagination-tests.ts" ] } \ No newline at end of file diff --git a/js-fixtures/fixtures-tests.ts b/js-fixtures/js-fixtures-tests.ts similarity index 100% rename from js-fixtures/fixtures-tests.ts rename to js-fixtures/js-fixtures-tests.ts diff --git a/js-fixtures/tsconfig.json b/js-fixtures/tsconfig.json index 3f93c8ccdc..3c1a51cf41 100644 --- a/js-fixtures/tsconfig.json +++ b/js-fixtures/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "fixtures-tests.ts" + "js-fixtures-tests.ts" ] } \ No newline at end of file diff --git a/js-md5/md5-tests.ts b/js-md5/js-md5-tests.ts similarity index 100% rename from js-md5/md5-tests.ts rename to js-md5/js-md5-tests.ts diff --git a/js-md5/tsconfig.json b/js-md5/tsconfig.json index cbccd9ae2e..1b5b2dd795 100644 --- a/js-md5/tsconfig.json +++ b/js-md5/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "md5-tests.ts" + "js-md5-tests.ts" ] } \ No newline at end of file diff --git a/knockout/tests/knockout-tests.ts b/knockout/test/index.ts similarity index 100% rename from knockout/tests/knockout-tests.ts rename to knockout/test/index.ts diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts b/knockout/test/templatingBehaviors.ts similarity index 100% rename from knockout/tests/knockout-templatingBehaviors-tests.ts rename to knockout/test/templatingBehaviors.ts diff --git a/knockout/tsconfig.json b/knockout/tsconfig.json index 04246314bb..b09f482a4a 100644 --- a/knockout/tsconfig.json +++ b/knockout/tsconfig.json @@ -15,7 +15,7 @@ }, "files": [ "index.d.ts", - "tests/knockout-templatingBehaviors-tests.ts", - "tests/knockout-tests.ts" + "test/templatingBehaviors.ts", + "test/index.ts" ] } \ No newline at end of file diff --git a/konami.js/konami-tests.ts b/konami.js/konami.js-tests.ts similarity index 100% rename from konami.js/konami-tests.ts rename to konami.js/konami.js-tests.ts diff --git a/konami.js/tsconfig.json b/konami.js/tsconfig.json index 8b4f43df6e..6175df34c2 100644 --- a/konami.js/tsconfig.json +++ b/konami.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "konami-tests.ts" + "konami.js-tests.ts" ] } \ No newline at end of file diff --git a/localforage/localForage-tests.ts b/localforage/localforage-tests.ts similarity index 100% rename from localforage/localForage-tests.ts rename to localforage/localforage-tests.ts diff --git a/localforage/tsconfig.json b/localforage/tsconfig.json index ac31a49c3e..b2ebf8be91 100644 --- a/localforage/tsconfig.json +++ b/localforage/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "localForage-tests.ts" + "localforage-tests.ts" ] } \ No newline at end of file diff --git a/loopback-boot/loopback-boot-test.ts b/loopback-boot/loopback-boot-tests.ts similarity index 100% rename from loopback-boot/loopback-boot-test.ts rename to loopback-boot/loopback-boot-tests.ts diff --git a/loopback-boot/tsconfig.json b/loopback-boot/tsconfig.json index d784404acf..3bd43c78fd 100644 --- a/loopback-boot/tsconfig.json +++ b/loopback-boot/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "loopback-boot-test.ts" + "loopback-boot-tests.ts" ] } \ No newline at end of file diff --git a/loopback/loopback-test.ts b/loopback/loopback-tests.ts similarity index 100% rename from loopback/loopback-test.ts rename to loopback/loopback-tests.ts diff --git a/loopback/tsconfig.json b/loopback/tsconfig.json index 9454529143..4ca6819f7e 100644 --- a/loopback/tsconfig.json +++ b/loopback/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "loopback-test.ts" + "loopback-tests.ts" ] } \ No newline at end of file diff --git a/maker.js/makerjs-tests.ts b/maker.js/maker.js-tests.ts similarity index 100% rename from maker.js/makerjs-tests.ts rename to maker.js/maker.js-tests.ts diff --git a/maker.js/tsconfig.json b/maker.js/tsconfig.json index cd4be3d273..c3fe4a7a20 100644 --- a/maker.js/tsconfig.json +++ b/maker.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "makerjs-tests.ts" + "maker.js-tests.ts" ] } \ No newline at end of file diff --git a/mandrill-api/mandrill-tests.ts b/mandrill-api/mandrill-api-tests.ts similarity index 100% rename from mandrill-api/mandrill-tests.ts rename to mandrill-api/mandrill-api-tests.ts diff --git a/mandrill-api/tsconfig.json b/mandrill-api/tsconfig.json index 8f41f411aa..25bf307996 100644 --- a/mandrill-api/tsconfig.json +++ b/mandrill-api/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "mandrill-tests.ts" + "mandrill-api-tests.ts" ] } \ No newline at end of file diff --git a/mcustomscrollbar/mCustomScrollbar-tests.ts b/mcustomscrollbar/mcustomscrollbar-tests.ts similarity index 100% rename from mcustomscrollbar/mCustomScrollbar-tests.ts rename to mcustomscrollbar/mcustomscrollbar-tests.ts diff --git a/mcustomscrollbar/tsconfig.json b/mcustomscrollbar/tsconfig.json index 06d2e59f1a..56a75dc8b2 100644 --- a/mcustomscrollbar/tsconfig.json +++ b/mcustomscrollbar/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "mCustomScrollbar-tests.ts" + "mcustomscrollbar-tests.ts" ] } \ No newline at end of file diff --git a/memory-fs/memory-fs-tests.ts b/memory-fs/test/index.ts similarity index 89% rename from memory-fs/memory-fs-tests.ts rename to memory-fs/test/index.ts index 61302916be..07abb3e3fe 100644 --- a/memory-fs/memory-fs-tests.ts +++ b/memory-fs/test/index.ts @@ -1,5 +1,3 @@ -/// - import MemoryFileSystem = require('memory-fs'); const fs = new MemoryFileSystem({}); diff --git a/memory-fs/lib/join-tests.ts b/memory-fs/test/join.ts similarity index 100% rename from memory-fs/lib/join-tests.ts rename to memory-fs/test/join.ts diff --git a/memory-fs/lib/normalize-tests.ts b/memory-fs/test/normalize.ts similarity index 100% rename from memory-fs/lib/normalize-tests.ts rename to memory-fs/test/normalize.ts diff --git a/memory-fs/tsconfig.json b/memory-fs/tsconfig.json index 8236038c24..f1afc33095 100644 --- a/memory-fs/tsconfig.json +++ b/memory-fs/tsconfig.json @@ -15,10 +15,10 @@ }, "files": [ "index.d.ts", - "memory-fs-tests.ts", - "lib/join-tests.ts", "lib/join.d.ts", - "lib/normalize-tests.ts", - "lib/normalize.d.ts" + "lib/normalize.d.ts", + "test/index.ts", + "test/join.ts", + "test/normalize.ts" ] } \ No newline at end of file diff --git a/metric-suffix/metric-suffix-external-tests.ts b/metric-suffix/metric-suffix-external-tests.ts deleted file mode 100644 index 5b22aeeaa1..0000000000 --- a/metric-suffix/metric-suffix-external-tests.ts +++ /dev/null @@ -1,22 +0,0 @@ -import metric_suffix = require('metric-suffix'); - -metric_suffix(42) // 42 -metric_suffix(999) // 999 -metric_suffix(1000) // 1.0k - -metric_suffix(1234, 2) // 1.2k -metric_suffix(12345, 2) // 12k -metric_suffix(123456, 2) // 123k - -metric_suffix(1234, 3) // 1.23k -metric_suffix(12345, 3) // 12.3k -metric_suffix(123456, 3) // 123k - -metric_suffix(1234, 4) // 1.234k -metric_suffix(12345, 4) // 12.35k -metric_suffix(123456, 4) // 123.5k - -metric_suffix(986725) // 987k -metric_suffix(986725, 4) // 986.7k -metric_suffix(986725123) // 987M -metric_suffix(986725123, 5) // 986.73M \ No newline at end of file diff --git a/metric-suffix/tsconfig.json b/metric-suffix/tsconfig.json index 313286b950..c23b32a4e4 100644 --- a/metric-suffix/tsconfig.json +++ b/metric-suffix/tsconfig.json @@ -15,7 +15,6 @@ }, "files": [ "index.d.ts", - "metric-suffix-tests.ts", - "metric-suffix-external-tests.ts" + "metric-suffix-tests.ts" ] } \ No newline at end of file diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft-ajax-tests.ts similarity index 100% rename from microsoft-ajax/microsoft.ajax-tests.ts rename to microsoft-ajax/microsoft-ajax-tests.ts diff --git a/microsoft-ajax/tsconfig.json b/microsoft-ajax/tsconfig.json index 0066ff394e..3ed87d107e 100644 --- a/microsoft-ajax/tsconfig.json +++ b/microsoft-ajax/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "microsoft.ajax-tests.ts" + "microsoft-ajax-tests.ts" ] } \ No newline at end of file diff --git a/mousetrap/mousetrap-global-bind-tests.ts b/mousetrap/test/global-bind.ts similarity index 100% rename from mousetrap/mousetrap-global-bind-tests.ts rename to mousetrap/test/global-bind.ts diff --git a/mousetrap/mousetrap-tests.ts b/mousetrap/test/index.ts similarity index 100% rename from mousetrap/mousetrap-tests.ts rename to mousetrap/test/index.ts diff --git a/mousetrap/tsconfig.json b/mousetrap/tsconfig.json index 003c378176..d7def634a2 100644 --- a/mousetrap/tsconfig.json +++ b/mousetrap/tsconfig.json @@ -15,7 +15,7 @@ }, "files": [ "index.d.ts", - "mousetrap-tests.ts", - "mousetrap-global-bind-tests.ts" + "test/index.ts", + "test/global-bind.ts" ] } \ No newline at end of file diff --git a/ng-cordova/actionSheet-tests.ts b/ng-cordova/test/actionSheet.ts similarity index 100% rename from ng-cordova/actionSheet-tests.ts rename to ng-cordova/test/actionSheet.ts diff --git a/ng-cordova/app-version-tests.ts b/ng-cordova/test/app-version.ts similarity index 100% rename from ng-cordova/app-version-tests.ts rename to ng-cordova/test/app-version.ts diff --git a/ng-cordova/appAvailability-tests.ts b/ng-cordova/test/appAvailability.ts similarity index 100% rename from ng-cordova/appAvailability-tests.ts rename to ng-cordova/test/appAvailability.ts diff --git a/ng-cordova/badge-tests.ts b/ng-cordova/test/badge.ts similarity index 100% rename from ng-cordova/badge-tests.ts rename to ng-cordova/test/badge.ts diff --git a/ng-cordova/camera-tests.ts b/ng-cordova/test/camera.ts similarity index 100% rename from ng-cordova/camera-tests.ts rename to ng-cordova/test/camera.ts diff --git a/ng-cordova/datepicker-tests.ts b/ng-cordova/test/datepicker.ts similarity index 100% rename from ng-cordova/datepicker-tests.ts rename to ng-cordova/test/datepicker.ts diff --git a/ng-cordova/device-tests.ts b/ng-cordova/test/device.ts similarity index 100% rename from ng-cordova/device-tests.ts rename to ng-cordova/test/device.ts diff --git a/ng-cordova/deviceMotion-tests.ts b/ng-cordova/test/deviceMotion.ts similarity index 100% rename from ng-cordova/deviceMotion-tests.ts rename to ng-cordova/test/deviceMotion.ts diff --git a/ng-cordova/deviceOrientation-tests.ts b/ng-cordova/test/deviceOrientation.ts similarity index 100% rename from ng-cordova/deviceOrientation-tests.ts rename to ng-cordova/test/deviceOrientation.ts diff --git a/ng-cordova/dialogs-tests.ts b/ng-cordova/test/dialogs.ts similarity index 100% rename from ng-cordova/dialogs-tests.ts rename to ng-cordova/test/dialogs.ts diff --git a/ng-cordova/emailComposer-tests.ts b/ng-cordova/test/emailComposer.ts similarity index 100% rename from ng-cordova/emailComposer-tests.ts rename to ng-cordova/test/emailComposer.ts diff --git a/ng-cordova/file-tests.ts b/ng-cordova/test/file.ts similarity index 100% rename from ng-cordova/file-tests.ts rename to ng-cordova/test/file.ts diff --git a/ng-cordova/fileTransfer-tests.ts b/ng-cordova/test/fileTransfer.ts similarity index 100% rename from ng-cordova/fileTransfer-tests.ts rename to ng-cordova/test/fileTransfer.ts diff --git a/ng-cordova/geolocation-tests.ts b/ng-cordova/test/geolocation.ts similarity index 100% rename from ng-cordova/geolocation-tests.ts rename to ng-cordova/test/geolocation.ts diff --git a/ng-cordova/network-tests.ts b/ng-cordova/test/network.ts similarity index 100% rename from ng-cordova/network-tests.ts rename to ng-cordova/test/network.ts diff --git a/ng-cordova/toast-tests.ts b/ng-cordova/test/toast.ts similarity index 100% rename from ng-cordova/toast-tests.ts rename to ng-cordova/test/toast.ts diff --git a/ng-cordova/tsconfig.json b/ng-cordova/tsconfig.json index 68bdca092a..68f86a18f9 100644 --- a/ng-cordova/tsconfig.json +++ b/ng-cordova/tsconfig.json @@ -16,21 +16,21 @@ }, "files": [ "index.d.ts", - "actionSheet-tests.ts", - "app-version-tests.ts", - "appAvailability-tests.ts", - "badge-tests.ts", - "camera-tests.ts", - "datepicker-tests.ts", - "device-tests.ts", - "deviceMotion-tests.ts", - "deviceOrientation-tests.ts", - "dialogs-tests.ts", - "emailComposer-tests.ts", - "file-tests.ts", - "fileTransfer-tests.ts", - "geolocation-tests.ts", - "network-tests.ts", - "toast-tests.ts" + "test/actionSheet.ts", + "test/app-version.ts", + "test/appAvailability.ts", + "test/badge.ts", + "test/camera.ts", + "test/datepicker.ts", + "test/device.ts", + "test/deviceMotion.ts", + "test/deviceOrientation.ts", + "test/dialogs.ts", + "test/emailComposer.ts", + "test/file.ts", + "test/fileTransfer.ts", + "test/geolocation.ts", + "test/network.ts", + "test/toast.ts" ] } \ No newline at end of file diff --git a/ngtoaster/angularjs-toaster-tests.ts b/ngtoaster/ngtoaster-tests.ts similarity index 100% rename from ngtoaster/angularjs-toaster-tests.ts rename to ngtoaster/ngtoaster-tests.ts diff --git a/ngtoaster/tsconfig.json b/ngtoaster/tsconfig.json index eaf3b5027d..67970d092e 100644 --- a/ngtoaster/tsconfig.json +++ b/ngtoaster/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "angularjs-toaster-tests.ts" + "ngtoaster-tests.ts" ] } \ No newline at end of file diff --git a/novnc/noVNC-tests.ts b/novnc/novnc-tests.ts similarity index 100% rename from novnc/noVNC-tests.ts rename to novnc/novnc-tests.ts diff --git a/novnc/tsconfig.json b/novnc/tsconfig.json index bfb76135a7..3c88833118 100644 --- a/novnc/tsconfig.json +++ b/novnc/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "noVNC-tests.ts" + "novnc-tests.ts" ] } \ No newline at end of file diff --git a/numeral/numeraljs-tests.ts b/numeral/numeral-tests.ts similarity index 100% rename from numeral/numeraljs-tests.ts rename to numeral/numeral-tests.ts diff --git a/numeral/tsconfig.json b/numeral/tsconfig.json index 61386fac51..5d51b7d6cc 100644 --- a/numeral/tsconfig.json +++ b/numeral/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "numeraljs-tests.ts" + "numeral-tests.ts" ] } \ No newline at end of file diff --git a/nw.gui/node-webkit-tests.ts b/nw.gui/nw.gui-tests.ts similarity index 100% rename from nw.gui/node-webkit-tests.ts rename to nw.gui/nw.gui-tests.ts diff --git a/nw.gui/tsconfig.json b/nw.gui/tsconfig.json index 0a184e9e8b..d59063a0b2 100644 --- a/nw.gui/tsconfig.json +++ b/nw.gui/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "node-webkit-tests.ts" + "nw.gui-tests.ts" ] } \ No newline at end of file diff --git a/openui5/ui5-tests.ts b/openui5/openui5-tests.ts similarity index 100% rename from openui5/ui5-tests.ts rename to openui5/openui5-tests.ts diff --git a/openui5/tsconfig.json b/openui5/tsconfig.json index 428f84704f..97d54dd860 100644 --- a/openui5/tsconfig.json +++ b/openui5/tsconfig.json @@ -18,6 +18,6 @@ "jquery.sap.d.ts", "sap.m.d.ts", "sap.ui.d.ts", - "ui5-tests.ts" + "openui5-tests.ts" ] } \ No newline at end of file diff --git a/paralleljs/parallel-tests.ts b/paralleljs/paralleljs-tests.ts similarity index 100% rename from paralleljs/parallel-tests.ts rename to paralleljs/paralleljs-tests.ts diff --git a/paralleljs/tsconfig.json b/paralleljs/tsconfig.json index debc292389..f6ae0047ac 100644 --- a/paralleljs/tsconfig.json +++ b/paralleljs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "parallel-tests.ts" + "paralleljs-tests.ts" ] } \ No newline at end of file diff --git a/paypal-cordova-plugin/PayPal-Cordova-Plugin-tests.ts b/paypal-cordova-plugin/paypal-cordova-plugin-tests.ts similarity index 100% rename from paypal-cordova-plugin/PayPal-Cordova-Plugin-tests.ts rename to paypal-cordova-plugin/paypal-cordova-plugin-tests.ts diff --git a/paypal-cordova-plugin/tsconfig.json b/paypal-cordova-plugin/tsconfig.json index 4cd4acf310..c32cd43755 100644 --- a/paypal-cordova-plugin/tsconfig.json +++ b/paypal-cordova-plugin/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "PayPal-Cordova-Plugin-tests.ts" + "paypal-cordova-plugin-tests.ts" ] } \ No newline at end of file diff --git a/pleasejs/please-tests.ts b/pleasejs/pleasejs-tests.ts similarity index 100% rename from pleasejs/please-tests.ts rename to pleasejs/pleasejs-tests.ts diff --git a/pleasejs/tsconfig.json b/pleasejs/tsconfig.json index 58ebc9d426..0a595973af 100644 --- a/pleasejs/tsconfig.json +++ b/pleasejs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "please-tests.ts" + "pleasejs-tests.ts" ] } \ No newline at end of file diff --git a/popper.js/popper-tests.ts b/popper.js/popper.js-tests.ts similarity index 100% rename from popper.js/popper-tests.ts rename to popper.js/popper.js-tests.ts diff --git a/popper.js/tsconfig.json b/popper.js/tsconfig.json index a9af98d819..599036ff15 100644 --- a/popper.js/tsconfig.json +++ b/popper.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "popper-tests.ts" + "popper.js-tests.ts" ] } \ No newline at end of file diff --git a/pouchdb/pouch-tests.ts b/pouchdb/pouchdb-tests.ts similarity index 100% rename from pouchdb/pouch-tests.ts rename to pouchdb/pouchdb-tests.ts diff --git a/pouchdb/tsconfig.json b/pouchdb/tsconfig.json index 173d43fcd5..09bc6a7440 100644 --- a/pouchdb/tsconfig.json +++ b/pouchdb/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "pouch-tests.ts" + "pouchdb-tests.ts" ] } \ No newline at end of file diff --git a/prismjs/prism-tests.ts b/prismjs/prismjs-tests.ts similarity index 100% rename from prismjs/prism-tests.ts rename to prismjs/prismjs-tests.ts diff --git a/prismjs/tsconfig.json b/prismjs/tsconfig.json index 9acf5a037c..972a24f9fe 100644 --- a/prismjs/tsconfig.json +++ b/prismjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "prism-tests.ts" + "prismjs-tests.ts" ] } \ No newline at end of file diff --git a/progressjs/progress-tests.ts b/progressjs/progressjs-tests.ts similarity index 100% rename from progressjs/progress-tests.ts rename to progressjs/progressjs-tests.ts diff --git a/progressjs/tsconfig.json b/progressjs/tsconfig.json index 0961490fd3..c04d0442c1 100644 --- a/progressjs/tsconfig.json +++ b/progressjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "progress-tests.ts" + "progressjs-tests.ts" ] } \ No newline at end of file diff --git a/pubsub-js/PubSub-tests.ts b/pubsub-js/pubsub-js-tests.ts similarity index 100% rename from pubsub-js/PubSub-tests.ts rename to pubsub-js/pubsub-js-tests.ts diff --git a/pubsub-js/tsconfig.json b/pubsub-js/tsconfig.json index d2fa213f84..eda08b963b 100644 --- a/pubsub-js/tsconfig.json +++ b/pubsub-js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "PubSub-tests.ts" + "pubsub-js-tests.ts" ] } \ No newline at end of file diff --git a/random-js/random-js-ambient-tests.ts b/random-js/random-js-tests.ts similarity index 100% rename from random-js/random-js-ambient-tests.ts rename to random-js/random-js-tests.ts diff --git a/random-js/tsconfig.json b/random-js/tsconfig.json index 04313eb3db..eb2e70e45c 100644 --- a/random-js/tsconfig.json +++ b/random-js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "random-js-ambient-tests.ts" + "random-js-tests.ts" ] } \ No newline at end of file diff --git a/raven-js/ravenjs-tests.ts b/raven-js/raven-js-tests.ts similarity index 100% rename from raven-js/ravenjs-tests.ts rename to raven-js/raven-js-tests.ts diff --git a/raven-js/tsconfig.json b/raven-js/tsconfig.json index 821b76f72e..78f622e685 100644 --- a/raven-js/tsconfig.json +++ b/raven-js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "ravenjs-tests.ts" + "raven-js-tests.ts" ] } \ No newline at end of file diff --git a/react-native/react-native-animated-tests.tsx b/react-native/test/animated.tsx similarity index 100% rename from react-native/react-native-animated-tests.tsx rename to react-native/test/animated.tsx diff --git a/react-native/react-native-tests.tsx b/react-native/test/index.tsx similarity index 100% rename from react-native/react-native-tests.tsx rename to react-native/test/index.tsx diff --git a/react-native/tsconfig.json b/react-native/tsconfig.json index 1a6f765478..930ac3d811 100644 --- a/react-native/tsconfig.json +++ b/react-native/tsconfig.json @@ -16,7 +16,7 @@ }, "files": [ "index.d.ts", - "react-native-tests.tsx", - "react-native-animated-tests.tsx" + "test/index.tsx", + "test/animated.tsx" ] } \ No newline at end of file diff --git a/react/react-tests.ts b/react/test/index.ts similarity index 100% rename from react/react-tests.ts rename to react/test/index.ts diff --git a/react/react-tsx-tests.tsx b/react/test/tsx.tsx similarity index 100% rename from react/react-tsx-tests.tsx rename to react/test/tsx.tsx diff --git a/react/tsconfig.json b/react/tsconfig.json index bf6595e99f..f26f721c8c 100644 --- a/react/tsconfig.json +++ b/react/tsconfig.json @@ -1,8 +1,8 @@ { "files": [ "index.d.ts", - "react-tests.ts", - "react-tsx-tests.tsx" + "test/index.ts", + "test/tsx.tsx" ], "compilerOptions": { "module": "commonjs", diff --git a/requirejs-domready/domready-tests.ts b/requirejs-domready/requirejs-domready-tests.ts similarity index 100% rename from requirejs-domready/domready-tests.ts rename to requirejs-domready/requirejs-domready-tests.ts diff --git a/requirejs-domready/tsconfig.json b/requirejs-domready/tsconfig.json index 4a6ca208f5..5d6731cbd1 100644 --- a/requirejs-domready/tsconfig.json +++ b/requirejs-domready/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "domready-tests.ts" + "requirejs-domready-tests.ts" ] } \ No newline at end of file diff --git a/requirejs/require-tests.ts b/requirejs/requirejs-tests.ts similarity index 100% rename from requirejs/require-tests.ts rename to requirejs/requirejs-tests.ts diff --git a/requirejs/tsconfig.json b/requirejs/tsconfig.json index 7fc6ef8516..6d8c38c0c9 100644 --- a/requirejs/tsconfig.json +++ b/requirejs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "require-tests.ts" + "requirejs-tests.ts" ] } \ No newline at end of file diff --git a/rx-angular/rx.angular-tests.ts b/rx-angular/rx-angular-tests.ts similarity index 100% rename from rx-angular/rx.angular-tests.ts rename to rx-angular/rx-angular-tests.ts diff --git a/rx-angular/tsconfig.json b/rx-angular/tsconfig.json index 2412cb2874..084109bfb3 100644 --- a/rx-angular/tsconfig.json +++ b/rx-angular/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "rx.angular-tests.ts" + "rx-angular-tests.ts" ] } \ No newline at end of file diff --git a/sammy/sammyjs-tests.ts b/sammy/sammy-tests.ts similarity index 100% rename from sammy/sammyjs-tests.ts rename to sammy/sammy-tests.ts diff --git a/sammy/tsconfig.json b/sammy/tsconfig.json index 34996aa4cc..15b4050f9e 100644 --- a/sammy/tsconfig.json +++ b/sammy/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "sammyjs-tests.ts" + "sammy-tests.ts" ] } \ No newline at end of file diff --git a/selenium-webdriver/chrome-tests.ts b/selenium-webdriver/test/chrome.ts similarity index 100% rename from selenium-webdriver/chrome-tests.ts rename to selenium-webdriver/test/chrome.ts diff --git a/selenium-webdriver/firefox-tests.ts b/selenium-webdriver/test/firefox.ts similarity index 100% rename from selenium-webdriver/firefox-tests.ts rename to selenium-webdriver/test/firefox.ts diff --git a/selenium-webdriver/index-tests.ts b/selenium-webdriver/test/index.ts similarity index 100% rename from selenium-webdriver/index-tests.ts rename to selenium-webdriver/test/index.ts diff --git a/selenium-webdriver/tsconfig.json b/selenium-webdriver/tsconfig.json index 89e3b4fd9f..3925dd11ee 100644 --- a/selenium-webdriver/tsconfig.json +++ b/selenium-webdriver/tsconfig.json @@ -15,18 +15,18 @@ }, "files": [ "index.d.ts", - "index-tests.ts", "chrome.d.ts", - "chrome-tests.ts", "edge.d.ts", "executors.d.ts", "firefox.d.ts", - "firefox-tests.ts", "http.d.ts", "ie.d.ts", "opera.d.ts", "remote.d.ts", "safari.d.ts", - "testing.d.ts" + "testing.d.ts", + "test/index.ts", + "test/chrome.ts", + "test/firefox.ts" ] } diff --git a/sencha_touch/SenchaTouch-tests.ts b/sencha_touch/sencha_touch-tests.ts similarity index 100% rename from sencha_touch/SenchaTouch-tests.ts rename to sencha_touch/sencha_touch-tests.ts diff --git a/sencha_touch/tsconfig.json b/sencha_touch/tsconfig.json index 3ed5d8263d..a8a395e97a 100644 --- a/sencha_touch/tsconfig.json +++ b/sencha_touch/tsconfig.json @@ -1,7 +1,7 @@ { "files": [ "index.d.ts", - "SenchaTouch-tests.ts" + "sencha_touch-tests.ts" ], "compilerOptions": { "module": "commonjs", diff --git a/sharepoint/SharePoint-tests.ts b/sharepoint/sharepoint-tests.ts similarity index 100% rename from sharepoint/SharePoint-tests.ts rename to sharepoint/sharepoint-tests.ts diff --git a/sharepoint/tsconfig.json b/sharepoint/tsconfig.json index 76d3dc13a0..e631b4c53e 100644 --- a/sharepoint/tsconfig.json +++ b/sharepoint/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "SharePoint-tests.ts" + "sharepoint-tests.ts" ] } \ No newline at end of file diff --git a/signals/js-signals-tests.ts b/signals/signals-tests.ts similarity index 100% rename from signals/js-signals-tests.ts rename to signals/signals-tests.ts diff --git a/signals/tsconfig.json b/signals/tsconfig.json index 13bc50af80..94b8397fd2 100644 --- a/signals/tsconfig.json +++ b/signals/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "js-signals-tests.ts" + "signals-tests.ts" ] } \ No newline at end of file diff --git a/slickgrid/slickgrid-tests.ts b/slickgrid/test/index.ts similarity index 100% rename from slickgrid/slickgrid-tests.ts rename to slickgrid/test/index.ts diff --git a/slickgrid/slick.autotooltips-tests.ts b/slickgrid/test/slick.autotooltips.ts similarity index 100% rename from slickgrid/slick.autotooltips-tests.ts rename to slickgrid/test/slick.autotooltips.ts diff --git a/slickgrid/slick.checkboxselectcolumn-tests.ts b/slickgrid/test/slick.checkboxselectcolumn.ts similarity index 89% rename from slickgrid/slick.checkboxselectcolumn-tests.ts rename to slickgrid/test/slick.checkboxselectcolumn.ts index 593496537f..c0f08bb2af 100644 --- a/slickgrid/slick.checkboxselectcolumn-tests.ts +++ b/slickgrid/test/slick.checkboxselectcolumn.ts @@ -1,7 +1,3 @@ -/// -/// -/// - /** * Extracted from https://github.com/mleibman/SlickGrid/blob/master/examples/example-checkbox-row-select.html */ diff --git a/slickgrid/tsconfig.json b/slickgrid/tsconfig.json index ff7ab0e597..081819d112 100644 --- a/slickgrid/tsconfig.json +++ b/slickgrid/tsconfig.json @@ -15,13 +15,13 @@ }, "files": [ "index.d.ts", - "slickgrid-tests.ts", "slick.autotooltips.d.ts", - "slick.autotooltips-tests.ts", "slick.checkboxselectcolumn.d.ts", - "slick.checkboxselectcolumn-tests.ts", "slick.columnpicker.d.ts", "slick.headerbuttons.d.ts", - "slick.rowselectionmodel.d.ts" + "slick.rowselectionmodel.d.ts", + "test/index.ts", + "test/slick.autotooltips.ts", + "test/slick.checkboxselectcolumn.ts" ] } \ No newline at end of file diff --git a/sprintf-js/sprintf-tests.ts b/sprintf-js/sprintf-js-tests.ts similarity index 100% rename from sprintf-js/sprintf-tests.ts rename to sprintf-js/sprintf-js-tests.ts diff --git a/sprintf-js/tsconfig.json b/sprintf-js/tsconfig.json index 51135a42a2..f3209176f2 100644 --- a/sprintf-js/tsconfig.json +++ b/sprintf-js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "sprintf-tests.ts" + "sprintf-js-tests.ts" ] } \ No newline at end of file diff --git a/svg.js/svgjs-tests.ts b/svg.js/svg.js-tests.ts similarity index 100% rename from svg.js/svgjs-tests.ts rename to svg.js/svg.js-tests.ts diff --git a/svg.js/tsconfig.json b/svg.js/tsconfig.json index 720007c430..fe7ec62362 100644 --- a/svg.js/tsconfig.json +++ b/svg.js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "svgjs-tests.ts" + "svg.js-tests.ts" ] } \ No newline at end of file diff --git a/touch-events/touch-event-tests.ts b/touch-events/touch-events-tests.ts similarity index 100% rename from touch-events/touch-event-tests.ts rename to touch-events/touch-events-tests.ts diff --git a/touch-events/tsconfig.json b/touch-events/tsconfig.json index 9193ccfb7e..2d6a066fdf 100644 --- a/touch-events/tsconfig.json +++ b/touch-events/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "touch-event-tests.ts" + "touch-events-tests.ts" ] } \ No newline at end of file diff --git a/uuidjs/tsconfig.json b/uuidjs/tsconfig.json index 6c43a5006f..5de0c29bb1 100644 --- a/uuidjs/tsconfig.json +++ b/uuidjs/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "UUID-tests.ts" + "uuidjs-tests.ts" ] } \ No newline at end of file diff --git a/uuidjs/UUID-tests.ts b/uuidjs/uuidjs-tests.ts similarity index 100% rename from uuidjs/UUID-tests.ts rename to uuidjs/uuidjs-tests.ts diff --git a/vex-js/tsconfig.json b/vex-js/tsconfig.json index fcaf4b9f3b..3428a5b5ed 100644 --- a/vex-js/tsconfig.json +++ b/vex-js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "vex-tests.ts" + "vex-js-tests.ts" ] } \ No newline at end of file diff --git a/vex-js/vex-tests.ts b/vex-js/vex-js-tests.ts similarity index 100% rename from vex-js/vex-tests.ts rename to vex-js/vex-js-tests.ts diff --git a/vivus/tsconfig.json b/vivus/tsconfig.json index 3d8c032420..1afb932f4c 100644 --- a/vivus/tsconfig.json +++ b/vivus/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "index-tests.ts" + "vivus-tests.ts" ] } \ No newline at end of file diff --git a/vivus/index-tests.ts b/vivus/vivus-tests.ts similarity index 100% rename from vivus/index-tests.ts rename to vivus/vivus-tests.ts diff --git a/webrtc/MediaStream-tests.ts b/webrtc/test/MediaStream.ts similarity index 97% rename from webrtc/MediaStream-tests.ts rename to webrtc/test/MediaStream.ts index e45154bd44..d8c87afdec 100644 --- a/webrtc/MediaStream-tests.ts +++ b/webrtc/test/MediaStream.ts @@ -1,4 +1,3 @@ -/// var mediaStreamConstraints: MediaStreamConstraints = { audio: true, video: true }; var mediaTrackConstraintSet: MediaTrackConstraintSet = {}; diff --git a/webrtc/RTCPeerConnection-tests.ts b/webrtc/test/RTCPeerConnection.ts similarity index 97% rename from webrtc/RTCPeerConnection-tests.ts rename to webrtc/test/RTCPeerConnection.ts index dcb6bf8657..1272327ac2 100644 --- a/webrtc/RTCPeerConnection-tests.ts +++ b/webrtc/test/RTCPeerConnection.ts @@ -1,6 +1,3 @@ -/// -/// - let defaultIceServers: RTCIceServer[] = RTCPeerConnection.defaultIceServers; if (defaultIceServers.length > 0) { let urls = defaultIceServers[0].urls; diff --git a/webrtc/tsconfig.json b/webrtc/tsconfig.json index 00a9884815..fdda3c7ab0 100644 --- a/webrtc/tsconfig.json +++ b/webrtc/tsconfig.json @@ -15,7 +15,7 @@ }, "files": [ "index.d.ts", - "MediaStream-tests.ts", - "RTCPeerConnection-tests.ts" + "test/MediaStream.ts", + "test/RTCPeerConnection.ts" ] } \ No newline at end of file diff --git a/x2js/tsconfig.json b/x2js/tsconfig.json index 860553af5b..bb82a3b504 100644 --- a/x2js/tsconfig.json +++ b/x2js/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "xml2json-tests.ts" + "x2js-tests.ts" ] } \ No newline at end of file diff --git a/x2js/xml2json-tests.ts b/x2js/x2js-tests.ts similarity index 100% rename from x2js/xml2json-tests.ts rename to x2js/x2js-tests.ts From 9aaced75157b7c33649ad4070211915f986c66e9 Mon Sep 17 00:00:00 2001 From: Thomas Townsend Date: Tue, 10 Jan 2017 14:34:19 +0000 Subject: [PATCH 053/422] Remove MapStore for flux v3.0 (#13819) * Remove MapStore for flux v3.0 * Add version to header * Add new api changes * Remove unneeded dependency on immutable * Remove package.json file for flux --- flux/index.d.ts | 3 +-- flux/package.json | 5 ----- flux/utils/index.d.ts | 45 +++++++++++++++---------------------------- 3 files changed, 17 insertions(+), 36 deletions(-) delete mode 100644 flux/package.json diff --git a/flux/index.d.ts b/flux/index.d.ts index 252d1c7920..4b9c261040 100644 --- a/flux/index.d.ts +++ b/flux/index.d.ts @@ -1,11 +1,10 @@ -// Type definitions for Flux +// Type definitions for Flux 3.0 // Project: http://facebook.github.io/flux/ // Definitions by: Steve Baker , Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// /// -/// export = Flux; diff --git a/flux/package.json b/flux/package.json deleted file mode 100644 index aa7d5773ad..0000000000 --- a/flux/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "immutable": "^3.8.1" - } -} diff --git a/flux/utils/index.d.ts b/flux/utils/index.d.ts index d69a6f1e55..b223945181 100644 --- a/flux/utils/index.d.ts +++ b/flux/utils/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Flux Utils +// Type definitions for Flux Utils 3.0 // Project: http://facebook.github.io/flux/ // Definitions by: Steve Baker , Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,12 +6,10 @@ /// /// /// -/// import * as React from 'react'; import * as Flux from 'flux'; import * as fbEmitter from 'fbemitter'; -import * as immutable from 'immutable'; export = FluxUtils; @@ -34,6 +32,12 @@ declare namespace FluxUtils { * @type {boolean} */ withProps?: boolean; + /** + * Default value: false + * + * @type {boolean} + */ + withContext?: boolean; } export class Container { @@ -44,35 +48,18 @@ declare namespace FluxUtils { * The provided base class must have static methods getStores() and calculateState(). */ static create(base: React.ComponentClass, options?: RealOptions): React.ComponentClass; - } - /** - * This class extends ReduceStore and defines the state as an immutable map. - */ - export class MapStore extends ReduceStore, TPayload> { - /** - * Access the value at the given key. - * Throws an error if the key does not exist in the cache. - */ - at(key: K): V; + /** - * Check if the cache has a particular key - */ - has(key: K): boolean; - - /** - * Get the value of a particular key. - * Returns undefined if the key does not exist in the cache. - */ - get(key: K): V; - - /** - * Gets an array of keys and puts the values in a map if they exist, - * it allows providing a previous result to update instead of generating a new map. - * Providing a previous result allows the possibility of keeping the same reference if the keys did not change. - */ - getAll(keys: immutable.Iterable.Indexed, prev?: immutable.Map): immutable.Map; + * This is a way to connect stores to a functional stateless view + */ + static createFunctional( + viewFn: (props: State) => React.ReactElement, + getStores: (props?: Props, context?: any) => FluxUtils.Store[], + calculateState: (prevState?: State, props?: Props, context?: any) => State, + options?: RealOptions + ): React.ComponentClass; } export class ReduceStore extends Store { From b29f39d324edbb9e714d28423dc67da5e2fd62ee Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 10 Jan 2017 07:49:04 -0800 Subject: [PATCH 054/422] Fix path mappings (#13902) * An old version must have a path mapping to itself * react-daterange-picker doesn't need a dependency on "moment", since that isn't used directly, only through "moment-range" (which does have the dependency). --- ember/v1/tsconfig.json | 2 +- hammerjs/v1/tsconfig.json | 2 +- ion.rangeslider/v1/tsconfig.json | 2 +- react-daterange-picker/package.json | 5 ----- react-daterange-picker/tsconfig.json | 6 ------ 5 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 react-daterange-picker/package.json diff --git a/ember/v1/tsconfig.json b/ember/v1/tsconfig.json index 04fdc535c5..2354a6e4db 100644 --- a/ember/v1/tsconfig.json +++ b/ember/v1/tsconfig.json @@ -11,7 +11,7 @@ ], "types": [], "paths": { - "ember": ["ember/v0"] + "ember": ["ember/v1"] }, "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/hammerjs/v1/tsconfig.json b/hammerjs/v1/tsconfig.json index deecbdb055..63de88e4e7 100644 --- a/hammerjs/v1/tsconfig.json +++ b/hammerjs/v1/tsconfig.json @@ -11,7 +11,7 @@ ], "types": [], "paths": { - "hammerjs": ["hammerjs/v0"] + "hammerjs": ["hammerjs/v1"] }, "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/ion.rangeslider/v1/tsconfig.json b/ion.rangeslider/v1/tsconfig.json index 7e3532f344..2460539a3f 100644 --- a/ion.rangeslider/v1/tsconfig.json +++ b/ion.rangeslider/v1/tsconfig.json @@ -11,7 +11,7 @@ ], "types": [], "paths": { - "ion.rangeslider": ["ion.rangeslider/v0"] + "ion.rangeslider": ["ion.rangeslider/v1"] }, "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/react-daterange-picker/package.json b/react-daterange-picker/package.json deleted file mode 100644 index 4c6d24a445..0000000000 --- a/react-daterange-picker/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "moment": ">=2.14.0" - } -} \ No newline at end of file diff --git a/react-daterange-picker/tsconfig.json b/react-daterange-picker/tsconfig.json index 5d13fe1e1c..ef3f5b7c35 100644 --- a/react-daterange-picker/tsconfig.json +++ b/react-daterange-picker/tsconfig.json @@ -9,12 +9,6 @@ "typeRoots": [ "../" ], - "paths": { - "*": [ - "*", - "react-daterange-picker/node_modules/*" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, From d22bd22f74ca1d22584b097836bd717555273e76 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 10 Jan 2017 08:13:39 -0800 Subject: [PATCH 055/422] Make version parse-able. (#13904) --- hypertext-application-language/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypertext-application-language/index.d.ts b/hypertext-application-language/index.d.ts index 7834a81faf..111356c1ee 100644 --- a/hypertext-application-language/index.d.ts +++ b/hypertext-application-language/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Hypertext Application Language Draft 6 +// Type definitions for Hypertext Application Language Draft 6.0 // Project: https://tools.ietf.org/html/draft-kelly-json-hal-06 // Definitions by: Maks3w // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 12302a50e5b2163a8f187d49b1b696f5f65009ff Mon Sep 17 00:00:00 2001 From: Jough Dempsey Date: Tue, 10 Jan 2017 10:20:48 -0600 Subject: [PATCH 056/422] Change $inject type from string[] to ReadonlyArray It may be prudent to make injected dependencies immutable since we can't Object.freeze() or use the Readonly interface for our dependency array if $inject only accepts a mutable array of strings. --- angular/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index 4a9445962d..b07ae7d5f9 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -10,7 +10,7 @@ declare var angular: angular.IAngularStatic; // Support for painless dependency injection declare global { interface Function { - $inject?: string[] | ReadonlyArray; + $inject?: ReadonlyArray; } } From ffabe14406652099f76cd93bb54e71676a9bc333 Mon Sep 17 00:00:00 2001 From: Markus Chmelar Date: Tue, 10 Jan 2017 17:51:31 +0100 Subject: [PATCH 057/422] Add `closeOnClick` to PopupOptions --- leaflet/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 3e50ded6fd..93cceb3425 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1046,6 +1046,7 @@ declare namespace L { keepInView?: boolean; closeButton?: boolean; autoClose?: boolean; + closeOnClick?: boolean; } type Content = string | HTMLElement; From 92933ca5fc28c42957d83ca013ac717c75c64252 Mon Sep 17 00:00:00 2001 From: Shu Sam Chen Date: Tue, 10 Jan 2017 17:22:16 +0000 Subject: [PATCH 058/422] Added missing methods to Body. --- p2/index.d.ts | 5 ++++- p2/p2-tests.ts | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/p2/index.d.ts b/p2/index.d.ts index 5fb85052e6..e9b8b79054 100644 --- a/p2/index.d.ts +++ b/p2/index.d.ts @@ -520,7 +520,10 @@ declare namespace p2 { addShape(shape: Shape, offset?: number[], angle?: number): void; removeShape(shape: Shape): boolean; updateMassProperties(): void; - applyForce(force: number[], worldPoint: number[]): void; + applyForce(force: number[], relativePoint?: number[]): void; + applyForceLocal(localforce: number[], localPoint?: number[]): void; + applyImpulse(impulse: number[], relativePoint?: number[]): void; + applyImpulseLocal(impulse: number[], localPoint?: number[]): void; toLocalFrame(out: number[], worldPoint: number[]): void; toWorldFrame(out: number[], localPoint: number[]): void; fromPolygon(path: number[][], options?: { diff --git a/p2/p2-tests.ts b/p2/p2-tests.ts index bdad71b906..0579a880b2 100644 --- a/p2/p2-tests.ts +++ b/p2/p2-tests.ts @@ -31,6 +31,12 @@ world.addBody(groundBody); // This is done using a fixed time step size. var timeStep = 1 / 60; // seconds +// Apply a force to the circle +circleBody.applyForce([10, 0]); + +// Apply an impulse to the circle +circleBody.applyImpulse([0, 50]); + // The "Game loop". Could be replaced by, for example, requestAnimationFrame. setInterval(function(){ From d7f3e8b418ce1a51ddfaacbc0ef5e18f3045b56f Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 10 Jan 2017 10:19:54 -0800 Subject: [PATCH 059/422] Make version number parse-able (#13910) --- iscroll/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iscroll/index.d.ts b/iscroll/index.d.ts index b4a8d62763..cfe1824643 100644 --- a/iscroll/index.d.ts +++ b/iscroll/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for iScroll 5 +// Type definitions for iScroll 5.0 // Project: http://cubiq.org/iscroll-5-ready-for-beta-test // Definitions by: Christiaan Rakowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 24906647e66a58d0cc0f937dafa40f627e05beac Mon Sep 17 00:00:00 2001 From: Brian Caruso Date: Tue, 10 Jan 2017 10:15:24 -0800 Subject: [PATCH 060/422] Update auth0-lock to v10.9.1 API --- auth0-lock/auth0-lock-tests.ts | 26 +++++++++++++++++++++++++- auth0-lock/index.d.ts | 26 +++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/auth0-lock/auth0-lock-tests.ts b/auth0-lock/auth0-lock-tests.ts index cd51950c6a..d0a9231a57 100644 --- a/auth0-lock/auth0-lock-tests.ts +++ b/auth0-lock/auth0-lock-tests.ts @@ -1,5 +1,5 @@ /// - +/// const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID"; const DOMAIN = "YOUR_DOMAIN_AT.auth0.com"; @@ -10,6 +10,30 @@ lock.show(); lock.hide(); lock.logout(() => {}); +// Show supports UI arguments + +var showOptions : Auth0LockShowOptions = { + allowedConnections: [ "twitter", "facebook" ], + autoclose: false, + autofocus: true, + closable: true, + container: "somediv", + flashMessage: { + type: "error", + text: "an error has occurred" + }, + language: "en", + popupOptions: { + width: 100, + height: 400, + left: 200, + top: 200 + }, + rememberLastLogin: false +}; + +lock.show(showOptions); + // The examples below are lifted from auth0-lock documentation on Github // "on" event-driven example diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts index e2964d287c..4593b4e32a 100644 --- a/auth0-lock/index.d.ts +++ b/auth0-lock/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for auth0-lock v10.0.1 +// Type definitions for auth0-lock v10.9.1 // Project: http://auth0.com // Definitions by: Brian Caruso // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -103,13 +103,33 @@ interface Auth0LockConstructorOptions { usernameStyle?: string; } +interface Auth0LockFlashMessageOptions { + type: "success" | "error", + text: string; +} + +interface Auth0LockShowOptions { + allowedConnections?: string[]; + autoclose?: boolean; + autofocus?: boolean; + avatar?: Auth0LockAvatarOptions; + closable?: boolean; + container?: string; + flashMessage?: Auth0LockFlashMessageOptions; + language?: string; + languageDictionary?: any; + popupOptions?: Auth0LockPopupOptions; + rememberLastLogin?: boolean; +} + interface Auth0LockStatic { new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic; - getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; + // deprecated + getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; - show(): void; + show(options?: Auth0LockShowOptions): void; hide(): void; logout(query: any): void; From 904bc106f104aed142b1eeefc9c3da7441152b08 Mon Sep 17 00:00:00 2001 From: Brian Caruso Date: Tue, 10 Jan 2017 10:47:17 -0800 Subject: [PATCH 061/422] Address tslint issues --- auth0-lock/index.d.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts index 4593b4e32a..32e473b84a 100644 --- a/auth0-lock/index.d.ts +++ b/auth0-lock/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for auth0-lock v10.9.1 +// Type definitions for auth0-lock 10.9 // Project: http://auth0.com // Definitions by: Brian Caruso // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -104,7 +104,7 @@ interface Auth0LockConstructorOptions { } interface Auth0LockFlashMessageOptions { - type: "success" | "error", + type: "success" | "error"; text: string; } @@ -126,19 +126,17 @@ interface Auth0LockStatic { new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic; // deprecated - getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; - getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void) : void; + getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void; + getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void; show(options?: Auth0LockShowOptions): void; hide(): void; logout(query: any): void; - on(event: "show", callback: () => void) : void; - on(event: "hide", callback: () => void) : void; - on(event: "unrecoverable_error", callback: (error: Auth0Error) => void) : void; - on(event: "authorization_error", callback: (error: Auth0Error) => void) : void; - on(event: "authenticated", callback: (authResult: any) => void) : void; - on(event: string, callback: (...args: any[]) => void) : void; + on(event: "show" | "hide", callback: () => void): void; + on(event: "unrecoverable_error" | "authorization_error", callback: (error: Auth0Error) => void): void; + on(event: "authenticated", callback: (authResult: any) => void): void; + on(event: string, callback: (...args: any[]) => void): void; } declare var Auth0Lock: Auth0LockStatic; From dd56cf09c456fc0f9f133107d8d6a3f8bc3dff13 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Tue, 10 Jan 2017 19:09:12 +0000 Subject: [PATCH 062/422] Create tslint.json --- sha1/tslint.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 sha1/tslint.json diff --git a/sha1/tslint.json b/sha1/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/sha1/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3a5255b8f25123254ea7948070497253fe7cef54 Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Tue, 10 Jan 2017 19:14:57 +0000 Subject: [PATCH 063/422] Update index.d.ts --- sha1/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sha1/index.d.ts b/sha1/index.d.ts index c792f7d585..91a4820973 100644 --- a/sha1/index.d.ts +++ b/sha1/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sha1 v1.1.1 +// Type definitions for sha1 v1.1 // Project: https://github.com/pvorb/node-sha1 // Definitions by: Bill Sourour // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 6aacd98e182240c38fab38ba77364e19cc5fb60f Mon Sep 17 00:00:00 2001 From: JD-Robbs Date: Tue, 10 Jan 2017 19:18:26 +0000 Subject: [PATCH 064/422] Update index.d.ts --- sha1/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sha1/index.d.ts b/sha1/index.d.ts index 91a4820973..81b2202dc3 100644 --- a/sha1/index.d.ts +++ b/sha1/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sha1 v1.1 +// Type definitions for sha1 1.1 // Project: https://github.com/pvorb/node-sha1 // Definitions by: Bill Sourour // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 60fb8a10230169a92e9fd0db443d596f620bf2be Mon Sep 17 00:00:00 2001 From: Robert Buehler Date: Tue, 10 Jan 2017 13:30:44 -0600 Subject: [PATCH 065/422] Added dir to JSZipFileOptions. --- jszip/index.d.ts | 1 + jszip/jszip-tests.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/jszip/index.d.ts b/jszip/index.d.ts index 46fe0f870c..be9b053d43 100644 --- a/jszip/index.d.ts +++ b/jszip/index.d.ts @@ -148,6 +148,7 @@ interface JSZipFileOptions { comment?: string; optimizedBinaryString?: boolean; createFolders?: boolean; + dir?: boolean; } interface JSZipObjectOptions { diff --git a/jszip/jszip-tests.ts b/jszip/jszip-tests.ts index da6366fbcb..f7a4b9f10f 100644 --- a/jszip/jszip-tests.ts +++ b/jszip/jszip-tests.ts @@ -9,6 +9,7 @@ var SEVERITY = { function createTestZip(): JSZip { var zip = new JSZip(); zip.file("test.txt", "test string"); + zip.file("test", null, { dir: true }); zip.file("test/test.txt", "test string"); return zip } From 28d96a9ec99af437e09c7357bf065f9848af0ea8 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 10 Jan 2017 19:31:57 +0000 Subject: [PATCH 066/422] Fix redux-form typings (#13867) * Patch FormErrors and FormWarnings * Allow passing ReactElement values to FormErrors and FormWarnings * Add typescript version to the end of the header --- redux-form/index.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/redux-form/index.d.ts b/redux-form/index.d.ts index 4c73f3e489..590fe3a633 100644 --- a/redux-form/index.d.ts +++ b/redux-form/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/erikras/redux-form // Definitions by: Carson Full , Daniel Lytkin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// @@ -16,9 +17,13 @@ export type FieldType = 'Field' | 'FieldArray'; export type DataShape = {[fieldName:string]: FieldValue}; -export type FormErrors = FormData & { _error?: string }; +export type FormErrors = { + [P in keyof FormData]?: React.ReactElement | string; +} & { _error?: string }; -export type FormWarnings = FormData & { _warning?: string }; +export type FormWarnings = { + [P in keyof FormData]?: React.ReactElement | string; +} & { _warning?: string }; /** * A component class or stateless function component. From c21893d61a9286cf7ffbe69c7d2c1677257d444a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 10 Jan 2017 11:44:39 -0800 Subject: [PATCH 067/422] Update expr-eval for new linter * Now warns if we `export =` a namespace * `unified-signatures` no longer complains when static and non-static methods share a name * Also change `values` paramters to be of type `Values` rather than `Value` --- expr-eval/index.d.ts | 52 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/expr-eval/index.d.ts b/expr-eval/index.d.ts index 7f72eb6101..cab8333186 100644 --- a/expr-eval/index.d.ts +++ b/expr-eval/index.d.ts @@ -3,35 +3,29 @@ // Definitions by: Connor Peet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace exprEval { - type Value = number - | string - | ((...args: Value[]) => Value) - | { [propertyName: string]: Value }; +type Value = number + | string + | ((...args: Value[]) => Value) + | { [propertyName: string]: Value }; - interface Values { - [propertyName: string]: Value; - } - - export class Parser { - constructor(options?: { allowMemberAccess?: boolean }); - parse(expression: string): Expression; - evaluate(expression: string, values?: Value): number; - - // todo(connor4312): tslint is disabled on the following two lines, as - // thinks that the above instance methods are overloads for the static methods. - static parse(expression: string): Expression; // tslint:disable-line - static evaluate(expression: string, values?: Value): number; // tslint:disable-line - } - - export interface Expression { - simplify(values?: Values): Expression; - evaluate(values?: Values): number; - substitute(values: Values): Expression; - symbols(): string[]; - variables(): string[]; - toJSFunction(params: string, values?: Values): (...args: Value[]) => number; - } +interface Values { + [propertyName: string]: Value; } -export = exprEval; +export class Parser { + constructor(options?: { allowMemberAccess?: boolean }); + parse(expression: string): Expression; + evaluate(expression: string, values?: Values): number; + + static parse(expression: string): Expression; + static evaluate(expression: string, values?: Values): number; +} + +export interface Expression { + simplify(values?: Values): Expression; + evaluate(values?: Values): number; + substitute(values: Values): Expression; + symbols(): string[]; + variables(): string[]; + toJSFunction(params: string, values?: Values): (...args: Value[]) => number; +} From 74bb64e32e2d79a956d1504b634d066f98f5ed25 Mon Sep 17 00:00:00 2001 From: Brian Caruso Date: Tue, 10 Jan 2017 12:27:32 -0800 Subject: [PATCH 068/422] Fix argument list for options object to 'show()' function --- auth0-lock/auth0-lock-tests.ts | 21 ++++++++++----------- auth0-lock/index.d.ts | 12 ++++-------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/auth0-lock/auth0-lock-tests.ts b/auth0-lock/auth0-lock-tests.ts index d0a9231a57..deb046f3e7 100644 --- a/auth0-lock/auth0-lock-tests.ts +++ b/auth0-lock/auth0-lock-tests.ts @@ -14,21 +14,20 @@ lock.logout(() => {}); var showOptions : Auth0LockShowOptions = { allowedConnections: [ "twitter", "facebook" ], - autoclose: false, - autofocus: true, - closable: true, - container: "somediv", + allowSignUp: true, + allowForgotPassword: false, + auth: { + params: { state: "foo" }, + redirect: true, + redirectUrl: "some url", + responseType: "token", + sso: true + }, + initialScreen: "login", flashMessage: { type: "error", text: "an error has occurred" }, - language: "en", - popupOptions: { - width: 100, - height: 400, - left: 200, - top: 200 - }, rememberLastLogin: false }; diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts index 32e473b84a..51fa67e401 100644 --- a/auth0-lock/index.d.ts +++ b/auth0-lock/index.d.ts @@ -110,15 +110,11 @@ interface Auth0LockFlashMessageOptions { interface Auth0LockShowOptions { allowedConnections?: string[]; - autoclose?: boolean; - autofocus?: boolean; - avatar?: Auth0LockAvatarOptions; - closable?: boolean; - container?: string; + allowSignUp?: boolean; + allowForgotPassword?: boolean; + auth?: Auth0LockAuthOptions; + initialScreen?: "login" | "signUp" | "forgotPassword"; flashMessage?: Auth0LockFlashMessageOptions; - language?: string; - languageDictionary?: any; - popupOptions?: Auth0LockPopupOptions; rememberLastLogin?: boolean; } From 0c55c305bef988cc5d2dab4953126d1712ddc1ba Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 10 Jan 2017 12:36:01 -0800 Subject: [PATCH 069/422] tar: Add "noProprietary" header --- tar/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tar/index.d.ts b/tar/index.d.ts index 3b2a6d176b..4b62578290 100644 --- a/tar/index.d.ts +++ b/tar/index.d.ts @@ -14,6 +14,7 @@ import stream = require("stream"); export interface HeaderProperties { path?: string; mode?: number; + noProprietary?: boolean; uid?: number; gid?: number; size?: number; From 5642676697a742f33118383184afc47264a70691 Mon Sep 17 00:00:00 2001 From: Brian Caruso Date: Tue, 10 Jan 2017 12:49:44 -0800 Subject: [PATCH 070/422] Add missing 'allowLogin' parameter to show() options. Alphabetize show() options in type definition. --- auth0-lock/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts index 51fa67e401..fc9a047115 100644 --- a/auth0-lock/index.d.ts +++ b/auth0-lock/index.d.ts @@ -110,8 +110,9 @@ interface Auth0LockFlashMessageOptions { interface Auth0LockShowOptions { allowedConnections?: string[]; - allowSignUp?: boolean; allowForgotPassword?: boolean; + allowLogin?: boolean; + allowSignUp?: boolean; auth?: Auth0LockAuthOptions; initialScreen?: "login" | "signUp" | "forgotPassword"; flashMessage?: Auth0LockFlashMessageOptions; From 88b843a4586377b05bce4f63e2a10493beeca6ad Mon Sep 17 00:00:00 2001 From: Alexander Efimov Date: Wed, 11 Jan 2017 00:12:27 +0300 Subject: [PATCH 071/422] Adding geolib definition with fixed signatures in file taken from Vladimir Venegas. Tests are also added. (#13886) Adding geolib definition with fixed signatures in file taken from Vladimir Venegas. Tests are also added. --- geolib/geolib-tests.ts | 201 +++++++++++++++++++++++++++++++++++++++++ geolib/index.d.ts | 199 ++++++++++++++++++++++++++++++++++++++++ geolib/tsconfig.json | 20 ++++ geolib/tslint.json | 1 + 4 files changed, 421 insertions(+) create mode 100644 geolib/geolib-tests.ts create mode 100644 geolib/index.d.ts create mode 100644 geolib/tsconfig.json create mode 100644 geolib/tslint.json diff --git a/geolib/geolib-tests.ts b/geolib/geolib-tests.ts new file mode 100644 index 0000000000..5386bf730b --- /dev/null +++ b/geolib/geolib-tests.ts @@ -0,0 +1,201 @@ +import "geolib"; +import PositionAsDecimal = geolib.PositionAsDecimal; +import CompassDirection = geolib.CompassDirection; +import Distance = geolib.Distance; +import Bound = geolib.Bound; + +let dist: number = geolib.getDistance( + {latitude: 51.5103, longitude: 7.49347}, + {latitude: "51° 31' N", longitude: "7° 28' E"} +); + +dist = geolib.getDistance( + {latitude: 51.5103, longitude: 7.49347}, + {latitude: "51° 31' N", longitude: "7° 28' E"} +); + +dist = geolib.getDistance( + {latitude: 51.5103, longitude: 7.49347}, + {latitude: "51° 31' N", longitude: "7° 28' E"}, + 1, + 1 +); + +// Working with W3C Geolocation API +navigator.geolocation.getCurrentPosition( + function(position) { + alert('You are ' + geolib.getDistance(position.coords, { + latitude: 51.525, + longitude: 7.4575 + }) + ' meters away from 51.525, 7.4575'); + }, + function() { + alert('Position could not be determined.') + }, + { + enableHighAccuracy: true + } +); + + +dist = geolib.getDistanceSimple( + {latitude: 51.5103, longitude: 7.49347}, + {latitude: "51° 31' N", longitude: "7° 28' E"} +); + +dist = geolib.getDistanceSimple( + {latitude: 51.5103, longitude: 7.49347}, + {latitude: "51° 31' N", longitude: "7° 28' E"}, + 1 +); + +let posAsDecimal: PositionAsDecimal = geolib.getCenter([ + {latitude: 52.516272, longitude: 13.377722}, + {latitude: 51.515, longitude: 7.453619}, + {latitude: 51.503333, longitude: -0.119722} +]); + +posAsDecimal = geolib.getCenter([ + {latitude: 52.516272, longitude: 13.377722}, + {latitude: 51.515, longitude: 7.453619}, + {latitude: 51.503333, longitude: -0.119722} +]); + +posAsDecimal = geolib.getCenterOfBounds([ + {latitude: 52.516272, longitude: 13.377722}, + {latitude: 51.515, longitude: 7.453619}, + {latitude: 51.503333, longitude: -0.119722}, + {latitude: 51.503333, longitude: -1.119722} +]); + + + +let bound: Bound = geolib.getBounds([ + {latitude: 52.516272, longitude: 13.377722, elevation: 1}, + {latitude: 51.515, longitude: 7.453619, elevation: 1}, + {latitude: 51.503333, longitude: -0.119722, elevation: 1}]); + +let isInside: boolean = geolib.isPointInside( + {latitude: 51.5125, longitude: 7.485}, + [ + {latitude: 51.50, longitude: 7.40}, + {latitude: 51.555, longitude: 7.40}, + {latitude: 51.555, longitude: 7.625}, + {latitude: 51.5125, longitude: 7.625} + ] +); // -> true + +// checks if 51.525, 7.4575 is within a radius of 5km from 51.5175, 7.4678 +let boolResult: boolean = geolib.isPointInCircle( + {latitude: 51.525, longitude: 7.4575}, + {latitude: 51.5175, longitude: 7.4678}, + 5000 +); + +let bearing: number = geolib.getRhumbLineBearing( + {latitude: 52.518611, longitude: 13.408056}, + {latitude: 51.519475, longitude: 7.46694444} +); + +bearing = geolib.getBearing( + {latitude: 52.518611, longitude: 13.408056}, + {latitude: 51.519475, longitude: 7.46694444} +); + +let compassDirection: CompassDirection = geolib.getCompassDirection( + {latitude: 52.518611, longitude: 13.408056}, + {latitude: 51.519475, longitude: 7.46694444} +); + +compassDirection = geolib.getCompassDirection( + {latitude: 52.518611, longitude: 13.408056}, + {latitude: 51.519475, longitude: 7.46694444}, + 'circle' +); + +// coords array +let distanceArray: Distance[] = geolib.orderByDistance({latitude: 51.515, longitude: 7.453619}, [ + {latitude: 52.516272, longitude: 13.377722}, + {latitude: 51.518, longitude: 7.45425}, + {latitude: 51.503333, longitude: -0.119722} +]); + +// coords object +distanceArray = geolib.orderByDistance({latitude: 51.515, longitude: 7.453619}, [ + {latitude: 52.516272, longitude: 13.377722}, + {latitude: 51.518, longitude: 7.45425}, + {latitude: 51.503333, longitude: -0.119722} +]); + + +// in this case set offset to 1 otherwise the nearest point will always be your reference point +let posAsDecimalArray: Distance[] = geolib.findNearest( + {latitude: 51.515, longitude: 7.453619}, + [ + {latitude: 52.516272, longitude: 13.377722}, + {latitude: 51.515, longitude: 7.453619}, + {latitude: 51.503333, longitude: -0.119722}, + {latitude: 55.751667, longitude: 37.617778}, + {latitude: 48.8583, longitude: 2.2945}, + {latitude: 59.3275, longitude: 18.0675}, + {latitude: 59.916911, longitude: 10.727567} + ], 1); + + +// Calculate distance from Berlin via Dortmund to London +dist = geolib.getPathLength([ + {latitude: 52.516272, longitude: 13.377722}, // Berlin + {latitude: 51.515, longitude: 7.453619}, // Dortmund + {latitude: 51.503333, longitude: -0.119722} // London +]); // -> 945235 + +let speed: number = geolib.getSpeed( + [ + {latitude: 51.567294, longitude: 7.38896, time: 1360231200880}, + {latitude: 52.54944, longitude: 13.468509, time: 1360245600880} + ], + {unit: 'mph'} +); // -> 66.9408 (mph) + +speed= geolib.getSpeed( + [ + {latitude: 51.567294, longitude: 7.38896, time: 1360231200880}, + {latitude: 52.54944, longitude: 13.468509, time: 1360245600880} + ] +); // -> 66.9408 (mph) + +let point1 = {latitude: 0.5, longitude: 0}; +let point2 = {latitude: 0, longitude: 10}; +let point3 = {latitude: 0, longitude: 15.5}; +let start = {latitude: 0, longitude: 0}; +let end = {latitude: 0, longitude: 15}; + +let isInLine1 = geolib.isPointInLine(point1, start, end) //-> false; +let isInLine2 = geolib.isPointInLine(point2, start, end) //-> true; +let isInLine3 = geolib.isPointInLine(point3, start, end) //-> false; + + +let convertResult: number = geolib.convertUnit('km', 14213, 2) // -> 14,21 +convertResult = geolib.convertUnit('km', 14213) // -> 14,21 + +let result: number = geolib.sexagesimal2decimal("51° 29' 46\" N") + +let resultString: string = geolib.decimal2sexagesimal(51.49611111); // -> 51° 29' 46.00 + +result = geolib.latitude({lat: 51.49611, lng: 7.38896}); // -> 51.49611 +result = geolib.longitude({lat: 51.49611, lng: 7.38896}); // -> 7.38896 + +result = geolib.useDecimal("51° 29' 46\" N"); // -> 51.59611111 +result = geolib.useDecimal(51.59611111) // -> 51.59611111 + +result = geolib.elevation({lat: 51.49611, lng: 7.38896}); + +let initialPoint = {latitude: 51.516272, longitude: 0.45425} +let radius = 100; +dist = 1234; +bearing = 45; + + +posAsDecimal = geolib.computeDestinationPoint(initialPoint, dist, bearing); +posAsDecimal = geolib.computeDestinationPoint(initialPoint, dist, bearing, radius); +// -> {"latitude":51.52411853234181,"longitude":0.4668623365950795} diff --git a/geolib/index.d.ts b/geolib/index.d.ts new file mode 100644 index 0000000000..69a6c99353 --- /dev/null +++ b/geolib/index.d.ts @@ -0,0 +1,199 @@ +// Type definitions for geolib 2.0 +// Project: https://github.com/manuelbieh/Geolib +// Definitions by: Vladimir Venegas , Alex Efimov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace geolib { + export interface PositionAsDecimal { + latitude: number; + longitude: number; + } + + export interface PositionAsSexadecimal { + latitude: string; + longitude: string; + } + + export interface PositionWithElevation extends PositionAsDecimal { + elevation?: number; + } + + export interface PositionInTime extends PositionAsDecimal { + time: number; + } + + export interface Bound { + minLat: number; + maxLat: number; + minLng: number; + maxLng: number; + minElev?: number; + maxElev?: number; + } + + export interface CompassDirection { + rough: string; + exact: string; + } + + export interface Distance { + latitude: number; + longitude: number; + distance: number; + key: string; + } + + export interface SpeedOption { + unit: string; + } + + /** Calculates the distance between two geo coordinates + * + * Return value is always float and represents the distance in meters. + */ + function getDistance(start: PositionAsDecimal|PositionAsSexadecimal, end: PositionAsDecimal|PositionAsSexadecimal, accuracy?: number, precision?: number): number; + + /** Calculates the distance between two geo coordinates but this method is far more inaccurate as compared to getDistance. + * It can take up 2 to 3 arguments. start, end and accuracy can be defined in the same as in getDistance. + * + * Return value is always float that represents the distance in meters. + */ + function getDistanceSimple(start: PositionAsDecimal|PositionAsSexadecimal, end: PositionAsDecimal|PositionAsSexadecimal, accuracy?: number): number; + + + /** Calculates the geographical center of all points in a collection of geo coordinates + * Takes an object or array of coordinates and calculates the center of it. + */ + function getCenter(coords: PositionAsDecimal[]): PositionAsDecimal; + + + /** Calculates the center of the bounds of geo coordinates. Takes an array of coordinates, + * calculate the border of those, and gives back the center of that rectangle. On polygons + * like political borders (eg. states), this may gives a closer result to human expectation, + * than getCenter, because that function can be disturbed by uneven distribution of point in + * different sides. Imagine the US state Oklahoma: getCenter on that gives a southern point, + * because the southern border contains a lot more nodes, than the others. + */ + function getCenterOfBounds(coords: PositionAsDecimal[]): PositionAsDecimal; + + + /** Calculates the bounds of geo coordinates. + * + * Returns maximum and minimum, latitude, longitude, and elevation (if provided) in form of an object + */ + function getBounds(coords: PositionWithElevation[]): Bound; + + + /** Checks whether a point is inside of a polygon or not. Note: the polygon coords must be in correct order! + * + * Returns true or false + */ + function isPointInside(latlng: PositionAsDecimal, polygon: PositionAsDecimal[]): boolean; + + + /** Similar to is point inside: checks whether a point is inside of a circle or not. + * + * Returns true or false + */ + function isPointInCircle(latlng: PositionAsDecimal, center: PositionAsDecimal, radius: number): boolean; + + + /** Gets rhumb line bearing of two points. Find out about the difference between rhumb line and great circle bearing on Wikipedia. + * Rhumb line should be fine in most cases: http://en.wikipedia.org/wiki/Rhumb_line#General_and_mathematical_description Function + * is heavily based on Doug Vanderweide's great PHP version (licensed under GPL 3.0) + * http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/ + * + * Returns calculated bearing as integer. + */ + function getRhumbLineBearing(originLL: PositionAsDecimal, destLL: PositionAsDecimal): number; + + + /** Gets great circle bearing of two points. See description of getRhumbLineBearing for more information. + * + * Returns calculated bearing as integer + */ + function getBearing(originLL: PositionAsDecimal, destLL: PositionAsDecimal): number; + + + /** Gets the compass direction from an origin coordinate (originLL) to a destination coordinate (destLL). + * Bearing mode. Can be either circle or rhumbline (default). + * + * Returns an object with a rough (NESW) and an exact direction (NNE, NE, ENE, E, ESE, etc). + */ + function getCompassDirection(originLL: PositionAsDecimal, destLL: PositionAsDecimal, bearingMode?: string): CompassDirection; + + + /** Sorts an object or array of coords by distance from a reference coordinate */ + function orderByDistance(latlng: PositionAsDecimal, coords: PositionAsDecimal[]): Distance[]; + + + /** Finds the nearest coordinate to a reference coordinate. */ + function findNearest(latlng: PositionAsDecimal, coords: PositionAsDecimal[], offset?: number, limit?: number): Distance[]; + + + /** Calculates the length of a collection of coordinates. + * + * Returns the length of the path in meters */ + function getPathLength(coords: PositionAsDecimal[]): number; + + /** Calculates the speed between two points within a given time span. + * + * Returns the speed in options.unit (default is km/h). + */ + function getSpeed(coords: PositionInTime[], option?: SpeedOption): number; + + + /** Calculates if given point lies in a line formed by start and end */ + function isPointInLine(point: PositionAsDecimal, start: PositionAsDecimal, end: PositionAsDecimal): boolean; + + + /** Converts a given distance (in meters) to another unit. + * distance distance to be converted (source must be in meter). unit can be one of: + * - m (meter) + * - km (kilometers) + * - cm (centimeters) + * - mm (millimeters) + * - mi (miles) + * - sm (seamiles) + * - ft (foot) + * - in (inch) + * - yd (yards) + */ + function convertUnit(unit: string, distance: number, round?: number): number; + + + /** Converts a sexagesimal coordinate to decimal format */ + function sexagesimal2decimal(coord: string): number; + + + /** Converts a decimal coordinate to sexagesimal format */ + function decimal2sexagesimal(coord: number): string; + + /** Returns the latitude for a given point and converts it to decimal. + * Works with: latitude, lat, 1 (GeoJSON array) + */ + function latitude(latlng: any): number; + + /** Returns the longitude for a given point and converts it to decimal. + * Works with: longitude, lng, lon, 0 (GeoJSON array) + */ + function longitude(latlng: any): number; + + /** Returns the elevation for a given point and converts it to decimal. + * Works with: elevation, elev, alt, altitude, 2 (GeoJSON array) + */ + function elevation(latlng: any): number; + + + /** Checks if a coordinate is already in decimal format and, if not, converts it to */ + function useDecimal(latlng: string|number): number; + + + /** Computes the destination point given an initial point, a distance (in meters) and a bearing (in degrees). + * If no radius is given it defaults to the mean earth radius of 6371000 meter. + * + * Returns an object: `{"latitude": destLat, "longitude": destLng}` + * (Attention: this formula is not *100%* accurate (but very close though)) + */ + function computeDestinationPoint(start: PositionAsDecimal, distance: number, bearing: number, radius?: number): PositionAsDecimal; +} diff --git a/geolib/tsconfig.json b/geolib/tsconfig.json new file mode 100644 index 0000000000..aca799d836 --- /dev/null +++ b/geolib/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "geolib-tests.ts" + ] +} diff --git a/geolib/tslint.json b/geolib/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/geolib/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From cfc5441a76bc3f54686bace707bc85bc15d9be80 Mon Sep 17 00:00:00 2001 From: Nelson Morais Date: Tue, 10 Jan 2017 22:51:25 +0100 Subject: [PATCH 072/422] Update config to support adal 1.0.13 settings (#13871) The instance setting was missing and is required if you need to connect to other instances (like China) --- adal/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adal/index.d.ts b/adal/index.d.ts index a896d687ec..abff003e97 100644 --- a/adal/index.d.ts +++ b/adal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ADAL.JS 1.0.8 +// Type definitions for ADAL.JS 1.0.13 // Project: https://github.com/AzureAD/azure-activedirectory-library-for-js // Definitions by: mmaitre314 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -16,6 +16,7 @@ declare namespace adal { tenant?: string; clientId: string; redirectUri?: string; + instance?: string; cacheLocation?: string; displayCall?: (urlNavigate: string) => any; correlationId?: string; From 67cce773b5de14cd64856782c79cc9a9e392e8cc Mon Sep 17 00:00:00 2001 From: Rafael Salguero Iturrios Date: Tue, 10 Jan 2017 14:54:42 -0700 Subject: [PATCH 073/422] Added module definition (#13870) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an optional extended description… --- leaflet-label/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/leaflet-label/index.d.ts b/leaflet-label/index.d.ts index 08be437e7a..ded3f798b9 100644 --- a/leaflet-label/index.d.ts +++ b/leaflet-label/index.d.ts @@ -79,3 +79,7 @@ declare namespace L { setOpacity(opacity: number): void; } } + +declare module 'leaflet.label' { + export = L; +} From e4d1d4b9a0858f356d4ca264212b0f291a30557f Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 10 Jan 2017 14:20:05 -0800 Subject: [PATCH 074/422] leaflet-label: Use external module syntax (#13918) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an optional extended description… --- leaflet-label/index.d.ts | 132 +++++++++++++++++++------------------- leaflet-label/tslint.json | 1 + 2 files changed, 67 insertions(+), 66 deletions(-) create mode 100644 leaflet-label/tslint.json diff --git a/leaflet-label/index.d.ts b/leaflet-label/index.d.ts index ded3f798b9..879f456e2d 100644 --- a/leaflet-label/index.d.ts +++ b/leaflet-label/index.d.ts @@ -1,85 +1,85 @@ -// Type definitions for Leaflet.label v0.2.1 +// Type definitions for Leaflet.label 0.2 // Project: https://github.com/Leaflet/Leaflet.label // Definitions by: Wim Looman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare namespace L { - export interface IconOptions { - labelAnchor?: Point; - } +declare global { + namespace L { + interface IconOptions { + labelAnchor?: Point; + } - export interface PathOptions { - labelAnchor?: Point; - } + interface PathOptions { + labelAnchor?: Point; + } - export interface CircleMarkerOptions { - labelAnchor?: Point; - } + interface CircleMarkerOptions { + labelAnchor?: Point; + } - export interface Marker { - showLabel(): Marker; - hideLabel(): Marker; - setLabelNoHide(noHide: boolean): void; - bindLabel(content: string, options?: LabelOptions): Marker; - unbindLabel(): Marker; - updateLabelContent(content: string): void; - getLabel(): Label; - setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; - } + interface Marker { + showLabel(): Marker; + hideLabel(): Marker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): Marker; + unbindLabel(): Marker; + updateLabelContent(content: string): void; + getLabel(): Label; + setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; + } - export interface CircleMarker { - showLabel(): CircleMarker; - hideLabel(): CircleMarker; - setLabelNoHide(noHide: boolean): void; - bindLabel(content: string, options?: LabelOptions): CircleMarker; - unbindLabel(): CircleMarker; - updateLabelContent(content: string): void; - getLabel(): Label; - } + interface CircleMarker { + showLabel(): CircleMarker; + hideLabel(): CircleMarker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): CircleMarker; + unbindLabel(): CircleMarker; + updateLabelContent(content: string): void; + getLabel(): Label; + } - export interface FeatureGroup { - clearLayers(): FeatureGroup; - bindLabel(content: string, options?: LabelOptions): FeatureGroup; - unbindLabel(): FeatureGroup; - updateLabelContent(content: string): FeatureGroup; - } + interface FeatureGroup { + clearLayers(): FeatureGroup; + bindLabel(content: string, options?: LabelOptions): FeatureGroup; + unbindLabel(): FeatureGroup; + updateLabelContent(content: string): FeatureGroup; + } - export interface Path { - bindLabel(content: string, options?: LabelOptions): Path; - unbindLabel(): Path; - updateLabelContent(content: string): void; - } + interface Path { + bindLabel(content: string, options?: LabelOptions): Path; + unbindLabel(): Path; + updateLabelContent(content: string): void; + } - export interface LabelOptions { - className?: string; - clickable?: boolean; - direction?: string; // 'left' | 'right' | 'auto'; - pane?: string; - noHide?: boolean; - offset?: Point; - opacity?: number; - zoomAnimation?: boolean; - } + interface LabelOptions { + className?: string; + clickable?: boolean; + direction?: string; // 'left' | 'right' | 'auto'; + pane?: string; + noHide?: boolean; + offset?: Point; + opacity?: number; + zoomAnimation?: boolean; + } - export interface LabelStatic extends ClassStatic { - new(options?: LabelOptions): Label; - } + interface LabelStatic extends ClassStatic { + new(options?: LabelOptions): Label; + } - export var Label: LabelStatic; + var Label: LabelStatic; - export interface Label extends IEventPowered