diff --git a/.gitignore b/.gitignore index 858238c5bf..ce5d4a9d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,6 @@ node_modules .sublimets .settings/launch.json + .vscode -yarn.lock \ No newline at end of file +yarn.lock diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8b263f19ae..1036be548d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1665,7 +1665,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](supertest/supertest.d.ts) [SuperTest](https://github.com/visionmedia/supertest) by [Alex Varju](https://github.com/varju) * [:link:](supertest-as-promised/supertest-as-promised.d.ts) [SuperTest as Promised](https://github.com/WhoopInc/supertest-as-promised) by [Tanguy Krotoff](https://github.com/tkrotoff) * [:link:](svg-injector/svg-injector.d.ts) [SVG Injector](https://github.com/iconic/SVGInjector) by [Patrick Westerhoff](https://github.com/poke) -* [:link:](svg-pan-zoom/svg-pan-zoom.d.ts) [svg-pan-zoom](https://github.com/ariutta/svg-pan-zoom) by [Chintan Shah](https://github.com/Promact) +* [:link:](svg-pan-zoom/svg-pan-zoom-2.3.9.d.ts) [svg-pan-zoom](https://github.com/ariutta/svg-pan-zoom) by [Chintan Shah](https://github.com/Promact) +* [:link:](svg-pan-zoom/svg-pan-zoom.d.ts) [svg-pan-zoom](https://github.com/ariutta/svg-pan-zoom) by [César Vidril](https://github.com/Yimiprod) * [:link:](svg-sprite/svg-sprite.d.ts) [svg-sprite](https://github.com/jkphl/svg-sprite) by [Qubo](https://github.com/tkqubo) * [:link:](svgjs/svgjs.d.ts) [svg.js](http://www.svgjs.com) by [Sean Hess](https://seanhess.github.io) * [:link:](svg2png/svg2png.d.ts) [svg2png node package](https://github.com/domenic/svg2png) by [hans windhoff](https://github.com/hansrwindhoff) diff --git a/README.md b/README.md index d3e6c0e27c..ab2080714b 100644 --- a/README.md +++ b/README.md @@ -55,18 +55,23 @@ Before you share your improvement with the world, use it yourself. #### Test editing an exiting package To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html). -You can also directly edit the types in `node_modules/@types/foo/index.d.ts`, -or copy them from there and paste inside of `declarations.d.ts` and follow the steps below. +You can also directly edit the types in `node_modules/@types/foo/index.d.ts`, or copy them from there and follow the steps below. #### Test a new package -* Add a new file `declarations.d.ts` to your project. -* Add it to the compilation, through `"includes"` or `"files"` in your [tsconfig](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html), -or through a `/// ` declaration in your code. -* Inside `declarations.d.ts`, write `declare module "foo" { }`, then write the module declaration inside. -* Test that your code works. -* *Then*, once you've tested your definitions, make a PR contributing the definition. +Add to your `tsconfig.json`: + +```json +"baseUrl": "types", +"typeRoots": ["types"], +``` + +(You can also use `src/types`.) +Create `types/foo/index.d.ts` containing declarations for the module "foo". +You should now be able import from `"foo"` in your code and it will route to the new type definition. +Then build *and* run the code to make sure your type definition actually corresponds to what happens at runtime. +Once you've tested your definitions with real code, make a PR contributing the definition by copying `types/foo` to `DefinitelyTyped/foo` and adding a `tsconfig.json` and `foo-tests.ts`. ### Make a pull request diff --git a/amcharts/index.d.ts b/amcharts/index.d.ts index fbc2ee4ac9..45c848e5af 100644 --- a/amcharts/index.d.ts +++ b/amcharts/index.d.ts @@ -24,6 +24,9 @@ declare namespace AmCharts { /** Set it to true if you want UTC time to be used instead of local time. */ var useUTC: boolean; + /** Object with themes */ + var themes: any; + /** Clears all the charts on page, removes listeners and intervals. */ function clear(): void; diff --git a/angular-breadcrumb/index.d.ts b/angular-breadcrumb/index.d.ts index 81bb8a1d37..81bd4b3d12 100644 --- a/angular-breadcrumb/index.d.ts +++ b/angular-breadcrumb/index.d.ts @@ -76,4 +76,4 @@ declare namespace ncy { **/ getLastStep(): angular.ui.IState; } -} \ No newline at end of file +} diff --git a/angular-material/index.d.ts b/angular-material/index.d.ts index 7895732ada..ffdab5839b 100644 --- a/angular-material/index.d.ts +++ b/angular-material/index.d.ts @@ -76,7 +76,7 @@ declare module 'angular' { } interface IColorService { - applyThemeColors(element: Element|JQuery, colorExpression: IColorExpression): void; + applyThemeColors(element: Element | JQuery, colorExpression: IColorExpression): void; getThemeColor(expression: string): string; hasTheme(): boolean; } @@ -158,7 +158,7 @@ declare module 'angular' { hideDelay(delay: number): T; position(position: string): T; parent(parent?: string | Element | JQuery): T; // default: root node - toastClass(toastClass: string): T; + toastClass(toastClass: string): T; } interface ISimpleToastPreset extends IToastPreset { @@ -225,7 +225,7 @@ declare module 'angular' { hues: IThemeHues; } - interface IBrowserColors{ + interface IBrowserColors { theme: string; palette: string; hue: string; @@ -264,6 +264,7 @@ declare module 'angular' { definePalette(name: string, palette: IPalette): IThemingProvider; enableBrowserColor(browserColors: IBrowserColors): Function; extendPalette(name: string, palette: IPalette): IPalette; + registerStyles(styles: String): void; setDefaultTheme(theme: string): void; setNonce(nonce: string): void; theme(name: string, inheritFrom?: string): ITheme; @@ -414,7 +415,7 @@ declare module 'angular' { ESCAPE: string, }; absPosition: { - TOP: string, + TOP: string, RIGHT: string, BOTTOM: string, LEFT: string, diff --git a/assert/index.d.ts b/assert/index.d.ts index f358833165..23536f9597 100644 --- a/assert/index.d.ts +++ b/assert/index.d.ts @@ -3,7 +3,13 @@ // Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// copy from assert external module in node.d.ts +// Definitions for commonjs-assert match that of node.js' assert module, +// but commonjs-assert is intended to be used as an independent module, +// for instance when making a stand-alone site or app that doesn't have +// access to node modules. For that reason, these definitions define a +// "assert" module. This will conflict with node.d.ts and other assert +// modules such as "power-assert", but a project should realistically +// only be using one of these at a time. declare function assert(value:any, message?:string):void; declare namespace assert { @@ -50,3 +56,4 @@ declare namespace assert { export function ifError(value:any):void; } + diff --git a/async/async-tests.ts b/async/async-tests.ts index c4a3506415..2a21a6cabb 100644 --- a/async/async-tests.ts +++ b/async/async-tests.ts @@ -7,22 +7,23 @@ declare var path: { exists: (path: string, callback?: (err: Error, exists: boolean) => any) => void; }; +function funcStringCbErrBoolean(v:string, cb:(err:Error,res:boolean) => void) {} function callback() { } -async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { }); -async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err, results) { }); -async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err, results) { }); +async.map(['file1', 'file2', 'file3'], fs.stat, function (err:Error, results:Array) { }); +async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err:Error, results:Array) { }); +async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err:Error, results:Array) { }); -async.filter(['file1', 'file2', 'file3'], path.exists, function (results) { }); -async.filterSeries(['file1', 'file2', 'file3'], path.exists, function (results) { }); -async.filterLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { }); -async.select(['file1', 'file2', 'file3'], path.exists, function (results) { }); -async.selectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { }); -async.selectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { }); +async.filter(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.filterSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.filterLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.select(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.selectSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.selectLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,results:Array) { }); -async.reject(['file1', 'file2', 'file3'], path.exists, function (results) { }); -async.rejectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { }); -async.rejectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { }); +async.reject(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.rejectSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array) { }); +async.rejectLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,results:Array) { }); async.parallel([ function () { }, @@ -46,9 +47,9 @@ var openFilesObj = { file2: "fileTwo" } -var saveFile = function () { } -async.each(openFiles, saveFile, function (err) { }); -async.eachSeries(openFiles, saveFile, function (err) { }); +var saveFile = function (file:string,cb:(err:Error)=>void) { } +async.each(openFiles, saveFile, function (err:Error) { }); +async.eachSeries(openFiles, saveFile, function (err:Error) { }); var documents: any, requestApi: any; async.eachLimit(documents, 20, requestApi, function (err) { }); @@ -77,9 +78,9 @@ async.foldl(numArray, 0, reducer, function (err, result) { }); async.reduceRight(numArray, 0, reducer, function (err, result) { }); async.foldr(numArray, 0, reducer, function (err, result) { }); -async.detect(['file1', 'file2', 'file3'], path.exists, function (result) { }); -async.detectSeries(['file1', 'file2', 'file3'], path.exists, function (result) { }); -async.detectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { }); +async.detect(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err: Error,result:string) { }); +async.detectSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err,result) { }); +async.detectLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err,result) { }); async.sortBy(['file1', 'file2', 'file3'], function (file, callback) { fs.stat(file, function (err, stats) { @@ -87,13 +88,13 @@ async.sortBy(['file1', 'file2', 'file3'], function (file, callback) { }); }, function (err, results) { }); -async.some(['file1', 'file2', 'file3'], path.exists, function (result) { }); -async.someLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { }); -async.any(['file1', 'file2', 'file3'], path.exists, function (result) { }); +async.some(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { }); +async.someLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,result:boolean) { }); +async.any(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { }); -async.every(['file1', 'file2', 'file3'], path.exists, function (result) { }); -async.everyLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { }); -async.all(['file1', 'file2', 'file3'], path.exists, function (result) { }); +async.every(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { }); +async.everyLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,result:boolean) { }); +async.all(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { }); async.concat(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { }); async.concatSeries(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { }); @@ -111,7 +112,7 @@ async.series([ ], function (err, results) { }); -async.series([ +async.series([ function (callback) { callback(undefined, 'one'); }, @@ -135,7 +136,7 @@ async.series({ }, function (err, results) { }); -async.series({ +async.series({ one: function (callback) { setTimeout(function () { callback(undefined, 1); @@ -175,7 +176,7 @@ async.parallel([ ], function (err, results) { }); -async.parallel([ +async.parallel([ function (callback) { setTimeout(function () { callback(undefined, 'one'); @@ -204,7 +205,7 @@ async.parallel({ }, function (err, results) { }); -async.parallel({ +async.parallel({ one: function (callback) { setTimeout(function () { callback(undefined, 1); @@ -270,7 +271,7 @@ async.waterfall([ ], function (err, result) { }); -var q = async.queue(function (task: any, callback: any) { +var q = async.queue(function (task: any, callback: () => void) { console.log('hello ' + task.name); callback(); }, 2); @@ -323,7 +324,7 @@ q.resume(); q.kill(); // tests for strongly typed tasks -var q2 = async.queue(function (task: string, callback: any) { +var q2 = async.queue(function (task: string, callback: () => void) { console.log('Task: ' + task); callback(); }, 1); @@ -386,10 +387,10 @@ async.retry({ times: 3, interval: (retryCount) => { return 200 * retryCount; } } async.parallel([ - function (callback) { }, + function (callback: ( err:Error, val:string ) => void ) { }, function (callback) { } ], -function (results) { +function (err:Error,results:Array) { async.series([ function (callback) { }, function email_link(callback) { } @@ -442,10 +443,10 @@ async.dir(function (name: string, callback: any) { // each -async.each({ +async.each({ "a": 1, "b": 2 -}, function(val: number, next: ErrorCallback): void { +}, function(val: number, next: ErrorCallback): void { setTimeout(function(): void { @@ -461,10 +462,10 @@ async.each({ }); -async.eachSeries({ +async.eachSeries({ "a": 1, "b": 2 -}, function(val: number, next: ErrorCallback): void { +}, function(val: number, next: ErrorCallback): void { setTimeout(function(): void { @@ -480,14 +481,14 @@ async.eachSeries({ }); -async.eachLimit({ +async.eachLimit({ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 -}, 2, function(val: number, next: ErrorCallback): void { +}, 2, function(val: number, next: ErrorCallback): void { setTimeout(function(): void { @@ -505,10 +506,10 @@ async.eachLimit({ // forEachOf/eachOf -async.eachOf({ +async.eachOf({ "a": 1, "b": 2 -}, function(val: number, key: string, next: ErrorCallback): void { +}, function(val: number, key: string, next: ErrorCallback): void { setTimeout(function(): void { @@ -524,10 +525,10 @@ async.eachOf({ }); -async.forEachOfSeries({ +async.forEachOfSeries({ "a": 1, "b": 2 -}, function(val: number, key: string, next: ErrorCallback): void { +}, function(val: number, key: string, next: ErrorCallback): void { setTimeout(function(): void { @@ -543,14 +544,14 @@ async.forEachOfSeries({ }); -async.forEachOfLimit({ +async.forEachOfLimit({ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 -}, 2, function(val: number, key: string, next: ErrorCallback): void { +}, 2, function(val: number, key: string, next: ErrorCallback): void { setTimeout(function(): void { @@ -568,11 +569,11 @@ async.forEachOfLimit({ // map -async.map({ +async.map({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncResultCallback): void { +}, function(val: number, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -588,11 +589,11 @@ async.map({ }); -async.mapSeries({ +async.mapSeries({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncResultCallback): void { +}, function(val: number, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -608,14 +609,14 @@ async.mapSeries({ }); -async.mapLimit({ +async.mapLimit({ "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 -}, 2, function(val: number, next: AsyncResultCallback): void { +}, 2, function(val: number, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -633,11 +634,11 @@ async.mapLimit({ // mapValues -async.mapValues({ +async.mapValues({ "a": 1, "b": 2, "c": 3 -}, function(val: number, key: string, next: AsyncResultCallback): void { +}, function(val: number, key: string, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -653,11 +654,11 @@ async.mapValues({ }); -async.mapValuesSeries({ +async.mapValuesSeries({ "a": 1, "b": 2, "c": 3 -}, function(val: number, key: string, next: AsyncResultCallback): void { +}, function(val: number, key: string, next: AsyncResultCallback): void { setTimeout(function(): void { @@ -675,11 +676,11 @@ async.mapValuesSeries({ // filter/select/reject -async.filter({ +async.filter({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncBooleanResultCallback): void { +}, function(val: number, next: AsyncBooleanResultCallback): void { setTimeout(function(): void { @@ -695,11 +696,11 @@ async.filter({ }); -async.reject({ +async.reject({ "a": 1, "b": 2, "c": 3 -}, function(val: number, next: AsyncBooleanResultCallback): void { +}, function(val: number, next: AsyncBooleanResultCallback): void { setTimeout(function(): void { @@ -717,11 +718,11 @@ async.reject({ // concat -async.concat({ +async.concat({ "a": "1", "b": "2", "c": "3" -}, function(item: string, next: AsyncResultCallback): void { +}, function(item: string, next: AsyncResultCallback): void { console.log(`async.concat: ${item}`); @@ -735,11 +736,11 @@ async.concat({ // detect/find -async.detect({ +async.detect({ "a": 1, "b": 2, "c": 3 -}, function(item: number, next: AsyncBooleanResultCallback): void { +}, function(item: number, next: AsyncBooleanResultCallback): void { console.log(`async.detect/find: ${item}`); @@ -760,11 +761,11 @@ async.detect({ // every/all -async.every({ +async.every({ "a": 1, "b": 2, "c": 3 -}, function(item: number, next: AsyncBooleanResultCallback): void { +}, function(item: number, next: AsyncBooleanResultCallback): void { console.log(`async.every/all: ${item}`); @@ -778,11 +779,11 @@ async.every({ // some/any -async.some({ +async.some({ "a": 1, "b": 2, "c": 3 -}, function(item: number, next: AsyncBooleanResultCallback): void { +}, function(item: number, next: AsyncBooleanResultCallback): void { console.log(`async.some/any: ${item}`); diff --git a/async/index.d.ts b/async/index.d.ts index 8b564fbd80..45d39ea955 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -5,22 +5,22 @@ interface Dictionary { [key: string]: T; } -interface ErrorCallback { (err?: Error): void; } -interface AsyncWaterfallCallback { (err: Error, ...args: any[]): void; } -interface AsyncBooleanResultCallback { (err: Error, truthValue: boolean): void; } -interface AsyncResultCallback { (err: Error, result: T): void; } -interface AsyncResultArrayCallback { (err: Error, results: T[]): void; } -interface AsyncResultObjectCallback { (err: Error, results: Dictionary): void; } +interface ErrorCallback { (err?: T): void; } +interface AsyncWaterfallCallback { (err: E, ...args: any[]): void; } +interface AsyncBooleanResultCallback { (err: E, truthValue: boolean): void; } +interface AsyncResultCallback { (err: E, result: T): void; } +interface AsyncResultArrayCallback { (err: E, results: T[]): void; } +interface AsyncResultObjectCallback { (err: E, results: Dictionary): void; } -interface AsyncFunction { (callback: (err?: Error, result?: T) => void): void; } -interface AsyncIterator { (item: T, callback: ErrorCallback): void; } -interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } -interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } -interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } -interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } +interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } +interface AsyncIterator { (item: T, callback: ErrorCallback): void; } +interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } +interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } +interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } +interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } -interface AsyncWorker { (task: T, callback: ErrorCallback): void; } -interface AsyncVoidFunction { (callback: ErrorCallback): void; } +interface AsyncWorker { (task: T, callback: ErrorCallback): void; } +interface AsyncVoidFunction { (callback: ErrorCallback): void; } interface AsyncQueue { length(): number; @@ -28,10 +28,10 @@ interface AsyncQueue { running(): number; idle(): boolean; concurrency: number; - push(task: T, callback?: ErrorCallback): void; - push(task: T[], callback?: ErrorCallback): void; - unshift(task: T, callback?: ErrorCallback): void; - unshift(task: T[], callback?: ErrorCallback): void; + push(task: T, callback?: ErrorCallback): void; + push(task: T[], callback?: ErrorCallback): void; + unshift(task: T, callback?: ErrorCallback): void; + unshift(task: T[], callback?: ErrorCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -53,8 +53,8 @@ interface AsyncPriorityQueue { concurrency: number; started: boolean; paused: boolean; - push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; - push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -90,122 +90,122 @@ interface AsyncCargo { interface Async { // Collections - each(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void; - each(arr: Dictionary, iterator: AsyncIterator, callback?: ErrorCallback): void; + each(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void; + each(arr: Dictionary, iterator: AsyncIterator, callback?: ErrorCallback): void; eachSeries: typeof async.each; - eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; - eachLimit(arr: Dictionary, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; + eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; + eachLimit(arr: Dictionary, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; forEach: typeof async.each; forEachSeries: typeof async.each; forEachLimit: typeof async.eachLimit; - forEachOf(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOf(obj: Dictionary, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; + forEachOf(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; + forEachOf(obj: Dictionary, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; forEachOfSeries: typeof async.forEachOf; - forEachOfLimit(obj: T[], limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOfLimit(obj: Dictionary, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; + forEachOfLimit(obj: T[], limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; + forEachOfLimit(obj: Dictionary, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; eachOf: typeof async.forEachOf; eachOfSeries: typeof async.forEachOf; eachOfLimit: typeof async.forEachOfLimit; - map(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + map(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; mapSeries: typeof async.map; - mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - mapLimit(arr: Dictionary, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultCallback): void; - mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultCallback): void; + mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + mapLimit(arr: Dictionary, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultCallback): void; + mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultCallback): void; mapValuesSeries: typeof async.mapValues; - filter(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; - filter(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; + filter(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; + filter(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; filterSeries: typeof async.filter; - filterLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; - filterLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; + filterLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; + filterLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; select: typeof async.filter; selectSeries: typeof async.filter; selectLimit: typeof async.filterLimit; reject: typeof async.filter; rejectSeries: typeof async.filter; rejectLimit: typeof async.filterLimit; - reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): void; + reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): void; inject: typeof async.reduce; foldl: typeof async.reduce; reduceRight: typeof async.reduce; foldr: typeof async.reduce; - detect(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; - detect(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; + detect(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; + detect(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; detectSeries: typeof async.detect; - detectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; - detectLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; + detectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; + detectLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; find: typeof async.detect; findSeries: typeof async.detect; findLimit: typeof async.detectLimit; - sortBy(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - some(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - some(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + sortBy(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + some(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + some(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; someSeries: typeof async.some; - someLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - someLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + someLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + someLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; any: typeof async.some; anySeries: typeof async.someSeries; anyLimit: typeof async.someLimit; - every(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - every(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + every(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + every(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; everySeries: typeof async.every; - everyLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - everyLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + everyLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; + everyLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; all: typeof async.every; allSeries: typeof async.every; allLimit: typeof async.everyLimit; - concat(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - concat(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + concat(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; + concat(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; concatSeries: typeof async.concat; // Control Flow - series(tasks: AsyncFunction[], callback?: AsyncResultArrayCallback): void; - series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; - parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; - parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; - parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; - parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; - whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; - doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; - until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; - doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; - during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; - doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; - forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; - waterfall(tasks: Function[], callback?: AsyncResultCallback): void; + series(tasks: AsyncFunction[], callback?: AsyncResultArrayCallback): void; + series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; + parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; + parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; + parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; + parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; + whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; + doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; + until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; + doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; + during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; + doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; + forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; + waterfall(tasks: Function[], callback?: AsyncResultCallback): void; compose(...fns: Function[]): Function; seq(...fns: Function[]): Function; applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. applyEachSeries(fns: Function[], argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. - queue(worker: AsyncWorker, concurrency?: number): AsyncQueue; - priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; - cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; - auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; - autoInject(tasks: any, callback?: AsyncResultCallback): void; - retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; - retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; - retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; - apply(fn: Function, ...arguments: any[]): AsyncFunction; + queue(worker: AsyncWorker, concurrency?: number): AsyncQueue; + priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; + cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; + auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; + autoInject(tasks: any, callback?: AsyncResultCallback): void; + retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; + retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; + retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; + apply(fn: Function, ...arguments: any[]): AsyncFunction; nextTick(callback: Function, ...args: any[]): void; setImmediate: typeof async.nextTick; - reflect(fn: AsyncFunction) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void; - reflectAll(tasks: AsyncFunction[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[]; + reflect(fn: AsyncFunction) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void; + reflectAll(tasks: AsyncFunction[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[]; - timeout(fn: AsyncFunction, milliseconds: number, info: any): AsyncFunction; + timeout(fn: AsyncFunction, milliseconds: number, info: any): AsyncFunction; - times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; + times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; + timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; + timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - transform(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: Error) => void) => void): void; - transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: Error) => void) => void): void; - transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: Error) => void) => void): void; - transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: Error) => void) => void): void; + transform(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; - race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; + race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; // Utils memoize(fn: Function, hasher?: Function): Function; diff --git a/azure-mobile-apps/index.d.ts b/azure-mobile-apps/index.d.ts index b13bfbb803..53dd5edae3 100644 --- a/azure-mobile-apps/index.d.ts +++ b/azure-mobile-apps/index.d.ts @@ -237,7 +237,7 @@ declare namespace Azure.MobileApps { interface SqlParameterDefinition { name: string; value: any; - } + } interface TableDefinition { access?: AccessType; diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 1591d1c3a5..ea1ea69882 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -336,6 +336,29 @@ fooOrBarProm = fooProm.caught(Promise.CancellationError, (reason: any) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +{ + class CustomError extends Error { + public customField: number; + } + fooProm = fooProm.catch(CustomError, reason => { + let a: number = reason.customField + }) +} + +{ + class CustomErrorWithConstructor extends Error { + constructor(public arg1: boolean, public arg2: number) { + super(); + }; + } + fooProm = fooProm.catch(CustomErrorWithConstructor, reason => { + let a: boolean = reason.arg1; + let b: number = reason.arg2; + }) +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + barProm = fooProm.error((reason: any) => { return bar; }); diff --git a/bluebird/index.d.ts b/bluebird/index.d.ts index 10077179e8..3087abb2e5 100644 --- a/bluebird/index.d.ts +++ b/bluebird/index.d.ts @@ -65,14 +65,19 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection boolean, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; caught(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + catch(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; caught(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - catch(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - caught(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; - catch(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; - caught(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; + + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + caught(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + + catch(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable): Bluebird; + caught(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable): Bluebird; + catch(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; caught(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable | void | Bluebird.Thenable): Bluebird; + catch(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; caught(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable): Bluebird; diff --git a/bunyan/index.d.ts b/bunyan/index.d.ts index 2983d8bb62..edf2e47cca 100644 --- a/bunyan/index.d.ts +++ b/bunyan/index.d.ts @@ -11,7 +11,7 @@ import { EventEmitter } from 'events'; declare class Logger extends EventEmitter { constructor(options: LoggerOptions); addStream(stream: Stream): void; - addSerializers(serializers:Serializers | StdSerializers):void; + addSerializers(serializers:Serializers | StdSerializers):void; child(options: LoggerOptions, simple?: boolean): Logger; child(obj: Object, simple?: boolean): Logger; reopenFileStreams(): void; @@ -58,18 +58,18 @@ interface LoggerOptions { src?: boolean; } - interface Serializer { - (input:any): any; - } +interface Serializer { + (input:any): any; +} interface Serializers { - [key:string]: Serializer; - } + [key: string]: Serializer +} - interface StdSerializers { - err: Serializer; - res: Serializer; - req: Serializer; +interface StdSerializers { + err: Serializer; + res: Serializer; + req: Serializer; } interface Stream { @@ -82,7 +82,7 @@ interface Stream { count?: number; } - export var stdSerializers:StdSerializers; +export declare var stdSerializers: StdSerializers; export declare var TRACE: number; export declare var DEBUG: number; diff --git a/cassandra-driver/index.d.ts b/cassandra-driver/index.d.ts index 041f9f84e2..9bf5fb7137 100644 --- a/cassandra-driver/index.d.ts +++ b/cassandra-driver/index.d.ts @@ -134,7 +134,7 @@ export namespace types { var LocalTime: LocalTimeStatic; var Long: _Long; var ResultSet: ResultSetStatic; - // var ResultStream: ResultStreamStatic; + // var ResultStream: ResultStreamStatic; var Row: RowStatic; var TimeUuid: TimeUuidStatic; var Tuple: TupleStatic; diff --git a/connect-mongo/index.d.ts b/connect-mongo/index.d.ts index df6a79b5ed..b469d08d00 100644 --- a/connect-mongo/index.d.ts +++ b/connect-mongo/index.d.ts @@ -74,6 +74,7 @@ declare namespace connectMongo { * (Default: 10) */ autoRemoveInterval?: number; + /** * don't save session if unmodified */ diff --git a/dc/dc-1.6.0.d.ts b/dc/dc-1.6.0.d.ts index 03b5e9039b..9938d3bc45 100644 --- a/dc/dc-1.6.0.d.ts +++ b/dc/dc-1.6.0.d.ts @@ -58,7 +58,15 @@ export interface ILegendwidget { export var events: IEvents; export interface IListener { - on: (eventName: string, fnctn: (c:T) => void) => T; + on: { + (event: "preRender", fnctn: (c: T) => any): T; + (event: "postRender", fnctn: (c: T) => any): T; + (event: "preRedraw", fnctn: (c: T) => any): T; + (event: "postRedraw", fnctn: (c: T) => any): T; + (event: "filtered", fnctn: (c: T, filter: any) => any): T; + (event: "zoomed", fnctn: (c: T, filter: any) => any): T; + (event: string, fnctn: (c: T, ...args: any[]) => any): T; + }; } export interface ImarginObj { diff --git a/dc/index.d.ts b/dc/index.d.ts index ffea80fa05..b0291d703c 100644 --- a/dc/index.d.ts +++ b/dc/index.d.ts @@ -160,7 +160,16 @@ declare namespace DC { legend: IGetSet; options(optionsObject: any): T; renderlet(fn: (chart: T) => any): T; - on(event: string, fn: (chart: T) => any): T; + + on(event: "renderlet", fn: (chart: T, filter: any) => any): T; + on(event: "pretransition", fn: (chart: T, filter: any) => any): T; + on(event: "preRender", fn: (chart: T) => any): T; + on(event: "postRender", fn: (chart: T) => any): T; + on(event: "preRedraw", fn: (chart: T) => any): T; + on(event: "postRedraw", fn: (chart: T) => any): T; + on(event: "filtered", fn: (chart: T, filter: any) => any): T; + on(event: "zoomed", fn: (chart: T, filter: any) => any): T; + on(event: string, fn: (chart: T, ...args: any[]) => any): T; } export interface Margins { diff --git a/electron/electron-tests.ts b/electron/electron-tests.ts new file mode 100644 index 0000000000..00b34d60b1 --- /dev/null +++ b/electron/electron-tests.ts @@ -0,0 +1,7 @@ +/// +/// + +import electron = require('electron'); +import child_process = require('child_process'); + +child_process.spawn(electron); diff --git a/electron/github-electron.d.ts b/electron/github-electron.d.ts new file mode 100644 index 0000000000..f87b50b362 --- /dev/null +++ b/electron/github-electron.d.ts @@ -0,0 +1,5765 @@ +// Type definitions for Electron v1.4.4 +// Project: http://electron.atom.io/ +// Definitions by: jedmao , rhysd , Milan Burda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Electron { + + interface Event { + preventDefault: Function; + sender: NodeJS.EventEmitter; + } + + type Point = { + x: number; + y: number; + } + + type Size = { + width: number; + height: number; + } + + type Rectangle = { + x: number; + y: number; + width: number; + height: number; + } + + interface Destroyable { + /** + * Destroys the object. + */ + destroy(): void; + /** + * @returns Whether the object is destroyed. + */ + isDestroyed(): boolean; + } + + // https://github.com/electron/electron/blob/master/docs/api/app.md + + /** + * The app module is responsible for controlling the application's lifecycle. + */ + interface App extends NodeJS.EventEmitter { + /** + * Emitted when the application has finished basic startup. + * On Windows and Linux, the will-finish-launching event + * is the same as the ready event; on macOS, this event represents + * the applicationWillFinishLaunching notification of NSApplication. + * You would usually set up listeners for the open-file and open-url events here, + * and start the crash reporter and auto updater. + * + * In most cases, you should just do everything in the ready event handler. + */ + on(event: 'will-finish-launching', listener: Function): this; + /** + * Emitted when Electron has finished initialization. + */ + on(event: 'ready', listener: (event: Event, launchInfo: Object) => void): this; + /** + * Emitted when all windows have been closed. + * + * If you do not subscribe to this event and all windows are closed, + * the default behavior is to quit the app; however, if you subscribe, + * you control whether the app quits or not. + * If the user pressed Cmd + Q, or the developer called app.quit(), + * Electron will first try to close all the windows and then emit the will-quit event, + * and in this case the window-all-closed event would not be emitted. + */ + on(event: 'window-all-closed', listener: Function): this; + /** + * Emitted before the application starts closing its windows. + * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. + */ + on(event: 'before-quit', listener: (event: Event) => void): this; + /** + * Emitted when all windows have been closed and the application will quit. + * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. + */ + on(event: 'will-quit', listener: (event: Event) => void): this; + /** + * Emitted when the application is quitting. + */ + on(event: 'quit', listener: (event: Event, exitCode: number) => void): this; + /** + * Emitted when the user wants to open a file with the application. + * The open-file event is usually emitted when the application is already open + * and the OS wants to reuse the application to open the file. + * open-file is also emitted when a file is dropped onto the dock and the application + * is not yet running. Make sure to listen for the open-file event very early + * in your application startup to handle this case (even before the ready event is emitted). + * + * You should call event.preventDefault() if you want to handle this event. + * + * Note: This is only implemented on macOS. + */ + on(event: 'open-file', listener: (event: Event, url: string) => void): this; + /** + * Emitted when the user wants to open a URL with the application. + * The URL scheme must be registered to be opened by your application. + * + * You should call event.preventDefault() if you want to handle this event. + * + * Note: This is only implemented on macOS. + */ + on(event: 'open-url', listener: (event: Event, url: string) => void): this; + /** + * Emitted when the application is activated, which usually happens when clicks on the applications’s dock icon. + * Note: This is only implemented on macOS. + */ + on(event: 'activate', listener: Function): this; + /** + * Emitted during Handoff when an activity from a different device wants to be resumed. + * You should call event.preventDefault() if you want to handle this event. + */ + on(event: 'continue-activity', listener: (event: Event, type: string, userInfo: Object) => void): this; + /** + * Emitted when a browserWindow gets blurred. + */ + on(event: 'browser-window-blur', listener: (event: Event, browserWindow: BrowserWindow) => void): this; + /** + * Emitted when a browserWindow gets focused. + */ + on(event: 'browser-window-focus', listener: (event: Event, browserWindow: BrowserWindow) => void): this; + /** + * Emitted when a new browserWindow is created. + */ + on(event: 'browser-window-created', listener: (event: Event, browserWindow: BrowserWindow) => void): this; + /** + * Emitted when a new webContents is created. + */ + on(event: 'web-contents-created', listener: (event: Event, webContents: WebContents) => void): this; + /** + * Emitted when failed to verify the certificate for url, to trust the certificate + * you should prevent the default behavior with event.preventDefault() and call callback(true). + */ + on(event: 'certificate-error', listener: (event: Event, + webContents: WebContents, + url: string, + error: string, + certificate: Certificate, + callback: (trust: boolean) => void + ) => void): this; + /** + * Emitted when a client certificate is requested. + * + * The url corresponds to the navigation entry requesting the client certificate + * and callback needs to be called with an entry filtered from the list. + * Using event.preventDefault() prevents the application from using the first certificate from the store. + */ + on(event: 'select-client-certificate', listener: (event: Event, + webContents: WebContents, + url: string, + certificateList: Certificate[], + callback: (certificate: Certificate) => void + ) => void): this; + /** + * Emitted when webContents wants to do basic auth. + * + * The default behavior is to cancel all authentications, to override this + * you should prevent the default behavior with event.preventDefault() + * and call callback(username, password) with the credentials. + */ + on(event: 'login', listener: (event: Event, + webContents: WebContents, + request: LoginRequest, + authInfo: LoginAuthInfo, + callback: (username: string, password: string) => void + ) => void): this; + /** + * Emitted when the gpu process crashes. + */ + on(event: 'gpu-process-crashed', listener: (event: Event, killed: boolean) => void): this; + /** + * Emitted when Chrome's accessibility support changes. + * + * Note: This API is only available on macOS and Windows. + */ + on(event: 'accessibility-support-changed', listener: (event: Event, accessibilitySupportEnabled: boolean) => void): this; + on(event: string, listener: Function): this; + /** + * Try to close all windows. The before-quit event will first be emitted. + * If all windows are successfully closed, the will-quit event will be emitted + * and by default the application would be terminated. + * + * This method guarantees all beforeunload and unload handlers are correctly + * executed. It is possible that a window cancels the quitting by returning + * false in beforeunload handler. + */ + quit(): void; + /** + * Exits immediately with exitCode. + * All windows will be closed immediately without asking user + * and the before-quit and will-quit events will not be emitted. + */ + exit(exitCode?: number): void; + /** + * Relaunches the app when current instance exits. + * + * By default the new instance will use the same working directory + * and command line arguments with current instance. + * When args is specified, the args will be passed as command line arguments instead. + * When execPath is specified, the execPath will be executed for relaunch instead of current app. + * + * Note that this method does not quit the app when executed, you have to call app.quit + * or app.exit after calling app.relaunch to make the app restart. + * + * When app.relaunch is called for multiple times, multiple instances + * will be started after current instance exited. + */ + relaunch(options?: { + args?: string[], + execPath?: string + }): void; + /** + * @returns Whether Electron has finished initializing. + */ + isReady(): boolean; + /** + * On Linux, focuses on the first visible window. + * On macOS, makes the application the active app. + * On Windows, focuses on the application’s first window. + */ + focus(): void; + /** + * Hides all application windows without minimizing them. + * Note: This is only implemented on macOS. + */ + hide(): void; + /** + * Shows application windows after they were hidden. Does not automatically focus them. + * Note: This is only implemented on macOS. + */ + show(): void; + /** + * Returns the current application directory. + */ + getAppPath(): string; + /** + * @returns The path to a special directory or file associated with name. + * On failure an Error would throw. + */ + getPath(name: AppPathName): string; + /** + * Overrides the path to a special directory or file associated with name. + * If the path specifies a directory that does not exist, the directory will + * be created by this method. On failure an Error would throw. + * + * You can only override paths of names defined in app.getPath. + * + * By default web pages' cookies and caches will be stored under userData + * directory, if you want to change this location, you have to override the + * userData path before the ready event of app module gets emitted. + */ + setPath(name: AppPathName, path: string): void; + /** + * @returns The version of loaded application, if no version is found in + * application's package.json, the version of current bundle or executable. + */ + getVersion(): string; + /** + * @returns The current application's name, the name in package.json would be used. + * Usually the name field of package.json is a short lowercased name, according to + * the spec of npm modules. So usually you should also specify a productName field, + * which is your application's full capitalized name, and it will be preferred over + * name by Electron. + */ + getName(): string; + /** + * Overrides the current application's name. + */ + setName(name: string): void; + /** + * @returns The current application locale. + */ + getLocale(): string; + /** + * Adds path to recent documents list. + * + * This list is managed by the system, on Windows you can visit the list from + * task bar, and on macOS you can visit it from dock menu. + * + * Note: This is only implemented on macOS and Windows. + */ + addRecentDocument(path: string): void; + /** + * Clears the recent documents list. + * + * Note: This is only implemented on macOS and Windows. + */ + clearRecentDocuments(): void; + /** + * Sets the current executable as the default handler for a protocol (aka URI scheme). + * Once registered, all links with your-protocol:// will be opened with the current executable. + * The whole link, including protocol, will be passed to your application as a parameter. + * + * On Windows you can provide optional parameters path, the path to your executable, + * and args, an array of arguments to be passed to your executable when it launches. + * + * @param protocol The name of your protocol, without ://. + * @param path Defaults to process.execPath. + * @param args Defaults to an empty array. + * + * Note: This is only implemented on macOS and Windows. + * On macOS, you can only register protocols that have been added to your app's info.plist. + */ + setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; + /** + * Removes the current executable as the default handler for a protocol (aka URI scheme). + * + * @param protocol The name of your protocol, without ://. + * @param path Defaults to process.execPath. + * @param args Defaults to an empty array. + * + * Note: This is only implemented on macOS and Windows. + */ + removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; + /** + * @param protocol The name of your protocol, without ://. + * @param path Defaults to process.execPath. + * @param args Defaults to an empty array. + * + * @returns Whether the current executable is the default handler for a protocol (aka URI scheme). + * + * Note: This is only implemented on macOS and Windows. + */ + isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean; + /** + * Adds tasks to the Tasks category of JumpList on Windows. + * + * Note: This API is only available on Windows. + */ + setUserTasks(tasks: Task[]): boolean; + /** + * Note: This API is only available on Windows. + */ + getJumpListSettings(): JumpListSettings; + /** + * Sets or removes a custom Jump List for the application. + * + * If categories is null the previously set custom Jump List (if any) will be replaced + * by the standard Jump List for the app (managed by Windows). + * + * Note: This API is only available on Windows. + */ + setJumpList(categories: JumpListCategory[]): SetJumpListResult; + /** + * This method makes your application a Single Instance Application instead of allowing + * multiple instances of your app to run, this will ensure that only a single instance + * of your app is running, and other instances signal this instance and exit. + */ + makeSingleInstance(callback: (args: string[], workingDirectory: string) => void): boolean; + /** + * Releases all locks that were created by makeSingleInstance. This will allow + * multiple instances of the application to once again run side by side. + */ + releaseSingleInstance(): void; + /** + * Creates an NSUserActivity and sets it as the current activity. + * The activity is eligible for Handoff to another device afterward. + * + * @param type Uniquely identifies the activity. Maps to NSUserActivity.activityType. + * @param userInfo App-specific state to store for use by another device. + * @param webpageURL The webpage to load in a browser if no suitable app is + * installed on the resuming device. The scheme must be http or https. + * + * Note: This API is only available on macOS. + */ + setUserActivity(type: string, userInfo: Object, webpageURL?: string): void; + /** + * @returns The type of the currently running activity. + * + * Note: This API is only available on macOS. + */ + getCurrentActivityType(): string; + /** + * Changes the Application User Model ID to id. + * + * Note: This is only implemented on Windows. + */ + setAppUserModelId(id: string): void; + /** + * Imports the certificate in pkcs12 format into the platform certificate store. + * @param callback Called with the result of import operation, a value of 0 indicates success + * while any other value indicates failure according to chromium net_error_list. + * + * Note: This API is only available on Linux. + */ + importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void; + /** + * Disables hardware acceleration for current app. + * This method can only be called before app is ready. + */ + disableHardwareAcceleration(): void; + /** + * @returns whether current desktop environment is Unity launcher. (Linux) + * + * Note: This API is only available on Linux. + */ + isUnityRunning(): boolean; + /** + * Returns a Boolean, true if Chrome's accessibility support is enabled, false otherwise. + * This API will return true if the use of assistive technologies, such as screen readers, + * has been detected. + * See https://www.chromium.org/developers/design-documents/accessibility for more details. + * + * Note: This API is only available on macOS and Windows. + */ + isAccessibilitySupportEnabled(): boolean; + /** + * @returns an Object with the login item settings of the app. + * + * Note: This API is only available on macOS and Windows. + */ + getLoginItemSettings(): LoginItemSettings; + /** + * Set the app's login item settings. + * + * Note: This API is only available on macOS and Windows. + */ + setLoginItemSettings(settings: LoginItemSettings): void; + /** + * Set the about panel options. This will override the values defined in the app's .plist file. + * See the Apple docs for more details. + * + * Note: This API is only available on macOS. + */ + setAboutPanelOptions(options: AboutPanelOptions): void; + commandLine: CommandLine; + /** + * Note: This API is only available on macOS. + */ + dock: Dock; + } + + type AppPathName = 'home'|'appData'|'userData'|'temp'|'exe'|'module'|'desktop'|'documents'|'downloads'|'music'|'pictures'|'videos'|'pepperFlashSystemPlugin'; + + interface ImportCertificateOptions { + /** + * Path for the pkcs12 file. + */ + certificate: string; + /** + * Passphrase for the certificate. + */ + password: string; + } + + interface CommandLine { + /** + * Append a switch [with optional value] to Chromium's command line. + * + * Note: This will not affect process.argv, and is mainly used by developers + * to control some low-level Chromium behaviors. + */ + appendSwitch(_switch: string, value?: string): void; + /** + * Append an argument to Chromium's command line. The argument will quoted properly. + * + * Note: This will not affect process.argv. + */ + appendArgument(value: string): void; + } + + interface Dock { + /** + * When critical is passed, the dock icon will bounce until either the + * application becomes active or the request is canceled. + * + * When informational is passed, the dock icon will bounce for one second. + * However, the request remains active until either the application becomes + * active or the request is canceled. + * + * @param type The default is informational. + * @returns An ID representing the request. + */ + bounce(type?: 'critical' | 'informational'): number; + /** + * Cancel the bounce of id. + * + * Note: This API is only available on macOS. + */ + cancelBounce(id: number): void; + /** + * Bounces the Downloads stack if the filePath is inside the Downloads folder. + * + * Note: This API is only available on macOS. + */ + downloadFinished(filePath: string): void; + /** + * Sets the string to be displayed in the dock’s badging area. + * + * Note: This API is only available on macOS. + */ + setBadge(text: string): void; + /** + * Returns the badge string of the dock. + * + * Note: This API is only available on macOS. + */ + getBadge(): string; + /** + * Sets the counter badge for current app. Setting the count to 0 will hide the badge. + * + * @returns True when the call succeeded, otherwise returns false. + * + * Note: This API is only available on macOS and Linux. + */ + setBadgeCount(count: number): boolean; + /** + * @returns The current value displayed in the counter badge. + * + * Note: This API is only available on macOS and Linux. + */ + getBadgeCount(): number; + /** + * Hides the dock icon. + * + * Note: This API is only available on macOS. + */ + hide(): void; + /** + * Shows the dock icon. + * + * Note: This API is only available on macOS. + */ + show(): void; + /** + * @returns Whether the dock icon is visible. + * The app.dock.show() call is asynchronous so this method might not return true immediately after that call. + * + * Note: This API is only available on macOS. + */ + isVisible(): boolean; + /** + * Sets the application dock menu. + * + * Note: This API is only available on macOS. + */ + setMenu(menu: Menu): void; + /** + * Sets the image associated with this dock icon. + * + * Note: This API is only available on macOS. + */ + setIcon(icon: NativeImage | string): void; + } + + interface Task { + /** + * Path of the program to execute, usually you should specify process.execPath + * which opens current program. + */ + program: string; + /** + * The arguments of command line when program is executed. + */ + arguments: string; + /** + * The string to be displayed in a JumpList. + */ + title: string; + /** + * Description of this task. + */ + description?: string; + /** + * The absolute path to an icon to be displayed in a JumpList, it can be + * arbitrary resource file that contains an icon, usually you can specify + * process.execPath to show the icon of the program. + */ + iconPath: string; + /** + * The icon index in the icon file. If an icon file consists of two or more + * icons, set this value to identify the icon. If an icon file consists of + * one icon, this value is 0. + */ + iconIndex?: number; + } + + /** + * ok - Nothing went wrong. + * error - One or more errors occured, enable runtime logging to figure out the likely cause. + * invalidSeparatorError - An attempt was made to add a separator to a custom category in the Jump List. + * Separators are only allowed in the standard Tasks category. + * fileTypeRegistrationError - An attempt was made to add a file link to the Jump List + * for a file type the app isn't registered to handle. + * customCategoryAccessDeniedError - Custom categories can't be added to the Jump List + * due to user privacy or group policy settings. + */ + type SetJumpListResult = 'ok' | 'error' | 'invalidSeparatorError' | 'fileTypeRegistrationError' | 'customCategoryAccessDeniedError'; + + interface JumpListSettings { + /** + * The minimum number of items that will be shown in the Jump List. + */ + minItems: number; + /** + * Items that the user has explicitly removed from custom categories in the Jump List. + */ + removedItems: JumpListItem[]; + } + + interface JumpListCategory { + /** + * tasks - Items in this category will be placed into the standard Tasks category. + * frequent - Displays a list of files frequently opened by the app, the name of the category and its items are set by Windows. + * recent - Displays a list of files recently opened by the app, the name of the category and its items are set by Windows. + * custom - Displays tasks or file links, name must be set by the app. + */ + type?: 'tasks' | 'frequent' | 'recent' | 'custom'; + /** + * Must be set if type is custom, otherwise it should be omitted. + */ + name?: string; + /** + * Array of JumpListItem objects if type is tasks or custom, otherwise it should be omitted. + */ + items?: JumpListItem[]; + } + + interface JumpListItem { + /** + * task - A task will launch an app with specific arguments. + * separator - Can be used to separate items in the standard Tasks category. + * file - A file link will open a file using the app that created the Jump List. + */ + type: 'task' | 'separator' | 'file'; + /** + * Path of the file to open, should only be set if type is file. + */ + path?: string; + /** + * Path of the program to execute, usually you should specify process.execPath which opens the current program. + * Should only be set if type is task. + */ + program?: string; + /** + * The command line arguments when program is executed. Should only be set if type is task. + */ + args?: string; + /** + * The text to be displayed for the item in the Jump List. Should only be set if type is task. + */ + title?: string; + /** + * Description of the task (displayed in a tooltip). Should only be set if type is task. + */ + description?: string; + /** + * The absolute path to an icon to be displayed in a Jump List, which can be an arbitrary + * resource file that contains an icon (e.g. .ico, .exe, .dll). + * You can usually specify process.execPath to show the program icon. + */ + iconPath?: string; + /** + * The index of the icon in the resource file. If a resource file contains multiple icons + * this value can be used to specify the zero-based index of the icon that should be displayed + * for this task. If a resource file contains only one icon, this property should be set to zero. + */ + iconIndex?: number; + } + + interface LoginItemSettings { + /** + * True if the app is set to open at login. + */ + openAtLogin: boolean; + /** + * True if the app is set to open as hidden at login. This setting is only supported on macOS. + */ + openAsHidden: boolean; + /** + * True if the app was opened at login automatically. This setting is only supported on macOS. + */ + wasOpenedAtLogin?: boolean; + /** + * True if the app was opened as a hidden login item. This indicates that the app should not + * open any windows at startup. This setting is only supported on macOS. + */ + wasOpenedAsHidden?: boolean; + /** + * True if the app was opened as a login item that should restore the state from the previous session. + * This indicates that the app should restore the windows that were open the last time the app was closed. + * This setting is only supported on macOS. + */ + restoreState?: boolean; + } + + interface AboutPanelOptions { + /** + * The app's name. + */ + applicationName?: string; + /** + * The app's version. + */ + applicationVersion?: string; + /** + * Copyright information. + */ + copyright?: string; + /** + * Credit information. + */ + credits?: string; + /** + * The app's build version number. + */ + version?: string; + } + + // https://github.com/electron/electron/blob/master/docs/api/auto-updater.md + + /** + * This module provides an interface for the Squirrel auto-updater framework. + */ + interface AutoUpdater extends NodeJS.EventEmitter { + /** + * Emitted when there is an error while updating. + */ + on(event: 'error', listener: (error: Error) => void): this; + /** + * Emitted when checking if an update has started. + */ + on(event: 'checking-for-update', listener: Function): this; + /** + * Emitted when there is an available update. The update is downloaded automatically. + */ + on(event: 'update-available', listener: Function): this; + /** + * Emitted when there is no available update. + */ + on(event: 'update-not-available', listener: Function): this; + /** + * Emitted when an update has been downloaded. + * Note: On Windows only releaseName is available. + */ + on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; + on(event: string, listener: Function): this; + /** + * Set the url and initialize the auto updater. + */ + setFeedURL(url: string, requestHeaders?: Headers): void; + /** + * @returns The current update feed URL. + */ + getFeedURL(): string; + /** + * Ask the server whether there is an update, you have to call setFeedURL + * before using this API + */ + checkForUpdates(): void; + /** + * Restarts the app and installs the update after it has been downloaded. + * It should only be called after update-downloaded has been emitted. + */ + quitAndInstall(): void; + } + + // https://github.com/electron/electron/blob/master/docs/api/browser-window.md + + /** + * The BrowserWindow class gives you ability to create a browser window. + * You can also create a window without chrome by using Frameless Window API. + */ + class BrowserWindow extends NodeJS.EventEmitter implements Destroyable { + /** + * Emitted when the document changed its title, + * calling event.preventDefault() would prevent the native window’s title to change. + */ + on(event: 'page-title-updated', listener: (event: Event, title: string) => void): this; + /** + * Emitted when the window is going to be closed. It’s emitted before the beforeunload + * and unload event of the DOM. Calling event.preventDefault() will cancel the close. + */ + on(event: 'close', listener: (event: Event) => void): this; + /** + * Emitted when the window is closed. After you have received this event + * you should remove the reference to the window and avoid using it anymore. + */ + on(event: 'closed', listener: Function): this; + /** + * Emitted when the web page becomes unresponsive. + */ + on(event: 'unresponsive', listener: Function): this; + /** + * Emitted when the unresponsive web page becomes responsive again. + */ + on(event: 'responsive', listener: Function): this; + /** + * Emitted when the window loses focus. + */ + on(event: 'blur', listener: Function): this; + /** + * Emitted when the window gains focus. + */ + on(event: 'focus', listener: Function): this; + /** + * Emitted when the window is shown. + */ + on(event: 'show', listener: Function): this; + /** + * Emitted when the window is hidden. + */ + on(event: 'hide', listener: Function): this; + /** + * Emitted when the web page has been rendered and window can be displayed without visual flash. + */ + on(event: 'ready-to-show', listener: Function): this; + /** + * Emitted when window is maximized. + */ + on(event: 'maximize', listener: Function): this; + /** + * Emitted when the window exits from maximized state. + */ + on(event: 'unmaximize', listener: Function): this; + /** + * Emitted when the window is minimized. + */ + on(event: 'minimize', listener: Function): this; + /** + * Emitted when the window is restored from minimized state. + */ + on(event: 'restore', listener: Function): this; + /** + * Emitted when the window is getting resized. + */ + on(event: 'resize', listener: Function): this; + /** + * Emitted when the window is getting moved to a new position. + */ + on(event: 'move', listener: Function): this; + /** + * Emitted when the window enters full screen state. + */ + on(event: 'enter-full-screen', listener: Function): this; + /** + * Emitted when the window leaves full screen state. + */ + on(event: 'leave-full-screen', listener: Function): this; + /** + * Emitted when the window enters full screen state triggered by HTML API. + */ + on(event: 'enter-html-full-screen', listener: Function): this; + /** + * Emitted when the window leaves full screen state triggered by HTML API. + */ + on(event: 'leave-html-full-screen', listener: Function): this; + /** + * Emitted when an App Command is invoked. These are typically related + * to keyboard media keys or browser commands, as well as the "Back" / + * "Forward" buttons built into some mice on Windows. + * Note: This is only implemented on Windows. + */ + on(event: 'app-command', listener: (event: Event, command: string) => void): this; + /** + * Emitted when scroll wheel event phase has begun. + * Note: This is only implemented on macOS. + */ + on(event: 'scroll-touch-begin', listener: Function): this; + /** + * Emitted when scroll wheel event phase has ended. + * Note: This is only implemented on macOS. + */ + on(event: 'scroll-touch-end', listener: Function): this; + /** + * Emitted when scroll wheel event phase filed upon reaching the edge of element. + * Note: This is only implemented on macOS. + */ + on(event: 'scroll-touch-edge', listener: Function): this; + /** + * Emitted on 3-finger swipe. + * Note: This is only implemented on macOS. + */ + on(event: 'swipe', listener: (event: Event, direction: SwipeDirection) => void): this; + on(event: string, listener: Function): this; + /** + * Creates a new BrowserWindow with native properties as set by the options. + */ + constructor(options?: BrowserWindowOptions); + /** + * @returns All opened browser windows. + */ + static getAllWindows(): BrowserWindow[]; + /** + * @returns The window that is focused in this application. + */ + static getFocusedWindow(): BrowserWindow; + /** + * Find a window according to the webContents it owns. + */ + static fromWebContents(webContents: WebContents): BrowserWindow; + /** + * Find a window according to its ID. + */ + static fromId(id: number): BrowserWindow; + /** + * Adds devtools extension located at path. The extension will be remembered + * so you only need to call this API once, this API is not for programming use. + * @returns The extension's name. + * + * Note: This API cannot be called before the ready event of the app module is emitted. + */ + static addDevToolsExtension(path: string): string; + /** + * Remove a devtools extension. + * @param name The name of the devtools extension to remove. + * + * Note: This API cannot be called before the ready event of the app module is emitted. + */ + static removeDevToolsExtension(name: string): void; + /** + * @returns devtools extensions. + * + * Note: This API cannot be called before the ready event of the app module is emitted. + */ + static getDevToolsExtensions(): DevToolsExtensions; + /** + * The WebContents object this window owns, all web page related events and + * operations would be done via it. + * Note: Users should never store this object because it may become null when + * the renderer process (web page) has crashed. + */ + webContents: WebContents; + /** + * Get the unique ID of this window. + */ + id: number; + /** + * Force closing the window, the unload and beforeunload event won't be emitted + * for the web page, and close event would also not be emitted for this window, + * but it would guarantee the closed event to be emitted. + * You should only use this method when the renderer process (web page) has crashed. + */ + destroy(): void; + /** + * Try to close the window, this has the same effect with user manually clicking + * the close button of the window. The web page may cancel the close though, + * see the close event. + */ + close(): void; + /** + * Focus on the window. + */ + focus(): void; + /** + * Remove focus on the window. + */ + blur(): void; + /** + * @returns Whether the window is focused. + */ + isFocused(): boolean; + /** + * @returns Whether the window is destroyed. + */ + isDestroyed(): boolean; + /** + * Shows and gives focus to the window. + */ + show(): void; + /** + * Shows the window but doesn't focus on it. + */ + showInactive(): void; + /** + * Hides the window. + */ + hide(): void; + /** + * @returns Whether the window is visible to the user. + */ + isVisible(): boolean; + /** + * @returns Whether the window is a modal window. + */ + isModal(): boolean; + /** + * Maximizes the window. + */ + maximize(): void; + /** + * Unmaximizes the window. + */ + unmaximize(): void; + /** + * @returns Whether the window is maximized. + */ + isMaximized(): boolean; + /** + * Minimizes the window. On some platforms the minimized window will be + * shown in the Dock. + */ + minimize(): void; + /** + * Restores the window from minimized state to its previous state. + */ + restore(): void; + /** + * @returns Whether the window is minimized. + */ + isMinimized(): boolean; + /** + * Sets whether the window should be in fullscreen mode. + */ + setFullScreen(flag: boolean): void; + /** + * @returns Whether the window is in fullscreen mode. + */ + isFullScreen(): boolean; + /** + * This will have a window maintain an aspect ratio. + * The extra size allows a developer to have space, specified in pixels, + * not included within the aspect ratio calculations. + * This API already takes into account the difference between a window’s size and its content size. + * + * Note: This API is available only on macOS. + */ + setAspectRatio(aspectRatio: number, extraSize?: Size): void; + /** + * Resizes and moves the window to width, height, x, y. + */ + setBounds(options: Rectangle, animate?: boolean): void; + /** + * @returns The window's width, height, x and y values. + */ + getBounds(): Rectangle; + /** + * Resizes and moves the window's client area (e.g. the web page) to width, height, x, y. + */ + setContentBounds(options: Rectangle, animate?: boolean): void; + /** + * @returns The window's client area (e.g. the web page) width, height, x and y values. + */ + getContentBounds(): Rectangle; + /** + * Resizes the window to width and height. + */ + setSize(width: number, height: number, animate?: boolean): void; + /** + * @returns The window's width and height. + */ + getSize(): number[]; + /** + * Resizes the window's client area (e.g. the web page) to width and height. + */ + setContentSize(width: number, height: number, animate?: boolean): void; + /** + * @returns The window's client area's width and height. + */ + getContentSize(): number[]; + /** + * Sets the minimum size of window to width and height. + */ + setMinimumSize(width: number, height: number): void; + /** + * @returns The window's minimum width and height. + */ + getMinimumSize(): number[]; + /** + * Sets the maximum size of window to width and height. + */ + setMaximumSize(width: number, height: number): void; + /** + * @returns The window's maximum width and height. + */ + getMaximumSize(): number[]; + /** + * Sets whether the window can be manually resized by user. + */ + setResizable(resizable: boolean): void; + /** + * @returns Whether the window can be manually resized by user. + */ + isResizable(): boolean; + /** + * Sets whether the window can be moved by user. On Linux does nothing. + * Note: This API is available only on macOS and Windows. + */ + setMovable(movable: boolean): void; + /** + * Note: This API is available only on macOS and Windows. + * @returns Whether the window can be moved by user. On Linux always returns true. + */ + isMovable(): boolean; + /** + * Sets whether the window can be manually minimized by user. On Linux does nothing. + * Note: This API is available only on macOS and Windows. + */ + setMinimizable(minimizable: boolean): void; + /** + * Note: This API is available only on macOS and Windows. + * @returns Whether the window can be manually minimized by user. On Linux always returns true. + */ + isMinimizable(): boolean; + /** + * Sets whether the window can be manually maximized by user. On Linux does nothing. + * Note: This API is available only on macOS and Windows. + */ + setMaximizable(maximizable: boolean): void; + /** + * Note: This API is available only on macOS and Windows. + * @returns Whether the window can be manually maximized by user. On Linux always returns true. + */ + isMaximizable(): boolean; + /** + * Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. + */ + setFullScreenable(fullscreenable: boolean): void; + /** + * @returns Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. + */ + isFullScreenable(): boolean; + /** + * Sets whether the window can be manually closed by user. On Linux does nothing. + * Note: This API is available only on macOS and Windows. + */ + setClosable(closable: boolean): void; + /** + * Note: This API is available only on macOS and Windows. + * @returns Whether the window can be manually closed by user. On Linux always returns true. + */ + isClosable(): boolean; + /** + * Sets whether the window should show always on top of other windows. After + * setting this, the window is still a normal window, not a toolbox window + * which can not be focused on. + */ + setAlwaysOnTop(flag: boolean, level?: WindowLevel): void; + /** + * @returns Whether the window is always on top of other windows. + */ + isAlwaysOnTop(): boolean; + /** + * Moves window to the center of the screen. + */ + center(): void; + /** + * Moves window to x and y. + */ + setPosition(x: number, y: number, animate?: boolean): void; + /** + * @returns The window's current position. + */ + getPosition(): number[]; + /** + * Changes the title of native window to title. + */ + setTitle(title: string): void; + /** + * Note: The title of web page can be different from the title of the native window. + * @returns The title of the native window. + */ + getTitle(): string; + /** + * Changes the attachment point for sheets on macOS. + * Note: This API is available only on macOS. + */ + setSheetOffset(offsetY: number, offsetX?: number): void; + /** + * Starts or stops flashing the window to attract user's attention. + */ + flashFrame(flag: boolean): void; + /** + * Makes the window do not show in Taskbar. + */ + setSkipTaskbar(skip: boolean): void; + /** + * Enters or leaves the kiosk mode. + */ + setKiosk(flag: boolean): void; + /** + * @returns Whether the window is in kiosk mode. + */ + isKiosk(): boolean; + /** + * The native type of the handle is HWND on Windows, NSView* on macOS, + * and Window (unsigned long) on Linux. + * @returns The platform-specific handle of the window as Buffer. + */ + getNativeWindowHandle(): Buffer; + /** + * Hooks a windows message. The callback is called when the message is received in the WndProc. + * Note: This API is available only on Windows. + */ + hookWindowMessage(message: number, callback: Function): void; + /** + * @returns Whether the message is hooked. + */ + isWindowMessageHooked(message: number): boolean; + /** + * Unhook the window message. + */ + unhookWindowMessage(message: number): void; + /** + * Unhooks all of the window messages. + */ + unhookAllWindowMessages(): void; + /** + * Sets the pathname of the file the window represents, and the icon of the + * file will show in window's title bar. + * Note: This API is available only on macOS. + */ + setRepresentedFilename(filename: string): void; + /** + * Note: This API is available only on macOS. + * @returns The pathname of the file the window represents. + */ + getRepresentedFilename(): string; + /** + * Specifies whether the window’s document has been edited, and the icon in + * title bar will become grey when set to true. + * Note: This API is available only on macOS. + */ + setDocumentEdited(edited: boolean): void; + /** + * Note: This API is available only on macOS. + * @returns Whether the window's document has been edited. + */ + isDocumentEdited(): boolean; + focusOnWebView(): void; + blurWebView(): void; + /** + * Captures the snapshot of page within rect, upon completion the callback + * will be called. Omitting the rect would capture the whole visible page. + * Note: Be sure to read documents on remote buffer in remote if you are going + * to use this API in renderer process. + * @param callback Supplies the image that stores data of the snapshot. + */ + capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; + /** + * Captures the snapshot of page within rect, upon completion the callback + * will be called. Omitting the rect would capture the whole visible page. + * Note: Be sure to read documents on remote buffer in remote if you are going + * to use this API in renderer process. + * @param callback Supplies the image that stores data of the snapshot. + */ + capturePage(callback: (image: NativeImage) => void): void; + /** + * Same as webContents.loadURL(url). + */ + loadURL(url: string, options?: LoadURLOptions): void; + /** + * Same as webContents.reload. + */ + reload(): void; + /** + * Sets the menu as the window top menu. + * Note: This API is not available on macOS. + */ + setMenu(menu: Menu): void; + /** + * Sets the progress value in the progress bar. + * On Linux platform, only supports Unity desktop environment, you need to + * specify the *.desktop file name to desktopName field in package.json. + * By default, it will assume app.getName().desktop. + * @param progress Valid range is [0, 1.0]. If < 0, the progress bar is removed. + * If greater than 0, it becomes indeterminate. + */ + setProgressBar(progress: number, options?: { + /** + * Mode for the progress bar. + * Note: This is only implemented on Windows. + */ + mode: 'none' | 'normal' | 'indeterminate' | 'error' | 'paused' + }): void; + /** + * Sets a 16px overlay onto the current Taskbar icon, usually used to convey + * some sort of application status or to passively notify the user. + * Note: This API is only available on Windows 7 or above. + * @param overlay The icon to display on the bottom right corner of the Taskbar + * icon. If this parameter is null, the overlay is cleared + * @param description Provided to Accessibility screen readers. + */ + setOverlayIcon(overlay: NativeImage, description: string): void; + /** + * Sets whether the window should have a shadow. On Windows and Linux does nothing. + * Note: This API is available only on macOS. + */ + setHasShadow(hasShadow: boolean): void; + /** + * Note: This API is available only on macOS. + * @returns whether the window has a shadow. On Windows and Linux always returns true. + */ + hasShadow(): boolean; + /** + * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image + * of a window in a taskbar button layout. + * @returns Whether the thumbnail has been added successfully. + * + * Note: This API is available only on Windows. + */ + setThumbarButtons(buttons: ThumbarButton[]): boolean; + /** + * Sets the region of the window to show as the thumbnail image displayed when hovering + * over the window in the taskbar. You can reset the thumbnail to be the entire window + * by specifying an empty region: {x: 0, y: 0, width: 0, height: 0}. + * + * Note: This API is available only on Windows. + */ + setThumbnailClip(region: Rectangle): boolean; + /** + * Sets the toolTip that is displayed when hovering over the window thumbnail in the taskbar. + * Note: This API is available only on Windows. + */ + setThumbnailToolTip(toolTip: string): boolean; + /** + * Same as webContents.showDefinitionForSelection(). + * Note: This API is available only on macOS. + */ + showDefinitionForSelection(): void; + /** + * Changes window icon. + * Note: This API is not available on macOS. + */ + setIcon(icon: NativeImage): void; + /** + * Sets whether the window menu bar should hide itself automatically. Once set + * the menu bar will only show when users press the single Alt key. + * If the menu bar is already visible, calling setAutoHideMenuBar(true) won't + * hide it immediately. + */ + setAutoHideMenuBar(hide: boolean): void; + /** + * @returns Whether menu bar automatically hides itself. + */ + isMenuBarAutoHide(): boolean; + /** + * Sets whether the menu bar should be visible. If the menu bar is auto-hide, + * users can still bring up the menu bar by pressing the single Alt key. + */ + setMenuBarVisibility(visibile: boolean): void; + /** + * @returns Whether the menu bar is visible. + */ + isMenuBarVisible(): boolean; + /** + * Sets whether the window should be visible on all workspaces. + * Note: This API does nothing on Windows. + */ + setVisibleOnAllWorkspaces(visible: boolean): void; + /** + * Note: This API always returns false on Windows. + * @returns Whether the window is visible on all workspaces. + */ + isVisibleOnAllWorkspaces(): boolean; + /** + * Makes the window ignore all mouse events. + * + * All mouse events happened in this window will be passed to the window below this window, + * but if this window has focus, it will still receive keyboard events. + */ + setIgnoreMouseEvents(ignore: boolean): void; + /** + * Prevents the window contents from being captured by other apps. + * + * On macOS it sets the NSWindow's sharingType to NSWindowSharingNone. + * On Windows it calls SetWindowDisplayAffinity with WDA_MONITOR. + */ + setContentProtection(enable: boolean): void; + /** + * Changes whether the window can be focused. + * Note: This API is available only on Windows. + */ + setFocusable(focusable: boolean): void; + /** + * Sets parent as current window's parent window, + * passing null will turn current window into a top-level window. + * Note: This API is not available on Windows. + */ + setParentWindow(parent: BrowserWindow): void; + /** + * @returns The parent window. + */ + getParentWindow(): BrowserWindow; + /** + * @returns All child windows. + */ + getChildWindows(): BrowserWindow[]; + } + + type WindowLevel = 'normal' | 'floating' | 'torn-off-menu' | 'modal-panel' | 'main-menu' | 'status' | 'pop-up-menu' | 'screen-saver' | 'dock'; + type SwipeDirection = 'up' | 'right' | 'down' | 'left'; + type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive'; + + interface ThumbarButton { + icon: NativeImage | string; + click: Function; + tooltip?: string; + flags?: ThumbarButtonFlags[]; + } + + interface DevToolsExtensions { + [name: string]: { + name: string; + value: string; + } + } + + interface WebPreferences { + /** + * Whether to enable DevTools. + * If it is set to false, can not use BrowserWindow.webContents.openDevTools() to open DevTools. + * Default: true. + */ + devTools?: boolean; + /** + * Whether node integration is enabled. + * Default: true. + */ + nodeIntegration?: boolean; + /** + * Specifies a script that will be loaded before other scripts run in the page. + * This script will always have access to node APIs no matter whether node integration is turned on or off. + * The value should be the absolute file path to the script. + * When node integration is turned off, the preload script can reintroduce + * Node global symbols back to the global scope. + */ + preload?: string; + /** + * Sets the session used by the page. Instead of passing the Session object directly, + * you can also choose to use the partition option instead, which accepts a partition string. + * When both session and partition are provided, session would be preferred. + * Default: the default session. + */ + session?: Session; + /** + * Sets the session used by the page according to the session’s partition string. + * If partition starts with persist:, the page will use a persistent session available + * to all pages in the app with the same partition. if there is no persist: prefix, + * the page will use an in-memory session. By assigning the same partition, + * multiple pages can share the same session. + * Default: the default session. + */ + partition?: string; + /** + * The default zoom factor of the page, 3.0 represents 300%. + * Default: 1.0. + */ + zoomFactor?: number; + /** + * Enables JavaScript support. + * Default: true. + */ + javascript?: boolean; + /** + * When setting false, it will disable the same-origin policy (Usually using testing + * websites by people), and set allowDisplayingInsecureContent and allowRunningInsecureContent + * to true if these two options are not set by user. + * Default: true. + */ + webSecurity?: boolean; + /** + * Allow an https page to display content like images from http URLs. + * Default: false. + */ + allowDisplayingInsecureContent?: boolean; + /** + * Allow a https page to run JavaScript, CSS or plugins from http URLs. + * Default: false. + */ + allowRunningInsecureContent?: boolean; + /** + * Enables image support. + * Default: true. + */ + images?: boolean; + /** + * Make TextArea elements resizable. + * Default: true. + */ + textAreasAreResizable?: boolean; + /** + * Enables WebGL support. + * Default: true. + */ + webgl?: boolean; + /** + * Enables WebAudio support. + * Default: true. + */ + webaudio?: boolean; + /** + * Whether plugins should be enabled. + * Default: false. + */ + plugins?: boolean; + /** + * Enables Chromium’s experimental features. + * Default: false. + */ + experimentalFeatures?: boolean; + /** + * Enables Chromium’s experimental canvas features. + * Default: false. + */ + experimentalCanvasFeatures?: boolean; + /** + * Enables DirectWrite font rendering system on Windows. + * Default: true. + */ + directWrite?: boolean; + /** + * Enables scroll bounce (rubber banding) effect on macOS. + * Default: false. + */ + scrollBounce?: boolean; + /** + * A list of feature strings separated by ",", like CSSVariables,KeyboardEventKey to enable. + */ + blinkFeatures?: string; + /** + * A list of feature strings separated by ",", like CSSVariables,KeyboardEventKey to disable. + */ + disableBlinkFeatures?: string; + /** + * Sets the default font for the font-family. + */ + defaultFontFamily?: { + /** + * Default: Times New Roman. + */ + standard?: string; + /** + * Default: Times New Roman. + */ + serif?: string; + /** + * Default: Arial. + */ + sansSerif?: string; + /** + * Default: Courier New. + */ + monospace?: string; + }; + /** + * Default: 16. + */ + defaultFontSize?: number; + /** + * Default: 13. + */ + defaultMonospaceFontSize?: number; + /** + * Default: 0. + */ + minimumFontSize?: number; + /** + * Default: ISO-8859-1. + */ + defaultEncoding?: string; + /** + * Whether to throttle animations and timers when the page becomes background. + * Default: true. + */ + backgroundThrottling?: boolean; + /** + * Whether to enable offscreen rendering for the browser window. + * Default: false. + */ + offscreen?: boolean; + /** + * Whether to enable Chromium OS-level sandbox. + * Default: false. + */ + sandbox?: boolean; + } + + interface BrowserWindowOptions { + /** + * Window’s width in pixels. + * Default: 800. + */ + width?: number; + /** + * Window’s height in pixels. + * Default: 600. + */ + height?: number; + /** + * Window’s left offset from screen. + * Default: center the window. + */ + x?: number; + /** + * Window’s top offset from screen. + * Default: center the window. + */ + y?: number; + /** + * The width and height would be used as web page’s size, which means + * the actual window’s size will include window frame’s size and be slightly larger. + * Default: false. + */ + useContentSize?: boolean; + /** + * Show window in the center of the screen. + * Default: true + */ + center?: boolean; + /** + * Window’s minimum width. + * Default: 0. + */ + minWidth?: number; + /** + * Window’s minimum height. + * Default: 0. + */ + minHeight?: number; + /** + * Window’s maximum width. + * Default: no limit. + */ + maxWidth?: number; + /** + * Window’s maximum height. + * Default: no limit. + */ + maxHeight?: number; + /** + * Whether window is resizable. + * Default: true. + */ + resizable?: boolean; + /** + * Whether window is movable. + * Note: This is not implemented on Linux. + * Default: true. + */ + movable?: boolean; + /** + * Whether window is minimizable. + * Note: This is not implemented on Linux. + * Default: true. + */ + minimizable?: boolean; + /** + * Whether window is maximizable. + * Note: This is not implemented on Linux. + * Default: true. + */ + maximizable?: boolean; + /** + * Whether window is closable. + * Note: This is not implemented on Linux. + * Default: true. + */ + closable?: boolean; + /** + * Whether the window can be focused. + * On Windows setting focusable: false also implies setting skipTaskbar: true. + * On Linux setting focusable: false makes the window stop interacting with wm, + * so the window will always stay on top in all workspaces. + * Default: true. + */ + focusable?: boolean; + /** + * Whether the window should always stay on top of other windows. + * Default: false. + */ + alwaysOnTop?: boolean; + /** + * Whether the window should show in fullscreen. + * When explicitly set to false the fullscreen button will be hidden or disabled on macOS. + * Default: false. + */ + fullscreen?: boolean; + /** + * Whether the window can be put into fullscreen mode. + * On macOS, also whether the maximize/zoom button should toggle full screen mode or maximize window. + * Default: true. + */ + fullscreenable?: boolean; + /** + * Whether to show the window in taskbar. + * Default: false. + */ + skipTaskbar?: boolean; + /** + * The kiosk mode. + * Default: false. + */ + kiosk?: boolean; + /** + * Default window title. + * Default: "Electron". + */ + title?: string; + /** + * The window icon, when omitted on Windows the executable’s icon would be used as window icon. + */ + icon?: NativeImage|string; + /** + * Whether window should be shown when created. + * Default: true. + */ + show?: boolean; + /** + * Specify false to create a Frameless Window. + * Default: true. + */ + frame?: boolean; + /** + * Specify parent window. + * Default: null. + */ + parent?: BrowserWindow; + /** + * Whether this is a modal window. This only works when the window is a child window. + * Default: false. + */ + modal?: boolean; + /** + * Whether the web view accepts a single mouse-down event that simultaneously activates the window. + * Default: false. + */ + acceptFirstMouse?: boolean; + /** + * Whether to hide cursor when typing. + * Default: false. + */ + disableAutoHideCursor?: boolean; + /** + * Auto hide the menu bar unless the Alt key is pressed. + * Default: true. + */ + autoHideMenuBar?: boolean; + /** + * Enable the window to be resized larger than screen. + * Default: false. + */ + enableLargerThanScreen?: boolean; + /** + * Window’s background color as Hexadecimal value, like #66CD00 or #FFF or #80FFFFFF (alpha is supported). + * Default: #FFF (white). + */ + backgroundColor?: string; + /** + * Whether window should have a shadow. + * Note: This is only implemented on macOS. + * Default: true. + */ + hasShadow?: boolean; + /** + * Forces using dark theme for the window. + * Note: Only works on some GTK+3 desktop environments. + * Default: false. + */ + darkTheme?: boolean; + /** + * Makes the window transparent. + * Default: false. + */ + transparent?: boolean; + /** + * The type of window, default is normal window. + */ + type?: BrowserWindowType; + /** + * The style of window title bar. + */ + titleBarStyle?: 'default' | 'hidden' | 'hidden-inset'; + /** + * Use WS_THICKFRAME style for frameless windows on Windows + */ + thickFrame?: boolean; + /** + * Settings of web page’s features. + */ + webPreferences?: WebPreferences; + } + + type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac | BrowserWindowTypeWindows; + type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification'; + type BrowserWindowTypeMac = 'desktop' | 'textured'; + type BrowserWindowTypeWindows = 'toolbar'; + + // https://github.com/electron/electron/blob/master/docs/api/clipboard.md + + /** + * The clipboard module provides methods to perform copy and paste operations. + */ + interface Clipboard { + /** + * @returns The contents of the clipboard as plain text. + */ + readText(type?: ClipboardType): string; + /** + * Writes the text into the clipboard as plain text. + */ + writeText(text: string, type?: ClipboardType): void; + /** + * @returns The contents of the clipboard as markup. + */ + readHTML(type?: ClipboardType): string; + /** + * Writes markup to the clipboard. + */ + writeHTML(markup: string, type?: ClipboardType): void; + /** + * @returns The contents of the clipboard as a NativeImage. + */ + readImage(type?: ClipboardType): NativeImage; + /** + * Writes the image into the clipboard. + */ + writeImage(image: NativeImage, type?: ClipboardType): void; + /** + * @returns The contents of the clipboard as RTF. + */ + readRTF(type?: ClipboardType): string; + /** + * Writes the text into the clipboard in RTF. + */ + writeRTF(text: string, type?: ClipboardType): void; + /** + * Clears everything in clipboard. + */ + clear(type?: ClipboardType): void; + /** + * @returns Array available formats for the clipboard type. + */ + availableFormats(type?: ClipboardType): string[]; + /** + * Returns whether the clipboard supports the format of specified data. + * Note: This API is experimental and could be removed in future. + * @returns Whether the clipboard has data in the specified format. + */ + has(format: string, type?: ClipboardType): boolean; + /** + * Reads the data in the clipboard of the specified format. + * Note: This API is experimental and could be removed in future. + */ + read(format: string, type?: ClipboardType): string | NativeImage; + /** + * Writes data to the clipboard. + */ + write(data: { + text?: string; + rtf?: string; + html?: string; + image?: NativeImage; + }, type?: ClipboardType): void; + /** + * @returns An Object containing title and url keys representing the bookmark in the clipboard. + * + * Note: This API is available on macOS and Windows. + */ + readBookmark(): Bookmark; + /** + * Writes the title and url into the clipboard as a bookmark. + * + * Note: This API is available on macOS and Windows. + */ + writeBookmark(title: string, url: string, type?: ClipboardType): void; + } + + type ClipboardType = '' | 'selection'; + + interface Bookmark { + title: string; + url: string; + } + + // https://github.com/electron/electron/blob/master/docs/api/content-tracing.md + + /** + * The content-tracing module is used to collect tracing data generated by the underlying Chromium content module. + * This module does not include a web interface so you need to open chrome://tracing/ + * in a Chrome browser and load the generated file to view the result. + */ + interface ContentTracing { + /** + * Get a set of category groups. The category groups can change as new code paths are reached. + * + * @param callback Called once all child processes have acknowledged the getCategories request. + */ + getCategories(callback: (categoryGroups: string[]) => void): void; + /** + * Start recording on all processes. Recording begins immediately locally and asynchronously + * on child processes as soon as they receive the EnableRecording request. + * + * @param callback Called once all child processes have acknowledged the startRecording request. + */ + startRecording(options: ContentTracingOptions, callback: Function): void; + /** + * Stop recording on all processes. Child processes typically are caching trace data and + * only rarely flush and send trace data back to the main process. That is because it may + * be an expensive operation to send the trace data over IPC, and we would like to avoid + * much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all + * child processes to flush any pending trace data. + * + * @param resultFilePath Trace data will be written into this file if it is not empty, + * or into a temporary file. + * @param callback Called once all child processes have acknowledged the stopRecording request. + */ + stopRecording(resultFilePath: string, callback: (filePath: string) => void): void; + /** + * Start monitoring on all processes. Monitoring begins immediately locally and asynchronously + * on child processes as soon as they receive the startMonitoring request. + * + * @param callback Called once all child processes have acked to the startMonitoring request. + */ + startMonitoring(options: ContentTracingOptions, callback: Function): void; + /** + * Stop monitoring on all processes. + * + * @param callback Called once all child processes have acknowledged the stopMonitoring request. + */ + stopMonitoring(callback: Function): void; + /** + * Get the current monitoring traced data. Child processes typically are caching trace data + * and only rarely flush and send trace data back to the main process. That is because it may + * be an expensive operation to send the trace data over IPC, and we would like to avoid much + * runtime overhead of tracing. So, to end tracing, we must asynchronously ask all child + * processes to flush any pending trace data. + * + * @param callback Called once all child processes have acknowledged the captureMonitoringSnapshot request. + */ + captureMonitoringSnapshot(resultFilePath: string, callback: (filePath: string) => void): void; + /** + * Get the maximum usage across processes of trace buffer as a percentage of the full state. + * + * @param callback Called when the TraceBufferUsage value is determined. + */ + getTraceBufferUsage(callback: Function): void; + /** + * @param callback Called every time the given event occurs on any process. + */ + setWatchEvent(categoryName: string, eventName: string, callback: Function): void; + /** + * Cancel the watch event. This may lead to a race condition with the watch event callback if tracing is enabled. + */ + cancelWatchEvent(): void; + } + + interface ContentTracingOptions { + /** + * Filter to control what category groups should be traced. + * A filter can have an optional - prefix to exclude category groups + * that contain a matching category. Having both included and excluded + * category patterns in the same list is not supported. + * + * Examples: + * test_MyTest* + * test_MyTest*,test_OtherStuff + * -excluded_category1,-excluded_category2 + */ + categoryFilter: string; + /** + * Controls what kind of tracing is enabled, it is a comma-delimited list. + * + * Possible options are: + * record-until-full + * record-continuously + * trace-to-console + * enable-sampling + * enable-systrace + * + * The first 3 options are trace recoding modes and hence mutually exclusive. + * If more than one trace recording modes appear in the traceOptions string, + * the last one takes precedence. If none of the trace recording modes are specified, + * recording mode is record-until-full. + * + * The trace option will first be reset to the default option (record_mode set + * to record-until-full, enable_sampling and enable_systrace set to false) + * before options parsed from traceOptions are applied on it. + */ + traceOptions: string; + } + + // https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md + + /** + * The crash-reporter module enables sending your app's crash reports. + */ + interface CrashReporter { + /** + * You are required to call this method before using other crashReporter APIs. + * + * Note: On macOS, Electron uses a new crashpad client, which is different from breakpad + * on Windows and Linux. To enable the crash collection feature, you are required to call + * the crashReporter.start API to initialize crashpad in the main process and in each + * renderer process from which you wish to collect crash reports. + */ + start(options: CrashReporterStartOptions): void; + /** + * @returns The crash report. When there was no crash report + * sent or the crash reporter is not started, null will be returned. + */ + getLastCrashReport(): CrashReport; + /** + * @returns All uploaded crash reports. + */ + getUploadedReports(): CrashReport[]; + } + + interface CrashReporterStartOptions { + /** + * Default: app.getName() + */ + productName?: string; + companyName: string; + /** + * URL that crash reports would be sent to as POST. + */ + submitURL: string; + /** + * Send the crash report without user interaction. + * Default: true. + */ + autoSubmit?: boolean; + /** + * Default: false. + */ + ignoreSystemCrashHandler?: boolean; + /** + * An object you can define that will be sent along with the report. + * Only string properties are sent correctly, nested objects are not supported. + */ + extra?: {[prop: string]: string}; + } + + interface CrashReport { + id: string; + date: Date; + } + + // https://github.com/electron/electron/blob/master/docs/api/desktop-capturer.md + + /** + * The desktopCapturer module can be used to get available sources + * that can be used to be captured with getUserMedia. + */ + interface DesktopCapturer { + /** + * Starts a request to get all desktop sources. + * + * Note: There is no guarantee that the size of source.thumbnail is always + * the same as the thumnbailSize in options. It also depends on the scale of the screen or window. + */ + getSources(options: DesktopCapturerOptions, callback: (error: Error, sources: DesktopCapturerSource[]) => any): void; + } + + interface DesktopCapturerOptions { + /** + * The types of desktop sources to be captured. + */ + types?: ('screen' | 'window')[]; + /** + * The suggested size that thumbnail should be scaled. + * Default: {width: 150, height: 150} + */ + thumbnailSize?: Size; + } + + interface DesktopCapturerSource { + /** + * The id of the captured window or screen used in navigator.webkitGetUserMedia. + * The format looks like window:XX or screen:XX where XX is a random generated number. + */ + id: string; + /** + * The described name of the capturing screen or window. + * If the source is a screen, the name will be Entire Screen or Screen ; + * if it is a window, the name will be the window’s title. + */ + name: string; + /** + * A thumbnail image. + */ + thumbnail: NativeImage; + } + + // https://github.com/electron/electron/blob/master/docs/api/dialog.md + + /** + * The dialog module provides APIs to show native system dialogs, such as opening files or alerting, + * so web applications can deliver the same user experience as native applications. + */ + interface Dialog { + /** + * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, + * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown. + * + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns an array of file paths chosen by the user, + * otherwise returns undefined. + */ + showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; + /** + * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, + * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown. + * + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns an array of file paths chosen by the user, + * otherwise returns undefined. + */ + showOpenDialog(options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; + /** + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns the path of file chosen by the user, otherwise + * returns undefined. + */ + showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (fileName: string) => void): string; + /** + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns the path of file chosen by the user, otherwise + * returns undefined. + */ + showSaveDialog(options: SaveDialogOptions, callback?: (fileName: string) => void): string; + /** + * Shows a message box. It will block until the message box is closed. + * @param callback If supplied, the API call will be asynchronous. + * @returns The index of the clicked button. + */ + showMessageBox(browserWindow: BrowserWindow, options: ShowMessageBoxOptions, callback?: (response: number) => void): number; + /** + * Shows a message box. It will block until the message box is closed. + * @param callback If supplied, the API call will be asynchronous. + * @returns The index of the clicked button. + */ + showMessageBox(options: ShowMessageBoxOptions, callback?: (response: number) => void): number; + /** + * Displays a modal dialog that shows an error message. + * + * This API can be called safely before the ready event the app module emits, + * it is usually used to report errors in early stage of startup. + * If called before the app readyevent on Linux, the message will be emitted to stderr, + * and no GUI dialog will appear. + */ + showErrorBox(title: string, content: string): void; + } + + interface OpenDialogOptions { + title?: string; + defaultPath?: string; + /** + * Custom label for the confirmation button, when left empty the default label will be used. + */ + buttonLabel?: string; + /** + * File types that can be displayed or selected. + */ + filters?: { + name: string; + /** + * Extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). + * To show all files, use the '*' wildcard (no other wildcard is supported). + */ + extensions: string[]; + }[]; + /** + * Contains which features the dialog should use. + */ + properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory' | 'showHiddenFiles')[]; + } + + interface SaveDialogOptions { + title?: string; + defaultPath?: string; + /** + * Custom label for the confirmation button, when left empty the default label will be used. + */ + buttonLabel?: string; + /** + * File types that can be displayed, see dialog.showOpenDialog for an example. + */ + filters?: { + name: string; + extensions: string[]; + }[]; + } + + interface ShowMessageBoxOptions { + /** + * On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option. + */ + type?: 'none' | 'info' | 'error' | 'question' | 'warning'; + /** + * Texts for buttons. On Windows, an empty array will result in one button labeled "OK". + */ + buttons?: string[]; + /** + * Index of the button in the buttons array which will be selected by default when the message box opens. + */ + defaultId?: number; + /** + * Title of the message box (some platforms will not show it). + */ + title?: string; + /** + * Contents of the message box. + */ + message?: string; + /** + * Extra information of the message. + */ + detail?: string; + icon?: NativeImage; + /** + * The value will be returned when user cancels the dialog instead of clicking the buttons of the dialog. + * By default it is the index of the buttons that have "cancel" or "no" as label, + * or 0 if there is no such buttons. On macOS and Windows the index of "Cancel" button + * will always be used as cancelId, not matter whether it is already specified. + */ + cancelId?: number; + /** + * On Windows Electron will try to figure out which one of the buttons are common buttons + * (like "Cancel" or "Yes"), and show the others as command links in the dialog. + * This can make the dialog appear in the style of modern Windows apps. + * If you don’t like this behavior, you can set noLink to true. + */ + noLink?: boolean; + } + + // https://github.com/electron/electron/blob/master/docs/api/download-item.md + + /** + * DownloadItem represents a download item in Electron. + */ + interface DownloadItem extends NodeJS.EventEmitter { + /** + * Emitted when the download has been updated and is not done. + */ + on(event: 'updated', listener: (event: Event, state: 'progressing' | 'interrupted') => void): this; + /** + * Emits when the download is in a terminal state. This includes a completed download, + * a cancelled download (via downloadItem.cancel()), and interrupted download that can’t be resumed. + */ + on(event: 'done', listener: (event: Event, state: 'completed' | 'cancelled' | 'interrupted') => void): this; + on(event: string, listener: Function): this; + /** + * Set the save file path of the download item. + * Note: The API is only available in session’s will-download callback function. + * If user doesn’t set the save path via the API, Electron will use the original + * routine to determine the save path (Usually prompts a save dialog). + */ + setSavePath(path: string): void; + /** + * @returns The save path of the download item. + * This will be either the path set via downloadItem.setSavePath(path) or the path selected from the shown save dialog. + */ + getSavePath(): string; + /** + * Pauses the download. + */ + pause(): void; + /** + * @returns Whether the download is paused. + */ + isPaused(): boolean; + /** + * Resumes the download that has been paused. + */ + resume(): void; + /** + * @returns Whether the download can resume. + */ + canResume(): boolean; + /** + * Cancels the download operation. + */ + cancel(): void; + /** + * @returns The origin url where the item is downloaded from. + */ + getURL(): string; + /** + * @returns The mime type. + */ + getMimeType(): string; + /** + * @returns Whether the download has user gesture. + */ + hasUserGesture(): boolean; + /** + * @returns The file name of the download item. + * Note: The file name is not always the same as the actual one saved in local disk. + * If user changes the file name in a prompted download saving dialog, + * the actual name of saved file will be different. + */ + getFilename(): string; + /** + * @returns The total size in bytes of the download item. If the size is unknown, it returns 0. + */ + getTotalBytes(): number; + /** + * @returns The received bytes of the download item. + */ + getReceivedBytes(): number; + /** + * @returns The Content-Disposition field from the response header. + */ + getContentDisposition(): string; + /** + * @returns The current state. + */ + getState(): 'progressing' | 'completed' | 'cancelled' | 'interrupted'; + } + + // https://github.com/electron/electron/blob/master/docs/api/global-shortcut.md + + /** + * The globalShortcut module can register/unregister a global keyboard shortcut + * with the operating system so that you can customize the operations for various shortcuts. + * Note: The shortcut is global; it will work even if the app does not have the keyboard focus. + * You should not use this module until the ready event of the app module is emitted. + */ + interface GlobalShortcut { + /** + * Registers a global shortcut of accelerator. + * @param accelerator Represents a keyboard shortcut. It can contain modifiers + * and key codes, combined by the "+" character. + * @param callback Called when the registered shortcut is pressed by the user. + */ + register(accelerator: string, callback: Function): void; + /** + * @param accelerator Represents a keyboard shortcut. It can contain modifiers + * and key codes, combined by the "+" character. + * @returns Whether the accelerator is registered. + */ + isRegistered(accelerator: string): boolean; + /** + * Unregisters the global shortcut of keycode. + * @param accelerator Represents a keyboard shortcut. It can contain modifiers + * and key codes, combined by the "+" character. + */ + unregister(accelerator: string): void; + /** + * Unregisters all the global shortcuts. + */ + unregisterAll(): void; + } + + // https://github.com/electron/electron/blob/master/docs/api/ipc-main.md + + /** + * The ipcMain module handles asynchronous and synchronous messages + * sent from a renderer process (web page). + * Messages sent from a renderer will be emitted to this module. + */ + interface IpcMain extends NodeJS.EventEmitter { + addListener(channel: string, listener: IpcMainEventListener): this; + on(channel: string, listener: IpcMainEventListener): this; + once(channel: string, listener: IpcMainEventListener): this; + removeListener(channel: string, listener: IpcMainEventListener): this; + removeAllListeners(channel?: string): this; + } + + type IpcMainEventListener = (event: IpcMainEvent, ...args: any[]) => void; + + interface IpcMainEvent { + /** + * Set this to the value to be returned in a synchronous message. + */ + returnValue?: any; + /** + * Returns the webContents that sent the message, you can call sender.send + * to reply to the asynchronous message. + */ + sender: WebContents; + } + + // https://github.com/electron/electron/blob/master/docs/api/ipc-renderer.md + + /** + * The ipcRenderer module provides a few methods so you can send synchronous + * and asynchronous messages from the render process (web page) to the main process. + * You can also receive replies from the main process. + */ + interface IpcRenderer extends NodeJS.EventEmitter { + addListener(channel: string, listener: IpcRendererEventListener): this; + on(channel: string, listener: IpcRendererEventListener): this; + once(channel: string, listener: IpcRendererEventListener): this; + removeListener(channel: string, listener: IpcRendererEventListener): this; + removeAllListeners(channel?: string): this; + /** + * Send ...args to the renderer via channel in asynchronous message, the main + * process can handle it by listening to the channel event of ipc module. + */ + send(channel: string, ...args: any[]): void; + /** + * Send ...args to the renderer via channel in synchronous message, and returns + * the result sent from main process. The main process can handle it by listening + * to the channel event of ipc module, and returns by setting event.returnValue. + * Note: Usually developers should never use this API, since sending synchronous + * message would block the whole renderer process. + * @returns The result sent from the main process. + */ + sendSync(channel: string, ...args: any[]): any; + /** + * Like ipc.send but the message will be sent to the host page instead of the main process. + * This is mainly used by the page in to communicate with host page. + */ + sendToHost(channel: string, ...args: any[]): void; + } + + type IpcRendererEventListener = (event: IpcRendererEvent, ...args: any[]) => void; + + interface IpcRendererEvent { + /** + * You can call sender.send to reply to the asynchronous message. + */ + sender: IpcRenderer; + } + + // https://github.com/electron/electron/blob/master/docs/api/menu-item.md + // https://github.com/electron/electron/blob/master/docs/api/accelerator.md + + /** + * The MenuItem allows you to add items to an application or context menu. + */ + class MenuItem { + /** + * Create a new menu item. + */ + constructor(options: MenuItemOptions); + + click: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void; + /** + * Read-only property. + */ + type: MenuItemType; + /** + * Read-only property. + */ + role: MenuItemRole | MenuItemRoleMac; + /** + * Read-only property. + */ + accelerator: string; + /** + * Read-only property. + */ + icon: NativeImage | string; + /** + * Read-only property. + */ + submenu: Menu | MenuItemOptions[]; + + label: string; + sublabel: string; + enabled: boolean; + visible: boolean; + checked: boolean; + } + + type MenuItemType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'; + type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteandmatchstyle' | 'selectall' | 'delete' | 'minimize' | 'close' | 'quit' | 'togglefullscreen' | 'resetzoom' | 'zoomin' | 'zoomout'; + type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'startspeaking' | 'stopspeaking' | 'front' | 'zoom' | 'window' | 'help' | 'services'; + + interface MenuItemOptions { + /** + * Callback when the menu item is clicked. + */ + click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; + /** + * Can be normal, separator, submenu, checkbox or radio. + */ + type?: MenuItemType; + label?: string; + sublabel?: string; + /** + * An accelerator is string that represents a keyboard shortcut, it can contain + * multiple modifiers and key codes, combined by the + character. + * + * Examples: + * CommandOrControl+A + * CommandOrControl+Shift+Z + * + * Platform notice: + * On Linux and Windows, the Command key would not have any effect, + * you can use CommandOrControl which represents Command on macOS and Control on + * Linux and Windows to define some accelerators. + * + * Use Alt instead of Option. The Option key only exists on macOS, whereas + * the Alt key is available on all platforms. + * + * The Super key is mapped to the Windows key on Windows and Linux and Cmd on macOS. + * + * Available modifiers: + * Command (or Cmd for short) + * Control (or Ctrl for short) + * CommandOrControl (or CmdOrCtrl for short) + * Alt + * Option + * AltGr + * Shift + * Super + * + * Available key codes: + * 0 to 9 + * A to Z + * F1 to F24 + * Punctuations like ~, !, @, #, $, etc. + * Plus + * Space + * Tab + * Backspace + * Delete + * Insert + * Return (or Enter as alias) + * Up, Down, Left and Right + * Home and End + * PageUp and PageDown + * Escape (or Esc for short) + * VolumeUp, VolumeDown and VolumeMute + * MediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause + * PrintScreen + */ + accelerator?: string; + /** + * In Electron for the APIs that take images, you can pass either file paths + * or NativeImage instances. When passing null, an empty image will be used. + */ + icon?: NativeImage|string; + /** + * If false, the menu item will be greyed out and unclickable. + */ + enabled?: boolean; + /** + * If false, the menu item will be entirely hidden. + */ + visible?: boolean; + /** + * Should only be specified for 'checkbox' or 'radio' type menu items. + */ + checked?: boolean; + /** + * Should be specified for submenu type menu item, when it's specified the + * type: 'submenu' can be omitted for the menu item + */ + submenu?: Menu|MenuItemOptions[]; + /** + * Unique within a single menu. If defined then it can be used as a reference + * to this item by the position attribute. + */ + id?: string; + /** + * This field allows fine-grained definition of the specific location within + * a given menu. + */ + position?: string; + /** + * Define the action of the menu item, when specified the click property will be ignored + */ + role?: MenuItemRole | MenuItemRoleMac; + } + + // https://github.com/electron/electron/blob/master/docs/api/menu.md + + /** + * The Menu class is used to create native menus that can be used as application + * menus and context menus. This module is a main process module which can be used + * in a render process via the remote module. + * + * Each menu consists of multiple menu items, and each menu item can have a submenu. + */ + class Menu extends NodeJS.EventEmitter { + /** + * Creates a new menu. + */ + constructor(); + /** + * Sets menu as the application menu on macOS. On Windows and Linux, the menu + * will be set as each window's top menu. + */ + static setApplicationMenu(menu: Menu): void; + /** + * @returns The application menu if set, or null if not set. + */ + static getApplicationMenu(): Menu; + /** + * Sends the action to the first responder of application. + * This is used for emulating default Cocoa menu behaviors, + * usually you would just use the role property of MenuItem. + * + * Note: This method is macOS only. + */ + static sendActionToFirstResponder(action: string): void; + /** + * @param template Generally, just an array of options for constructing MenuItem. + * You can also attach other fields to element of the template, and they will + * become properties of the constructed menu items. + */ + static buildFromTemplate(template: MenuItemOptions[]): Menu; + /** + * Pops up this menu as a context menu in the browserWindow. You can optionally + * provide a (x,y) coordinate to place the menu at, otherwise it will be placed + * at the current mouse cursor position. + * @param x Horizontal coordinate where the menu will be placed. + * @param y Vertical coordinate where the menu will be placed. + */ + popup(browserWindow?: BrowserWindow, x?: number, y?: number): void; + /** + * Appends the menuItem to the menu. + */ + append(menuItem: MenuItem): void; + /** + * Inserts the menuItem to the pos position of the menu. + */ + insert(position: number, menuItem: MenuItem): void; + /** + * @returns an array containing the menu’s items. + */ + items: MenuItem[]; + } + + // https://github.com/electron/electron/blob/master/docs/api/native-image.md + + /** + * This class is used to represent an image. + */ + class NativeImage { + /** + * Creates an empty NativeImage instance. + */ + static createEmpty(): NativeImage; + /** + * Creates a new NativeImage instance from file located at path. + * This method returns an empty image if the path does not exist, cannot be read, or is not a valid image. + */ + static createFromPath(path: string): NativeImage; + /** + * Creates a new NativeImage instance from buffer. + * @param scaleFactor 1.0 by default. + */ + static createFromBuffer(buffer: Buffer, scaleFactor?: number): NativeImage; + /** + * Creates a new NativeImage instance from dataURL + */ + static createFromDataURL(dataURL: string): NativeImage; + /** + * @returns Buffer that contains the image's PNG encoded data. + */ + toPNG(): Buffer; + /** + * @returns Buffer that contains the image's JPEG encoded data. + */ + toJPEG(quality: number): Buffer; + /** + * @returns Buffer that contains a copy of the image's raw bitmap pixel data. + */ + toBitmap(): Buffer; + /** + * @returns Buffer that contains the image's raw bitmap pixel data. + * + * The difference between getBitmap() and toBitmap() is, getBitmap() does not copy the bitmap data, + * so you have to use the returned Buffer immediately in current event loop tick, + * otherwise the data might be changed or destroyed. + */ + getBitmap(): Buffer; + /** + * @returns The data URL of the image. + */ + toDataURL(): string; + /** + * The native type of the handle is NSImage* on macOS. + * Note: This is only implemented on macOS. + * @returns The platform-specific handle of the image as Buffer. + */ + getNativeHandle(): Buffer; + /** + * @returns Whether the image is empty. + */ + isEmpty(): boolean; + /** + * @returns The size of the image. + */ + getSize(): Size; + /** + * Marks the image as template image. + */ + setTemplateImage(option: boolean): void; + /** + * Returns a boolean whether the image is a template image. + */ + isTemplateImage(): boolean; + /** + * @param rect The area of the image to crop + * @returns The cropped image. + */ + crop(rect: Rectangle): NativeImage; + /** + * @returns The resized image. + * If only the height or the width are specified then the current aspect ratio will be preserved in the resized image. + */ + resize(options: { + width?: number; + height?: number; + /** + * The desired quality of the resized image. + * Default: best. + */ + quality?: 'good' | 'better' | 'best'; + }): NativeImage; + /** + * @returns The image's aspect ratio. + */ + getAspectRatio(): number; + } + + // https://github.com/electron/electron/blob/master/docs/api/power-monitor.md + + /** + * The power-monitor module is used to monitor power state changes. + * You should not use this module until the ready event of the app module is emitted. + */ + interface PowerMonitor extends NodeJS.EventEmitter { + /** + * Emitted when the system is suspending. + */ + on(event: 'suspend', listener: Function): this; + /** + * Emitted when system is resuming. + */ + on(event: 'resume', listener: Function): this; + /** + * Emitted when the system changes to AC power. + */ + on(event: 'on-ac', listener: Function): this; + /** + * Emitted when system changes to battery power. + */ + on(event: 'on-battery', listener: Function): this; + on(event: string, listener: Function): this; + } + + // https://github.com/electron/electron/blob/master/docs/api/power-save-blocker.md + + /** + * The powerSaveBlocker module is used to block the system from entering + * low-power (sleep) mode and thus allowing the app to keep the system and screen active. + */ + interface PowerSaveBlocker { + /** + * Starts preventing the system from entering lower-power mode. + * @returns The blocker ID that is assigned to this power blocker. + * Note: prevent-display-sleep has higher has precedence over prevent-app-suspension. + */ + start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number; + /** + * @param id The power save blocker id returned by powerSaveBlocker.start. + * Stops the specified power save blocker. + */ + stop(id: number): void; + /** + * @param id The power save blocker id returned by powerSaveBlocker.start. + * @returns Whether the corresponding powerSaveBlocker has started. + */ + isStarted(id: number): boolean; + } + + // https://github.com/electron/electron/blob/master/docs/api/protocol.md + + /** + * The protocol module can register a custom protocol or intercept an existing protocol. + */ + interface Protocol { + /** + * Registers custom schemes as standard schemes. + */ + registerStandardSchemes(schemes: string[]): void; + /** + * Registers custom schemes to handle service workers. + */ + registerServiceWorkerSchemes(schemes: string[]): void; + /** + * Registers a protocol of scheme that will send the file as a response. + */ + registerFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void; + /** + * Registers a protocol of scheme that will send a Buffer as a response. + */ + registerBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void; + /** + * Registers a protocol of scheme that will send a String as a response. + */ + registerStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void; + /** + * Registers a protocol of scheme that will send an HTTP request as a response. + */ + registerHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void; + /** + * Unregisters the custom protocol of scheme. + */ + unregisterProtocol(scheme: string, completion?: (error: Error) => void): void; + /** + * The callback will be called with a boolean that indicates whether there is already a handler for scheme. + */ + isProtocolHandled(scheme: string, callback: (handled: boolean) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a file as a response. + */ + interceptFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a Buffer as a response. + */ + interceptBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response. + */ + interceptStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a new HTTP request as a response. + */ + interceptHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void; + /** + * Remove the interceptor installed for scheme and restore its original handler. + */ + uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void; + } + + type FileProtocolHandler = (request: ProtocolRequest, callback: FileProtocolCallback) => void; + type BufferProtocolHandler = (request: ProtocolRequest, callback: BufferProtocolCallback) => void; + type StringProtocolHandler = (request: ProtocolRequest, callback: StringProtocolCallback) => void; + type HttpProtocolHandler = (request: ProtocolRequest, callback: HttpProtocolCallback) => void; + + interface ProtocolRequest { + url: string; + referrer: string; + method: string; + uploadData?: { + /** + * Content being sent. + */ + bytes: Buffer, + /** + * Path of file being uploaded. + */ + file: string, + /** + * UUID of blob data. Use session.getBlobData method to retrieve the data. + */ + blobUUID: string; + }[]; + } + + interface ProtocolCallback { + (error: number): void; + (obj: { + error: number + }): void; + (): void; + } + + interface FileProtocolCallback extends ProtocolCallback { + (filePath: string): void; + (obj: { + path: string + }): void; + } + + interface BufferProtocolCallback extends ProtocolCallback { + (buffer: Buffer): void; + (obj: { + data: Buffer, + mimeType: string, + charset?: string + }): void; + } + + interface StringProtocolCallback extends ProtocolCallback { + (str: string): void; + (obj: { + data: Buffer, + mimeType: string, + charset?: string + }): void; + } + + interface HttpProtocolCallback extends ProtocolCallback { + (redirectRequest: { + url: string; + method: string; + session?: Object; + uploadData?: { + contentType: string; + data: string; + }; + }): void; + } + + // https://github.com/electron/electron/blob/master/docs/api/remote.md + + /** + * The remote module provides a simple way to do inter-process communication (IPC) + * between the renderer process (web page) and the main process. + */ + interface Remote extends CommonElectron { + /** + * @returns The object returned by require(module) in the main process. + */ + require(module: string): any; + /** + * @returns The BrowserWindow object which this web page belongs to. + */ + getCurrentWindow(): BrowserWindow; + /** + * @returns The WebContents object of this web page. + */ + getCurrentWebContents(): WebContents; + /** + * @returns The global variable of name (e.g. global[name]) in the main process. + */ + getGlobal(name: string): any; + /** + * Returns the process object in the main process. This is the same as + * remote.getGlobal('process'), but gets cached. + */ + process: NodeJS.Process; + } + + // https://github.com/electron/electron/blob/master/docs/api/screen.md + + /** + * The Display object represents a physical display connected to the system. + * A fake Display may exist on a headless system, or a Display may correspond to a remote, virtual display. + */ + interface Display { + /** + * Unique identifier associated with the display. + */ + id: number; + bounds: Rectangle; + workArea: Rectangle; + size: Size; + workAreaSize: Size; + /** + * Output device’s pixel scale factor. + */ + scaleFactor: number; + /** + * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees. + */ + rotation: number; + touchSupport: 'available' | 'unavailable' | 'unknown'; + } + + type DisplayMetrics = 'bounds' | 'workArea' | 'scaleFactor' | 'rotation'; + + /** + * The screen module retrieves information about screen size, displays, cursor position, etc. + * You can not use this module until the ready event of the app module is emitted. + */ + interface Screen extends NodeJS.EventEmitter { + /** + * Emitted when newDisplay has been added. + */ + on(event: 'display-added', listener: (event: Event, newDisplay: Display) => void): this; + /** + * Emitted when oldDisplay has been removed. + */ + on(event: 'display-removed', listener: (event: Event, oldDisplay: Display) => void): this; + /** + * Emitted when one or more metrics change in a display. + */ + on(event: 'display-metrics-changed', listener: (event: Event, display: Display, changedMetrics: DisplayMetrics[]) => void): this; + on(event: string, listener: Function): this; + /** + * @returns The current absolute position of the mouse pointer. + */ + getCursorScreenPoint(): Point; + /** + * @returns The primary display. + */ + getPrimaryDisplay(): Display; + /** + * @returns An array of displays that are currently available. + */ + getAllDisplays(): Display[]; + /** + * @returns The display nearest the specified point. + */ + getDisplayNearestPoint(point: Point): Display; + /** + * @returns The display that most closely intersects the provided bounds. + */ + getDisplayMatching(rect: Rectangle): Display; + } + + // https://github.com/electron/electron/blob/master/docs/api/session.md + + /** + * The session module can be used to create new Session objects. + * You can also access the session of existing pages by using + * the session property of webContents which is a property of BrowserWindow. + */ + class Session extends NodeJS.EventEmitter { + /** + * @returns a new Session instance from partition string. + */ + static fromPartition(partition: string, options?: FromPartitionOptions): Session; + /** + * @returns the default session object of the app. + */ + static defaultSession: Session; + /** + * Emitted when Electron is about to download item in webContents. + * Calling event.preventDefault() will cancel the download + * and item will not be available from next tick of the process. + */ + on(event: 'will-download', listener: (event: Event, item: DownloadItem, webContents: WebContents) => void): this; + on(event: string, listener: Function): this; + /** + * The cookies gives you ability to query and modify cookies. + */ + cookies: SessionCookies; + /** + * @returns the session’s current cache size. + */ + getCacheSize(callback: (size: number) => void): void; + /** + * Clears the session’s HTTP cache. + */ + clearCache(callback: Function): void; + /** + * Clears the data of web storages. + */ + clearStorageData(callback: Function): void; + /** + * Clears the data of web storages. + */ + clearStorageData(options: ClearStorageDataOptions, callback: Function): void; + /** + * Writes any unwritten DOMStorage data to disk. + */ + flushStorageData(): void; + /** + * Sets the proxy settings. + */ + setProxy(config: ProxyConfig, callback: Function): void; + /** + * Resolves the proxy information for url. + */ + resolveProxy(url: URL, callback: (proxy: string) => void): void; + /** + * Sets download saving directory. + * By default, the download directory will be the Downloads under the respective app folder. + */ + setDownloadPath(path: string): void; + /** + * Emulates network with the given configuration for the session. + */ + enableNetworkEmulation(options: NetworkEmulationOptions): void; + /** + * Disables any network emulation already active for the session. + * Resets to the original network configuration. + */ + disableNetworkEmulation(): void; + /** + * Sets the certificate verify proc for session, the proc will be called + * whenever a server certificate verification is requested. + * + * Calling setCertificateVerifyProc(null) will revert back to default certificate verify proc. + */ + setCertificateVerifyProc(proc: (hostname: string, cert: Certificate, callback: (accepted: boolean) => void) => void): void; + /** + * Sets the handler which can be used to respond to permission requests for the session. + */ + setPermissionRequestHandler(handler: (webContents: WebContents, permission: Permission, callback: (allow: boolean) => void) => void): void; + /** + * Clears the host resolver cache. + */ + clearHostResolverCache(callback: Function): void; + /** + * Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication. + * @param domains Comma-seperated list of servers for which integrated authentication is enabled. + */ + allowNTLMCredentialsForDomains(domains: string): void; + /** + * Overrides the userAgent and acceptLanguages for this session. + * The acceptLanguages must a comma separated ordered list of language codes, for example "en-US,fr,de,ko,zh-CN,ja". + * This doesn't affect existing WebContents, and each WebContents can use webContents.setUserAgent to override the session-wide user agent. + */ + setUserAgent(userAgent: string, acceptLanguages?: string): void; + /** + * @returns The user agent for this session. + */ + getUserAgent(): string; + /** + * Returns the blob data associated with the identifier. + */ + getBlobData(identifier: string, callback: (result: Buffer) => void): void; + /** + * The webRequest API set allows to intercept and modify contents of a request at various stages of its lifetime. + */ + webRequest: WebRequest; + /** + * @returns An instance of protocol module for this session. + */ + protocol: Protocol; + } + + type Permission = 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal'; + + interface FromPartitionOptions { + /** + * Whether to enable cache. + */ + cache?: boolean; + } + + interface ClearStorageDataOptions { + /** + * Should follow window.location.origin’s representation scheme://host:port. + */ + origin?: string; + /** + * The types of storages to clear. + */ + storages?: ('appcache' | 'cookies' | 'filesystem' | 'indexdb' | 'localstorage' | 'shadercache' | 'websql' | 'serviceworkers')[]; + /** + * The types of quotas to clear. + */ + quotas?: ('temporary' | 'persistent' | 'syncable')[]; + } + + interface ProxyConfig { + /** + * The URL associated with the PAC file. + */ + pacScript: string; + /** + * Rules indicating which proxies to use. + */ + proxyRules: string; + /** + * Rules indicating which URLs should bypass the proxy settings. + */ + proxyBypassRules: string; + } + + interface NetworkEmulationOptions { + /** + * Whether to emulate network outage. + * Default: false. + */ + offline?: boolean; + /** + * RTT in ms. + * Default: 0, which will disable latency throttling. + */ + latency?: number; + /** + * Download rate in Bps. + * Default: 0, which will disable download throttling. + */ + downloadThroughput?: number; + /** + * Upload rate in Bps. + * Default: 0, which will disable upload throttling. + */ + uploadThroughput?: number; + } + + interface CookieFilter { + /** + * Retrieves cookies which are associated with url. Empty implies retrieving cookies of all urls. + */ + url?: string; + /** + * Filters cookies by name. + */ + name?: string; + /** + * Retrieves cookies whose domains match or are subdomains of domains. + */ + domain?: string; + /** + * Retrieves cookies whose path matches path. + */ + path?: string; + /** + * Filters cookies by their Secure property. + */ + secure?: boolean; + /** + * Filters out session or persistent cookies. + */ + session?: boolean; + } + + interface Cookie { + /** + * Emitted when a cookie is changed because it was added, edited, removed, or expired. + */ + on(event: 'changed', listener: (event: Event, cookie: Cookie, cause: CookieChangedCause) => void): this; + on(event: string, listener: Function): this; + /** + * The name of the cookie. + */ + name: string; + /** + * The value of the cookie. + */ + value: string; + /** + * The domain of the cookie. + */ + domain: string; + /** + * Whether the cookie is a host-only cookie. + */ + hostOnly: string; + /** + * The path of the cookie. + */ + path: string; + /** + * Whether the cookie is marked as secure. + */ + secure: boolean; + /** + * Whether the cookie is marked as HTTP only. + */ + httpOnly: boolean; + /** + * Whether the cookie is a session cookie or a persistent cookie with an expiration date. + */ + session: boolean; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. + * Not provided for session cookies. + */ + expirationDate?: number; + } + + type CookieChangedCause = 'explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'; + + interface CookieDetails { + /** + * The URL associated with the cookie. + */ + url: string; + /** + * The name of the cookie. + * Default: empty. + */ + name?: string; + /** + * The value of the cookie. + * Default: empty. + */ + value?: string; + /** + * The domain of the cookie. + * Default: empty. + */ + domain?: string; + /** + * The path of the cookie. + * Default: empty. + */ + path?: string; + /** + * Whether the cookie should be marked as secure. + * Default: false. + */ + secure?: boolean; + /** + * Whether the cookie should be marked as HTTP only. + * Default: false. + */ + httpOnly?: boolean; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. + * If omitted, the cookie becomes a session cookie. + */ + expirationDate?: number; + } + + interface SessionCookies { + /** + * Sends a request to get all cookies matching filter. + */ + get(filter: CookieFilter, callback: (error: Error, cookies: Cookie[]) => void): void; + /** + * Sets the cookie with details. + */ + set(details: CookieDetails, callback: (error: Error) => void): void; + /** + * Removes the cookies matching url and name. + */ + remove(url: string, name: string, callback: (error: Error) => void): void; + } + + /** + * Each API accepts an optional filter and a listener, the listener will be called when the API's event has happened. + * Passing null as listener will unsubscribe from the event. + * + * The filter will be used to filter out the requests that do not match the URL patterns. + * If the filter is omitted then all requests will be matched. + * + * For certain events the listener is passed with a callback, + * which should be called with an response object when listener has done its work. + */ + interface WebRequest { + /** + * The listener will be called when a request is about to occur. + */ + onBeforeRequest(listener: (details: WebRequest.BeforeRequestDetails, callback: WebRequest.BeforeRequestCallback) => void): void; + /** + * The listener will be called when a request is about to occur. + */ + onBeforeRequest(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeRequestDetails, callback: WebRequest.BeforeRequestCallback) => void): void; + /** + * The listener will be called before sending an HTTP request, once the request headers are available. + * This may occur after a TCP connection is made to the server, but before any http data is sent. + */ + onBeforeSendHeaders(listener: (details: WebRequest.BeforeSendHeadersDetails, callback: WebRequest.BeforeSendHeadersCallback) => void): void; + /** + * The listener will be called before sending an HTTP request, once the request headers are available. + * This may occur after a TCP connection is made to the server, but before any http data is sent. + */ + onBeforeSendHeaders(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeSendHeadersDetails, callback: WebRequest.BeforeSendHeadersCallback) => void): void; + /** + * The listener will be called just before a request is going to be sent to the server, + * modifications of previous onBeforeSendHeaders response are visible by the time this listener is fired. + */ + onSendHeaders(listener: (details: WebRequest.SendHeadersDetails) => void): void; + /** + * The listener will be called just before a request is going to be sent to the server, + * modifications of previous onBeforeSendHeaders response are visible by the time this listener is fired. + */ + onSendHeaders(filter: WebRequest.Filter, listener: (details: WebRequest.SendHeadersDetails) => void): void; + /** + * The listener will be called when HTTP response headers of a request have been received. + */ + onHeadersReceived(listener: (details: WebRequest.HeadersReceivedDetails, callback: WebRequest.HeadersReceivedCallback) => void): void; + /** + * The listener will be called when HTTP response headers of a request have been received. + */ + onHeadersReceived(filter: WebRequest.Filter, listener: (details: WebRequest.HeadersReceivedDetails, callback: WebRequest.HeadersReceivedCallback) => void): void; + /** + * The listener will be called when first byte of the response body is received. + * For HTTP requests, this means that the status line and response headers are available. + */ + onResponseStarted(listener: (details: WebRequest.ResponseStartedDetails) => void): void; + /** + * The listener will be called when first byte of the response body is received. + * For HTTP requests, this means that the status line and response headers are available. + */ + onResponseStarted(filter: WebRequest.Filter, listener: (details: WebRequest.ResponseStartedDetails) => void): void; + /** + * The listener will be called when a server initiated redirect is about to occur. + */ + onBeforeRedirect(listener: (details: WebRequest.BeforeRedirectDetails) => void): void; + /** + * The listener will be called when a server initiated redirect is about to occur. + */ + onBeforeRedirect(filter: WebRequest.Filter, listener: (details: WebRequest.BeforeRedirectDetails) => void): void; + /** + * The listener will be called when a request is completed. + */ + onCompleted(listener: (details: WebRequest.CompletedDetails) => void): void; + /** + * The listener will be called when a request is completed. + */ + onCompleted(filter: WebRequest.Filter, listener: (details: WebRequest.CompletedDetails) => void): void; + /** + * The listener will be called when an error occurs. + */ + onErrorOccurred(listener: (details: WebRequest.ErrorOccurredDetails) => void): void; + /** + * The listener will be called when an error occurs. + */ + onErrorOccurred(filter: WebRequest.Filter, listener: (details: WebRequest.ErrorOccurredDetails) => void): void; + } + + namespace WebRequest { + interface Filter { + urls: string[]; + } + + interface Details { + id: number; + url: string; + method: string; + resourceType: string; + timestamp: number; + } + + interface UploadData { + /** + * Content being sent. + */ + bytes: Buffer; + /** + * Path of file being uploaded. + */ + file: string; + /** + * UUID of blob data. Use session.getBlobData method to retrieve the data. + */ + blobUUID: string; + } + + interface BeforeRequestDetails extends Details { + uploadData?: UploadData[]; + } + + type BeforeRequestCallback = (response: { + cancel?: boolean; + /** + * The original request is prevented from being sent or completed, and is instead redirected to the given URL. + */ + redirectURL?: string; + }) => void; + + interface BeforeSendHeadersDetails extends Details { + requestHeaders: Headers; + } + + type BeforeSendHeadersCallback = (response: { + cancel?: boolean; + /** + * When provided, request will be made with these headers. + */ + requestHeaders?: Headers; + }) => void; + + interface SendHeadersDetails extends Details { + requestHeaders: Headers; + } + + interface HeadersReceivedDetails extends Details { + statusLine: string; + statusCode: number; + responseHeaders: Headers; + } + + type HeadersReceivedCallback = (response: { + cancel?: boolean; + /** + * When provided, the server is assumed to have responded with these headers. + */ + responseHeaders?: Headers; + /** + * Should be provided when overriding responseHeaders to change header status + * otherwise original response header's status will be used. + */ + statusLine?: string; + }) => void; + + interface ResponseStartedDetails extends Details { + responseHeaders: Headers; + fromCache: boolean; + statusCode: number; + statusLine: string; + } + + interface BeforeRedirectDetails extends Details { + redirectURL: string; + statusCode: number; + ip?: string; + fromCache: boolean; + responseHeaders: Headers; + } + + interface CompletedDetails extends Details { + responseHeaders: Headers; + fromCache: boolean; + statusCode: number; + statusLine: string; + } + + interface ErrorOccurredDetails extends Details { + fromCache: boolean; + error: string; + } + } + + // https://github.com/electron/electron/blob/master/docs/api/shell.md + + /** + * The shell module provides functions related to desktop integration. + */ + interface Shell { + /** + * Show the given file in a file manager. If possible, select the file. + * @returns Whether the item was successfully shown. + */ + showItemInFolder(fullPath: string): boolean; + /** + * Open the given file in the desktop's default manner. + * @returns Whether the item was successfully shown. + */ + openItem(fullPath: string): boolean; + /** + * Open the given external protocol URL in the desktop's default manner + * (e.g., mailto: URLs in the default mail user agent). + * @returns Whether an application was available to open the URL. + */ + openExternal(url: string, options?: { + /** + * Bring the opened application to the foreground. + * Default: true. + */ + activate: boolean; + }): boolean; + /** + * Move the given file to trash. + * @returns Whether the item was successfully moved to the trash. + */ + moveItemToTrash(fullPath: string): boolean; + /** + * Play the beep sound. + */ + beep(): void; + /** + * Creates or updates a shortcut link at shortcutPath. + * + * Note: This API is available only on Windows. + */ + writeShortcutLink(shortcutPath: string, options: ShortcutLinkOptions): boolean; + /** + * Creates or updates a shortcut link at shortcutPath. + * + * Note: This API is available only on Windows. + */ + writeShortcutLink(shortcutPath: string, operation: 'create' | 'update' | 'replace', options: ShortcutLinkOptions): boolean; + /** + * Resolves the shortcut link at shortcutPath. + * An exception will be thrown when any error happens. + * + * Note: This API is available only on Windows. + */ + readShortcutLink(shortcutPath: string): ShortcutLinkOptions; + } + + interface ShortcutLinkOptions { + /** + * The target to launch from this shortcut. + */ + target: string; + /** + * The working directory. + * Default: empty. + */ + cwd?: string; + /** + * The arguments to be applied to target when launching from this shortcut. + * Default: empty. + */ + args?: string; + /** + * The description of the shortcut. + * Default: empty. + */ + description?: string; + /** + * The path to the icon, can be a DLL or EXE. icon and iconIndex have to be set together. + * Default: empty, which uses the target's icon. + */ + icon?: string; + /** + * The resource ID of icon when icon is a DLL or EXE. + * Default: 0. + */ + iconIndex?: number; + /** + * The Application User Model ID. + * Default: empty. + */ + appUserModelId?: string; + } + + // https://github.com/electron/electron/blob/master/docs/api/system-preferences.md + + type SystemColor = + '3d-dark-shadow' | // Dark shadow for three-dimensional display elements. + '3d-face' | // Face color for three-dimensional display elements and for dialog box backgrounds. + '3d-highlight' | // Highlight color for three-dimensional display elements. + '3d-light' | // Light color for three-dimensional display elements. + '3d-shadow' | // Shadow color for three-dimensional display elements. + 'active-border' | // Active window border. + 'active-caption' | // Active window title bar. Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled. + 'active-caption-gradient' | // Right side color in the color gradient of an active window's title bar. + 'app-workspace' | // Background color of multiple document interface (MDI) applications. + 'button-text' | // Text on push buttons. + 'caption-text' | // Text in caption, size box, and scroll bar arrow box. + 'desktop' | // Desktop background color. + 'disabled-text' | // Grayed (disabled) text. + 'highlight' | // Item(s) selected in a control. + 'highlight-text' | // Text of item(s) selected in a control. + 'hotlight' | // Color for a hyperlink or hot-tracked item. + 'inactive-border' | // Inactive window border. + 'inactive-caption' | // Inactive window caption. Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled. + 'inactive-caption-gradient' | // Right side color in the color gradient of an inactive window's title bar. + 'inactive-caption-text' | // Color of text in an inactive caption. + 'info-background' | // Background color for tooltip controls. + 'info-text' | // Text color for tooltip controls. + 'menu' | // Menu background. + 'menu-highlight' | // The color used to highlight menu items when the menu appears as a flat menu. + 'menubar' | // The background color for the menu bar when menus appear as flat menus. + 'menu-text' | // Text in menus. + 'scrollbar' | // Scroll bar gray area. + 'window' | // Window background. + 'window-frame' | // Window frame. + 'window-text'; // Text in windows. + + /** + * Get system preferences. + */ + interface SystemPreferences { + /** + * Note: This is only implemented on Windows. + */ + on(event: 'accent-color-changed', listener: (event: Event, newColor: string) => void): this; + /** + * Note: This is only implemented on Windows. + */ + on(event: 'color-changed', listener: (event: Event) => void): this; + /** + * Note: This is only implemented on Windows. + */ + on(event: 'inverted-color-scheme-changed', listener: ( + event: Event, + /** + * @param invertedColorScheme true if an inverted color scheme, such as a high contrast theme, is being used, false otherwise. + */ + invertedColorScheme: boolean + ) => void): this; + on(event: string, listener: Function): this; + /** + * @returns Whether the system is in Dark Mode. + * + * Note: This is only implemented on macOS. + */ + isDarkMode(): boolean; + /** + * @returns Whether the Swipe between pages setting is on. + * + * Note: This is only implemented on macOS. + */ + isSwipeTrackingFromScrollEventsEnabled(): boolean; + /** + * Posts event as native notifications of macOS. + * The userInfo contains the user information dictionary sent along with the notification. + * + * Note: This is only implemented on macOS. + */ + postNotification(event: string, userInfo: Object): void; + /** + * Posts event as native notifications of macOS. + * The userInfo contains the user information dictionary sent along with the notification. + * + * Note: This is only implemented on macOS. + */ + postLocalNotification(event: string, userInfo: Object): void; + /** + * Subscribes to native notifications of macOS, callback will be called when the corresponding event happens. + * The id of the subscriber is returned, which can be used to unsubscribe the event. + * + * Note: This is only implemented on macOS. + */ + subscribeNotification(event: string, callback: (event: Event, userInfo: Object) => void): number; + /** + * Removes the subscriber with id. + * + * Note: This is only implemented on macOS. + */ + unsubscribeNotification(id: number): void; + /** + * Same as subscribeNotification, but uses NSNotificationCenter for local defaults. + */ + subscribeLocalNotification(event: string, callback: (event: Event, userInfo: Object) => void): number; + /** + * Same as unsubscribeNotification, but removes the subscriber from NSNotificationCenter. + */ + unsubscribeLocalNotification(id: number): void; + /** + * Get the value of key in system preferences. + * + * Note: This is only implemented on macOS. + */ + getUserDefault(key: string, type: 'string' | 'boolean' | 'integer' | 'float' | 'double' | 'url' | 'array' | 'dictionary'): any; + /** + * @returns Whether DWM composition (Aero Glass) is enabled. + * + * Note: This is only implemented on Windows. + */ + isAeroGlassEnabled(): boolean; + /** + * @returns The users current system wide color preference in the form of an RGBA hexadecimal string. + * + * Note: This is only implemented on Windows. + */ + getAccentColor(): string; + /** + * @returns true if an inverted color scheme, such as a high contrast theme, is active, false otherwise. + * + * Note: This is only implemented on Windows. + */ + isInvertedColorScheme(): boolean; + /** + * @returns The system color setting in RGB hexadecimal form (#ABCDEF). See the Windows docs for more details. + * + * Note: This is only implemented on Windows. + */ + getColor(color: SystemColor): string; + } + + // https://github.com/electron/electron/blob/master/docs/api/tray.md + + /** + * A Tray represents an icon in an operating system's notification area. + */ + class Tray extends NodeJS.EventEmitter implements Destroyable { + /** + * Emitted when the tray icon is clicked. + * Note: The bounds payload is only implemented on macOS and Windows. + */ + on(event: 'click', listener: (modifiers: Modifiers, bounds: Rectangle) => void): this; + /** + * Emitted when the tray icon is right clicked. + * Note: This is only implemented on macOS and Windows. + */ + on(event: 'right-click', listener: (modifiers: Modifiers, bounds: Rectangle) => void): this; + /** + * Emitted when the tray icon is double clicked. + * Note: This is only implemented on macOS and Windows. + */ + on(event: 'double-click', listener: (modifiers: Modifiers, bounds: Rectangle) => void): this; + /** + * Emitted when the tray balloon shows. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-show', listener: Function): this; + /** + * Emitted when the tray balloon is clicked. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-click', listener: Function): this; + /** + * Emitted when the tray balloon is closed because of timeout or user manually closes it. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-closed', listener: Function): this; + /** + * Emitted when any dragged items are dropped on the tray icon. + * Note: This is only implemented on macOS. + */ + on(event: 'drop', listener: Function): this; + /** + * Emitted when dragged files are dropped in the tray icon. + * Note: This is only implemented on macOS + */ + on(event: 'drop-files', listener: (event: Event, files: string[]) => void): this; + /** + * Emitted when dragged text is dropped in the tray icon. + * Note: This is only implemented on macOS + */ + on(event: 'drop-text', listener: (event: Event, text: string) => void): this; + /** + * Emitted when a drag operation enters the tray icon. + * Note: This is only implemented on macOS + */ + on(event: 'drag-enter', listener: Function): this; + /** + * Emitted when a drag operation exits the tray icon. + * Note: This is only implemented on macOS + */ + on(event: 'drag-leave', listener: Function): this; + /** + * Emitted when a drag operation ends on the tray or ends at another location. + * Note: This is only implemented on macOS + */ + on(event: 'drag-end', listener: Function): this; + on(event: string, listener: Function): this; + /** + * Creates a new tray icon associated with the image. + */ + constructor(image: NativeImage|string); + /** + * Destroys the tray icon immediately. + */ + destroy(): void; + /** + * Sets the image associated with this tray icon. + */ + setImage(image: NativeImage|string): void; + /** + * Sets the image associated with this tray icon when pressed. + */ + setPressedImage(image: NativeImage): void; + /** + * Sets the hover text for this tray icon. + */ + setToolTip(toolTip: string): void; + /** + * Sets the title displayed aside of the tray icon in the status bar. + * Note: This is only implemented on macOS. + */ + setTitle(title: string): void; + /** + * Sets when the tray's icon background becomes highlighted. + * Note: This is only implemented on macOS. + */ + setHighlightMode(mode: 'selection' | 'always' | 'never'): void; + /** + * Displays a tray balloon. + * Note: This is only implemented on Windows. + */ + displayBalloon(options?: { + icon?: NativeImage; + title?: string; + content?: string; + }): void; + /** + * Pops up the context menu of tray icon. When menu is passed, + * the menu will showed instead of the tray's context menu. + * The position is only available on Windows, and it is (0, 0) by default. + * Note: This is only implemented on macOS and Windows. + */ + popUpContextMenu(menu?: Menu, position?: Point): void; + /** + * Sets the context menu for this icon. + */ + setContextMenu(menu: Menu): void; + /** + * @returns The bounds of this tray icon. + */ + getBounds(): Rectangle; + /** + * @returns Whether the tray icon is destroyed. + */ + isDestroyed(): boolean; + } + + interface Modifiers { + altKey: boolean; + shiftKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + } + + interface DragItem { + /** + * The absolute path of the file to be dragged + */ + file: string; + /** + * The image showing under the cursor when dragging. + */ + icon: NativeImage; + } + + // https://github.com/electron/electron/blob/master/docs/api/web-contents.md + + interface WebContentsStatic { + /** + * @returns An array of all WebContents instances. This will contain web contents for all windows, + * webviews, opened devtools, and devtools extension background pages. + */ + getAllWebContents(): WebContents[]; + /** + * @returns The web contents that is focused in this application, otherwise returns null. + */ + getFocusedWebContents(): WebContents; + /** + * Find a WebContents instance according to its ID. + */ + fromId(id: number): WebContents; + } + + /** + * A WebContents is responsible for rendering and controlling a web page. + */ + interface WebContents extends NodeJS.EventEmitter { + /** + * Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning, + * and the onload event was dispatched. + */ + on(event: 'did-finish-load', listener: Function): this; + /** + * This event is like did-finish-load but emitted when the load failed or was cancelled, + * e.g. window.stop() is invoked. + */ + on(event: 'did-fail-load', listener: (event: Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => void): this; + /** + * Emitted when a frame has done navigation. + */ + on(event: 'did-frame-finish-load', listener: (event: Event, isMainFrame: boolean) => void): this; + /** + * Corresponds to the points in time when the spinner of the tab started spinning. + */ + on(event: 'did-start-loading', listener: Function): this; + /** + * Corresponds to the points in time when the spinner of the tab stopped spinning. + */ + on(event: 'did-stop-loading', listener: Function): this; + /** + * Emitted when details regarding a requested resource are available. + * status indicates the socket connection to download the resource. + */ + on(event: 'did-get-response-details', listener: (event: Event, + status: boolean, + newURL: string, + originalURL: string, + httpResponseCode: number, + requestMethod: string, + referrer: string, + headers: Headers, + resourceType: string + ) => void): this; + /** + * Emitted when a redirect is received while requesting a resource. + */ + on(event: 'did-get-redirect-request', listener: (event: Event, + oldURL: string, + newURL: string, + isMainFrame: boolean, + httpResponseCode: number, + requestMethod: string, + referrer: string, + headers: Headers + ) => void): this; + /** + * Emitted when the document in the given frame is loaded. + */ + on(event: 'dom-ready', listener: (event: Event) => void): this; + /** + * Emitted when page receives favicon URLs. + */ + on(event: 'page-favicon-updated', listener: (event: Event, favicons: string[]) => void): this; + /** + * Emitted when the page requests to open a new window for a url. + * It could be requested by window.open or an external link like . + * + * By default a new BrowserWindow will be created for the url. + * + * Calling event.preventDefault() will prevent creating new windows. + * In such case, the event.newGuest may be set with a reference + * to a BrowserWindow instance to make it used by the Electron's runtime. + */ + on(event: 'new-window', listener: (event: WebContents.NewWindowEvent, + url: string, + frameName: string, + disposition: NewWindowDisposition, + /** + * The options which will be used for creating the new BrowserWindow. + */ + options: BrowserWindowOptions, + /** + * The non-standard features (features not handled by Chromium or Electron) given to window.open(). + */ + additionalFeatures: string[] + ) => void): this; + /** + * Emitted when a user or the page wants to start navigation. + * It can happen when the window.location object is changed or a user clicks a link in the page. + * + * This event will not emit when the navigation is started programmatically with APIs like + * webContents.loadURL and webContents.back. + * + * It is also not emitted for in-page navigations, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + * + * Calling event.preventDefault() will prevent the navigation. + */ + on(event: 'will-navigate', listener: (event: Event, url: string) => void): this; + /** + * Emitted when a navigation is done. + * + * This event is not emitted for in-page navigations, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + */ + on(event: 'did-navigate', listener: (event: Event, url: string) => void): this; + /** + * Emitted when an in-page navigation happened. + * + * When in-page navigation happens, the page URL changes but does not cause + * navigation outside of the page. Examples of this occurring are when anchor links + * are clicked or when the DOM hashchange event is triggered. + */ + on(event: 'did-navigate-in-page', listener: (event: Event, url: string, isMainFrame: boolean) => void): this; + /** + * Emitted when the renderer process has crashed. + */ + on(event: 'crashed', listener: (event: Event, killed: boolean) => void): this; + /** + * Emitted when a plugin process has crashed. + */ + on(event: 'plugin-crashed', listener: (event: Event, name: string, version: string) => void): this; + /** + * Emitted when webContents is destroyed. + */ + on(event: 'destroyed', listener: Function): this; + /** + * Emitted when DevTools is opened. + */ + on(event: 'devtools-opened', listener: Function): this; + /** + * Emitted when DevTools is closed. + */ + on(event: 'devtools-closed', listener: Function): this; + /** + * Emitted when DevTools is focused / opened. + */ + on(event: 'devtools-focused', listener: Function): this; + /** + * Emitted when failed to verify the certificate for url. + * The usage is the same with the "certificate-error" event of app. + */ + on(event: 'certificate-error', listener: (event: Event, + url: string, + error: string, + certificate: Certificate, + callback: (trust: boolean) => void + ) => void): this; + /** + * Emitted when a client certificate is requested. + * The usage is the same with the "select-client-certificate" event of app. + */ + on(event: 'select-client-certificate', listener: (event: Event, + url: string, + certificateList: Certificate[], + callback: (certificate: Certificate) => void + ) => void): this; + /** + * Emitted when webContents wants to do basic auth. + * The usage is the same with the "login" event of app. + */ + on(event: 'login', listener: (event: Event, + request: LoginRequest, + authInfo: LoginAuthInfo, + callback: (username: string, password: string) => void + ) => void): this; + /** + * Emitted when a result is available for webContents.findInPage request. + */ + on(event: 'found-in-page', listener: (event: Event, result: FoundInPageResult) => void): this; + /** + * Emitted when media starts playing. + */ + on(event: 'media-started-playing', listener: Function): this; + /** + * Emitted when media is paused or done playing. + */ + on(event: 'media-paused', listener: Function): this; + /** + * Emitted when a page’s theme color changes. This is usually due to encountering a meta tag: + * + */ + on(event: 'did-change-theme-color', listener: Function): this; + /** + * Emitted when mouse moves over a link or the keyboard moves the focus to a link. + */ + on(event: 'update-target-url', listener: (event: Event, url: string) => void): this; + /** + * Emitted when the cursor’s type changes. + * If the type parameter is custom, the image parameter will hold the custom cursor image + * in a NativeImage, and scale, size and hotspot will hold additional information about the custom cursor. + */ + on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number, size?: Size, hotspot?: Point) => void): this; + /** + * Emitted when there is a new context menu that needs to be handled. + */ + on(event: 'context-menu', listener: (event: Event, params: ContextMenuParams) => void): this; + /** + * Emitted when bluetooth device needs to be selected on call to navigator.bluetooth.requestDevice. + * To use navigator.bluetooth api webBluetooth should be enabled. + * If event.preventDefault is not called, first available device will be selected. + * callback should be called with deviceId to be selected, + * passing empty string to callback will cancel the request. + */ + on(event: 'select-bluetooth-device', listener: (event: Event, deviceList: BluetoothDevice[], callback: (deviceId: string) => void) => void): this; + /** + * Emitted when a new frame is generated. Only the dirty area is passed in the buffer. + */ + on(event: 'paint', listener: (event: Event, dirtyRect: Rectangle, image: NativeImage) => void): this; + on(event: string, listener: Function): this; + /** + * Loads the url in the window. + * @param url Must contain the protocol prefix (e.g., the http:// or file://). + */ + loadURL(url: string, options?: LoadURLOptions): void; + /** + * Initiates a download of the resource at url without navigating. + * The will-download event of session will be triggered. + */ + downloadURL(url: string): void; + /** + * @returns The URL of current web page. + */ + getURL(): string; + /** + * @returns The title of web page. + */ + getTitle(): string; + /** + * @returns The favicon of the web page. + */ + getFavicon(): NativeImage; + /** + * @returns Whether web page is still loading resources. + */ + isLoading(): boolean; + /** + * @returns Whether the main frame (and not just iframes or frames within it) is still loading. + */ + isLoadingMainFrame(): boolean; + /** + * @returns Whether web page is waiting for a first-response for the main + * resource of the page. + */ + isWaitingForResponse(): boolean; + /** + * Stops any pending navigation. + */ + stop(): void; + /** + * Reloads current page. + */ + reload(): void; + /** + * Reloads current page and ignores cache. + */ + reloadIgnoringCache(): void; + /** + * @returns Whether the web page can go back. + */ + canGoBack(): boolean; + /** + * @returns Whether the web page can go forward. + */ + canGoForward(): boolean; + /** + * @returns Whether the web page can go to offset. + */ + canGoToOffset(offset: number): boolean; + /** + * Clears the navigation history. + */ + clearHistory(): void; + /** + * Makes the web page go back. + */ + goBack(): void; + /** + * Makes the web page go forward. + */ + goForward(): void; + /** + * Navigates to the specified absolute index. + */ + goToIndex(index: number): void; + /** + * Navigates to the specified offset from the "current entry". + */ + goToOffset(offset: number): void; + /** + * @returns Whether the renderer process has crashed. + */ + isCrashed(): boolean; + /** + * Overrides the user agent for this page. + */ + setUserAgent(userAgent: string): void; + /** + * @returns The user agent for this web page. + */ + getUserAgent(): string; + /** + * Injects CSS into this page. + */ + insertCSS(css: string): void; + /** + * Evaluates code in page. + * @param code Code to evaluate. + */ + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + /** + * Mute the audio on the current web page. + */ + setAudioMuted(muted: boolean): void; + /** + * @returns Whether this page has been muted. + */ + isAudioMuted(): boolean; + /** + * Changes the zoom factor to the specified factor. + * Zoom factor is zoom percent divided by 100, so 300% = 3.0. + */ + setZoomFactor(factor: number): void; + /** + * Sends a request to get current zoom factor. + */ + getZoomFactor(callback: (zoomFactor: number) => void): void; + /** + * Changes the zoom level to the specified level. + * The original size is 0 and each increment above or below represents + * zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. + */ + setZoomLevel(level: number): void; + /** + * Sends a request to get current zoom level. + */ + getZoomLevel(callback: (zoomLevel: number) => void): void; + /** + * Sets the maximum and minimum zoom level. + */ + setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; + /** + * Executes the editing command undo in web page. + */ + undo(): void; + /** + * Executes the editing command redo in web page. + */ + redo(): void; + /** + * Executes the editing command cut in web page. + */ + cut(): void; + /** + * Executes the editing command copy in web page. + */ + copy(): void; + /** + * Copy the image at the given position to the clipboard. + */ + copyImageAt(x: number, y: number): void; + /** + * Executes the editing command paste in web page. + */ + paste(): void; + /** + * Executes the editing command pasteAndMatchStyle in web page. + */ + pasteAndMatchStyle(): void; + /** + * Executes the editing command delete in web page. + */ + delete(): void; + /** + * Executes the editing command selectAll in web page. + */ + selectAll(): void; + /** + * Executes the editing command unselect in web page. + */ + unselect(): void; + /** + * Executes the editing command replace in web page. + */ + replace(text: string): void; + /** + * Executes the editing command replaceMisspelling in web page. + */ + replaceMisspelling(text: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Starts a request to find all matches for the text in the web page. + * The result of the request can be obtained by subscribing to found-in-page event. + * @returns The request id used for the request. + */ + findInPage(text: string, options?: FindInPageOptions): number; + /** + * Stops any findInPage request for the webContents with the provided action. + */ + stopFindInPage(action: StopFindInPageAtion): void; + /** + * Checks if any serviceworker is registered. + */ + hasServiceWorker(callback: (hasServiceWorker: boolean) => void): void; + /** + * Unregisters any serviceworker if present. + */ + unregisterServiceWorker(callback: (isFulfilled: boolean) => void): void; + /** + * Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing. + * Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}). + * Note: On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size. + */ + print(options?: PrintOptions): void; + /** + * Prints windows' web page as PDF with Chromium's preview printing custom settings. + */ + printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void; + /** + * Adds the specified path to DevTools workspace. + */ + addWorkSpace(path: string): void; + /** + * Removes the specified path from DevTools workspace. + */ + removeWorkSpace(path: string): void; + /** + * Opens the developer tools. + */ + openDevTools(options?: { + /** + * Opens the devtools with specified dock state. Defaults to last used dock state. + */ + mode?: 'right' | 'bottom' | 'undocked' | 'detach' + }): void; + /** + * Closes the developer tools. + */ + closeDevTools(): void; + /** + * Returns whether the developer tools are opened. + */ + isDevToolsOpened(): boolean; + /** + * Returns whether the developer tools are focussed. + */ + isDevToolsFocused(): boolean; + /** + * Toggle the developer tools. + */ + toggleDevTools(): void; + /** + * Starts inspecting element at position (x, y). + */ + inspectElement(x: number, y: number): void; + /** + * Opens the developer tools for the service worker context. + */ + inspectServiceWorker(): void; + /** + * Send args.. to the web page via channel in asynchronous message, the web page + * can handle it by listening to the channel event of ipc module. + * Note: + * 1. The IPC message handler in web pages do not have a event parameter, + * which is different from the handlers on the main process. + * 2. There is no way to send synchronous messages from the main process + * to a renderer process, because it would be very easy to cause dead locks. + */ + send(channel: string, ...args: any[]): void; + /** + * Enable device emulation with the given parameters. + */ + enableDeviceEmulation(parameters: DeviceEmulationParameters): void; + /** + * Disable device emulation. + */ + disableDeviceEmulation(): void; + /** + * Sends an input event to the page. + */ + sendInputEvent(event: SendInputEvent): void; + /** + * Begin subscribing for presentation events and captured frames, + * The callback will be called when there is a presentation event. + */ + beginFrameSubscription(onlyDirty: boolean, callback: BeginFrameSubscriptionCallback): void; + /** + * Begin subscribing for presentation events and captured frames, + * The callback will be called when there is a presentation event. + */ + beginFrameSubscription(callback: BeginFrameSubscriptionCallback): void; + /** + * End subscribing for frame presentation events. + */ + endFrameSubscription(): void; + /** + * @returns If the process of saving page has been initiated successfully. + */ + savePage(fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', callback?: (eror: Error) => void): boolean; + /** + * Shows pop-up dictionary that searches the selected word on the page. + * Note: This API is available only on macOS. + */ + showDefinitionForSelection(): void; + /** + * @returns Whether offscreen rendering is enabled. + */ + isOffscreen(): boolean; + /** + * If offscreen rendering is enabled and not painting, start painting. + */ + startPainting(): void; + /** + * If offscreen rendering is enabled and painting, stop painting. + */ + stopPainting(): void; + /** + * If offscreen rendering is enabled returns whether it is currently painting. + */ + isPainting(): boolean; + /** + * If offscreen rendering is enabled sets the frame rate to the specified number. + * Only values between 1 and 60 are accepted. + */ + setFrameRate(fps: number): void; + /** + * If offscreen rendering is enabled returns the current frame rate. + */ + getFrameRate(): number; + /** + * If offscreen rendering is enabled invalidates the frame and generates a new one through the 'paint' event. + */ + invalidate(): void; + /** + * Sets the item as dragging item for current drag-drop operation. + */ + startDrag(item: DragItem): void; + /** + * Captures a snapshot of the page within rect. + */ + capturePage(callback: (image: NativeImage) => void): void; + /** + * Captures a snapshot of the page within rect. + */ + capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; + /** + * @returns The unique ID of this WebContents. + */ + id: number; + /** + * @returns The session object used by this webContents. + */ + session: Session; + /** + * @returns The WebContents that might own this WebContents. + */ + hostWebContents: WebContents; + /** + * @returns The WebContents of DevTools for this WebContents. + * Note: Users should never store this object because it may become null + * when the DevTools has been closed. + */ + devToolsWebContents: WebContents; + /** + * @returns Debugger API + */ + debugger: Debugger; + } + + namespace WebContents { + interface NewWindowEvent extends Event { + newGuest?: BrowserWindow; + } + } + + interface BeginFrameSubscriptionCallback { + ( + /** + * The frameBuffer is a Buffer that contains raw pixel data. + * On most machines, the pixel data is effectively stored in 32bit BGRA format, + * but the actual representation depends on the endianness of the processor + * (most modern processors are little-endian, on machines with big-endian + * processors the data is in 32bit ARGB format). + */ + frameBuffer: Buffer, + /** + * The dirtyRect is an object with x, y, width, height properties that describes which part of the page was repainted. + * If onlyDirty is set to true, frameBuffer will only contain the repainted area. onlyDirty defaults to false. + */ + dirtyRect?: Rectangle + ): void + } + + interface ContextMenuParams { + /** + * x coordinate + */ + x: number; + /** + * y coordinate + */ + y: number; + /** + * URL of the link that encloses the node the context menu was invoked on. + */ + linkURL: string; + /** + * Text associated with the link. May be an empty string if the contents of the link are an image. + */ + linkText: string; + /** + * URL of the top level page that the context menu was invoked on. + */ + pageURL: string; + /** + * URL of the subframe that the context menu was invoked on. + */ + frameURL: string; + /** + * Source URL for the element that the context menu was invoked on. + * Elements with source URLs are images, audio and video. + */ + srcURL: string; + /** + * Type of the node the context menu was invoked on. + */ + mediaType: 'none' | 'image' | 'audio' | 'video' | 'canvas' | 'file' | 'plugin'; + /** + * Parameters for the media element the context menu was invoked on. + */ + mediaFlags: { + /** + * Whether the media element has crashed. + */ + inError: boolean; + /** + * Whether the media element is paused. + */ + isPaused: boolean; + /** + * Whether the media element is muted. + */ + isMuted: boolean; + /** + * Whether the media element has audio. + */ + hasAudio: boolean; + /** + * Whether the media element is looping. + */ + isLooping: boolean; + /** + * Whether the media element's controls are visible. + */ + isControlsVisible: boolean; + /** + * Whether the media element's controls are toggleable. + */ + canToggleControls: boolean; + /** + * Whether the media element can be rotated. + */ + canRotate: boolean; + } + /** + * Whether the context menu was invoked on an image which has non-empty contents. + */ + hasImageContents: boolean; + /** + * Whether the context is editable. + */ + isEditable: boolean; + /** + * These flags indicate whether the renderer believes it is able to perform the corresponding action. + */ + editFlags: { + /** + * Whether the renderer believes it can undo. + */ + canUndo: boolean; + /** + * Whether the renderer believes it can redo. + */ + canRedo: boolean; + /** + * Whether the renderer believes it can cut. + */ + canCut: boolean; + /** + * Whether the renderer believes it can copy + */ + canCopy: boolean; + /** + * Whether the renderer believes it can paste. + */ + canPaste: boolean; + /** + * Whether the renderer believes it can delete. + */ + canDelete: boolean; + /** + * Whether the renderer believes it can select all. + */ + canSelectAll: boolean; + } + /** + * Text of the selection that the context menu was invoked on. + */ + selectionText: string; + /** + * Title or alt text of the selection that the context was invoked on. + */ + titleText: string; + /** + * The misspelled word under the cursor, if any. + */ + misspelledWord: string; + /** + * The character encoding of the frame on which the menu was invoked. + */ + frameCharset: string; + /** + * If the context menu was invoked on an input field, the type of that field. + */ + inputFieldType: 'none' | 'plainText' | 'password' | 'other'; + /** + * Input source that invoked the context menu. + */ + menuSourceType: 'none' | 'mouse' | 'keyboard' | 'touch' | 'touchMenu'; + } + + interface BluetoothDevice { + deviceName: string; + deviceId: string; + } + + interface Headers { + [key: string]: string; + } + + type NewWindowDisposition = 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'; + + /** + * Specifies the action to take place when ending webContents.findInPage request. + * 'clearSelection' - Clear the selection. + * 'keepSelection' - Translate the selection into a normal selection. + * 'activateSelection' - Focus and click the selection node. + */ + type StopFindInPageAtion = 'clearSelection' | 'keepSelection' | 'activateSelection'; + + type CursorType = 'default' | 'crosshair' | 'pointer' | 'text' | 'wait' | 'help' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'm-panning' | 'e-panning' | 'n-panning' | 'ne-panning' | 'nw-panning' | 's-panning' | 'se-panning' |'sw-panning' | 'w-panning' | 'move' | 'vertical-text' | 'cell' | 'context-menu' | 'alias' | 'progress' | 'nodrop' | 'copy' | 'none' | 'not-allowed' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing' | 'custom'; + + interface LoadURLOptions { + /** + * HTTP Referrer URL. + */ + httpReferrer?: string; + /** + * User agent originating the request. + */ + userAgent?: string; + /** + * Extra headers separated by "\n" + */ + extraHeaders?: string; + } + + interface PrintOptions { + /** + * Don't ask user for print settings. + * Defaults: false. + */ + silent?: boolean; + /** + * Also prints the background color and image of the web page. + * Defaults: false. + */ + printBackground?: boolean; + } + + interface PrintToPDFOptions { + /** + * Specify the type of margins to use. + * 0 - default + * 1 - none + * 2 - minimum + * Default: 0 + */ + marginsType?: number; + /** + * Specify page size of the generated PDF. + * Default: A4. + */ + pageSize?: 'A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid' | Size; + /** + * Whether to print CSS backgrounds. + * Default: false. + */ + printBackground?: boolean; + /** + * Whether to print selection only. + * Default: false. + */ + printSelectionOnly?: boolean; + /** + * true for landscape, false for portrait. + * Default: false. + */ + landscape?: boolean; + } + + interface Certificate { + /** + * PEM encoded data. + */ + data: string; + /** + * Issuer's Common Name. + */ + issuerName: string; + /** + * Subject's Common Name. + */ + subjectName: string; + /** + * Hex value represented string. + */ + serialNumber: string; + /** + * Start date of the certificate being valid in seconds. + */ + validStart: number; + /** + * End date of the certificate being valid in seconds. + */ + validExpiry: number; + /** + * Fingerprint of the certificate. + */ + fingerprint: string; + } + + interface LoginRequest { + method: string; + url: string; + referrer: string; + } + + interface LoginAuthInfo { + isProxy: boolean; + scheme: string; + host: string; + port: number; + realm: string; + } + + interface FindInPageOptions { + /** + * Whether to search forward or backward, defaults to true + */ + forward?: boolean; + /** + * Whether the operation is first request or a follow up, defaults to false. + */ + findNext?: boolean; + /** + * Whether search should be case-sensitive, defaults to false. + */ + matchCase?: boolean; + /** + * Whether to look only at the start of words. defaults to false. + */ + wordStart?: boolean; + /** + * When combined with wordStart, accepts a match in the middle of a word + * if the match begins with an uppercase letter followed by a lowercase + * or non-letter. Accepts several other intra-word matches, defaults to false. + */ + medialCapitalAsWordStart?: boolean; + } + + interface FoundInPageResult { + requestId: number; + /** + * Indicates if more responses are to follow. + */ + finalUpdate: boolean; + /** + * Position of the active match. + */ + activeMatchOrdinal?: number; + /** + * Number of Matches. + */ + matches?: number; + /** + * Coordinates of first match region. + */ + selectionArea?: Rectangle; + } + + interface DeviceEmulationParameters { + /** + * Specify the screen type to emulated + * Default: desktop + */ + screenPosition?: 'desktop' | 'mobile'; + /** + * Set the emulated screen size (screenPosition == mobile) + */ + screenSize?: Size; + /** + * Position the view on the screen (screenPosition == mobile) + * Default: {x: 0, y: 0} + */ + viewPosition?: Point; + /** + * Set the device scale factor (if zero defaults to original device scale factor) + * Default: 0 + */ + deviceScaleFactor: number; + /** + * Set the emulated view size (empty means no override). + */ + viewSize?: Size; + /** + * Whether emulated view should be scaled down if necessary to fit into available space + * Default: false + */ + fitToView?: boolean; + /** + * Offset of the emulated view inside available space (not in fit to view mode) + * Default: {x: 0, y: 0} + */ + offset?: Point; + /** + * Scale of emulated view inside available space (not in fit to view mode) + * Default: 1 + */ + scale: number; + } + + interface SendInputEvent { + type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove' | 'keyDown' | 'keyUp' | 'char'; + modifiers: ('shift' | 'control' | 'alt' | 'meta' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right')[]; + } + + interface SendInputKeyboardEvent extends SendInputEvent { + keyCode: string; + } + + interface SendInputMouseEvent extends SendInputEvent { + x: number; + y: number; + button?: 'left' | 'middle' | 'right'; + globalX?: number; + globalY?: number; + movementX?: number; + movementY?: number; + clickCount?: number; + } + + interface SendInputMouseWheelEvent extends SendInputEvent { + deltaX?: number; + deltaY?: number; + wheelTicksX?: number; + wheelTicksY?: number; + accelerationRatioX?: number; + accelerationRatioY?: number; + hasPreciseScrollingDeltas?: boolean; + canScroll?: boolean; + } + + /** + * Debugger API serves as an alternate transport for remote debugging protocol. + */ + interface Debugger extends NodeJS.EventEmitter { + /** + * Attaches the debugger to the webContents. + * @param protocolVersion Requested debugging protocol version. + */ + attach(protocolVersion?: string): void; + /** + * @returns Whether a debugger is attached to the webContents. + */ + isAttached(): boolean; + /** + * Detaches the debugger from the webContents. + */ + detach(): void; + /** + * Send given command to the debugging target. + * @param method Method name, should be one of the methods defined by the remote debugging protocol. + * @param commandParams JSON object with request parameters. + * @param callback Response defined by the ‘returns’ attribute of the command description in the remote debugging protocol. + */ + sendCommand(method: string, commandParams?: any, callback?: (error: Error, result: any) => void): void; + /** + * Emitted when debugging session is terminated. This happens either when + * webContents is closed or devtools is invoked for the attached webContents. + */ + on(event: 'detach', listener: (event: Event, reason: string) => void): this; + /** + * Emitted whenever debugging target issues instrumentation event. + * Event parameters defined by the ‘parameters’ attribute in the remote debugging protocol. + */ + on(event: 'message', listener: (event: Event, method: string, params: any) => void): this; + on(event: string, listener: Function): this; + } + + // https://github.com/electron/electron/blob/master/docs/api/web-frame.md + + /** + * The web-frame module allows you to customize the rendering of the current web page. + */ + interface WebFrame { + /** + * Changes the zoom factor to the specified factor, zoom factor is + * zoom percent / 100, so 300% = 3.0. + */ + setZoomFactor(factor: number): void; + /** + * @returns The current zoom factor. + */ + getZoomFactor(): number; + /** + * Changes the zoom level to the specified level, 0 is "original size", and each + * increment above or below represents zooming 20% larger or smaller to default + * limits of 300% and 50% of original size, respectively. + */ + setZoomLevel(level: number): void; + /** + * @returns The current zoom level. + */ + getZoomLevel(): number; + /** + * Sets the maximum and minimum zoom level. + */ + setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; + /** + * Sets a provider for spell checking in input fields and text areas. + */ + setSpellCheckProvider(language: string, autoCorrectWord: boolean, provider: { + /** + * @returns Whether the word passed is correctly spelled. + */ + spellCheck: (text: string) => boolean; + }): void; + /** + * Sets the scheme as secure scheme. Secure schemes do not trigger mixed content + * warnings. For example, https and data are secure schemes because they cannot be + * corrupted by active network attackers. + */ + registerURLSchemeAsSecure(scheme: string): void; + /** + * Resources will be loaded from this scheme regardless of the current page’s Content Security Policy. + */ + registerURLSchemeAsBypassingCSP(scheme: string): void; + /** + * Registers the scheme as secure, bypasses content security policy for resources, + * allows registering ServiceWorker and supports fetch API. + */ + registerURLSchemeAsPrivileged(scheme: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Evaluates `code` in page. + * In the browser window some HTML APIs like `requestFullScreen` can only be + * invoked by a gesture from the user. Setting `userGesture` to `true` will remove + * this limitation. + */ + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + /** + * @returns Object describing usage information of Blink’s internal memory caches. + */ + getResourceUsage(): ResourceUsages; + /** + * Attempts to free memory that is no longer being used (like images from a previous navigation). + */ + clearCache(): void; + } + + interface ResourceUsages { + fonts: ResourceUsage; + images: ResourceUsage; + cssStyleSheets: ResourceUsage; + xslStyleSheets: ResourceUsage; + scripts: ResourceUsage; + other: ResourceUsage; + } + + interface ResourceUsage { + count: number; + decodedSize: number; + liveSize: number; + purgeableSize: number; + purgedSize: number; + size: number; + } + + // https://github.com/electron/electron/blob/master/docs/api/web-view-tag.md + + /** + * Use the webview tag to embed 'guest' content (such as web pages) in your Electron app. + * The guest content is contained within the webview container. + * An embedded page within your app controls how the guest content is laid out and rendered. + * + * Unlike an iframe, the webview runs in a separate process than your app. + * It doesn't have the same permissions as your web page and all interactions between your app + * and embedded content will be asynchronous. This keeps your app safe from the embedded content. + */ + interface WebViewElement extends HTMLElement { + /** + * Returns the visible URL. Writing to this attribute initiates top-level navigation. + * Assigning src its own value will reload the current page. + * The src attribute can also accept data URLs, such as data:text/plain,Hello, world!. + */ + src: string; + /** + * If "on", the webview container will automatically resize within the bounds specified + * by the attributes minwidth, minheight, maxwidth, and maxheight. + * These constraints do not impact the webview unless autosize is enabled. + * When autosize is enabled, the webview container size cannot be less than + * the minimum values or greater than the maximum. + */ + autosize: string; + /** + * If "on", the guest page in webview will have node integration and can use node APIs + * like require and process to access low level system resources. + */ + nodeintegration: string; + /** + * If "on", the guest page in webview will be able to use browser plugins. + */ + plugins: string; + /** + * Specifies a script that will be loaded before other scripts run in the guest page. + * The protocol of script's URL must be either file: or asar:, + * because it will be loaded by require in guest page under the hood. + * + * When the guest page doesn't have node integration this script will still have access to all Node APIs, + * but global objects injected by Node will be deleted after this script has finished executing. + */ + preload: string; + /** + * Sets the referrer URL for the guest page. + */ + httpreferrer: string; + /** + * Sets the user agent for the guest page before the page is navigated to. + * Once the page is loaded, use the setUserAgent method to change the user agent. + */ + useragent: string; + /** + * If "on", the guest page will have web security disabled. + */ + disablewebsecurity: string; + /** + * Sets the session used by the page. If partition starts with persist:, + * the page will use a persistent session available to all pages in the app with the same partition. + * If there is no persist: prefix, the page will use an in-memory session. + * By assigning the same partition, multiple pages can share the same session. + * If the partition is unset then default session of the app will be used. + * + * This value can only be modified before the first navigation, + * since the session of an active renderer process cannot change. + * Subsequent attempts to modify the value will fail with a DOM exception. + */ + partition: string; + /** + * If "on", the guest page will be allowed to open new windows. + */ + allowpopups: string; + /** + * A list of strings which specifies the blink features to be enabled separated by ,. + */ + blinkfeatures: string; + /** + * A list of strings which specifies the blink features to be disabled separated by ,. + */ + disableblinkfeatures: string; + /** + * A value that links the webview to a specific webContents. + * When a webview first loads a new webContents is created and this attribute is set + * to its instance identifier. Setting this attribute on a new or existing webview connects + * it to the existing webContents that currently renders in a different webview. + * + * The existing webview will see the destroy event and will then create a new webContents when a new url is loaded. + */ + guestinstance: string; + /** + * Loads the url in the webview, the url must contain the protocol prefix, e.g. the http:// or file://. + */ + loadURL(url: string, options?: LoadURLOptions): void; + /** + * @returns URL of guest page. + */ + getURL(): string; + /** + * @returns The title of guest page. + */ + getTitle(): string; + /** + * @returns Whether the web page is destroyed. + */ + isDestroyed(): boolean; + /** + * @returns Whether the web page is focused. + */ + isFocused(): boolean; + /** + * @returns Whether guest page is still loading resources. + */ + isLoading(): boolean; + /** + * Returns a boolean whether the guest page is waiting for a first-response for the main resource of the page. + */ + isWaitingForResponse(): boolean; + /** + * Stops any pending navigation. + */ + stop(): void; + /** + * Reloads the guest page. + */ + reload(): void; + /** + * Reloads the guest page and ignores cache. + */ + reloadIgnoringCache(): void; + /** + * @returns Whether the guest page can go back. + */ + canGoBack(): boolean; + /** + * @returns Whether the guest page can go forward. + */ + canGoForward(): boolean; + /** + * @returns Whether the guest page can go to offset. + */ + canGoToOffset(offset: number): boolean; + /** + * Clears the navigation history. + */ + clearHistory(): void; + /** + * Makes the guest page go back. + */ + goBack(): void; + /** + * Makes the guest page go forward. + */ + goForward(): void; + /** + * Navigates to the specified absolute index. + */ + goToIndex(index: number): void; + /** + * Navigates to the specified offset from the "current entry". + */ + goToOffset(offset: number): void; + /** + * @returns Whether the renderer process has crashed. + */ + isCrashed(): boolean; + /** + * Overrides the user agent for the guest page. + */ + setUserAgent(userAgent: string): void; + /** + * @returns The user agent for guest page. + */ + getUserAgent(): string; + /** + * Injects CSS into the guest page. + */ + insertCSS(css: string): void; + /** + * Evaluates code in page. If userGesture is set, it will create the user gesture context in the page. + * HTML APIs like requestFullScreen, which require user action, can take advantage of this option for automation. + */ + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + /** + * Opens a DevTools window for guest page. + */ + openDevTools(): void; + /** + * Closes the DevTools window of guest page. + */ + closeDevTools(): void; + /** + * @returns Whether guest page has a DevTools window attached. + */ + isDevToolsOpened(): boolean; + /** + * @returns Whether DevTools window of guest page is focused. + */ + isDevToolsFocused(): boolean; + /** + * Starts inspecting element at position (x, y) of guest page. + */ + inspectElement(x: number, y: number): void; + /** + * Opens the DevTools for the service worker context present in the guest page. + */ + inspectServiceWorker(): void; + /** + * Set guest page muted. + */ + setAudioMuted(muted: boolean): void; + /** + * @returns Whether guest page has been muted. + */ + isAudioMuted(): boolean; + /** + * Executes editing command undo in page. + */ + undo(): void; + /** + * Executes editing command redo in page. + */ + redo(): void; + /** + * Executes editing command cut in page. + */ + cut(): void; + /** + * Executes editing command copy in page. + */ + copy(): void; + /** + * Executes editing command paste in page. + */ + paste(): void; + /** + * Executes editing command pasteAndMatchStyle in page. + */ + pasteAndMatchStyle(): void; + /** + * Executes editing command delete in page. + */ + delete(): void; + /** + * Executes editing command selectAll in page. + */ + selectAll(): void; + /** + * Executes editing command unselect in page. + */ + unselect(): void; + /** + * Executes editing command replace in page. + */ + replace(text: string): void; + /** + * Executes editing command replaceMisspelling in page. + */ + replaceMisspelling(text: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Starts a request to find all matches for the text in the web page. + * The result of the request can be obtained by subscribing to found-in-page event. + * @returns The request id used for the request. + */ + findInPage(text: string, options?: FindInPageOptions): number; + /** + * Stops any findInPage request for the webview with the provided action. + */ + stopFindInPage(action: StopFindInPageAtion): void; + /** + * Prints webview's web page. Same with webContents.print([options]). + */ + print(options?: PrintOptions): void; + /** + * Prints webview's web page as PDF, Same with webContents.printToPDF(options, callback) + */ + printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void; + /** + * Send an asynchronous message to renderer process via channel, you can also send arbitrary arguments. + * The renderer process can handle the message by listening to the channel event with the ipcRenderer module. + * See webContents.send for examples. + */ + send(channel: string, ...args: any[]): void; + /** + * Sends an input event to the page. + * See webContents.sendInputEvent for detailed description of event object. + */ + sendInputEvent(event: SendInputEvent): void + /** + * Changes the zoom factor to the specified factor. + * Zoom factor is zoom percent divided by 100, so 300% = 3.0. + */ + setZoomFactor(factor: number): void; + /** + * Changes the zoom level to the specified level. + * The original size is 0 and each increment above or below represents + * zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. + */ + setZoomLevel(level: number): void; + /** + * Shows pop-up dictionary that searches the selected word on the page. + * Note: This API is available only on macOS. + */ + showDefinitionForSelection(): void; + /** + * @returns The WebContents associated with this webview. + */ + getWebContents(): WebContents; + /** + * Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback). + */ + capturePage(callback: (image: NativeImage) => void): void; + /** + * Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback). + */ + capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; + /** + * Fired when a load has committed. This includes navigation within the current document + * as well as subframe document-level loads, but does not include asynchronous resource loads. + */ + addEventListener(type: 'load-commit', listener: (event: WebViewElement.LoadCommitEvent) => void, useCapture?: boolean): void; + /** + * Fired when the navigation is done, i.e. the spinner of the tab will stop spinning, and the onload event is dispatched. + */ + addEventListener(type: 'did-finish-load', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * This event is like did-finish-load, but fired when the load failed or was cancelled, e.g. window.stop() is invoked. + */ + addEventListener(type: 'did-fail-load', listener: (event: WebViewElement.DidFailLoadEvent) => void, useCapture?: boolean): void; + /** + * Fired when a frame has done navigation. + */ + addEventListener(type: 'did-frame-finish-load', listener: (event: WebViewElement.DidFrameFinishLoadEvent) => void, useCapture?: boolean): void; + /** + * Corresponds to the points in time when the spinner of the tab starts spinning. + */ + addEventListener(type: 'did-start-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Corresponds to the points in time when the spinner of the tab stops spinning. + */ + addEventListener(type: 'did-stop-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when details regarding a requested resource is available. + * status indicates socket connection to download the resource. + */ + addEventListener(type: 'did-get-response-details', listener: (event: WebViewElement.DidGetResponseDetails) => void, useCapture?: boolean): void; + /** + * Fired when a redirect was received while requesting a resource. + */ + addEventListener(type: 'did-get-redirect-request', listener: (event: WebViewElement.DidGetRedirectRequestEvent) => void, useCapture?: boolean): void; + /** + * Fired when document in the given frame is loaded. + */ + addEventListener(type: 'dom-ready', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when page title is set during navigation. explicitSet is false when title is synthesized from file URL. + */ + addEventListener(type: 'page-title-updated', listener: (event: WebViewElement.PageTitleUpdatedEvent) => void, useCapture?: boolean): void; + /** + * Fired when page receives favicon URLs. + */ + addEventListener(type: 'page-favicon-updated', listener: (event: WebViewElement.PageFaviconUpdatedEvent) => void, useCapture?: boolean): void; + /** + * Fired when page enters fullscreen triggered by HTML API. + */ + addEventListener(type: 'enter-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when page leaves fullscreen triggered by HTML API. + */ + addEventListener(type: 'leave-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when the guest window logs a console message. + */ + addEventListener(type: 'console-message', listener: (event: WebViewElement.ConsoleMessageEvent) => void, useCapture?: boolean): void; + /** + * Fired when a result is available for webview.findInPage request. + */ + addEventListener(type: 'found-in-page', listener: (event: WebViewElement.FoundInPageEvent) => void, useCapture?: boolean): void; + /** + * Fired when the guest page attempts to open a new browser window. + */ + addEventListener(type: 'new-window', listener: (event: WebViewElement.NewWindowEvent) => void, useCapture?: boolean): void; + /** + * Emitted when a user or the page wants to start navigation. + * It can happen when the window.location object is changed or a user clicks a link in the page. + * + * This event will not emit when the navigation is started programmatically with APIs + * like .loadURL and .back. + * + * It is also not emitted during in-page navigation, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + * + * Calling event.preventDefault() does NOT have any effect. + */ + addEventListener(type: 'will-navigate', listener: (event: WebViewElement.WillNavigateEvent) => void, useCapture?: boolean): void; + /** + * Emitted when a navigation is done. + * + * This event is not emitted for in-page navigations, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + */ + addEventListener(type: 'did-navigate', listener: (event: WebViewElement.DidNavigateEvent) => void, useCapture?: boolean): void; + /** + * Emitted when an in-page navigation happened. + * + * When in-page navigation happens, the page URL changes but does not cause + * navigation outside of the page. Examples of this occurring are when anchor links + * are clicked or when the DOM hashchange event is triggered. + */ + addEventListener(type: 'did-navigate-in-page', listener: (event: WebViewElement.DidNavigateInPageEvent) => void, useCapture?: boolean): void; + /** + * Fired when the guest page attempts to close itself. + */ + addEventListener(type: 'close', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when the guest page has sent an asynchronous message to embedder page. + */ + addEventListener(type: 'ipc-message', listener: (event: WebViewElement.IpcMessageEvent) => void, useCapture?: boolean): void; + /** + * Fired when the renderer process is crashed. + */ + addEventListener(type: 'crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when the gpu process is crashed. + */ + addEventListener(type: 'gpu-crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Fired when a plugin process is crashed. + */ + addEventListener(type: 'plugin-crashed', listener: (event: WebViewElement.PluginCrashedEvent) => void, useCapture?: boolean): void; + /** + * Fired when the WebContents is destroyed. + */ + addEventListener(type: 'destroyed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Emitted when media starts playing. + */ + addEventListener(type: 'media-started-playing', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Emitted when media is paused or done playing. + */ + addEventListener(type: 'media-paused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Emitted when a page's theme color changes. This is usually due to encountering a meta tag: + * + */ + addEventListener(type: 'did-change-theme-color', listener: (event: WebViewElement.DidChangeThemeColorEvent) => void, useCapture?: boolean): void; + /** + * Emitted when mouse moves over a link or the keyboard moves the focus to a link. + */ + addEventListener(type: 'update-target-url', listener: (event: WebViewElement.UpdateTargetUrlEvent) => void, useCapture?: boolean): void; + /** + * Emitted when DevTools is opened. + */ + addEventListener(type: 'devtools-opened', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Emitted when DevTools is closed. + */ + addEventListener(type: 'devtools-closed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + /** + * Emitted when DevTools is focused / opened. + */ + addEventListener(type: 'devtools-focused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + addEventListener(type: string, listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + } + + namespace WebViewElement { + type Event = ElectronPrivate.GlobalEvent; + + interface LoadCommitEvent extends Event { + url: string; + isMainFrame: boolean; + } + + interface DidFailLoadEvent extends Event { + errorCode: number; + errorDescription: string; + validatedURL: string; + isMainFrame: boolean; + } + + interface DidFrameFinishLoadEvent extends Event { + isMainFrame: boolean; + } + + interface DidGetResponseDetails extends Event { + status: boolean; + newURL: string; + originalURL: string; + httpResponseCode: number; + requestMethod: string; + referrer: string; + headers: Headers; + resourceType: string; + } + + interface DidGetRedirectRequestEvent extends Event { + oldURL: string; + newURL: string; + isMainFrame: boolean; + httpResponseCode: number; + requestMethod: string; + referrer: string; + headers: Headers; + } + + interface PageTitleUpdatedEvent extends Event { + title: string; + explicitSet: string; + } + + interface PageFaviconUpdatedEvent extends Event { + favicons: string[]; + } + + interface ConsoleMessageEvent extends Event { + level: number; + message: string; + line: number; + sourceId: string; + } + + interface FoundInPageEvent extends Event { + result: FoundInPageResult; + } + + interface NewWindowEvent extends Event { + url: string; + frameName: string; + disposition: NewWindowDisposition; + options: BrowserWindowOptions; + } + + interface WillNavigateEvent extends Event { + url: string; + } + + interface DidNavigateEvent extends Event { + url: string; + } + + interface DidNavigateInPageEvent extends Event { + url: string; + isMainFrame: boolean; + } + + interface IpcMessageEvent extends Event { + channel: string; + args: any[]; + } + + interface PluginCrashedEvent extends Event { + name: string; + version: string; + } + + interface DidChangeThemeColorEvent extends Event { + themeColor: string; + } + + interface UpdateTargetUrlEvent extends Event { + url: string; + } + } + + /** + * The BrowserWindowProxy object is returned from window.open and provides limited functionality with the child window. + */ + interface BrowserWindowProxy { + /** + * Removes focus from the child window. + */ + blur(): void; + /** + * Forcefully closes the child window without calling its unload event. + */ + close(): void; + /** + * Set to true after the child window gets closed. + */ + closed: boolean; + /** + * Evaluates the code in the child window. + */ + eval(code: string): void; + /** + * Focuses the child window (brings the window to front). + */ + focus(): void; + /** + * Sends a message to the child window with the specified origin or * for no origin preference. + * In addition to these methods, the child window implements window.opener object with no + * properties and a single method. + */ + postMessage(message: string, targetOrigin: string): void; + /** + * Invokes the print dialog on the child window. + */ + print(): void; + } + + // https://github.com/electron/electron/blob/master/docs/api/synopsis.md + + interface CommonElectron { + clipboard: Electron.Clipboard; + crashReporter: Electron.CrashReporter; + nativeImage: typeof Electron.NativeImage; + shell: Electron.Shell; + + app: Electron.App; + autoUpdater: Electron.AutoUpdater; + BrowserWindow: typeof Electron.BrowserWindow; + contentTracing: Electron.ContentTracing; + dialog: Electron.Dialog; + ipcMain: Electron.IpcMain; + globalShortcut: Electron.GlobalShortcut; + Menu: typeof Electron.Menu; + MenuItem: typeof Electron.MenuItem; + powerMonitor: Electron.PowerMonitor; + powerSaveBlocker: Electron.PowerSaveBlocker; + protocol: Electron.Protocol; + screen: Electron.Screen; + session: typeof Electron.Session; + systemPreferences: Electron.SystemPreferences; + Tray: typeof Electron.Tray; + webContents: Electron.WebContentsStatic; + } + + interface ElectronMainAndRenderer extends CommonElectron { + desktopCapturer: Electron.DesktopCapturer; + ipcRenderer: Electron.IpcRenderer; + remote: Electron.Remote; + webFrame: Electron.WebFrame; + } +} + +declare namespace ElectronPrivate { + type GlobalEvent = Event; +} + +interface Document { + createElement(tagName: 'webview'): Electron.WebViewElement; +} + +// https://github.com/electron/electron/blob/master/docs/api/window-open.md + +interface Window { + /** + * Creates a new window. + */ + open(url: string, frameName?: string, features?: string): Electron.BrowserWindowProxy; +} + +// https://github.com/electron/electron/blob/master/docs/api/file-object.md + +interface File { + /** + * Exposes the real path of the filesystem. + */ + path: string; +} + +// https://github.com/electron/electron/blob/master/docs/api/process.md + +declare namespace NodeJS { + + interface ProcessVersions { + /** + * Electron's version string. + */ + electron: string; + /** + * Chrome's version string. + */ + chrome: string; + } + + interface Process { + /** + * Setting this to true can disable the support for asar archives in Node's built-in modules. + */ + noAsar?: boolean; + /** + * Process's type + */ + type: 'browser' | 'renderer'; + /** + * Path to JavaScript source code. + */ + resourcesPath: string; + /** + * For Mac App Store build, this value is true, for other builds it is undefined. + */ + mas?: boolean; + /** + * If the app is running as a Windows Store app (appx), this value is true, for other builds it is undefined. + */ + windowsStore?: boolean; + /** + * When app is started by being passed as parameter to the default app, + * this value is true in the main process, otherwise it is undefined. + */ + defaultApp?: boolean; + /** + * Emitted when Electron has loaded its internal initialization script + * and is beginning to load the web page or the main script. + */ + on(event: 'loaded', listener: Function): this; + on(event: string, listener: Function): this; + /** + * Causes the main thread of the current process crash; + */ + crash(): void; + /** + * Causes the main thread of the current process hang. + */ + hang(): void; + /** + * Sets the file descriptor soft limit to maxDescriptors or the OS hard limit, + * whichever is lower for the current process. + * + * Note: This API is only available on macOS and Linux. + */ + setFdLimit(maxDescriptors: number): void; + /** + * @returns Object giving memory usage statistics about the current process. + * Note: All statistics are reported in Kilobytes. + */ + getProcessMemoryInfo(): ProcessMemoryInfo; + /** + * @returns Object giving memory usage statistics about the entire system. + * Note: All statistics are reported in Kilobytes. + */ + getSystemMemoryInfo(): SystemMemoryInfo; + } + + interface ProcessMemoryInfo { + /** + * The amount of memory currently pinned to actual physical RAM. + */ + workingSetSize: number; + /** + * The maximum amount of memory that has ever been pinned to actual physical RAM. + */ + peakWorkingSetSize: number; + /** + * The amount of memory not shared by other processes, such as JS heap or HTML content. + */ + privateBytes: number; + /** + * The amount of memory shared between processes, typically memory consumed by the Electron code itself. + */ + sharedBytes: number; + } + + interface SystemMemoryInfo { + /** + * The total amount of physical memory available to the system. + */ + total: number; + /** + * The total amount of memory not being used by applications or disk cache. + */ + free: number; + /** + * The total amount of swap memory available to the system. + */ + swapTotal: number; + /** + * The free amount of swap memory available to the system. + */ + swapFree: number; + } +} + +declare module 'electron' { + var electron: Electron.ElectronMainAndRenderer; + export = electron; +} + +interface NodeRequireFunction { + (moduleName: 'electron'): Electron.ElectronMainAndRenderer; +} diff --git a/fb/index.d.ts b/fb/index.d.ts index f641fa9820..a968d9f3c0 100644 --- a/fb/index.d.ts +++ b/fb/index.d.ts @@ -29,13 +29,13 @@ interface PageTabDialogParams { interface RequestsDialogParams { method: string; // "apprequests" - app_id: string; + app_id?: string; redirect_uri?: string; to?: string; message: string; action_type?: string; // "send" | "askfor" | "turn" object_id?: string; - filters: string /* "app_users" | "app_non_users" */ | { + filters: string[] | { name: string; user_ids: string[]; }; diff --git a/fbemitter/fbemitter-tests.ts b/fbemitter/fbemitter-tests.ts index 11e1ce74a5..2085f9ac51 100644 --- a/fbemitter/fbemitter-tests.ts +++ b/fbemitter/fbemitter-tests.ts @@ -2,6 +2,7 @@ /// /// /// + 'use strict'; /** diff --git a/finalhandler/index.d.ts b/finalhandler/index.d.ts index 07bbe63c91..a238c0d2a5 100644 --- a/finalhandler/index.d.ts +++ b/finalhandler/index.d.ts @@ -5,7 +5,6 @@ /// - import {ServerRequest, ServerResponse} from "http"; declare function finalHandler(req: ServerRequest, res: ServerResponse, options?: finalHandler.Options): (err: any) => void; diff --git a/fs-extra/index.d.ts b/fs-extra/index.d.ts index 5d53a4d28f..c24ee5a49d 100644 --- a/fs-extra/index.d.ts +++ b/fs-extra/index.d.ts @@ -18,6 +18,9 @@ export declare function copySync(src: string, dest: string): void; export declare function copySync(src: string, dest: string, filter: CopyFilter): void; export declare function copySync(src: string, dest: string, options: CopyOptions): void; +export declare function move(src: string, dest: string, callback?: (err: Error) => void): void; +export declare function move(src: string, dest: string, options: MoveOptions, callback?: (err: Error) => void): void; + export declare function createFile(file: string, callback?: (err: Error) => void): void; export declare function createFileSync(file: string): void; @@ -89,6 +92,11 @@ export interface CopyOptions { limit?: number; } +export interface MoveOptions { + clobber? : boolean; + limit?: number; +} + export interface OpenOptions { encoding?: string; flag?: string; diff --git a/fullcalendar/index.d.ts b/fullcalendar/index.d.ts index fc687696f1..21f0e4a9be 100644 --- a/fullcalendar/index.d.ts +++ b/fullcalendar/index.d.ts @@ -136,7 +136,13 @@ export interface Options extends AgendaOptions, EventDraggingResizingOptions, Dr eventAfterAllRender?: (view: ViewObject) => void; eventDestroy?: (event: EventObject, element: JQuery, view: ViewObject) => void; - //scheduler options + //scheduler options + resourceAreaWidth?:number, + schedulerLicenseKey?:string, + customButtons?:any, + resourceLabelText?:any, + resourceColumns?:any, + displayEventTime?:any, } /** diff --git a/greensock/index.d.ts b/greensock/index.d.ts index 95c2ad6a4c..881fb1cd92 100644 --- a/greensock/index.d.ts +++ b/greensock/index.d.ts @@ -161,7 +161,7 @@ declare class TimelineLite extends SimpleTimeline { static exportRoot(vars?: Object, omitDelayedCalls?: boolean): TimelineLite; from(target: Object, duration: number, vars: Object, position?: any): TimelineLite; fromTo(target: Object, duration: number, fromVars: Object, toVars: Object, position?: any): TimelineLite; - getChildren(nested?: boolean, tweens?: boolean, timelines?: boolean, ignoreBeforeTime?: number): Tween | Timeline[]; + getChildren(nested?: boolean, tweens?: boolean, timelines?: boolean, ignoreBeforeTime?: number): (Tween | Timeline)[]; getLabelTime(label: string): number; getTweensOf(target: Object, nested?: boolean): Tween[]; recent(): Animation; diff --git a/handsontable/index.d.ts b/handsontable/index.d.ts index 7a82509baa..49b4a307a5 100644 --- a/handsontable/index.d.ts +++ b/handsontable/index.d.ts @@ -290,3 +290,9 @@ declare namespace ht { declare var Handsontable: { new (element: Element, options: ht.Options): ht.Methods; }; + +declare module "handsontable" { + export var Handsontable: { + new (element: Element, options: ht.Options): ht.Methods; + }; +} diff --git a/hapi-decorators/hapi-decorators-tests.ts b/hapi-decorators/hapi-decorators-tests.ts index 57d0c1a232..2a05f67e4d 100644 --- a/hapi-decorators/hapi-decorators-tests.ts +++ b/hapi-decorators/hapi-decorators-tests.ts @@ -1,6 +1,3 @@ -/// -/// - import * as hapi from 'hapi'; import { controller, get, post, put, cache, config, route, validate, Controller } from 'hapi-decorators'; diff --git a/hapi-decorators/tsconfig.json b/hapi-decorators/tsconfig.json index a763c6c6cd..3c7877c976 100644 --- a/hapi-decorators/tsconfig.json +++ b/hapi-decorators/tsconfig.json @@ -17,4 +17,4 @@ "index.d.ts", "hapi-decorators-tests.ts" ] -} \ No newline at end of file +} diff --git a/hapi/hapi-8.2.0.d.ts b/hapi/hapi-8.2.0.d.ts index d3f51873d9..9a9355412d 100644 --- a/hapi/hapi-8.2.0.d.ts +++ b/hapi/hapi-8.2.0.d.ts @@ -304,9 +304,9 @@ export interface ISessionHandler { export interface IStrictSessionHandler { (request: Request, reply: IStrictReply): void; -} + } -export interface IRequestHandler { + export interface IRequestHandler { (request: Request): T; } diff --git a/hapi/hapi-tests.ts b/hapi/hapi-tests.ts index 2ee355e9d1..97c4a77b44 100644 --- a/hapi/hapi-tests.ts +++ b/hapi/hapi-tests.ts @@ -116,8 +116,8 @@ server.route([{ server.route({ method: 'GET', path: '/hello6', - handler: function (request, reply) { - request.log('info', { route: '/hello' }, Date.now()); + handler: function (request: Hapi.Request, reply: Hapi.IReply) { + request.log('info', { route: '/hello' }, Date.now()); reply('hello world'); } }); diff --git a/highcharts/highstock.d.ts b/highcharts/highstock.d.ts index f312286745..332ea3d5ca 100644 --- a/highcharts/highstock.d.ts +++ b/highcharts/highstock.d.ts @@ -28,10 +28,10 @@ declare namespace __Highstock { } interface RangeSelectorButton { - type: string; //Defines the timespan, can be one of 'millisecond', 'second', 'minute', 'day', 'week', 'month', 'ytd' (year to date), 'year' and 'all'. - count?: number; - text: string; - dataGrouping?: any; //not sure how this works + type: string; //Defines the timespan, can be one of 'millisecond', 'second', 'minute', 'day', 'week', 'month', 'ytd' (year to date), 'year' and 'all'. + count?: number; + text: string; + dataGrouping?: any; //not sure how this works } interface RangeSelectorOptions { @@ -59,24 +59,24 @@ declare namespace __Highstock { } interface ScrollbarOptions { - barBackgroundColor?: string; - barBorderColor?: string; - barBorderRadius?: number; - barBorderWidth?: number; - buttonArrowColor?: string; - buttonBackgroundColor?: string; - buttonBorderColor?: string; - buttonBorderRadius?: number; - buttonBorderWidth?: number; - enabled?: boolean; - height?: number; - liveRedraw?: boolean; - minWidth?: number; - rifleColor?: string; - trackBackgroundColor?: string; - trackBorderColor?: string; - trackBorderRadius?: number; - trackBorderWidth?: number; + barBackgroundColor?: string; + barBorderColor?: string; + barBorderRadius?: number; + barBorderWidth?: number; + buttonArrowColor?: string; + buttonBackgroundColor?: string; + buttonBorderColor?: string; + buttonBorderRadius?: number; + buttonBorderWidth?: number; + enabled?: boolean; + height?: number; + liveRedraw?: boolean; + minWidth?: number; + rifleColor?: string; + trackBackgroundColor?: string; + trackBorderColor?: string; + trackBorderRadius?: number; + trackBorderWidth?: number; } interface Options extends Highcharts.Options { @@ -119,3 +119,4 @@ interface JQuery { highcharts(type: string, options: Highcharts.Options): JQuery; highcharts(type: string, options: Highcharts.Options, callback: (chart: Highcharts.ChartObject) => void): JQuery; } + diff --git a/http-errors/index.d.ts b/http-errors/index.d.ts index 7766aa3508..883fbf0ac1 100644 --- a/http-errors/index.d.ts +++ b/http-errors/index.d.ts @@ -3,89 +3,90 @@ // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare module 'http-errors' { + namespace createHttpError { -declare namespace createHttpError { + // See https://github.com/jshttp/http-errors/blob/1.3.1/index.js#L42 + interface HttpError extends Error { + status: number; + statusCode: number; + expose: boolean; + } - // See https://github.com/jshttp/http-errors/blob/1.3.1/index.js#L42 - interface HttpError extends Error { - status: number; - statusCode: number; - expose: boolean; + type HttpErrorConstructor = new(msg?: string) => HttpError; + + interface CreateHttpError { + // See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674 + [code: string]: new () => HttpError; + + (...args: Array): HttpError; + + Continue: HttpErrorConstructor; + SwitchingProtocols: HttpErrorConstructor; + Processing: HttpErrorConstructor; + OK: HttpErrorConstructor; + Created: HttpErrorConstructor; + Accepted: HttpErrorConstructor; + NonAuthoritativeInformation: HttpErrorConstructor; + NoContent: HttpErrorConstructor; + ResetContent: HttpErrorConstructor; + PartialContent: HttpErrorConstructor; + MultiStatus: HttpErrorConstructor; + AlreadyReported: HttpErrorConstructor; + IMUsed: HttpErrorConstructor; + MultipleChoices: HttpErrorConstructor; + MovedPermanently: HttpErrorConstructor; + Found: HttpErrorConstructor; + SeeOther: HttpErrorConstructor; + NotModified: HttpErrorConstructor; + UseProxy: HttpErrorConstructor; + Unused: HttpErrorConstructor; + TemporaryRedirect: HttpErrorConstructor; + PermanentRedirect: HttpErrorConstructor; + BadRequest: HttpErrorConstructor; + Unauthorized: HttpErrorConstructor; + PaymentRequired: HttpErrorConstructor; + Forbidden: HttpErrorConstructor; + NotFound: HttpErrorConstructor; + MethodNotAllowed: HttpErrorConstructor; + NotAcceptable: HttpErrorConstructor; + ProxyAuthenticationRequired: HttpErrorConstructor; + RequestTimeout: HttpErrorConstructor; + Conflict: HttpErrorConstructor; + Gone: HttpErrorConstructor; + LengthRequired: HttpErrorConstructor; + PreconditionFailed: HttpErrorConstructor; + PayloadTooLarge: HttpErrorConstructor; + URITooLong: HttpErrorConstructor; + UnsupportedMediaType: HttpErrorConstructor; + RangeNotSatisfiable: HttpErrorConstructor; + ExpectationFailed: HttpErrorConstructor; + ImATeapot: HttpErrorConstructor; + MisdirectedRequest: HttpErrorConstructor; + UnprocessableEntity: HttpErrorConstructor; + Locked: HttpErrorConstructor; + FailedDependency: HttpErrorConstructor; + UnorderedCollection: HttpErrorConstructor; + UpgradeRequired: HttpErrorConstructor; + PreconditionRequired: HttpErrorConstructor; + TooManyRequests: HttpErrorConstructor; + RequestHeaderFieldsTooLarge: HttpErrorConstructor; + UnavailableForLegalReasons: HttpErrorConstructor; + InternalServerError: HttpErrorConstructor; + NotImplemented: HttpErrorConstructor; + BadGateway: HttpErrorConstructor; + ServiceUnavailable: HttpErrorConstructor; + GatewayTimeout: HttpErrorConstructor; + HTTPVersionNotSupported: HttpErrorConstructor; + VariantAlsoNegotiates: HttpErrorConstructor; + InsufficientStorage: HttpErrorConstructor; + LoopDetected: HttpErrorConstructor; + BandwidthLimitExceeded: HttpErrorConstructor; + NotExtended: HttpErrorConstructor; + NetworkAuthenticationRequired: HttpErrorConstructor; + } } - - type HttpErrorConstructor = new(msg?: string) => HttpError; - interface CreateHttpError { - // See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674 - [code: string]: new () => HttpError; - - (...args: Array): HttpError; - - Continue: HttpErrorConstructor; - SwitchingProtocols: HttpErrorConstructor; - Processing: HttpErrorConstructor; - OK: HttpErrorConstructor; - Created: HttpErrorConstructor; - Accepted: HttpErrorConstructor; - NonAuthoritativeInformation: HttpErrorConstructor; - NoContent: HttpErrorConstructor; - ResetContent: HttpErrorConstructor; - PartialContent: HttpErrorConstructor; - MultiStatus: HttpErrorConstructor; - AlreadyReported: HttpErrorConstructor; - IMUsed: HttpErrorConstructor; - MultipleChoices: HttpErrorConstructor; - MovedPermanently: HttpErrorConstructor; - Found: HttpErrorConstructor; - SeeOther: HttpErrorConstructor; - NotModified: HttpErrorConstructor; - UseProxy: HttpErrorConstructor; - Unused: HttpErrorConstructor; - TemporaryRedirect: HttpErrorConstructor; - PermanentRedirect: HttpErrorConstructor; - BadRequest: HttpErrorConstructor; - Unauthorized: HttpErrorConstructor; - PaymentRequired: HttpErrorConstructor; - Forbidden: HttpErrorConstructor; - NotFound: HttpErrorConstructor; - MethodNotAllowed: HttpErrorConstructor; - NotAcceptable: HttpErrorConstructor; - ProxyAuthenticationRequired: HttpErrorConstructor; - RequestTimeout: HttpErrorConstructor; - Conflict: HttpErrorConstructor; - Gone: HttpErrorConstructor; - LengthRequired: HttpErrorConstructor; - PreconditionFailed: HttpErrorConstructor; - PayloadTooLarge: HttpErrorConstructor; - URITooLong: HttpErrorConstructor; - UnsupportedMediaType: HttpErrorConstructor; - RangeNotSatisfiable: HttpErrorConstructor; - ExpectationFailed: HttpErrorConstructor; - ImATeapot: HttpErrorConstructor; - MisdirectedRequest: HttpErrorConstructor; - UnprocessableEntity: HttpErrorConstructor; - Locked: HttpErrorConstructor; - FailedDependency: HttpErrorConstructor; - UnorderedCollection: HttpErrorConstructor; - UpgradeRequired: HttpErrorConstructor; - PreconditionRequired: HttpErrorConstructor; - TooManyRequests: HttpErrorConstructor; - RequestHeaderFieldsTooLarge: HttpErrorConstructor; - UnavailableForLegalReasons: HttpErrorConstructor; - InternalServerError: HttpErrorConstructor; - NotImplemented: HttpErrorConstructor; - BadGateway: HttpErrorConstructor; - ServiceUnavailable: HttpErrorConstructor; - GatewayTimeout: HttpErrorConstructor; - HTTPVersionNotSupported: HttpErrorConstructor; - VariantAlsoNegotiates: HttpErrorConstructor; - InsufficientStorage: HttpErrorConstructor; - LoopDetected: HttpErrorConstructor; - BandwidthLimitExceeded: HttpErrorConstructor; - NotExtended: HttpErrorConstructor; - NetworkAuthenticationRequired: HttpErrorConstructor; - } + var createHttpError: createHttpError.CreateHttpError; + export = createHttpError; } - -declare var createHttpError: createHttpError.CreateHttpError; -export = createHttpError; diff --git a/i18next/index.d.ts b/i18next/index.d.ts index 39e0f2a1a2..03dcb9daac 100644 --- a/i18next/index.d.ts +++ b/i18next/index.d.ts @@ -130,6 +130,8 @@ declare namespace i18n { on(languageChanged: 'languageChanged', listener: (lng: string) => void): void; off(event: string, listener: () => void): void; + + options: Options; } } diff --git a/inquirer/index.d.ts b/inquirer/index.d.ts index b60dfef00d..618da5593d 100644 --- a/inquirer/index.d.ts +++ b/inquirer/index.d.ts @@ -111,7 +111,7 @@ declare namespace inquirer { * A key/value hash containing the client answers in each prompt. */ interface Answers { - [key: string]: any; + [key: string]: any; } namespace ui { diff --git a/jquery-handsontable/index.d.ts b/jquery-handsontable/index.d.ts index 7b4deaabdf..bdbd5b713a 100644 --- a/jquery-handsontable/index.d.ts +++ b/jquery-handsontable/index.d.ts @@ -292,6 +292,11 @@ declare namespace Handsontable { */ manualRowResize?: boolean; + /** + * Turns on Manual row move, if set to a boolean or define initial row order, if set to an array of row indexes. + */ + manualRowMove?: boolean; + /** * Setting to true enables the copyPaste plugin, which enables the copying and pasting to the clipboard. */ diff --git a/kafka-node/index.d.ts b/kafka-node/index.d.ts index 347cc066f0..049278ac51 100644 --- a/kafka-node/index.d.ts +++ b/kafka-node/index.d.ts @@ -66,6 +66,8 @@ export declare class Offset { fetch(payloads: Array, cb: (error: any, data: any) => any): void; commit(groupId: string, payloads: Array, cb: (error: any, data: any) => any): void; fetchCommits(groupId: string, payloads: Array, cb: (error: any, data: any) => any): void; + fetchLatestOffsets(topics: Array, cb: (error: any, data: any) => any): void; + on(eventName: string, cb: (error: any) => any): void; } export declare class KeyedMessage { @@ -100,6 +102,8 @@ export interface ConsumerOptions { export interface Topic { topic: string; offset?: number; + encoding?: string; + autoCommit?: boolean; } export interface OffsetRequest { diff --git a/kefir/index.d.ts b/kefir/index.d.ts index d445be74ad..93d1c6c14f 100644 --- a/kefir/index.d.ts +++ b/kefir/index.d.ts @@ -16,6 +16,17 @@ export interface Observer { end?: () => void; } +export interface Subscription { + unsubscribe(): void; + closed: boolean; // Actually, `readonly` but it's avaiable in tsc starting with 2.0.0 +} + +export interface Observer { + value?: (value: T) => void; + error?: (error: S) => void; + end?: () => void; +} + export interface Observable { // Subscribe / add side effects onValue(callback: (value: T) => void): void; diff --git a/kendo-ui/index.d.ts b/kendo-ui/index.d.ts index 43af9f8305..fb033d78ec 100644 --- a/kendo-ui/index.d.ts +++ b/kendo-ui/index.d.ts @@ -1026,6 +1026,8 @@ declare namespace kendo.data { class DataSource extends Observable{ options: DataSourceOptions; + transports: any; + static create(options?: DataSourceOptions): DataSource; constructor(options?: DataSourceOptions); diff --git a/knex/index.d.ts b/knex/index.d.ts index 905841283d..0b69f64109 100644 --- a/knex/index.d.ts +++ b/knex/index.d.ts @@ -326,9 +326,9 @@ declare namespace Knex { } interface Transaction extends QueryBuilder { - commit: any; - rollback: any; - raw: Knex.RawBuilder; + commit: any; + rollback: any; + raw: Knex.RawBuilder; } // @@ -349,37 +349,39 @@ declare namespace Knex { } interface TableBuilder { - increments(columnName?: string): ColumnBuilder; - bigIncrements(columnName?: string): ColumnBuilder; - dropColumn(columnName: string): TableBuilder; - dropColumns(...columnNames: string[]): TableBuilder; - renameColumn(from: string, to: string): ColumnBuilder; - integer(columnName: string): ColumnBuilder; - bigInteger(columnName: string): ColumnBuilder; - text(columnName: string, textType?: string): ColumnBuilder; - string(columnName: string, length?: number): ColumnBuilder; - float(columnName: string, precision?: number, scale?: number): ColumnBuilder; - decimal(columnName: string, precision?: number, scale?: number): ColumnBuilder; - boolean(columnName: string): ColumnBuilder; - date(columnName: string): ColumnBuilder; - dateTime(columnName: string): ColumnBuilder; - time(columnName: string): ColumnBuilder; - timestamp(columnName: string): ColumnBuilder; - timestamps(): ColumnBuilder; - binary(columnName: string): ColumnBuilder; - enum(columnName: string, values: Value[]): ColumnBuilder; - enu(columnName: string, values: Value[]): ColumnBuilder; - json(columnName: string): ColumnBuilder; - jsonb(columnName: string): ColumnBuilder; - uuid(columnName: string): ColumnBuilder; - comment(val: string): TableBuilder; - specificType(columnName: string, type: string): ColumnBuilder; - primary(columnNames: string[]) : TableBuilder; - index(columnNames: string[], indexName?: string, indexType?: string) : TableBuilder; - unique(columnNames: string[], indexName?: string) : TableBuilder; - foreign(column: string): ForeignConstraintBuilder; - foreign(columns: string[]): MultikeyForeignConstraintBuilder; - dropForeign(columnNames: string[], foreignKeyName?: string): TableBuilder; + increments(columnName?: string): ColumnBuilder; + bigIncrements(columnName?: string): ColumnBuilder; + dropColumn(columnName: string): TableBuilder; + dropColumns(...columnNames: string[]): TableBuilder; + renameColumn(from: string, to: string): ColumnBuilder; + integer(columnName: string): ColumnBuilder; + bigInteger(columnName: string): ColumnBuilder; + text(columnName: string, textType?: string): ColumnBuilder; + string(columnName: string, length?: number): ColumnBuilder; + float(columnName: string, precision?: number, scale?: number): ColumnBuilder; + decimal(columnName: string, precision?: number, scale?: number): ColumnBuilder; + boolean(columnName: string): ColumnBuilder; + date(columnName: string): ColumnBuilder; + dateTime(columnName: string): ColumnBuilder; + time(columnName: string): ColumnBuilder; + timestamp(columnName: string): ColumnBuilder; + timestamps(): ColumnBuilder; + binary(columnName: string): ColumnBuilder; + enum(columnName: string, values: Value[]): ColumnBuilder; + enu(columnName: string, values: Value[]): ColumnBuilder; + json(columnName: string): ColumnBuilder; + jsonb(columnName: string): ColumnBuilder; + uuid(columnName: string): ColumnBuilder; + comment(val: string): TableBuilder; + specificType(columnName: string, type: string): ColumnBuilder; + primary(columnNames: string[]): TableBuilder; + index(columnNames: string[], indexName?: string, indexType?: string): TableBuilder; + unique(columnNames: string[], indexName?: string): TableBuilder; + foreign(column: string): ForeignConstraintBuilder; + foreign(columns: string[]): MultikeyForeignConstraintBuilder; + dropForeign(columnNames: string[], foreignKeyName?: string): TableBuilder; + dropUnique(columnNames: string[], indexName?: string): TableBuilder; + dropPrimary(constraintName?: string): TableBuilder; } interface CreateTableBuilder extends TableBuilder { diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index eaab2ca8bd..353c382973 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -453,6 +453,10 @@ knex.schema.raw("SET sql_mode='TRADITIONAL'") table.dropColumn('name'); table.string('first_name'); table.string('last_name'); + table.dropUnique(["name1", "name2"], "index_name"); + table.dropUnique(["name1", "name2"]); + table.dropPrimary(); + table.dropPrimary("constraint_name"); }); knex('users') diff --git a/knockout/index.d.ts b/knockout/index.d.ts index e44f15814c..3db35f7578 100644 --- a/knockout/index.d.ts +++ b/knockout/index.d.ts @@ -332,7 +332,7 @@ interface KnockoutUtils { } interface KnockoutArrayChange { - status: "added" | "deleted"; + status: "added" | "deleted" | "retained"; value: T; index: number; moved?: number; diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index d16be0bc1f..1adf9f0b0b 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Leaflet.js 1.0.0-rc3 +// Type definitions for Leaflet.js 1.0.0 // Project: https://github.com/Leaflet/Leaflet // Definitions by: Alejandro Sánchez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -1413,8 +1413,12 @@ declare namespace L { createShadow(oldIcon?: HTMLElement): HTMLElement; } + export interface IconDefault extends Icon { + imagePath: string; + } + export namespace Icon { - export const Default: Icon; + export const Default: IconDefault; } export function icon(options: IconOptions): Icon; @@ -1471,45 +1475,25 @@ declare namespace L { export const gecko: boolean; export const android: boolean; export const android23: boolean; - export const chrome: boolean; - export const safari: boolean; - export const win: boolean; - export const ie3d: boolean; - export const webkit3d: boolean; - export const gecko3d: boolean; - export const opera12: boolean; - export const any3d: boolean; - export const mobile: boolean; - export const mobileWebkit: boolean; - export const mobiWebkit3d: boolean; - export const mobileOpera: boolean; - export const mobileGecko: boolean; - export const touch: boolean; - export const msPointer: boolean; - export const pointer: boolean; - export const retina: boolean; - export const canvas: boolean; - export const vml: boolean; - export const svg: boolean; } } diff --git a/lodash/index.d.ts b/lodash/index.d.ts index f8b14bb3af..507d8b3250 100644 --- a/lodash/index.d.ts +++ b/lodash/index.d.ts @@ -1594,12 +1594,13 @@ declare module _ { * * @param array The array to search. * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. + * @param fromIndex The index to search from. * @return Returns the index of the found element, else -1. */ findIndex( array: List, - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): number; /** @@ -1607,7 +1608,8 @@ declare module _ { */ findIndex( array: List, - predicate?: string + predicate?: string, + fromIndex?: number ): number; /** @@ -1615,7 +1617,8 @@ declare module _ { */ findIndex( array: List, - predicate?: W + predicate?: W, + fromIndex?: number ): number; } @@ -1624,21 +1627,24 @@ declare module _ { * @see _.findIndex */ findIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): number; /** * @see _.findIndex */ findIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): number; /** * @see _.findIndex */ findIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): number; } @@ -1647,21 +1653,24 @@ declare module _ { * @see _.findIndex */ findIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): number; /** * @see _.findIndex */ findIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): number; /** * @see _.findIndex */ findIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): number; } @@ -1670,21 +1679,24 @@ declare module _ { * @see _.findIndex */ findIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findIndex */ findIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findIndex */ findIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): LoDashExplicitWrapper; } @@ -1693,21 +1705,24 @@ declare module _ { * @see _.findIndex */ findIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findIndex */ findIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findIndex */ findIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): LoDashExplicitWrapper; } @@ -1727,12 +1742,13 @@ declare module _ { * * @param array The array to search. * @param predicate The function invoked per iteration. - * @param thisArg The function invoked per iteration. + * @param fromIndex The index to search from. * @return Returns the index of the found element, else -1. */ findLastIndex( array: List, - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): number; /** @@ -1740,7 +1756,8 @@ declare module _ { */ findLastIndex( array: List, - predicate?: string + predicate?: string, + fromIndex?: number ): number; /** @@ -1748,7 +1765,8 @@ declare module _ { */ findLastIndex( array: List, - predicate?: W + predicate?: W, + fromIndex?: number ): number; } @@ -1757,21 +1775,24 @@ declare module _ { * @see _.findLastIndex */ findLastIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): number; /** * @see _.findLastIndex */ findLastIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): number; /** * @see _.findLastIndex */ findLastIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): number; } @@ -1780,21 +1801,24 @@ declare module _ { * @see _.findLastIndex */ findLastIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): number; /** * @see _.findLastIndex */ findLastIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): number; /** * @see _.findLastIndex */ findLastIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): number; } @@ -1803,21 +1827,24 @@ declare module _ { * @see _.findLastIndex */ findLastIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findLastIndex */ findLastIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findLastIndex */ findLastIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): LoDashExplicitWrapper; } @@ -1826,21 +1853,24 @@ declare module _ { * @see _.findLastIndex */ findLastIndex( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findLastIndex */ findLastIndex( - predicate?: string + predicate?: string, + fromIndex?: number ): LoDashExplicitWrapper; /** * @see _.findLastIndex */ findLastIndex( - predicate?: W + predicate?: W, + fromIndex?: number ): LoDashExplicitWrapper; } @@ -6898,26 +6928,32 @@ declare module _ { * right to left. * @param collection Searches for a value in this list. * @param callback The function called per iteration. - * @param thisArg The this binding of callback. + * @param fromIndex The index to search from. * @return The found element, else undefined. **/ findLast( collection: Array, - callback: ListIterator): T; + callback: ListIterator, + fromIndex?: number + ): T; /** * @see _.find **/ findLast( collection: List, - callback: ListIterator): T; + callback: ListIterator, + fromIndex?: number + ): T; /** * @see _.find **/ findLast( collection: Dictionary, - callback: DictionaryIterator): T; + callback: DictionaryIterator, + fromIndex?: number + ): T; /** * @see _.find @@ -6925,7 +6961,9 @@ declare module _ { **/ findLast( collection: Array, - whereValue: W): T; + whereValue: W, + fromIndex?: number + ): T; /** * @see _.find @@ -6933,7 +6971,9 @@ declare module _ { **/ findLast( collection: List, - whereValue: W): T; + whereValue: W, + fromIndex?: number + ): T; /** * @see _.find @@ -6941,7 +6981,9 @@ declare module _ { **/ findLast( collection: Dictionary, - whereValue: W): T; + whereValue: W, + fromIndex?: number + ): T; /** * @see _.find @@ -6949,7 +6991,9 @@ declare module _ { **/ findLast( collection: Array, - pluckValue: string): T; + pluckValue: string, + fromIndex?: number + ): T; /** * @see _.find @@ -6957,7 +7001,9 @@ declare module _ { **/ findLast( collection: List, - pluckValue: string): T; + pluckValue: string, + fromIndex?: number + ): T; /** * @see _.find @@ -6965,7 +7011,9 @@ declare module _ { **/ findLast( collection: Dictionary, - pluckValue: string): T; + pluckValue: string, + fromIndex?: number + ): T; } interface LoDashImplicitArrayWrapper { @@ -6973,20 +7021,26 @@ declare module _ { * @see _.findLast */ findLast( - callback: ListIterator): T; + callback: ListIterator, + fromIndex?: number + ): T; /** * @see _.findLast * @param _.where style callback */ findLast( - whereValue: W): T; + whereValue: W, + fromIndex?: number + ): T; /** * @see _.findLast * @param _.where style callback */ findLast( - pluckValue: string): T; + pluckValue: string, + fromIndex?: number + ): T; } //_.flatMap @@ -18210,6 +18264,34 @@ declare module _ { constant(): LoDashExplicitObjectWrapper<() => TResult>; } + //_.defaultTo + interface LoDashStatic { + /** + * Checks `value` to determine whether a default value should be returned in + * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, + * or `undefined`. + * + * @param value The value to check. + * @param defaultValue The default value. + * @returns Returns the resolved value. + */ + defaultTo(value: T, defaultValue: T): T; + } + + interface LoDashImplicitWrapperBase { + /** + * @see _.defaultTo + */ + defaultTo(value: TResult): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitWrapperBase { + /** + * @see _.defaultTo + */ + defaultTo(value: TResult): LoDashExplicitObjectWrapper; + } + //_.identity interface LoDashStatic { /** diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4f6ee5a921..cead404be0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -681,6 +681,7 @@ namespace TestFindIndex { let array: TResult[]; let list: _.List; let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let fromIndex: number; { let result: number; @@ -689,21 +690,25 @@ namespace TestFindIndex { result = _.findIndex(array, predicateFn); result = _.findIndex(array, ''); result = _.findIndex<{a: number}, TResult>(array, {a: 42}); + result = _.findIndex(array, predicateFn, fromIndex); result = _.findIndex(list); result = _.findIndex(list, predicateFn); result = _.findIndex(list, ''); result = _.findIndex<{a: number}, TResult>(list, {a: 42}); + result = _.findIndex(list, predicateFn, fromIndex); result = _(array).findIndex(); result = _(array).findIndex(predicateFn); result = _(array).findIndex(''); result = _(array).findIndex<{a: number}>({a: 42}); + result = _(array).findIndex(predicateFn, fromIndex); result = _(list).findIndex(); result = _(list).findIndex(predicateFn); result = _(list).findIndex(''); result = _(list).findIndex<{a: number}>({a: 42}); + result = _(list).findIndex(predicateFn, fromIndex); } { @@ -713,11 +718,13 @@ namespace TestFindIndex { result = _(array).chain().findIndex(predicateFn); result = _(array).chain().findIndex(''); result = _(array).chain().findIndex<{a: number}>({a: 42}); + result = _(array).chain().findIndex(predicateFn, fromIndex); result = _(list).chain().findIndex(); result = _(list).chain().findIndex(predicateFn); result = _(list).chain().findIndex(''); result = _(list).chain().findIndex<{a: number}>({a: 42}); + result = _(list).chain().findIndex(predicateFn, fromIndex); } } @@ -727,6 +734,7 @@ namespace TestFindLastIndex { let list: _.List; let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let fromIndex: number; { let result: number; @@ -735,21 +743,25 @@ namespace TestFindLastIndex { result = _.findLastIndex(array, predicateFn); result = _.findLastIndex(array, ''); result = _.findLastIndex<{a: number}, TResult>(array, {a: 42}); + result = _.findLastIndex(array, predicateFn, fromIndex); result = _.findLastIndex(list); result = _.findLastIndex(list, predicateFn); result = _.findLastIndex(list, ''); result = _.findLastIndex<{a: number}, TResult>(list, {a: 42}); + result = _.findLastIndex(list, predicateFn, fromIndex); result = _(array).findLastIndex(); result = _(array).findLastIndex(predicateFn); result = _(array).findLastIndex(''); result = _(array).findLastIndex<{a: number}>({a: 42}); + result = _(array).findLastIndex(predicateFn, fromIndex); result = _(list).findLastIndex(); result = _(list).findLastIndex(predicateFn); result = _(list).findLastIndex(''); result = _(list).findLastIndex<{a: number}>({a: 42}); + result = _(list).findLastIndex(predicateFn, fromIndex); } { @@ -759,11 +771,13 @@ namespace TestFindLastIndex { result = _(array).chain().findLastIndex(predicateFn); result = _(array).chain().findLastIndex(''); result = _(array).chain().findLastIndex<{a: number}>({a: 42}); + result = _(array).chain().findLastIndex(predicateFn, fromIndex); result = _(list).chain().findLastIndex(); result = _(list).chain().findLastIndex(predicateFn); result = _(list).chain().findLastIndex(''); result = _(list).chain().findLastIndex<{a: number}>({a: 42}); + result = _(list).chain().findLastIndex(predicateFn, fromIndex); } } @@ -3735,12 +3749,16 @@ result = _.findLast([1, 2, 3, 4], function (num) { result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); +result = _.findLast(foodsCombined, 'organic', 1); + result = _([1, 2, 3, 4]).findLast(function (num) { return num % 2 == 0; }); result = _(foodsCombined).findLast({ 'type': 'vegetable' }); result = _(foodsCombined).findLast('organic'); +result = _(foodsCombined).findLast('organic', 1); + // _.flatMap namespace TestFlatMap { let numArray: (number|number[])[] = [1, [2, 3]]; @@ -11111,6 +11129,125 @@ namespace TestConstant { } } +// _.defaultTo +namespace TestDefaultTo { + { + let result: number; + result = _.defaultTo(42, 42); + result = _.defaultTo(undefined, 42); + result = _.defaultTo(null, 42); + result = _.defaultTo(NaN, 42); + } + + { + let result: string; + result = _.defaultTo('a', 'default'); + result = _.defaultTo(undefined, 'default'); + result = _.defaultTo(null, 'default'); + } + + { + let result: boolean; + result = _.defaultTo(true, true); + result = _.defaultTo(undefined, true); + result = _.defaultTo(null, true); + } + + { + let result: string[]; + result = _.defaultTo(['a'], ['default']); + result = _.defaultTo(undefined, ['default']); + result = _.defaultTo(null, ['default']); + } + + { + let result: {a: string}; + result = _.defaultTo<{a: string}>({a: 'a'}, {a: 'a'}); + result = _.defaultTo<{a: string}>(undefined, {a: 'a'}); + result = _.defaultTo<{a: string}>(null, {a: 'a'}); + } + + { + let result: _.LoDashImplicitObjectWrapper; + result = _(42).defaultTo(42); + result = _(undefined).defaultTo(42); + result = _(null).defaultTo(42); + result = _(NaN).defaultTo(42); + } + + { + let result: _.LoDashImplicitObjectWrapper; + result = _('a').defaultTo('default'); + result = _(null).defaultTo('default'); + result = _(NaN).defaultTo('default'); + } + + { + let result: _.LoDashImplicitObjectWrapper; + result = _(true).defaultTo(true); + result = _(undefined).defaultTo(true); + result = _(null).defaultTo(true); + result = _(NaN).defaultTo(true); + } + + { + let result: _.LoDashImplicitObjectWrapper; + result = _(['a']).defaultTo(['default']); + result = _(undefined).defaultTo(['default']); + result = _(null).defaultTo(['default']); + result = _(NaN).defaultTo(['default']); + } + + { + let result: _.LoDashImplicitObjectWrapper<{ a: string }>; + result = _({ a: 'a' }).defaultTo({a : 'a'}); + result = _(undefined).defaultTo({a : 'a'}); + result = _(null).defaultTo({a : 'a'}); + result = _(NaN).defaultTo({a : 'a'}); + } + + { + let result: _.LoDashExplicitObjectWrapper; + result = _(42).chain().defaultTo(42); + result = _(undefined).chain().defaultTo(42); + result = _(null).chain().defaultTo(42); + result = _(NaN).chain().defaultTo(42); + } + + { + let result: _.LoDashExplicitObjectWrapper; + result = _('a').chain().defaultTo('default'); + result = _(undefined).chain().defaultTo('default'); + result = _(null).chain().defaultTo('default'); + result = _(NaN).chain().defaultTo('default'); + } + + { + let result: _.LoDashExplicitObjectWrapper; + result = _(true).chain().defaultTo(true); + result = _(undefined).chain().defaultTo(true); + result = _(null).chain().defaultTo(true); + result = _(NaN).chain().defaultTo(true); + } + + { + let result: _.LoDashExplicitObjectWrapper; + result = _(['a']).chain().defaultTo(['default']); + result = _(undefined).chain().defaultTo(['default']); + result = _(null).chain().defaultTo(['default']); + result = _(NaN).chain().defaultTo(['default']); + } + + { + let result: _.LoDashExplicitObjectWrapper<{ a: string }>; + result = _({ a: 'a' }).chain().defaultTo({a : 'a'}); + result = _(undefined).chain().defaultTo({a : 'a'}); + result = _(null).chain().defaultTo({a : 'a'}); + result = _(NaN).chain().defaultTo({a : 'a'}); + } + +} + // _.identity namespace TestIdentity { { diff --git a/math3d/index.d.ts b/math3d/index.d.ts new file mode 100644 index 0000000000..8981aaf1a9 --- /dev/null +++ b/math3d/index.d.ts @@ -0,0 +1,168 @@ +// Type definitions for math3.d.ts +// Project: https://github.com/adragonite/math3d +// Definitions by: Laszlo Jakab +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export class Vector3 { + constructor(x?: number, y?: number, z?: number); + + static back: Vector3; + static down: Vector3; + static forward: Vector3; + static left: Vector3; + static one: Vector3; + static right: Vector3; + static up: Vector3; + static zero: Vector3; + static dimension: number; + static FromVector4: (vector4: Vector4) => Vector3; + + homogeneous: Vector4; + magnitude: number; + values: number[]; + vector4: Vector4; + x: number; + y: number; + z: number; + + add(vector3: Vector3): Vector3; + average(vector3: Vector3): Vector3; + cross(vector3: Vector3): Vector3; + distanceTo(vector3: Vector3): number; + dot(vector3: Vector3): number; + equals(vector3: Vector3): boolean; + mulScalar(scalar: number): Vector3; + negate(): Vector3; + normalize(): Vector3; + scale(vector3: Vector3): Vector3; + sub(vector3: Vector3): Vector3; + toString(): string; +} + +export class Vector4 { + constructor(x?: number, y?: number, z?: number, w?: number); + + static one: Vector4; + static zero: Vector4; + static dimension: number; + + magnitude: number; + values: number[]; + x: number; + y: number; + z: number; + w: number; + + add(vector4: Vector4): Vector4; + distanceTo(vector4: Vector4): number; + dot(vector4: Vector4): number; + equals(vector4: Vector4): boolean; + mulScalar(scalar: number): Vector4; + negate(): Vector4; + normalize(): Vector3; + sub(vector4: Vector4): Vector3; + toString(): string; +} + +export class Quaternion { + constructor(x?: number, y?: number, z?: number, w?: number); + static Euler(x?: number, y?: number, z?: number): Quaternion; + static AngleAxis(axis: Vector3, angle: number): Quaternion; + + static identity: Quaternion; + static zero: Quaternion; + + angleAxis: { axis: Vector3, angle: number }; + eulerAngles: { x: number, y: number, z: number }; + x: number; + y: number; + z: number; + w: number; + + angleTo(quaternion: Quaternion): number; + conjugate(): Quaternion; + distanceTo(quaternion: Quaternion): number; + dot(quaternion: Quaternion): number; + equals(quaternion: Quaternion): boolean; + inverse(): Quaternion; + mul(quaternion: Quaternion): Quaternion; + mulVector3(vector3: Vector3): Vector3; + toString(): string; +} + +export class Matrix4x4 { + constructor(data: number[]); + + static FlipMatrix(flipX: boolean, flipY: boolean, flipZ: boolean): Matrix4x4; + static ScaleMatrix(scale: number | Vector3): Matrix4x4; + static RotationMatrix(quaternion: Quaternion): Matrix4x4; + static TranslationMatrix(translation: Vector3): Matrix4x4; + static TRS(translation: Vector3, rotation: Quaternion, scale: number | Vector3): Matrix4x4; + static LocalToWorldMatrix(position: Vector3, rotation: Quaternion, scale: number | Vector3): Matrix4x4; + static WorldToLocalMatrix(position: Vector3, rotation: Quaternion, scale: number | Vector3): Matrix4x4; + + static identity: Matrix4x4; + static zero: Matrix4x4; + + columns: number[][]; + m11: number; + m12: number; + m13: number; + m14: number; + m21: number; + m22: number; + m23: number; + m24: number; + m31: number; + m32: number; + m33: number; + m34: number; + m41: number; + m42: number; + m43: number; + m44: number; + rows: number[][]; + size: { rows: number, columns: number }; + values: number[]; + + determinant(): number + inverse(): Matrix4x4; + negate(): Matrix4x4; + transpose(): Matrix4x4; + add(matrix4x4: Matrix4x4): Matrix4x4; + sub(matrix4x4: Matrix4x4): Matrix4x4; + mul(matrix4x4: Matrix4x4): Matrix4x4; + mulScalar(scalar: number): Matrix4x4; + mulVector3(vector3: Vector3): Vector3; +} + +export class Transform { + constructor(position?: Vector3, rotation?: Quaternion); + + forward: Vector3; + localPosition: Vector3; + localRotation: Quaternion; + localToWorldMatrix: Matrix4x4; + name: string; + parent: Transform; + position: Vector3; + right: Vector3; + root: Transform; + rotation: Vector3; + up: Vector3; + worldToLocalMatrix: Matrix4x4; + + addChild(child: Transform): void; + inverseTransformPosition(position: Vector3): Vector3; + removeChild(child: Transform): void; + transformPosition(position: Vector3): Vector3; + translate(translation: Vector3, relativeTo?: Transform.Space): Transform; + rotate(x: number, y: number, z: number, relativeTo?: Transform.Space): Transform; +} + +export namespace Transform { + export enum Space { + Self, + World + } +} diff --git a/math3d/math3d-tests.ts b/math3d/math3d-tests.ts new file mode 100644 index 0000000000..d04ddbefb9 --- /dev/null +++ b/math3d/math3d-tests.ts @@ -0,0 +1,7 @@ +import * as math3d from 'math3d'; +const v = new math3d.Vector3(1, 2, 3); +v.add(new math3d.Vector3(0, 0, 1)); +new math3d.Matrix4x4([1,1,1,1, + 2,2,2,2, + 3,3,3,3, + 4,4,4,4]); diff --git a/math3d/tsconfig.json b/math3d/tsconfig.json new file mode 100644 index 0000000000..2f4e358aaf --- /dev/null +++ b/math3d/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", + "math3d-tests.ts" + ] +} diff --git a/math3d/tslint.json b/math3d/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/math3d/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/matter-js/index.d.ts b/matter-js/index.d.ts index 7d63ad6195..2ecf70d680 100644 --- a/matter-js/index.d.ts +++ b/matter-js/index.d.ts @@ -487,7 +487,7 @@ declare namespace Matter { * @type boolean * @default true */ - visible: boolean; + visible?: boolean; /** * An `Object` that defines the sprite properties to use when rendering, if any. @@ -495,31 +495,31 @@ declare namespace Matter { * @property render.sprite * @type object */ - sprite: IBodyRenderOptionsSprite; + sprite?: IBodyRenderOptionsSprite; /** * A String that defines the fill style to use when rendering the body (if a sprite is not defined). It is the same as when using a canvas, so it accepts CSS style property values. Default: a random colour */ - fillStyle: string; + fillStyle?: string; /** * A Number that defines the line width to use when rendering the body outline (if a sprite is not defined). A value of 0 means no outline will be rendered. Default: 1.5 */ - lineWidth: number; + lineWidth?: number; /** * A String that defines the stroke style to use when rendering the body outline (if a sprite is not defined). It is the same as when using a canvas, so it accepts CSS style property values. Default: a random colour */ - strokeStyle: string; + strokeStyle?: string; /* * Sets the opacity. 1.0 is fully opaque. 0.0 is fully translucent */ - opacity: number; + opacity?: number; } export interface IBodyRenderOptionsSprite { @@ -1969,6 +1969,11 @@ declare namespace Matter { */ enableSleeping: boolean; + /** + * Collision pair set for this `Engine`. + */ + pairs: any; + /** * An integer `Number` that specifies the number of position iterations to perform each update. * The higher the value, the higher quality the simulation will be at the expense of performance. @@ -2124,7 +2129,7 @@ declare namespace Matter { * @param {} options * @return {MouseConstraint} A new MouseConstraint */ - create(engine: Engine, options: IMouseConstraintDefinition): MouseConstraint; + static create(engine: Engine, options?: IMouseConstraintDefinition): MouseConstraint; /** * The `Constraint` object that is used to move the body during interaction. @@ -2173,6 +2178,21 @@ declare namespace Matter { type: string; } + /** + * The `Matter.Pairs` module contains methods for creating and manipulating collision pair sets. + * + * @class Pairs + */ + export class Pairs { + /** + * Clears the given pairs structure. + * @method clear + * @param {pairs} pairs + * @return {pairs} pairs + */ + static clear(pairs: any): any; + } + export interface IPair { id: number; bodyA: Body; @@ -2328,9 +2348,12 @@ declare namespace Matter { */ hasBounds?: boolean; - - - + /** + * Render wireframes only + * @type boolean + * @default true + */ + wireframes?: boolean; } /** @@ -2923,7 +2946,7 @@ declare namespace Matter { * @param body * @returns world */ - static add(world: World, body: Body | Array | Composite | Array | Constraint | Array): World; + static add(world: World, body: Body | Array | Composite | Array | Constraint | Array | MouseConstraint): World; /** * An alias for Composite.addBody since World is also a Composite @@ -3285,7 +3308,7 @@ declare namespace Matter { * @param eventNames * @param event */ - static trigger(object: any, eventNames: string, event: (e: any) => void): void; + static trigger(object: any, eventNames: string, event?: (e: any) => void): void; } } diff --git a/mongodb/index.d.ts b/mongodb/index.d.ts index 49f092a0f1..cb134242e6 100644 --- a/mongodb/index.d.ts +++ b/mongodb/index.d.ts @@ -982,8 +982,10 @@ export interface FindOperatorsOrdered { upsert(): FindOperatorsOrdered; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html export interface UnorderedBulkOperation { + //http://mongodb.github.io/node-mongodb-native/2.1/api/lib_bulk_unordered.js.html line 339 + length: number; //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute execute(callback: MongoCallback): void; execute(options?: FSyncOptions): Promise; @@ -1170,7 +1172,7 @@ export interface Cursor extends Readable, NodeJS.EventEmitter { // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit limit(value: number): Cursor; // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map - map(transform: Function): void; + map(transform: Function): Cursor; // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max max(max: number): Cursor; //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS diff --git a/multiparty/index.d.ts b/multiparty/index.d.ts index 601d888956..ca968fefcf 100644 --- a/multiparty/index.d.ts +++ b/multiparty/index.d.ts @@ -19,7 +19,7 @@ export declare class Form extends events.EventEmitter { * @param callback */ parse(request: http.IncomingMessage, callback?: (error: Error, fields: any, files: any) => any): void; - } +} export interface File { /** diff --git a/multiplexjs/multiplexjs-tests.ts b/multiplexjs/multiplexjs-tests.ts index 94f212b533..606b63fa13 100644 --- a/multiplexjs/multiplexjs-tests.ts +++ b/multiplexjs/multiplexjs-tests.ts @@ -1,4 +1,3 @@ - /// diff --git a/needle/index.d.ts b/needle/index.d.ts index 63270e3ff8..7607fdfc78 100644 --- a/needle/index.d.ts +++ b/needle/index.d.ts @@ -5,93 +5,88 @@ /// -declare var needle: Needle.NeedleStatic; -export = needle; +declare module "needle" { + import * as http from 'http'; + import * as Buffer from 'buffer'; + module Needle { + interface NeedleResponse extends http.IncomingMessage { + body: any; + raw: Buffer; + bytes: number; + } -declare namespace Needle { - interface ReadableStream extends NodeJS.ReadableStream { - } + interface ReadableStream extends NodeJS.ReadableStream { + } - interface Callback { - (error: Error, response: any, body: any): void; + interface Callback { + (error: Error, response: NeedleResponse, body: any): void; + } + + interface RequestOptions { + timeout?: number; + follow?: number; + follow_max?: number; + multipart?: boolean; + proxy?: string; + agent?: string; + headers?: Object; + auth?: string; // auto | digest | basic (default) + json?: boolean; + + // These properties are overwritten by those in the 'headers' field + compressed?: boolean; + cookies?: { [name: string]: any; }; + // Overwritten if present in the URI + username?: string; + password?: string; + } + + interface ResponseOptions { + decode?: boolean; + parse?: boolean; + output?: any; + } + + interface TLSOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: any; + rejectUnauthorized?: boolean; + secureProtocol?: any; + } + + interface NeedleStatic { + defaults(options?: any): void; + + head(url: string): ReadableStream; + head(url: string, callback?: Callback): ReadableStream; + head(url: string, options?: RequestOptions, callback?: Callback): ReadableStream; + + get(url: string): ReadableStream; + get(url: string, callback?: Callback): ReadableStream; + get(url: string, options?: RequestOptions, callback?: Callback): ReadableStream; + + post(url: string, data: any): ReadableStream; + post(url: string, data: any, callback?: Callback): ReadableStream; + post(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + + put(url: string, data: any): ReadableStream; + put(url: string, data: any, callback?: Callback): ReadableStream; + put(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + + delete(url: string, data: any): ReadableStream; + delete(url: string, data: any, callback?: Callback): ReadableStream; + delete(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + + request(method: string, url: string, data: any): ReadableStream; + request(method: string, url: string, data: any, callback?: Callback): ReadableStream; + request(method: string, url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + } } - interface RequestOptions { - timeout?: number; - follow?: number; - follow_max?: number; - multipart?: boolean; - proxy?: string; - agent?: string; - headers?: HttpHeaderOptions; - auth?: string; // auto | digest | basic (default) - json?: boolean; - - // These properties are overwritten by those in the 'headers' field - compressed?: boolean; - cookies?: { [name: string]: any; }; - // Overwritten if present in the URI - username?: string; - password?: string; - } - - interface ResponseOptions { - decode?: boolean; - parse?: boolean; - output?: any; - } - - interface HttpHeaderOptions { - cookies?: { [name: string]: any; }; - compressed?: boolean; - accept?: string; - connection?: string; - user_agent?: string; - - // Overwritten if present in the URI - username?: string; - password?: string; - } - - interface TLSOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: any; - rejectUnauthorized?: boolean; - secureProtocol?: any; - } - - interface NeedleOptions extends RequestOptions, ResponseOptions, HttpHeaderOptions, TLSOptions { - } - - interface NeedleStatic { - defaults(options?: any): void; - - head(url: string): ReadableStream; - head(url: string, callback?: Callback): ReadableStream; - head(url: string, options?: RequestOptions, callback?: Callback): ReadableStream; - - get(url: string): ReadableStream; - get(url: string, callback?: Callback): ReadableStream; - get(url: string, options?: RequestOptions, callback?: Callback): ReadableStream; - - post(url: string, data: any): ReadableStream; - post(url: string, data: any, callback?: Callback): ReadableStream; - post(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; - - put(url: string, data: any): ReadableStream; - put(url: string, data: any, callback?: Callback): ReadableStream; - put(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; - - delete(url: string, data: any): ReadableStream; - delete(url: string, data: any, callback?: Callback): ReadableStream; - delete(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; - - request(method: string, url: string, data: any): ReadableStream; - request(method: string, url: string, data: any, callback?: Callback): ReadableStream; - request(method: string, url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; - } -} + var needle: Needle.NeedleStatic; + export = needle; +} \ No newline at end of file diff --git a/needle/needle-tests.ts b/needle/needle-tests.ts index 4db70f008c..3df14952c3 100644 --- a/needle/needle-tests.ts +++ b/needle/needle-tests.ts @@ -1,5 +1,3 @@ - - import needle = require("needle"); function Usage() { diff --git a/ng-dialog/index.d.ts b/ng-dialog/index.d.ts index 1c24461057..f38757afbf 100644 --- a/ng-dialog/index.d.ts +++ b/ng-dialog/index.d.ts @@ -237,7 +237,7 @@ declare module 'angular' { template: string; controller?: string| any[] | any; controllerAs?: string; - bindToController?: boolean; + bindToController?: boolean; /** * Scope object that will be passed to dialog. If you use controller with separate $scope service this object will be passed to $scope.$parent param. diff --git a/ng-file-upload/index.d.ts b/ng-file-upload/index.d.ts index 03976de7e8..17f454c5a9 100644 --- a/ng-file-upload/index.d.ts +++ b/ng-file-upload/index.d.ts @@ -91,6 +91,20 @@ declare module 'angular' { */ ngfValidateForce?: boolean; } + + interface ResizeIfFunction { + (width: number, height: number): boolean; + } + + interface FileResizeOptions { + centerCrop?: boolean; + height?: number; + ratio?: number; + resizeIf?: ResizeIfFunction; + restoreExif?: boolean; + quality?: number; + width?: number; + } interface ResizeIfFunction { (width: number, height: number): boolean; diff --git a/ng-file-upload/ng-file-upload-tests.ts b/ng-file-upload/ng-file-upload-tests.ts index 0bca49ea91..3f3f264c2b 100644 --- a/ng-file-upload/ng-file-upload-tests.ts +++ b/ng-file-upload/ng-file-upload-tests.ts @@ -85,7 +85,7 @@ class UploadController { ratio: 0.9, centerCrop: true, restoreExif: true, - resizeIf: (width, height) => { + resizeIf: (width: number, height: number) => { return true; } }) diff --git a/node-sass/index.d.ts b/node-sass/index.d.ts index c75469595f..a91d56e370 100644 --- a/node-sass/index.d.ts +++ b/node-sass/index.d.ts @@ -22,13 +22,13 @@ interface Options { linefeed?: string; omitSourceMapUrl?: boolean; outFile?: string; - outputStyle?: "compact" | "compressed" | "expanded" | "nested"; + outputStyle?: "compact" | "compressed" | "expanded" | "nested"; precision?: number; sourceComments?: boolean; sourceMap?: boolean | string; sourceMapContents?: boolean; sourceMapEmbed?: boolean; - sourceMapRoot?: string; + sourceMapRoot?: string; } interface SassError extends Error { diff --git a/node-sass/node-sass-tests.ts b/node-sass/node-sass-tests.ts index 623e7ae4d6..33ce90ec67 100644 --- a/node-sass/node-sass-tests.ts +++ b/node-sass/node-sass-tests.ts @@ -1,4 +1,3 @@ - import * as sass from 'node-sass'; sass.render({ file: '/path/to/myFile.scss', diff --git a/node/index.d.ts b/node/index.d.ts index ea22eb6486..b95377c756 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -1539,7 +1539,7 @@ declare module "child_process" { disconnect(): void; unref(): void; ref(): void; - + /** * events.EventEmitter * 1. close diff --git a/object-assign/object-assign-tests.ts b/object-assign/object-assign-tests.ts index d3a5197a7e..e7c58cf5fb 100644 --- a/object-assign/object-assign-tests.ts +++ b/object-assign/object-assign-tests.ts @@ -9,7 +9,7 @@ interface Source1 { } interface Result extends Target, Source1 { - + } interface Source2 { @@ -17,7 +17,7 @@ interface Source2 { } interface Result2 extends Result, Source2 { - + } interface Source3 { @@ -25,7 +25,7 @@ interface Source3 { } interface Result3 extends Result2, Source3 { - + } interface Source4 { @@ -33,7 +33,7 @@ interface Source4 { } interface Result4 extends Result3, Source4 { - + } interface Source5 { @@ -41,7 +41,7 @@ interface Source5 { } interface Result5 extends Result4, Source5 { - + } function assign1(): Result { diff --git a/office-js/index.d.ts b/office-js/index.d.ts index fdfa55622f..cae1dedcae 100644 --- a/office-js/index.d.ts +++ b/office-js/index.d.ts @@ -128,284 +128,6 @@ declare namespace Office { } } -declare module OfficeExtension { - /** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling "context.sync()". */ - class ClientObject { - /** The request context associated with the object */ - context: ClientRequestContext; - /** Returns a boolean value for whether the corresponding object is null. You must call "context.sync()" before reading the isNull property. [Api set: ExcelApi 1.3 (Preview), WordApi 1.3] */ - isNull: boolean; - } -} -declare module OfficeExtension { - interface LoadOption { - select?: string | string[]; - expand?: string | string[]; - top?: number; - skip?: number; - } - /** An abstract RequestContext object that facilitates requests to the host Office application. The "Excel.run" and "Word.run" methods provide a request context. */ - class ClientRequestContext { - constructor(url?: string); - /** Collection of objects that are tracked for automatic adjustments based on surrounding changes in the document. */ - trackedObjects: TrackedObjects; - /** Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ - load(object: ClientObject, option?: string | string[] | LoadOption): void; - /** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */ - trace(message: string): void; - /** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code. This method returns a promise, which is resolved when the synchronization is complete. */ - sync(passThroughValue?: T): IPromise; - } -} -declare module OfficeExtension { - /** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after "context.sync()" is invoked. */ - class ClientResult { - /** The value of the result that is retrieved from the document after "context.sync()" is invoked. */ - value: T; - } -} -declare module OfficeExtension { - /** The error object returned by "context.sync()", if a promise is rejected due to an error while processing the request. */ - class Error { - /** Error name: "OfficeExtension.Error".*/ - name: string; - /** The error message passed through from the host Office application. */ - message: string; - /** Stack trace, if applicable. */ - stack: string; - /** Error code string, such as "InvalidArgument". */ - code: string; - /** Trace messages (if any) that were added via a "context.trace()" invocation before calling "context.sync()". If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */ - traceMessages: Array; - /** Debug info, if applicable. The ".errorLocation" property can describe the object and method or property that caused the error. */ - debugInfo: { - /** If applicable, will return the object type and the name of the method or property that caused the error. */ - errorLocation?: string; - }; - } -} -declare module OfficeExtension { - class ErrorCodes { - static accessDenied: string; - static generalException: string; - static activityLimitReached: string; - static invalidObjectPath: string; - static propertyNotLoaded: string; - static valueNotLoaded: string; - static invalidRequestContext: string; - static invalidArgument: string; - static runMustReturnPromise: string; - static cannotRegisterEvent: string; - } -} -declare module OfficeExtension { - /** An IPromise object that represents a deferred interaction with the host Office application. */ - interface IPromise { - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => IPromise): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => U): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => void): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise; - - - /** - * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. - * @param onRejected function to be called if or when the promise rejects. - */ - catch(onRejected?: (error: any) => IPromise): IPromise; - - /** - * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. - * @param onRejected function to be called if or when the promise rejects. - */ - catch(onRejected?: (error: any) => U): IPromise; - - /** - * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. - * @param onRejected function to be called if or when the promise rejects. - */ - catch(onRejected?: (error: any) => void): IPromise; - } - - /** An Promise object that represents a deferred interaction with the host Office application. The publically-consumable OfficeExtension.Promise is available starting in ExcelApi 1.2 and WordApi 1.2. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. When a "native" Promise implementation is available, OfficeExtension.Promise will switch to use the native Promise instead. */ - export class Promise implements IPromise - { - /** - * Creates a new promise based on a function that accepts resolve and reject handlers. - */ - constructor(func: (resolve: (value?: R | IPromise) => void, reject: (error?: any) => void) => void); - - /** - * Creates a promise that resolves when all of the child promises resolve. - */ - static all(promises: OfficeExtension.IPromise[]): IPromise; - - /** - * Creates a promise that is resolved. - */ - static resolve(value: U): IPromise; - - /** - * Creates a promise that is rejected. - */ - static reject(error: any): IPromise; - - /* This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => IPromise): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => U): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => void): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise; - - /** - * This method will be called once the previous promise has been resolved. - * Both the onFulfilled on onRejected callbacks are optional. - * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. - - * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. - */ - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise; - - - /** - * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. - * @param onRejected function to be called if or when the promise rejects. - */ - catch(onRejected?: (error: any) => IPromise): IPromise; - - /** - * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. - * @param onRejected function to be called if or when the promise rejects. - */ - catch(onRejected?: (error: any) => U): IPromise; - - /** - * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. - * @param onRejected function to be called if or when the promise rejects. - */ - catch(onRejected?: (error: any) => void): IPromise; - } -} - -declare module OfficeExtension { - /** Collection of tracked objects, contained within a request context. See "context.trackedObjects" for more information. */ - class TrackedObjects { - /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ - add(object: ClientObject): void; - /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ - add(objects: ClientObject[]): void; - /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ - remove(object: ClientObject): void; - /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ - remove(objects: ClientObject[]): void; - } -} - -declare module OfficeExtension { - export class EventHandlers { - constructor(context: ClientRequestContext, parentObject: ClientObject, name: string, eventInfo: EventInfo); - add(handler: (args: T) => IPromise): EventHandlerResult; - remove(handler: (args: T) => IPromise): void; - removeAll(): void; - } - - export class EventHandlerResult { - constructor(context: ClientRequestContext, handlers: EventHandlers, handler: (args: T) => IPromise); - remove(): void; - } - - export interface EventInfo { - registerFunc: (callback: (args: any) => void) => IPromise; - unregisterFunc: (callback: (args: any) => void) => IPromise; - eventArgsTransformFunc: (args: any) => IPromise; - } -} - declare namespace Office { /** * Returns a promise of an object described in the expression. Callback is invoked only if method fails. @@ -1689,6 +1411,958 @@ declare namespace Office { getWSSUrlAsync(options?: any, callback?: (result: AsyncResult) => void): void; } } + + + + +//////////////////////////////////////////////////////////////// +////////////////////// Begin Exchange APIs ///////////////////// +//////////////////////////////////////////////////////////////// + + +declare namespace Office.MailboxEnums { + export enum BodyType { + /** + * The body is in HTML format + */ + Html, + /** + * The body is in text format + */ + text + } + export enum EntityType { + /** + * Specifies that the entity is a meeting suggestion + */ + MeetingSuggestion, + /** + * Specifies that the entity is a task suggestion + */ + TaskSuggestion, + /** + * Specifies that the entity is a postal address + */ + Address, + /** + * Specifies that the entity is SMTP email address + */ + EmailAddress, + /** + * Specifies that the entity is an Internet URL + */ + Url, + /** + * Specifies that the entity is US phone number + */ + PhoneNumber, + /** + * Specifies that the entity is a contact + */ + Contact + } + export enum ItemType { + /** + * A meeting request, response, or cancellation + */ + Message, + /** + * Specifies an appointment item + */ + Appointment + } + export enum ResponseType { + /** + * There has been no response from the attendee + */ + None, + /** + * The attendee is the meeting organizer + */ + Organizer, + /** + * The meeting request was tentatively accepted by the attendee + */ + Tentative, + /** + * The meeting request was accepted by the attendee + */ + Accepted, + /** + * The meeting request was declined by the attendee + */ + Declined + } + export enum RecipientType { + /** + * Specifies that the recipient is not one of the other recipient types + */ + Other, + /** + * Specifies that the recipient is a distribution list containing a list of email addresses + */ + DistributionList, + /** + * Specifies that the recipient is an SMTP email address that is on the Exchange server + */ + User, + /** + * Specifies that the recipient is an SMTP email address that is not on the Exchange server + */ + ExternalUser + } + export enum AttachmentType { + /** + * The attachment is a file + */ + File, + /** + * The attachment is an Exchange item + */ + Item + } +} +declare namespace Office { + export module Types { + export interface ItemRead extends Office.Item { + subject: any; + /** + * Displays a reply form that includes the sender and all the recipients of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the sender of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an message + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an message + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + export interface ItemCompose extends Office.Item { + body: Office.Body; + subject: any; + /** + * Adds a file to a message as an attachment + * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the message + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a message + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface MessageCompose extends Office.Message { + attachments: Office.AttachmentDetails[]; + body: Office.Body; + bcc: Office.Recipients; + cc: Office.Recipients; + subject: Office.Subject; + to: Office.Recipients; + /** + * Adds a file to a message as an attachment + * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the message + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a message + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface MessageRead extends Office.Message { + cc: Office.EmailAddressDetails[]; + from: Office.EmailAddressDetails; + internetMessageId: string; + normalizedSubject: string; + sender: Office.EmailAddressDetails; + subject: string; + to: Office.EmailAddressDetails; + /** + * Displays a reply form that includes the sender and all the recipients of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the sender of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an message + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an message + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + export interface AppointmentCompose extends Office.Appointment { + body: Office.Body; + end: Office.Time; + location: Office.Location; + optionalAttendees: Office.Recipients; + requiredAttendees: Office.Recipients; + start: Office.Time; + subject: Office.Subject; + /** + * Adds a file to an appointment as an attachment + * @param uri The URI that provides the location of the file to attach to the appointment. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the appointment + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a appointment + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface AppointmentRead extends Office.Appointment { + attachments: Office.AttachmentDetails[]; + end: Date; + location: string; + normalizedSubject: string; + optionalAttendees: Office.EmailAddressDetails; + organizer: Office.EmailAddressDetails; + requiredAttendees: Office.EmailAddressDetails; + resources: string[]; + start: Date; + subject: string; + /** + * Displays a reply form that includes the organizer and all the attendees of the selected appointment item + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the organizer of the selected appointment item + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an appointment + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an appointment + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected appointment object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + } + export module cast { + export module item { + function toAppointmentCompose(item: Office.Item): Office.Types.AppointmentCompose; + function toAppointmentRead(item: Office.Item): Office.Types.AppointmentRead; + function toAppointment(item: Office.Item): Office.Appointment; + function toMessageCompose(item: Office.Item): Office.Types.MessageCompose; + function toMessageRead(item: Office.Item): Office.Types.MessageRead; + function toMessage(item: Office.Item): Office.Message; + function toItemCompose(item: Office.Item): Office.Types.ItemCompose; + function toItemRead(item: Office.Item): Office.Types.ItemRead; + } + } + export interface AttachmentDetails { + attachmentType: Office.MailboxEnums.AttachmentType; + contentType: string; + id: string; + isInline: boolean; + name: string; + size: number; + } + export interface Contact { + personName: string; + businessName: string; + phoneNumbers: PhoneNumber[]; + emailAddresses: string[]; + urls: string[]; + addresses: string[]; + contactString: string; + } + + export interface Context { + mailbox: Mailbox; + roamingSettings: RoamingSettings; + } + export interface CustomProperties { + /** + * Returns the value of the specified custom property + * @param name The name of the property to be returned + */ + get(name: string): any; + /** + * Sets the specified property to the specified value + * @param name The name of the property to be set + * @param value The value of the property to be set + */ + set(name: string, value: string): void; + /** + * Removes the specified property from the custom property collection. + * @param name The name of the property to be removed + */ + remove(name: string): void; + /** + * Saves the custom property collection to the server + * @param callback The optional callback method + * @param userContext Optional variable for any state data that is passed to the saveAsync method + */ + saveAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface EmailAddressDetails { + emailAddress: string; + displayName: string; + appointmentResponse: Office.MailboxEnums.ResponseType; + recipientType: Office.MailboxEnums.RecipientType; + } + export interface EmailUser { + name: string; + userId: string; + } + export interface Entities { + addresses: string[]; + taskSuggestions: string[]; + meetingSuggestions: MeetingSuggestion[]; + emailAddresses: string[]; + urls: string[]; + phoneNumbers: PhoneNumber[]; + contacts: Contact[]; + } + export interface Item { + dateTimeCreated: Date; + dateTimeModified: Date; + itemClass: string; + itemId: string; + itemType: Office.MailboxEnums.ItemType; + /** + * Asynchronously loads custom properties that are specific to the item and a app for Office + * @param callback The optional callback method + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + loadCustomPropertiesAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface Appointment extends Item { + } + export interface Body { + /** + * Gets a value that indicates whether the content is in HTML or text format + * @param tableData A TableData object with the headers and rows + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the getTypeAsync method returns + */ + getTypeAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified content to the beginning of the item body + * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + prependAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Replaces the selection in the body with the specified text + * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Location { + /** + * Begins an asynchronous request for the location of an appointment + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the location of an appointment + * @param data The location of the appointment. The string is limited to 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the location is set + */ + setAsync(location: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Mailbox { + item: Item; + userProfile: UserProfile; + /** + * Gets a Date object from a dictionary containing time information + * @param timeValue A Date object + */ + convertToLocalClientTime(timeValue: Date): any; + /** + * Gets a dictionary containing time information in local client time + * @param input A dictionary containing a date. The dictionary should contain the following fields: year, month, date, hours, minutes, seconds, time zone, time zone offset + */ + convertToUtcClientTime(input: any): Date; + /** + * Displays an existing calendar appointment + * @param itemId The Exchange Web Services (EWS) identifier for an existing calendar appointment + */ + displayAppointmentForm(itemId: any): void; + /** + * Displays an existing message + * @param itemId The Exchange Web Services (EWS) identifier for an existing message + */ + displayMessageForm(itemId: any): void; + /** + * Displays a form for creating a new calendar appointment + * @param requiredAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the required attendees for the appointment. The array is limited to a maximum of 100 entries + * @param optionalAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the optional attendees for the appointment. The array is limited to a maximum of 100 entries + * @param start A Date object specifying the start date and time of the appointment + * @param end A Date object specifying the end date and time of the appointment + * @param location A string containing the location of the appointment. The string is limited to a maximum of 255 characters + * @param resources An array of strings containing the resources required for the appointment. The array is limited to a maximum of 100 entries + * @param subject A string containing the subject of the appointment. The string is limited to a maximum of 255 characters + * @param body The body of the appointment message. The body content is limited to a maximum size of 32 KB + */ + displayNewAppointmentForm(requiredAttendees: any, optionalAttendees: any, start: Date, end: Date, location: string, resources: string[], subject: string, body: string): void; + /** + * Gets a string that contains a token used to get an attachment or item from an Exchange Server + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + getCallbackTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + /** + * Gets a token identifying the user and the app for Office + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + getUserIdentityTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + /** + * Makes an asynchronous request to an Exchange Web Services (EWS) service on the Exchange server that hosts the user’s mailbox + * @param data The EWS request + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + makeEwsRequestAsync(data: any, callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface Message extends Item { + conversationId: string; + } + export interface MeetingRequest extends Message { + start: Date; + end: Date; + location: string; + optionalAttendees: EmailAddressDetails[]; + requiredAttendees: EmailAddressDetails[]; + } + export interface MeetingSuggestion { + meetingString: string; + attendees: EmailAddressDetails[]; + location: string; + subject: string; + start: Date; + end: Date; + } + export interface PhoneNumber { + phoneString: string; + originalPhoneString: string; + type: string; + } + export interface Recipients { + /** + * Begins an asynchronous request to add a recipient list to an appointment or message + * @param recipients The recipients to add to the recipients list + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + addAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to get the recipient list for an appointment or message + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the recipient list for an appointment or message + * @param recipients The recipients to add to the recipients list + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface RoamingSettings { + /** + * Retrieves the specified setting + * @param name The case-sensitive name of the setting to retrieve + */ + get(name: string): any; + /** + * Removes the specified setting + * @param name The case-sensitive name of the setting to remove + */ + remove(name: string): void; + /** + * Saves the settings + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult + */ + saveAsync(callback?: (result: AsyncResult) => void): void; + /** + * Sets or creates the specified setting + * @param name The case-sensitive name of the setting to set or create + * @param value Specifies the value to be stored + */ + set(name: string, value: any): void; + } + export interface Subject { + /** + * Begins an asynchronous request to get the subject of an appointment or message + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous call to set the subject of an appointment or message + * @param data The subject of the appointment. The string is limited to 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface TaskSuggestion { + assignees: EmailUser[]; + taskString: string; + } + export interface Time { + /** + * Begins an asynchronous request to get the start or end time + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the start or end time + * @param dateTime A date-time object in Coordinated Universal Time (UTC) + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(dateTime: Date, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface UserProfile { + displayName: string; + emailAddress: string; + timeZone: string; + } +} + + +//////////////////////////////////////////////////////////////// +/////////////////////// End Exchange APIs ////////////////////// +//////////////////////////////////////////////////////////////// + + + +/////////////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////////////// +///////////////// Begin OfficeExtension runtime //////////////// +//////////////////////////////////////////////////////////////// + + +declare module OfficeExtension { + /** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling "context.sync()". */ + class ClientObject { + /** The request context associated with the object */ + context: ClientRequestContext; + /** Returns a boolean value for whether the corresponding object is a null object. You must call "context.sync()" before reading the isNullObject property. */ + isNullObject: boolean; + } +} +declare module OfficeExtension { + interface LoadOption { + select?: string | string[]; + expand?: string | string[]; + top?: number; + skip?: number; + } + /** An abstract RequestContext object that facilitates requests to the host Office application. The "Excel.run" and "Word.run" methods provide a request context. */ + class ClientRequestContext { + constructor(url?: string); + + /** Collection of objects that are tracked for automatic adjustments based on surrounding changes in the document. */ + trackedObjects: TrackedObjects; + + /** Request headers */ + requestHeaders: { [name: string]: string }; + + /** Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ + load(object: ClientObject, option?: string | string[]| LoadOption): void; + + /** + * Queues up a command to recursively load the specified properties of the object and its navigation properties. + * You must call "context.sync()" before reading the properties. + * + * @param object The object to be loaded. + * @param options The key-value pairing of load options for the types, such as { "Workbook": "worksheets,tables", "Worksheet": "tables", "Tables": "name" } + * @param maxDepth The maximum recursive depth. + */ + loadRecursive(object: ClientObject, options: { [typeName: string]: string | string[] | LoadOption }, maxDepth?: number): void; + + /** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */ + trace(message: string): void; + + /** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code. This method returns a promise, which is resolved when the synchronization is complete. */ + sync(passThroughValue?: T): IPromise; + } +} +declare module OfficeExtension { + /** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after "context.sync()" is invoked. */ + class ClientResult { + /** The value of the result that is retrieved from the document after "context.sync()" is invoked. */ + value: T; + } +} +declare module OfficeExtension { + /** The error object returned by "context.sync()", if a promise is rejected due to an error while processing the request. */ + class Error { + /** Error name: "OfficeExtension.Error".*/ + name: string; + /** The error message passed through from the host Office application. */ + message: string; + /** Stack trace, if applicable. */ + stack: string; + /** Error code string, such as "InvalidArgument". */ + code: string; + /** Trace messages (if any) that were added via a "context.trace()" invocation before calling "context.sync()". If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */ + traceMessages: Array; + /** Debug info, if applicable. The ".errorLocation" property can describe the object and method or property that caused the error. */ + debugInfo: { + /** If applicable, will return the object type and the name of the method or property that caused the error. */ + errorLocation?: string; + }; + } +} +declare module OfficeExtension { + class ErrorCodes { + static accessDenied: string; + static generalException: string; + static activityLimitReached: string; + } +} +declare module OfficeExtension { + /** An IPromise object that represents a deferred interaction with the host Office application. */ + interface IPromise { + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => IPromise): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => U): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => void): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise; + + + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => IPromise): IPromise; + + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => U): IPromise; + + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => void): IPromise; + } + + /** An Promise object that represents a deferred interaction with the host Office application. The publically-consumable OfficeExtension.Promise is available starting in ExcelApi 1.2 and WordApi 1.2. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. When a "native" Promise implementation is available, OfficeExtension.Promise will switch to use the native Promise instead. */ + export class Promise implements IPromise + { + /** + * Creates a new promise based on a function that accepts resolve and reject handlers. + */ + constructor(func: (resolve: (value?: R | IPromise) => void, reject: (error?: any) => void) => void); + + /** + * Creates a promise that resolves when all of the child promises resolve. + */ + static all(promises: OfficeExtension.IPromise[]): IPromise; + + /** + * Creates a promise that is resolved. + */ + static resolve(value: U): IPromise; + + /** + * Creates a promise that is rejected. + */ + static reject(error: any): IPromise; + + /* This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => IPromise): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => U): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => void): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise; + + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise; + + + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => IPromise): IPromise; + + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => U): IPromise; + + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => void): IPromise; + } +} + +declare module OfficeExtension { + /** Collection of tracked objects, contained within a request context. See "context.trackedObjects" for more information. */ + class TrackedObjects { + /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ + add(object: ClientObject): void; + /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ + add(objects: ClientObject[]): void; + /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ + remove(object: ClientObject): void; + /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ + remove(objects: ClientObject[]): void; + } +} + +declare module OfficeExtension { + export class EventHandlers { + constructor(context: ClientRequestContext, parentObject: ClientObject, name: string, eventInfo: EventInfo); + add(handler: (args: T) => IPromise): EventHandlerResult; + remove(handler: (args: T) => IPromise): void; + removeAll(): void; + } + + export class EventHandlerResult { + constructor(context: ClientRequestContext, handlers: EventHandlers, handler: (args: T) => IPromise); + remove(): void; + } + + export interface EventInfo { + registerFunc: (callback: (args: any) => void) => IPromise; + unregisterFunc: (callback: (args: any) => void) => IPromise; + eventArgsTransformFunc: (args: any) => IPromise; + } +} +declare module OfficeExtension { + /** + * Request URL and headers + */ + interface RequestUrlAndHeaderInfo { + /** Request URL */ + url: string; + /** Request headers */ + headers?: { + [name: string]: string; + }; + } +} + + + +//////////////////////////////////////////////////////////////// +////////////////// End OfficeExtension runtime ///////////////// +//////////////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////////////// +//////////////// Begin Excel APIs (latest = 1.3) /////////////// +//////////////////////////////////////////////////////////////// + + declare module Excel { interface ThreeArrowsSet { [index: number]: Icon; @@ -1928,7 +2602,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Application extends OfficeExtension.ClientObject { - private m_calculationMode; /** * * Returns the calculation mode used in the workbook. See Excel.CalculationMode for details. Read-only. @@ -1949,6 +2622,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Application; + toJSON(): { + "calculationMode": string; + }; } /** * @@ -1957,14 +2633,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Workbook extends OfficeExtension.ClientObject { - private m_application; - private m_bindings; - private m_functions; - private m_names; - private m_pivotTables; - private m_tables; - private m_worksheets; - private m_selectionChanged; /** * * Represents Excel application instance that contains this workbook. Read-only. @@ -1997,7 +2665,7 @@ declare module Excel { * * Represents a collection of PivotTables associated with the workbook. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ pivotTables: Excel.PivotTableCollection; /** @@ -2032,6 +2700,7 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ onSelectionChanged: OfficeExtension.EventHandlers; + toJSON(): {}; } /** * @@ -2040,14 +2709,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Worksheet extends OfficeExtension.ClientObject { - private m_charts; - private m_id; - private m_name; - private m_pivotTables; - private m_position; - private m_protection; - private m_tables; - private m_visibility; /** * * Returns collection of charts that are part of the worksheet. Read-only. @@ -2059,7 +2720,7 @@ declare module Excel { * * Collection of PivotTables that are part of the worksheet. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ pivotTables: Excel.PivotTableCollection; /** @@ -2150,6 +2811,13 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Worksheet; + toJSON(): { + "id": string; + "name": string; + "position": number; + "protection": WorksheetProtection; + "visibility": string; + }; } /** * @@ -2158,7 +2826,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class WorksheetCollection extends OfficeExtension.ClientObject { - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -2186,19 +2853,11 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getItem(key: string): Excel.Worksheet; - /** - * - * Gets a worksheet object using its Name or ID. If the worksheet does not exist, the returned object's isNull property will be true. - * - * @param key The Name or ID of the worksheet. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(key: string): Excel.Worksheet; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.WorksheetCollection; + toJSON(): {}; } /** * @@ -2207,11 +2866,9 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ class WorksheetProtection extends OfficeExtension.ClientObject { - private m_options; - private m_protected; /** * - * Sheet protection options. + * Sheet protection options. Read-Only. * * [Api set: ExcelApi 1.2] */ @@ -2243,6 +2900,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.WorksheetProtection; + toJSON(): { + "options": WorksheetProtectionOptions; + "protected": boolean; + }; } /** * @@ -2336,29 +2997,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Range extends OfficeExtension.ClientObject { - private m_address; - private m_addressLocal; - private m_cellCount; - private m_columnCount; - private m_columnHidden; - private m_columnIndex; - private m_format; - private m_formulas; - private m_formulasLocal; - private m_formulasR1C1; - private m_hidden; - private m_numberFormat; - private m_rowCount; - private m_rowHidden; - private m_rowIndex; - private m_sort; - private m_text; - private m_valueTypes; - private m_values; - private m_worksheet; - private m__ReferenceId; - private _ensureInteger(num, methodName); - private _getAdjacentRange(functionName, count, referenceRange, rowDirection, columnDirection); /** * * Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties. Read-only. @@ -2396,7 +3034,7 @@ declare module Excel { addressLocal: string; /** * - * Number of cells in the range. Read-only. + * Number of cells in the range. This API will return -1 if the cell count exceeds 2^31-1 (2,147,483,647). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -2586,15 +3224,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getIntersection(anotherRange: Excel.Range | string): Excel.Range; - /** - * - * Gets the range object that represents the rectangular intersection of the given ranges. If no intersection is found, will return a null object. - * - * @param anotherRange The range object or range address that will be used to determine the intersection of ranges. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getIntersectionOrNull(anotherRange: Excel.Range | string): Excel.Range; /** * * Gets the last cell within the range. For example, the last cell of "B2:D5" is "D5". @@ -2676,7 +3305,7 @@ declare module Excel { * * Represents the visible rows of the current range. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ getVisibleView(): Excel.RangeView; /** @@ -2715,6 +3344,34 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Range; + /** + * Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. + */ + track(): Excel.Range; + /** + * Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. + */ + untrack(): Excel.Range; + toJSON(): { + "address": string; + "addressLocal": string; + "cellCount": number; + "columnCount": number; + "columnHidden": boolean; + "columnIndex": number; + "format": RangeFormat; + "formulas": any[][]; + "formulasLocal": any[][]; + "formulasR1C1": any[][]; + "hidden": boolean; + "numberFormat": any[][]; + "rowCount": number; + "rowHidden": boolean; + "rowIndex": number; + "text": any[][]; + "values": any[][]; + "valueTypes": string[][]; + }; } /** * @@ -2729,109 +3386,125 @@ declare module Excel { * * RangeView represents a set of visible cells of the parent range. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ class RangeView extends OfficeExtension.ClientObject { - private m_columnCount; - private m_formulas; - private m_formulasLocal; - private m_formulasR1C1; - private m_numberFormat; - private m_rowCount; - private m_rows; - private m_text; - private m_valueTypes; - private m_values; /** * * Represents a collection of range views associated with the range. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ rows: Excel.RangeViewCollection; + /** + * + * Represents the cell addresses of the RangeView. + * + * [Api set: ExcelApi 1.3] + */ + cellAddresses: Array>; /** * * Returns the number of visible columns. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ columnCount: number; /** * * Represents the formula in A1-style notation. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ formulas: Array>; /** * * Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ formulasLocal: Array>; /** * * Represents the formula in R1C1-style notation. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ formulasR1C1: Array>; /** * - * Represents Excel's number format code for the given cell. Read-only. + * Returns a value that represents the index of the RangeView. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] + */ + index: number; + /** + * + * Represents Excel's number format code for the given cell. + * + * [Api set: ExcelApi 1.3] */ numberFormat: Array>; /** * * Returns the number of visible rows. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ rowCount: number; /** * * Text values of the specified range. The Text value will not depend on the cell width. The # sign substitution that happens in Excel UI will not affect the text value returned by the API. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ text: Array>; /** * * Represents the type of data of each cell. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ valueTypes: Array>; /** * * Represents the raw values of the specified range view. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ values: Array>; /** * * Gets the parent range associated with the current RangeView. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ getRange(): Excel.Range; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeView; + toJSON(): { + "cellAddresses": any[][]; + "columnCount": number; + "formulas": any[][]; + "formulasLocal": any[][]; + "formulasR1C1": any[][]; + "index": number; + "numberFormat": any[][]; + "rowCount": number; + "text": any[][]; + "values": any[][]; + "valueTypes": string[][]; + }; } /** * * Represents a collection of worksheet objects that are part of the workbook. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ class RangeViewCollection extends OfficeExtension.ClientObject { - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -2840,22 +3513,58 @@ declare module Excel { * * @param index Index of the visible row. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ - getItem(index: number): Excel.RangeView; + getItemAt(index: number): Excel.RangeView; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeViewCollection; + toJSON(): {}; } /** * - * A collection of all the nameditem objects that are part of the workbook. + * Setting represents a key-value pair of a setting persisted to the document. + * + * [Api set: ExcelApi 1.3] + */ + class Setting extends OfficeExtension.ClientObject { + /** + * + * Represents the value stored for this setting. + * + * [Api set: ExcelApi 1.3] + */ + value: any; + /** + * + * Returns the key that represents the id of the Setting. Read-only. + * + * [Api set: ExcelApi 1.3] + */ + key: string; + /** + * + * Deletes the setting. + * + * [Api set: ExcelApi 1.3] + */ + delete(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Setting; + toJSON(): { + "key": string; + }; + } + /** + * + * A collection of all the nameditem objects that are part of the workbook or worksheet, depending on how it was reached. * * [Api set: ExcelApi 1.1] */ class NamedItemCollection extends OfficeExtension.ClientObject { - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -2867,19 +3576,11 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getItem(name: string): Excel.NamedItem; - /** - * - * Gets a nameditem object using its name. If the nameditem object does not exist, the returned object's isNull property will be true. - * - * @param name nameditem name. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(name: string): Excel.NamedItem; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.NamedItemCollection; + toJSON(): {}; } /** * @@ -2888,11 +3589,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class NamedItem extends OfficeExtension.ClientObject { - private m_name; - private m_type; - private m_value; - private m_visible; - private m__Id; /** * * The name of the object. Read-only. @@ -2902,14 +3598,14 @@ declare module Excel { name: string; /** * - * Indicates what type of reference is associated with the name. See Excel.NamedItemType for details. Read-only. + * Indicates the type of the value returned by the name's formula. See Excel.NamedItemType for details. Read-only. * * [Api set: ExcelApi 1.1] */ type: string; /** * - * Represents the formula that the name is defined to refer to. E.g. =Sheet14!$B$2:$H$12, =4.75, etc. Read-only. + * Represents the value computed by the name's formula. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -2928,10 +3624,23 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getRange(): Excel.Range; + /** + * + * Returns the range object that is associated with the name. Returns a null object if the named item's type is not a range + * + * [Api set: ExcelApi 1.1] + */ + getRangeOrNullObject(): Excel.Range; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.NamedItem; + toJSON(): { + "name": string; + "type": string; + "value": any; + "visible": boolean; + }; } /** * @@ -2940,10 +3649,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Binding extends OfficeExtension.ClientObject { - private m_id; - private m_type; - private m_dataChanged; - private m_selectionChanged; /** * * Represents binding identifier. Read-only. @@ -2958,6 +3663,13 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ type: string; + /** + * + * Deletes the binding. + * + * [Api set: ExcelApi 1.3] + */ + delete(): void; /** * * Returns the range represented by the binding. Will throw an error if binding is not of the correct type. @@ -2985,7 +3697,7 @@ declare module Excel { load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Binding; /** * - * Occurs when data within the binding is changed. + * Occurs when data or formatting within the binding is changed. * * [Api set: ExcelApi 1.2] */ @@ -2997,6 +3709,10 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ onSelectionChanged: OfficeExtension.EventHandlers; + toJSON(): { + "id": string; + "type": string; + }; } /** * @@ -3005,8 +3721,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class BindingCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -3024,7 +3738,7 @@ declare module Excel { * @param bindingType Type of binding. See Excel.BindingType. * @param id Name of binding. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ add(range: Excel.Range | string, bindingType: string, id: string): Excel.Binding; /** @@ -3035,7 +3749,7 @@ declare module Excel { * @param bindingType Type of binding. See Excel.BindingType. * @param id Name of binding. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ addFromNamedItem(name: string, bindingType: string, id: string): Excel.Binding; /** @@ -3045,7 +3759,7 @@ declare module Excel { * @param bindingType Type of binding. See Excel.BindingType. * @param id Name of binding. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ addFromSelection(bindingType: string, id: string): Excel.Binding; /** @@ -3066,29 +3780,21 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getItemAt(index: number): Excel.Binding; - /** - * - * Gets a binding object by ID. If the binding object does not exist, the return object's isNull property will be true. - * - * @param id Id of the binding object to be retrieved. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(id: string): Excel.Binding; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.BindingCollection; + toJSON(): { + "count": number; + }; } /** * - * Represents a collection of all the tables that are part of the workbook. + * Represents a collection of all the tables that are part of the workbook or worksheet, depending on how it was reached. * * [Api set: ExcelApi 1.1] */ class TableCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -3100,14 +3806,14 @@ declare module Excel { count: number; /** * - * Create a new table. The range source address determines the worksheet under which the table will be added. If the table cannot be added (e.g., because the address is invalid, or the table would overlap with another table), an error will be thrown. + * Create a new table. The range object or source address determines the worksheet under which the table will be added. If the table cannot be added (e.g., because the address is invalid, or the table would overlap with another table), an error will be thrown. * - * @param address Address or name of the range object representing the data source. If the address does not contain a sheet name, the currently-active sheet is used. + * @param address A Range object, or a string address or name of the range representing the data source. If the address does not contain a sheet name, the currently-active sheet is used. [Api set: ExcelApi 1.1 for string parameter; 1.3 for accepting a Range object as well] * @param hasHeaders Boolean value that indicates whether the data being imported has column labels. If the source does not contain headers (i.e,. when this property set to false), Excel will automatically generate header shifting the data down by one row. * * [Api set: ExcelApi 1.1] */ - add(address: string, hasHeaders: boolean): Excel.Table; + add(address: Excel.Range | string, hasHeaders: boolean): Excel.Table; /** * * Gets a table by Name or ID. @@ -3126,19 +3832,13 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getItemAt(index: number): Excel.Table; - /** - * - * Gets a table by Name or ID. If the table does not exist, the return object's isNull property will be true. - * - * @param key Name or ID of the table to be retrieved. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(key: number | string): Excel.Table; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableCollection; + toJSON(): { + "count": number; + }; } /** * @@ -3147,20 +3847,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Table extends OfficeExtension.ClientObject { - private m_columns; - private m_highlightFirstColumn; - private m_highlightLastColumn; - private m_id; - private m_name; - private m_rows; - private m_showBandedColumns; - private m_showBandedRows; - private m_showFilterButton; - private m_showHeaders; - private m_showTotals; - private m_sort; - private m_style; - private m_worksheet; /** * * Represents a collection of all the columns in the table. Read-only. @@ -3193,14 +3879,14 @@ declare module Excel { * * Indicates whether the first column contains special formatting. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ highlightFirstColumn: boolean; /** * * Indicates whether the last column contains special formatting. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ highlightLastColumn: boolean; /** @@ -3221,21 +3907,21 @@ declare module Excel { * * Indicates whether the columns show banded formatting in which odd columns are highlighted differently from even ones to make reading the table easier. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ showBandedColumns: boolean; /** * * Indicates whether the rows show banded formatting in which odd rows are highlighted differently from even ones to make reading the table easier. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ showBandedRows: boolean; /** * * Indicates whether the filter buttons are visible at the top of each column header. Setting this is only allowed if the table contains a header row. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ showFilterButton: boolean; /** @@ -3319,6 +4005,18 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Table; + toJSON(): { + "highlightFirstColumn": boolean; + "highlightLastColumn": boolean; + "id": number; + "name": string; + "showBandedColumns": boolean; + "showBandedRows": boolean; + "showFilterButton": boolean; + "showHeaders": boolean; + "showTotals": boolean; + "style": string; + }; } /** * @@ -3327,8 +4025,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class TableColumnCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -3342,12 +4038,13 @@ declare module Excel { * * Adds a new column to the table. * - * @param index Specifies the relative position of the new column. The previous column at this position is shifted to the right. The index value should be equal to or less than the last column's index value, so it cannot be used to append a column at the end of the table. Zero-indexed. + * @param index Specifies the relative position of the new column. If null or -1, the addition happens at the end. Columns with a higher index will be shifted to the side. Zero-indexed. * @param values A 2-dimensional array of unformatted values of the table column. + * @param name Specifies the name of the new column. If null, the default name will be used. * - * [Api set: ExcelApi 1.1] + * [Api set: ExcelApi 1.1 requires an index smaller than the total column count; 1.4 allows index to be optional (null or -1) and will append a column at the end; 1.4 allows name parameter at creation time.] */ - add(index: number, values?: Array> | boolean | string | number): Excel.TableColumn; + add(index?: number, values?: Array> | boolean | string | number, name?: string): Excel.TableColumn; /** * * Gets a column object by Name or ID. @@ -3366,19 +4063,13 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getItemAt(index: number): Excel.TableColumn; - /** - * - * Gets a column object by Name or ID. If the column does not exist, the returned object's isNull property will be true. - * - * @param key Column Name or ID. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(key: number | string): Excel.TableColumn; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableColumnCollection; + toJSON(): { + "count": number; + }; } /** * @@ -3387,11 +4078,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class TableColumn extends OfficeExtension.ClientObject { - private m_filter; - private m_id; - private m_index; - private m_name; - private m_values; /** * * Retrieve the filter applied to the column. @@ -3415,9 +4101,9 @@ declare module Excel { index: number; /** * - * Returns the name of the table column. Read-only. + * Represents the name of the table column. * - * [Api set: ExcelApi 1.1] + * [Api set: ExcelApi 1.1 for getting the name; 1.4 for setting it.] */ name: string; /** @@ -3466,6 +4152,12 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableColumn; + toJSON(): { + "id": number; + "index": number; + "name": string; + "values": any[][]; + }; } /** * @@ -3474,8 +4166,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class TableRowCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -3487,12 +4177,12 @@ declare module Excel { count: number; /** * - * Adds a new row to the table. + * Adds one or more rows to the table. The return object will be the top of the newly added row(s). * - * @param index Specifies the relative position of the new row. If null, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed. + * @param index Specifies the relative position of the new row. If null or -1, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed. * @param values A 2-dimensional array of unformatted values of the table row. * - * [Api set: ExcelApi 1.1] + * [Api set: ExcelApi 1.1 for adding a single row; 1.4 allows adding of multiple rows.] */ add(index?: number, values?: Array> | boolean | string | number): Excel.TableRow; /** @@ -3508,6 +4198,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableRowCollection; + toJSON(): { + "count": number; + }; } /** * @@ -3516,8 +4209,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class TableRow extends OfficeExtension.ClientObject { - private m_index; - private m_values; /** * * Returns the index number of the row within the rows collection of the table. Zero-indexed. Read-only. @@ -3527,7 +4218,14 @@ declare module Excel { index: number; /** * +<<<<<<< HEAD * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. +======= + * The first criterion used to filter data. Used as an operator in the case of "custom" filtering. + For example ">50" for number greater than 50 or "=*s" for values ending in "s". + + Used as a number in the case of top/bottom items/percents. E.g. "5" for the top 5 items if filterOn is set to "topItems" +>>>>>>> types-2.0 * * [Api set: ExcelApi 1.1] */ @@ -3550,6 +4248,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableRow; + toJSON(): { + "index": number; + "values": any[][]; + }; } /** * @@ -3558,18 +4260,9 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class RangeFormat extends OfficeExtension.ClientObject { - private m_borders; - private m_columnWidth; - private m_fill; - private m_font; - private m_horizontalAlignment; - private m_protection; - private m_rowHeight; - private m_verticalAlignment; - private m_wrapText; /** * - * Collection of border objects that apply to the overall range selected Read-only. + * Collection of border objects that apply to the overall range. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -3583,7 +4276,7 @@ declare module Excel { fill: Excel.RangeFill; /** * - * Returns the font object defined on the overall range selected Read-only. + * Returns the font object defined on the overall range. Read-only. * * [Api set: ExcelApi 1.1] */ @@ -3648,6 +4341,16 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFormat; + toJSON(): { + "columnWidth": number; + "fill": RangeFill; + "font": RangeFont; + "horizontalAlignment": string; + "protection": FormatProtection; + "rowHeight": number; + "verticalAlignment": string; + "wrapText": boolean; + }; } /** * @@ -3656,8 +4359,6 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ class FormatProtection extends OfficeExtension.ClientObject { - private m_formulaHidden; - private m_locked; /** * * Indicates if Excel hides the formula for the cells in the range. A null value indicates that the entire range doesn't have uniform formula hidden setting. @@ -3676,6 +4377,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.FormatProtection; + toJSON(): { + "formulaHidden": boolean; + "locked": boolean; + }; } /** * @@ -3684,7 +4389,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class RangeFill extends OfficeExtension.ClientObject { - private m_color; /** * * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") @@ -3703,6 +4407,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFill; + toJSON(): { + "color": string; + }; } /** * @@ -3711,10 +4418,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class RangeBorder extends OfficeExtension.ClientObject { - private m_color; - private m_sideIndex; - private m_style; - private m_weight; /** * * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). @@ -3747,6 +4450,12 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeBorder; + toJSON(): { + "color": string; + "sideIndex": string; + "style": string; + "weight": string; + }; } /** * @@ -3755,8 +4464,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class RangeBorderCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -3788,6 +4495,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeBorderCollection; + toJSON(): { + "count": number; + }; } /** * @@ -3796,12 +4506,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class RangeFont extends OfficeExtension.ClientObject { - private m_bold; - private m_color; - private m_italic; - private m_name; - private m_size; - private m_underline; /** * * Represents the bold status of font. @@ -3848,6 +4552,14 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFont; + toJSON(): { + "bold": boolean; + "color": string; + "italic": boolean; + "name": string; + "size": number; + "underline": string; + }; } /** * @@ -3856,8 +4568,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -3896,20 +4606,13 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ getItemAt(index: number): Excel.Chart; - /** - * - * Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned. - If the chart does not exist, the returned object's isNull property will be true. - * - * @param name Name of the chart to be retrieved. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(name: string): Excel.Chart; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartCollection; + toJSON(): { + "count": number; + }; } /** * @@ -3918,18 +4621,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class Chart extends OfficeExtension.ClientObject { - private m_axes; - private m_dataLabels; - private m_format; - private m_height; - private m_left; - private m_legend; - private m_name; - private m_series; - private m_title; - private m_top; - private m_width; - private m_worksheet; /** * * Represents chart axes. Read-only. @@ -4057,6 +4748,18 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Chart; + toJSON(): { + "axes": ChartAxes; + "dataLabels": ChartDataLabels; + "format": ChartAreaFormat; + "height": number; + "left": number; + "legend": ChartLegend; + "name": string; + "title": ChartTitle; + "top": number; + "width": number; + }; } /** * @@ -4065,8 +4768,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartAreaFormat extends OfficeExtension.ClientObject { - private m_fill; - private m_font; /** * * Represents the fill format of an object, which includes background formatting information. Read-only. @@ -4085,6 +4786,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAreaFormat; + toJSON(): { + "fill": ChartFill; + "font": ChartFont; + }; } /** * @@ -4093,8 +4798,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartSeriesCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -4117,6 +4820,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeriesCollection; + toJSON(): { + "count": number; + }; } /** * @@ -4125,9 +4831,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartSeries extends OfficeExtension.ClientObject { - private m_format; - private m_name; - private m_points; /** * * Represents the formatting of a chart series, which includes fill and line formatting. Read-only. @@ -4153,6 +4856,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeries; + toJSON(): { + "format": ChartSeriesFormat; + "name": string; + }; } /** * @@ -4161,8 +4868,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartSeriesFormat extends OfficeExtension.ClientObject { - private m_fill; - private m_line; /** * * Represents the fill format of a chart series, which includes background formating information. Read-only. @@ -4181,6 +4886,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeriesFormat; + toJSON(): { + "fill": ChartFill; + "line": ChartLineFormat; + }; } /** * @@ -4189,8 +4898,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartPointsCollection extends OfficeExtension.ClientObject { - private m_count; - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -4213,6 +4920,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPointsCollection; + toJSON(): { + "count": number; + }; } /** * @@ -4221,8 +4931,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartPoint extends OfficeExtension.ClientObject { - private m_format; - private m_value; /** * * Encapsulates the format properties chart point. Read-only. @@ -4241,6 +4949,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPoint; + toJSON(): { + "format": ChartPointFormat; + "value": any; + }; } /** * @@ -4249,7 +4961,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartPointFormat extends OfficeExtension.ClientObject { - private m_fill; /** * * Represents the fill format of a chart, which includes background formating information. Read-only. @@ -4261,6 +4972,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPointFormat; + toJSON(): { + "fill": ChartFill; + }; } /** * @@ -4269,9 +4983,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartAxes extends OfficeExtension.ClientObject { - private m_categoryAxis; - private m_seriesAxis; - private m_valueAxis; /** * * Represents the category axis in a chart. Read-only. @@ -4297,6 +5008,11 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxes; + toJSON(): { + "categoryAxis": ChartAxis; + "seriesAxis": ChartAxis; + "valueAxis": ChartAxis; + }; } /** * @@ -4305,14 +5021,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartAxis extends OfficeExtension.ClientObject { - private m_format; - private m_majorGridlines; - private m_majorUnit; - private m_maximum; - private m_minimum; - private m_minorGridlines; - private m_minorUnit; - private m_title; /** * * Represents the formatting of a chart object, which includes line and font formatting. Read-only. @@ -4373,6 +5081,16 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxis; + toJSON(): { + "format": ChartAxisFormat; + "majorGridlines": ChartGridlines; + "majorUnit": any; + "maximum": any; + "minimum": any; + "minorGridlines": ChartGridlines; + "minorUnit": any; + "title": ChartAxisTitle; + }; } /** * @@ -4381,8 +5099,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartAxisFormat extends OfficeExtension.ClientObject { - private m_font; - private m_line; /** * * Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. @@ -4401,6 +5117,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisFormat; + toJSON(): { + "font": ChartFont; + "line": ChartLineFormat; + }; } /** * @@ -4409,9 +5129,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartAxisTitle extends OfficeExtension.ClientObject { - private m_format; - private m_text; - private m_visible; /** * * Represents the formatting of chart axis title. Read-only. @@ -4437,6 +5154,11 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisTitle; + toJSON(): { + "format": ChartAxisTitleFormat; + "text": string; + "visible": boolean; + }; } /** * @@ -4445,7 +5167,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartAxisTitleFormat extends OfficeExtension.ClientObject { - private m_font; /** * * Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. @@ -4457,6 +5178,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisTitleFormat; + toJSON(): { + "font": ChartFont; + }; } /** * @@ -4465,15 +5189,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartDataLabels extends OfficeExtension.ClientObject { - private m_format; - private m_position; - private m_separator; - private m_showBubbleSize; - private m_showCategoryName; - private m_showLegendKey; - private m_showPercentage; - private m_showSeriesName; - private m_showValue; /** * * Represents the format of chart data labels, which includes fill and font formatting. Read-only. @@ -4541,6 +5256,17 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartDataLabels; + toJSON(): { + "format": ChartDataLabelFormat; + "position": string; + "separator": string; + "showBubbleSize": boolean; + "showCategoryName": boolean; + "showLegendKey": boolean; + "showPercentage": boolean; + "showSeriesName": boolean; + "showValue": boolean; + }; } /** * @@ -4549,8 +5275,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartDataLabelFormat extends OfficeExtension.ClientObject { - private m_fill; - private m_font; /** * * Represents the fill format of the current chart data label. Read-only. @@ -4569,6 +5293,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartDataLabelFormat; + toJSON(): { + "fill": ChartFill; + "font": ChartFont; + }; } /** * @@ -4577,8 +5305,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartGridlines extends OfficeExtension.ClientObject { - private m_format; - private m_visible; /** * * Represents the formatting of chart gridlines. Read-only. @@ -4597,6 +5323,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartGridlines; + toJSON(): { + "format": ChartGridlinesFormat; + "visible": boolean; + }; } /** * @@ -4605,7 +5335,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartGridlinesFormat extends OfficeExtension.ClientObject { - private m_line; /** * * Represents chart line formatting. Read-only. @@ -4617,6 +5346,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartGridlinesFormat; + toJSON(): { + "line": ChartLineFormat; + }; } /** * @@ -4625,10 +5357,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartLegend extends OfficeExtension.ClientObject { - private m_format; - private m_overlay; - private m_position; - private m_visible; /** * * Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. @@ -4661,6 +5389,12 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLegend; + toJSON(): { + "format": ChartLegendFormat; + "overlay": boolean; + "position": string; + "visible": boolean; + }; } /** * @@ -4669,8 +5403,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartLegendFormat extends OfficeExtension.ClientObject { - private m_fill; - private m_font; /** * * Represents the fill format of an object, which includes background formating information. Read-only. @@ -4689,6 +5421,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLegendFormat; + toJSON(): { + "fill": ChartFill; + "font": ChartFont; + }; } /** * @@ -4697,10 +5433,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartTitle extends OfficeExtension.ClientObject { - private m_format; - private m_overlay; - private m_text; - private m_visible; /** * * Represents the formatting of a chart title, which includes fill and font formatting. Read-only. @@ -4733,6 +5465,12 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartTitle; + toJSON(): { + "format": ChartTitleFormat; + "overlay": boolean; + "text": string; + "visible": boolean; + }; } /** * @@ -4741,8 +5479,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartTitleFormat extends OfficeExtension.ClientObject { - private m_fill; - private m_font; /** * * Represents the fill format of an object, which includes background formating information. Read-only. @@ -4761,6 +5497,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartTitleFormat; + toJSON(): { + "fill": ChartFill; + "font": ChartFont; + }; } /** * @@ -4789,6 +5529,7 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ setSolidColor(color: string): void; + toJSON(): {}; } /** * @@ -4797,7 +5538,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartLineFormat extends OfficeExtension.ClientObject { - private m_color; /** * * HTML color code representing the color of lines in the chart. @@ -4816,6 +5556,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLineFormat; + toJSON(): { + "color": string; + }; } /** * @@ -4824,12 +5567,6 @@ declare module Excel { * [Api set: ExcelApi 1.1] */ class ChartFont extends OfficeExtension.ClientObject { - private m_bold; - private m_color; - private m_italic; - private m_name; - private m_size; - private m_underline; /** * * Represents the bold status of font. @@ -4876,6 +5613,14 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartFont; + toJSON(): { + "bold": boolean; + "color": string; + "italic": boolean; + "name": string; + "size": number; + "underline": string; + }; } /** * @@ -4897,6 +5642,7 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ apply(fields: Array, matchCase?: boolean, hasHeaders?: boolean, orientation?: string, method?: string): void; + toJSON(): {}; } /** * @@ -4905,9 +5651,6 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ class TableSort extends OfficeExtension.ClientObject { - private m_fields; - private m_matchCase; - private m_method; /** * * Represents the current conditions used to last sort the table. @@ -4958,6 +5701,11 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableSort; + toJSON(): { + "fields": SortField[]; + "matchCase": boolean; + "method": string; + }; } /** * @@ -5016,7 +5764,6 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ class Filter extends OfficeExtension.ClientObject { - private m_criteria; /** * * The currently applied filter on the given column. @@ -5136,6 +5883,9 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Filter; + toJSON(): { + "criteria": FilterCriteria; + }; } /** * @@ -5155,7 +5905,7 @@ declare module Excel { * * The first criterion used to filter data. Used as an operator in the case of "custom" filtering. For example ">50" for number greater than 50 or "=*s" for values ending in "s". - + Used as a number in the case of top/bottom items/percents. E.g. "5" for the top 5 items if filterOn is set to "topItems" * * [Api set: ExcelApi 1.2] @@ -5252,10 +6002,9 @@ declare module Excel { * * Represents a collection of all the PivotTables that are part of the workbook or worksheet. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ class PivotTableCollection extends OfficeExtension.ClientObject { - private m__items; /** Gets the loaded child items in this collection. */ items: Array; /** @@ -5264,64 +6013,57 @@ declare module Excel { * * @param name Name of the PivotTable to be retrieved. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ getItem(name: string): Excel.PivotTable; - /** - * - * Gets a PivotTable by name. If the PivotTable does not exist, the return object's isNull property will be true. - * - * @param name Name of the PivotTable to be retrieved. - * - * [Api set: ExcelApi 1.3 (Preview)] - */ - getItemOrNull(name: string): Excel.PivotTable; /** * * Refreshes all the PivotTables in the collection. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ refreshAll(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.PivotTableCollection; + toJSON(): {}; } /** * * Represents an Excel PivotTable. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ class PivotTable extends OfficeExtension.ClientObject { - private m_name; - private m_worksheet; /** * * The worksheet containing the current PivotTable. Read-only. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ worksheet: Excel.Worksheet; /** * * Name of the PivotTable. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ name: string; /** * * Refreshes the PivotTable. * - * [Api set: ExcelApi 1.3 (Preview)] + * [Api set: ExcelApi 1.3] */ refresh(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): Excel.PivotTable; + toJSON(): { + "name": string; + }; } /** * [Api set: ExcelApi 1.1] @@ -5664,6 +6406,7 @@ declare module Excel { var double: string; var boolean: string; var range: string; + var error: string; } /** * [Api set: ExcelApi 1.1] @@ -5742,8 +6485,6 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ class FunctionResult extends OfficeExtension.ClientObject { - private m_error; - private m_value; /** * * Error value (such as "#DIV/0") representing the error. If the error string is not set, then the function succeeded, and its result is written to the Value field. The error is always in the English locale. @@ -5753,7 +6494,7 @@ declare module Excel { error: string; /** * - * The value of function evaluation. The value field will be populated only if no error has occured (i.e., the Error property is not set). + * The value of function evaluation. The value field will be populated only if no error has occurred (i.e., the Error property is not set). * * [Api set: ExcelApi 1.2] */ @@ -5762,6 +6503,10 @@ declare module Excel { * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(option?: string | string[] | OfficeExtension.LoadOption): FunctionResult; + toJSON(): { + "error": string; + "value": T; + }; } /** * @@ -9506,9 +10251,11 @@ declare module Excel { * [Api set: ExcelApi 1.2] */ z_Test(array: number | Excel.Range | Excel.RangeReference | Excel.FunctionResult, x: number | Excel.Range | Excel.RangeReference | Excel.FunctionResult, sigma?: number | Excel.Range | Excel.RangeReference | Excel.FunctionResult): FunctionResult; + toJSON(): {}; } module ErrorCodes { var accessDenied: string; + var apiNotFound: string; var generalException: string; var insertDeleteConflict: string; var invalidArgument: string; @@ -9527,17 +10274,67 @@ declare module Excel { * The RequestContext object facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the request context is required to get access to the Excel object model from the add-in. */ class RequestContext extends OfficeExtension.ClientRequestContext { - private m_workbook; constructor(url?: string); workbook: Workbook; } /** - * Executes a batch script that performs actions on the Excel object model. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. - * @param batch - A function that takes in an Excel.RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the request context is required to get access to the Excel object model from the add-in. + * Executes a batch script that performs actions on the Excel object model, using a new RequestContext. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. */ function run(batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; + /** + * Executes a batch script that performs actions on the Excel object model, using a new remote RequestContext. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param requestInfo - The URL of the remote workbook and the request headers to be sent. + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(requestInfo: OfficeExtension.RequestUrlAndHeaderInfo, batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; + /** + * Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created API object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param object - A previously-created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()". + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; + /** + * Executes a batch script that performs actions on the Excel object model, using the remote RequestContext of a previously-created API object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param requestInfo - The URL of the remote workbook and the request headers to be sent. + * @param object - A previously-created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()". + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(requestInfo: OfficeExtension.RequestUrlAndHeaderInfo, object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; + /** + * Executes a batch script that performs actions on the Excel object model, using the RequestContext of previously-created API objects. + * @param objects - An array of previously-created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by "context.sync()". + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; + /** + * Executes a batch script that performs actions on the Excel object model, using the remote RequestContext of previously-created API objects. + * @param requestInfo - The URL of the remote workbook and the request headers to be sent. + * @param objects - An array of previously-created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by "context.sync()". + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(requestInfo: OfficeExtension.RequestUrlAndHeaderInfo, objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; } + + +//////////////////////////////////////////////////////////////// +//////////////////////// End Excel APIs //////////////////////// +//////////////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////////////// +//////////////////////// Begin Word APIs /////////////////////// +//////////////////////////////////////////////////////////////// + + declare namespace Word { /** * @@ -12943,614 +13740,26 @@ declare namespace Word { function run(batch: (context: Word.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; } -declare namespace Office.MailboxEnums { - export enum BodyType { - /** - * The body is in HTML format - */ - Html, - /** - * The body is in text format - */ - text - } - export enum EntityType { - /** - * Specifies that the entity is a meeting suggestion - */ - MeetingSuggestion, - /** - * Specifies that the entity is a task suggestion - */ - TaskSuggestion, - /** - * Specifies that the entity is a postal address - */ - Address, - /** - * Specifies that the entity is SMTP email address - */ - EmailAddress, - /** - * Specifies that the entity is an Internet URL - */ - Url, - /** - * Specifies that the entity is US phone number - */ - PhoneNumber, - /** - * Specifies that the entity is a contact - */ - Contact - } - export enum ItemType { - /** - * A meeting request, response, or cancellation - */ - Message, - /** - * Specifies an appointment item - */ - Appointment - } - export enum ResponseType { - /** - * There has been no response from the attendee - */ - None, - /** - * The attendee is the meeting organizer - */ - Organizer, - /** - * The meeting request was tentatively accepted by the attendee - */ - Tentative, - /** - * The meeting request was accepted by the attendee - */ - Accepted, - /** - * The meeting request was declined by the attendee - */ - Declined - } - export enum RecipientType { - /** - * Specifies that the recipient is not one of the other recipient types - */ - Other, - /** - * Specifies that the recipient is a distribution list containing a list of email addresses - */ - DistributionList, - /** - * Specifies that the recipient is an SMTP email address that is on the Exchange server - */ - User, - /** - * Specifies that the recipient is an SMTP email address that is not on the Exchange server - */ - ExternalUser - } - export enum AttachmentType { - /** - * The attachment is a file - */ - File, - /** - * The attachment is an Exchange item - */ - Item - } -} -declare namespace Office { - export module Types { - export interface ItemRead extends Office.Item { - subject: any; - /** - * Displays a reply form that includes the sender and all the recipients of the selected message - * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB - */ - displayReplyAllForm(htmlBody: string): void; - /** - * Displays a reply form that includes only the sender of the selected message - * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB - */ - displayReplyForm(htmlBody: string): void; - /** - * Gets an array of entities found in an message - */ - getEntities(): Office.Entities; - /** - * Gets an array of entities of the specified entity type found in an message - * @param entityType One of the EntityType enumeration values - */ - getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; - /** - * Returns well-known entities that pass the named filter defined in the manifest XML file - * @param name A TableData object with the headers and rows - */ - getFilteredEntitiesByName(name: string): Office.Entities; - /** - * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file - */ - getRegExMatches(): string[]; - /** - * Returns string values that match the named regular expression defined in the manifest XML file - */ - getRegExMatchesByName(name: string): string[]; - } - export interface ItemCompose extends Office.Item { - body: Office.Body; - subject: any; - /** - * Adds a file to a message as an attachment - * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters - * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Adds an Exchange item, such as a message, as an attachment to the message - * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters - * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Removes an attachment from a message - * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; - } - export interface MessageCompose extends Office.Message { - attachments: Office.AttachmentDetails[]; - body: Office.Body; - bcc: Office.Recipients; - cc: Office.Recipients; - subject: Office.Subject; - to: Office.Recipients; - /** - * Adds a file to a message as an attachment - * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters - * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Adds an Exchange item, such as a message, as an attachment to the message - * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters - * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Removes an attachment from a message - * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; - } - export interface MessageRead extends Office.Message { - cc: Office.EmailAddressDetails[]; - from: Office.EmailAddressDetails; - internetMessageId: string; - normalizedSubject: string; - sender: Office.EmailAddressDetails; - subject: string; - to: Office.EmailAddressDetails; - /** - * Displays a reply form that includes the sender and all the recipients of the selected message - * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB - */ - displayReplyAllForm(htmlBody: string): void; - /** - * Displays a reply form that includes only the sender of the selected message - * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB - */ - displayReplyForm(htmlBody: string): void; - /** - * Gets an array of entities found in an message - */ - getEntities(): Office.Entities; - /** - * Gets an array of entities of the specified entity type found in an message - * @param entityType One of the EntityType enumeration values - */ - getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; - /** - * Returns well-known entities that pass the named filter defined in the manifest XML file - * @param name A TableData object with the headers and rows - */ - getFilteredEntitiesByName(name: string): Office.Entities; - /** - * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file - */ - getRegExMatches(): string[]; - /** - * Returns string values that match the named regular expression defined in the manifest XML file - */ - getRegExMatchesByName(name: string): string[]; - } - export interface AppointmentCompose extends Office.Appointment { - body: Office.Body; - end: Office.Time; - location: Office.Location; - optionalAttendees: Office.Recipients; - requiredAttendees: Office.Recipients; - start: Office.Time; - subject: Office.Subject; - /** - * Adds a file to an appointment as an attachment - * @param uri The URI that provides the location of the file to attach to the appointment. The maximum length is 2048 characters - * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Adds an Exchange item, such as a message, as an attachment to the appointment - * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters - * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Removes an attachment from a appointment - * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional callback method - */ - removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; - } - export interface AppointmentRead extends Office.Appointment { - attachments: Office.AttachmentDetails[]; - end: Date; - location: string; - normalizedSubject: string; - optionalAttendees: Office.EmailAddressDetails; - organizer: Office.EmailAddressDetails; - requiredAttendees: Office.EmailAddressDetails; - resources: string[]; - start: Date; - subject: string; - /** - * Displays a reply form that includes the organizer and all the attendees of the selected appointment item - * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB - */ - displayReplyAllForm(htmlBody: string): void; - /** - * Displays a reply form that includes only the organizer of the selected appointment item - * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB - */ - displayReplyForm(htmlBody: string): void; - /** - * Gets an array of entities found in an appointment - */ - getEntities(): Office.Entities; - /** - * Gets an array of entities of the specified entity type found in an appointment - * @param entityType One of the EntityType enumeration values - */ - getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; - /** - * Returns well-known entities that pass the named filter defined in the manifest XML file - * @param name A TableData object with the headers and rows - */ - getFilteredEntitiesByName(name: string): Office.Entities; - /** - * Returns string values in the currently selected appointment object that match the regular expressions defined in the manifest XML file - */ - getRegExMatches(): string[]; - /** - * Returns string values that match the named regular expression defined in the manifest XML file - */ - getRegExMatchesByName(name: string): string[]; - } - } - export module cast { - export module item { - function toAppointmentCompose(item: Office.Item): Office.Types.AppointmentCompose; - function toAppointmentRead(item: Office.Item): Office.Types.AppointmentRead; - function toAppointment(item: Office.Item): Office.Appointment; - function toMessageCompose(item: Office.Item): Office.Types.MessageCompose; - function toMessageRead(item: Office.Item): Office.Types.MessageRead; - function toMessage(item: Office.Item): Office.Message; - function toItemCompose(item: Office.Item): Office.Types.ItemCompose; - function toItemRead(item: Office.Item): Office.Types.ItemRead; - } - } - export interface AttachmentDetails { - attachmentType: Office.MailboxEnums.AttachmentType; - contentType: string; - id: string; - isInline: boolean; - name: string; - size: number; - } - export interface Contact { - personName: string; - businessName: string; - phoneNumbers: PhoneNumber[]; - emailAddresses: string[]; - urls: string[]; - addresses: string[]; - contactString: string; - } - export interface Context { - mailbox: Mailbox; - roamingSettings: RoamingSettings; - } - export interface CustomProperties { - /** - * Returns the value of the specified custom property - * @param name The name of the property to be returned - */ - get(name: string): any; - /** - * Sets the specified property to the specified value - * @param name The name of the property to be set - * @param value The value of the property to be set - */ - set(name: string, value: string): void; - /** - * Removes the specified property from the custom property collection. - * @param name The name of the property to be removed - */ - remove(name: string): void; - /** - * Saves the custom property collection to the server - * @param callback The optional callback method - * @param userContext Optional variable for any state data that is passed to the saveAsync method - */ - saveAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; - } - export interface EmailAddressDetails { - emailAddress: string; - displayName: string; - appointmentResponse: Office.MailboxEnums.ResponseType; - recipientType: Office.MailboxEnums.RecipientType; - } - export interface EmailUser { - name: string; - userId: string; - } - export interface Entities { - addresses: string[]; - taskSuggestions: string[]; - meetingSuggestions: MeetingSuggestion[]; - emailAddresses: string[]; - urls: string[]; - phoneNumbers: PhoneNumber[]; - contacts: Contact[]; - } - export interface Item { - dateTimeCreated: Date; - dateTimeModified: Date; - itemClass: string; - itemId: string; - itemType: Office.MailboxEnums.ItemType; - /** - * Asynchronously loads custom properties that are specific to the item and a app for Office - * @param callback The optional callback method - * @param userContext Optional variable for any state data that is passed to the asynchronous method - */ - loadCustomPropertiesAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; - } - export interface Appointment extends Item { - } - export interface Body { - /** - * Gets a value that indicates whether the content is in HTML or text format - * @param tableData A TableData object with the headers and rows - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the getTypeAsync method returns - */ - getTypeAsync(options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Adds the specified content to the beginning of the item body - * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - prependAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Replaces the selection in the body with the specified text - * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; - } - export interface Location { - /** - * Begins an asynchronous request for the location of an appointment - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - getAsync(options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Begins an asynchronous request to set the location of an appointment - * @param data The location of the appointment. The string is limited to 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the location is set - */ - setAsync(location: string, options?: any, callback?: (result: AsyncResult) => void): void; - } - export interface Mailbox { - item: Item; - userProfile: UserProfile; - /** - * Gets a Date object from a dictionary containing time information - * @param timeValue A Date object - */ - convertToLocalClientTime(timeValue: Date): any; - /** - * Gets a dictionary containing time information in local client time - * @param input A dictionary containing a date. The dictionary should contain the following fields: year, month, date, hours, minutes, seconds, time zone, time zone offset - */ - convertToUtcClientTime(input: any): Date; - /** - * Displays an existing calendar appointment - * @param itemId The Exchange Web Services (EWS) identifier for an existing calendar appointment - */ - displayAppointmentForm(itemId: any): void; - /** - * Displays an existing message - * @param itemId The Exchange Web Services (EWS) identifier for an existing message - */ - displayMessageForm(itemId: any): void; - /** - * Displays a form for creating a new calendar appointment - * @param requiredAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the required attendees for the appointment. The array is limited to a maximum of 100 entries - * @param optionalAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the optional attendees for the appointment. The array is limited to a maximum of 100 entries - * @param start A Date object specifying the start date and time of the appointment - * @param end A Date object specifying the end date and time of the appointment - * @param location A string containing the location of the appointment. The string is limited to a maximum of 255 characters - * @param resources An array of strings containing the resources required for the appointment. The array is limited to a maximum of 100 entries - * @param subject A string containing the subject of the appointment. The string is limited to a maximum of 255 characters - * @param body The body of the appointment message. The body content is limited to a maximum size of 32 KB - */ - displayNewAppointmentForm(requiredAttendees: any, optionalAttendees: any, start: Date, end: Date, location: string, resources: string[], subject: string, body: string): void; - /** - * Gets a string that contains a token used to get an attachment or item from an Exchange Server - * @param callback The optional method to call when the string is inserted - * @param userContext Optional variable for any state data that is passed to the asynchronous method - */ - getCallbackTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; - /** - * Gets a token identifying the user and the app for Office - * @param callback The optional method to call when the string is inserted - * @param userContext Optional variable for any state data that is passed to the asynchronous method - */ - getUserIdentityTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; - /** - * Makes an asynchronous request to an Exchange Web Services (EWS) service on the Exchange server that hosts the user’s mailbox - * @param data The EWS request - * @param callback The optional method to call when the string is inserted - * @param userContext Optional variable for any state data that is passed to the asynchronous method - */ - makeEwsRequestAsync(data: any, callback?: (result: AsyncResult) => void, userContext?: any): void; - } - export interface Message extends Item { - conversationId: string; - } - export interface MeetingRequest extends Message { - start: Date; - end: Date; - location: string; - optionalAttendees: EmailAddressDetails[]; - requiredAttendees: EmailAddressDetails[]; - } - export interface MeetingSuggestion { - meetingString: string; - attendees: EmailAddressDetails[]; - location: string; - subject: string; - start: Date; - end: Date; - } - export interface PhoneNumber { - phoneString: string; - originalPhoneString: string; - type: string; - } - export interface Recipients { - /** - * Begins an asynchronous request to add a recipient list to an appointment or message - * @param recipients The recipients to add to the recipients list - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - addAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Begins an asynchronous request to get the recipient list for an appointment or message - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - getAsync(options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Begins an asynchronous request to set the recipient list for an appointment or message - * @param recipients The recipients to add to the recipients list - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - setAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; - } - export interface RoamingSettings { - /** - * Retrieves the specified setting - * @param name The case-sensitive name of the setting to retrieve - */ - get(name: string): any; - /** - * Removes the specified setting - * @param name The case-sensitive name of the setting to remove - */ - remove(name: string): void; - /** - * Saves the settings - * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult - */ - saveAsync(callback?: (result: AsyncResult) => void): void; - /** - * Sets or creates the specified setting - * @param name The case-sensitive name of the setting to set or create - * @param value Specifies the value to be stored - */ - set(name: string, value: any): void; - } - export interface Subject { - /** - * Begins an asynchronous request to get the subject of an appointment or message - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - getAsync(options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Begins an asynchronous call to set the subject of an appointment or message - * @param data The subject of the appointment. The string is limited to 255 characters - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - setAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; - } - export interface TaskSuggestion { - assignees: EmailUser[]; - taskString: string; - } - export interface Time { - /** - * Begins an asynchronous request to get the start or end time - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - getAsync(options?: any, callback?: (result: AsyncResult) => void): void; - /** - * Begins an asynchronous request to set the start or end time - * @param dateTime A date-time object in Coordinated Universal Time (UTC) - * @param options Any optional parameters or state data passed to the method - * @param callback The optional method to call when the string is inserted - */ - setAsync(dateTime: Date, options?: any, callback?: (result: AsyncResult) => void): void; - } - export interface UserProfile { - displayName: string; - emailAddress: string; - timeZone: string; - } -} + + + +//////////////////////////////////////////////////////////////// +///////////////////////// End Word APIs //////////////////////// +//////////////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////////////// +////////////////////// Begin OneNote APIs ////////////////////// +//////////////////////////////////////////////////////////////// + declare namespace OneNote { /** @@ -15725,3 +15934,8 @@ declare namespace OneNote { */ function run(batch: (context: OneNote.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; } + + +//////////////////////////////////////////////////////////////// +/////////////////////// End OneNote APIs /////////////////////// +//////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/plugapi/index.d.ts b/plugapi/index.d.ts new file mode 100644 index 0000000000..794fa01d46 --- /dev/null +++ b/plugapi/index.d.ts @@ -0,0 +1,416 @@ +// Type definitions for plugapi +// Project: https://www.npmjs.com/package/plugapi +// Definitions by: Brice Theurillat +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare namespace PlugAPI { + + export interface PlugLogin { + email: string; + password: string; + } + + export interface Notification { + action: string; + id: number; + timestamp: string; + value: string; + } + + export interface RawChatMessage { + cid: string; + message: string; + sub: number; + uid: number; + un: string; + } + + export interface Media { + author: string; + format: number; + image: string; + cid: string; + duration: number; + title: string; + id: number; + } + + export interface Score { + positive: number; + listeners: number; + grabs: number; + negative: number; + skipped: number; + } + + export interface LastPlay { + dj: User.DJ; + media: Media; + score: Score; + } + + export interface FollowJoinData { + r: number; + un: string; + id: string; + } + + export interface LogObject { + log: () => void; + } + + export namespace User { + interface Default { + username: string; + language: string; + avatarID: string; + } + + interface Extended extends Default { + status: number; + fans: number; + listenerPoints: number; + id: string; + curatorPoints: number; + djPoints: number; + } + + interface Update extends Extended { + dateJoined: string; + } + + interface Room extends Default { + sub: number; + level: number; + joined: string; + id: number; + badge: string; + role: number; + gRole: number; + slug: string; + } + + interface User extends Room { + silver: boolean; + guest: boolean; + } + + interface DJ extends Room { + blurp: any; + grab: boolean; + status: number; + vote: number; + } + + interface Audience extends DJ { + ignores: any[]; + notifications: Notification[]; + pp: number; + pw: number; + xp: number; + } + } + + export namespace Enum { + interface RoomRole { + NONE: number; + RESIDENTDJ: number; + BOUNCER: number; + MANAGER: number; + COHOST: number; + HOST: number; + } + + interface GlobalRole { + NONE: number; + VOLUNTEER: number; + AMBASSADOR: number; + LEADER: number; + ADMIN: number; + } + + interface Status { + OFFLINE: number; + ONLINE: number; + } + + interface Ban { + HOUR: "h"; + DAY: "d"; + PERMA: "f"; + } + + interface BanReason { + SPAMMING_TROLLING: number; + VERBAL_ABUSE: number; + OFFENSIVE_MEDIA: number; + INAPPROPRIATE_GENRE: number; + NEGATIVE_ATTITUDE: number; + } + + interface Mute { + SHORT: "s"; + MEDIUM: "m"; + LONG: "l"; + } + + interface MuteReason { + VIOLATING_COMMUNITY_RULES: number; + VERBAL_ABUSE: number; + SPAMMING_TROLLING: number; + OFFENSIVE_LANGUAGE: number; + NEGATIVE_ATTITUDE: number; + } + + interface Events { + ADVANCE: "advance"; + BAN: "ban"; + BOOTH_LOCKED: "boothLocked"; + CHAT: "chat"; + CHAT_COMMAND: "command"; + CHAT_DELETE: "chatDelete"; + CHAT_LEVEL_UPDATE: "roomMinChatLevelUpdate"; + COMMAND: "command"; + DJ_LIST_CYCLE: "djListCycle"; + DJ_LIST_UPDATE: "djListUpdate"; + DJ_LIST_LOCKED: "djListLocked"; + EARN: "earn"; + FOLLOW_JOIN: "followJoin"; + FLOOD_CHAT: "floodChat"; + FRIEND_REQUEST: "friendRequest"; + GIFTED: "gifted"; + GRAB: "grab"; + KILL_SESSION: "killSession"; + MAINT_MODE: "plugMaintenance"; + MAINT_MODE_ALERT: "plugMaintenanceAlert"; + MODERATE_ADD_DJ: "modAddDJ"; + MODERATE_ADD_WAITLIST: "modAddWaitList"; + MODERATE_AMBASSADOR: "modAmbassador"; + MODERATE_BAN: "modBan"; + MODERATE_MOVE_DJ: "modMoveDJ"; + MODERATE_MUTE: "modMute"; + MODERATE_REMOVE_DJ: "modRemoveDJ"; + MODERATE_REMOVE_WAITLIST: "modRemoveWaitList"; + MODERATE_SKIP: "modSkip"; + MODERATE_STAFF: "modStaff"; + NOTIFY: "notify"; + PDJ_MESSAGE: "pdjMessage"; + PDJ_UPDATE: "pdjUpdate"; + PING: "ping"; + PLAYLIST_CYCLE: "playlistCycle"; + REQUEST_DURATION: "requestDuration"; + REQUEST_DURATION_RETRY: "requestDurationRetry"; + ROOM_CHANGE: "roomChanged"; + ROOM_DESCRIPTION_UPDATE: "roomDescriptionUpdate"; + ROOM_JOIN: "roomJoin"; + ROOM_NAME_UPDATE: "roomNameUpdate"; + ROOM_VOTE_SKIP: "roomVoteSkip"; + ROOM_WELCOME_UPDATE: "roomWelcomeUpdate"; + SESSION_CLOSE: "sessionClose"; + SKIP: "skip"; + STROBE_TOGGLE: "strobeToggle"; + USER_COUNTER_UPDATE: "userCounterUpdate"; + USER_FOLLOW: "userFollow"; + USER_JOIN: "userJoin"; + USER_LEAVE: "userLeave"; + USER_UPDATE: "userUpdate"; + VOTE: "vote"; + } + } + + export namespace Event { + interface BoothCycle { + moderator: string; + cycle: boolean; + } + + interface BoothLocked { + m: string; + c: boolean; + ml: string; + f: boolean; + } + + interface Chat { + raw: RawChatMessage; + id: string; + from: User.User; + message: string; + mentions: any[]; + muted: boolean; + type: string; + } + + interface ChatDelete { + mi: number; + chatID: string; + } + + type Grab = number; + + interface Advance { + media: Media; + startTime: string; + historyID: string; + djs: User.DJ[]; + currentDJ: User.DJ; + playlistID: number; + lastPlay: LastPlay; + } + + interface DJListUpdate { + djs: User.DJ[]; + remove: string; + } + + interface Emote { + fromID: string; + message: string; + from: string; + type: string; + chatID: string; + } + + interface FollowJoin { + data: FollowJoinData; + type: string; + } + + interface ModAddDJ { + moderator: string; + username: string; + } + + interface ModBan { + moderator: string; + username: string; + duration: number; + ref: string; + reason: string; + } + + interface ModMoveDJ { + moderator: string; + index: number; + old: number; + userID: string; + } + + interface ModRemoveDJ { + moderator: string; + username: string; + userID: string; + } + + interface ModSkip { + mi: number; + m: string; + } + + interface RoomMinChatLevelUpdate { + level: number; + id: number; + user: User.User; + } + + type RoomJoin = string; + + type UserJoin = User.User; + + type UserLeave = User.User; + + interface UserUpdate { + username: string; + status: number; + fans: number; + listenerPoints: number; + dateJoined: string; + language: string; + avatarID: string; + id: string; + curatorPoints: number; + djPoints: number; + } + + interface Vote { + i: number; + v: number; + } + + interface Command extends Event.Chat { + command: string; + args: string[]; + respond: (...args: any[]) => any; + respondTimeout: (...args: any[]) => any; + havePermission: (...args: any[]) => boolean; + isFrom: (...args: any[]) => boolean; + } + } + + export var ROOM_ROLE: Enum.RoomRole; + export var GLOBAL_ROLES: Enum.GlobalRole; + export var STATUS: Enum.Status; + export var BAN: Enum.Ban; + export var BAN_REASON: Enum.BanReason; + export var MUTE: Enum.Mute; + export var MUTE_REASON: Enum.MuteReason; + export var events: Enum.Events; +} + +declare class PlugAPI { + constructor(login: PlugAPI.PlugLogin, callback?: (error: Error, bot: PlugAPI) => void); + constructor(login: PlugAPI.PlugLogin, callback?: (bot: PlugAPI) => void); + deleteAllChat: boolean; + multiLine: boolean; + multiLineLimit: number; + + connect(room: string): void; + changeDJCycle(enabled: boolean, callback?: () => void): boolean; + changeRoom(room: string, callback?: () => void): void; + close(): void; + getAdmins(): PlugAPI.User.Extended[]; + getAmbassadors(): PlugAPI.User.Extended[]; + getAudience(): PlugAPI.User.Audience[]; + getDJ(): PlugAPI.User.DJ; + getDJs(): PlugAPI.User.DJ[]; + getHost(): PlugAPI.User.Extended; + getMedia(): PlugAPI.Media; + getRoomScore(): PlugAPI.Score; + getSelf(): PlugAPI.User.Audience; + getStaff(): PlugAPI.User.Extended[]; + getTimeElapsed(): number; + getTimeRemaining(): number; + getUser(userID: number): PlugAPI.User.DJ; + getUsers(): PlugAPI.User.DJ[]; + getWaitList(): PlugAPI.User.Extended; + getWaitListPosition(userID: number): number; + havePermission(userID: number, permission: number, global?: boolean): boolean; + joinBooth(callback?: () => void): boolean; + leaveBooth(callback?: () => void): boolean; + selfSkip(callback?: () => void): boolean; + sendChat(msg: string, timeout?: number): void; + setLogger(logObject: PlugAPI.LogObject): boolean; + + on(event: "boothCycle", callback: (data: PlugAPI.Event.BoothCycle) => void): void; + on(event: "boothLocked", callback: (data: PlugAPI.Event.BoothLocked) => void): void; + on(event: "chat", callback: (data: PlugAPI.Event.Chat) => void): void; + on(event: "chatDelete", callback: (data: PlugAPI.Event.ChatDelete) => void): void; + on(event: "grab", callback: (data: PlugAPI.Event.Grab) => void): void; + on(event: "advance", callback: (data: PlugAPI.Event.Advance) => void): void; + on(event: "djListUpdate", callback: (data: PlugAPI.Event.DJListUpdate) => void): void; + on(event: "emote", callback: (data: PlugAPI.Event.Emote) => void): void; + on(event: "followJoin", callback: (data: PlugAPI.Event.FollowJoin) => void): void; + on(event: "modAddDJ", callback: (data: PlugAPI.Event.ModAddDJ) => void): void; + on(event: "modBan", callback: (data: PlugAPI.Event.ModBan) => void): void; + on(event: "modMoveDJ", callback: (data: PlugAPI.Event.ModMoveDJ) => void): void; + on(event: "modRemoveDJ", callback: (data: PlugAPI.Event.ModRemoveDJ) => void): void; + on(event: "modSkip", callback: (data: PlugAPI.Event.ModSkip) => void): void; + on(event: "roomMinChatLevelUpdate", callback: (data: PlugAPI.Event.RoomMinChatLevelUpdate) => void): void; + on(event: "roomJoin", callback: (data: PlugAPI.Event.RoomJoin) => void): void; + on(event: "userJoin", callback: (data: PlugAPI.Event.UserJoin) => void): void; + on(event: "userLeave", callback: (data: PlugAPI.Event.UserLeave) => void): void; + on(event: "userUpdate", callback: (data: PlugAPI.Event.UserUpdate) => void): void; + on(event: "vote", callback: (data: PlugAPI.Event.Vote) => void): void; + on(event: "command", callback: (data: PlugAPI.Event.Command) => void): void; + on(event: string, callback: (data: any) => void): void; +} +export = PlugAPI; diff --git a/plugapi/plugapi-tests.ts b/plugapi/plugapi-tests.ts new file mode 100644 index 0000000000..d9a0845997 --- /dev/null +++ b/plugapi/plugapi-tests.ts @@ -0,0 +1,33 @@ +import PlugAPI = require("plugapi"); + +new PlugAPI({ + email: "", + password: "" +}, function (err, bot) { + if (!err) { + const ROOM = "roomslug"; + bot.connect(ROOM); // The part after https://plug.dj + + bot.on(PlugAPI.events.ROOM_JOIN, function (room) { + console.log("Joined " + room); + }); + + bot.on("chat", function (data) { + if (data.type == "emote") { + console.log(data.from + data.message); + } else { + console.log(data.from + "> " + data.message); + } + }); + + bot.on("error", function () { + bot.connect(ROOM); + }); + + bot.deleteAllChat = false; + bot.multiLine = true; + bot.multiLineLimit = 5; + } else { + console.log("Error initializing plugAPI: " + err); + } +}); diff --git a/plugapi/tsconfig.json b/plugapi/tsconfig.json new file mode 100644 index 0000000000..36b84a69c2 --- /dev/null +++ b/plugapi/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", + "plugapi-tests.ts" + ] +} diff --git a/plugapi/tslint.json b/plugapi/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/plugapi/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/query-string/index.d.ts b/query-string/index.d.ts index 2f002c2966..fbd2d3638d 100644 --- a/query-string/index.d.ts +++ b/query-string/index.d.ts @@ -3,28 +3,29 @@ // Definitions by: Sam Verschueren // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - +declare module "query-string" { type value = string | boolean | number; - + interface StringifyOptions { strict?: boolean; encode?: boolean; } -/** - * Parse a query string into an object. - * Leading ? or # are ignored, so you can pass location.search or location.hash directly. - * @param str - */ - export declare function parse(str: string): { [key: string]: string | string[] }; + /** + * Parse a query string into an object. + * Leading ? or # are ignored, so you can pass location.search or location.hash directly. + * @param str + */ + export function parse(str: string): { [key: string]: string | string[] }; -/** - * Stringify an object into a query string, sorting the keys. - * - * @param obj - */ - export declare function stringify(obj: { [key: string]: value | value[] }, options?: StringifyOptions): string; + /** + * Stringify an object into a query string, sorting the keys. + * + * @param obj + */ + export function stringify(obj: { [key: string]: value | value[] }, options?: StringifyOptions): string; -/** - * Extract a query string from a URL that can be passed into .parse(). - * - * @param str - */ -export declare function extract(str: string): string; + /** + * Extract a query string from a URL that can be passed into .parse(). + * + * @param str + */ + export function extract(str: string): string; +} diff --git a/quill/index.d.ts b/quill/index.d.ts index 1a159d4407..cf7440f428 100644 --- a/quill/index.d.ts +++ b/quill/index.d.ts @@ -27,7 +27,7 @@ declare namespace Quill { placeholder?: string, readOnly?: boolean, theme?: string, - formats?: string[] + formats?: string[] } export interface BoundsStatic { diff --git a/qunit/qunit-tests-1.16.ts b/qunit/qunit-tests-1.16.ts index 88734488c6..93081b15f3 100644 --- a/qunit/qunit-tests-1.16.ts +++ b/qunit/qunit-tests-1.16.ts @@ -1,5 +1,3 @@ - - QUnit.test("assert.async() test", function (assert) { var done = assert.async(); var input = []; @@ -1666,4 +1664,4 @@ QUnit.extend(QUnit.assert, { var expected = "String matching /" + regex.toString() + "/"; this.push(success, actual, expected, message); } -}); \ No newline at end of file +}); diff --git a/qunit/qunit-tests.ts b/qunit/qunit-tests.ts index 6a739b8213..f6b645875f 100644 --- a/qunit/qunit-tests.ts +++ b/qunit/qunit-tests.ts @@ -551,4 +551,4 @@ QUnit.module( "module", { }); QUnit.test( "test with beforeEach and afterEach", function( assert ) { assert.expect( 2 ); -}); \ No newline at end of file +}); diff --git a/qunit/tsconfig.json b/qunit/tsconfig.json index 4a3678001b..6bbbd55474 100644 --- a/qunit/tsconfig.json +++ b/qunit/tsconfig.json @@ -16,4 +16,4 @@ "index.d.ts", "qunit-tests.ts" ] -} \ No newline at end of file +} diff --git a/random-seed/index.d.ts b/random-seed/index.d.ts new file mode 100644 index 0000000000..cdd63a140c --- /dev/null +++ b/random-seed/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for random-seed 0.3.0 +// Project: https://github.com/skratchdot/random-seed/ +// Definitions by: Endel Dreyer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface RandomSeed { + range (range: number): number; + random (): number; + floatBetween (min: number, max: number): number; + intBetween (min: number, max: number): number; + + string (count: number): string; + seed (seed: string): void; + + cleanString (inStr: string): string; + hashString (inStr: string): string; + + addEntropy (...args: any[]): void; + initState (): void; + + done (): void; +} + +export function create (seed?: string): RandomSeed; diff --git a/random-seed/random-seed-tests.ts b/random-seed/random-seed-tests.ts new file mode 100644 index 0000000000..9eb399eff5 --- /dev/null +++ b/random-seed/random-seed-tests.ts @@ -0,0 +1,17 @@ +import { RandomSeed, create } from "random-seed"; + +// these generators produce different numbers +let rand1: RandomSeed = create(); // method 1 + +// these generators will produce +// the same sequence of numbers +let seed = 'My Secret String Value'; +let rand2 = create(seed); + +// API +rand1.addEntropy(); +rand1.random(); +rand1.range(100); +rand1.intBetween(0, 10); +rand1.floatBetween(0, 1); +rand1.seed("new seed"); diff --git a/random-seed/tsconfig.json b/random-seed/tsconfig.json new file mode 100644 index 0000000000..19bb011f0d --- /dev/null +++ b/random-seed/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", + "random-seed-tests.ts" + ] +} diff --git a/random-seed/tslint.json b/random-seed/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/random-seed/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/raven-js/ravenjs-tests.ts b/raven-js/ravenjs-tests.ts index d35e89c448..9608e41322 100644 --- a/raven-js/ravenjs-tests.ts +++ b/raven-js/ravenjs-tests.ts @@ -47,6 +47,8 @@ Raven.setUserContext({ Raven.captureMessage('Broken!'); Raven.captureMessage('Broken!', {tags: { key: "value" }}); +Raven.showReportDialog(options); + Raven.setTagsContext({ key: "value" }); Raven.setExtraContext({ foo: "bar" }); diff --git a/react-bootstrap-table/index.d.ts b/react-bootstrap-table/index.d.ts index 8cfa2c2d4b..cc902fe4c2 100644 --- a/react-bootstrap-table/index.d.ts +++ b/react-bootstrap-table/index.d.ts @@ -121,8 +121,8 @@ export interface BootstrapTableProps extends Props { headerStyle?: any; bodyStyle?: any; ignoreSinglePage?: boolean; - } + export type SelectRowMode = 'none' | 'radio' | 'checkbox'; export interface SelectRow { diff --git a/react-native-sortable-list/tsconfig.json b/react-native-sortable-list/tsconfig.json index 1f709abb74..9e533f6495 100644 --- a/react-native-sortable-list/tsconfig.json +++ b/react-native-sortable-list/tsconfig.json @@ -17,4 +17,4 @@ "index.d.ts", "react-native-sortable-list-tests.tsx" ] -} \ No newline at end of file +} diff --git a/redis/index.d.ts b/redis/index.d.ts index f1b4b6e11b..0c2e107646 100644 --- a/redis/index.d.ts +++ b/redis/index.d.ts @@ -385,6 +385,9 @@ export interface RedisClient extends NodeJS.EventEmitter { hscan(args: any[], callback?: ResCallbackT): boolean; zscan(...args: any[]): boolean; zscan(args: any[], callback?: ResCallbackT): boolean; + + // Extras + duplicate(options?:any[], callback?:ResCallbackT): RedisClient; } export interface Multi { diff --git a/redis/redis-tests.ts b/redis/redis-tests.ts index 1002c03031..d98979f256 100644 --- a/redis/redis-tests.ts +++ b/redis/redis-tests.ts @@ -110,4 +110,6 @@ client.multi(commandArr).exec(); client.monitor(resCallback); // Send command -client.send_command(str, args, resCallback); \ No newline at end of file +client.send_command(str, args, resCallback); +// Duplicate +client.duplicate(); \ No newline at end of file diff --git a/redux-actions/index.d.ts b/redux-actions/index.d.ts index 5247e21704..7d4a6ea622 100644 --- a/redux-actions/index.d.ts +++ b/redux-actions/index.d.ts @@ -44,6 +44,11 @@ declare namespace ReduxActions { metaCreator: (...args: any[]) => Meta ): (...args: any[]) => ActionMeta; + export function handleAction( + actionType: { toString: () => string }, + reducer: Reducer | ReducerMap + ): Reducer; + export function handleAction( actionType: { toString(): string }, reducer: Reducer | ReducerMap @@ -54,6 +59,11 @@ declare namespace ReduxActions { reducer: ReducerMeta | ReducerMap ): Reducer; + export function handleActions( + reducerMap: ReducerMap, + initialState?: StateAndPayload + ): Reducer; + export function handleActions( reducerMap: ReducerMap, initialState?: State diff --git a/redux-devtools/index.d.ts b/redux-devtools/index.d.ts index 414e0b6573..5be4b746df 100644 --- a/redux-devtools/index.d.ts +++ b/redux-devtools/index.d.ts @@ -9,7 +9,7 @@ import * as React from 'react'; import { GenericStoreEnhancer } from 'redux'; -interface IDevTools { +export interface IDevTools { new (): JSX.ElementClass; instrument(): GenericStoreEnhancer } diff --git a/request/index.d.ts b/request/index.d.ts index f842e37400..0dff82cfa3 100644 --- a/request/index.d.ts +++ b/request/index.d.ts @@ -84,6 +84,8 @@ declare namespace request { aws?: AWSOptions; hawk?: HawkOptions; qs?: any; + qsStringifyOptions?: any; + qsParseOptions?: any; json?: any; multipart?: RequestPart[] | Multipart; agent?: http.Agent | https.Agent; diff --git a/restangular/index.d.ts b/restangular/index.d.ts index da0bc085de..20a0bff82c 100644 --- a/restangular/index.d.ts +++ b/restangular/index.d.ts @@ -93,6 +93,15 @@ declare namespace restangular { extendModel(route: string, extender: (model: IElement) => any): void; extendCollection(route: string, extender: (collection: ICollection) => any): void; } + + interface IScopedService extends IService { + one(id: number): IElement; + one(id: string): IElement; + post(elementToPost: any, queryParams?: any, headers?: any): IPromise; + post(elementToPost: T, queryParams?: any, headers?: any): IPromise; + getList(queryParams?: any, headers?: any): ICollectionPromise; + getList(queryParams?: any, headers?: any): ICollectionPromise; + } interface IScopedService extends IService { one(id: number): IElement; diff --git a/restify/index.d.ts b/restify/index.d.ts index a1fd5e18d9..2a99479d7c 100644 --- a/restify/index.d.ts +++ b/restify/index.d.ts @@ -468,22 +468,22 @@ interface ClientOptions { } interface Client { - get: (opts: string | { path?: string;[name: string]: any }, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; - head: (opts: string | { path?: string;[name: string]: any }, callback?: (err: any, req: Request, res: Response) => any) => any; - post: (opts: string | { path?: string;[name: string]: any }, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; - put: (opts: string | { path?: string;[name: string]: any }, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; - patch: (opts: string | { path?: string;[name: string]: any }, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; - del: (opts: string | { path?: string;[name: string]: any }, callback?: (err: any, req: Request, res: Response) => any) => any; + get: (opts: string | { path?: string; [name: string]: any }, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; + head: (opts: string | { path?: string; [name: string]: any }, callback?: (err: any, req: Request, res: Response) => any) => any; + post: (opts: string | { path?: string; [name: string]: any }, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; + put: (opts: string | { path?: string; [name: string]: any }, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; + patch: (opts: string | { path?: string; [name: string]: any }, object: any, callback?: (err: any, req: Request, res: Response, obj: any) => any) => any; + del: (opts: string | { path?: string; [name: string]: any }, callback?: (err: any, req: Request, res: Response) => any) => any; basicAuth: (username: string, password: string) => any; } interface HttpClient extends Client { - get: (opts?: string | { path?: string;[name: string]: any }, callback?: Function) => any; - head: (opts?: string | { path?: string;[name: string]: any }, callback?: Function) => any; - post: (opts?: string | { path?: string;[name: string]: any }, callback?: Function) => any; - put: (opts?: string | { path?: string;[name: string]: any }, callback?: Function) => any; - patch: (opts?: string | { path?: string;[name: string]: any }, callback?: Function) => any; - del: (opts?: string | { path?: string;[name: string]: any }, callback?: Function) => any; + get: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any; + head: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any; + post: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any; + put: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any; + patch: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any; + del: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any; } interface ThrottleOptions { diff --git a/rethinkdb/index.d.ts b/rethinkdb/index.d.ts index 1489edc4ec..355e57c94b 100644 --- a/rethinkdb/index.d.ts +++ b/rethinkdb/index.d.ts @@ -1,240 +1,516 @@ -// Type definitions for Rethinkdb 1.10.0 +// Type definitions for RethinkDB 2.3 // Project: http://rethinkdb.com/ -// Definitions by: Sean Hess +// Definitions by: Alex Gorbatchev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Reference: http://www.rethinkdb.com/api/#js -// TODO: Document manipulation and below +// +// Reference: https://rethinkdb.com/api/javascript/ +// +// Notes: +// - Currently missing control structures and geospatial commands. Please help out! +// +// Testing: +// $ tsc --noImplicitAny --module commonjs -p rethinkdb/ -/// +/// -export declare function connect(host: ConnectionOptions, cb?: (err: Error, conn: Connection) => void): Promise; +/** + * https://rethinkdb.com/api/javascript/ + */ +declare module "rethinkdb" { + /** + * Create a new connection to the database server. + * + * See: https://rethinkdb.com/api/javascript/connect/ + */ + export function connect(opts: ConnectionOptions, cb: (err: ReqlDriverError, conn: Connection) => void): void; + export function connect(host: string, cb: (err: ReqlDriverError, conn: Connection) => void): void; + export function connect(opts: ConnectionOptions): Promise; + export function connect(host: string): Promise; -export declare function dbCreate(name: string): Operation; -export declare function dbDrop(name: string): Operation; -export declare function dbList(): Operation; + export function dbCreate(name: string): Operation; + export function dbDrop(name: string): Operation; + export function dbList(): Operation; -export declare function db(name: string): Db; -export declare function table(name: string, options?: { useOutdated: boolean }): Table; + export function db(name: string): Db; + export function table(name: string, options?: { useOutdated: boolean }): Table; -export declare function asc(property: string): Sort; -export declare function desc(property: string): Sort; + export function asc(property: string): Sort; + export function desc(property: string): Sort; -export declare var count: Aggregator; -export declare function sum(prop: string): Aggregator; -export declare function avg(prop: string): Aggregator; + export var count: Aggregator; + export function sum(prop: string): Aggregator; + export function avg(prop: string): Aggregator; -export declare function row(name: string): Expression; -export declare function expr(stuff: any): Expression; + export const row: Row; + export function expr(stuff: any): Expression; -export declare function now(): Time; + export function now(): Expression