From 48521ecfe5bf75d2d084c0c331bb1d1d00b01030 Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Thu, 17 Nov 2016 10:21:48 -0500 Subject: [PATCH 001/181] fetch-merge commit from DT master --- gapi.analytics/gapi.analytics-tests.ts | 132 ++++++------- gapi.analytics/gapi.analytics.d.ts | 252 ++++++++++++------------- matter-js/matter-js.d.ts | 2 +- 3 files changed, 193 insertions(+), 193 deletions(-) diff --git a/gapi.analytics/gapi.analytics-tests.ts b/gapi.analytics/gapi.analytics-tests.ts index a6aea00796..78b30e1745 100644 --- a/gapi.analytics/gapi.analytics-tests.ts +++ b/gapi.analytics/gapi.analytics-tests.ts @@ -1,66 +1,66 @@ -// Type definitions for Google Analytics API - -/// -/// - -function test_namespace() { - var analytics : boolean = gapi.client.analytics instanceof Object; - - var provisioning : boolean = gapi.client.analytics.provisioning.createAccountTicket instanceof Function; - analytics = analytics && provisioning; - - var data : boolean = gapi.client.analytics.data.ga.get instanceof Function; - data = data && gapi.client.analytics.data.mcf.get instanceof Function; - data = data && gapi.client.analytics.data.realtime.get instanceof Function; - analytics = analytics && data; - - interface AnalyticsParameter { - "type" ?: string; - "description" ?: string; - "default" ?: string; - "enum" ?: string[]; - "enumDescriptions" ?: string[]; - "location" ?: string; - } - var kBI : AnalyticsParameter = gapi.client.analytics.kB.parameters.alt; - var kB = !!kBI; - kBI = gapi.client.analytics.kB.parameters.fields; - kB = kB && !!kBI; - kBI = gapi.client.analytics.kB.parameters.key; - kB = kB && !!kBI; - kBI = gapi.client.analytics.kB.parameters.oauth_token; - kB = kB && !!kBI; - kBI = gapi.client.analytics.kB.parameters.prettyPrint; - kB = kB && !!kBI; - kBI = gapi.client.analytics.kB.parameters.quotaUser; - kB = kB && !!kBI; - kBI = gapi.client.analytics.kB.parameters.userIP; - kB = kB && !!kBI; - analytics = analytics && kB; - - var management : boolean = gapi.client.analytics.management.accountSummaries.list instanceof Function; - management = management && gapi.client.analytics.management.accountUserLinks.list instanceof Function; - management = management && gapi.client.analytics.management.accounts.list instanceof Function; - management = management && gapi.client.analytics.management.customDataSources.list instanceof Function; - management = management && gapi.client.analytics.management.customDimensions.list instanceof Function; - management = management && gapi.client.analytics.management.customMetrics.list instanceof Function; - management = management && gapi.client.analytics.management.experiments.list instanceof Function; - management = management && gapi.client.analytics.management.filters.list instanceof Function; - management = management && gapi.client.analytics.management.goals.list instanceof Function; - management = management && gapi.client.analytics.management.profileFilterLinks.list instanceof Function; - management = management && gapi.client.analytics.management.profileUserLinks.list instanceof Function; - management = management && gapi.client.analytics.management.profiles.list instanceof Function; - management = management && gapi.client.analytics.management.remarketingAudience.list instanceof Function; - management = management && gapi.client.analytics.management.segments.list instanceof Function; - management = management && gapi.client.analytics.management.unsampledReports.list instanceof Function; - management = management && gapi.client.analytics.management.uploads.list instanceof Function; - management = management && gapi.client.analytics.management.webPropertyAdWordsLinks.list instanceof Function; - management = management && gapi.client.analytics.management.webproperties.list instanceof Function; - management = management && gapi.client.analytics.management.webpropertyUserLinks.list instanceof Function; - analytics = analytics && management; - - var metadata : boolean = gapi.client.analytics.metadata.column.list instanceof Function; - analytics = analytics && metadata; - - return analytics; -} +// Type definitions for Google Analytics API + +/// +/// + +function test_namespace() { + var analytics : boolean = gapi.client.analytics instanceof Object; + + var provisioning : boolean = gapi.client.analytics.provisioning.createAccountTicket instanceof Function; + analytics = analytics && provisioning; + + var data : boolean = gapi.client.analytics.data.ga.get instanceof Function; + data = data && gapi.client.analytics.data.mcf.get instanceof Function; + data = data && gapi.client.analytics.data.realtime.get instanceof Function; + analytics = analytics && data; + + interface AnalyticsParameter { + "type" ?: string; + "description" ?: string; + "default" ?: string; + "enum" ?: string[]; + "enumDescriptions" ?: string[]; + "location" ?: string; + } + var kBI : AnalyticsParameter = gapi.client.analytics.kB.parameters.alt; + var kB = !!kBI; + kBI = gapi.client.analytics.kB.parameters.fields; + kB = kB && !!kBI; + kBI = gapi.client.analytics.kB.parameters.key; + kB = kB && !!kBI; + kBI = gapi.client.analytics.kB.parameters.oauth_token; + kB = kB && !!kBI; + kBI = gapi.client.analytics.kB.parameters.prettyPrint; + kB = kB && !!kBI; + kBI = gapi.client.analytics.kB.parameters.quotaUser; + kB = kB && !!kBI; + kBI = gapi.client.analytics.kB.parameters.userIP; + kB = kB && !!kBI; + analytics = analytics && kB; + + var management : boolean = gapi.client.analytics.management.accountSummaries.list instanceof Function; + management = management && gapi.client.analytics.management.accountUserLinks.list instanceof Function; + management = management && gapi.client.analytics.management.accounts.list instanceof Function; + management = management && gapi.client.analytics.management.customDataSources.list instanceof Function; + management = management && gapi.client.analytics.management.customDimensions.list instanceof Function; + management = management && gapi.client.analytics.management.customMetrics.list instanceof Function; + management = management && gapi.client.analytics.management.experiments.list instanceof Function; + management = management && gapi.client.analytics.management.filters.list instanceof Function; + management = management && gapi.client.analytics.management.goals.list instanceof Function; + management = management && gapi.client.analytics.management.profileFilterLinks.list instanceof Function; + management = management && gapi.client.analytics.management.profileUserLinks.list instanceof Function; + management = management && gapi.client.analytics.management.profiles.list instanceof Function; + management = management && gapi.client.analytics.management.remarketingAudience.list instanceof Function; + management = management && gapi.client.analytics.management.segments.list instanceof Function; + management = management && gapi.client.analytics.management.unsampledReports.list instanceof Function; + management = management && gapi.client.analytics.management.uploads.list instanceof Function; + management = management && gapi.client.analytics.management.webPropertyAdWordsLinks.list instanceof Function; + management = management && gapi.client.analytics.management.webproperties.list instanceof Function; + management = management && gapi.client.analytics.management.webpropertyUserLinks.list instanceof Function; + analytics = analytics && management; + + var metadata : boolean = gapi.client.analytics.metadata.column.list instanceof Function; + analytics = analytics && metadata; + + return analytics; +} diff --git a/gapi.analytics/gapi.analytics.d.ts b/gapi.analytics/gapi.analytics.d.ts index dc49ffd617..34027c9d47 100644 --- a/gapi.analytics/gapi.analytics.d.ts +++ b/gapi.analytics/gapi.analytics.d.ts @@ -1,126 +1,126 @@ -// Type definitions for Google Analytics API -// Project: https://developers.google.com/analytics/devguides/reporting/core/v4/ -// Definitions by: César Costas -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace gapi.client.analytics {} -declare namespace gapi.client.analytics.provisioning { - export function createAccountTicket() : Promise; -} - -interface DataQuery { - "ids" ?: string; - "start-date" ?: string; - "30daysAgo" ?: string; - "end-date" ?: string; - "yesterday" ?: string; - "metrics" ?: string; - "dimensions" ?: string; - "sort" ?: string; - "filters" ?: string; - "segment" ?: string; - "samplingLevel" ?: string; - "include-empty-rows" ?: string; - "start-index" ?: string; - "max-results" ?: string; -} -declare namespace gapi.client.analytics.data {} -declare namespace gapi.client.analytics.data.ga { - export function get(data ?: DataQuery) : Promise; -} -declare namespace gapi.client.analytics.data.mcf { - export function get(data ?: DataQuery) : Promise; -} -declare namespace gapi.client.analytics.data.realtime { - export function get(data ?: DataQuery) : Promise; -} - -declare namespace gapi.client.analytics.kB {} -declare namespace gapi.client.analytics.kB.parameters { - export interface AnalyticsParameter { - "type" ?: string; - "description" ?: string; - "default" ?: string; - "enum" ?: string[]; - "enumDescriptions" ?: string[]; - "location" ?: string; - } - export class alt implements AnalyticsParameter {} - export class fields implements AnalyticsParameter {} - export class key implements AnalyticsParameter {} - export class oauth_token implements AnalyticsParameter {} - export class prettyPrint implements AnalyticsParameter {} - export class quotaUser implements AnalyticsParameter {} - export class userIP implements AnalyticsParameter {} -} - -interface View { - accountId ?: string; - webPropertyId ?: string; - webViewId ?: string; -} -declare namespace gapi.client.analytics.management {} -declare namespace gapi.client.analytics.management.accountSummaries { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.accountUserLinks { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.accounts { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.customDataSources { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.customDimensions { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.customMetrics { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.experiments { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.filters { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.goals { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.profileFilterLinks { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.profileUserLinks { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.profiles { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.remarketingAudience { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.segments { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.unsampledReports { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.uploads { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.webPropertyAdWordsLinks { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.webproperties { - export function list(view ?: View) : Promise; -} -declare namespace gapi.client.analytics.management.webpropertyUserLinks { - export function list(view ?: View) : Promise; -} - -declare namespace gapi.client.analytics.metadata {} -declare namespace gapi.client.analytics.metadata.column { - export function list() : Promise; -} +// Type definitions for Google Analytics API +// Project: https://developers.google.com/analytics/devguides/reporting/core/v4/ +// Definitions by: César Costas +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace gapi.client.analytics {} +declare namespace gapi.client.analytics.provisioning { + export function createAccountTicket() : Promise; +} + +interface DataQuery { + "ids" ?: string; + "start-date" ?: string; + "30daysAgo" ?: string; + "end-date" ?: string; + "yesterday" ?: string; + "metrics" ?: string; + "dimensions" ?: string; + "sort" ?: string; + "filters" ?: string; + "segment" ?: string; + "samplingLevel" ?: string; + "include-empty-rows" ?: string; + "start-index" ?: string; + "max-results" ?: string; +} +declare namespace gapi.client.analytics.data {} +declare namespace gapi.client.analytics.data.ga { + export function get(data ?: DataQuery) : Promise; +} +declare namespace gapi.client.analytics.data.mcf { + export function get(data ?: DataQuery) : Promise; +} +declare namespace gapi.client.analytics.data.realtime { + export function get(data ?: DataQuery) : Promise; +} + +declare namespace gapi.client.analytics.kB {} +declare namespace gapi.client.analytics.kB.parameters { + export interface AnalyticsParameter { + "type" ?: string; + "description" ?: string; + "default" ?: string; + "enum" ?: string[]; + "enumDescriptions" ?: string[]; + "location" ?: string; + } + export class alt implements AnalyticsParameter {} + export class fields implements AnalyticsParameter {} + export class key implements AnalyticsParameter {} + export class oauth_token implements AnalyticsParameter {} + export class prettyPrint implements AnalyticsParameter {} + export class quotaUser implements AnalyticsParameter {} + export class userIP implements AnalyticsParameter {} +} + +interface View { + accountId ?: string; + webPropertyId ?: string; + webViewId ?: string; +} +declare namespace gapi.client.analytics.management {} +declare namespace gapi.client.analytics.management.accountSummaries { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.accountUserLinks { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.accounts { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.customDataSources { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.customDimensions { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.customMetrics { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.experiments { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.filters { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.goals { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.profileFilterLinks { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.profileUserLinks { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.profiles { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.remarketingAudience { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.segments { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.unsampledReports { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.uploads { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.webPropertyAdWordsLinks { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.webproperties { + export function list(view ?: View) : Promise; +} +declare namespace gapi.client.analytics.management.webpropertyUserLinks { + export function list(view ?: View) : Promise; +} + +declare namespace gapi.client.analytics.metadata {} +declare namespace gapi.client.analytics.metadata.column { + export function list() : Promise; +} diff --git a/matter-js/matter-js.d.ts b/matter-js/matter-js.d.ts index cc887673ee..f21ad2ef7b 100644 --- a/matter-js/matter-js.d.ts +++ b/matter-js/matter-js.d.ts @@ -2129,7 +2129,7 @@ declare namespace Matter { * @param {engine} engine * @param {} options * @return {MouseConstraint} A new MouseConstraint - */ + */ static create(engine: Engine, options?: IMouseConstraintDefinition): MouseConstraint; /** From 2e1a28de3d571ba809cd03686544aec739f48bf6 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Thu, 1 Dec 2016 08:07:00 +0100 Subject: [PATCH 002/181] Added http-link-header --- http-link-header/http-link-header-tests.ts | 28 ++++++++++++++++++++++ http-link-header/index.d.ts | 19 +++++++++++++++ http-link-header/tsconfig.json | 19 +++++++++++++++ http-link-header/tslint.json | 1 + 4 files changed, 67 insertions(+) create mode 100644 http-link-header/http-link-header-tests.ts create mode 100644 http-link-header/index.d.ts create mode 100644 http-link-header/tsconfig.json create mode 100644 http-link-header/tslint.json diff --git a/http-link-header/http-link-header-tests.ts b/http-link-header/http-link-header-tests.ts new file mode 100644 index 0000000000..85145dc8eb --- /dev/null +++ b/http-link-header/http-link-header-tests.ts @@ -0,0 +1,28 @@ +import * as LinkHeader from 'http-link-header'; + +function isBool(bool: boolean): null { + return null; +} + +function isReference(ref: LinkHeader.Reference): null { + return null; +} + +function isString(str: string): null { + return null; +} + +const link = LinkHeader.parse( + '; rel="example"; title="Example Website", ' + + '; rel="alternate"; title="Alternate Example Domain"' +); +const has = link.has('rel', 'alternate'); +isBool(has); +const get = link.get('title', 'Example Website'); +isReference(get); +const rel = link.rel('alternate'); +isReference(rel); +const set = link.set({ rel: 'next', uri: 'http://example.com/next' }); +isReference(set); +const str = link.toString(); +isString(str); diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts new file mode 100644 index 0000000000..f72a1fe065 --- /dev/null +++ b/http-link-header/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for http-link-header v0.6.0 +// Project: https://github.com/jhermsmeier/node-http-link-header +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Reference { + uri: string; + rel: string; + title?: string; +} +export interface Link { + refs: Array; + has: (attribute: string, value: string) => boolean; + get: (attribute: string, value: string) => Reference; + rel: (value: string) => Reference; + set: (ref: Reference) => Reference; + toString: () => string; +} +export function parse(header: string): Link; diff --git a/http-link-header/tsconfig.json b/http-link-header/tsconfig.json new file mode 100644 index 0000000000..12f90f78bd --- /dev/null +++ b/http-link-header/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", + "http-link-header-tests.ts" + ] +} diff --git a/http-link-header/tslint.json b/http-link-header/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/http-link-header/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 0419f39e859a707e16ecd13ecedbbb76825c5142 Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 17:19:52 +0100 Subject: [PATCH 003/181] Add memoizee definitions --- memoizee/index.d.ts | 31 ++++++++++++++++++++ memoizee/memoizee-tests.ts | 60 ++++++++++++++++++++++++++++++++++++++ memoizee/tsconfig.json | 19 ++++++++++++ memoizee/tslint.json | 1 + 4 files changed, 111 insertions(+) create mode 100644 memoizee/index.d.ts create mode 100644 memoizee/memoizee-tests.ts create mode 100644 memoizee/tsconfig.json create mode 100644 memoizee/tslint.json diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts new file mode 100644 index 0000000000..007bbc7d27 --- /dev/null +++ b/memoizee/index.d.ts @@ -0,0 +1,31 @@ + +// Type definitions for memoizee 0.4.1 +// Project: https://github.com/medikoo/memoizee +// Definitions by: Juan Picado +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface RevolversArray { + [index:number]:Object +} + +interface MemoizeeOptions { + length?: number, + maxAge?: number, + max?: number, + preFetch?: number, + promise?: boolean, + dispose?: Function, + async?: boolean, + primitive?: boolean, + normalizer?:Function, + resolvers?: RevolversArray +} + +interface IMemoizee extends Function { + delete: Function, + clear: Function +} + +declare function memoizee(f: any, options?:MemoizeeOptions): IMemoizee; + +export = memoizee; diff --git a/memoizee/memoizee-tests.ts b/memoizee/memoizee-tests.ts new file mode 100644 index 0000000000..138a605712 --- /dev/null +++ b/memoizee/memoizee-tests.ts @@ -0,0 +1,60 @@ +import memoize = require('memoizee'); + +var fn = function (one:any, two:any, three:any) { /* ... */ }; + +let memoized = memoize(fn); +memoized('foo', 3, 'bar'); +memoized('foo', 3, 'bar'); +memoized = memoize(fn, { length: 2 }); +memoized('foo'); +memoized('foo', undefined); +memoized('foo', 3, {}); +memoized('foo', 3, 13); +memoized('foo', undefined); +memoized('foo', undefined); +memoized('foo', 3, {}); +memoized('foo', 3, 13); +memoized('foo', 3, 13); +memoized = memoize(fn, { primitive: true }); +memoized('/path/one'); +memoized('/path/one'); +memoized = memoize(fn, { dispose: function (value:number) { /*…*/ } }); +var foo3 = memoized('foo', 3); +var bar7 = memoized('bar', 7); +memoized.clear('foo', 3); // Dispose called with foo3 value +memoized.clear('bar', 7); // Dispose called with bar7 value +memoized.delete('foo', true); +var mFn = memoize(function (hash:any) { + // body of memoized function +}, { normalizer: function (args:any) { + // args is arguments object as accessible in memoized function + return JSON.stringify(args[0]); +} }); + +mFn({ foo: 'bar' }); + +memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] }); +memoized(12, [1,2,3].length); +memoized("12", true); +memoized({ toString: function () { return "12"; } }, {}); + +var afn = function (a:number, b:number) { + return new Promise(function (res) { res(a + b); }); +}; +memoized = memoize(afn, { promise: true }); + +memoized(3, 7); +memoized(3, 7); + +memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 }); + +memoized('foo', 3); +memoized('foo', 3); + +setTimeout(function () { + memoized('foo', 3); +}, 500); + +setTimeout(function () { + memoized('foo', 3); +}, 1300); diff --git a/memoizee/tsconfig.json b/memoizee/tsconfig.json new file mode 100644 index 0000000000..e2f4dc61cb --- /dev/null +++ b/memoizee/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", + "memoizee-tests.ts" + ] +} \ No newline at end of file diff --git a/memoizee/tslint.json b/memoizee/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/memoizee/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 125fee99068e49e0e7ba72222ace7f7abafa612e Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 18:45:49 +0100 Subject: [PATCH 004/181] Fix common issues, added doc --- memoizee/index.d.ts | 31 +++++++++++++++++++++++++------ memoizee/tsconfig.json | 4 ++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index 007bbc7d27..db0eb4e84f 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -4,28 +4,47 @@ // Definitions by: Juan Picado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/** + * Resolver options + * @interface RevolversArray + */ interface RevolversArray { [index:number]:Object } -interface MemoizeeOptions { +/** + * List of options + * @interface IMemoizeeOptions + */ +interface IMemoizeeOptions { length?: number, maxAge?: number, max?: number, preFetch?: number, promise?: boolean, - dispose?: Function, + dispose?: () => void, async?: boolean, primitive?: boolean, - normalizer?:Function, + normalizer?:() => void, resolvers?: RevolversArray } +/** + * Main interface functions + * @interface IMemoizee + * @extends {Function} + */ interface IMemoizee extends Function { - delete: Function, - clear: Function + delete: () => void, + clear: () => void } -declare function memoizee(f: any, options?:MemoizeeOptions): IMemoizee; +/** + * Memoize function + * @param {*} f + * @param {IMemoizeeOptions} [options] + * @returns {IMemoizee} + */ +declare function memoizee(f: any, options?: IMemoizeeOptions): IMemoizee; export = memoizee; diff --git a/memoizee/tsconfig.json b/memoizee/tsconfig.json index e2f4dc61cb..68b204fbd9 100644 --- a/memoizee/tsconfig.json +++ b/memoizee/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -16,4 +16,4 @@ "index.d.ts", "memoizee-tests.ts" ] -} \ No newline at end of file +} From fa5e2817687917261672de48eaf23b4c62830568 Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 19:08:59 +0100 Subject: [PATCH 005/181] Removed blank line --- memoizee/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index db0eb4e84f..6cefaf39d5 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -1,4 +1,3 @@ - // Type definitions for memoizee 0.4.1 // Project: https://github.com/medikoo/memoizee // Definitions by: Juan Picado From 05272150f091ce3a75b73259eadbd7fafb63b53e Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 19:51:04 +0100 Subject: [PATCH 006/181] fix test --- memoizee/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index 6cefaf39d5..5d6fc049ad 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -21,10 +21,10 @@ interface IMemoizeeOptions { max?: number, preFetch?: number, promise?: boolean, - dispose?: () => void, + dispose?: ()=> void, async?: boolean, primitive?: boolean, - normalizer?:() => void, + normalizer?:()=> void, resolvers?: RevolversArray } @@ -44,6 +44,6 @@ interface IMemoizee extends Function { * @param {IMemoizeeOptions} [options] * @returns {IMemoizee} */ -declare function memoizee(f: any, options?: IMemoizeeOptions): IMemoizee; +declare function memoizee(f: () => void, options?: IMemoizeeOptions): IMemoizee; export = memoizee; From 42ffcea96b84be8a230ea14bc03a272d9c63686c Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 21:03:41 +0100 Subject: [PATCH 007/181] Fix test methods --- memoizee/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index 5d6fc049ad..be984e3575 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -21,10 +21,10 @@ interface IMemoizeeOptions { max?: number, preFetch?: number, promise?: boolean, - dispose?: ()=> void, + dispose?: (value: any) => void, async?: boolean, primitive?: boolean, - normalizer?:()=> void, + normalizer?:(value:any ) => void, resolvers?: RevolversArray } @@ -34,8 +34,8 @@ interface IMemoizeeOptions { * @extends {Function} */ interface IMemoizee extends Function { - delete: () => void, - clear: () => void + delete: (...params: any[]) => void, + clear: (...params: any[]) => void } /** @@ -44,6 +44,6 @@ interface IMemoizee extends Function { * @param {IMemoizeeOptions} [options] * @returns {IMemoizee} */ -declare function memoizee(f: () => void, options?: IMemoizeeOptions): IMemoizee; +declare function memoizee(f: Function, options?: IMemoizeeOptions): IMemoizee; export = memoizee; From 7808c389685e0a06870095c233d786bbfcc7fceb Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 21:10:22 +0100 Subject: [PATCH 008/181] Fix check style --- memoizee/index.d.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index be984e3575..5de5fb9a2d 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -8,7 +8,7 @@ * @interface RevolversArray */ interface RevolversArray { - [index:number]:Object + [index:number]: {}; } /** @@ -16,16 +16,16 @@ interface RevolversArray { * @interface IMemoizeeOptions */ interface IMemoizeeOptions { - length?: number, - maxAge?: number, - max?: number, - preFetch?: number, - promise?: boolean, - dispose?: (value: any) => void, - async?: boolean, - primitive?: boolean, - normalizer?:(value:any ) => void, - resolvers?: RevolversArray + length?: number; + maxAge?: number; + max?: number; + preFetch?: number; + promise?: boolean; + dispose?: (value: any) => void; + async?: boolean; + primitive?: boolean; + normalizer?: (value:any ) => void; + resolvers?: RevolversArray; } /** @@ -34,8 +34,8 @@ interface IMemoizeeOptions { * @extends {Function} */ interface IMemoizee extends Function { - delete: (...params: any[]) => void, - clear: (...params: any[]) => void + delete: (...params: any[]) => void; + clear: (...params: any[]) => void; } /** @@ -44,6 +44,6 @@ interface IMemoizee extends Function { * @param {IMemoizeeOptions} [options] * @returns {IMemoizee} */ -declare function memoizee(f: Function, options?: IMemoizeeOptions): IMemoizee; +declare function memoizee(f: (...params: any[])=>void, options?: IMemoizeeOptions): IMemoizee; export = memoizee; From fbb5f29d19c564346f01b8c7b3139c354f136184 Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 21:15:20 +0100 Subject: [PATCH 009/181] Fix check style --- memoizee/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index 5de5fb9a2d..8f943c4167 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -8,7 +8,7 @@ * @interface RevolversArray */ interface RevolversArray { - [index:number]: {}; + [index: number]: {}; } /** @@ -24,7 +24,7 @@ interface IMemoizeeOptions { dispose?: (value: any) => void; async?: boolean; primitive?: boolean; - normalizer?: (value:any ) => void; + normalizer?: (value: any ) => void; resolvers?: RevolversArray; } @@ -44,6 +44,6 @@ interface IMemoizee extends Function { * @param {IMemoizeeOptions} [options] * @returns {IMemoizee} */ -declare function memoizee(f: (...params: any[])=>void, options?: IMemoizeeOptions): IMemoizee; +declare function memoizee(f: (...params: any[]) => void, options?: IMemoizeeOptions): IMemoizee; export = memoizee; From 8070c5a1fcb555b7372911b152ada272590cde44 Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 21:26:41 +0100 Subject: [PATCH 010/181] Fixing semver header --- memoizee/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index 8f943c4167..aba59ed744 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for memoizee 0.4.1 +// Type definitions for memoizee v0.4.1 // Project: https://github.com/medikoo/memoizee // Definitions by: Juan Picado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 8825deefbc83b48fb75649dc8b988e21d18d7f62 Mon Sep 17 00:00:00 2001 From: Juan Carlos Picado Date: Sun, 4 Dec 2016 21:37:20 +0100 Subject: [PATCH 011/181] Fixing semver header --- memoizee/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index aba59ed744..125b34f264 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for memoizee v0.4.1 +// Type definitions for memoizee 0.4 // Project: https://github.com/medikoo/memoizee // Definitions by: Juan Picado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 142daba378bca250818450d967265661c79550b1 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Mon, 5 Dec 2016 12:03:53 +0100 Subject: [PATCH 012/181] Fixed Travis build --- http-link-header/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index f72a1fe065..cb3205c81a 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -9,7 +9,7 @@ export interface Reference { title?: string; } export interface Link { - refs: Array; + refs: Reference[]; has: (attribute: string, value: string) => boolean; get: (attribute: string, value: string) => Reference; rel: (value: string) => Reference; From ef08762ba252e4ac9088ebba22c04a8d4548189b Mon Sep 17 00:00:00 2001 From: Stephan Troyer Date: Wed, 7 Dec 2016 21:01:14 +0100 Subject: [PATCH 013/181] Added export, tests to chart.js fixes #12525 --- chart.js/chart.js-tests.ts | 26 ++++++++++++ chart.js/index.d.ts | 82 +++++++++++++++++++------------------- chart.js/tsconfig.json | 3 +- 3 files changed, 69 insertions(+), 42 deletions(-) create mode 100644 chart.js/chart.js-tests.ts diff --git a/chart.js/chart.js-tests.ts b/chart.js/chart.js-tests.ts new file mode 100644 index 0000000000..2b38efaa25 --- /dev/null +++ b/chart.js/chart.js-tests.ts @@ -0,0 +1,26 @@ +import { Chart, LinearChartData } from 'chart.js'; + +//alternative: +//import chartjs = require('chart.js'); +// => chartjs.Chart + +var chart = new Chart(new CanvasRenderingContext2D(), { + type: 'bar', + data: { + labels: ['group 1'], + datasets: [ + { + label: 'test', + data: [1] + } + ] + }, + options: { + scales: { + xAxes: [{ + gridLines: { display: false } + }] + } + } +}); +chart.update(); diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index e9186035c7..609fbeb338 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -3,15 +3,15 @@ // Definitions by: Alberto Nuti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare enum ChartType { +export enum ChartType { line, bar, radar, doughnut, polarArea, bubble } -declare enum TimeUnit { +export enum TimeUnit { millisecond, second, minute, hour, day, week, month, quarter, year } -interface ChartLegendItem { +export interface ChartLegendItem { text?: string; fillStyle?: string; hidden?: boolean; @@ -22,13 +22,13 @@ interface ChartLegendItem { lineWidth?: number; strokeStyle?: string; } -interface ChartTooltipItem { +export interface ChartTooltipItem { xLabel?: string; yLabel?: string; datasetIndex?: number; index?: number; } -interface ChartTooltipCallback { +export interface ChartTooltipCallback { beforeTitle?: (item?: ChartTooltipItem[], data?: any) => void; title?: (item?: ChartTooltipItem[], data?: any) => void; afterTitle?: (item?: ChartTooltipItem[], data?: any) => void; @@ -41,31 +41,31 @@ interface ChartTooltipCallback { footer?: (item?: ChartTooltipItem[], data?: any) => void; afterfooter?: (item?: ChartTooltipItem[], data?: any) => void; } -interface ChartAnimationParameter { +export interface ChartAnimationParameter { chartInstance?: any; animationObject?: any; } -interface ChartPoint { +export interface ChartPoint { x?: number; y?: number; } -interface ChartConfiguration { +export interface ChartConfiguration { type?: string; data?: ChartData; options?: ChartOptions; } -interface ChartData { +export interface ChartData { } -interface LinearChartData extends ChartData { +export interface LinearChartData extends ChartData { labels?: string[]; datasets?: ChartDataSets[]; } -interface ChartOptions { +export interface ChartOptions { responsive?: boolean; responsiveAnimationDuration?: number; maintainAspectRatio?: boolean; @@ -80,14 +80,14 @@ interface ChartOptions { scales?: ChartScales; } -interface ChartFontOptions { +export interface ChartFontOptions { defaultFontColor?: ChartColor; defaultFontFamily?: string; defaultFontSize?: number; defaultFontStyle?: string; } -interface ChartTitleOptions { +export interface ChartTitleOptions { display?: boolean; position?: string; fullWdith?: boolean; @@ -99,7 +99,7 @@ interface ChartTitleOptions { text?: string; } -interface ChartLegendOptions { +export interface ChartLegendOptions { display?: boolean; position?: string; fullWidth?: boolean; @@ -107,7 +107,7 @@ interface ChartLegendOptions { labels?: ChartLegendLabelOptions; } -interface ChartLegendLabelOptions { +export interface ChartLegendLabelOptions { boxWidth?: number; fontSize?: number; fontStyle?: number; @@ -117,7 +117,7 @@ interface ChartLegendLabelOptions { generateLabels?: (chart: any) => any; } -interface ChartTooltipOptions { +export interface ChartTooltipOptions { enabled?: boolean; custom?: (a: any) => void; mode?: string; @@ -147,13 +147,13 @@ interface ChartTooltipOptions { callbacks?: ChartTooltipCallback; } -interface ChartHoverOptions { +export interface ChartHoverOptions { mode?: string; animationDuration?: number; onHover?: (active: any) => void; } -interface ChartAnimationObject { +export interface ChartAnimationObject { currentStep?: number; numSteps?: number; easing?: string; @@ -162,27 +162,27 @@ interface ChartAnimationObject { onAnimationComplete?: (arg: any) => void; } -interface ChartAnimationOptions { +export interface ChartAnimationOptions { duration?: number; easing?: string; onProgress?: (chart: any) => void; onComplete?: (chart: any) => void; } -interface ChartElementsOptions { +export interface ChartElementsOptions { point?: ChartPointOptions; line?: ChartLineOptions; arg?: ChartArcOtpions; rectangle?: ChartRectangleOptions; } -interface ChartArcOtpions { +export interface ChartArcOtpions { backgroundColor?: ChartColor; borderColor?: ChartColor; borderWidth?: number; } -interface ChartLineOptions { +export interface ChartLineOptions { tension?: number; backgroundColor?: ChartColor; borderWidth?: number; @@ -193,7 +193,7 @@ interface ChartLineOptions { borderJoinStyle?: string; } -interface ChartPointOptions { +export interface ChartPointOptions { radius?: number; pointStyle?: string; backgroundColor?: ChartColor; @@ -204,13 +204,13 @@ interface ChartPointOptions { hoverBorderWidth?: number; } -interface ChartRectangleOptions { +export interface ChartRectangleOptions { backgroundColor?: ChartColor; borderWidth?: number; borderColor?: ChartColor; borderSkipped?: string; } -interface GridLineOptions { +export interface GridLineOptions { display?: boolean; color?: ChartColor; lineWidth?: number; @@ -223,7 +223,7 @@ interface GridLineOptions { offsetGridLines?: boolean; } -interface ScaleTitleOptions { +export interface ScaleTitleOptions { display?: boolean; labelString?: string; fontColor?: ChartColor; @@ -232,7 +232,7 @@ interface ScaleTitleOptions { fontStyle?: string; } -interface TickOptions { +export interface TickOptions { autoSkip?: boolean; callback?: (value: any, index: any, values: any) => string; display?: boolean; @@ -249,13 +249,13 @@ interface TickOptions { min?: any; max?: any; } -interface AngleLineOptions { +export interface AngleLineOptions { display?: boolean; color?: ChartColor; lineWidth?: number; } -interface PointLabelOptions { +export interface PointLabelOptions { callback?: (arg: any) => any; fontColor?: ChartColor; fontFamily?: string; @@ -263,14 +263,14 @@ interface PointLabelOptions { fontStyle?: string; } -interface TickOptions { +export interface TickOptions { backdropColor?: ChartColor; backdropPaddingX?: number; backdropPaddingY?: number; maxTicksLimit?: number; showLabelBackdrop?: boolean; } -interface LinearTickOptions extends TickOptions { +export interface LinearTickOptions extends TickOptions { beginAtZero?: boolean; min?: number; max?: number; @@ -280,14 +280,14 @@ interface LinearTickOptions extends TickOptions { suggestedMax?: number; } -interface LogarithmicTickOptions extends TickOptions { +export interface LogarithmicTickOptions extends TickOptions { min?: number; max?: number; } type ChartColor = string | CanvasGradient | CanvasPattern; -interface ChartDataSets { +export interface ChartDataSets { backgroundColor?: ChartColor; borderWidth?: number; borderColor?: ChartColor; @@ -313,7 +313,7 @@ interface ChartDataSets { yAxisID?: string; } -interface ChartScales { +export interface ChartScales { type?: string; display?: boolean; position?: string; @@ -338,7 +338,7 @@ interface ChartScales { yAxes?: ChartYAxe[]; } -interface ChartXAxe { +export interface ChartXAxe { type?: string; display?: boolean; id?: string; @@ -353,7 +353,7 @@ interface ChartXAxe { scaleLabel?: ScaleTitleOptions; } -interface ChartYAxe { +export interface ChartYAxe { type?: string; display?: boolean; id?: string; @@ -363,15 +363,15 @@ interface ChartYAxe { scaleLabel?: ScaleTitleOptions; } -interface LinearScale extends ChartScales { +export interface LinearScale extends ChartScales { ticks?: LinearTickOptions; } -interface LogarithmicScale extends ChartScales { +export interface LogarithmicScale extends ChartScales { ticks?: LogarithmicTickOptions; } -interface TimeScale extends ChartScales { +export interface TimeScale extends ChartScales { format?: string; displayFormats?: string; isoWeekday?: boolean; @@ -384,14 +384,14 @@ interface TimeScale extends ChartScales { unitStepSize?: number; } -interface RadialLinearScale { +export interface RadialLinearScale { lineArc?: boolean; angleLines?: AngleLineOptions; pointLabels?: PointLabelOptions; ticks?: TickOptions; } -declare class Chart { +export class Chart { constructor (context: CanvasRenderingContext2D | HTMLCanvasElement, options: ChartConfiguration); config: ChartConfiguration; destroy: () => {}; diff --git a/chart.js/tsconfig.json b/chart.js/tsconfig.json index 79b9eb6b27..684beee72d 100644 --- a/chart.js/tsconfig.json +++ b/chart.js/tsconfig.json @@ -13,6 +13,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "chart.js-tests.ts" ] } \ No newline at end of file From 6f5fed8bf3deba960e7d003d33bb5f2bf76932ea Mon Sep 17 00:00:00 2001 From: Stephan Troyer Date: Thu, 8 Dec 2016 00:14:19 +0100 Subject: [PATCH 014/181] adding export as namespace --- chart.js/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 609fbeb338..62dc61426b 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -410,3 +410,5 @@ export class Chart { global: ChartOptions; } } + +export as namespace Chart; \ No newline at end of file From 3215c7f6964f7a9898020c25e625b1f37d9675ea Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 12 Dec 2016 12:19:00 +0100 Subject: [PATCH 015/181] Changed ChartType, TimeUnit, ScaleType, corrected TimeScale.displayFormats --- chart.js/index.d.ts | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 62dc61426b..413887601b 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -3,14 +3,12 @@ // Definitions by: Alberto Nuti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export enum ChartType { - line, bar, radar, doughnut, polarArea, bubble -} -export enum TimeUnit { - millisecond, second, minute, - hour, day, week, - month, quarter, year -} +export declare type ChartType = 'line' | 'bar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble'; + +export declare type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; + +export declare type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear'; + export interface ChartLegendItem { text?: string; fillStyle?: string; @@ -51,7 +49,7 @@ export interface ChartPoint { } export interface ChartConfiguration { - type?: string; + type?: ChartType | string; data?: ChartData; options?: ChartOptions; } @@ -314,7 +312,7 @@ export interface ChartDataSets { } export interface ChartScales { - type?: string; + type?: ScaleType | string; display?: boolean; position?: string; beforeUpdate?: (scale?: any) => void; @@ -339,7 +337,7 @@ export interface ChartScales { } export interface ChartXAxe { - type?: string; + type?: ScaleType | string; display?: boolean; id?: string; stacked?: boolean; @@ -354,7 +352,7 @@ export interface ChartXAxe { } export interface ChartYAxe { - type?: string; + type?: ScaleType | string; display?: boolean; id?: string; stacked?: boolean; @@ -371,16 +369,28 @@ export interface LogarithmicScale extends ChartScales { ticks?: LogarithmicTickOptions; } +export interface TimeDisplayFormat { + millisecond?: string; + second?: string; + minute?: string; + hour?: string; + day?: string; + week?: string; + month?: string; + quarter?: string; + year?: string; +} + export interface TimeScale extends ChartScales { format?: string; - displayFormats?: string; + displayFormats?: TimeDisplayFormat; isoWeekday?: boolean; max?: string; min?: string; parser?: string | ((arg: any) => any); round?: string; tooltipFormat?: string; - unit?: string | TimeUnit; + unit?: TimeUnit; unitStepSize?: number; } From 50efc65b9f9213f84150035c3ac3cc3c0d277239 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 12 Dec 2016 12:33:16 +0100 Subject: [PATCH 016/181] export types as namespace so that it can be accessed via reference -> Chart, reference -> Chart.Chart, import ... from, import ... = require() --- chart.js/index.d.ts | 764 ++++++++++++++++++++++---------------------- 1 file changed, 386 insertions(+), 378 deletions(-) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 413887601b..56b832f572 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -3,422 +3,430 @@ // Definitions by: Alberto Nuti // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export declare type ChartType = 'line' | 'bar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble'; +declare class Chart { + public static readonly Chart: typeof Chart; + constructor(context: CanvasRenderingContext2D | HTMLCanvasElement, options: Chart.ChartConfiguration); + config: Chart.ChartConfiguration; + destroy: () => {}; + update: (duration?: any, lazy?: any) => {}; + render: (duration?: any, lazy?: any) => {}; + stop: () => {}; + resize: () => {}; + clear: () => {}; + toBase64: () => string; + generateLegend: () => {}; + getElementAtEvent: (e: any) => {}; + getElementsAtEvent: (e: any) => {}[]; + getDatasetAtEvent: (e: any) => {}[]; -export declare type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; - -export declare type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear'; - -export interface ChartLegendItem { - text?: string; - fillStyle?: string; - hidden?: boolean; - lineCap?: string; - lineDash?: number[]; - lineDashOffset?: number; - lineJoin?: string; - lineWidth?: number; - strokeStyle?: string; -} -export interface ChartTooltipItem { - xLabel?: string; - yLabel?: string; - datasetIndex?: number; - index?: number; -} -export interface ChartTooltipCallback { - beforeTitle?: (item?: ChartTooltipItem[], data?: any) => void; - title?: (item?: ChartTooltipItem[], data?: any) => void; - afterTitle?: (item?: ChartTooltipItem[], data?: any) => void; - beforeBody?: (item?: ChartTooltipItem[], data?: any) => void; - beforeLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; - label?: (tooltipItem?: ChartTooltipItem, data?: any) => void; - afterLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; - afterBody?: (item?: ChartTooltipItem[], data?: any) => void; - beforeFooter?: (item?: ChartTooltipItem[], data?: any) => void; - footer?: (item?: ChartTooltipItem[], data?: any) => void; - afterfooter?: (item?: ChartTooltipItem[], data?: any) => void; -} -export interface ChartAnimationParameter { - chartInstance?: any; - animationObject?: any; -} -export interface ChartPoint { - x?: number; - y?: number; + defaults: { + global: Chart.ChartOptions; + } } -export interface ChartConfiguration { - type?: ChartType | string; - data?: ChartData; - options?: ChartOptions; -} +declare namespace Chart { + export type ChartType = 'line' | 'bar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble'; -export interface ChartData { + export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; -} + export type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear'; -export interface LinearChartData extends ChartData { - labels?: string[]; - datasets?: ChartDataSets[]; -} + export interface ChartLegendItem { + text?: string; + fillStyle?: string; + hidden?: boolean; + lineCap?: string; + lineDash?: number[]; + lineDashOffset?: number; + lineJoin?: string; + lineWidth?: number; + strokeStyle?: string; + } -export interface ChartOptions { - responsive?: boolean; - responsiveAnimationDuration?: number; - maintainAspectRatio?: boolean; - events?: string[]; - onClick?: (any?: any) => any; - title?: ChartTitleOptions; - legend?: ChartLegendOptions; - tooltips?: ChartTooltipOptions; - hover?: ChartHoverOptions; - animation?: ChartAnimationOptions; - elements?: ChartElementsOptions; - scales?: ChartScales; -} + export interface ChartTooltipItem { + xLabel?: string; + yLabel?: string; + datasetIndex?: number; + index?: number; + } -export interface ChartFontOptions { - defaultFontColor?: ChartColor; - defaultFontFamily?: string; - defaultFontSize?: number; - defaultFontStyle?: string; -} + export interface ChartTooltipCallback { + beforeTitle?: (item?: ChartTooltipItem[], data?: any) => void; + title?: (item?: ChartTooltipItem[], data?: any) => void; + afterTitle?: (item?: ChartTooltipItem[], data?: any) => void; + beforeBody?: (item?: ChartTooltipItem[], data?: any) => void; + beforeLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + label?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + afterLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + afterBody?: (item?: ChartTooltipItem[], data?: any) => void; + beforeFooter?: (item?: ChartTooltipItem[], data?: any) => void; + footer?: (item?: ChartTooltipItem[], data?: any) => void; + afterfooter?: (item?: ChartTooltipItem[], data?: any) => void; + } -export interface ChartTitleOptions { - display?: boolean; - position?: string; - fullWdith?: boolean; - fontSize?: number; - fontFamily?: string; - fontColor?: ChartColor; - fontStyle?: string; - padding?: number; - text?: string; -} + export interface ChartAnimationParameter { + chartInstance?: any; + animationObject?: any; + } -export interface ChartLegendOptions { - display?: boolean; - position?: string; - fullWidth?: boolean; - onClick?: (event: any, legendItem: any) => void; - labels?: ChartLegendLabelOptions; -} + export interface ChartPoint { + x?: number; + y?: number; + } -export interface ChartLegendLabelOptions { - boxWidth?: number; - fontSize?: number; - fontStyle?: number; - fontColor?: ChartColor; - fontFamily?: string; - padding?: number; - generateLabels?: (chart: any) => any; -} + export interface ChartConfiguration { + type?: ChartType | string; + data?: ChartData; + options?: ChartOptions; + } -export interface ChartTooltipOptions { - enabled?: boolean; - custom?: (a: any) => void; - mode?: string; - backgroundColor?: ChartColor; - titleFontFamily?: string; - titleFontSize?: number; - titleFontStyle?: string; - titleFontColor?: ChartColor; - titleSpacing?: number; - titleMarginBottom?: number; - bodyFontFamily?: string; - bodyFontSize?: number; - bodyFontStyle?: string; - bodyFontColor?: ChartColor; - bodySpacing?: number; - footerFontFamily?: string; - footerFontSize?: number; - footerFontStyle?: string; - footerFontColor?: ChartColor; - footerSpacing?: number; - footerMarginTop?: number; - xPadding?: number; - yPadding?: number; - caretSize?: number; - cornerRadius?: number; - multiKeyBackground?: string; - callbacks?: ChartTooltipCallback; -} + export interface ChartData { -export interface ChartHoverOptions { - mode?: string; - animationDuration?: number; - onHover?: (active: any) => void; -} + } -export interface ChartAnimationObject { - currentStep?: number; - numSteps?: number; - easing?: string; - render?: (arg: any) => void; - onAnimationProgress?: (arg: any) => void; - onAnimationComplete?: (arg: any) => void; -} + export interface LinearChartData extends ChartData { + labels?: string[]; + datasets?: ChartDataSets[]; + } -export interface ChartAnimationOptions { - duration?: number; - easing?: string; - onProgress?: (chart: any) => void; - onComplete?: (chart: any) => void; -} + export interface ChartOptions { + responsive?: boolean; + responsiveAnimationDuration?: number; + maintainAspectRatio?: boolean; + events?: string[]; + onClick?: (any?: any) => any; + title?: ChartTitleOptions; + legend?: ChartLegendOptions; + tooltips?: ChartTooltipOptions; + hover?: ChartHoverOptions; + animation?: ChartAnimationOptions; + elements?: ChartElementsOptions; + scales?: ChartScales; + } -export interface ChartElementsOptions { - point?: ChartPointOptions; - line?: ChartLineOptions; - arg?: ChartArcOtpions; - rectangle?: ChartRectangleOptions; -} + export interface ChartFontOptions { + defaultFontColor?: ChartColor; + defaultFontFamily?: string; + defaultFontSize?: number; + defaultFontStyle?: string; + } -export interface ChartArcOtpions { - backgroundColor?: ChartColor; - borderColor?: ChartColor; - borderWidth?: number; -} + export interface ChartTitleOptions { + display?: boolean; + position?: string; + fullWdith?: boolean; + fontSize?: number; + fontFamily?: string; + fontColor?: ChartColor; + fontStyle?: string; + padding?: number; + text?: string; + } -export interface ChartLineOptions { - tension?: number; - backgroundColor?: ChartColor; - borderWidth?: number; - borderColor?: ChartColor; - borderCapStyle?: string; - borderDash?: any[]; - borderDashOffset?: number; - borderJoinStyle?: string; -} + export interface ChartLegendOptions { + display?: boolean; + position?: string; + fullWidth?: boolean; + onClick?: (event: any, legendItem: any) => void; + labels?: ChartLegendLabelOptions; + } -export interface ChartPointOptions { - radius?: number; - pointStyle?: string; - backgroundColor?: ChartColor; - borderWidth?: number; - borderColor?: ChartColor; - hitRadius?: number; - hoverRadius?: number; - hoverBorderWidth?: number; -} + export interface ChartLegendLabelOptions { + boxWidth?: number; + fontSize?: number; + fontStyle?: number; + fontColor?: ChartColor; + fontFamily?: string; + padding?: number; + generateLabels?: (chart: any) => any; + } -export interface ChartRectangleOptions { - backgroundColor?: ChartColor; - borderWidth?: number; - borderColor?: ChartColor; - borderSkipped?: string; -} -export interface GridLineOptions { - display?: boolean; - color?: ChartColor; - lineWidth?: number; - drawBorder?: boolean; - drawOnChartArea?: boolean; - drawticks?: boolean; - tickMarkLength?: number; - zeroLineWidth?: number; - zeroLineColor?: ChartColor; - offsetGridLines?: boolean; -} + export interface ChartTooltipOptions { + enabled?: boolean; + custom?: (a: any) => void; + mode?: string; + backgroundColor?: ChartColor; + titleFontFamily?: string; + titleFontSize?: number; + titleFontStyle?: string; + titleFontColor?: ChartColor; + titleSpacing?: number; + titleMarginBottom?: number; + bodyFontFamily?: string; + bodyFontSize?: number; + bodyFontStyle?: string; + bodyFontColor?: ChartColor; + bodySpacing?: number; + footerFontFamily?: string; + footerFontSize?: number; + footerFontStyle?: string; + footerFontColor?: ChartColor; + footerSpacing?: number; + footerMarginTop?: number; + xPadding?: number; + yPadding?: number; + caretSize?: number; + cornerRadius?: number; + multiKeyBackground?: string; + callbacks?: ChartTooltipCallback; + } -export interface ScaleTitleOptions { - display?: boolean; - labelString?: string; - fontColor?: ChartColor; - fontFamily?: string; - fontSize?: number; - fontStyle?: string; -} + export interface ChartHoverOptions { + mode?: string; + animationDuration?: number; + onHover?: (active: any) => void; + } -export interface TickOptions { - autoSkip?: boolean; - callback?: (value: any, index: any, values: any) => string; - display?: boolean; - fontColor?: ChartColor; - fontFamily?: string; - fontSize?: number; - fontStyle?: string; - labelOffset?: number; - maxRotation?: number; - minRotation?: number; - mirror?: boolean; - padding?: number; - reverse?: boolean; - min?: any; - max?: any; -} -export interface AngleLineOptions { - display?: boolean; - color?: ChartColor; - lineWidth?: number; -} + export interface ChartAnimationObject { + currentStep?: number; + numSteps?: number; + easing?: string; + render?: (arg: any) => void; + onAnimationProgress?: (arg: any) => void; + onAnimationComplete?: (arg: any) => void; + } -export interface PointLabelOptions { - callback?: (arg: any) => any; - fontColor?: ChartColor; - fontFamily?: string; - fontSize?: number; - fontStyle?: string; -} + export interface ChartAnimationOptions { + duration?: number; + easing?: string; + onProgress?: (chart: any) => void; + onComplete?: (chart: any) => void; + } -export interface TickOptions { - backdropColor?: ChartColor; - backdropPaddingX?: number; - backdropPaddingY?: number; - maxTicksLimit?: number; - showLabelBackdrop?: boolean; -} -export interface LinearTickOptions extends TickOptions { - beginAtZero?: boolean; - min?: number; - max?: number; - maxTicksLimit?: number; - stepSize?: number; - suggestedMin?: number; - suggestedMax?: number; -} + export interface ChartElementsOptions { + point?: ChartPointOptions; + line?: ChartLineOptions; + arg?: ChartArcOtpions; + rectangle?: ChartRectangleOptions; + } -export interface LogarithmicTickOptions extends TickOptions { - min?: number; - max?: number; -} + export interface ChartArcOtpions { + backgroundColor?: ChartColor; + borderColor?: ChartColor; + borderWidth?: number; + } -type ChartColor = string | CanvasGradient | CanvasPattern; + export interface ChartLineOptions { + tension?: number; + backgroundColor?: ChartColor; + borderWidth?: number; + borderColor?: ChartColor; + borderCapStyle?: string; + borderDash?: any[]; + borderDashOffset?: number; + borderJoinStyle?: string; + } -export interface ChartDataSets { - backgroundColor?: ChartColor; - borderWidth?: number; - borderColor?: ChartColor; - borderCapStyle?: string; - borderDash?: number[]; - borderDashOffset?: number; - borderJoinStyle?: string; - data?: number[] | ChartPoint[]; - fill?: boolean; - label?: string; - lineTension?: number; - pointBorderColor?: ChartColor | ChartColor[]; - pointBackgroundColor?: ChartColor | ChartColor[]; - pointBorderWidth?: number | number[]; - pointRadius?: number | number[]; - pointHoverRadius?: number | number[]; - pointHitRadius?: number | number[]; - pointHoverBackgroundColor?: ChartColor | ChartColor[]; - pointHoverBorderColor?: ChartColor | ChartColor[]; - pointHoverBorderWidth?: number | number[]; - pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[]; - xAxisID?: string; - yAxisID?: string; -} + export interface ChartPointOptions { + radius?: number; + pointStyle?: string; + backgroundColor?: ChartColor; + borderWidth?: number; + borderColor?: ChartColor; + hitRadius?: number; + hoverRadius?: number; + hoverBorderWidth?: number; + } -export interface ChartScales { - type?: ScaleType | string; - display?: boolean; - position?: string; - beforeUpdate?: (scale?: any) => void; - beforeSetDimension?: (scale?: any) => void; - beforeDataLimits?: (scale?: any) => void; - beforeBuildTicks?: (scale?: any) => void; - beforeTickToLabelConversion?: (scale?: any) => void; - beforeCalculateTickRotation?: (scale?: any) => void; - beforeFit?: (scale?: any) => void; - afterUpdate?: (scale?: any) => void; - afterSetDimension?: (scale?: any) => void; - afterDataLimits?: (scale?: any) => void; - afterBuildTicks?: (scale?: any) => void; - afterTickToLabelConversion?: (scale?: any) => void; - afterCalculateTickRotation?: (scale?: any) => void; - afterFit?: (scale?: any) => void; - gridLines?: GridLineOptions; - scaleLabel?: ScaleTitleOptions; - ticks?: TickOptions; - xAxes?: ChartXAxe[]; - yAxes?: ChartYAxe[]; -} + export interface ChartRectangleOptions { + backgroundColor?: ChartColor; + borderWidth?: number; + borderColor?: ChartColor; + borderSkipped?: string; + } + export interface GridLineOptions { + display?: boolean; + color?: ChartColor; + lineWidth?: number; + drawBorder?: boolean; + drawOnChartArea?: boolean; + drawticks?: boolean; + tickMarkLength?: number; + zeroLineWidth?: number; + zeroLineColor?: ChartColor; + offsetGridLines?: boolean; + } -export interface ChartXAxe { - type?: ScaleType | string; - display?: boolean; - id?: string; - stacked?: boolean; - categoryPercentage?: number; - barPercentage?: number; - barThickness?: number; - gridLines?: GridLineOptions; - position?: string; - ticks?: TickOptions; - time?: TimeScale; - scaleLabel?: ScaleTitleOptions; -} + export interface ScaleTitleOptions { + display?: boolean; + labelString?: string; + fontColor?: ChartColor; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; + } -export interface ChartYAxe { - type?: ScaleType | string; - display?: boolean; - id?: string; - stacked?: boolean; - position?: string; - ticks?: TickOptions; - scaleLabel?: ScaleTitleOptions; -} + export interface TickOptions { + autoSkip?: boolean; + callback?: (value: any, index: any, values: any) => string; + display?: boolean; + fontColor?: ChartColor; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; + labelOffset?: number; + maxRotation?: number; + minRotation?: number; + mirror?: boolean; + padding?: number; + reverse?: boolean; + min?: any; + max?: any; + } + export interface AngleLineOptions { + display?: boolean; + color?: ChartColor; + lineWidth?: number; + } -export interface LinearScale extends ChartScales { - ticks?: LinearTickOptions; -} + export interface PointLabelOptions { + callback?: (arg: any) => any; + fontColor?: ChartColor; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; + } -export interface LogarithmicScale extends ChartScales { - ticks?: LogarithmicTickOptions; -} + export interface TickOptions { + backdropColor?: ChartColor; + backdropPaddingX?: number; + backdropPaddingY?: number; + maxTicksLimit?: number; + showLabelBackdrop?: boolean; + } + export interface LinearTickOptions extends TickOptions { + beginAtZero?: boolean; + min?: number; + max?: number; + maxTicksLimit?: number; + stepSize?: number; + suggestedMin?: number; + suggestedMax?: number; + } -export interface TimeDisplayFormat { - millisecond?: string; - second?: string; - minute?: string; - hour?: string; - day?: string; - week?: string; - month?: string; - quarter?: string; - year?: string; -} + export interface LogarithmicTickOptions extends TickOptions { + min?: number; + max?: number; + } -export interface TimeScale extends ChartScales { - format?: string; - displayFormats?: TimeDisplayFormat; - isoWeekday?: boolean; - max?: string; - min?: string; - parser?: string | ((arg: any) => any); - round?: string; - tooltipFormat?: string; - unit?: TimeUnit; - unitStepSize?: number; -} + type ChartColor = string | CanvasGradient | CanvasPattern; -export interface RadialLinearScale { - lineArc?: boolean; - angleLines?: AngleLineOptions; - pointLabels?: PointLabelOptions; - ticks?: TickOptions; -} + export interface ChartDataSets { + backgroundColor?: ChartColor; + borderWidth?: number; + borderColor?: ChartColor; + borderCapStyle?: string; + borderDash?: number[]; + borderDashOffset?: number; + borderJoinStyle?: string; + data?: number[] | ChartPoint[]; + fill?: boolean; + label?: string; + lineTension?: number; + pointBorderColor?: ChartColor | ChartColor[]; + pointBackgroundColor?: ChartColor | ChartColor[]; + pointBorderWidth?: number | number[]; + pointRadius?: number | number[]; + pointHoverRadius?: number | number[]; + pointHitRadius?: number | number[]; + pointHoverBackgroundColor?: ChartColor | ChartColor[]; + pointHoverBorderColor?: ChartColor | ChartColor[]; + pointHoverBorderWidth?: number | number[]; + pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[]; + xAxisID?: string; + yAxisID?: string; + } -export class Chart { - constructor (context: CanvasRenderingContext2D | HTMLCanvasElement, options: ChartConfiguration); - config: ChartConfiguration; - destroy: () => {}; - update: (duration?: any, lazy?: any) => {}; - render: (duration?: any, lazy?: any) => {}; - stop: () => {}; - resize: () => {}; - clear: () => {}; - toBase64: () => string; - generateLegend: () => {}; - getElementAtEvent: (e: any) => {}; - getElementsAtEvent: (e: any) => {}[]; - getDatasetAtEvent: (e: any) => {}[]; + export interface ChartScales { + type?: ScaleType | string; + display?: boolean; + position?: string; + beforeUpdate?: (scale?: any) => void; + beforeSetDimension?: (scale?: any) => void; + beforeDataLimits?: (scale?: any) => void; + beforeBuildTicks?: (scale?: any) => void; + beforeTickToLabelConversion?: (scale?: any) => void; + beforeCalculateTickRotation?: (scale?: any) => void; + beforeFit?: (scale?: any) => void; + afterUpdate?: (scale?: any) => void; + afterSetDimension?: (scale?: any) => void; + afterDataLimits?: (scale?: any) => void; + afterBuildTicks?: (scale?: any) => void; + afterTickToLabelConversion?: (scale?: any) => void; + afterCalculateTickRotation?: (scale?: any) => void; + afterFit?: (scale?: any) => void; + gridLines?: GridLineOptions; + scaleLabel?: ScaleTitleOptions; + ticks?: TickOptions; + xAxes?: ChartXAxe[]; + yAxes?: ChartYAxe[]; + } - defaults: { - global: ChartOptions; + export interface ChartXAxe { + type?: ScaleType | string; + display?: boolean; + id?: string; + stacked?: boolean; + categoryPercentage?: number; + barPercentage?: number; + barThickness?: number; + gridLines?: GridLineOptions; + position?: string; + ticks?: TickOptions; + time?: TimeScale; + scaleLabel?: ScaleTitleOptions; + } + + export interface ChartYAxe { + type?: ScaleType | string; + display?: boolean; + id?: string; + stacked?: boolean; + position?: string; + ticks?: TickOptions; + scaleLabel?: ScaleTitleOptions; + } + + export interface LinearScale extends ChartScales { + ticks?: LinearTickOptions; + } + + export interface LogarithmicScale extends ChartScales { + ticks?: LogarithmicTickOptions; + } + + export interface TimeDisplayFormat { + millisecond?: string; + second?: string; + minute?: string; + hour?: string; + day?: string; + week?: string; + month?: string; + quarter?: string; + year?: string; + } + + export interface TimeScale extends ChartScales { + format?: string; + displayFormats?: TimeDisplayFormat; + isoWeekday?: boolean; + max?: string; + min?: string; + parser?: string | ((arg: any) => any); + round?: string; + tooltipFormat?: string; + unit?: TimeUnit; + unitStepSize?: number; + } + + export interface RadialLinearScale { + lineArc?: boolean; + angleLines?: AngleLineOptions; + pointLabels?: PointLabelOptions; + ticks?: TickOptions; } } +export = Chart; export as namespace Chart; \ No newline at end of file From e7058eda4bf174b45a4cc821c3940ccfc45152e5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 16 Dec 2016 00:47:00 -0800 Subject: [PATCH 017/181] Added declarations and tests for 'pulltorefeshjs'. --- pulltorefreshjs/index.d.ts | 117 +++++++++++++++++++++++ pulltorefreshjs/pulltorefreshjs-tests.ts | 19 ++++ pulltorefreshjs/tsconfig.json | 19 ++++ pulltorefreshjs/tslint.json | 1 + 4 files changed, 156 insertions(+) create mode 100644 pulltorefreshjs/index.d.ts create mode 100644 pulltorefreshjs/pulltorefreshjs-tests.ts create mode 100644 pulltorefreshjs/tsconfig.json create mode 100644 pulltorefreshjs/tslint.json diff --git a/pulltorefreshjs/index.d.ts b/pulltorefreshjs/index.d.ts new file mode 100644 index 0000000000..e26af8e54c --- /dev/null +++ b/pulltorefreshjs/index.d.ts @@ -0,0 +1,117 @@ +// Type definitions for pulltorefreshjs 0.1 +// Project: https://github.com/BoxFactura/pulltorefresh.js +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function init(options?: Options): void; + +export interface Options { + /** + * Minimum distance required to trigger the refresh. + * (default: `60`) + */ + distThreshold?: number; + + /** + * Maximum distance possible for the element. + * (default: `80`) + */ + distMax?: number; + + /** + * After the `distThreshold` is reached and released, the element will have this height. + * (default: `50`) + */ + distReload?: number; + + /** + * Before which element the pull to refresh elements will be? + * (default: `body`) + */ + mainElement?: string; + + /** + * Which element should trigger the pull to refresh? + * (default: `body`) + */ + triggerElement?: string; + + /** + * What class will the main element have? + * (default: `.ptr`) + */ + ptrElement?: string; + + /** + * What class prefix for the elements? + * (default: `ptr--`) + */ + classPrefix?: string; + + /** + * What property will be used to calculate the element's proportions? + * (default: `min-height`) + */ + cssProp?: string; + + /** + * The icon for both `instructionsPullToRefresh` and `instructionsReleaseToRefresh` + * (default: `⇣`) + */ + iconArrow?: string; + + /** + * The icon when the refresh is in progress. + * (default: `…`) + */ + iconRefreshing?: string; + + /** + * The initial instructions string. + * (default: `Pull down to refresh`) + */ + instructionsPullToRefresh?: string; + + /** + * The instructions string when the `distThreshold` has been reached. + * (default: `Release to refresh`) + */ + instructionsReleaseToRefresh?: string; + + /** + * The refreshing text. + * (default: `Refreshing`) + */ + instructionsRefreshing?: string; + + /** + * The delay, in milliseconds before the `onRefresh` is triggered. + * (default: `500`) + */ + refreshTimeout?: number; + + /** + * The initialize function. + */ + onInit?: () => void; + + /** + * What will the pull to refresh trigger? You can return a promise. + * + * Defaults to `window.location.reload()` + */ + onRefresh?: (() => PromiseLike) | (() => void); + + + /** + * The resistance function, accepts one parameter, must return a number, capping at 1. + * + * Defaults to `t => Math.min(1, t / 2.5)` + */ + resistanceFunction?: (input: number) => number; +} + +/** + * If no loader is present, this module is available as a global. + */ +export as namespace PullToRefresh; \ No newline at end of file diff --git a/pulltorefreshjs/pulltorefreshjs-tests.ts b/pulltorefreshjs/pulltorefreshjs-tests.ts new file mode 100644 index 0000000000..b971e7a92d --- /dev/null +++ b/pulltorefreshjs/pulltorefreshjs-tests.ts @@ -0,0 +1,19 @@ +import * as PullToRefresh from "pulltorefreshjs"; + +PullToRefresh.init(); + +PullToRefresh.init({}); + +PullToRefresh.init({ + mainElement: "body", + onRefresh: () => { window.location.reload(); }, +}); + +PullToRefresh.init({ + resistanceFunction: x => Math.sqrt(x), +}); + +PullToRefresh.init({ + mainElement: "body", + onRefresh: () => Promise.resolve(), +}); \ No newline at end of file diff --git a/pulltorefreshjs/tsconfig.json b/pulltorefreshjs/tsconfig.json new file mode 100644 index 0000000000..199c61cf0e --- /dev/null +++ b/pulltorefreshjs/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pulltorefreshjs-tests.ts" + ] +} diff --git a/pulltorefreshjs/tslint.json b/pulltorefreshjs/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/pulltorefreshjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 0d97dfa1eeb25916bee168dffc49e35483a8dece Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 28 Dec 2016 13:55:02 +0100 Subject: [PATCH 018/181] Updated tsconfig.json --- http-link-header/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/http-link-header/tsconfig.json b/http-link-header/tsconfig.json index 12f90f78bd..9fb6d5e158 100644 --- a/http-link-header/tsconfig.json +++ b/http-link-header/tsconfig.json @@ -3,7 +3,8 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From d10885743b370f39cf198576693338c41ec07ea3 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 28 Dec 2016 13:55:14 +0100 Subject: [PATCH 019/181] Fixed version number --- http-link-header/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index cb3205c81a..615d94f76b 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for http-link-header v0.6.0 +// Type definitions for http-link-header 0.6 // Project: https://github.com/jhermsmeier/node-http-link-header // Definitions by: Christian Rackerseder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 33f91fb45c54cc13b706347f8ee5ee082653a9c1 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 28 Dec 2016 13:55:26 +0100 Subject: [PATCH 020/181] Removed toString() --- http-link-header/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index 615d94f76b..b24b01ee4a 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -14,6 +14,5 @@ export interface Link { get: (attribute: string, value: string) => Reference; rel: (value: string) => Reference; set: (ref: Reference) => Reference; - toString: () => string; } export function parse(header: string): Link; From b2209b605ac9011d7b7df1dea326158c5f41415f Mon Sep 17 00:00:00 2001 From: Guilhem Soulas Date: Wed, 14 Dec 2016 22:02:12 +0000 Subject: [PATCH 021/181] [lodash] add type guards to isNull, isUndefined, isNil --- lodash/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash/index.d.ts b/lodash/index.d.ts index bf19508fa6..db882d5c51 100644 --- a/lodash/index.d.ts +++ b/lodash/index.d.ts @@ -12310,7 +12310,7 @@ declare module _ { * _.isNil(NaN); * // => false */ - isNil(value?: any): boolean; + isNil(value: any): value is null | undefined; } interface LoDashImplicitWrapperBase { @@ -12335,7 +12335,7 @@ declare module _ { * @param value The value to check. * @return Returns true if value is null, else false. */ - isNull(value?: any): boolean; + isNull(value: any): value is null; } interface LoDashImplicitWrapperBase { @@ -12662,7 +12662,7 @@ declare module _ { * @param value The value to check. * @return Returns true if value is undefined, else false. */ - isUndefined(value: any): boolean; + isUndefined(value: any): value is undefined; } interface LoDashImplicitWrapperBase { From 87fb5359400a3fd267813bdf461534e09cd5745f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 29 Dec 2016 14:25:38 -0500 Subject: [PATCH 022/181] `memoizee`: Clean up types --- memoizee/index.d.ts | 60 +++++++++++++------------------------- memoizee/memoizee-tests.ts | 25 ++++++++-------- memoizee/tsconfig.json | 1 + 3 files changed, 34 insertions(+), 52 deletions(-) diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts index 125b34f264..456641dc59 100644 --- a/memoizee/index.d.ts +++ b/memoizee/index.d.ts @@ -3,47 +3,27 @@ // Definitions by: Juan Picado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/** - * Resolver options - * @interface RevolversArray - */ -interface RevolversArray { - [index: number]: {}; +declare namespace memoizee { + interface Options { + length?: number; + maxAge?: number; + max?: number; + preFetch?: number | true; + promise?: boolean; + dispose?: (value: any) => void; + async?: boolean; + primitive?: boolean; + normalizer?: (value: any) => void; + resolvers?: Array<(arg: any) => any>; + } + + interface Memoized { + delete: F; + clear: F & (() => void); + } } -/** - * List of options - * @interface IMemoizeeOptions - */ -interface IMemoizeeOptions { - length?: number; - maxAge?: number; - max?: number; - preFetch?: number; - promise?: boolean; - dispose?: (value: any) => void; - async?: boolean; - primitive?: boolean; - normalizer?: (value: any ) => void; - resolvers?: RevolversArray; -} - -/** - * Main interface functions - * @interface IMemoizee - * @extends {Function} - */ -interface IMemoizee extends Function { - delete: (...params: any[]) => void; - clear: (...params: any[]) => void; -} - -/** - * Memoize function - * @param {*} f - * @param {IMemoizeeOptions} [options] - * @returns {IMemoizee} - */ -declare function memoizee(f: (...params: any[]) => void, options?: IMemoizeeOptions): IMemoizee; +// tslint:disable:forbidden-types +declare function memoizee(f: F, options?: memoizee.Options): F & memoizee.Memoized; export = memoizee; diff --git a/memoizee/memoizee-tests.ts b/memoizee/memoizee-tests.ts index 138a605712..e8e73a2d6a 100644 --- a/memoizee/memoizee-tests.ts +++ b/memoizee/memoizee-tests.ts @@ -1,6 +1,6 @@ import memoize = require('memoizee'); -var fn = function (one:any, two:any, three:any) { /* ... */ }; +var fn = function (one: string, two?: number, three?: any) { /* ... */ }; let memoized = memoize(fn); memoized('foo', 3, 'bar'); @@ -23,7 +23,7 @@ var foo3 = memoized('foo', 3); var bar7 = memoized('bar', 7); memoized.clear('foo', 3); // Dispose called with foo3 value memoized.clear('bar', 7); // Dispose called with bar7 value -memoized.delete('foo', true); +memoized.delete('foo', 0); var mFn = memoize(function (hash:any) { // body of memoized function }, { normalizer: function (args:any) { @@ -34,17 +34,18 @@ var mFn = memoize(function (hash:any) { mFn({ foo: 'bar' }); memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] }); -memoized(12, [1,2,3].length); -memoized("12", true); -memoized({ toString: function () { return "12"; } }, {}); +memoized(String(12), [1,2,3].length); +memoized("12", Number(true)); +memoized(String({ toString: function () { return "12"; } }), Number({})); -var afn = function (a:number, b:number) { - return new Promise(function (res) { res(a + b); }); -}; -memoized = memoize(afn, { promise: true }); - -memoized(3, 7); -memoized(3, 7); +{ + var afn = function (a:number, b:number) { + return new Promise(function (res) { res(a + b); }); + }; + let memoized = memoize(afn, { promise: true }); + memoized(3, 7); + memoized(3, 7); +} memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 }); diff --git a/memoizee/tsconfig.json b/memoizee/tsconfig.json index 68b204fbd9..c2ccff1cab 100644 --- a/memoizee/tsconfig.json +++ b/memoizee/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, + "noImplicitThis": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From b67114684cb47640ddee4f0ca00dde7499ff72eb Mon Sep 17 00:00:00 2001 From: Daryl LaBar Date: Fri, 30 Dec 2016 03:01:32 -0500 Subject: [PATCH 023/181] Updated Paths of files to match https://github.com/Microsoft/types-publisher/issues/3 --- xrm/{xrm-6.d.ts => v6/index.d.ts} | 0 xrm/v6/tsconfig.json | 20 +++++++++++++++++++ xrm/{xrm-6.tests.ts => v6/xrm-v6-tests.ts} | 2 ++ xrm/{xrm-7.1.d.ts => v7.1/index.d.ts} | 0 xrm/v7.1/tsconfig.json | 20 +++++++++++++++++++ .../xrm-v7.1-tests.ts} | 6 +++--- xrm/{xrm-7.0.d.ts => v7/index.d.ts} | 0 xrm/v7/tsconfig.json | 20 +++++++++++++++++++ xrm/{xrm-7.0.tests.ts => v7/xrm-v7-tests.ts} | 2 ++ xrm/xrm-tests.ts | 7 +++---- 10 files changed, 70 insertions(+), 7 deletions(-) rename xrm/{xrm-6.d.ts => v6/index.d.ts} (100%) create mode 100644 xrm/v6/tsconfig.json rename xrm/{xrm-6.tests.ts => v6/xrm-v6-tests.ts} (95%) rename xrm/{xrm-7.1.d.ts => v7.1/index.d.ts} (100%) create mode 100644 xrm/v7.1/tsconfig.json rename xrm/{xrm-7.1.tests.ts => v7.1/xrm-v7.1-tests.ts} (97%) rename xrm/{xrm-7.0.d.ts => v7/index.d.ts} (100%) create mode 100644 xrm/v7/tsconfig.json rename xrm/{xrm-7.0.tests.ts => v7/xrm-v7-tests.ts} (96%) diff --git a/xrm/xrm-6.d.ts b/xrm/v6/index.d.ts similarity index 100% rename from xrm/xrm-6.d.ts rename to xrm/v6/index.d.ts diff --git a/xrm/v6/tsconfig.json b/xrm/v6/tsconfig.json new file mode 100644 index 0000000000..220693faf6 --- /dev/null +++ b/xrm/v6/tsconfig.json @@ -0,0 +1,20 @@ +{ + "files": [ + "index.d.ts", + "xrm-v6-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} \ No newline at end of file diff --git a/xrm/xrm-6.tests.ts b/xrm/v6/xrm-v6-tests.ts similarity index 95% rename from xrm/xrm-6.tests.ts rename to xrm/v6/xrm-v6-tests.ts index 3b911da94d..6cdb61a33c 100644 --- a/xrm/xrm-6.tests.ts +++ b/xrm/v6/xrm-v6-tests.ts @@ -1,3 +1,5 @@ +/// +/// function _getContext() diff --git a/xrm/xrm-7.1.d.ts b/xrm/v7.1/index.d.ts similarity index 100% rename from xrm/xrm-7.1.d.ts rename to xrm/v7.1/index.d.ts diff --git a/xrm/v7.1/tsconfig.json b/xrm/v7.1/tsconfig.json new file mode 100644 index 0000000000..ab52c3f626 --- /dev/null +++ b/xrm/v7.1/tsconfig.json @@ -0,0 +1,20 @@ +{ + "files": [ + "index.d.ts", + "xrm-v7.1-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} \ No newline at end of file diff --git a/xrm/xrm-7.1.tests.ts b/xrm/v7.1/xrm-v7.1-tests.ts similarity index 97% rename from xrm/xrm-7.1.tests.ts rename to xrm/v7.1/xrm-v7.1-tests.ts index f3f4576b02..e962910a96 100644 --- a/xrm/xrm-7.1.tests.ts +++ b/xrm/v7.1/xrm-v7.1-tests.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// /// Demonstrate usage in the browser's window object @@ -41,7 +41,7 @@ grids.forEach(( gridControl: Xrm.Page.GridControl ) => gridControl.getGrid().getSelectedRows().forEach(( row ) => { selectedGridReferences.push( row.getData().getEntity().getEntityReference() ); - }) + }); }); /// Demonstrate generic overload vs typecast diff --git a/xrm/xrm-7.0.d.ts b/xrm/v7/index.d.ts similarity index 100% rename from xrm/xrm-7.0.d.ts rename to xrm/v7/index.d.ts diff --git a/xrm/v7/tsconfig.json b/xrm/v7/tsconfig.json new file mode 100644 index 0000000000..0e2582bf02 --- /dev/null +++ b/xrm/v7/tsconfig.json @@ -0,0 +1,20 @@ +{ + "files": [ + "index.d.ts", + "xrm-v7.0-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} \ No newline at end of file diff --git a/xrm/xrm-7.0.tests.ts b/xrm/v7/xrm-v7-tests.ts similarity index 96% rename from xrm/xrm-7.0.tests.ts rename to xrm/v7/xrm-v7-tests.ts index f45f49c20c..17ae2a3d9a 100644 --- a/xrm/xrm-7.0.tests.ts +++ b/xrm/v7/xrm-v7-tests.ts @@ -1,3 +1,5 @@ +/// +/// function _getContext() diff --git a/xrm/xrm-tests.ts b/xrm/xrm-tests.ts index 65ae6e0184..1893b9b89a 100644 --- a/xrm/xrm-tests.ts +++ b/xrm/xrm-tests.ts @@ -38,10 +38,9 @@ var selectedGridReferences: Xrm.Page.LookupValue[] = []; grids.forEach(( gridControl: Xrm.Page.GridControl ) => { - gridControl.getGrid().getSelectedRows().forEach(( row ) => - { - selectedGridReferences.push( row.getData().getEntity().getEntityReference() ); - }) + gridControl.getGrid().getSelectedRows().forEach((row) => { + selectedGridReferences.push(row.getData().getEntity().getEntityReference()); + }); }); /// Demonstrate generic overload vs typecast From 2379ab7be2142b750ae2615e30f72638026127b2 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 30 Dec 2016 14:29:50 -0800 Subject: [PATCH 024/181] Remove mistakes from readme if we will lint for them anyway --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index a724009cf3..0b1a79ae7c 100644 --- a/README.md +++ b/README.md @@ -121,17 +121,11 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D #### Common mistakes * First, follow advice from the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html). -* Formatting: Either use all tabs, or always use 4 spaces. Also, always use semicolons, and use egyptian braces. -* `interface X {}`: An empty interface is essentially the `{}` type: it places no constraints on an object. -* `interface IFoo {}`: Don't add `I` to the front of an interface name. +* Formatting: Either use all tabs, or always use 4 spaces. * `interface Foo { new(): Foo; }`: This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); }`. * `const Class: { new(): IClass; }`: Prefer to use a class declaration `class Class { constructor(); }` instead of a new-able constant. -* `namespace foo {}`: - Do not add a namespace just so that the `import * as foo` syntax will work. - If it is commonJs module with a single export, you should use the `import foo = require("foo")` syntax. - See more explanation [here](https://stackoverflow.com/questions/39415661/why-cant-i-import-a-class-or-function-with-import-as-x-from-y). * `getMeAT(): T`: If a type parameter does not appear in the types of any parameters, you don't really have a generic function, you just have a disguised type assertion. Prefer to use a real type assertion, e.g. `getMeAT() as number`. From 0232616783affa57eb6615c7acead2649ca41fa4 Mon Sep 17 00:00:00 2001 From: William Rummler Date: Fri, 30 Dec 2016 16:47:00 -0600 Subject: [PATCH 025/181] Types 2.0 - Fix JS-quantities (#12739) * Enable strict null checking per readme FAQ. * Add tslint.json. * Improve test file with project spec. * Fix js-quantities d.ts, with adjustment of test. * Add trailing newline to tslint. * Simplify functional interface per linter. * js-quantities: add readme examples to tests * js-quantities: fix & clean declaration --- js-quantities/index.d.ts | 132 ++- js-quantities/js-quantities-tests.ts | 1503 +++++++++++++++++++++++++- js-quantities/tsconfig.json | 4 +- js-quantities/tslint.json | 3 + 4 files changed, 1567 insertions(+), 75 deletions(-) create mode 100644 js-quantities/tslint.json diff --git a/js-quantities/index.d.ts b/js-quantities/index.d.ts index a2e3c2d96c..5d4a8df304 100644 --- a/js-quantities/index.d.ts +++ b/js-quantities/index.d.ts @@ -1,79 +1,73 @@ -// Type definitions for JS-quantities +// Type definitions for JS-quantities 1.6 // Project: http://gentooboontoo.github.io/js-quantities/ -// Definitions by: William Comartin +// Definitions by: William Rummler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare var Qty: QtyModule.QtyStatic; - -declare namespace QtyModule { - interface QtyStatic { - (value: string): Qty; - (value: number): Qty; - (value: number, unit: string): Qty; - (value: Qty): Qty; - } - - interface Qty { - version: string; - - scalar: number; - baseScalar: number; - - parse(value: string): Qty; - - swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number; - - getkinds(): string[]; - - getUnits(kind:string): string[]; - - getAliases(unitName:string): string[]; - - formatter(scalar:number, units:string):string; - - toFloat(): number; - - isUnitless(): boolean; - - isCompatible(other:string|Qty): boolean; - - isInverse(other:string|Qty): boolean - - kind(): string; - - isBase(): boolean; - - toBase(): Qty; +declare const Qty: Qty.Type; +declare interface Qty { + readonly numerator: string[]; + readonly denominator: string[]; + readonly scalar: number; + readonly baseScalar: number; + readonly initValue: string; units(): string; - - eq(other:Qty): boolean; - lt(other:Qty): boolean; - lte(other:Qty): boolean; - gt(other:Qty): boolean; - gte(other:Qty): boolean; - - toPrec(precQuantity: Qty|string|number): Qty; - - toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string; - - format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string; - - compareTo(other:Qty|string): number; - - same(other: Qty): boolean; - + isCompatible(value: Qty.UnitSource): boolean; + kind(): string; + isUnitless(): boolean; + isBase(): boolean; + toBase(): Qty; + toFloat(): number; + to(value: Qty.UnitSource): Qty; inverse(): Qty; + eq(value: Qty.UnitSource): boolean; + same(value: Qty.UnitSource): boolean; + lt(value: Qty.UnitSource): boolean; + lte(value: Qty.UnitSource): boolean; + gt(value: Qty.UnitSource): boolean; + gte(value: Qty.UnitSource): boolean; + compareTo(value: Qty): Qty.ComparisonResult; + add(value: Qty.Source): Qty; + sub(value: Qty.Source): Qty; + mul(value: Qty.Source): Qty; + div(value: Qty.Source): Qty; + toPrec(value: Qty.Source): Qty; + toString(valueOrPrecision?: Qty.Source): string; + toString(value: string, precision: number): string; + format(formatter?: Qty.Formatter): string; + format(value: string, formatter?: Qty.Formatter): string; +} - isDegrees(): boolean; +declare namespace Qty { - isTemperature(): boolean; + interface Type { + (value: Source): Qty; + (value: number, unit: string): Qty; + new (value: Source): Qty; + new (value: number, unit: string): Qty; + parse(value: string): Qty; + getKinds(): string[]; + getUnits(kind?: string): string[]; + getAliases(unit: string): string[]; + swiftConverter(sourceUnit: string, targetUnit: string): Converter; + formatter: Formatter; + readonly Error: any; + mulSafe(n1: number, n2: number): number; + divSafe(n1: number, n2: number): number; + } - to(other:string|Qty): Qty; + interface Converter { + (sourceValue: number): number; + (sourceValues: number[]): number[]; + } - add(other:string|Qty): Qty; - sub(other:string|Qty): Qty; - mul(other:number|string|Qty): Qty; - div(other:number|string|Qty): Qty; - } -} \ No newline at end of file + type Formatter = (scalar: number, unit: string) => string; + + type ComparisonResult = -1 | 0 | 1; + + type Source = UnitSource | number; + + type UnitSource = Qty | string; +} + +export default Qty; diff --git a/js-quantities/js-quantities-tests.ts b/js-quantities/js-quantities-tests.ts index c09867634a..b1916bb626 100644 --- a/js-quantities/js-quantities-tests.ts +++ b/js-quantities/js-quantities-tests.ts @@ -1,7 +1,1502 @@ -var Val1 = Qty('1 m') +import "../jasmine"; +import Qty from "."; -var Val2 = Qty(1); +// From project readme -var Val3 = Qty(1, 'm'); +let qty: Qty; -var Val4 = Qty(Val1); \ No newline at end of file +qty = new Qty('23 ft'); // constructor +qty = Qty('23 ft'); // factory + +qty = new Qty(124, 'cm'); // => 1.24 meter +qty = Qty(124, 'cm'); // => 1.24 meter + +qty = Qty('1m'); // => 1 meter +qty = Qty('m'); // => 1 meter (scalar defaults to 1) + +qty = Qty('1 N*m'); +qty = Qty('1 N m'); // * is optional + +qty = Qty('1 m/s'); + +qty = Qty('1 m^2/s^2'); +qty = Qty('1 m^2 s^-2'); // negative powers +qty = Qty('1 m2 s-2'); // ^ is optional + +qty = Qty('1 m^2 kg^2 J^2/s^2 A'); + +qty = Qty('1.5'); // unitless quantity +qty = Qty(1.5); // number as initializing value + +qty = Qty('1 attoparsec/microfortnight'); + +let qtyCopy: Qty; + +qtyCopy = Qty(qty); // quantity could be copied when used as initializing value + +Qty.parse('1 m'); // => 1 meter +Qty.parse('foo'); // => null + +Qty.getKinds(); // => Array of names of every well-known kind of units + +Qty.getUnits('currency'); // => [ 'dollar', 'cents' ] +// Or all alphabetically sorted +Qty.getUnits(); // => [ 'acre','Ah','ampere','AMU','angstrom'] + +Qty.getAliases('m'); // => [ 'm', 'meter', 'meters', 'metre', 'metres' ] + +const qty1 = Qty('1m'); +const qty2 = Qty('2m'); + +qty1.isCompatible(qty2); // => true or false + +qty.kind(); // => 'length', 'area', etc... + +qty.isUnitless(); // => true or false +qty.isBase(); // => true if quantity is represented with base units + +qty.toBase(); // converts to SI units (10 cm => 0.1 m) (new instance) + +qty.toFloat(); // returns scalar of unitless quantity (otherwise throws error) + +qty.to('m'); // converts quantity to meter if compatible or throws an error (new instance) +qty1.to(qty2); // converts quantity to same unit of qty2 if compatible or throws an error (new instance) + +qty.inverse(); // converts quantity to its inverse ('100 m/s' => '.01 s/m') +// Inverses can be used, but there is no special checking to +// rename the units +Qty('10ohm').inverse(); // '.1/ohm' (not '.1S', although they are equivalent) +// however, the 'to' command will convert between inverses also +Qty('10ohm').to('S'); // '.1S' + +var convert = Qty.swiftConverter('m/h', 'ft/s'); // Configures converter + +// Converting single value +var converted = convert(2500); // => 2.278.. + +// Converting large array of values +var convertedSerie = convert([2500, 5000]); // => [2.278.., 4.556.., ...] + +qty1.eq(qty2); // => true if both quantities are equal (1m == 100cm => true) +qty1.same(qty2); // => true if both quantities are same (1m == 100cm => false) +qty1.lt(qty2); // => true if qty1 is stricty less than qty2 +qty1.lte(qty2); // => true if qty1 is less than or equal to qty2 +qty1.gt(qty2); // => true if qty1 is stricty greater than qty2 +qty1.gte(qty2); // => true if qty1 is greater than or equal to qty2 + +qty1.compareTo(qty2); // => -1 if qty1 < qty2, => 0 if qty1 == qty2, => 1 if qty1 > qty2 + +qty = Qty('5.17 ft'); +qty.toPrec('ft'); // => 5 ft +qty.toPrec('0.5 ft'); // => 5 ft +qty.toPrec('0.25 ft'); // => 5.25 ft +qty.toPrec('0.1 ft'); // => 5.2 ft +qty.toPrec('0.05 ft'); // => 5.15 ft +qty.toPrec('0.01 ft'); // => 5.17 ft +qty.toPrec('0.00001 ft'); // => 5.17 ft +qty.toPrec('2 ft'); // => 6 ft +qty.toPrec('2'); // => 6 ft + +qty = Qty('6.3782 m'); +qty.toPrec('dm'); // => 6.4 m +qty.toPrec('cm'); // => 6.38 m +qty.toPrec('mm'); // => 6.378 m +qty.toPrec('5 cm'); // => 6.4 m +qty.toPrec('10 m'); // => 10 m +qty.toPrec(0.1); // => 6.3 m + +qty = Qty('1.146 MPa'); +qty.toPrec('0.1 bar'); // => 1.15 MPa + +qty = Qty('1.146 MPa'); +qty.toString(); // => '1.146 MPa' + +qty = Qty('1.146 MPa'); +qty.toString('bar'); // => '11.46 bar' +qty.to('bar').toString(); // => '11.46 bar' + +qty = Qty('1.146 MPa'); +qty.toPrec(0.1).toString(); // => '1.1 MPa' +qty.to('bar').toPrec(0.1).toString(); // => '11.5 bar' + +qty = Qty('1.1234 m'); +qty.format(); // same units, default formatter => '1.234 m' +qty.format('cm'); // converted to 'cm', default formatter => '123.45 cm' + +var configurableRoundingFormatter = function (maxDecimals: number) { + return function (scalar: number, units: string) { + var pow = Math.pow(10, maxDecimals); + var rounded = Math.round(scalar * pow) / pow; + + return rounded + ' ' + units; + }; +}; + +qty = Qty('1.1234 m'); + +// same units, custom formatter => '1.12 m' +qty.format(configurableRoundingFormatter(2)); + +// convert to 'cm', custom formatter => '123.4 cm' +qty.format('cm', configurableRoundingFormatter(1)); + +Qty.formatter = configurableRoundingFormatter(2); +qty = Qty('1.1234 m'); +qty.format(); // same units, current default formatter => '1.12 m' + +Qty('37 tempC').to('tempF'); // => 98.6 tempF + +let scalar: number = 42; + +Qty('100 tempC').add('10 degC'); // 110 tempC +Qty('100 tempC').sub('10 degC'); // 90 tempC +Qty('100 tempC').add('50 tempC'); // throws error +Qty('100 tempC').sub('50 tempC'); // 50 degC +Qty('50 tempC').sub('100 tempC'); // -50 degC +Qty('100 tempC').mul(scalar); // 100*scalar tempC +Qty('100 tempC').div(scalar); // 100/scalar tempC +Qty('100 tempC').mul(qty); // throws error +Qty('100 tempC').div(qty); // throws error +Qty('100 tempC*unit'); // throws error +Qty('100 tempC/unit'); // throws error +Qty('100 unit/tempC'); // throws error +Qty('100 tempC').inverse(); // throws error + +Qty('100 tempC').to('degC'); // => 100 degC + +Qty('100 degC').to('tempC'); // => -173.15 tempC + +Qty('0 tempC').add('100 degC'); // => 100 tempC + +try { + // code triggering an error inside JS-quantities +} catch (e) { + if (e instanceof Qty.Error) { + // ... + } else { + // ... + } +} + +// From project spec + +describe("js-quantities", function () { + "use strict"; + + describe("initialization", function () { + it("should create unit only", function () { + var qty = Qty("m"); + expect(qty.numerator).toEqual([""]); + expect(qty.scalar).toBe(1); + }); + + it("should create unitless", function () { + var qty = Qty("1"); + expect(qty.toFloat()).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + qty = Qty("1.5"); + expect(qty.toFloat()).toBe(1.5); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create unitless from numbers", function () { + var qty = Qty(1.5); + expect(qty.toFloat()).toBe(1.5); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create from numbers with explicit units", function () { + var qty = Qty(1.5, "m"); + expect(qty.scalar).toBe(1.5); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("temperatures should have base unit in kelvin", function () { + var qty = Qty("1 tempK").toBase(); + expect(qty.scalar).toBe(1); + expect(qty.units()).toBe("tempK"); + + qty = Qty("1 tempR").toBase(); + expect(qty.scalar).toBe(5 / 9); + expect(qty.units()).toBe("tempK"); + + qty = Qty("0 tempC").toBase(); + expect(qty.scalar).toBe(273.15); + expect(qty.units()).toBe("tempK"); + + qty = Qty("0 tempF").toBase(); + expect(qty.scalar).toBeCloseTo(255.372, 3); + expect(qty.units()).toBe("tempK"); + }); + + it("temperature degrees should have base unit in kelvin", function () { + var qty = Qty("1 degK").toBase(); + expect(qty.scalar).toBe(1); + expect(qty.units()).toBe("degK"); + + qty = Qty("1 degR").toBase(); + expect(qty.scalar).toBe(5 / 9); + expect(qty.units()).toBe("degK"); + + qty = Qty("1 degC").toBase(); + expect(qty.scalar).toBe(1); + expect(qty.units()).toBe("degK"); + + qty = Qty("1 degF").toBase(); + expect(qty.scalar).toBe(5 / 9); + expect(qty.units()).toBe("degK"); + }); + + it("should not create temperatures below absolute zero", function () { + expect(function () { Qty("-1 tempK"); }).toThrow("Temperatures must not be less than absolute zero"); + expect(function () { Qty("-273.16 tempC"); }).toThrow("Temperatures must not be less than absolute zero"); + expect(function () { Qty("-459.68 tempF"); }).toThrow("Temperatures must not be less than absolute zero"); + expect(function () { Qty("-1 tempR"); }).toThrow("Temperatures must not be less than absolute zero"); + + var qty = Qty("1 tempK"); + expect(function () { qty.mul("-1"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("0 tempK"); + expect(function () { qty.sub("1 degK"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("-273.15 tempC"); + expect(function () { qty.sub("1 degC"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("-459.67 tempF"); + expect(function () { qty.sub("1 degF"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("0 tempR"); + expect(function () { qty.sub("1 degR"); }).toThrow("Temperatures must not be less than absolute zero"); + }); + + it("should create simple", function () { + var qty = Qty("1m"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create negative", function () { + var qty = Qty("-1m"); + expect(qty.scalar).toBe(-1); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create compound", function () { + var qty = Qty("1 N*m"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create pressure units in term of height of water", function () { + var qty = Qty("1 inH2O"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + + qty = Qty("1 cmH2O"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + }); + + it("should create with denominator", function () { + var qty = Qty("1 m/s"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual([""]); + }); + + it("should create with denominator only", function () { + var qty = Qty("1 /s"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual([""]); + + qty = Qty("1 1/s"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual([""]); + + qty = Qty("1 s^-1"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual([""]); + }); + + it("should create with powers", function () { + var qty = Qty("1 m^2/s^2"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["", ""]); + qty = Qty("1 m^2 kg^2 J^2/s^2"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", "", "", "", "", ""]); + expect(qty.denominator).toEqual(["", ""]); + qty = Qty("1 m^2/s^2*J^3"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["", "", "", "", ""]); + }); + + it("should create with zero power", function () { + var qty = Qty("1 m^0"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create with negative powers", function () { + var qty = Qty("1 m^2 s^-2"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["", ""]); + expect(qty.same(Qty("1 m^2/s^2"))).toBe(true); + }); + + it("should accept powers without ^ syntax (simple)", function () { + var qty1 = Qty("1 m2"); + var qty2 = Qty("1 m^2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should accept powers without ^ syntax (negative power)", function () { + var qty1 = Qty("1 m-2"); + var qty2 = Qty("1 m^-2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should accept powers without ^ syntax (compound)", function () { + var qty1 = Qty("1 m^2 kg^2 J^2/s^2"); + var qty2 = Qty("1 m2 kg2 J2/s2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should accept powers without ^ syntax (compound and negative power)", function () { + var qty1 = Qty("1 m^2 kg^2 J^2 s^-2"); + var qty2 = Qty("1 m2 kg2 J2 s-2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should throw 'Unit not recognized' error when initializing with an invalid unit", function () { + expect(function () { Qty("aa"); }).toThrow("Unit not recognized"); + expect(function () { Qty("m/aa"); }).toThrow("Unit not recognized"); + expect(function () { Qty("m-"); }).toThrow("Unit not recognized"); + expect(function () { Qty("N*m"); }).not.toThrow("Unit not recognized"); + // mm is millimeter, but mmm is not a valid unit + expect(function () { Qty("mmm"); }).toThrow("Unit not recognized"); + }); + + it("should accept empty string as unitless 1", function () { + expect(Qty("").same(Qty("1"))).toBe(true); + expect(Qty(" ").same(Qty("1"))).toBe(true); + }); + + it("should throw error when passing NaN", function () { + expect( + function () { Qty(NaN); } + ).toThrow("Only string, number or quantity accepted as single " + + "initialization value"); + }); + + it("should throw 'Unit not recognized' error when initializing with an invalid unit and a 0 exponent", function () { + expect(function () { Qty("3p0"); }).toThrow("Unit not recognized"); + expect(function () { Qty("3p-0"); }).toThrow("Unit not recognized"); + }); + + it("should set baseScalar", function () { + var qty = Qty("0.018 MPa"); + expect(qty.baseScalar).toBe(18000); + + qty = Qty("66 cm3"); + expect(qty.baseScalar).toBe(0.000066); + }); + + it("should keep init value as is", function () { + var initValue = " 66 cm3 "; + var qty = Qty(initValue); + + expect(qty.initValue).toEqual(initValue); + }); + + it("should allow whitespace-wrapped value", function () { + expect(function () { Qty(" 2 MPa "); }).not.toThrow(); + }); + + it("should allow whitespaces between sign and scalar", function () { + var qty = Qty("- 1m"); + + expect(qty.scalar).toEqual(-1); + expect(qty.units()).toEqual("m"); + }); + + it("should throw an error when parsing negative quantity " + + "with no scalar", function () { + expect(function () { Qty("-m"); }).toThrow("Unit not recognized"); + }); + }); + + describe("isCompatible", function () { + it("should return true with compatible quantities", function () { + var qty1 = Qty("1 m*kg/s"); + var qty2 = Qty("1 in*pound/min"); + expect(qty1.isCompatible(qty2)).toBe(true); + qty2 = Qty("1 in/min"); + expect(qty1.isCompatible(qty2)).toBe(false); + }); + + it("should return true with dimensionless quantities", function () { + var qty1 = Qty("1"); + var qty2 = Qty("2"); + expect(qty1.isCompatible(qty2)).toBe(true); + }); + }); + + describe("conversion", function () { + it("should convert to base units", function () { + var qty = Qty("100 cm"); + expect(qty.toBase().scalar).toBe(1); + expect(qty.toBase().units()).toBe("m"); + qty = Qty("10 cm"); + expect(qty.toBase().scalar).toBe(0.1); + expect(qty.toBase().units()).toBe("m"); + qty = Qty("0.3 mm^2 ms^-2"); + expect(qty.toBase().scalar).toBe(0.3); + expect(qty.toBase().units()).toBe("m2/s2"); + }); + + it("should convert to compatible units", function () { + var qty = Qty("10 cm"); + expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048)); + qty = Qty("2m^3"); + expect(qty.to("l").scalar).toBe(2000); + + qty = Qty("10 cm"); + expect(qty.to(Qty("m")).scalar).toBe(0.1); + expect(qty.to(Qty("20m")).scalar).toBe(0.1); + + qty = Qty("1 m3"); + expect(qty.to("cm3").scalar).toBe(1000000); + + qty = Qty("1 cm3"); + expect(qty.to("mm3").scalar).toBe(1000); + + qty = Qty("550 cm3"); + expect(qty.to("cm^3").scalar).toBe(550); + + qty = Qty("0.000773 m3"); + expect(qty.to("cm^3").scalar).toBe(773); + }); + + describe('percents', function () { + it("should convert from % to unitless", function () { + expect(Qty("10 %").to("").same(Qty("0.1"))).toBe(true); + }); + + it("should convert from unitless to %", function () { + expect(Qty("0.1").to("%").same(Qty("10 %"))).toBe(true); + }); + }); + + it("should convert temperatures to compatible units", function () { + var qty = Qty("0 tempK"); + expect(qty.to("tempC").scalar).toBe(-273.15); + + qty = Qty("0 tempF"); + expect(qty.to("tempK").scalar).toBeCloseTo(255.372, 3); + + qty = Qty("32 tempF"); + expect(qty.to("tempC").scalar).toBe(0); + + qty = Qty("0 tempC"); + expect(qty.to("tempF").scalar).toBeCloseTo(32, 10); + }); + + it("should convert temperature degrees to compatible units", function () { + var qty = Qty("0 degK"); + expect(qty.to("degC").scalar).toBe(0); + + qty = Qty("1 degK/s"); + expect(qty.to("degC/min").scalar).toBe(60); + + qty = Qty("100 cm/degF"); + expect(qty.to("m/degF").scalar).toBe(1); + + qty = Qty("10 degC"); + expect(qty.to("degF").scalar).toBe(18); + }); + + it("should convert temperature degrees to temperatures", function () { + // according to ruby-units, deg -> temp conversion adds the degress to 0 kelvin before converting + var qty = Qty("100 degC"); + expect(qty.to("tempC").scalar).toBeCloseTo(-173.15, 10); + + qty = Qty("273.15 degC"); + expect(qty.to("tempC").scalar).toBe(0); + + qty = Qty("460.67 degF"); + expect(qty.to("tempF").scalar).toBeCloseTo(1, 10); + }); + + it("should convert temperatures to temperature degrees", function () { + // according to ruby-units, temp -> deg conversion always uses the 0 relative degrees + var qty = Qty("100 tempC"); + expect(qty.to("degC").scalar).toBe(100); + + qty = Qty("0 tempK"); + expect(qty.to("degC").scalar).toBe(0); + + qty = Qty("0 tempF"); + expect(qty.to("degK").scalar).toBe(0); + + qty = Qty("18 tempF"); + expect(qty.to("degC").scalar).toBe(10); + + qty = Qty("10 tempC"); + expect(qty.to("degF").scalar).toBe(18); + }); + + it("should calculate inverses", function () { + var qty = Qty("1 ohm"); + var result = qty.to("siemens"); + expect(result.scalar).toBe(1); + expect(result.kind()).toBe("conductance"); + + qty = Qty("10 ohm"); + result = qty.to("siemens"); + expect(result.scalar).toBe(0.1); + expect(result.kind()).toBe("conductance"); + + qty = Qty("10 siemens"); + result = qty.to("ohm"); + expect(result.scalar).toBe(0.1); + expect(result.kind()).toBe("resistance"); + + qty = Qty("10 siemens"); + result = qty.inverse(); + expect(result.eq(".1 ohm")).toBe(true); + expect(result.kind()).toBe("resistance"); + + // cannot inverse a quantity with a 0 scalar + qty = Qty("0 ohm"); + expect(function () { qty.inverse(); }).toThrow("Divide by zero"); + + qty = Qty("10 ohm").inverse(); + result = qty.to("S"); + expect(result.scalar).toBe(0.1); + expect(result.kind()).toBe("conductance"); + + qty = Qty("12 in").inverse(); + // TODO: Swap toBeCloseTo with toBe once divSafe is fixed + expect(qty.to("ft").scalar).toBeCloseTo(1, 10); + }); + + it("should return itself if target units are the same", function () { + var qty = Qty("123 cm3"); + + expect(qty.to("cm3")).toBe(qty); + expect(qty.to("cm^3")).toBe(qty); + + qty = Qty("123 mcg"); + expect(qty.to("ug")).toBe(qty); + }); + + it("should be cached", function () { + var qty = Qty("100 m"), + converted = qty.to("ft"); + + expect(qty.to("ft") === converted).toBe(true); + }); + }); + + describe("comparison", function () { + it("should return true when comparing equal quantities", function () { + var qty1 = Qty("1cm"); + var qty2 = Qty("10mm"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should compare compatible quantities", function () { + var qty1 = Qty("1cm"); + var qty2 = Qty("1mm"); + var qty3 = Qty("10mm"); + var qty4 = Qty("28A"); + expect(qty1.compareTo(qty2)).toBe(1); + expect(qty2.compareTo(qty1)).toBe(-1); + expect(qty1.compareTo(qty3)).toBe(0); + expect(function () { qty1.compareTo(qty4); }).toThrow("Incompatible units"); + + expect(qty1.lt(qty2)).toBe(false); + expect(qty1.lt(qty3)).toBe(false); + expect(qty1.lte(qty3)).toBe(true); + expect(qty1.gte(qty3)).toBe(true); + expect(qty1.gt(qty2)).toBe(true); + expect(qty2.gt(qty1)).toBe(false); + }); + + it("should compare identical quantities", function () { + var qty1 = Qty("1cm"); + var qty2 = Qty("1cm"); + var qty3 = Qty("10mm"); + expect(qty1.same(qty2)).toBe(true); + expect(qty1.same(qty3)).toBe(false); + }); + + it("should accept strings as parameter", function () { + var qty = Qty("1 cm"); + expect(qty.lt("0.5 cm")).toBe(false); + expect(qty.lte("1 cm")).toBe(true); + expect(qty.gte("3 mm")).toBe(true); + expect(qty.gt("5 m")).toBe(false); + }); + + }); + + describe("non-ASCII character", function () { + describe("µ", function () { + it("should be supported as prefix", function () { + // µ as greek letter + expect(Qty("1 \u03BCm").eq(Qty("1 um"))).toBe(true); + // µ as micro sign + expect(Qty("1 \u00B5m").eq(Qty("1 um"))).toBe(true); + }); + }); + + describe("Ω", function () { + it("should be accepted as unit for ohm", function () { + // Ω as greek letter + expect(Qty("1 \u03A9").eq(Qty("1 ohm"))).toBe(true); + // Ω as ohm sign + expect(Qty("1 \u2126").eq(Qty("1 ohm"))).toBe(true); + }); + }); + }); + + describe("math", function () { + + it("should add quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + expect(qty1.add(qty2).scalar).toBe(5.5); + + expect(qty1.add("3m").scalar).toBe(5.5); + + qty2 = Qty("3cm"); + var result = qty1.add(qty2); + expect(result.scalar).toBe(2.53); + expect(result.units()).toBe("m"); + + result = qty2.add(qty1); + expect(result.scalar).toBe(253); + expect(result.units()).toBe("cm"); + + // make sure adding 2 of the same non-base units work + result = Qty("5cm").add("3cm"); + expect(result.scalar).toBe(8); + expect(result.units()).toBe("cm"); + }); + + it("should fail to add unlike quantities", function () { + var qty1 = Qty("3m"); + var qty2 = Qty("2s"); + expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); + }); + + it("should fail to add inverse quantities", function () { + var qty1 = Qty("10S"); + var qty2 = qty1.inverse(); + expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); + + qty1 = Qty("10S"); + qty2 = Qty("0.1ohm"); + expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); + }); + + it("should subtract quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + expect(qty1.sub(qty2).scalar).toBe(-0.5); + + expect(qty1.sub("2m").scalar).toBe(0.5); + expect(qty1.sub("-2m").scalar).toBe(4.5); + + qty2 = Qty("3cm"); + var result = qty1.sub(qty2); + expect(result.scalar).toBe(2.47); + expect(result.units()).toBe("m"); + + result = qty2.sub(qty1); + expect(result.scalar).toBe(-247); + expect(result.units()).toBe("cm"); + }); + + it("should fail to subtract unlike quantities", function () { + var qty1 = Qty("3m"); + var qty2 = Qty("2s"); + expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); + }); + + it("should fail to subtract inverse quantities", function () { + var qty1 = Qty("10S"); + var qty2 = qty1.inverse(); + expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); + + qty1 = Qty("10S"); + qty2 = Qty("0.1ohm"); + expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); + }); + + it("should multiply quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + var result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + expect(result.units()).toBe("m2"); + expect(result.kind()).toBe("area"); + + qty2 = Qty("3cm"); + result = qty1.mul(qty2); + expect(result.scalar).toBe(0.075); + expect(result.units()).toBe("m2"); + + result = qty2.mul(qty1); + expect(result.scalar).toBe(750); + expect(result.units()).toBe("cm2"); + + result = qty1.mul(3.5); + expect(result.scalar).toBe(8.75); + expect(result.units()).toBe("m"); + + result = qty1.mul(0); + expect(result.scalar).toBe(0); + expect(result.units()).toBe("m"); + + result = qty1.mul(Qty("0m")); + expect(result.scalar).toBe(0); + expect(result.units()).toBe("m2"); + + qty2 = Qty("1.458 m"); + result = qty1.mul(qty2); + expect(result.scalar).toBe(3.645); + expect(result.units()).toBe("m2"); + }); + + it("should multiply unlike quantities", function () { + var qty1 = Qty("2.5 m"); + var qty2 = Qty("3 N"); + + var result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + + qty1 = Qty("2.5 m^2"); + qty2 = Qty("3 kg/m^2"); + + result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + expect(result.units()).toBe("kg"); + }); + + it("should multiply inverse quantities", function () { + var qty1 = Qty("10S"); + var qty2 = Qty(".5S").inverse(); // 2/S + var qty3 = qty1.inverse(); // .1/S + + var result = qty1.mul(qty2); + expect(result.scalar).toBe(20); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + // swapping operands should give the same outcome + result = qty2.mul(qty1); + expect(result.scalar).toBe(20); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + + result = qty1.mul(qty3); + expect(result.scalar).toBe(1); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + // swapping operands should give the same outcome + result = qty3.mul(qty1); + expect(result.scalar).toBe(1); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + }); + + it("should divide quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + var qty3 = Qty("0m"); + + expect(function () { qty1.div(qty3); }).toThrow("Divide by zero"); + expect(function () { qty1.div(0); }).toThrow("Divide by zero"); + expect(qty3.div(qty1).scalar).toBe(0); + + var result = qty1.div(qty2); + expect(result.scalar).toBe(2.5 / 3); + expect(result.units()).toBe(""); + expect(result.kind()).toBe("unitless"); + + var qty4 = Qty("3cm"); + result = qty1.div(qty4); + expect(result.scalar).toBe(2.5 / 0.03); + expect(result.units()).toBe(""); + + result = qty4.div(qty1); + expect(result.scalar).toBe(0.012); + expect(result.units()).toBe(""); + + result = qty1.div(3.5); + expect(result.scalar).toBe(2.5 / 3.5); + expect(result.units()).toBe("m"); + }); + + it("should divide unlike quantities", function () { + var qty1 = Qty("7.5kg"); + var qty2 = Qty("2.5m^2"); + + var result = qty1.div(qty2); + expect(result.scalar).toBe(3); + expect(result.units()).toBe("kg/m2"); + }); + + it("should divide inverse quantities", function () { + var qty1 = Qty("10 S"); + var qty2 = Qty(".5 S").inverse(); // 2/S + var qty3 = qty1.inverse(); // .1/S + + var result = qty1.div(qty2); + expect(result.scalar).toBe(5); + expect(result.units()).toBe("S2"); + + result = qty2.div(qty1); + expect(result.scalar).toBe(0.2); + expect(result.units()).toBe("1/S2"); + + result = qty1.div(qty3); + expect(result.scalar).toBe(100); + expect(result.units()).toBe("S2"); + + result = qty3.div(qty1); + expect(result.scalar).toBe(0.01); + expect(result.units()).toBe("1/S2"); + }); + + }); + + describe("math with temperatures", function () { + + it("should add temperature degrees", function () { + var qty = Qty("2degC"); + expect(qty.add("3degF").scalar).toBeCloseTo(11 / 3, 10); + expect(qty.add("-1degC").scalar).toBe(1); + + qty = Qty("2 degC"); + var result = qty.add("2 degF"); + expect(result.scalar).toBe(28 / 9); + expect(result.units()).toBe("degC"); + + qty = Qty("2degK"); + result = qty.add("3degC"); + expect(result.scalar).toBe(5); + expect(result.units()).toBe("degK"); + + qty = Qty("2degC"); + result = qty.add("2degK"); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("degC"); + }); + + it("should not add two temperatures", function () { + var qty = Qty("2tempC"); + expect(function () { qty.add("1 tempF"); }).toThrow("Cannot add two temperatures"); + expect(function () { qty.add("1 tempC"); }).toThrow("Cannot add two temperatures"); + }); + + it("should add temperatures to degrees", function () { + var qty = Qty("2degC"); + var result = qty.add("3tempF"); + expect(result.scalar).toBe(33 / 5); + expect(result.units()).toBe("tempF"); + + result = qty.add("-1tempC"); + expect(result.scalar).toBe(1); + expect(result.units()).toBe("tempC"); + + qty = Qty("2 tempC"); + result = qty.add("2 degF"); + expect(result.scalar).toBe(28 / 9); + expect(result.units()).toBe("tempC"); + }); + + it("should subtract degrees from degrees", function () { + var qty = Qty("2degC"); + expect(qty.sub("1.5degK").scalar).toBe(0.5); + expect(qty.sub("-2degC").scalar).toBe(4); + expect(qty.sub("1degF").scalar).toBe(2 - 5 / 9); + expect(qty.sub("-1degC").scalar).toBe(3); + + var result = qty.sub("degC"); + expect(result.scalar).toBe(1); + expect(result.units()).toBe("degC"); + }); + + it("should subtract degrees from temperatures", function () { + var qty = Qty("2tempC"); + expect(qty.sub("1.5degK").scalar).toBe(0.5); + expect(qty.sub("-2degC").scalar).toBe(4); + expect(qty.sub("1degF").scalar).toBe(2 - 5 / 9); + expect(qty.sub("-1degC").scalar).toBe(3); + + var result = qty.sub("degC"); + expect(result.scalar).toBe(1); + expect(result.units()).toBe("tempC"); + }); + + it("should subtract temperatures from temperatures", function () { + var qty = Qty("2tempC"); + + var result = qty.sub("1.5tempK"); + expect(result.scalar).toBe(273.65); + expect(result.units()).toBe("degC"); + + result = qty.sub("-2tempC"); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("degC"); + + result = qty.sub("32tempF"); + expect(result.scalar).toBe(2); + expect(result.units()).toBe("degC"); + }); + + it("should not subtract temperatures from degrees", function () { + var qty = Qty("2degC"); + expect(function () { qty.sub("1 tempF"); }).toThrow("Cannot subtract a temperature from a differential degree unit"); + expect(function () { qty.sub("1 tempC"); }).toThrow("Cannot subtract a temperature from a differential degree unit"); + }); + + it("should multiply temperature degrees", function () { + var qty = Qty("2degF"); + var result = qty.mul(3); + expect(result.scalar).toBe(6); + expect(result.units()).toBe("degF"); + + result = qty.mul("3degF"); + expect(result.scalar).toBe(6); + expect(result.units()).toBe("degF2"); + + // TODO: Should we convert degrees ("2 degK" to "degC") before we do the math? + qty = Qty("2degC"); + result = qty.mul("2degK"); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("degC*degK"); + + qty = Qty("2degC"); + result = qty.mul("degF"); + expect(result.scalar).toBe(2); + expect(result.units()).toBe("degC*degF"); + }); + + it("should not multiply temperatures except by scalar", function () { + var qty = Qty("2tempF"); + expect(function () { qty.mul("1 tempC"); }).toThrow("Cannot multiply by temperatures"); + expect(function () { qty.mul("1 degC"); }).toThrow("Cannot multiply by temperatures"); + expect(function () { Qty("1 tempC*s"); }).toThrow("Cannot multiply by temperatures"); + + var result = qty.mul(2); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("tempF"); + + result = Qty("2").mul(qty); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("tempF"); + }); + + it("should multiply temperature degrees with unlike quantities", function () { + var qty1 = Qty("2.5 degF"); + var qty2 = Qty("3 m"); + + var result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + + qty1 = Qty("2.5 degF"); + qty2 = Qty("3 kg/degF"); + + result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + expect(result.units()).toBe("kg"); + }); + + it("should divide temperature degrees with unlike quantities", function () { + var qty1 = Qty("7.5degF"); + var qty2 = Qty("2.5m^2"); + + var result = qty1.div(qty2); + expect(result.scalar).toBe(3); + expect(result.units()).toBe("degF/m2"); + }); + + it("should divide temperature degree quantities", function () { + var qty = Qty("2.5 degF"); + + expect(function () { qty.div("0 degF"); }).toThrow("Divide by zero"); + expect(function () { qty.div(0); }).toThrow("Divide by zero"); + expect(Qty("0 degF").div(qty).scalar).toBe(0); + expect(Qty("0 degF").div(qty).units()).toBe(""); + + var result = qty.div("3 degF"); + expect(result.scalar).toBe(2.5 / 3); + expect(result.units()).toBe(""); + expect(result.kind()).toBe("unitless"); + + result = qty.div(3); + expect(result.scalar).toBe(2.5 / 3); + expect(result.units()).toBe("degF"); + expect(result.kind()).toBe("temperature"); + + // TODO: Should we convert "2 degC" to "degF" before we do the math? + result = qty.div("2 degC"); + expect(result.scalar).toBe(1.25); + expect(result.units()).toBe("degF/degC"); + }); + + it("should not divide with temperatures except by scalar", function () { + expect(function () { Qty("tempF").div("1 tempC"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("tempF").div("1 degC"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("2").div("tempF"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("2 tempF/s"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("2 s/tempF"); }).toThrow("Cannot divide with temperatures"); + + // inverse is division: 1/x + expect(function () { Qty("tempF").inverse(); }).toThrow("Cannot divide with temperatures"); + + var result = Qty("4 tempF").div(2); + expect(result.scalar).toBe(2); + expect(result.units()).toBe("tempF"); + }); + + }); + + describe("errors", function () { + it("should be instance of Qty.Error", function () { + try { + Qty("aa"); + } catch (e) { + expect(e instanceof Qty.Error).toBeTruthy(); + } + }); + }); + + describe("utility methods", function () { + + it("should accept string as parameter for compatibility tests", function () { + var qty = Qty("1 mm"); + + expect(qty.isCompatible("2 mm")).toBe(true); + expect(qty.isCompatible("2 mm^3")).toBe(false); + }); + + it("should return kind", function () { + var qty = Qty("1 mm"); + expect(qty.kind()).toBe("length"); + + qty = Qty("1 N"); + expect(qty.kind()).toBe("force"); + }); + + it("should know if a quantity is in base units", function () { + var qty = Qty("100 cm"); + expect(qty.isBase()).toBe(false); + + qty = Qty("1m"); + expect(qty.isBase()).toBe(true); + }); + + it("should return unit part of quantities", function () { + var qty = Qty("1"); + expect(qty.units()).toBe(""); + qty = Qty("1 /s"); + expect(qty.units()).toBe("1/s"); + qty = Qty("100 cm"); + expect(qty.units()).toBe("cm"); + qty = Qty("100 cm/s"); + expect(qty.units()).toBe("cm/s"); + qty = Qty("1 cm^2"); + expect(qty.units()).toBe("cm2"); + qty = Qty("1 cm^2/s^2"); + expect(qty.units()).toBe("cm2/s2"); + qty = Qty("1 cm^2*J^3/s^2*A^2"); + expect(qty.units()).toBe("cm2*J3/s2*A2"); + }); + + }); + + describe("toString", function () { + it("should generate readable human output", function () { + var qty = Qty("2m"); + expect(qty.toString()).toBe("2 m"); + expect(qty.toString("cm")).toBe("200 cm"); + expect(qty.toString("km")).toBe("0.002 km"); + expect(function () { qty.toString("A"); }).toThrow("Incompatible units"); + + qty = Qty("24.5m/s"); + expect(qty.toString()).toBe("24.5 m/s"); + expect(function () { qty.toString("m"); }).toThrow("Incompatible units"); + expect(qty.toString("km/h")).toBe("88.2 km/h"); + + qty = Qty("254kg/m^2"); + expect(qty.toString()).toBe("254 kg/m2"); + + qty = Qty("2"); + expect(qty.toString()).toBe("2"); + }); + + it("should round readable human output when max decimals is specified", function () { + var qty = (Qty("2m")).div(3); + expect(qty.toString("cm", 2)).toBe("66.67 cm"); + + qty = Qty("2.8m"); + expect(qty.toString("m", 0)).toBe("3 m"); + expect(qty.toString("cm", 0)).toBe("280 cm"); + qty = Qty("2.818m"); + expect(qty.toString("cm", 0)).toBe("282 cm"); + }); + + it("should round to max decimals", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.toString(3)).toBe("2.988 m"); + expect(qty.toString(0)).toBe("3 m"); + }); + + it("should round according to precision passed as quantity", function () { + var qty = Qty("5.17 ft"); + + expect(qty.toString(Qty("ft"))).toBe("5 ft"); + expect(qty.toString(Qty("2 ft"))).toBe("6 ft"); + expect(qty.toString(Qty("0.5 ft"))).toBe("5 ft"); + expect(qty.toString(Qty("0.1 ft"))).toBe("5.2 ft"); + expect(qty.toString(Qty("0.05 ft"))).toBe("5.15 ft"); + expect(qty.toString(Qty("0.01 ft"))).toBe("5.17 ft"); + expect(qty.toString(Qty("0.0001 ft"))).toBe("5.17 ft"); + }); + + it("should return same output with successive calls", function () { + var qty = Qty("123 cm3"); + expect(qty.toString("cm3", 0)).toBe("123 cm3"); + expect(qty.toString("cm3", 0)).toBe("123 cm3"); + }); + + it("should return identical output when called with no parameters or same units", function () { + var qty = Qty("123 cm3"); + expect(qty.toString()).toBe(qty.toString("cm3")); + }); + + }); + + describe("format", function () { + describe("provided default formatter", function () { + it("should be applied to output", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.format()).toBe("2.987654321 m"); + }); + }); + + describe("custom formatter", function () { + var roundingFormatter = function (maxDecimals: number) { + return function (scalar: number, units: string) { + var pow = Math.pow(10, maxDecimals); + var rounded = Math.round(scalar * pow) / pow; + + return rounded + " " + units; + }; + }; + + it("should be applied to output", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.format(roundingFormatter(3))).toBe("2.988 m"); + expect(qty.format(roundingFormatter(0))).toBe("3 m"); + }); + + it("should be applied after conversion to target units", function () { + var qty = (Qty("2m")).div(3); + expect(qty.format("cm", roundingFormatter(2))).toBe("66.67 cm"); + + var intRoundingFormatter = roundingFormatter(0); + qty = Qty("2.8m"); + expect(qty.format("m", intRoundingFormatter)).toBe("3 m"); + expect(qty.format("cm", intRoundingFormatter)).toBe("280 cm"); + qty = Qty("2.818m"); + expect(qty.format("cm", intRoundingFormatter)).toBe("282 cm"); + }); + + describe("globally set as default formatter", function () { + var previousFormatter: Qty.Formatter; + + beforeEach(function () { + previousFormatter = Qty.formatter; + Qty.formatter = roundingFormatter(3); + }); + + afterEach(function () { + // Restore previous formatter + Qty.formatter = previousFormatter; + }); + + it("should be applied when no formatter is passed", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.format()).toBe("2.988 m"); + }); + }); + }); + }); + + describe("precision rounding", function () { + it("should round according to precision passed as quantity with same units", function () { + var qty = Qty("5.17 ft"); + + expect(qty.toPrec(Qty("ft")).toString()).toBe("5 ft"); + expect(qty.toPrec(Qty("2 ft")).toString()).toBe("6 ft"); + expect(qty.toPrec(Qty("10 ft")).toString()).toBe("10 ft"); + expect(qty.toPrec(Qty("0.5 ft")).toString()).toBe("5 ft"); + expect(qty.toPrec(Qty("0.1 ft")).toString()).toBe("5.2 ft"); + expect(qty.toPrec(Qty("0.05 ft")).toString()).toBe("5.15 ft"); + expect(qty.toPrec(Qty("0.01 ft")).toString()).toBe("5.17 ft"); + expect(qty.toPrec(Qty("0.0001 ft")).toString()).toBe("5.17 ft"); + expect(qty.toPrec(Qty("0.25 ft")).toString()).toBe("5.25 ft"); + }); + + it("should allow string as precision parameter", function () { + var qty = Qty("5.17 ft"); + + expect(qty.toPrec("ft").toString()).toBe("5 ft"); + expect(qty.toPrec("0.5 ft").toString()).toBe("5 ft"); + expect(qty.toPrec("0.05 ft").toString()).toBe("5.15 ft"); + }); + + it("should round according to precision passed as quantity with different prefixes", function () { + var qty = Qty("6.3782 m"); + + expect(qty.toPrec(Qty("dm")).toString()).toBe("6.4 m"); + expect(qty.toPrec(Qty("cm")).toString()).toBe("6.38 m"); + expect(qty.toPrec(Qty("mm")).toString()).toBe("6.378 m"); + + expect(qty.toPrec(Qty("5 cm")).toString()).toBe("6.4 m"); + }); + + it("should round according to precision passed as quantity with different compatible units", function () { + var qty = Qty("1.146 MPa"); + expect(qty.toPrec(Qty("0.1 bar")).toString()).toBe("1.15 MPa"); + expect(qty.toPrec(Qty("0.01 MPa")).toString()).toBe("1.15 MPa"); + expect(qty.toPrec(Qty("dbar")).toString()).toBe("1.15 MPa"); + + // Tests below are mainly a safety net because not sure if there is + // any usefulness to do things like that + qty = Qty("5.171234568 ft"); + expect(qty.toPrec(Qty("m")).toString()).toBe("6.561679790026248 ft"); + expect(qty.toPrec(Qty("dm")).toString()).toBe("5.249343832020998 ft"); + expect(qty.toPrec(Qty("cm")).toString()).toBe("5.183727034120736 ft"); + expect(qty.toPrec(Qty("mm")).toString()).toBe("5.170603674540684 ft"); + }); + }); + + describe("mulSafe", function () { + it("should multiply while trying to avoid numerical errors", function () { + expect(Qty.mulSafe(0.1, 0.1)).toBe(0.01); + expect(Qty.mulSafe(1e-11, 123.456789)).toBe(1.23456789e-9); + expect(Qty.mulSafe(6e-12, 100000)).toBe(6e-7); + }); + }); + + describe("divSafe", function () { + it("should divide while trying to avoid numerical errors", function () { + expect(Qty.divSafe(0.000773, 0.000001)).toBe(773); + // TODO uncomment and fix + //expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2); + }); + }); + + describe("Qty.parse", function () { + it("should not throw if parsed argument is a string", function () { + expect(function () { Qty.parse("foo"); }).not.toThrow("Argument should be a string"); + }); + + it("should return parsed quantity when passing a valid quantity", function () { + expect((Qty.parse("2.5 m") instanceof Qty)).toBe(true); + }); + + it("should return null when passing an invalid quantity", function () { + expect(Qty.parse("aa")).toBeNull(); + }); + }); + + describe("Qty.swiftConverter", function () { + it("should return a function", function () { + expect(typeof Qty.swiftConverter("m/h", "ft/s")).toBe("function"); + }); + + it("should throw when passing incompatible units", function () { + expect(function () { Qty.swiftConverter("m", "s"); }).toThrow("Incompatible units"); + }); + + describe("converter", function () { + describe("single value", function () { + it("should convert value", function () { + // TODO Same test but with m/h -> ft/s triggers rounding issue + // (For the sake of speed, converter does not check and fix rounding issues) + var converter = Qty.swiftConverter("m/h", "m/s"); + + expect(converter(2500)).toEqual(Qty("2500 m/h").to("m/s").scalar); + }); + + it("should returned value unchanged when units are identical", function () { + var converter = Qty.swiftConverter("m/h", "m/h"); + + expect(converter(2500)).toEqual(2500); + }); + + it("should convert temperatures", function () { + var converter = Qty.swiftConverter("tempF", "tempC"); + + expect(converter(32)).toEqual(0); + }); + + it("should convert degrees", function () { + var converter = Qty.swiftConverter("degC", "degF"); + + expect(converter(10)).toEqual(18); + }); + }); + + describe("array of values", function () { + it("should be converted", function () { + var converter = Qty.swiftConverter("MPa", "bar"), + values = [250, 10, 15], + expected = [2500, 100, 150]; + + expect(converter(values)).toEqual(expected); + }); + }); + }); + }); + + describe("Qty.getKinds", function () { + it("should return an array of kind names", function () { + expect(Qty.getKinds()).toContain("resistance"); + }); + + it("should not contain duplicate kind names", function () { + var kinds = Qty.getKinds(); + var map: { [key: string]: number } = {}; + kinds.forEach(function (kind) { + map[kind] = 1; + }); + expect(kinds.length).toEqual(Object.keys(map).length); + }); + }); + + describe("Qty.getUnits", function () { + it("should return an array of units of kind", function () { + expect(Qty.getUnits("currency")).toContain("dollar"); + }); + it("should return an array of all units without arg", function () { + expect(Qty.getUnits()).toContain("sievert"); + }); + it("should throw unknown kind", function () { + expect(function () { Qty.getUnits('bogusKind'); }).toThrow("Kind not recognized"); + }); + }); + + describe("Qty.getAliases", function () { + it("should return array of alternative names for unit", function () { + expect(Qty.getAliases("m")).toContain("meter"); + expect(Qty.getAliases("meter")).toContain("metre"); + expect(Qty.getAliases("N")).toContain("newton"); + }); + }); + + describe("information", function () { + describe("bits and bytes", function () { + it("should have 'information' as kind", function () { + expect(Qty("3 b").kind()).toBe("information"); + expect(Qty("5 B").kind()).toBe("information"); + }); + + it("could be pluralized", function () { + expect(Qty("3 bits").eq(Qty("3 b"))).toBe(true); + expect(Qty("5 bytes").eq(Qty("5 B"))).toBe(true); + }); + }); + + describe("rate", function () { + it("should accept bps and Bps aliases", function () { + expect(Qty("3 bps").eq(Qty("3 b/s"))).toBe(true); + expect(Qty("5 Bps").eq(Qty("5 B/s"))).toBe(true); + }); + + it("should be parsed when prefixed", function () { + expect(Qty("3 kbps").eq(Qty("3 kb/s"))).toBe(true); + expect(Qty("5 MBps").eq(Qty("5 MB/s"))).toBe(true); + }); + + it("should have 'information_rate' as kind", function () { + expect(Qty("3 bps").kind()).toBe("information_rate"); + expect(Qty("5 Bps").kind()).toBe("information_rate"); + }); + }); + }); + + describe("non regression tests", function () { + describe("Wh (#38)", function () { + it("should be parsed", function () { + expect(Qty("Wh").eq(Qty("3600 J"))).toBe(true); + }); + + it("should be parsed when prefixed", function () { + expect(Qty("kWh").eq(Qty("1000 Wh"))).toBe(true); + }); + }); + + describe("Ah (#25)", function () { + it("should be parsed", function () { + expect(Qty("Ah").eq(Qty("3600 C"))).toBe(true); + }); + + it("should be parsed when prefixed", function () { + expect(Qty("mAh").eq(Qty("3.6 C"))).toBe(true); + }); + }); + + describe("Farad (#67)", function () { + it('should be equal to its definition', function () { + expect(Qty("1 F").eq(Qty("1 C").div(Qty("1 V")))).toBe(true); + }); + + it('should not be defined as base unit', function () { + var qty = Qty("F"); + + expect(qty.isBase()).toBe(false); + expect(qty.toBase().units()).toEqual("s4*A2/m2*kg"); + }); + + it('should be parsed when prefixed', function () { + var qty = Qty("100 nF"); + + expect(qty.eq(Qty("100 F").div(1e9))).toBe(true); + expect(qty.baseScalar).toEqual(1e-7); + }); + }); + }); +}); diff --git a/js-quantities/tsconfig.json b/js-quantities/tsconfig.json index efde674e39..1680f0d478 100644 --- a/js-quantities/tsconfig.json +++ b/js-quantities/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -16,4 +16,4 @@ "index.d.ts", "js-quantities-tests.ts" ] -} \ No newline at end of file +} diff --git a/js-quantities/tslint.json b/js-quantities/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/js-quantities/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From b8610fa972b0b73c72025a1389b7a13da2d0bcb4 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 30 Dec 2016 15:21:58 -0800 Subject: [PATCH 026/181] moment-timezone: Move all types into augmentation --- moment-timezone/index.d.ts | 15 ++++++--------- moment-timezone/tslint.json | 6 ++++++ 2 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 moment-timezone/tslint.json diff --git a/moment-timezone/index.d.ts b/moment-timezone/index.d.ts index 991af87fea..49c068a211 100644 --- a/moment-timezone/index.d.ts +++ b/moment-timezone/index.d.ts @@ -1,14 +1,14 @@ -// Type definitions for moment-timezone.js 0.2.5 +// Type definitions for moment-timezone.js 0.2 // Project: http://momentjs.com/timezone/ // Definitions by: Michel Salib // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as moment from 'moment'; -export as namespace MomentTimezone; +// require("moment-timezone") === require("moment") export = moment; -declare namespace MomentTimezone { +declare module "moment" { interface MomentZone { name: string; abbrs: string[]; @@ -17,7 +17,7 @@ declare namespace MomentTimezone { abbr(timestamp: number): string; offset(timestamp: number): number; - parse(timestamp: number): number + parse(timestamp: number): number; } interface MomentTimezone { @@ -32,7 +32,7 @@ declare namespace MomentTimezone { (date: string, format: moment.MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment; (date: Date, timezone: string): moment.Moment; (date: moment.Moment, timezone: string): moment.Moment; - (date: Object, timezone: string): moment.Moment; + (date: any, timezone: string): moment.Moment; zone(timezone: string): MomentZone; @@ -54,9 +54,6 @@ declare namespace MomentTimezone { setDefault(timezone: string): void; } -} - -declare module "moment" { interface Moment { tz(): string; tz(timezone: string): Moment; @@ -64,5 +61,5 @@ declare module "moment" { zoneName(): string; } - const tz: MomentTimezone.MomentTimezone; + const tz: MomentTimezone; } diff --git a/moment-timezone/tslint.json b/moment-timezone/tslint.json new file mode 100644 index 0000000000..012ccb0889 --- /dev/null +++ b/moment-timezone/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false + } +} \ No newline at end of file From 3e12b136687dd8ca971e507f6ca0b1670f5c8753 Mon Sep 17 00:00:00 2001 From: Ezekiel Victor Date: Fri, 30 Dec 2016 17:50:06 -0800 Subject: [PATCH 027/181] JasmineAjaxRequest.data() def --- jasmine-ajax/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jasmine-ajax/index.d.ts b/jasmine-ajax/index.d.ts index 0eb873e048..72a3348afc 100644 --- a/jasmine-ajax/index.d.ts +++ b/jasmine-ajax/index.d.ts @@ -20,6 +20,7 @@ interface JasmineAjaxRequest extends XMLHttpRequest { password: string; requestHeaders: { [key: string]: string }; overriddenMimeType: string; + data: () => string; respondWith(response: JasmineAjaxResponse): void; } From ee9aae2daf6039af8899b40463db1bb470c1e983 Mon Sep 17 00:00:00 2001 From: eejdoowad Date: Sat, 31 Dec 2016 17:00:20 -0600 Subject: [PATCH 028/181] Fixed type of Port disconnect listener --- chrome/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chrome/index.d.ts b/chrome/index.d.ts index 942c5ef5eb..3414eee560 100644 --- a/chrome/index.d.ts +++ b/chrome/index.d.ts @@ -4952,7 +4952,7 @@ declare namespace chrome.runtime { */ sender?: MessageSender; /** An object which allows the addition and removal of listeners for a Chrome event. */ - onDisconnect: chrome.events.Event<() => void>; + onDisconnect: PortDisconnectEvent; /** An object which allows the addition and removal of listeners for a Chrome event. */ onMessage: PortMessageEvent; name: string; @@ -4968,6 +4968,8 @@ declare namespace chrome.runtime { version: string; } + interface PortDisconnectEvent extends chrome.events.Event<(port: Port) => void> {} + interface PortMessageEvent extends chrome.events.Event<(message: Object, port: Port) => void> {} interface ExtensionMessageEvent extends chrome.events.Event<(message: any, sender: MessageSender, sendResponse: (response: any) => void) => void> {} @@ -5517,7 +5519,7 @@ declare namespace chrome.storage { get(callback: (items: { [key: string]: any }) => void): void; /** * Gets one or more items from storage. - * @param keys A single key to get, list of keys to get, or a dictionary specifying default values. + * @param keys A single key to get, list of keys to get, or a dictionary specifying default values. * An empty list or object will return an empty result object. Pass in null to get the entire contents of storage. * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set). * Parameter items: Object with items in their key-value mappings. From d9e5ce085f416c931479bade14fda2623aa2798a Mon Sep 17 00:00:00 2001 From: Sam Bleckley Date: Sun, 1 Jan 2017 16:16:46 -0500 Subject: [PATCH 029/181] d3-selection: Mark before param of insert() as optional (#13090) Selection.insert functions perfectly well without a `before` selector -- it does so in many d3 official examples. This corrects the type signature to mark it as optional. --- d3-selection/d3-selection-tests.ts | 77 ++++++++++++------------------ d3-selection/index.d.ts | 4 +- 2 files changed, 32 insertions(+), 49 deletions(-) diff --git a/d3-selection/d3-selection-tests.ts b/d3-selection/d3-selection-tests.ts index b1f776c442..042fba622a 100644 --- a/d3-selection/d3-selection-tests.ts +++ b/d3-selection/d3-selection-tests.ts @@ -846,60 +846,43 @@ newDiv2 = body.append(function (d, i, g) { // without insert<...> typing returned selection has group element of type BaseType let newParagraph: d3Selection.Selection; newParagraph = body.insert('p', 'p.second-paragraph'); +newParagraph = body.insert('p'); + +// Two arguments; the first can be string, selection , or a + +const typeValueFunction = function ( + this: HTMLBodyElement, + d: BodyDatum, + i: number, + g: HTMLBodyElement[] | d3Selection.ArrayLike +) { + return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement +} + +const beforeValueFunction = function ( + this: HTMLBodyElement, + d: BodyDatum, + i: number, + g: HTMLBodyElement[] | d3Selection.ArrayLike +) { + return this.children[0]; +} let newParagraph2: d3Selection.Selection; + +// 2 args, with 3 possibilities each, makes 9 possible combinations: newParagraph2 = body.insert('p', 'p.second-paragraph'); +newParagraph2 = body.insert('p', beforeValueFunction); +newParagraph2 = body.insert('p'); newParagraph2 = body.insert(d3Selection.creator('p'), 'p.second-paragraph'); -newParagraph2 = body.insert(function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement -}, 'p.second-paragraph'); +newParagraph2 = body.insert(d3Selection.creator('p'), beforeValueFunction); +newParagraph2 = body.insert(d3Selection.creator('p')); -// newParagraph2 = body.insert(function(d) { -// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type parameter, HTMLAnchorElement returned -// }, 'p.second-paragraph'); +newParagraph2 = body.insert(typeValueFunction, 'p.second-paragraph'); +newParagraph2 = body.insert(typeValueFunction, beforeValueFunction); +newParagraph2 = body.insert(typeValueFunction); -// newParagraph2 = body.insert(function(d) { -// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type inference, HTMLAnchorElement returned -// }, 'p.second-paragraph'); - -newParagraph2 = body.insert(d3Selection.creator('p'), function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.children[0]; // this type HTMLBodyElement -}); - -newParagraph2 = body.insert( - // type - function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement - }, - // before - function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.children[0]; // this type HTMLBodyElement - }); // sort(...) ----------------------------------------------------------------------------- diff --git a/d3-selection/index.d.ts b/d3-selection/index.d.ts index 0380e10c9d..029a986024 100644 --- a/d3-selection/index.d.ts +++ b/d3-selection/index.d.ts @@ -509,7 +509,7 @@ interface Selection(type: string, before: string): Selection; + insert(type: string, before?: string): Selection; /** * Inserts a new element of the type provided by the element creator function before the element matching the specified "before" * selector string for each selected element. @@ -524,7 +524,7 @@ interface Selection(type: ValueFn, before: string): Selection; + insert(type: ValueFn, before?: string): Selection; /** * Inserts a new element of the specified type (tag name) before the element returned by the "before" child selector function * for each selected element. From 88184efb06f4b176a4aa36c07415e71523acc7c2 Mon Sep 17 00:00:00 2001 From: Fedor Nezhivoi Date: Mon, 2 Jan 2017 01:21:49 +0200 Subject: [PATCH 030/181] [react-intl] bugfix for #12716 (#12906) * fix for issue introduced in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12716 * injectIntl is now usable as class decorator * fixed test * use inferface instead of type * format document --- react-intl/index.d.ts | 8 +++-- react-intl/react-intl-tests.tsx | 53 +++++++++++++++++---------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/react-intl/index.d.ts b/react-intl/index.d.ts index 1d6412defa..d4d3d5cfd0 100644 --- a/react-intl/index.d.ts +++ b/react-intl/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-intl 2.1.5 // Project: http://formatjs.io/react/ -// Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi +// Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi , Till Wolff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -12,7 +12,7 @@ declare namespace ReactIntl { pluralRuleFunction?: (n: number, ord: boolean) => string; } - function injectIntl(component: React.ComponentClass | React.StatelessComponent): React.ComponentClass; + function injectIntl | React.StatelessComponent>(component: T): T; function addLocaleData(data: Locale[] | Locale): void; @@ -44,6 +44,10 @@ declare namespace ReactIntl { formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string; } + interface InjectedIntlProps { + intl?: InjectedIntl + } + namespace IntlComponent { interface DateTimeFormatProps { /* diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx index cd484c17b4..160a37bc0f 100644 --- a/react-intl/react-intl-tests.tsx +++ b/react-intl/react-intl-tests.tsx @@ -9,20 +9,20 @@ import * as React from "react" import * as reactMixin from "react-mixin" import { -IntlProvider, -InjectedIntl, -addLocaleData, -hasLocaleData, -injectIntl, -intlShape, -defineMessages, -FormattedRelative, -FormattedMessage, -FormattedHTMLMessage, -FormattedNumber, -FormattedPlural, -FormattedDate, -FormattedTime + IntlProvider, + InjectedIntl, + addLocaleData, + hasLocaleData, + injectIntl, + intlShape, + defineMessages, + FormattedRelative, + FormattedMessage, + FormattedHTMLMessage, + FormattedNumber, + FormattedPlural, + FormattedDate, + FormattedTime } from "react-intl" import reactIntlEn = require("react-intl/locale-data/en"); @@ -31,7 +31,8 @@ addLocaleData(reactIntlEn); console.log(hasLocaleData("en")); interface SomeComponentProps { - intl: InjectedIntl + className: string, + intl?: InjectedIntl } class SomeComponent extends React.Component { @@ -47,14 +48,14 @@ class SomeComponent extends React.Component { const formattedPlural = intl.formatPlural(1, { one: "hai!" }); const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); - return
+ return
+ initialNow={new Date()} /> { many="haiku" /> { timeZoneName="short" /> { {(formattedNum: string) => ( {formattedNum} - ) } - -
+ )} + +
} } @@ -159,9 +160,9 @@ class TestApp extends React.Component<{}, {}> { "hello": "Hello, {name}!" }; return ( - - - + + + ); } } From 8200deb71d49730584d8d09db5d134bd07e16f68 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Sun, 1 Jan 2017 15:33:31 -0800 Subject: [PATCH 031/181] react: Add link about SyntheticEvent.target --- react/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react/index.d.ts b/react/index.d.ts index 467af23d9f..02cedfb5b0 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -284,6 +284,7 @@ declare namespace React { stopPropagation(): void; isPropagationStopped(): boolean; persist(): void; + // If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239 target: EventTarget; timeStamp: Date; type: string; From a67d9c1d527277e30d46a5ef51dc686664a24622 Mon Sep 17 00:00:00 2001 From: smhc Date: Mon, 2 Jan 2017 17:14:53 +1000 Subject: [PATCH 032/181] Added comparator to IFilterOrderBy --- angular/index.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index 920b616a26..6d72ae6fef 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -660,7 +660,11 @@ declare namespace angular { interface IFilterFilterComparatorFunc { (actual: T, expected: T): boolean; } - + + interface IFilterOrderByComparatorFunc { + (left: T, right: T): boolean; + } + interface IFilterCurrency { /** * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default symbol for current locale is used. @@ -743,9 +747,10 @@ declare namespace angular { * @param array The array to sort. * @param expression A predicate to be used by the comparator to determine the order of elements. * @param reverse Reverse the order of the array. + * @param comparator Function used to determine the relative order of value pairs. * @return Reverse the order of the array. */ - (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean): T[]; + (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; } /** From 6fabcf1e1245c3692721fdde8e5ad0cdcda34af4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Jan 2017 03:44:20 -0500 Subject: [PATCH 033/181] Added 'noImplicitThis' to the 'tsconfig.json' for 'pulltorefreshjs'. --- pulltorefreshjs/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/pulltorefreshjs/tsconfig.json b/pulltorefreshjs/tsconfig.json index 199c61cf0e..26c3326609 100644 --- a/pulltorefreshjs/tsconfig.json +++ b/pulltorefreshjs/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, + "noImplicitThis": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From bdc896651ebd8a0397f05f82769e92e272069e93 Mon Sep 17 00:00:00 2001 From: stonio Date: Mon, 2 Jan 2017 17:28:44 +0100 Subject: [PATCH 034/181] add maxFileSize --- jquery.fileupload/index.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jquery.fileupload/index.d.ts b/jquery.fileupload/index.d.ts index f34325ad8b..8eba9853b2 100644 --- a/jquery.fileupload/index.d.ts +++ b/jquery.fileupload/index.d.ts @@ -213,6 +213,18 @@ interface JQueryFileInputOptions { progress?: (e: JQueryEventObject, data: JQueryFileUploadProgressObject) => void; send?: (e: JQueryEventObject, data: JQueryFileUploadProgressObject) => void; + // Validation + + /** + * The maximum allowed file size in bytes. + * Type: integer + * Default: undefined + * Example: 10000000 // 10 MB + * Note: This option has only an effect for browsers supporting the File API. + * @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options#maxfilesize + */ + maxFileSize?: number; + // Other callbacks: submit?: Function; done?: (e: JQueryEventObject, data: JQueryFileUploadDone) => void; @@ -289,4 +301,4 @@ interface JQueryFileUploadProgressObject extends JQueryFileInputOptions, JQueryF } interface JQueryFileUploadDone extends JQueryFileInputOptions, JQueryFileUploadXhr { -} \ No newline at end of file +} From 41d00df110f806afd7450d94cba9ca9c4da7357d Mon Sep 17 00:00:00 2001 From: Kevin Brightwell Date: Mon, 2 Jan 2017 12:44:32 -0500 Subject: [PATCH 035/181] Add more declarations to `reveal` * Added more declarations and adjusted types based on documentation https://github.com/hakimel/reveal.js#configuration Fixes #13684. --- reveal/index.d.ts | 62 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/reveal/index.d.ts b/reveal/index.d.ts index e99fb44add..08a5ab54b0 100644 --- a/reveal/index.d.ts +++ b/reveal/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Reveal 3.3.0 // Project: https://github.com/hakimel/reveal.js/ -// Definitions by: robertop87 +// Definitions by: robertop87 , Nava2 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var Reveal:RevealStatic; @@ -70,8 +70,12 @@ interface RevealOptions { // Configuration controls?:boolean; progress?:boolean; - slideNumber?:boolean; + // https://github.com/hakimel/reveal.js/#slide-number + slideNumber?:boolean|string; + history?:boolean; + + // https://github.com/hakimel/reveal.js/#keyboard-bindings keyboard?:any; overview?:boolean; center?:boolean; @@ -102,18 +106,56 @@ interface RevealOptions { theme?:string; // Presentation Size - width?:number; - height?:number; - margin?:number; - minScale?:number; - maxScale?:number; + // https://github.com/hakimel/reveal.js/#presentation-size + width?:number|string; + height?:number|string; + margin?:number|string; + minScale?:number|string; + maxScale?:number|string; // Dependencies - dependencies?:RevealDependency[]; + // https://github.com/hakimel/reveal.js/#dependencies + dependencies?: RevealDependency[]; + + // Exposes the reveal.js API through window.postMessage + postMessage?: boolean; + + // Dispatches all reveal.js events to the parent window through postMessage + postMessageEvents?: boolean; + + // https://github.com/hakimel/reveal.js/#multiplexing + multiplex?: MultiplexConfig; + + // https://github.com/hakimel/reveal.js/#mathjax + math?: MathConfig; } +// https://github.com/hakimel/reveal.js/#multiplexing +interface MultiplexConfig { + // Obtained from the socket.io server. Gives this (the master) control of the presentation + secret?: string; + // Obtained from the socket.io server + id: string; + + // Location of socket.io server + url: string; +} + +// https://github.com/hakimel/reveal.js/#mathjax +interface MathConfig { + // Obtained from the socket.io server. Gives this (the master) control of the presentation + mathjax: string; + // Obtained from the socket.io server + config: string; + + // Location of socket.io server + url: string; +} + +// https://github.com/hakimel/reveal.js/#dependencies interface RevealDependency { src:string; - condition:()=>boolean; + condition?: ()=>boolean; async?:boolean; -} \ No newline at end of file + callback?: ()=>void; +} From e7b6ff74cefeb6b7ed55982da13ec160341d67d7 Mon Sep 17 00:00:00 2001 From: reblace Date: Mon, 2 Jan 2017 13:05:33 -0500 Subject: [PATCH 036/181] Making the GeoJSON methods accessible as static methods --- leaflet/index.d.ts | 85 +++++++++++++++++++++------------------- leaflet/leaflet-tests.ts | 12 ++++++ 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 0d455717f2..1e8231f497 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -817,6 +817,51 @@ declare namespace L { coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property } + export class GeoJSON { + /** + * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer + * and/or coordsToLatLng functions if provided as options. + */ + static geometryToLayer(featureData: GeoJSON.Feature, options?: GeoJSONOptions): Layer; + + /** + * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or + * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. + */ + static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng; + + /** + * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. + * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of + * arrays of points, etc., 0 by default). + * Can use a custom coordsToLatLng function. + */ + static coordsToLatLngs( + coords: any[], + levelsDeep?: number, + coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): any[]; // Using any[] to avoid artificially limiting valid calls + + /** + * Reverse of coordsToLatLng + */ + static latLngToCoords(latlng: LatLng): number[]; + + /** + * Reverse of coordsToLatLngs closed determines whether the first point should be + * appended to the end of the array to close the feature, only used when levelsDeep is 0. + * False by default. + */ + static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls + + /** + * Normalize GeoJSON geometries/features into GeoJSON features. + */ + static asFeature(geojson: GeoJSON.GeometryObject): GeoJSON.Feature; + + static asFeature(geojson: GeoJSON.Feature): GeoJSON.Feature; + + } + /** * Represents a GeoJSON object or an array of GeoJSON objects. * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup. @@ -838,46 +883,6 @@ declare namespace L { */ setStyle(style: StyleFunction): this; - /** - * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer - * and/or coordsToLatLng functions if provided as options. - */ - geometryToLayer(featureData: GeoJSON.Feature, options?: GeoJSONOptions): Layer; - - /** - * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or - * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. - */ - coordsToLatLng(coords: [number, number]): LatLng; - - coordsToLatLng(coords: [number, number, number]): LatLng; - - /** - * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. - * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of - * arrays of points, etc., 0 by default). - * Can use a custom coordsToLatLng function. - */ - coordsToLatLngs(coords: Array, levelsDeep?: number, coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): LatLng[]; // Not entirely sure how to define arbitrarily nested arrays - - /** - * Reverse of coordsToLatLng - */ - latLngToCoords(latlng: LatLng): [number, number] | [number, number, number]; - - /** - * Reverse of coordsToLatLngs closed determines whether the first point should be - * appended to the end of the array to close the feature, only used when levelsDeep is 0. - * False by default. - */ - latLngsToCoords(latlngs: Array, levelsDeep?: number, closed?: boolean): [number, number] | [number, number, number]; - - /** - * Normalize GeoJSON geometries/features into GeoJSON features. - */ - asFeature(geojson: GeoJSON.GeometryObject): GeoJSON.Feature; - - asFeature(geojson: GeoJSON.Feature): GeoJSON.Feature; } /** diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 8b988509c6..93d019b46b 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -358,6 +358,18 @@ draggable.enable(); draggable.disable(); draggable.on('drag', () => {}); +let twoCoords: [number, number] = [1, 2]; +latLng = L.GeoJSON.coordsToLatLng(twoCoords); +let coords: number[] = L.GeoJSON.latLngToCoords(latLng); + +let threeCoords: [number, number, number] = [1, 2, 3]; +latLng = L.GeoJSON.coordsToLatLng(threeCoords); +coords = L.GeoJSON.latLngToCoords(latLng); + +let nestedTwoCoords = [ [12, 13], [13, 14], [14, 15] ]; +let nestedLatLngs: L.LatLng[] = L.GeoJSON.coordsToLatLngs(nestedTwoCoords, 1); +nestedTwoCoords = L.GeoJSON.latLngsToCoords(nestedLatLngs, 1); + class MyMarker extends L.Marker { constructor() { super([12, 13]); From 43bf7198576dbdc4e759439c83f50e6ea477f7ec Mon Sep 17 00:00:00 2001 From: Kevin Brightwell Date: Mon, 2 Jan 2017 13:08:17 -0500 Subject: [PATCH 037/181] reveal: Add more tests and definitions --- reveal/index.d.ts | 43 ++++++++++++----- reveal/reveal-tests.ts | 104 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 14 deletions(-) diff --git a/reveal/index.d.ts b/reveal/index.d.ts index 08a5ab54b0..5d205424cc 100644 --- a/reveal/index.d.ts +++ b/reveal/index.d.ts @@ -30,19 +30,19 @@ interface RevealStatic { // Retrieves the previous and current slide elements - getPreviousSlide():Element; - getCurrentSlide():Element; + getPreviousSlide(): Element; + getCurrentSlide(): Element; getIndices(slide?:Element):{h:number; v:number;}; getProgress():number; getTotalSlides():number; // Returns the speaker notes for the current slide - getSlideNotes(slide:any):string; + getSlideNotes(slide?:Element):string; // States - addEventListener(type:string, listener:Function, useCapture?:boolean):void; - removeEventListener(type:string, listener:Function, useCapture?:boolean):void; + addEventListener(type:string, listener:(event: any)=>void, useCapture?:boolean):void; + removeEventListener(type:string, listener:(event: any)=>void, useCapture?:boolean):void; // State Checks isFirstSlide():boolean; @@ -97,10 +97,19 @@ interface RevealOptions { transitionSpeed?:string; backgroundTransition?:string; viewDistance?:number; - parallaxBackgroundImage?:string; - parallaxBackgroundSize?:string; - parallaxBackgroundHorizontal?:any; - parallaxBackgroundVertical?:any; + + // https://github.com/hakimel/reveal.js/#parallax-background + // Parallax background image + parallaxBackgroundImage?: string; + + // Parallax background size + parallaxBackgroundSize?: string; // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) + + // Number of pixels to move the parallax background per slide + // - Calculated automatically unless specified + // - Set to 0 to disable movement along an axis + parallaxBackgroundHorizontal?: number; + parallaxBackgroundVertical?: number; rollingLinks?:boolean; theme?:string; @@ -130,6 +139,19 @@ interface RevealOptions { math?: MathConfig; } +// https://github.com/hakimel/reveal.js/#slide-changed-event +interface SlideEvent { + previousSlide?: Element; + currentSlide: Element; + indexh: number; + indexv?: number; +} + +// https://github.com/hakimel/reveal.js/#fragment-events +interface FragmentEvent { + fragment: Element; +} + // https://github.com/hakimel/reveal.js/#multiplexing interface MultiplexConfig { // Obtained from the socket.io server. Gives this (the master) control of the presentation @@ -147,9 +169,6 @@ interface MathConfig { mathjax: string; // Obtained from the socket.io server config: string; - - // Location of socket.io server - url: string; } // https://github.com/hakimel/reveal.js/#dependencies diff --git a/reveal/reveal-tests.ts b/reveal/reveal-tests.ts index 2de9b596ef..ec31a7a24f 100644 --- a/reveal/reveal-tests.ts +++ b/reveal/reveal-tests.ts @@ -5,5 +5,105 @@ Reveal.initialize({ progress: true, history: true, center: true, - transition: 'linear' -}); \ No newline at end of file + transition: 'linear', + slideNumber: 'c/t', + width: '100%', + height: '80%', + + postMessage: true, + postMessageEvents: true, + + multiplex: { + // Example values. To generate your own, see the socket.io server instructions. + secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation + id: '1ea875674b17ca76', // Obtained from socket.io server + url: 'https://reveal-js-multiplex-ccjbegmaii.now.sh' // Location of socket.io server + }, + + math: { + mathjax: 'https://cdn.mathjax.org/mathjax/latest/MathJax.js', + config: 'TeX-AMS_HTML-full' // See http://docs.mathjax.org/en/latest/config-files.html + }, + + dependencies: [ + { src: 'plugin/multiplex/master.js', async: true }, + { src: 'plugin/math/math.js', async: true } + ] +}); + +// Alternate representations +Reveal.initialize({ + slideNumber: true, + width: 20, + height: 20 +}); + +// Taken from https://github.com/hakimel/reveal.js/#api + +// Navigation +Reveal.slide( 0, 1, 2 ); +Reveal.left(); +Reveal.right(); +Reveal.up(); +Reveal.down(); +Reveal.prev(); +Reveal.next(); +Reveal.prevFragment(); +Reveal.nextFragment(); + +// Randomize the order of slides +Reveal.shuffle(); + +// Toggle presentation states, optionally pass true/false to force on/off +Reveal.toggleOverview(); +Reveal.togglePause(); +Reveal.toggleAutoSlide(); + +// Change a config value at runtime +Reveal.configure({ controls: true }); + +// Returns the present configuration options +Reveal.getConfig(); + +// Fetch the current scale of the presentation +Reveal.getScale(); + +// Retrieves the previous and current slide elements +Reveal.getPreviousSlide(); +Reveal.getCurrentSlide(); + +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); + +// Returns the speaker notes for the current slide +Reveal.getSlideNotes(); + +// State checks +Reveal.isFirstSlide(); +Reveal.isLastSlide(); +Reveal.isOverview(); +Reveal.isPaused(); +Reveal.isAutoSliding(); + +Reveal.addEventListener( 'slidechanged', ( event: SlideEvent ) => { + // event.previousSlide, event.currentSlide, event.indexh, event.indexv +} ); + +Reveal.addEventListener( 'fragmentshown', ( event: FragmentEvent ) => { + // event.fragment = the fragment DOM element +} ); +Reveal.addEventListener( 'fragmenthidden', ( event: FragmentEvent ) => { + // event.fragment = the fragment DOM element +} ); + +Reveal.slide( 1 ); +// we're on slide 1 + +const state = Reveal.getState(); + +Reveal.slide( 3 ); +// we're on slide 3 + +Reveal.setState( state ); +// we're back on slide 1 \ No newline at end of file From 58659b5a399db8868fc76338bd8491dd42ebc727 Mon Sep 17 00:00:00 2001 From: JulienDuf Date: Mon, 2 Jan 2017 15:23:47 -0500 Subject: [PATCH 038/181] Add node-wit types definitions --- node-wit/index.d.ts | 85 ++++++++++++++++++++++++++++++++++++++ node-wit/node-wit-tests.ts | 14 +++++++ node-wit/tsconfig.json | 20 +++++++++ node-wit/tslint.json | 1 + 4 files changed, 120 insertions(+) create mode 100644 node-wit/index.d.ts create mode 100644 node-wit/node-wit-tests.ts create mode 100644 node-wit/tsconfig.json create mode 100644 node-wit/tslint.json diff --git a/node-wit/index.d.ts b/node-wit/index.d.ts new file mode 100644 index 0000000000..f2fc3cfa10 --- /dev/null +++ b/node-wit/index.d.ts @@ -0,0 +1,85 @@ +// Type definitions for node-wit 4.2 +// Project: https://github.com/wit-ai/node-wit#readme +// Definitions by: Julien Dufresne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as Promise from "bluebird"; + + +export namespace log { + + class Logger { + + constructor(lvl: string); + } + + const DEBUG = 'debug'; + const INFO = 'info'; + const WARN = 'warn'; + const ERROR = 'error'; +} + +export interface WitEntityValue { + + value?: string; + expressions?: string[]; +} + +export interface WitEntity { + + id?: string; + values?: WitEntityValue[]; +} + +export interface WitContext { + + state?: string[]; + reference_time?: string; + timezone?: string; + entities?: WitEntity[]; + location?: string; +} + +export interface WitRequest { + + sessinId?: string; + context?: WitContext; + text?: string; + entities?: WitEntity[]; +} + +export interface WitResponse { + + text?: string; + qickReplies?: Object; +} + +export interface WitOption { + + accessToken?: string; + actions?: Object; + logger?: log.Logger; +} + +export interface MessageResponseEntity { + + confidence?: number; + value?: string; +} + +export interface MessageResponse { + + msg_id: string; + _text: string; + entities: Array; +} + +export declare class Wit { + + constructor(option: WitOption); + message(message: string, context: WitContext): Promise; + converse(sessinId: string, message: string, context: WitContext, reset?: boolean): Promise; + runActions(sessinId: string, message: string, context: WitContext, maxSteps?: number): Promise; +} \ No newline at end of file diff --git a/node-wit/node-wit-tests.ts b/node-wit/node-wit-tests.ts new file mode 100644 index 0000000000..9bf0f1184e --- /dev/null +++ b/node-wit/node-wit-tests.ts @@ -0,0 +1,14 @@ +import { Wit, log } from "node-wit"; + +var wit = new Wit({accessToken: "", logger: new log.Logger(log.DEBUG)}); +wit.message("Hello", {}).then((res) => { + console.log(res._text); + + for (let entity of res.entities) { + + console.log(entity.value + ": " + entity.confidence * 100 + "%"); + } + +}).catch((err) => { + +}); \ No newline at end of file diff --git a/node-wit/tsconfig.json b/node-wit/tsconfig.json new file mode 100644 index 0000000000..28e685c088 --- /dev/null +++ b/node-wit/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-wit-tests.ts" + ] +} diff --git a/node-wit/tslint.json b/node-wit/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/node-wit/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 327a67bab506c77eaeeba559a5a148ade43b04ab Mon Sep 17 00:00:00 2001 From: JulienDuf Date: Mon, 2 Jan 2017 15:33:28 -0500 Subject: [PATCH 039/181] Fix node-wit lint errors --- node-wit/index.d.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/node-wit/index.d.ts b/node-wit/index.d.ts index f2fc3cfa10..4421b1b9b0 100644 --- a/node-wit/index.d.ts +++ b/node-wit/index.d.ts @@ -3,11 +3,8 @@ // Definitions by: Julien Dufresne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Promise from "bluebird"; - export namespace log { class Logger { @@ -51,15 +48,14 @@ export interface WitRequest { } export interface WitResponse { - text?: string; - qickReplies?: Object; + qickReplies?: any; } export interface WitOption { accessToken?: string; - actions?: Object; + actions?: any; logger?: log.Logger; } @@ -73,7 +69,7 @@ export interface MessageResponse { msg_id: string; _text: string; - entities: Array; + entities: MessageResponseEntity[]; } export declare class Wit { From 83d54577e502669d71ee8b2466b030dab4790520 Mon Sep 17 00:00:00 2001 From: Julien Dufresne Date: Mon, 2 Jan 2017 16:14:58 -0500 Subject: [PATCH 040/181] Update index.d.ts --- node-wit/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/node-wit/index.d.ts b/node-wit/index.d.ts index 4421b1b9b0..9ded60de17 100644 --- a/node-wit/index.d.ts +++ b/node-wit/index.d.ts @@ -7,15 +7,15 @@ import * as Promise from "bluebird"; export namespace log { - class Logger { + declare class Logger { constructor(lvl: string); } - const DEBUG = 'debug'; - const INFO = 'info'; - const WARN = 'warn'; - const ERROR = 'error'; + declare const DEBUG = 'debug'; + declare const INFO = 'info'; + declare const WARN = 'warn'; + declare const ERROR = 'error'; } export interface WitEntityValue { @@ -78,4 +78,4 @@ export declare class Wit { message(message: string, context: WitContext): Promise; converse(sessinId: string, message: string, context: WitContext, reset?: boolean): Promise; runActions(sessinId: string, message: string, context: WitContext, maxSteps?: number): Promise; -} \ No newline at end of file +} From f16e8848deff37a998a1ff813f3d33cc07d79bbe Mon Sep 17 00:00:00 2001 From: Julien Dufresne Date: Mon, 2 Jan 2017 16:30:32 -0500 Subject: [PATCH 041/181] Update index.d.ts --- node-wit/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node-wit/index.d.ts b/node-wit/index.d.ts index 9ded60de17..52c7a67890 100644 --- a/node-wit/index.d.ts +++ b/node-wit/index.d.ts @@ -7,15 +7,15 @@ import * as Promise from "bluebird"; export namespace log { - declare class Logger { + class Logger { constructor(lvl: string); } - declare const DEBUG = 'debug'; - declare const INFO = 'info'; - declare const WARN = 'warn'; - declare const ERROR = 'error'; + const DEBUG; + const INFO; + const WARN; + const ERROR; } export interface WitEntityValue { From b1e4a08ea0b747e6097bc657eb323d20937bd731 Mon Sep 17 00:00:00 2001 From: Julien Dufresne Date: Mon, 2 Jan 2017 16:44:39 -0500 Subject: [PATCH 042/181] Add type string to const variable --- node-wit/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node-wit/index.d.ts b/node-wit/index.d.ts index 52c7a67890..511fde0913 100644 --- a/node-wit/index.d.ts +++ b/node-wit/index.d.ts @@ -12,10 +12,10 @@ export namespace log { constructor(lvl: string); } - const DEBUG; - const INFO; - const WARN; - const ERROR; + const DEBUG: string; + const INFO: string; + const WARN: string; + const ERROR: string; } export interface WitEntityValue { From 26ced0acb9ddf27b71a2194bff47a28b2657e8e9 Mon Sep 17 00:00:00 2001 From: Colby Brown Date: Mon, 2 Jan 2017 16:31:10 -0600 Subject: [PATCH 043/181] Add contains to bootstrap-datepicker DatepickerOptions --- bootstrap-datepicker/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap-datepicker/index.d.ts b/bootstrap-datepicker/index.d.ts index a692b663bb..fcd24f19c4 100644 --- a/bootstrap-datepicker/index.d.ts +++ b/bootstrap-datepicker/index.d.ts @@ -42,6 +42,7 @@ interface DatepickerOptions { showOnFocus?: boolean; immediateUpdates?: boolean; title?: string; + contains?: string; } interface DatepickerCustomFormatOptions { From 266898f207a17497dd13b90bf0324ade2f0a48c4 Mon Sep 17 00:00:00 2001 From: Colby Date: Mon, 2 Jan 2017 16:41:47 -0600 Subject: [PATCH 044/181] Fix typo from 'contains' to 'container' --- bootstrap-datepicker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-datepicker/index.d.ts b/bootstrap-datepicker/index.d.ts index fcd24f19c4..5a6e80f72e 100644 --- a/bootstrap-datepicker/index.d.ts +++ b/bootstrap-datepicker/index.d.ts @@ -42,7 +42,7 @@ interface DatepickerOptions { showOnFocus?: boolean; immediateUpdates?: boolean; title?: string; - contains?: string; + container?: string; } interface DatepickerCustomFormatOptions { From 0c56e6562c7f68b195601b8b2832deeb47bd5217 Mon Sep 17 00:00:00 2001 From: Michael Mrowetz Date: Tue, 3 Jan 2017 08:07:26 +0900 Subject: [PATCH 045/181] add swagger-sails-hook (#13676) * add Sails and Connect middleware test * add swagger-sails-hook * Fix indentation --- .../swagger-node-runner-tests.ts | 27 ++++++++- swagger-sails-hook/index.d.ts | 55 +++++++++++++++++++ .../swagger-sails-hook-tests.ts | 21 +++++++ swagger-sails-hook/tsconfig.json | 20 +++++++ swagger-sails-hook/tslint.json | 1 + 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 swagger-sails-hook/index.d.ts create mode 100644 swagger-sails-hook/swagger-sails-hook-tests.ts create mode 100644 swagger-sails-hook/tsconfig.json create mode 100644 swagger-sails-hook/tslint.json diff --git a/swagger-node-runner/swagger-node-runner-tests.ts b/swagger-node-runner/swagger-node-runner-tests.ts index 2d20ad21c8..49538d3825 100644 --- a/swagger-node-runner/swagger-node-runner-tests.ts +++ b/swagger-node-runner/swagger-node-runner-tests.ts @@ -1,7 +1,9 @@ import * as SwaggerNodeRunner from "swagger-node-runner"; import * as express from "express"; +import * as connect from "connect"; import * as Hapi from "hapi"; import * as restify from "restify"; +import * as sails from "sails.io.js"; let config: SwaggerNodeRunner.Config = { appRoot: __dirname @@ -21,6 +23,30 @@ SwaggerNodeRunner.create(config, (err, runner) => { }); +//Connect middleware +let connectApp = connect(); +SwaggerNodeRunner.create(config, (err, runner) => { + if (err) { throw err; } + + let conncetMiddleware = runner.connectMiddleware(); + + conncetMiddleware.register(connectApp); + var port = process.env.PORT || 10010; + connectApp.listen(port); +}); + + +// Sails Middleware (chain) test +SwaggerNodeRunner.create(config, (err, runner) => { + if (err) { throw err; } + + let sailsMw = runner.sailsMiddleware(); + if(typeof sailsMw.chain !== 'function' || !sailsMw.runner) { + // do nothing + } +}); + + //Hapi Middleware var hapiapp = new Hapi.Server(); SwaggerNodeRunner.create(config, function(err, runner) { @@ -47,7 +73,6 @@ SwaggerNodeRunner.create(config, function(err, runner) { // Restify Middelware - let app = restify.createServer(); SwaggerNodeRunner.create(config, function(err, runner) { if (err) { throw err; } diff --git a/swagger-sails-hook/index.d.ts b/swagger-sails-hook/index.d.ts new file mode 100644 index 0000000000..4ce957a6bf --- /dev/null +++ b/swagger-sails-hook/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for swagger-sails-hook 0.7 +// Project: https://github.com/apigee-127/swagger-sails#readme +// Definitions by: Michael Mrowetz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* =================== USAGE =================== +// Registers itself as sails hook, when added to the project via `npm install swagger-sails-hook`. +// see http://sailsjs.com/documentation/concepts/extending-sails/hooks + =============================================== */ + +import { Config, SailsMiddleware } from "swagger-node-runner"; + +export = SwaggerHook; + +/** + * Create a new `swagger-sails-hook` sails hook and register it with `sails` + * @param {any} sails - reference to the running sails instance + * @returns SailsHook - `swagger-sails-hook` object implementing the Sails' hook specification. + */ +declare function SwaggerHook(sails: any): SwaggerHook.SailsHook; + +declare namespace SwaggerHook { + /** + * `swagger-sails-hook` object implementing the Sails' hook specification. + * + * @see {@link http://sailsjs.com/documentation/concepts/extending-sails/hooks/hook-specification|Sails Hook Docs} + * @see {@link http://sailsjs.com/documentation/anatomy/api/hooks/my-hook/index-js|Sails Hook Example} + */ + export interface SailsHook { + + /** + * Perform startup tasks. + * All Sails configuration is guaranteed to be completed before a hook’s initialize function runs. + * @param {Function} done - called when `swagger-sails-hook`'s startup tasks have finished. + */ + initialize: (done: () => any) => void; + + /** + * `swagger-sails-hook` specific route bound to a Sails app at load time. + * + * It handles any unhandled requests (any routes that aren't bound in the app via a + * custom route configuration or a blueprint) via the swagger middleware. + */ + routes: { + /** routes specified in the `after` object will be bound after custom and blueprint routes */ + after: { + /** + * This route will match any routes that aren't bound in the app via a custom route configuration + * or a blueprint. + */ + "/*": (req: any, res: any, next: () => any) => any + } + }; + } +} diff --git a/swagger-sails-hook/swagger-sails-hook-tests.ts b/swagger-sails-hook/swagger-sails-hook-tests.ts new file mode 100644 index 0000000000..ee023047c3 --- /dev/null +++ b/swagger-sails-hook/swagger-sails-hook-tests.ts @@ -0,0 +1,21 @@ +import swaggerSailsHook = require("swagger-sails-hook"); +import * as express from "express"; + + +const mockSailsApp = { + models: {}, + conf: {}, + sockets: {}, + hooks: {}, + lift: () => { /* do nothing */ } +}; + +// create and register hook +let swaggerHookRef = swaggerSailsHook(mockSailsApp); +if(typeof swaggerHookRef.routes.after['/*'] === 'function') { + // right type +} + +swaggerHookRef.initialize(() => { + // do something, when initialized +}); diff --git a/swagger-sails-hook/tsconfig.json b/swagger-sails-hook/tsconfig.json new file mode 100644 index 0000000000..ac43d0e157 --- /dev/null +++ b/swagger-sails-hook/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "swagger-sails-hook-tests.ts" + ] +} diff --git a/swagger-sails-hook/tslint.json b/swagger-sails-hook/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/swagger-sails-hook/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From a0da31216510e8b99c4f11b7206841da9b540205 Mon Sep 17 00:00:00 2001 From: Jesse Sessler Date: Mon, 2 Jan 2017 18:15:20 -0500 Subject: [PATCH 046/181] Fix signature for onSelectionChange (#13685) --- react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 9e89306872..57e670575e 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -1223,7 +1223,7 @@ declare module "react" { /** * Callback that is called when the text input selection is changed. */ - onSelectionChange?: () => void + onSelectionChange?: (event: { nativeEvent: { selection: { start: number, end: number }, target: number } }) => void /** * Callback that is called when the text input's submit button is pressed. From f991a320e5a0a7391e6d73d888df25b7bb2f2943 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Tue, 3 Jan 2017 01:25:52 +0200 Subject: [PATCH 047/181] Add assert.containSubset method; refactor to follow latest style instructions (#13690) --- chai-subset/chai-subset-tests.ts | 3 +++ chai-subset/index.d.ts | 19 +++++++++++-------- chai-subset/tslint.json | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 chai-subset/tslint.json diff --git a/chai-subset/chai-subset-tests.ts b/chai-subset/chai-subset-tests.ts index d4c7ca3f2b..ded911ed19 100644 --- a/chai-subset/chai-subset-tests.ts +++ b/chai-subset/chai-subset-tests.ts @@ -29,6 +29,8 @@ function test_containSubset() { }); obj.should.containSubset({ a: 'b' }); + + assert.containSubset(obj, { a: 'b' }); } function test_notContainSubset() { @@ -52,6 +54,7 @@ function test_arrayContainSubset() { expect(list).to.containSubset([{a:'a', b: 'b'}]); list.should.containSubset([{a:'a', b: 'b'}]); + assert.containSubset(list, [{a:'a', b: 'b'}]); } function test_arrayNotContainSubset() { diff --git a/chai-subset/index.d.ts b/chai-subset/index.d.ts index 89ee553945..3e0818aa2b 100644 --- a/chai-subset/index.d.ts +++ b/chai-subset/index.d.ts @@ -1,17 +1,20 @@ -// Type definitions for chai-subset 1.0.0 +// Type definitions for chai-subset 1.3 // Project: https://github.com/e-conomic/chai-subset // Definitions by: Sam Noedel , Andrew Brown // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare namespace Chai { - interface Assertion { - containSubset(obj: Object): Assertion; +declare global { + namespace Chai { + interface Assertion { + containSubset(expected: any): Assertion; + } + interface Assert { + containSubset(val: any, exp: any, msg?: string): void; + } } } -declare module "chai-subset" { - function chaiSubset(chai: any, utils: any): void; - export = chaiSubset; -} +declare function chaiSubset(chai: any, utils: any): void; +export = chaiSubset; diff --git a/chai-subset/tslint.json b/chai-subset/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/chai-subset/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 545bec0b00bcf26d6d654f080cc334fe6021773b Mon Sep 17 00:00:00 2001 From: smhc Date: Tue, 3 Jan 2017 09:44:53 +1000 Subject: [PATCH 048/181] Corrected interface for IFilterOrderByComparatorFunc Fixed return value and parameter types. --- angular/index.d.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index 6d72ae6fef..d614bc5265 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -661,10 +661,16 @@ declare namespace angular { (actual: T, expected: T): boolean; } - interface IFilterOrderByComparatorFunc { - (left: T, right: T): boolean; + interface IFilterOrderByItem { + value: any, + type: string, + index: any } - + + interface IFilterOrderByComparatorFunc { + (left: IFilterOrderByItem, right: IFilterOrderByItem): [-1, 0, 1]; + } + interface IFilterCurrency { /** * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default symbol for current locale is used. @@ -748,9 +754,9 @@ declare namespace angular { * @param expression A predicate to be used by the comparator to determine the order of elements. * @param reverse Reverse the order of the array. * @param comparator Function used to determine the relative order of value pairs. - * @return Reverse the order of the array. + * @return An array containing the items from the specified collection, ordered by a comparator function based on the values computed using the expression predicate. */ - (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; + (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; } /** From 01fed1ac847b9d90a7e0882c77bc3a0da7f2222d Mon Sep 17 00:00:00 2001 From: smhc Date: Tue, 3 Jan 2017 10:03:08 +1000 Subject: [PATCH 049/181] Fixed again - incorrect return type --- angular/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index d614bc5265..7d710eaa7f 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -661,14 +661,14 @@ declare namespace angular { (actual: T, expected: T): boolean; } - interface IFilterOrderByItem { - value: any, + interface IFilterOrderByItem { + value: T, type: string, index: any } - interface IFilterOrderByComparatorFunc { - (left: IFilterOrderByItem, right: IFilterOrderByItem): [-1, 0, 1]; + interface IFilterOrderByComparatorFunc { + (left: IFilterOrderByItem, right: IFilterOrderByItem): -1 | 0 | 1; } interface IFilterCurrency { @@ -756,7 +756,7 @@ declare namespace angular { * @param comparator Function used to determine the relative order of value pairs. * @return An array containing the items from the specified collection, ordered by a comparator function based on the values computed using the expression predicate. */ - (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; + (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; } /** From b0d3f2601e3e1151f5568f69522996b7146dfb51 Mon Sep 17 00:00:00 2001 From: bumbleblym Date: Tue, 3 Jan 2017 08:56:14 +0800 Subject: [PATCH 050/181] Add html-webpack-template (#13680) * Add html-webpack-template * Add Attributes type --- .../html-webpack-template-tests.ts | 65 +++++++++++++ html-webpack-template/index.d.ts | 96 +++++++++++++++++++ html-webpack-template/tsconfig.json | 20 ++++ html-webpack-template/tslint.json | 1 + 4 files changed, 182 insertions(+) create mode 100644 html-webpack-template/html-webpack-template-tests.ts create mode 100644 html-webpack-template/index.d.ts create mode 100644 html-webpack-template/tsconfig.json create mode 100644 html-webpack-template/tslint.json diff --git a/html-webpack-template/html-webpack-template-tests.ts b/html-webpack-template/html-webpack-template-tests.ts new file mode 100644 index 0000000000..c24a9506d3 --- /dev/null +++ b/html-webpack-template/html-webpack-template-tests.ts @@ -0,0 +1,65 @@ +import HtmlWebpackPlugin = require('html-webpack-plugin'); +import template = require('html-webpack-template'); + +const configs: Array = [ + { + // Required + inject: false, + template, + // template: 'node_modules/html-webpack-template/index.ejs', + + // Optional + appMountId: 'app', + appMountIds: [ + 'root0', + 'root1', + ], + baseHref: 'http://example.com/awesome', + devServer: 'http://localhost:3001', + googleAnalytics: { + trackingId: 'UA-XXXX-XX', + pageViewOnLoad: true, + }, + links: [ + 'https://fonts.googleapis.com/css?family=Roboto', + { + href: '/apple-touch-icon.png', + rel: 'apple-touch-icon', + sizes: '180x180', + }, + { + href: '/favicon-32x32.png', + rel: 'icon', + sizes: '32x32', + type: 'image/png', + }, + ], + meta: [ + { + description: 'A better default template for html-webpack-plugin.', + }, + ], + mobile: true, + inlineManifestWebpackName: 'webpackManifest', + scripts: [ + 'http://example.com/somescript.js', + { + src: '/myModule.js', + type: 'module', + }, + ], + window: { + env: { + apiHost: 'http://myapi.com/api/v1', + }, + }, + + // And any other config options from html-webpack-plugin: + // https://github.com/ampedandwired/html-webpack-plugin#configuration + title: 'My App', + }, +]; + +const plugins: Array = configs.map(config => + new HtmlWebpackPlugin(config) +); diff --git a/html-webpack-template/index.d.ts b/html-webpack-template/index.d.ts new file mode 100644 index 0000000000..e224e96296 --- /dev/null +++ b/html-webpack-template/index.d.ts @@ -0,0 +1,96 @@ +// Type definitions for html-webpack-template 6.0 +// Project: https://github.com/jaketrent/html-webpack-template +// Definitions by: Benjamin Lim +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Config as HtmlWebpackPluginConfig } from 'html-webpack-plugin'; + +export = HtmlWebpackTemplate; + +declare const HtmlWebpackTemplate: string; + +declare namespace HtmlWebpackTemplate { + export interface GoogleAnalyticsConfig { + trackingId: string; + // Log a pageview event after the analytics code loads. + pageViewOnLoad?: boolean; + } + + export interface Attributes { + [name: string]: any; + } + + type Resource = string | Attributes; + + /** + * string: value is assigned to the href attribute and the rel attribute is + * set to "stylesheet" + * + * object: properties and values are used as the attribute names and values, + * respectively: + */ + export type Link = Resource; + + /** + * string: value is assigned to the src attribute and the type attribute is + * set to "text/javascript"; + * + * object: properties and values are used as the attribute names and values, + * respectively. + */ + export type Script = Resource; + + export interface Config extends HtmlWebpackPluginConfig { + /** + * Set to false. Controls asset addition to the template. This template + * takes care of that. + */ + inject: false; + + // Specify this module's index.ejs file. + template: string; + + // The
element id on which you plan to mount a JavaScript app. + appMountId?: string; + + // An array of application element ids. + appMountIds?: string[]; + + /** + * Adjust the URL for relative URLs in the document (MDN). + * https://developer.mozilla.org/en/docs/Web/HTML/Element/base + */ + baseHref?: string; + + /** + * Insert the webpack-dev-server hot reload script at this + * host:port/path; e.g., http://localhost:3000. + */ + devServer?: string; + + // Track usage of your site via Google Analytics. + googleAnalytics?: GoogleAnalyticsConfig; + + // Array of elements. + links?: Link[]; + + // Array of objects containing key value pairs to be included as meta tags. + meta?: Attributes[]; + + // Sets appropriate meta tag for page scaling. + mobile?: boolean; + + /** + * For use with inline-manifest-webpack-plugin. + * + * https://github.com/szrenwei/inline-manifest-webpack-plugin + */ + inlineManifestWebpackName?: string; + + // Array of external script imports to include on page. + scripts?: Script[]; + + // Object that defines data you need to bootstrap a JavaScript app. + window?: {}; + } +} diff --git a/html-webpack-template/tsconfig.json b/html-webpack-template/tsconfig.json new file mode 100644 index 0000000000..8e51dd1f5c --- /dev/null +++ b/html-webpack-template/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "html-webpack-template-tests.ts" + ] +} diff --git a/html-webpack-template/tslint.json b/html-webpack-template/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/html-webpack-template/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 88b2aae802c17fda4c82b52a14453abe6f97d45c Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Mon, 2 Jan 2017 17:03:06 -0800 Subject: [PATCH 051/181] Deprecate argon2. The lib has its own typings now. (#13696) * Add type definitions for koa-send. * Deprecate argon2 typings. They're included in the lib now. * Remove unneeded file (big upstream merge mistake). --- argon2/argon2-tests.ts | 35 ----------------------------------- argon2/index.d.ts | 39 --------------------------------------- argon2/tsconfig.json | 20 -------------------- argon2/tslint.json | 1 - notNeededPackages.json | 6 ++++++ 5 files changed, 6 insertions(+), 95 deletions(-) delete mode 100644 argon2/argon2-tests.ts delete mode 100644 argon2/index.d.ts delete mode 100644 argon2/tsconfig.json delete mode 100644 argon2/tslint.json diff --git a/argon2/argon2-tests.ts b/argon2/argon2-tests.ts deleted file mode 100644 index 566292b4fa..0000000000 --- a/argon2/argon2-tests.ts +++ /dev/null @@ -1,35 +0,0 @@ - -import { defaults, limits, hash, verify, generateSalt } from 'argon2'; - -main(); - -async function main() { - - const defaultTimeCost: number = defaults.timeCost; - const defaultMemoryCost: number = defaults.memoryCost; - const defaultParallelism: number = defaults.parallelism; - const defaultArgon2d: boolean = defaults.argon2d; - - const minMemoryCost: number = limits.memoryCost.min; - const maxMemoryCost: number = limits.memoryCost.max; - const minTimeCost: number = limits.timeCost.min; - const maxTimeCost: number = limits.timeCost.max; - const minParallelism: number = limits.parallelism.min; - const maxParallelism: number = limits.parallelism.max; - - const options = { - timeCost: 4, - memoryCost: 13, - parallelism: 2, - argon2d: true, - }; - - const hash1: string = await hash('secret', new Buffer(''), options); - const hash2: string = await hash('secret', new Buffer(''), {}); - const hash3: string = await hash('secret', new Buffer('')); - - const verified: boolean = await verify('long-hash', 'secret'); - - const salt1: Buffer = await generateSalt(); - const salt2: Buffer = await generateSalt(32); -} diff --git a/argon2/index.d.ts b/argon2/index.d.ts deleted file mode 100644 index 1cbf1a5156..0000000000 --- a/argon2/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Type definitions for argon2 0.14 -// Project: https://github.com/ranisalt/node-argon2#readme -// Definitions by: Peter Safranek -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -export var defaults: { - timeCost: number; - memoryCost: number; - parallelism: number; - argon2d: boolean; -}; - -export var limits: { - memoryCost: { - min: number; - max: number; - }; - timeCost: { - min: number; - max: number; - }; - parallelism: { - min: number; - max: number; - }; -}; - -export function hash(plain: string, salt: Buffer, options?: { - timeCost?: number; - memoryCost?: number; - parallelism?: number; - argon2d?: boolean; -}): Promise; - -export function verify(hash: string, plain: string): Promise; - -export function generateSalt(length?: number): Promise; diff --git a/argon2/tsconfig.json b/argon2/tsconfig.json deleted file mode 100644 index d58eaf4f82..0000000000 --- a/argon2/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "argon2-tests.ts" - ] -} \ No newline at end of file diff --git a/argon2/tslint.json b/argon2/tslint.json deleted file mode 100644 index 377cc837d4..0000000000 --- a/argon2/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../tslint.json" } diff --git a/notNeededPackages.json b/notNeededPackages.json index 7c695fee83..80dcb22e82 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -268,6 +268,12 @@ "typingsPackageName": "inversify-restify-utils", "sourceRepoURL": "https://github.com/inversify/inversify-restify-utils", "asOfVersion": "2.0.0" + }, + { + "libraryName": "Argon2", + "typingsPackageName": "argon2", + "sourceRepoURL": "https://github.com/ranisalt/node-argon2", + "asOfVersion": "0.15.0" } ] } \ No newline at end of file From 1776ecb31a881ac95d0a3c2766c3d81c276f6117 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Mon, 2 Jan 2017 19:14:19 -0700 Subject: [PATCH 052/181] Added declarations for 'readline-sync'. --- readline-sync/index.d.ts | 67 ++++++++++++++++ readline-sync/readline-sync-tests.ts | 110 +++++++++++++++++++++++++++ readline-sync/tsconfig.json | 20 +++++ readline-sync/tslint.json | 1 + 4 files changed, 198 insertions(+) create mode 100644 readline-sync/index.d.ts create mode 100644 readline-sync/readline-sync-tests.ts create mode 100644 readline-sync/tsconfig.json create mode 100644 readline-sync/tslint.json diff --git a/readline-sync/index.d.ts b/readline-sync/index.d.ts new file mode 100644 index 0000000000..ce7d15d6a4 --- /dev/null +++ b/readline-sync/index.d.ts @@ -0,0 +1,67 @@ +// Type definitions for readline-sync 1.4 +// Project: https://github.com/anseki/readline-sync +// Definitions by: Tristan Jones +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type optionType = string | number | RegExp | ((input:string) => boolean); + +interface BasicOptions { + prompt?: any; + hideEchoBack?: boolean; + mask?: string; + limit?: optionType | Array; + limitMessage?: string; + defaultInput?: string; + trueValue?: optionType | Array; + falseValue?: optionType | Array; + caseSensitive?: boolean; + keepWhitespace?: boolean; + encoding?: string; + bufferSize?: number; + print?: ((display:string, encoding:string) => void); + history?: boolean; + cd?: boolean; + charlist?: string; + min?: any; + max?: any; + confirmMessage?: any; + unmatchMessage?: any; + exists?: any; + isFile?: boolean; + isDirectory?: boolean; + validate?: ((path:string) => boolean | string); + create?: boolean; + guide?: boolean; +} + +// Basic Functions +export function question(query?: any, options?: BasicOptions): string; +export function prompt(options?: BasicOptions): string; +export function keyIn(query?: any, options?: BasicOptions): string; +export function setDefaultOptions(options?: BasicOptions): BasicOptions; + +// Utility Functions +export function questionEMail(query?: any, options?: BasicOptions): string; +export function questionNewPassword(query?: any, options?: BasicOptions): string; +export function questionInt(query?: any, options?: BasicOptions): number; +export function questionFloat(query?: any, options?: BasicOptions): number; +export function questionPath(query?: any, options?: BasicOptions): string; + +export function promptCL(commandHandler?: { [id:string]: ((...args:string[]) => void) } | ((command:string, ...args:string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: ((value:string) => boolean), options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id:string]: ((...args:string[]) => boolean | void) } | ((command:string, ...args:string[]) => boolean | void), options?: BasicOptions): void; +export function promptSimShell(options?: BasicOptions): string; + +export function keyInYN(query?: any, options?: BasicOptions): boolean | string; +export function keyInYNStrict(query?: any, options?: BasicOptions): boolean; +export function keyInPause(query?: any, options?: BasicOptions): void; +export function keyInSelect(items: string[], query?: any, options?: BasicOptions): number; + +export function getRawInput(): string; + +// Deprecated +export function setBufferSize(value: number): void; +export function setEncoding(value: string): void; +export function setMask(value: string): void; +export function setPrint(value: ((display:string, encoding:string) => void)): void; +export function setPrompt(value: any): void; \ No newline at end of file diff --git a/readline-sync/readline-sync-tests.ts b/readline-sync/readline-sync-tests.ts new file mode 100644 index 0000000000..a201659e7a --- /dev/null +++ b/readline-sync/readline-sync-tests.ts @@ -0,0 +1,110 @@ + + +import readlineSync = require('readline-sync'); + +let result:string = readlineSync.question('Which program starts do you want? ', { + defaultInput: 'firefox' +}); + +let result2:string = readlineSync.prompt({prompt: '$$'}); + +let result3:string = readlineSync.keyIn('Press a key', { limit: '$<1-5>' }); + +let result4:{} = readlineSync.setDefaultOptions({ + prompt: '$$', + hideEchoBack: true, + mask: '*', + limit: [ /^a|b$/, /[a-zA-Z]+/], + limitMessage: 'Limit reached', + defaultInput: 'English', + trueValue: 2, + falseValue: (value:string) => { return true; }, + caseSensitive: true, + keepWhitespace: true, + encoding: 'utf-8', + bufferSize: 12, + print: (display:string, encoding:string) => { console.log(display)}, + history: false, + cd: true, + charlist: 'abc', + min: 0, + max: 10, + confirmMessage: 'Yes', + unmatchMessage: new Date(), + exists: false, + isFile: true, + isDirectory: false, + validate: (path:string) => { return (path === '/usr/local/bin'); }, + create: true, + guide: false, +}); + +let result5:string = readlineSync.questionEMail('Enter email'); + +let result6:string = readlineSync.questionNewPassword('PASSWORD: ', {charlist: '$#$@%'}); + +let result7:number = readlineSync.questionInt('Enter an integer', { limitMessage: 'Enter a valid integer' }); + +let result8:number = readlineSync.questionFloat('Enter a float', { limitMessage: 'Enter a valid float' }); + +let result9:string = readlineSync.questionPath('Save to: ', { + isDirectory: true, + exists: null, + create: true +}); + +readlineSync.promptCL((command:string, arg1:string, arg2:string) => { + if (command === 'add') { + console.log(arg1 + ' is added.'); + } else if (command === 'copy') { + console.log(arg1 + ' is copied to ' + arg2 + '.'); + } +}); + +readlineSync.promptCL({ + add: (element:string) => { // It's called by also "ADD", "Add", "aDd", etc.. + console.log(element + ' is added.'); + }, + copy: (from:string, to:string) => { + console.log(from + ' is copied to ' + to + '.'); + } +}); + +readlineSync.promptLoop((input:string) => { + console.log('-- You said "' + input + '"'); + return input === 'bye'; +}); + +readlineSync.promptCLLoop({ + add: (element:string) => { + console.log(element + ' is added.'); + }, + copy: (from:string, to:string) => { + console.log(from + ' is copied to ' + to + '.'); + }, + bye: () => { return true; } +}); + +let result10:string = readlineSync.promptSimShell(); + +let result11:(boolean | string) = readlineSync.keyInYN('Do you want to install this?'); + +let result12:boolean = readlineSync.keyInYNStrict('Do you want to install this?', { guide: true }); + +readlineSync.keyInPause({ guide:true }); + +let frameworks = ['Express', 'hapi', 'flatiron', 'MEAN.JS', 'locomotive']; +let result13:number = readlineSync.keyInSelect(frameworks, 'Which framework?'); + +let result14:string = readlineSync.getRawInput(); + +readlineSync.setPrint((display:string, encoding:string) => { console.log(display) }); + +readlineSync.setPrompt(new Date()); + +readlineSync.setEncoding('utf-16'); + +readlineSync.setMask('%'); + +readlineSync.setBufferSize(128); + diff --git a/readline-sync/tsconfig.json b/readline-sync/tsconfig.json new file mode 100644 index 0000000000..144427ec3c --- /dev/null +++ b/readline-sync/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "readline-sync-tests.ts" + ] +} diff --git a/readline-sync/tslint.json b/readline-sync/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/readline-sync/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 1982f9cfaae81a6b2fb6bc6654e42d8a78e13556 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Mon, 2 Jan 2017 19:22:17 -0700 Subject: [PATCH 053/181] Added fixes to pass linting --- readline-sync/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/readline-sync/index.d.ts b/readline-sync/index.d.ts index ce7d15d6a4..0307af5eda 100644 --- a/readline-sync/index.d.ts +++ b/readline-sync/index.d.ts @@ -3,22 +3,22 @@ // Definitions by: Tristan Jones // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -type optionType = string | number | RegExp | ((input:string) => boolean); +type optionType = string | number | RegExp | ((input: string) => boolean); interface BasicOptions { prompt?: any; hideEchoBack?: boolean; mask?: string; - limit?: optionType | Array; + limit?: optionType | optionType[]; limitMessage?: string; defaultInput?: string; - trueValue?: optionType | Array; - falseValue?: optionType | Array; + trueValue?: optionType | optionType[]; + falseValue?: optionType | optionType[]; caseSensitive?: boolean; keepWhitespace?: boolean; encoding?: string; bufferSize?: number; - print?: ((display:string, encoding:string) => void); + print?: ((display: string, encoding: string) => void); history?: boolean; cd?: boolean; charlist?: string; @@ -29,7 +29,7 @@ interface BasicOptions { exists?: any; isFile?: boolean; isDirectory?: boolean; - validate?: ((path:string) => boolean | string); + validate?: ((path: string) => boolean | string); create?: boolean; guide?: boolean; } @@ -47,9 +47,9 @@ export function questionInt(query?: any, options?: BasicOptions): number; export function questionFloat(query?: any, options?: BasicOptions): number; export function questionPath(query?: any, options?: BasicOptions): string; -export function promptCL(commandHandler?: { [id:string]: ((...args:string[]) => void) } | ((command:string, ...args:string[]) => void), options?: BasicOptions): string[]; -export function promptLoop(inputHandler: ((value:string) => boolean), options?: BasicOptions): void; -export function promptCLLoop(commandHandler?: { [id:string]: ((...args:string[]) => boolean | void) } | ((command:string, ...args:string[]) => boolean | void), options?: BasicOptions): void; +export function promptCL(commandHandler?: { [id: string]: ((...args: string[]) => void) } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: ((value: string) => boolean), options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id: string]: ((...args: string[]) => boolean | void) } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; export function promptSimShell(options?: BasicOptions): string; export function keyInYN(query?: any, options?: BasicOptions): boolean | string; @@ -63,5 +63,5 @@ export function getRawInput(): string; export function setBufferSize(value: number): void; export function setEncoding(value: string): void; export function setMask(value: string): void; -export function setPrint(value: ((display:string, encoding:string) => void)): void; +export function setPrint(value: ((display: string, encoding: string) => void)): void; export function setPrompt(value: any): void; \ No newline at end of file From daf4d787ea7347674e177665fe7f10fa499e8591 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Mon, 2 Jan 2017 22:01:28 -0700 Subject: [PATCH 054/181] Fixed capitalization of OptionTypes and extra parens around functions --- readline-sync/index.d.ts | 40 +++++++++++++++++++++------- readline-sync/readline-sync-tests.ts | 1 - 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/readline-sync/index.d.ts b/readline-sync/index.d.ts index 0307af5eda..78d7e313f9 100644 --- a/readline-sync/index.d.ts +++ b/readline-sync/index.d.ts @@ -3,22 +3,22 @@ // Definitions by: Tristan Jones // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -type optionType = string | number | RegExp | ((input: string) => boolean); +type OptionType = string | number | RegExp | ((input: string) => boolean); interface BasicOptions { prompt?: any; hideEchoBack?: boolean; mask?: string; - limit?: optionType | optionType[]; + limit?: OptionType | OptionType[]; limitMessage?: string; defaultInput?: string; - trueValue?: optionType | optionType[]; - falseValue?: optionType | optionType[]; + trueValue?: OptionType | OptionType[]; + falseValue?: OptionType | OptionType[]; caseSensitive?: boolean; keepWhitespace?: boolean; encoding?: string; bufferSize?: number; - print?: ((display: string, encoding: string) => void); + print?: (display: string, encoding: string) => void; history?: boolean; cd?: boolean; charlist?: string; @@ -29,7 +29,7 @@ interface BasicOptions { exists?: any; isFile?: boolean; isDirectory?: boolean; - validate?: ((path: string) => boolean | string); + validate?: (path: string) => boolean | string; create?: boolean; guide?: boolean; } @@ -47,9 +47,9 @@ export function questionInt(query?: any, options?: BasicOptions): number; export function questionFloat(query?: any, options?: BasicOptions): number; export function questionPath(query?: any, options?: BasicOptions): string; -export function promptCL(commandHandler?: { [id: string]: ((...args: string[]) => void) } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; -export function promptLoop(inputHandler: ((value: string) => boolean), options?: BasicOptions): void; -export function promptCLLoop(commandHandler?: { [id: string]: ((...args: string[]) => boolean | void) } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; +export function promptCL(commandHandler?: { [id: string]: (...args: string[]) => void } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: (value: string) => boolean, options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id: string]: (...args: string[]) => boolean | void } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; export function promptSimShell(options?: BasicOptions): string; export function keyInYN(query?: any, options?: BasicOptions): boolean | string; @@ -60,8 +60,28 @@ export function keyInSelect(items: string[], query?: any, options?: BasicOptions export function getRawInput(): string; // Deprecated + +/** + * @deprecated Use the bufferSize option instead: readlineSync.setDefaultOptions({bufferSize: value}); + */ export function setBufferSize(value: number): void; + +/** + * @deprecated Use the encoding option instead: readlineSync.setDefaultOptions({encoding: value}); + */ export function setEncoding(value: string): void; + +/** + * @deprecated Use the mask option instead: readlineSync.setDefaultOptions({mask: value}); + */ export function setMask(value: string): void; -export function setPrint(value: ((display: string, encoding: string) => void)): void; + +/** + * @deprecated Use the print option instead: readlineSync.setDefaultOptions({print: value}); + */ +export function setPrint(value: (display: string, encoding: string) => void): void; + +/** + * @deprecated Use the prompt option instead: readlineSync.setDefaultOptions({prompt: value}); + */ export function setPrompt(value: any): void; \ No newline at end of file diff --git a/readline-sync/readline-sync-tests.ts b/readline-sync/readline-sync-tests.ts index a201659e7a..02c8d8e952 100644 --- a/readline-sync/readline-sync-tests.ts +++ b/readline-sync/readline-sync-tests.ts @@ -107,4 +107,3 @@ readlineSync.setEncoding('utf-16'); readlineSync.setMask('%'); readlineSync.setBufferSize(128); - From c37d3e05c1fd70b0d7c20f29b757b7c235629935 Mon Sep 17 00:00:00 2001 From: smhc Date: Tue, 3 Jan 2017 15:46:34 +1000 Subject: [PATCH 055/181] Fixed IFilterOrderByItem to not use value: T The value property of IFilterOrderByItem should be any as it is driven by the expression predicate and is not array item. --- angular/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/angular/index.d.ts b/angular/index.d.ts index 7d710eaa7f..3e74ed3321 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -661,14 +661,14 @@ declare namespace angular { (actual: T, expected: T): boolean; } - interface IFilterOrderByItem { - value: T, + interface IFilterOrderByItem { + value: any, type: string, index: any } - interface IFilterOrderByComparatorFunc { - (left: IFilterOrderByItem, right: IFilterOrderByItem): -1 | 0 | 1; + interface IFilterOrderByComparatorFunc { + (left: IFilterOrderByItem, right: IFilterOrderByItem): -1 | 0 | 1; } interface IFilterCurrency { @@ -756,7 +756,7 @@ declare namespace angular { * @param comparator Function used to determine the relative order of value pairs. * @return An array containing the items from the specified collection, ordered by a comparator function based on the values computed using the expression predicate. */ - (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; + (array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean, comparator?: IFilterOrderByComparatorFunc): T[]; } /** From 386659ab1ceea89d12ea039274c705ea6fcedcf4 Mon Sep 17 00:00:00 2001 From: JulienDuf Date: Tue, 3 Jan 2017 03:07:30 -0500 Subject: [PATCH 056/181] node-wit: Fix errors and add new tests --- node-wit/index.d.ts | 28 ++++++-------------- node-wit/node-wit-tests.ts | 53 ++++++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/node-wit/index.d.ts b/node-wit/index.d.ts index 511fde0913..33f0bd8cb9 100644 --- a/node-wit/index.d.ts +++ b/node-wit/index.d.ts @@ -3,13 +3,9 @@ // Definitions by: Julien Dufresne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as Promise from "bluebird"; - export namespace log { - class Logger { - - constructor(lvl: string); + constructor(level: string); } const DEBUG: string; @@ -19,19 +15,16 @@ export namespace log { } export interface WitEntityValue { - value?: string; expressions?: string[]; } export interface WitEntity { - id?: string; values?: WitEntityValue[]; } export interface WitContext { - state?: string[]; reference_time?: string; timezone?: string; @@ -40,8 +33,7 @@ export interface WitContext { } export interface WitRequest { - - sessinId?: string; + sessionId?: string; context?: WitContext; text?: string; entities?: WitEntity[]; @@ -49,33 +41,29 @@ export interface WitRequest { export interface WitResponse { text?: string; - qickReplies?: any; + quickReplies?: any; } export interface WitOption { - - accessToken?: string; + accessToken: string; actions?: any; logger?: log.Logger; } export interface MessageResponseEntity { - - confidence?: number; - value?: string; + confidence: number; + value: string; } export interface MessageResponse { - msg_id: string; _text: string; entities: MessageResponseEntity[]; } export declare class Wit { - constructor(option: WitOption); message(message: string, context: WitContext): Promise; - converse(sessinId: string, message: string, context: WitContext, reset?: boolean): Promise; - runActions(sessinId: string, message: string, context: WitContext, maxSteps?: number): Promise; + converse(sessionId: string, message: string, context: WitContext, reset?: boolean): Promise; + runActions(sessionId: string, message: string, context: WitContext, maxSteps?: number): Promise; } diff --git a/node-wit/node-wit-tests.ts b/node-wit/node-wit-tests.ts index 9bf0f1184e..d71c1d0cad 100644 --- a/node-wit/node-wit-tests.ts +++ b/node-wit/node-wit-tests.ts @@ -1,14 +1,57 @@ -import { Wit, log } from "node-wit"; +import { Wit, log, WitRequest, WitResponse, WitContext } from "node-wit"; -var wit = new Wit({accessToken: "", logger: new log.Logger(log.DEBUG)}); -wit.message("Hello", {}).then((res) => { +var wit = new Wit({ + accessToken: "", + actions: { + send(request: WitRequest, response: WitResponse) { + return new Promise(function(resolve, reject) { + console.log(response.text); + console.log(request.entities); + return resolve(); + }); + }, + myAction(request: WitRequest) { + console.log(`Session ${request.sessionId} received ${request.text}`); + console.log(`The current context is ${JSON.stringify(request.context)}`); + console.log(`Wit extracted ${JSON.stringify(request.entities)}`); + return Promise.resolve(request.context); + } + }, + logger: new log.Logger(log.DEBUG) +}); + +wit.message("what is the weather in London?", {}).then((res) => { console.log(res._text); for (let entity of res.entities) { - console.log(entity.value + ": " + entity.confidence * 100 + "%"); } }).catch((err) => { + console.log(err); +}); -}); \ No newline at end of file +var sessionId = 'my-user-session-42'; +var context0: WitContext = {}; +wit.runActions(sessionId, 'what is the weather in London?', context0) +.then((context1) => { + console.log('The session state is now: ' + JSON.stringify(context1)); + return wit.runActions(sessionId, 'and in Brussels?', context1); +}) +.then((context2) => { + console.log(context2.entities + ", "); + console.log(context2.location + ", "); + console.log(context2.reference_time + ", "); + console.log(context2.state + ", "); + console.log(context2.timezone); +}) +.catch((e) => { + console.log('Oops! Got an error: ' + e); +}); + +wit.converse('my-user-session-42', 'what is the weather in London?', {}) +.then((data) => { + console.log('Yay, got Wit.ai response: ' + JSON.stringify(data)); + console.log(data.entities); +}) +.catch(console.error); \ No newline at end of file From 1afa4639883c5b6334cf6cb16b826ff872e1ab18 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Tue, 3 Jan 2017 06:25:39 -0800 Subject: [PATCH 057/181] Add typings for expr-eval (#13628) * Add typings for expr-eval * Avoid use of Function type * Use (slightly) stricter typings for expr-eval * Update with more PR comments * Disable linter due to bugs, allow CI to pass --- expr-eval/expr-eval-tests.ts | 14 ++++++++++++++ expr-eval/index.d.ts | 37 ++++++++++++++++++++++++++++++++++++ expr-eval/tsconfig.json | 20 +++++++++++++++++++ expr-eval/tslint.json | 1 + 4 files changed, 72 insertions(+) create mode 100644 expr-eval/expr-eval-tests.ts create mode 100644 expr-eval/index.d.ts create mode 100644 expr-eval/tsconfig.json create mode 100644 expr-eval/tslint.json diff --git a/expr-eval/expr-eval-tests.ts b/expr-eval/expr-eval-tests.ts new file mode 100644 index 0000000000..53689ea6bd --- /dev/null +++ b/expr-eval/expr-eval-tests.ts @@ -0,0 +1,14 @@ +import { Parser, Expression } from 'expr-eval'; + +const expr = Parser.parse('2^2'); +Parser.evaluate('2^2'); +Parser.evaluate('2^x', { x: 2 }); +Parser.evaluate('x.toUpperCase()', { x: 'hello world' }); + +expr.evaluate({ x: 3 }); +expr.simplify(); +expr.simplify({ x: 2 }); +expr.variables().forEach(str => str.toUpperCase()); +expr.symbols().forEach(str => str.toUpperCase()); +expr.toJSFunction('y, x'); +expr.toJSFunction('y, z', { y: 2 })({ z: 3 }); diff --git a/expr-eval/index.d.ts b/expr-eval/index.d.ts new file mode 100644 index 0000000000..7f72eb6101 --- /dev/null +++ b/expr-eval/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for expr-eval 1.0 +// Project: https://github.com/silentmatt/expr-eval#readme +// Definitions by: Connor Peet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace exprEval { + type Value = number + | string + | ((...args: Value[]) => Value) + | { [propertyName: string]: Value }; + + interface Values { + [propertyName: string]: Value; + } + + export class Parser { + constructor(options?: { allowMemberAccess?: boolean }); + parse(expression: string): Expression; + evaluate(expression: string, values?: Value): number; + + // todo(connor4312): tslint is disabled on the following two lines, as + // thinks that the above instance methods are overloads for the static methods. + static parse(expression: string): Expression; // tslint:disable-line + static evaluate(expression: string, values?: Value): number; // tslint:disable-line + } + + export interface Expression { + simplify(values?: Values): Expression; + evaluate(values?: Values): number; + substitute(values: Values): Expression; + symbols(): string[]; + variables(): string[]; + toJSFunction(params: string, values?: Values): (...args: Value[]) => number; + } +} + +export = exprEval; diff --git a/expr-eval/tsconfig.json b/expr-eval/tsconfig.json new file mode 100644 index 0000000000..80230f8303 --- /dev/null +++ b/expr-eval/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "expr-eval-tests.ts" + ] +} diff --git a/expr-eval/tslint.json b/expr-eval/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/expr-eval/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 334e1d136358071b200163abb0a9b1db55b5b52e Mon Sep 17 00:00:00 2001 From: Ali Taheri Moghaddar Date: Tue, 3 Jan 2017 18:15:12 +0330 Subject: [PATCH 058/181] Add jalaali-js typings (#13702) * Add jalaali-js typings * Fix version and improve jsdoc formatting --- jalaali-js/index.d.ts | 142 +++++++++++++++++++++++++++++++++ jalaali-js/jalaali-js-tests.ts | 42 ++++++++++ jalaali-js/tsconfig.json | 20 +++++ jalaali-js/tslint.json | 3 + 4 files changed, 207 insertions(+) create mode 100644 jalaali-js/index.d.ts create mode 100644 jalaali-js/jalaali-js-tests.ts create mode 100644 jalaali-js/tsconfig.json create mode 100644 jalaali-js/tslint.json diff --git a/jalaali-js/index.d.ts b/jalaali-js/index.d.ts new file mode 100644 index 0000000000..be002bb60d --- /dev/null +++ b/jalaali-js/index.d.ts @@ -0,0 +1,142 @@ +// Type definitions for jalaali-js 1.1 +// Project: https://github.com/jalaali/jalaali-js +// Definitions by: Ali Taheri Moghaddar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Jalaali date parts + */ +export interface JalaaliDateObject { + /** Jalaali year */ + jy: number; + /** Jalaali month */ + jm: number; + /** Jalaali day */ + jd: number; +} + +/** + * Gregorian date parts + */ +export interface GregorianDateObject { + /** Gregorian year */ + gy: number; + /** Gregorian month */ + gm: number; + /** Gregorian day */ + gd: number; +} + +/** + * Object returned by jalCal function + */ +export interface JalCalResult { + /** Number of years since the last leap year (0 to 4) */ + leap: number; + /** Gregorian year of the beginning of Jalaali year */ + gy: number; + /** The March day of Farvardin the 1st (1st day of jy) */ + march: number; +} + +/** + * Converts a Gregorian date to Jalaali. + * @param gy Gregorian Calendar year (years BC numbered 0, -1, -2, ...) + * @param gm Gregorian Calendar month (1 to 12) + * @param gd Gregorian Calendar day of the month (1 to 28/29/30/31) + */ +export function toJalaali(gy: number, gm: number, gd: number): JalaaliDateObject; + +/** + * Converts a Gregorian Date object to Jalaali. + * @param date Gregorian Date object + */ +export function toJalaali(date: Date): JalaaliDateObject; + +/** + * Converts a Jalaali date to Gregorian. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + * @param jm Jalaali Calendar month (1 to 12) + * @param jd Jalaali Calendar day of the month (1 to 28/29/30/31) + */ +export function toGregorian(jy: number, jm: number, jd: number): GregorianDateObject; + +/** + * Checks whether a Jalaali date is valid or not. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + * @param jm Jalaali Calendar month (1 to 12) + * @param jd Jalaali Calendar day of the month (1 to 28/29/30/31) + */ +export function isValidJalaaliDate(jy: number, jm: number, jd: number): boolean; + +/** + * Check if this is a leap year. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + */ +export function isLeapJalaaliYear(jy: number): boolean; + +/** + * Number of days in a given month in a Jalaali year. + * @param jy Jalaali Calendar year (years BC numbered 0, -1, -2, ...) + * @param jm Jalaali Calendar month (1 to 12) + */ +export function jalaaliMonthLength(jy: number, jm: number): number; + +/** + * This function determines if the Jalaali (Persian) year is + * leap (366-day long) or is the common year (365 days), and + * finds the day in March (Gregorian calendar) of the first + * day of the Jalaali year (jy). + * @param jy Jalaali calendar year (-61 to 3177) + * @return + * leap: number of years since the last leap year (0 to 4) + * gy: Gregorian year of the beginning of Jalaali year + * march: the March day of Farvardin the 1st (1st day of jy) + * @see: http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm + * @see: http://www.fourmilab.ch/documents/calendar/ + */ +export function jalCal(jy: number): JalCalResult; + +/** + * Converts a date of the Jalaali calendar to the Julian Day number. + * @param jy Jalaali year (1 to 3100) + * @param jm Jalaali month (1 to 12) + * @param jd Jalaali day (1 to 29/31) + * @return Julian Day number + */ +export function j2d(jy: number, jm: number, jd: number): number; + +/** + * Converts the Julian Day number to a date in the Jalaali calendar. + * @param jdn Julian Day number + * @return + * jy: Jalaali Calendar year (1 to 3100) + * jm: Jalaali Calendar month (1 to 12) + * jd: Jalaali Calendar day (1 to 29/31) + */ +export function d2j(jdn: number): JalaaliDateObject; + +/** + * Calculates the Julian Day number from Gregorian or Julian + * calendar dates. This integer number corresponds to the noon of + * the date (i.e. 12 hours of Universal Time). + * The procedure was tested to be good since 1 March, -100100 (of both + * calendars) up to a few million years into the future. + * @param gy Gregorian Calendar year (years BC numbered 0, -1, -2, ...) + * @param gm Gregorian Calendar month (1 to 12) + * @param gd Gregorian Calendar day of the month (1 to 28/29/30/31) + * @return Julian Day number + */ +export function g2d(gy: number, gm: number, gd: number): number; + +/** + * Calculates Gregorian and Julian calendar dates from the Julian Day number + * (jdn) for the period since jdn=-34839655 (i.e. the year -100100 of both + * calendars) to some millions years ahead of the present. + * @param jdn Julian Day number + * @return + * gy: Gregorian Calendar year (years BC numbered 0, -1, -2, ...) + * gm: Gregorian Calendar month (1 to 12) + * gd: Gregorian Calendar day of the month M (1 to 28/29/30/31) + */ +export function d2g(jdn: number): GregorianDateObject; diff --git a/jalaali-js/jalaali-js-tests.ts b/jalaali-js/jalaali-js-tests.ts new file mode 100644 index 0000000000..4071d3ca28 --- /dev/null +++ b/jalaali-js/jalaali-js-tests.ts @@ -0,0 +1,42 @@ +import { + toJalaali, + toGregorian, + isValidJalaaliDate, + isLeapJalaaliYear, + jalaaliMonthLength, + jalCal, + j2d, + d2j, + g2d, + d2g, +} from 'jalaali-js'; + +toJalaali(2016, 4, 11); // { jy: 1395, jm: 1, jd: 23 } + +toJalaali(new Date(2016, 3, 11)); // { jy: 1395, jm: 1, jd: 23 } + +toGregorian(1395, 1, 23); // { gy: 2016, gm: 4, gd: 11 } + +isValidJalaaliDate(1394, 12, 30); // false +isValidJalaaliDate(1395, 12, 30); // true + +isLeapJalaaliYear(1394); // false +isLeapJalaaliYear(1395); // true + +jalaaliMonthLength(1394, 12); // 29 +jalaaliMonthLength(1395, 12); // 30 + +jalCal(1390); // { leap: 3, gy: 2011, march: 21 } +jalCal(1391); // { leap: 0, gy: 2012, march: 20 } +jalCal(1392); // { leap: 1, gy: 2013, march: 21 } +jalCal(1393); // { leap: 2, gy: 2014, march: 21 } +jalCal(1394); // { leap: 3, gy: 2015, march: 21 } +jalCal(1395); // { leap: 0, gy: 2016, march: 20 } + +j2d(1395, 1, 23); // 2457490 + +d2j(2457490); // { jy: 1395, jm: 1, jd: 23 } + +g2d(2016, 4, 11); // 2457490 + +d2g(2457490); // { gy: 2016, gm: 4, gd: 11 } diff --git a/jalaali-js/tsconfig.json b/jalaali-js/tsconfig.json new file mode 100644 index 0000000000..780ff29ad6 --- /dev/null +++ b/jalaali-js/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jalaali-js-tests.ts" + ] +} \ No newline at end of file diff --git a/jalaali-js/tslint.json b/jalaali-js/tslint.json new file mode 100644 index 0000000000..fdc7cdc370 --- /dev/null +++ b/jalaali-js/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From b43f9bced037e38c5b6d4166de1e4ff6fb2c9dda Mon Sep 17 00:00:00 2001 From: Brady Liles Date: Tue, 3 Jan 2017 07:58:01 -0700 Subject: [PATCH 059/181] Added Bootstrap-Validator (#13657) * Added Bootstrap-Validator * StrictNullChecks => true * Removed Patch Version --- .../bootstrap-validator-tests.ts | 14 +++++++++++++ bootstrap-validator/index.d.ts | 20 +++++++++++++++++++ bootstrap-validator/tsconfig.json | 20 +++++++++++++++++++ bootstrap-validator/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 bootstrap-validator/bootstrap-validator-tests.ts create mode 100644 bootstrap-validator/index.d.ts create mode 100644 bootstrap-validator/tsconfig.json create mode 100644 bootstrap-validator/tslint.json diff --git a/bootstrap-validator/bootstrap-validator-tests.ts b/bootstrap-validator/bootstrap-validator-tests.ts new file mode 100644 index 0000000000..07d4753ed1 --- /dev/null +++ b/bootstrap-validator/bootstrap-validator-tests.ts @@ -0,0 +1,14 @@ +/// + +$('#myForm').validator(); +$('#myForm').validator('update'); +$('#myForm').validator('validate'); +$('#myForm').validator('destroy'); +$('#myForm').validator({ + delay: 500, + html: false, + disable: false, + focus: true, + feedback: {}, + custom: {} +}); diff --git a/bootstrap-validator/index.d.ts b/bootstrap-validator/index.d.ts new file mode 100644 index 0000000000..92dee2c310 --- /dev/null +++ b/bootstrap-validator/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for bootstrap-validator 0.11 +// Project: https://github.com/1000hz/bootstrap-validator +// Definitions by: Brady Liles +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +interface ValidatorOptions { + delay?: number; + html?: boolean; + disable?: boolean; + focus?: boolean; + feedback?: any; + custom?: any; +} + +interface JQuery { + validator(options?: ValidatorOptions): JQuery; + validator(command: string): JQuery; +} diff --git a/bootstrap-validator/tsconfig.json b/bootstrap-validator/tsconfig.json new file mode 100644 index 0000000000..d5bde637e0 --- /dev/null +++ b/bootstrap-validator/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bootstrap-validator-tests.ts" + ] +} diff --git a/bootstrap-validator/tslint.json b/bootstrap-validator/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/bootstrap-validator/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 7b6d9b01582ec90cc5bc9ace6b1320a55d2a0634 Mon Sep 17 00:00:00 2001 From: reblace Date: Tue, 3 Jan 2017 12:46:13 -0500 Subject: [PATCH 060/181] Making the latLngToCoords property more restrictive. A three tuple is assinable to a one, two, or three tuple. --- leaflet/index.d.ts | 3 ++- leaflet/leaflet-tests.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 1e8231f497..fdaea84934 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -844,7 +844,8 @@ declare namespace L { /** * Reverse of coordsToLatLng */ - static latLngToCoords(latlng: LatLng): number[]; + static latLngToCoords(latlng: LatLng): [number, number, number]; // A three tuple can be assigned to a two or three tuple + /** * Reverse of coordsToLatLngs closed determines whether the first point should be diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 93d019b46b..b36337aa6c 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -360,11 +360,11 @@ draggable.on('drag', () => {}); let twoCoords: [number, number] = [1, 2]; latLng = L.GeoJSON.coordsToLatLng(twoCoords); -let coords: number[] = L.GeoJSON.latLngToCoords(latLng); +twoCoords = L.GeoJSON.latLngToCoords(latLng); let threeCoords: [number, number, number] = [1, 2, 3]; latLng = L.GeoJSON.coordsToLatLng(threeCoords); -coords = L.GeoJSON.latLngToCoords(latLng); +threeCoords = L.GeoJSON.latLngToCoords(latLng); let nestedTwoCoords = [ [12, 13], [13, 14], [14, 15] ]; let nestedLatLngs: L.LatLng[] = L.GeoJSON.coordsToLatLngs(nestedTwoCoords, 1); From 6b628df7b4730f405128bcddeed618a20828a8be Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 3 Jan 2017 12:53:50 -0500 Subject: [PATCH 061/181] Meow showHelp optional param (#13710) --- meow/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meow/index.d.ts b/meow/index.d.ts index d687f65611..fe208c83f5 100644 --- a/meow/index.d.ts +++ b/meow/index.d.ts @@ -22,7 +22,7 @@ declare namespace meow { flags: { [name: string]: any }; pkg: any; help: string; - showHelp(code: number): void; + showHelp(code?: number): void; } } From 4f8d89c52e204cba51c4d753d27bbc531cf400ce Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 3 Jan 2017 09:54:10 -0800 Subject: [PATCH 062/181] Revert #13423: Change `createBrowserHistory` back to `createHistory` (#13709) --- history/history-tests.ts | 18 +++++++++--------- history/index.d.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/history/history-tests.ts b/history/history-tests.ts index 454b223e09..1d6565838e 100644 --- a/history/history-tests.ts +++ b/history/history-tests.ts @@ -1,4 +1,4 @@ -import { createBrowserHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history' +import { createHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history' import { getUserConfirmation } from 'history/lib/DOMUtils' @@ -10,7 +10,7 @@ let doSomethingAsync: () => Promise; let input = { value: "" }; { - let history = createBrowserHistory() + let history = createHistory() // Listen for changes to the current location. The // listener is called once immediately. @@ -46,7 +46,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory() + let history = createHistory() // Pushing a path string. history.push('/the/path') @@ -63,7 +63,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory() + let history = createHistory() history.listenBefore(function(location) { if (input.value !== '') return 'Are you sure you want to leave this page?' @@ -75,7 +75,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory({ + let history = createHistory({ getUserConfirmation(message, callback) { callback(window.confirm(message)) // The default behavior } @@ -83,7 +83,7 @@ let input = { value: "" }; } { - let history = useBeforeUnload(createBrowserHistory)() + let history = useBeforeUnload(createHistory)() history.listenBeforeUnload(function() { return 'Are you sure you want to leave this page?' @@ -91,7 +91,7 @@ let input = { value: "" }; } { - let history = useQueries(createBrowserHistory)() + let history = useQueries(createHistory)() history.listen(function(location) { console.log(location.query) @@ -99,7 +99,7 @@ let input = { value: "" }; } { - let history = useQueries(createBrowserHistory)({ + let history = useQueries(createHistory)({ parseQueryString: function(queryString) { // TODO: return a parsed version of queryString return {}; @@ -116,7 +116,7 @@ let input = { value: "" }; { // Run our app under the /base URL. - let history = useBasename(createBrowserHistory)({ + let history = useBasename(createHistory)({ basename: '/base' }) diff --git a/history/index.d.ts b/history/index.d.ts index 5f719c2f0b..6b61fa1b77 100644 --- a/history/index.d.ts +++ b/history/index.d.ts @@ -127,7 +127,7 @@ export interface Module { }; } -export { default as createBrowserHistory } from "./lib/createBrowserHistory"; +export { default as createHistory } from "./lib/createBrowserHistory"; export { default as createHashHistory } from "./lib/createHashHistory"; export { default as createMemoryHistory } from "./lib/createMemoryHistory"; export { default as createLocation } from "./lib/createLocation"; From 3876a417cd0bb5ffd1e530d7768ac91612e5184d Mon Sep 17 00:00:00 2001 From: Alfy Date: Tue, 3 Jan 2017 21:02:50 +0300 Subject: [PATCH 063/181] Added types to functions for FlexSlider (#13708) * Changed noImplicitAny to true * Added any type to the functions * Fixed failing tests * Changed canAdvance to return a boolean --- flexslider/flexSlider-tests.ts | 4 ++-- flexslider/index.d.ts | 12 ++++++------ flexslider/tsconfig.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flexslider/flexSlider-tests.ts b/flexslider/flexSlider-tests.ts index 2369ce9b31..591e874262 100644 --- a/flexslider/flexSlider-tests.ts +++ b/flexslider/flexSlider-tests.ts @@ -62,7 +62,7 @@ $(window).load(function() { var player = document.getElementById('player_1'); $(player).on('ready', ready); - function addEvent(element, eventName, callback) { + function addEvent(element:any, eventName:any, callback:any) { if (element.addEventListener) { element.addEventListener(eventName, callback, false) } else { @@ -70,7 +70,7 @@ $(window).load(function() { } } - function ready(player_id) { + function ready(player_id: any) { var froogaloop = $(player_id); froogaloop.on('play', function(data) { $('.flexslider').flexslider("pause"); diff --git a/flexslider/index.d.ts b/flexslider/index.d.ts index c15d5d59be..9767744919 100644 --- a/flexslider/index.d.ts +++ b/flexslider/index.d.ts @@ -18,11 +18,11 @@ interface SliderObject { //Object: The slider element itself directionNav: Object; //Object: The slider directionNav controlsContainer: Object; //Object: The controlsContainer element of the slider manualControls: Object; //Object: The manualControls element of the slider - flexAnimate(target, pause?); //Function: Move slider - (target, pause) parameters - pause(); //Function: Pause slider slideshow interval - resume(); //Function: Resume slider slideshow interval - canAdvance(target); //Function: returns boolean if slider can advance - (target) parameter - getTarget(dir); //Function: get target given a direction - "next" or "prev" parameter + flexAnimate(target:any, pause?: any) :any; //Function: Move slider - (target, pause) parameters + pause(): any; //Function: Pause slider slideshow interval + resume(): any; //Function: Resume slider slideshow interval + canAdvance(target:any): boolean; //Function: returns boolean if slider can advance - (target) parameter + getTarget(dir: any): any; //Function: get target given a direction - "next" or "prev" parameter } interface FlexSliderOptions { @@ -86,5 +86,5 @@ interface FlexSliderOptions { interface JQuery { - flexslider(options?: FlexSliderOptions); + flexslider(options?: FlexSliderOptions): any; } diff --git a/flexslider/tsconfig.json b/flexslider/tsconfig.json index c34db7d4d9..2319b11528 100644 --- a/flexslider/tsconfig.json +++ b/flexslider/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es6", - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "baseUrl": "../", From 18e96e67d7c60b226281a509e9dccb2f23bcecae Mon Sep 17 00:00:00 2001 From: a8775 Date: Tue, 3 Jan 2017 19:21:31 +0100 Subject: [PATCH 064/181] add HeapInfo interface to v8 module (#13677) * add HeapInfo interface to v8 module Documentation: https://nodejs.org/dist/latest-v7.x/docs/api/v8.html#v8_v8_getheapstatistics Changes: - add HeapInfo interface to the v8 module, add missing fields: malloced_memory, peak_malloced_memory, does_zap_garbage - change return type for the method: v8.getHeapStatistics() * change does_zap_garbage type to be 0|1 * add const enum DoesZapCodeSpaceFlag type --- node/index.d.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/node/index.d.ts b/node/index.d.ts index c7f481015c..54f9f53753 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -3961,7 +3961,25 @@ declare module "v8" { space_available_size: number; physical_space_size: number; } - export function getHeapStatistics(): { total_heap_size: number, total_heap_size_executable: number, total_physical_size: number, total_avaialble_size: number, used_heap_size: number, heap_size_limit: number }; + + const enum DoesZapCodeSpaceFlag { + Disabled = 0, + Enabled = 1 + } + + interface HeapInfo { + total_heap_size: number; + total_heap_size_executable: number; + total_physical_size: number; + total_available_size: number; + used_heap_size: number; + heap_size_limit: number; + malloced_memory: number; + peak_malloced_memory: number; + does_zap_garbage: DoesZapCodeSpaceFlag; + } + + export function getHeapStatistics(): HeapInfo; export function getHeapSpaceStatistics(): HeapSpaceInfo[]; export function setFlagsFromString(flags: string): void; } From a1b6a0884a9c0725a04c08a23b97dd803baed476 Mon Sep 17 00:00:00 2001 From: Bryan Johnson Date: Tue, 3 Jan 2017 11:30:59 -0700 Subject: [PATCH 065/181] Update mapbox-gl typings to 0.29.0 --- mapbox-gl/index.d.ts | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/mapbox-gl/index.d.ts b/mapbox-gl/index.d.ts index a0ba241d99..360eb1ce33 100644 --- a/mapbox-gl/index.d.ts +++ b/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.27.0 +// Type definitions for Mapbox GL JS v0.29.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -64,6 +64,8 @@ declare namespace mapboxgl { addLayer(layer: mapboxgl.Layer, before?: string): this; + moveLayer(id: string, beforeId?: string): this; + removeLayer(id: string): this; getLayer(id: string): mapboxgl.Layer; @@ -330,6 +332,12 @@ declare namespace mapboxgl { enableRotation(): void; } + export interface IControl { + onAdd(map: Map): HTMLElement; + onRemove(map: Map): any; + getDefaultPosition(): string; + } + /** * Control */ @@ -343,11 +351,17 @@ declare namespace mapboxgl { constructor(); } + export class PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; + } + /** * Geolocate */ export class GeolocateControl extends Control { - constructor(); + constructor(options?: {positionOptions?: PositionOptions, watchPosition?: boolean}); } /** @@ -704,6 +718,9 @@ declare namespace mapboxgl { export class MapDataEvent { type: string; dataType: "source" | "style" | "tile"; + isSourceLoaded?: boolean; + source?: mapboxgl.Source; + coord?: any; } /** @@ -760,6 +777,9 @@ declare namespace mapboxgl { contextmenu?: {data: mapboxgl.MapMouseEvent}; dblclick?: {data: mapboxgl.MapMouseEvent}; click?: {data: mapboxgl.MapMouseEvent}; + tiledataloading?: {data: mapboxgl.MapDataEvent}; + sourcedataloading?: {data: mapboxgl.MapDataEvent}; + styledataloading?: {data: mapboxgl.MapDataEvent}; touchcancel?: {data: mapboxgl.MapTouchEvent}; touchmove?: {data: mapboxgl.MapTouchEvent}; touchend?: {data: mapboxgl.MapTouchEvent}; @@ -772,6 +792,8 @@ declare namespace mapboxgl { movestart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; mouseout?:{data: mapboxgl.MapMouseEvent}; load?: void; + sourcedata?: {data: mapboxgl.MapDataEvent}; + styledata?: {data: mapboxgl.MapDataEvent}; zoomend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; zoom?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; zoomstart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent}; @@ -845,6 +867,7 @@ declare namespace mapboxgl { "fill-extrusion-color"?: string | StyleFunction; "fill-extrusion-translate"?: number[]; "fill-extrusion-translate-anchor"?: "map" | "viewport"; + "fill-extrusion-pattern": string; "fill-extrusion-height"?: number | StyleFunction; "fill-extrusion-base"?: number; } @@ -888,7 +911,7 @@ declare namespace mapboxgl { "icon-rotate"?: number | StyleFunction; "icon-padding"?: number; "icon-keep-upright"?: boolean; - "icon-offset"?: number[]; + "icon-offset"?: number[] | StyleFunction; "text-pitch-alignment"?: "map" | "viewport" | "auto"; "text-rotation-alignment"?: "map" | "viewport" | "auto"; "text-field"?: string; @@ -954,6 +977,9 @@ declare namespace mapboxgl { "circle-translate"?: number[]; "circle-translate-anchor"?: "map" | "viewport"; "circle-pitch-scale"?: "map" | "viewport"; + "circle-stroke-width"?: number | StyleFunction; + "circle-stoke-color"?: string | StyleFunction; + "circle-stroke-opactiy"?: number | StyleFunction; } } From 5f1f3ebb00568c016844d3a93b690fa1143aa2a2 Mon Sep 17 00:00:00 2001 From: Mizunashi Mana Date: Wed, 4 Jan 2017 05:17:41 +0900 Subject: [PATCH 066/181] Add extract-zip types (#13713) --- extract-zip/extract-zip-tests.ts | 20 ++++++++++++++++++++ extract-zip/index.d.ts | 21 +++++++++++++++++++++ extract-zip/tsconfig.json | 20 ++++++++++++++++++++ extract-zip/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 extract-zip/extract-zip-tests.ts create mode 100644 extract-zip/index.d.ts create mode 100644 extract-zip/tsconfig.json create mode 100644 extract-zip/tslint.json diff --git a/extract-zip/extract-zip-tests.ts b/extract-zip/extract-zip-tests.ts new file mode 100644 index 0000000000..33b3a714af --- /dev/null +++ b/extract-zip/extract-zip-tests.ts @@ -0,0 +1,20 @@ +import * as extract from 'extract-zip'; + +let str = 'str'; +let num = 0; + +let options: extract.Options = { + dir: str, +}; +options = { + dir: str, + defaultFileMode: num, +}; + +extract(str, options, (err) => { + if (err) { + console.error(err); + return; + } + console.log('done'); +}); diff --git a/extract-zip/index.d.ts b/extract-zip/index.d.ts new file mode 100644 index 0000000000..52ce40094f --- /dev/null +++ b/extract-zip/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for extract-zip 1.6 +// Project: https://github.com/maxogden/extract-zip +// Definitions by: Mizunashi Mana +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace extract { + export interface Options { + dir?: string; + defaultDirMode?: number; + defaultFileMode?: number; + onEntry?: (entry: any, zipfile: any) => void; + } +} + +declare function extract( + zipPath: string, + opts: extract.Options, + cb: (err?: Error) => void, +): void; + +export = extract; diff --git a/extract-zip/tsconfig.json b/extract-zip/tsconfig.json new file mode 100644 index 0000000000..9a52a5d990 --- /dev/null +++ b/extract-zip/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "extract-zip-tests.ts" + ] +} diff --git a/extract-zip/tslint.json b/extract-zip/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/extract-zip/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From b784512c2e943d4b12b20a5f1337306e4d9d7c3b Mon Sep 17 00:00:00 2001 From: Matthew Clive Date: Tue, 3 Jan 2017 15:19:02 -0500 Subject: [PATCH 067/181] Update Configstore/index.d.ts with accurate definitions for 2.1.0 (#13714) * Fix whitespacing issue * Update index.d.ts * Add version number back * Forgot a line of the header * Update Configstore tests Configstore is a class now, and doesn't expose these properties * Create Configstore/tslint.json * Update index.d.ts * Remove JSDoc types per @andy-ms * Forgot the size property * Update index.d.ts --- configstore/configstore-tests.ts | 7 +-- configstore/index.d.ts | 92 ++++++++++++++++++++++---------- configstore/tslint.json | 3 ++ 3 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 configstore/tslint.json diff --git a/configstore/configstore-tests.ts b/configstore/configstore-tests.ts index 5a615ae9fa..0d8e777fe0 100644 --- a/configstore/configstore-tests.ts +++ b/configstore/configstore-tests.ts @@ -1,5 +1,6 @@ -import cs = require('configstore'); +import Configstore = require('configstore'); +var cs = new Configstore('foo'); var value: any; var key: string; @@ -9,9 +10,9 @@ var object:Object; cs.set(key, value); value = cs.get(key); -cs.del(key); +cs.delete(key); object = cs.all; cs.all = object; num = cs.size; -key = cs.path; \ No newline at end of file +key = cs.path; diff --git a/configstore/index.d.ts b/configstore/index.d.ts index 5d8463b45b..628a4a1d6c 100644 --- a/configstore/index.d.ts +++ b/configstore/index.d.ts @@ -1,37 +1,71 @@ -// Type definitions for configstore 0.3.0 +// Type definitions for configstore 2.1 // Project: https://github.com/yeoman/configstore -// Definitions by: Bart van der Schoor +// Definitions by: ArcticLight // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = Configstore; -/* - Set an item - */ -export declare function set(key: string, val: any): void; +declare class Configstore { + constructor(packageName: string, defaults?: any, options?: Configstore.ConfigstoreOptions); -/* - Get an item - */ -export declare function get(key: string): any; + /** + * Get the path to the config file. Can be used to show the user + * where it is, or better, open it for them. + */ + path: string; -/* - Delete an item - */ -export declare function del(key: string): void; + /** + * Get all items as an object or replace the current config with an object. + */ + all: any; -/* - Get all items as an object or replace the current config with an object: + /** + * Get the item count + */ + size: number; - conf.all = { - hello: 'world' - }; - */ -export declare var all: Object; -/* - Get the item count - */ -export declare var size: number; -/* - Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them. - */ -export declare var path: string; + /** + * Get an item + * @param key The string key to get + * @return The contents of the config from key $key + */ + get(key: string): any; + + /** + * Set an item + * @param key The string key + * @param val The value to set + */ + set(key: string, val: any): void; + + /** + * Set all key/value pairs declared in $values + * @param values The values object. + */ + set(values: any): void; + + /** + * Determines if a key is present in the config + * @param key The string key to test for + * @return True if the key is present + */ + has(key: string): boolean; + + /** + * Delete an item. + * @param key The key to delete + */ + delete(key: string): void; + + /** + * Clear the config. + * Equivalent to Configstore.all = {}; + */ + clear(): void; + } + +declare namespace Configstore { + export interface ConfigstoreOptions { + globalConfigPath?: boolean; + } +} diff --git a/configstore/tslint.json b/configstore/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/configstore/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 36a5697b553e2b9ea3bcd4c746143397da2f3c31 Mon Sep 17 00:00:00 2001 From: Masahiro Wakame Date: Wed, 4 Jan 2017 07:37:51 +0900 Subject: [PATCH 068/181] fix chai-json-schema styling (#13537) --- chai-json-schema/index.d.ts | 24 ++++++++++++------------ chai-json-schema/tslint.json | 6 +----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/chai-json-schema/index.d.ts b/chai-json-schema/index.d.ts index e3e4934c76..e66e2c96af 100644 --- a/chai-json-schema/index.d.ts +++ b/chai-json-schema/index.d.ts @@ -6,19 +6,19 @@ // // -declare namespace Chai { - export interface Assert { - jsonSchema(value: any, schema: any, msg?: string): void; - notJsonSchema(value: any, schema: any, msg?: string): void; - } +declare global { + namespace Chai { + export interface Assert { + jsonSchema(value: any, schema: any, msg?: string): void; + notJsonSchema(value: any, schema: any, msg?: string): void; + } - export interface LanguageChains { - jsonSchema(schema: any, msg?: string): void; + export interface LanguageChains { + jsonSchema(schema: any, msg?: string): void; + } } } -declare module "chai-json-schema" { - function chaiJsonSchema(chai: any, utils: any): void; - namespace chaiJsonSchema {} - export = chaiJsonSchema; -} +declare function chaiJsonSchema(chai: any, utils: any): void; +declare namespace chaiJsonSchema { } +export = chaiJsonSchema; diff --git a/chai-json-schema/tslint.json b/chai-json-schema/tslint.json index 83a03ce890..377cc837d4 100644 --- a/chai-json-schema/tslint.json +++ b/chai-json-schema/tslint.json @@ -1,5 +1 @@ -{ "extends": "../tslint.json", - "rules": { - "no-single-declare-module": false - } -} +{ "extends": "../tslint.json" } From f914c29ba3a58bc78dd3c235d603c189cc9396e7 Mon Sep 17 00:00:00 2001 From: Grant Hutchins Date: Tue, 3 Jan 2017 16:40:53 -0600 Subject: [PATCH 069/181] googlemaps: Allow Marker.setAnimation(null) and Marker.setMap(null) (#13240) * googlemaps: Allow Marker.setAnimation(null) * Also, turn on strictNullChecks * Allow new google.maps.Map(null) since it's technically possible with Google's example code from the docs Signed-off-by: Iqbal Yusuf * googlemaps: Allow Marker.setMap(null) * Also, add more test code from the Google Maps API documentation Signed-off-by: Grant Hutchins --- googlemaps/google.maps-tests.ts | 95 ++++++++++++++++++++++++++++++--- googlemaps/index.d.ts | 10 ++-- googlemaps/tsconfig.json | 4 +- 3 files changed, 96 insertions(+), 13 deletions(-) diff --git a/googlemaps/google.maps-tests.ts b/googlemaps/google.maps-tests.ts index 9829a23a1a..87fcc424bf 100644 --- a/googlemaps/google.maps-tests.ts +++ b/googlemaps/google.maps-tests.ts @@ -141,19 +141,102 @@ var mapTypeStyle: google.maps.MapTypeStyle ={ stylers: [], }; -// https://developers.google.com/maps/documentation/javascript/adding-a-google-map -function initMap() { - var uluru = {lat: -25.363, lng: 131.044}; +// https://developers.google.com/maps/documentation/javascript/markers +function initMap1() { + var myLatLng = {lat: -25.363, lng: 131.044}; + var map = new google.maps.Map(document.getElementById('map'), { zoom: 4, - center: uluru + center: myLatLng }); + var marker = new google.maps.Marker({ - position: uluru, + position: myLatLng, + map: map, + title: 'Hello World!' + }); +} + +var myLatlng = new google.maps.LatLng(-25.363882,131.044922); +var mapOptions = { + zoom: 4, + center: myLatlng +} +var map = new google.maps.Map(document.getElementById("map"), mapOptions); + +var marker = new google.maps.Marker({ + position: myLatlng, + title:"Hello World!" +}); + +// To add the marker to the map, call setMap(); +marker.setMap(map); + +marker.setMap(null); + +// The following example creates a marker in Stockholm, Sweden using a DROP +// animation. Clicking on the marker will toggle the animation between a BOUNCE +// animation and no animation. + +var marker: google.maps.Marker; + +function initMap2() { + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 13, + center: {lat: 59.325, lng: 18.070} + }); + + marker = new google.maps.Marker({ + map: map, + draggable: true, + animation: google.maps.Animation.DROP, + position: {lat: 59.327, lng: 18.067} + }); + marker.addListener('click', toggleBounce); +} + +function toggleBounce() { + if (marker.getAnimation() !== null) { + marker.setAnimation(null); + } else { + marker.setAnimation(google.maps.Animation.BOUNCE); + } +} + +// In the following example, markers appear when the user clicks on the map. +// Each marker is labeled with a single alphabetical character. +var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; +var labelIndex = 0; + +function initialize() { + var bangalore = { lat: 12.97, lng: 77.59 }; + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 12, + center: bangalore + }); + + // This event listener calls addMarker() when the map is clicked. + google.maps.event.addListener(map, 'click', function(event: any) { + addMarker(event.latLng, map); + }); + + // Add a marker at the center of the map. + addMarker(bangalore, map); +} + +// Adds a marker to the map. +function addMarker(location: google.maps.LatLngLiteral, map: google.maps.Map) { + // Add the marker at the clicked location, and add the next-available label + // from the array of alphabetical characters. + var marker = new google.maps.Marker({ + position: location, + label: labels[labelIndex++ % labels.length], map: map }); } +google.maps.event.addDomListener(window, 'load', initialize); + /***** OverlayView *****/ var div = document.createElement('div'); var overlay = new google.maps.OverlayView(); @@ -165,4 +248,4 @@ panes.markerLayer.appendChild(div); panes.overlayImage.appendChild(div); panes.overlayLayer.appendChild(div); panes.overlayMouseTarget.appendChild(div); -panes.overlayShadow.appendChild(div); +panes.overlayShadow.appendChild(div); \ No newline at end of file diff --git a/googlemaps/index.d.ts b/googlemaps/index.d.ts index 28feff6d03..bccfb51299 100644 --- a/googlemaps/index.d.ts +++ b/googlemaps/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Maps JavaScript API 3.25 // Project: https://developers.google.com/maps/ -// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin +// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin , Grant Hutchins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* @@ -30,7 +30,7 @@ THE SOFTWARE. declare namespace google.maps { /***** Map *****/ export class Map extends MVCObject { - constructor(mapDiv: Element, opts?: MapOptions); + constructor(mapDiv: Element|null, opts?: MapOptions); fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void; getBounds(): LatLngBounds; getCenter(): LatLng; @@ -349,14 +349,14 @@ declare namespace google.maps { getTitle(): string; getVisible(): boolean; getZIndex(): number; - setAnimation(animation: Animation): void; + setAnimation(animation: Animation|null): void; setAttribution(attribution: Attribution): void; setClickable(flag: boolean): void; setCursor(cursor: string): void; setDraggable(flag: boolean): void; setIcon(icon: string|Icon|Symbol): void; setLabel(label: string|MarkerLabel): void; - setMap(map: Map|StreetViewPanorama): void; + setMap(map: Map|StreetViewPanorama|null): void; setOpacity(opacity: number): void; setOptions(options: MarkerOptions): void; setPlace(place: Place): void; @@ -1801,7 +1801,7 @@ declare namespace google.maps { /** Returns a string of the form "lat,lng". We round the lat/lng values to 6 decimal places by default. */ toUrlValue(precision?: number): string; /** Converts to JSON representation. This function is intended to be used via JSON.stringify. */ - toJSON(): LatLngLiteral; + toJSON(): LatLngLiteral; } export type LatLngLiteral = { lat: number; lng: number } diff --git a/googlemaps/tsconfig.json b/googlemaps/tsconfig.json index deafdc4eec..dff0eb7ca3 100644 --- a/googlemaps/tsconfig.json +++ b/googlemaps/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -16,4 +16,4 @@ "index.d.ts", "google.maps-tests.ts" ] -} \ No newline at end of file +} From ee770df8befef4863ff5ad29534b3b7ae64474c6 Mon Sep 17 00:00:00 2001 From: Sebastiaan de Rooij Date: Tue, 3 Jan 2017 23:45:16 +0100 Subject: [PATCH 070/181] off added and namespaces updated (#13511) --- dropzone/dropzone-commonjs-tests.ts | 42 ++-- dropzone/dropzone-tests.ts | 52 +++-- dropzone/index.d.ts | 312 ++++++++++++++-------------- 3 files changed, 207 insertions(+), 199 deletions(-) mode change 100644 => 100755 dropzone/dropzone-commonjs-tests.ts mode change 100644 => 100755 dropzone/dropzone-tests.ts mode change 100644 => 100755 dropzone/index.d.ts diff --git a/dropzone/dropzone-commonjs-tests.ts b/dropzone/dropzone-commonjs-tests.ts old mode 100644 new mode 100755 index 0e202168a2..c77de6e583 --- a/dropzone/dropzone-commonjs-tests.ts +++ b/dropzone/dropzone-commonjs-tests.ts @@ -48,7 +48,7 @@ const dropzoneWithOptions = new Dropzone(".test", { dictRemoveFileConfirmation: "", dictMaxFilesExceeded: "", - accept: (file:DropzoneFile, done:(error?:string|Error) => void) => { + accept: (file:Dropzone.DropzoneFile, done:(error?:string|Error) => void) => { if (file.accepted) { file.previewElement.classList.add("accepted"); file.previewTemplate.classList.add("accepted"); @@ -62,7 +62,7 @@ const dropzoneWithOptions = new Dropzone(".test", { init: () => console.log("Initialized"), forceFallback: false, fallback: () => console.log("Fallback"), - resize: (file:DropzoneFile) => ({ + resize: (file:Dropzone.DropzoneFile) => ({ srcX: 0, srcY: 0, trgX: 10, @@ -85,34 +85,34 @@ const dropzoneWithOptions = new Dropzone(".test", { reset: () => console.log("Reset"), - addedfile: (file:DropzoneFile) => console.log("Addedfile"), - addedfiles: (files:DropzoneFile[]) => console.log("Addedfiles"), - removedfile: (file:DropzoneFile) => console.log("Removedfile"), - thumbnail: (file:DropzoneFile, dataUrl:string) => console.log("Thumbnail"), + addedfile: (file:Dropzone.DropzoneFile) => console.log("Addedfile"), + addedfiles: (files:Dropzone.DropzoneFile[]) => console.log("Addedfiles"), + removedfile: (file:Dropzone.DropzoneFile) => console.log("Removedfile"), + thumbnail: (file:Dropzone.DropzoneFile, dataUrl:string) => console.log("Thumbnail"), - error: (file:DropzoneFile, message:string|Error) => console.log("Error"), - errormultiple: (files:DropzoneFile[], message:string|Error) => console.log("Errormultiple"), + error: (file:Dropzone.DropzoneFile, message:string|Error) => console.log("Error"), + errormultiple: (files:Dropzone.DropzoneFile[], message:string|Error) => console.log("Errormultiple"), - processing: (file:DropzoneFile) => console.log("Processing"), - processingmultiple: (files:DropzoneFile[]) => console.log("Processingmultiple"), + processing: (file:Dropzone.DropzoneFile) => console.log("Processing"), + processingmultiple: (files:Dropzone.DropzoneFile[]) => console.log("Processingmultiple"), - uploadprogress: (file:DropzoneFile, progress:number, bytesSent:number) => console.log("Uploadprogress"), + uploadprogress: (file:Dropzone.DropzoneFile, progress:number, bytesSent:number) => console.log("Uploadprogress"), totaluploadprogress: (totalProgress:number, totalBytes:number, totalBytesSent:number) => console.log("Totaluploadprogress"), - sending: (file:DropzoneFile, xhr:XMLHttpRequest, formData:{}) => console.log("Sending"), - sendingmultiple: (files:DropzoneFile[], xhr:XMLHttpRequest, formData:{}) => console.log("Sendingmultiple"), + sending: (file:Dropzone.DropzoneFile, xhr:XMLHttpRequest, formData:{}) => console.log("Sending"), + sendingmultiple: (files:Dropzone.DropzoneFile[], xhr:XMLHttpRequest, formData:{}) => console.log("Sendingmultiple"), - success: (file:DropzoneFile) => console.log("Success"), - successmultiple: (files:DropzoneFile[]) => console.log("Successmultiple"), + success: (file:Dropzone.DropzoneFile) => console.log("Success"), + successmultiple: (files:Dropzone.DropzoneFile[]) => console.log("Successmultiple"), - canceled: (file:DropzoneFile) => console.log("Canceled"), - canceledmultiple: (file:DropzoneFile[]) => console.log("Canceledmultiple"), + canceled: (file:Dropzone.DropzoneFile) => console.log("Canceled"), + canceledmultiple: (file:Dropzone.DropzoneFile[]) => console.log("Canceledmultiple"), - complete: (file:DropzoneFile) => console.log("Complete"), - completemultiple: (file:DropzoneFile[]) => console.log("Completemultiple"), + complete: (file:Dropzone.DropzoneFile) => console.log("Complete"), + completemultiple: (file:Dropzone.DropzoneFile[]) => console.log("Completemultiple"), - maxfilesexceeded: (file:DropzoneFile) => console.log("Maxfilesexceeded"), - maxfilesreached: (files:DropzoneFile[]) => console.log("Maxfilesreached"), + maxfilesexceeded: (file:Dropzone.DropzoneFile) => console.log("Maxfilesexceeded"), + maxfilesreached: (files:Dropzone.DropzoneFile[]) => console.log("Maxfilesreached"), queuecomplete: () => console.log("Queuecomplete"), previewTemplate: "
", diff --git a/dropzone/dropzone-tests.ts b/dropzone/dropzone-tests.ts old mode 100644 new mode 100755 index d3b5c4a1fb..f52cbc303e --- a/dropzone/dropzone-tests.ts +++ b/dropzone/dropzone-tests.ts @@ -47,7 +47,7 @@ const dropzoneWithOptions = new Dropzone(".test", { dictRemoveFileConfirmation: "", dictMaxFilesExceeded: "", - accept: (file:DropzoneFile, done:(error?:string|Error) => void) => { + accept: (file:Dropzone.DropzoneFile, done:(error?:string|Error) => void) => { if (file.accepted) { file.previewElement.classList.add("accepted"); file.previewTemplate.classList.add("accepted"); @@ -61,7 +61,7 @@ const dropzoneWithOptions = new Dropzone(".test", { init: () => console.log("Initialized"), forceFallback: false, fallback: () => console.log("Fallback"), - resize: (file:DropzoneFile) => ({ + resize: (file:Dropzone.DropzoneFile) => ({ srcX: 0, srcY: 0, trgX: 10, @@ -84,34 +84,34 @@ const dropzoneWithOptions = new Dropzone(".test", { reset: () => console.log("Reset"), - addedfile: (file:DropzoneFile) => console.log("Addedfile"), - addedfiles: (files:DropzoneFile[]) => console.log("Addedfiles"), - removedfile: (file:DropzoneFile) => console.log("Removedfile"), - thumbnail: (file:DropzoneFile, dataUrl:string) => console.log("Thumbnail"), + addedfile: (file:Dropzone.DropzoneFile) => console.log("Addedfile"), + addedfiles: (files:Dropzone.DropzoneFile[]) => console.log("Addedfiles"), + removedfile: (file:Dropzone.DropzoneFile) => console.log("Removedfile"), + thumbnail: (file:Dropzone.DropzoneFile, dataUrl:string) => console.log("Thumbnail"), - error: (file:DropzoneFile, message:string|Error) => console.log("Error"), - errormultiple: (files:DropzoneFile[], message:string|Error) => console.log("Errormultiple"), + error: (file:Dropzone.DropzoneFile, message:string|Error) => console.log("Error"), + errormultiple: (files:Dropzone.DropzoneFile[], message:string|Error) => console.log("Errormultiple"), - processing: (file:DropzoneFile) => console.log("Processing"), - processingmultiple: (files:DropzoneFile[]) => console.log("Processingmultiple"), + processing: (file:Dropzone.DropzoneFile) => console.log("Processing"), + processingmultiple: (files:Dropzone.DropzoneFile[]) => console.log("Processingmultiple"), - uploadprogress: (file:DropzoneFile, progress:number, bytesSent:number) => console.log("Uploadprogress"), + uploadprogress: (file:Dropzone.DropzoneFile, progress:number, bytesSent:number) => console.log("Uploadprogress"), totaluploadprogress: (totalProgress:number, totalBytes:number, totalBytesSent:number) => console.log("Totaluploadprogress"), - sending: (file:DropzoneFile, xhr:XMLHttpRequest, formData:{}) => console.log("Sending"), - sendingmultiple: (files:DropzoneFile[], xhr:XMLHttpRequest, formData:{}) => console.log("Sendingmultiple"), + sending: (file:Dropzone.DropzoneFile, xhr:XMLHttpRequest, formData:{}) => console.log("Sending"), + sendingmultiple: (files:Dropzone.DropzoneFile[], xhr:XMLHttpRequest, formData:{}) => console.log("Sendingmultiple"), - success: (file:DropzoneFile) => console.log("Success"), - successmultiple: (files:DropzoneFile[]) => console.log("Successmultiple"), + success: (file:Dropzone.DropzoneFile) => console.log("Success"), + successmultiple: (files:Dropzone.DropzoneFile[]) => console.log("Successmultiple"), - canceled: (file:DropzoneFile) => console.log("Canceled"), - canceledmultiple: (file:DropzoneFile[]) => console.log("Canceledmultiple"), + canceled: (file:Dropzone.DropzoneFile) => console.log("Canceled"), + canceledmultiple: (file:Dropzone.DropzoneFile[]) => console.log("Canceledmultiple"), - complete: (file:DropzoneFile) => console.log("Complete"), - completemultiple: (file:DropzoneFile[]) => console.log("Completemultiple"), + complete: (file:Dropzone.DropzoneFile) => console.log("Complete"), + completemultiple: (file:Dropzone.DropzoneFile[]) => console.log("Completemultiple"), - maxfilesexceeded: (file:DropzoneFile) => console.log("Maxfilesexceeded"), - maxfilesreached: (files:DropzoneFile[]) => console.log("Maxfilesreached"), + maxfilesexceeded: (file:Dropzone.DropzoneFile) => console.log("Maxfilesexceeded"), + maxfilesreached: (files:Dropzone.DropzoneFile[]) => console.log("Maxfilesreached"), queuecomplete: () => console.log("Queuecomplete"), previewTemplate: "
", @@ -135,10 +135,10 @@ dropzoneWithOptionsVariations = new Dropzone(".test", { }); dropzoneWithOptionsVariations = new Dropzone(".test", { - success: (file:DropzoneFile, response:Object) => console.log(file, response) + success: (file:Dropzone.DropzoneFile, response:Object) => console.log(file, response) }); dropzoneWithOptionsVariations = new Dropzone(".test", { - success: (file:DropzoneFile, response:string) => console.log(file, response) + success: (file:Dropzone.DropzoneFile, response:string) => console.log(file, response) }); const dropzone = new Dropzone(".test"); @@ -287,4 +287,10 @@ dropzone console.count('queuecomplete'); }); + dropzone.off("drop", () => { + console.count('drop'); + }) + .off("dragstart") + .off(); + dropzone.destroy(); diff --git a/dropzone/index.d.ts b/dropzone/index.d.ts old mode 100644 new mode 100755 index 88d18602f4..905fa53ab9 --- a/dropzone/index.d.ts +++ b/dropzone/index.d.ts @@ -1,122 +1,124 @@ // Type definitions for Dropzone 4.3.0 // Project: http://www.dropzonejs.com/ -// Definitions by: Natan Vivo , Andy Hawkins , Vasya Aksyonov , Simon Huber +// Definitions by: Natan Vivo , Andy Hawkins , Vasya Aksyonov , Simon Huber , Sebastiaan de Rooij // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -interface DropzoneResizeInfo { - srcX?:number; - srcY?:number; - trgX?:number; - trgY?:number; - srcWidth?:number; - srcHeight?:number; - trgWidth?:number; - trgHeight?:number; - optWidth?:number; - optHeight?:number; -} +declare namespace Dropzone { + export interface DropzoneResizeInfo { + srcX?:number; + srcY?:number; + trgX?:number; + trgY?:number; + srcWidth?:number; + srcHeight?:number; + trgWidth?:number; + trgHeight?:number; + optWidth?:number; + optHeight?:number; + } -interface DropzoneFile extends File { - previewElement: HTMLElement; - previewTemplate: HTMLElement; - previewsContainer: HTMLElement; - status: string; - accepted: boolean; - xhr?: XMLHttpRequest; -} + export interface DropzoneFile extends File { + previewElement: HTMLElement; + previewTemplate: HTMLElement; + previewsContainer: HTMLElement; + status: string; + accepted: boolean; + xhr?: XMLHttpRequest; + } -interface DropzoneOptions { - url?: string; - method?: string; - withCredentials?: boolean; - parallelUploads?: number; - uploadMultiple?: boolean; - maxFilesize?: number; - paramName?: string; - createImageThumbnails?: boolean; - maxThumbnailFilesize?: number; - thumbnailWidth?: number; - thumbnailHeight?: number; - filesizeBase?: number; - maxFiles?: number; - params?: {}; - headers?: {}; - clickable?: boolean|string|HTMLElement|(string|HTMLElement)[]; - ignoreHiddenFiles?: boolean; - acceptedFiles?: string; - renameFilename?(name:string): string; - autoProcessQueue?: boolean; - autoQueue?: boolean; - addRemoveLinks?: boolean; - previewsContainer?: boolean|string|HTMLElement; - hiddenInputContainer?: HTMLElement; - capture?: string; + export interface DropzoneOptions { + url?: string; + method?: string; + withCredentials?: boolean; + parallelUploads?: number; + uploadMultiple?: boolean; + maxFilesize?: number; + paramName?: string; + createImageThumbnails?: boolean; + maxThumbnailFilesize?: number; + thumbnailWidth?: number; + thumbnailHeight?: number; + filesizeBase?: number; + maxFiles?: number; + params?: {}; + headers?: {}; + clickable?: boolean|string|HTMLElement|(string|HTMLElement)[]; + ignoreHiddenFiles?: boolean; + acceptedFiles?: string; + renameFilename?(name:string): string; + autoProcessQueue?: boolean; + autoQueue?: boolean; + addRemoveLinks?: boolean; + previewsContainer?: boolean|string|HTMLElement; + hiddenInputContainer?: HTMLElement; + capture?: string; - dictDefaultMessage?: string; - dictFallbackMessage?: string; - dictFallbackText?: string; - dictFileTooBig?: string; - dictInvalidFileType?: string; - dictResponseError?: string; - dictCancelUpload?: string; - dictCancelUploadConfirmation?: string; - dictRemoveFile?: string; - dictRemoveFileConfirmation?: string; - dictMaxFilesExceeded?: string; + dictDefaultMessage?: string; + dictFallbackMessage?: string; + dictFallbackText?: string; + dictFileTooBig?: string; + dictInvalidFileType?: string; + dictResponseError?: string; + dictCancelUpload?: string; + dictCancelUploadConfirmation?: string; + dictRemoveFile?: string; + dictRemoveFileConfirmation?: string; + dictMaxFilesExceeded?: string; - accept?(file:DropzoneFile, done:(error?:string|Error) => void):void; - init?():void; - forceFallback?: boolean; - fallback?():void; - resize?(file:DropzoneFile):DropzoneResizeInfo; + accept?(file:DropzoneFile, done:(error?:string|Error) => void):void; + init?():void; + forceFallback?: boolean; + fallback?():void; + resize?(file:DropzoneFile):DropzoneResizeInfo; - drop?(e:DragEvent):void; - dragstart?(e:DragEvent):void; - dragend?(e:DragEvent):void; - dragenter?(e:DragEvent):void; - dragover?(e:DragEvent):void; - dragleave?(e:DragEvent):void; - paste?(e:DragEvent):void; + drop?(e:DragEvent):void; + dragstart?(e:DragEvent):void; + dragend?(e:DragEvent):void; + dragenter?(e:DragEvent):void; + dragover?(e:DragEvent):void; + dragleave?(e:DragEvent):void; + paste?(e:DragEvent):void; - reset?():void; + reset?():void; - addedfile?(file:DropzoneFile):void; - addedfiles?(files:DropzoneFile[]):void; - removedfile?(file:DropzoneFile):void; - thumbnail?(file:DropzoneFile, dataUrl:string):void; + addedfile?(file:DropzoneFile):void; + addedfiles?(files:DropzoneFile[]):void; + removedfile?(file:DropzoneFile):void; + thumbnail?(file:DropzoneFile, dataUrl:string):void; - error?(file:DropzoneFile, message:string|Error, xhr:XMLHttpRequest):void; - errormultiple?(files:DropzoneFile[], message:string|Error, xhr:XMLHttpRequest):void; + error?(file:DropzoneFile, message:string|Error, xhr:XMLHttpRequest):void; + errormultiple?(files:DropzoneFile[], message:string|Error, xhr:XMLHttpRequest):void; - processing?(file:DropzoneFile):void; - processingmultiple?(files:DropzoneFile[]):void; + processing?(file:DropzoneFile):void; + processingmultiple?(files:DropzoneFile[]):void; - uploadprogress?(file:DropzoneFile, progress:number, bytesSent:number):void; - totaluploadprogress?(totalProgress:number, totalBytes:number, totalBytesSent:number):void; + uploadprogress?(file:DropzoneFile, progress:number, bytesSent:number):void; + totaluploadprogress?(totalProgress:number, totalBytes:number, totalBytesSent:number):void; - sending?(file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData):void; - sendingmultiple?(files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData):void; + sending?(file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData):void; + sendingmultiple?(files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData):void; - success?(file: DropzoneFile, response: Object|string): void; - successmultiple?(files:DropzoneFile[], responseText:string):void; + success?(file: DropzoneFile, response: Object|string): void; + successmultiple?(files:DropzoneFile[], responseText:string):void; - canceled?(file:DropzoneFile):void; - canceledmultiple?(file:DropzoneFile[]):void; + canceled?(file:DropzoneFile):void; + canceledmultiple?(file:DropzoneFile[]):void; - complete?(file:DropzoneFile):void; - completemultiple?(file:DropzoneFile[]):void; + complete?(file:DropzoneFile):void; + completemultiple?(file:DropzoneFile[]):void; - maxfilesexceeded?(file:DropzoneFile):void; - maxfilesreached?(files:DropzoneFile[]):void; - queuecomplete?():void; + maxfilesexceeded?(file:DropzoneFile):void; + maxfilesreached?(files:DropzoneFile[]):void; + queuecomplete?():void; - previewTemplate?: string; + previewTemplate?: string; + } } declare class Dropzone { - constructor(container:string|HTMLElement, options?:DropzoneOptions); + constructor(container:string|HTMLElement, options?:Dropzone.DropzoneOptions); static autoDiscover:boolean; static options:any; @@ -131,7 +133,7 @@ declare class Dropzone { static ERROR:string; static SUCCESS:string; - files:DropzoneFile[]; + files:Dropzone.DropzoneFile[]; enable():void; @@ -139,47 +141,48 @@ declare class Dropzone { destroy():Dropzone; - addFile(file:DropzoneFile):void; + addFile(file:Dropzone.DropzoneFile):void; - removeFile(file:DropzoneFile):void; + removeFile(file:Dropzone.DropzoneFile):void; removeAllFiles(cancelIfNecessary?:boolean):void; processQueue():void; - cancelUpload(file:DropzoneFile):void; + cancelUpload(file:Dropzone.DropzoneFile):void; - processFiles(files:DropzoneFile[]):void; + processFiles(files:Dropzone.DropzoneFile[]):void; - processFile(file:DropzoneFile):void; + processFile(file:Dropzone.DropzoneFile):void; - uploadFile(file:DropzoneFile):void; + uploadFile(file:Dropzone.DropzoneFile):void; - getAcceptedFiles():DropzoneFile[]; + getAcceptedFiles():Dropzone.DropzoneFile[]; - getRejectedFiles():DropzoneFile[]; + getRejectedFiles():Dropzone.DropzoneFile[]; - getQueuedFiles():DropzoneFile[]; + getQueuedFiles():Dropzone.DropzoneFile[]; - getUploadingFiles():DropzoneFile[]; + getUploadingFiles():Dropzone.DropzoneFile[]; - accept(file:DropzoneFile, done:(error?:string|Error) => void):void; + accept(file:Dropzone.DropzoneFile, done:(error?:string|Error) => void):void; - getActiveFiles():DropzoneFile[]; + getActiveFiles():Dropzone.DropzoneFile[]; - getFilesWithStatus(status:string):DropzoneFile[]; + getFilesWithStatus(status:string):Dropzone.DropzoneFile[]; - enqueueFile(file:DropzoneFile):void; + enqueueFile(file:Dropzone.DropzoneFile):void; - enqueueFiles(file:DropzoneFile[]):void; + enqueueFiles(file:Dropzone.DropzoneFile[]):void; - createThumbnail(file:DropzoneFile, callback?:(...args:any[]) => void):any; + createThumbnail(file:Dropzone.DropzoneFile, callback?:(...args:any[]) => void):any; - createThumbnailFromUrl(file:DropzoneFile, url:string, callback?:(...args:any[]) => void):any; + createThumbnailFromUrl(file:Dropzone.DropzoneFile, url:string, callback?:(...args:any[]) => void):any; on(eventName:string, callback:(...args:any[]) => void):Dropzone; - off(eventName:string):Dropzone; + off(): Dropzone; + off(eventName:string, callback?:(...args:any[]) => void):Dropzone; emit(eventName:string, ...args:any[]):Dropzone; @@ -193,34 +196,34 @@ declare class Dropzone { on(eventName:"reset"):Dropzone; - on(eventName:"addedfile", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"addedfiles", callback:(files:DropzoneFile[]) => any):Dropzone; - on(eventName:"removedfile", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"thumbnail", callback:(file:DropzoneFile, dataUrl:string) => any):Dropzone; + on(eventName:"addedfile", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"addedfiles", callback:(files:Dropzone.DropzoneFile[]) => any):Dropzone; + on(eventName:"removedfile", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"thumbnail", callback:(file:Dropzone.DropzoneFile, dataUrl:string) => any):Dropzone; - on(eventName:"error", callback:(file:DropzoneFile, message:string|Error) => any):Dropzone; - on(eventName:"errormultiple", callback:(files:DropzoneFile[], message:string|Error) => any):Dropzone; + on(eventName:"error", callback:(file:Dropzone.DropzoneFile, message:string|Error) => any):Dropzone; + on(eventName:"errormultiple", callback:(files:Dropzone.DropzoneFile[], message:string|Error) => any):Dropzone; - on(eventName:"processing", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"processingmultiple", callback:(files:DropzoneFile[]) => any):Dropzone; + on(eventName:"processing", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"processingmultiple", callback:(files:Dropzone.DropzoneFile[]) => any):Dropzone; - on(eventName:"uploadprogress", callback:(file:DropzoneFile, progress:number, bytesSent:number) => any):Dropzone; + on(eventName:"uploadprogress", callback:(file:Dropzone.DropzoneFile, progress:number, bytesSent:number) => any):Dropzone; on(eventName:"totaluploadprogress", callback:(totalProgress:number, totalBytes:number, totalBytesSent:number) => any):Dropzone; - on(eventName:"sending", callback:(file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData) => any):Dropzone; - on(eventName:"sendingmultiple", callback:(files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData) => any):Dropzone; + on(eventName:"sending", callback:(file:Dropzone.DropzoneFile, xhr:XMLHttpRequest, formData:FormData) => any):Dropzone; + on(eventName:"sendingmultiple", callback:(files:Dropzone.DropzoneFile[], xhr:XMLHttpRequest, formData:FormData) => any):Dropzone; - on(eventName:"success", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"successmultiple", callback:(files:DropzoneFile[]) => any):Dropzone; + on(eventName:"success", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"successmultiple", callback:(files:Dropzone.DropzoneFile[]) => any):Dropzone; - on(eventName:"canceled", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"canceledmultiple", callback:(file:DropzoneFile[]) => any):Dropzone; + on(eventName:"canceled", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"canceledmultiple", callback:(file:Dropzone.DropzoneFile[]) => any):Dropzone; - on(eventName:"complete", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"completemultiple", callback:(file:DropzoneFile[]) => any):Dropzone; + on(eventName:"complete", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"completemultiple", callback:(file:Dropzone.DropzoneFile[]) => any):Dropzone; - on(eventName:"maxfilesexceeded", callback:(file:DropzoneFile) => any):Dropzone; - on(eventName:"maxfilesreached", callback:(files:DropzoneFile[]) => any):Dropzone; + on(eventName:"maxfilesexceeded", callback:(file:Dropzone.DropzoneFile) => any):Dropzone; + on(eventName:"maxfilesreached", callback:(files:Dropzone.DropzoneFile[]) => any):Dropzone; on(eventName:"queuecomplete"):Dropzone; emit(eventName:"drop", e:DragEvent):Dropzone; @@ -233,42 +236,41 @@ declare class Dropzone { emit(eventName:"reset"):Dropzone; - emit(eventName:"addedfile", file:DropzoneFile):Dropzone; - emit(eventName:"addedfiles", files:DropzoneFile[]):Dropzone; - emit(eventName:"removedfile", file:DropzoneFile):Dropzone; - emit(eventName:"thumbnail", file:DropzoneFile, dataUrl:string):Dropzone; + emit(eventName:"addedfile", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"addedfiles", files:Dropzone.DropzoneFile[]):Dropzone; + emit(eventName:"removedfile", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"thumbnail", file:Dropzone.DropzoneFile, dataUrl:string):Dropzone; - emit(eventName:"error", file:DropzoneFile, message:string|Error):Dropzone; - emit(eventName:"errormultiple", files:DropzoneFile[], message:string|Error):Dropzone; + emit(eventName:"error", file:Dropzone.DropzoneFile, message:string|Error):Dropzone; + emit(eventName:"errormultiple", files:Dropzone.DropzoneFile[], message:string|Error):Dropzone; - emit(eventName:"processing", file:DropzoneFile):Dropzone; - emit(eventName:"processingmultiple", files:DropzoneFile[]):Dropzone; + emit(eventName:"processing", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"processingmultiple", files:Dropzone.DropzoneFile[]):Dropzone; - emit(eventName:"uploadprogress", file:DropzoneFile, progress:number, bytesSent:number):Dropzone; + emit(eventName:"uploadprogress", file:Dropzone.DropzoneFile, progress:number, bytesSent:number):Dropzone; emit(eventName:"totaluploadprogress", totalProgress:number, totalBytes:number, totalBytesSent:number):Dropzone; - emit(eventName:"sending", file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData):Dropzone; - emit(eventName:"sendingmultiple", files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData):Dropzone; + emit(eventName:"sending", file:Dropzone.DropzoneFile, xhr:XMLHttpRequest, formData:FormData):Dropzone; + emit(eventName:"sendingmultiple", files:Dropzone.DropzoneFile[], xhr:XMLHttpRequest, formData:FormData):Dropzone; - emit(eventName:"success", file:DropzoneFile):Dropzone; - emit(eventName:"successmultiple", files:DropzoneFile[]):Dropzone; + emit(eventName:"success", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"successmultiple", files:Dropzone.DropzoneFile[]):Dropzone; - emit(eventName:"canceled", file:DropzoneFile):Dropzone; - emit(eventName:"canceledmultiple", file:DropzoneFile[]):Dropzone; + emit(eventName:"canceled", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"canceledmultiple", file:Dropzone.DropzoneFile[]):Dropzone; - emit(eventName:"complete", file:DropzoneFile):Dropzone; - emit(eventName:"completemultiple", file:DropzoneFile[]):Dropzone; + emit(eventName:"complete", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"completemultiple", file:Dropzone.DropzoneFile[]):Dropzone; - emit(eventName:"maxfilesexceeded", file:DropzoneFile):Dropzone; - emit(eventName:"maxfilesreached", files:DropzoneFile[]):Dropzone; + emit(eventName:"maxfilesexceeded", file:Dropzone.DropzoneFile):Dropzone; + emit(eventName:"maxfilesreached", files:Dropzone.DropzoneFile[]):Dropzone; emit(eventName:"queuecomplete"):Dropzone; } interface JQuery { - dropzone(options:DropzoneOptions): Dropzone; + dropzone(options:Dropzone.DropzoneOptions): Dropzone; } -declare module "dropzone" { - export = Dropzone; -} +export = Dropzone; +export as namespace Dropzone; From 296bee463234b1907de752fd1da9b3f4c0c70700 Mon Sep 17 00:00:00 2001 From: KostiaTretiak Date: Wed, 4 Jan 2017 01:07:18 +0200 Subject: [PATCH 071/181] Fixed and extended declarations for 'assert-plus'. --- assert-plus/index.d.ts | 510 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 475 insertions(+), 35 deletions(-) diff --git a/assert-plus/index.d.ts b/assert-plus/index.d.ts index 2bdcae3250..920419ba60 100644 --- a/assert-plus/index.d.ts +++ b/assert-plus/index.d.ts @@ -3,65 +3,505 @@ // Definitions by: Костя Третяк // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +import {Stream} from 'stream'; + +/** + * + */ export function array(options: any[], message ?: string): void; + +/** + * + */ export function bool(options: boolean, message ?: string): void; -export function buffer(options: any, message ?: string): void; + +/** + * + */ +export function buffer(options: Buffer, message ?: string): void; + +/** + * + */ export function func(options: any, message ?: string): void; + +/** + * + */ export function number(options: number, message ?: string): void; -export function finite(options: any, message ?: string): void; + +/** + * + */ +export function finite(options: number, message ?: string): void; + +/** + * + */ export function object(options: any, message ?: string): void; + +/** + * + */ export function string(options: string, message ?: string): void; -export function stream(options: any, message ?: string): void; -export function date(options: string | number, message ?: string): void; -export function regexp(options: any, message ?: string): void; + +/** + * + */ +export function stream(options: Stream, message ?: string): void; + +/** + * + */ +export function date(options: Date, message ?: string): void; + +/** + * + */ +export function regexp(options: RegExp, message ?: string): void; + +/** + * + */ export function uuid(options: string, message ?: string): void; -export function arrayOfArray(options: any[], message ?: string): void; + +/** + * + */ +export function arrayOfArray(options: any[][], message ?: string): void; + +/** + * + */ export function arrayOfBool(options: boolean[], message ?: string): void; -export function arrayOfBuffer(options: any[], message ?: string): void; + +/** + * + */ +export function arrayOfBuffer(options: Buffer[], message ?: string): void; + +/** + * + */ export function arrayOfFunc(options: any[], message ?: string): void; + +/** + * + */ export function arrayOfNumber(options: number[], message ?: string): void; -export function arrayOfFinite(options: any[], message ?: string): void; + +/** + * + */ +export function arrayOfFinite(options: number[], message ?: string): void; + +/** + * + */ export function arrayOfObject(options: any[], message ?: string): void; + +/** + * + */ export function arrayOfString(options: string[], message ?: string): void; -export function arrayOfStream(options: any[], message ?: string): void; -export function arrayOfDate(options: Array, message ?: string): void; -export function arrayOfRegexp(options: any[], message ?: string): void; + +/** + * + */ +export function arrayOfStream(options: Stream[], message ?: string): void; + +/** + * + */ +export function arrayOfDate(options: Date[], message ?: string): void; + +/** + * + */ +export function arrayOfRegexp(options: RegExp[], message ?: string): void; + +/** + * + */ export function arrayOfUuid(options: string[], message ?: string): void; -export function optionalArray(options: any, message ?: string): void; -export function optionalBool(options: any, message ?: string): void; -export function optionalBuffer(options: any, message ?: string): void; -export function optionalFunc(options: any, message ?: string): void; -export function optionalNumber(options: any, message ?: string): void; -export function optionalFinite(options: any, message ?: string): void; -export function optionalObject(options: any, message ?: string): void; -export function optionalString(options: any, message ?: string): void; -export function optionalStream(options: any, message ?: string): void; -export function optionalDate(options: any, message ?: string): void; -export function optionalRegexp(options: any, message ?: string): void; -export function optionalUuid(options: any, message ?: string): void; -export function optionalArrayOfArray(options: any, message ?: string): void; -export function optionalArrayOfBool(options: any, message ?: string): void; -export function optionalArrayOfBuffer(options: any, message ?: string): void; -export function optionalArrayOfFunc(options: any, message ?: string): void; -export function optionalArrayOfNumber(options: any, message ?: string): void; -export function optionalArrayOfFinite(options: any, message ?: string): void; -export function optionalArrayOfObject(options: any, message ?: string): void; -export function optionalArrayOfString(options: any, message ?: string): void; -export function optionalArrayOfStream(options: any, message ?: string): void; -export function optionalArrayOfDate(options: any, message ?: string): void; -export function optionalArrayOfRegexp(options: any, message ?: string): void; -export function optionalArrayOfUuid(options: any, message ?: string): void; + +/** + * + */ +export function optionalArray(options ?: any[], message ?: string): void; + +/** + * + */ +export function optionalBool(options ?: boolean, message ?: string): void; + +/** + * + */ +export function optionalBuffer(options ?: Buffer, message ?: string): void; + +/** + * + */ +export function optionalFunc(options ?: any, message ?: string): void; + +/** + * + */ +export function optionalNumber(options ?: number, message ?: string): void; + +/** + * + */ +export function optionalFinite(options ?: number, message ?: string): void; + +/** + * + */ +export function optionalObject(options ?: any, message ?: string): void; + +/** + * + */ +export function optionalString(options ?: string, message ?: string): void; + +/** + * + */ +export function optionalStream(options ?: Stream, message ?: string): void; + +/** + * + */ +export function optionalDate(options ?: Date, message ?: string): void; + +/** + * + */ +export function optionalRegexp(options ?: RegExp, message ?: string): void; + +/** + * + */ +export function optionalUuid(options ?: string, message ?: string): void; + +/** + * + */ +export function optionalArrayOfArray(options ?: any[][], message ?: string): void; + +/** + * + */ +export function optionalArrayOfBool(options ?: boolean[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfBuffer(options ?: Buffer[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfFunc(options ?: any[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfNumber(options ?: number[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfFinite(options ?: number[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfObject(options ?: any[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfString(options ?: string[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfStream(options ?: Stream[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfDate(options ?: Date[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfRegexp(options ?: RegExp[], message ?: string): void; + +/** + * + */ +export function optionalArrayOfUuid(options ?: string[], message ?: string): void; + +/** + * + */ export function AssertionError(options: any, message ?: string): void; + +/** + * Throws an `AssertionError`. If `message` is falsy, the error message is set + * as the values of `actual` and `expected` separated by the provided `operator`. + * Otherwise, the error message is the value of `message`. + * + * ```js + * const assert = require('assert'); + * + * assert.fail(1, 2, undefined, '>'); + * // AssertionError: 1 > 2 + * + * assert.fail(1, 2, 'whoops', '>'); + * // AssertionError: whoops + * ``` + */ export function fail(actual: any, expected: any, message: any, operator: any): void; + + +/** + * Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`. + * + * If `value` is not truthy, an `AssertionError` is thrown with a `message` property + * set equal to the value of the `message` parameter. + * If the `message` parameter is `undefined`, a default error message is assigned. + * + * ```js + * const assert = require('assert'); + * + * assert.ok(true); + * // OK + * assert.ok(1); + * // OK + * assert.ok(false); + * // throws "AssertionError: false == true" + * assert.ok(0); + * // throws "AssertionError: 0 == true" + * assert.ok(false, 'it\'s false'); + * // throws "AssertionError: it's false" + * ``` + */ export function ok(options: any, message ?: string): void; + +/** + * Tests shallow, coercive equality between the actual and expected parameters + * using the equal comparison operator ( `==` ). + * + * ```js + * const assert = require('assert'); + * + * assert.equal(1, 1); + * // OK, 1 == 1 + * assert.equal(1, '1'); + * // OK, 1 == '1' + * + * assert.equal(1, 2); + * // AssertionError: 1 == 2 + * assert.equal({a: {b: 1}}, {a: {b: 1}}); + * //AssertionError: { a: { b: 1 } } == { a: { b: 1 } } + * ``` + * + * If the values are not equal, an `AssertionError` is thrown with + * a `message` property set equal to the value of the `message` parameter. + * If the `message` parameter is undefined, a default error message is assigned. + */ export function equal(actual: any, expected: any, message ?: string): void; + +/** + * Tests shallow, coercive inequality with the not equal comparison operator ( `!=` ). + * + * ```js + * const assert = require('assert'); + * + * assert.notEqual(1, 2); + * // OK + * + * assert.notEqual(1, 1); + * // AssertionError: 1 != 1 + * + * assert.notEqual(1, '1'); + * // AssertionError: 1 != '1' + * ``` + * + * If the values are equal, an `AssertionError` is thrown with + * a `message` property set equal to the value of the `message` parameter. + * If the `message` parameter is undefined, a default error message is assigned. + */ export function notEqual(actual: any, expected: any, message ?: string): void; + +/** + * Tests for deep equality between the `actual` and `expected` parameters. + * Primitive values are compared with the equal comparison operator ( `==` ). + * + * Only enumerable "own" properties are considered. + * The `deepEqual()` implementation does not test object prototypes, attached symbols, + * or non-enumerable properties. This can lead to some potentially surprising results. + * For example, the following example does not throw an `AssertionError` because + * the properties on the Error object are non-enumerable: + * + * ```js + * // WARNING: This does not throw an AssertionError! + * assert.deepEqual(Error('a'), Error('b')); + * ``` + * + * "Deep" equality means that the enumerable "own" properties of child objects are evaluated also. + * + * If the values are not equal, an `AssertionError` is thrown with a `message` property + * set equal to the value of the `message` parameter. If the `message` parameter is undefined, + * a default error message is assigned. + */ export function deepEqual(actual: any, expected: any, message ?: string): void; + +/** + * Tests for any deep inequality. Opposite of `assert.deepEqual()`. + * + * ```js + * const assert = require('assert'); + * + * const obj1 = { a : { b : 1 } }; + * const obj2 = { a : { b : 2 } }; + * const obj3 = { a : { b : 1 } }; + * const obj4 = Object.create(obj1); + * + * assert.notDeepEqual(obj1, obj1); + * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } + * + * assert.notDeepEqual(obj1, obj2); + * // OK, obj1 and obj2 are not deeply equal + * + * assert.notDeepEqual(obj1, obj3); + * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } } + * + * assert.notDeepEqual(obj1, obj4); + * // OK, obj1 and obj2 are not deeply equal + * ``` + * + * If the values are deeply equal, an `AssertionError` is thrown with + * a `message` property set equal to the value of the `message` parameter. + * If the `message` parameter is undefined, a default error message is assigned. + */ export function notDeepEqual(actual: any, expected: any, message ?: string): void; + +/** + * Tests strict equality as determined by the strict equality operator ( `===` ). + * + * ```js + * const assert = require('assert'); + * + * assert.strictEqual(1, 2); + * // AssertionError: 1 === 2 + * + * assert.strictEqual(1, 1); + * // OK + * + * assert.strictEqual(1, '1'); + * // AssertionError: 1 === '1' + * ``` + * + * If the values are not strictly equal, an `AssertionError` is thrown with + * a `message` property set equal to the value of the `message` parameter. + * If the `message` parameter is undefined, a default error message is assigned. + */ export function strictEqual(actual: any, expected: any, message ?: string): void; + +/** + * Tests strict inequality as determined by the strict not equal operator ( `!==` ). + * + * ```js + * const assert = require('assert'); + * + * assert.notStrictEqual(1, 2); + * // OK + * + * assert.notStrictEqual(1, 1); + * // AssertionError: 1 !== 1 + * + * assert.notStrictEqual(1, '1'); + * // OK + * ``` + * + * If the values are strictly equal, an `AssertionError` is thrown with a `message` property + * set equal to the value of the `message` parameter. If the `message` parameter is undefined, + * a default error message is assigned. + */ export function notStrictEqual(actual: any, expected: any, message ?: string): void; + +/** + * + */ export function throws(block: any, error ?: any, message ?: string): void; + +/** + * Asserts that the function `block` does not throw an error. See `assert.throws()` for more details. + * + * When `assert.doesNotThrow()` is called, it will immediately call the `block` function. + * + * If an error is thrown and it is the same type as that specified by the `error` parameter, + * then an `AssertionError` is thrown. If the error is of a different type, + * or if the `error` parameter is undefined, the error is propagated back to the caller. + * + * The following, for instance, will throw the TypeError because there is no matching error type in the assertion: + * ```js + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * SyntaxError + * ); + * ``` + * + * However, the following will result in an `AssertionError` with the message 'Got unwanted exception (TypeError)..': + * ```js + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * TypeError + * ); + * ``` + * + * If an `AssertionError` is thrown and a value is provided for the `message` parameter, + * the value of `message` will be appended to the `AssertionError` message: + * ```js + * assert.doesNotThrow( + * () => { + * throw new TypeError('Wrong value'); + * }, + * TypeError, + * 'Whoops' + * ); + * // Throws: AssertionError: Got unwanted exception (TypeError). Whoops + * ``` + */ export function doesNotThrow(block: any, error ?: any, message ?: string): void; + +/** + * Throws `value` if `value` is truthy. This is useful when testing the `error` argument in callbacks. + * ```js + * const assert = require('assert'); + * + * assert.ifError(0); + * // OK + * assert.ifError(1); + * // Throws 1 + * assert.ifError('error'); + * // Throws 'error' + * assert.ifError(new Error()); + * // Throws Error + * ``` + */ export function ifError(value: any): void; + export as namespace AssertPlus; From a5a69f514a2d1ff10f540bbb40288a3835518204 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 3 Jan 2017 15:53:49 -0800 Subject: [PATCH 072/181] Refactor rx (#13652) * Move rx.virtualtime to its own package * Update headers * Update module name * Move rx.time to its own package * Update header and module name * Move rx.testing to its own package * Update headers and module name * Move rx.joinpatterns to its own package * Update headers and module name * Move rx.expermental to its own package * Update headder and module name * Move rx.coincidence to its own package * Combine rx.coincidence-lite.d.ts and rx.coincidence.d.ts into one file * Update header and module name * Move rx.binding to its own package * combine rx.binding into index.d.ts * Update headers and module name * Move rx.backpressure to its own package * Fix headers and update module name * Move rx.aggregte to its own package * Fix headers and update module name * move rx.async to its own package * Fix headers and module name * move startAsync to rx-lite-async * Move fromCallback tests back to rx * Move rx-lite to its own package * Fix headers * Combine files * import new module * Fix file extension * Fix strict null checks * Move definitions back to rx * move rx-core to its own package * Update header and change module name * Fix lint errors * reference new rx-core * update index.d.ts * Point to new submodules * turn strictNull On * update tslint config * Update module name * Move Subject to core-binding * Make rx-lite-* libraries depend on rx-lite * Fix reference * Fix lint errors * Disable lint rules * Disable lint rules * Fix failing test * Fixed up indentation on 'rx-lite-async-tests.ts' * Fix formatting * Switch tabs to spaces --- rx-core-binding/index.d.ts | 100 +++ rx-core-binding/tsconfig.json | 19 + rx-core-binding/tslint.json | 8 + rx-core/index.d.ts | 75 ++ rx-core/tsconfig.json | 19 + rx-core/tslint.json | 9 + rx-dom/index.d.ts | 2 +- rx-dom/rx-dom-tests.ts | 4 +- rx-lite-aggregates/index.d.ts | 53 ++ rx-lite-aggregates/tsconfig.json | 19 + rx-lite-aggregates/tslint.json | 7 + rx-lite-async/index.d.ts | 49 ++ rx-lite-async/rx-lite-async-tests.ts | 27 + rx-lite-async/tsconfig.json | 20 + rx-lite-async/tslint.json | 6 + rx-lite-backpressure/index.d.ts | 52 ++ .../rx-lite-backpressure-tests.ts | 7 +- rx-lite-backpressure/tsconfig.json | 20 + rx-lite-backpressure/tslint.json | 6 + rx-lite-coincidence/index.d.ts | 58 ++ rx-lite-coincidence/tsconfig.json | 19 + rx-lite-coincidence/tslint.json | 7 + rx-lite-experimental/index.d.ts | 321 ++++++++ rx-lite-experimental/tsconfig.json | 19 + rx-lite-experimental/tslint.json | 7 + rx-lite-joinpatterns/index.d.ts | 60 ++ rx-lite-joinpatterns/tsconfig.json | 19 + rx-lite-joinpatterns/tslint.json | 8 + rx-lite-testing/index.d.ts | 61 ++ rx-lite-testing/tsconfig.json | 19 + rx-lite-testing/tslint.json | 6 + rx-lite-time/index.d.ts | 65 ++ rx-lite-time/tsconfig.json | 19 + rx-lite-time/tslint.json | 7 + rx-lite-virtualtime/index.d.ts | 41 + rx-lite-virtualtime/tsconfig.json | 19 + rx-lite-virtualtime/tslint.json | 8 + rx-lite/index.d.ts | 704 ++++++++++++++++++ rx-lite/rx-lite-tests.ts | 152 ++++ rx-lite/tsconfig.json | 20 + rx-lite/tslint.json | 11 + rx.wamp/rx.wamp-tests.ts | 2 +- rx/index.d.ts | 72 +- rx/rx-lite.d.ts | 627 ---------------- rx/rx-tests.ts | 90 --- rx/rx.aggregates.d.ts | 53 -- rx/rx.all.d.ts | 19 - rx/rx.async-lite.d.ts | 73 -- rx/rx.async-tests.ts | 82 -- rx/rx.async.d.ts | 43 -- rx/rx.backpressure-lite.d.ts | 46 -- rx/rx.backpressure.d.ts | 11 - rx/rx.binding-lite.d.ts | 71 -- rx/rx.binding.d.ts | 11 - rx/rx.coincidence-lite.d.ts | 32 - rx/rx.coincidence.d.ts | 36 - rx/rx.experimental.d.ts | 321 -------- rx/rx.joinpatterns.d.ts | 60 -- rx/rx.lite.d.ts | 15 - rx/rx.testing.d.ts | 64 -- rx/rx.time-lite.d.ts | 45 -- rx/rx.time.d.ts | 66 -- rx/rx.virtualtime.d.ts | 41 - rx/tsconfig.json | 25 +- rx/tslint.json | 7 - 65 files changed, 2161 insertions(+), 1903 deletions(-) create mode 100644 rx-core-binding/index.d.ts create mode 100644 rx-core-binding/tsconfig.json create mode 100644 rx-core-binding/tslint.json create mode 100644 rx-core/index.d.ts create mode 100644 rx-core/tsconfig.json create mode 100644 rx-core/tslint.json create mode 100644 rx-lite-aggregates/index.d.ts create mode 100644 rx-lite-aggregates/tsconfig.json create mode 100644 rx-lite-aggregates/tslint.json create mode 100644 rx-lite-async/index.d.ts create mode 100644 rx-lite-async/rx-lite-async-tests.ts create mode 100644 rx-lite-async/tsconfig.json create mode 100644 rx-lite-async/tslint.json create mode 100644 rx-lite-backpressure/index.d.ts rename rx/rx.backpressure-tests.ts => rx-lite-backpressure/rx-lite-backpressure-tests.ts (71%) create mode 100644 rx-lite-backpressure/tsconfig.json create mode 100644 rx-lite-backpressure/tslint.json create mode 100644 rx-lite-coincidence/index.d.ts create mode 100644 rx-lite-coincidence/tsconfig.json create mode 100644 rx-lite-coincidence/tslint.json create mode 100644 rx-lite-experimental/index.d.ts create mode 100644 rx-lite-experimental/tsconfig.json create mode 100644 rx-lite-experimental/tslint.json create mode 100644 rx-lite-joinpatterns/index.d.ts create mode 100644 rx-lite-joinpatterns/tsconfig.json create mode 100644 rx-lite-joinpatterns/tslint.json create mode 100644 rx-lite-testing/index.d.ts create mode 100644 rx-lite-testing/tsconfig.json create mode 100644 rx-lite-testing/tslint.json create mode 100644 rx-lite-time/index.d.ts create mode 100644 rx-lite-time/tsconfig.json create mode 100644 rx-lite-time/tslint.json create mode 100644 rx-lite-virtualtime/index.d.ts create mode 100644 rx-lite-virtualtime/tsconfig.json create mode 100644 rx-lite-virtualtime/tslint.json create mode 100644 rx-lite/index.d.ts create mode 100644 rx-lite/rx-lite-tests.ts create mode 100644 rx-lite/tsconfig.json create mode 100644 rx-lite/tslint.json delete mode 100644 rx/rx-lite.d.ts delete mode 100644 rx/rx-tests.ts delete mode 100644 rx/rx.aggregates.d.ts delete mode 100644 rx/rx.all.d.ts delete mode 100644 rx/rx.async-lite.d.ts delete mode 100644 rx/rx.async-tests.ts delete mode 100644 rx/rx.async.d.ts delete mode 100644 rx/rx.backpressure-lite.d.ts delete mode 100644 rx/rx.backpressure.d.ts delete mode 100644 rx/rx.binding-lite.d.ts delete mode 100644 rx/rx.binding.d.ts delete mode 100644 rx/rx.coincidence-lite.d.ts delete mode 100644 rx/rx.coincidence.d.ts delete mode 100644 rx/rx.experimental.d.ts delete mode 100644 rx/rx.joinpatterns.d.ts delete mode 100644 rx/rx.lite.d.ts delete mode 100644 rx/rx.testing.d.ts delete mode 100644 rx/rx.time-lite.d.ts delete mode 100644 rx/rx.time.d.ts delete mode 100644 rx/rx.virtualtime.d.ts diff --git a/rx-core-binding/index.d.ts b/rx-core-binding/index.d.ts new file mode 100644 index 0000000000..cf283070e9 --- /dev/null +++ b/rx-core-binding/index.d.ts @@ -0,0 +1,100 @@ +// Type definitions for rx-core-binding 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Carl de Billy , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + interface ISubject extends Observable, Observer, IDisposable { + hasObservers(): boolean; + } + + export interface Subject extends ISubject { + } + + interface SubjectStatic { + new (): Subject; + create(observer?: Observer, observable?: Observable): ISubject; + } + + export var Subject: SubjectStatic; + + export interface AsyncSubject extends Subject { + } + + interface AsyncSubjectStatic { + new (): AsyncSubject; + } + + export var AsyncSubject: AsyncSubjectStatic; + + export interface BehaviorSubject extends Subject { + getValue(): T; + } + + interface BehaviorSubjectStatic { + new (initialValue: T): BehaviorSubject; + } + + export var BehaviorSubject: BehaviorSubjectStatic; + + export interface ReplaySubject extends Subject { + } + + interface ReplaySubjectStatic { + new (bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject; + } + + export var ReplaySubject: ReplaySubjectStatic; + + interface ConnectableObservable extends Observable { + connect(): IDisposable; + refCount(): Observable; + } + + interface ConnectableObservableStatic { + new (): ConnectableObservable; + } + + export var ConnectableObservable: ConnectableObservableStatic; + + export interface Observable { + multicast(subject: Observable): ConnectableObservable; + multicast(subjectSelector: () => ISubject, selector: (source: ConnectableObservable) => Observable): Observable; + publish(): ConnectableObservable; + publish(selector: (source: ConnectableObservable) => Observable): Observable; + /** + * Returns an observable sequence that shares a single subscription to the underlying sequence. + * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + * + * @example + * var res = source.share(); + * + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + share(): Observable; + publishLast(): ConnectableObservable; + publishLast(selector: (source: ConnectableObservable) => Observable): Observable; + publishValue(initialValue: T): ConnectableObservable; + publishValue(selector: (source: ConnectableObservable) => Observable, initialValue: T): Observable; + /** + * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue. + * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + * + * @example + * var res = source.shareValue(42); + * + * @param initialValue Initial value received by observers upon subscription. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + shareValue(initialValue: T): Observable; + replay(selector?: boolean, bufferSize?: number, window?: number, scheduler?: IScheduler): ConnectableObservable; // hack to catch first omitted parameter + replay(selector: (source: ConnectableObservable) => Observable, bufferSize?: number, window?: number, scheduler?: IScheduler): Observable; + shareReplay(bufferSize?: number, window?: number, scheduler?: IScheduler): Observable; + } +} + +declare module "rx-core-binding" { + export = Rx; +} diff --git a/rx-core-binding/tsconfig.json b/rx-core-binding/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-core-binding/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-core-binding/tslint.json b/rx-core-binding/tslint.json new file mode 100644 index 0000000000..c169b612d0 --- /dev/null +++ b/rx-core-binding/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "../tslint.json", + "rules": { + "no-empty-interface": false, + "interface-name": false, + "no-single-declare-module": false + } +} diff --git a/rx-core/index.d.ts b/rx-core/index.d.ts new file mode 100644 index 0000000000..62ef95ff80 --- /dev/null +++ b/rx-core/index.d.ts @@ -0,0 +1,75 @@ +// Type definitions for rx-core 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: gsino , Igor Oleinikov , Mizunashi Mana +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace Rx { + /** + * Promise A+ + */ + export interface IPromise { + then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise; + then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; + then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise; + then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise; + } + + export interface IDisposable { + dispose(): void; + } + + export interface IScheduler { + catch(handler: (exception: any) => boolean): IScheduler; + catchException(handler: (exception: any) => boolean): IScheduler; + } + + // Observer + export interface Observer { + checked(): Observer; + } + + interface ObserverStatic { + /** + * Schedules the invocation of observer methods on the given scheduler. + * @param scheduler Scheduler to schedule observer messages on. + * @returns Observer whose messages are scheduled on the given scheduler. + */ + notifyOn(scheduler: IScheduler): Observer; + } + + export interface Observable { + observeOn(scheduler: IScheduler): Observable; + subscribeOn(scheduler: IScheduler): Observable; + + amb(rightSource: IPromise | Observable): Observable; + onErrorResumeNext(second: IPromise | Observable): Observable; + bufferWithCount(count: number, skip?: number): Observable; + windowWithCount(count: number, skip?: number): Observable>; + defaultIfEmpty(defaultValue?: T): Observable; + distinct(skipParameter: boolean, valueSerializer: (value: T) => string): Observable; + distinct(keySelector?: (value: T) => TKey, keySerializer?: (key: TKey) => string): Observable; + groupBy(keySelector: (value: T) => TKey, skipElementSelector?: boolean, keySerializer?: (key: TKey) => string): Observable>; + groupBy(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, keySerializer?: (key: TKey) => string): Observable>; + groupByUntil(keySelector: (value: T) => TKey, skipElementSelector: boolean, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; + groupByUntil(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; + } + + interface ObservableStatic { + using(resourceFactory: () => TResource, observableFactory: (resource: TResource) => Observable): Observable; + amb(...sources: Array>): Observable; + amb(...sources: Array>): Observable; + amb(sources: Array> | Array>): Observable; + onErrorResumeNext(...sources: Array>): Observable; + onErrorResumeNext(...sources: Array>): Observable; + onErrorResumeNext(sources: Array> | Array>): Observable; + } + + interface GroupedObservable extends Observable { + key: TKey; + underlyingObservable: Observable; + } +} + +declare module "rx-core" { + export = Rx; +} diff --git a/rx-core/tsconfig.json b/rx-core/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-core/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-core/tslint.json b/rx-core/tslint.json new file mode 100644 index 0000000000..e601518a4d --- /dev/null +++ b/rx-core/tslint.json @@ -0,0 +1,9 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false, + "no-empty-interface": false, + "interface-name": false, + "no-single-declare-module": false + } +} diff --git a/rx-dom/index.d.ts b/rx-dom/index.d.ts index d3897a2c47..00fca183d9 100644 --- a/rx-dom/index.d.ts +++ b/rx-dom/index.d.ts @@ -137,6 +137,6 @@ declare module Rx.DOM { } } -declare module "rx.DOM" { +declare module "rx-dom" { export default Rx.DOM; } \ No newline at end of file diff --git a/rx-dom/rx-dom-tests.ts b/rx-dom/rx-dom-tests.ts index fb834ee9c6..4a97a9d0d4 100644 --- a/rx-dom/rx-dom-tests.ts +++ b/rx-dom/rx-dom-tests.ts @@ -1,4 +1,2 @@ -/// - import * as Rx from 'rx'; -import * as DOM from 'rx.DOM'; \ No newline at end of file +import * as DOM from 'rx-dom'; \ No newline at end of file diff --git a/rx-lite-aggregates/index.d.ts b/rx-lite-aggregates/index.d.ts new file mode 100644 index 0000000000..d09a4868f2 --- /dev/null +++ b/rx-lite-aggregates/index.d.ts @@ -0,0 +1,53 @@ +// Type definitions for rx-lite-aggregates 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Carl de Billy , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + export interface Observable { + finalValue(): Observable; + aggregate(accumulator: (acc: T, value: T) => T): Observable; + aggregate(seed: TAcc, accumulator: (acc: TAcc, value: T) => TAcc): Observable; + + reduce(accumulator: (acc: T, value: T) => T): Observable; + reduce(accumulator: (acc: TAcc, value: T) => TAcc, seed: TAcc): Observable; // TS0.9.5: won't work https://typescript.codeplex.com/discussions/471751 + + any(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + some(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for any + + isEmpty(): Observable; + all(predicate?: (value: T) => boolean, thisArg?: any): Observable; + every(predicate?: (value: T) => boolean, thisArg?: any): Observable; // alias for all + contains(value: T): Observable; + contains(value: TOther, comparer: (value1: T, value2: TOther) => boolean): Observable; + count(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + sum(keySelector?: (value: T, index: number, source: Observable) => number, thisArg?: any): Observable; + minBy(keySelector: (item: T) => TKey, comparer: (value1: TKey, value2: TKey) => number): Observable; + minBy(keySelector: (item: T) => number): Observable; + min(comparer?: (value1: T, value2: T) => number): Observable; + maxBy(keySelector: (item: T) => TKey, comparer: (value1: TKey, value2: TKey) => number): Observable; + maxBy(keySelector: (item: T) => number): Observable; + max(comparer?: (value1: T, value2: T) => number): Observable; + average(keySelector?: (value: T, index: number, source: Observable) => number, thisArg?: any): Observable; + + sequenceEqual(second: Observable, comparer: (value1: T, value2: TOther) => number): Observable; + sequenceEqual(second: IPromise, comparer: (value1: T, value2: TOther) => number): Observable; + sequenceEqual(second: Observable): Observable; + sequenceEqual(second: IPromise): Observable; + sequenceEqual(second: TOther[], comparer: (value1: T, value2: TOther) => number): Observable; + sequenceEqual(second: T[]): Observable; + + elementAt(index: number): Observable; + single(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + first(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + last(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + find(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + findIndex(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + } +} + +declare module "rx-lite-aggregates" { + export = Rx; +} diff --git a/rx-lite-aggregates/tsconfig.json b/rx-lite-aggregates/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-aggregates/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-aggregates/tslint.json b/rx-lite-aggregates/tslint.json new file mode 100644 index 0000000000..bd7d2217e3 --- /dev/null +++ b/rx-lite-aggregates/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false, + "no-single-declare-module": false + } +} diff --git a/rx-lite-async/index.d.ts b/rx-lite-async/index.d.ts new file mode 100644 index 0000000000..d912f56d39 --- /dev/null +++ b/rx-lite-async/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for rx-lite-async 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: zoetrope , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + interface ObservableStatic { + /** + * Invokes the asynchronous function, surfacing the result through an observable sequence. + * @param functionAsync Asynchronous function which returns a Promise to run. + * @returns An observable sequence exposing the function's result value, or an exception. + */ + startAsync(functionAsync: () => IPromise): Observable; + + start(func: () => T, context?: any, scheduler?: IScheduler): Observable; + + toAsync(func: () => TResult, context?: any, scheduler?: IScheduler): () => Observable; + toAsync(func: (arg1: T1) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1) => Observable; + toAsync(func: (arg1?: T1) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1) => Observable; + toAsync(func: (...args: T1[]) => TResult, context?: any, scheduler?: IScheduler): (...args: T1[]) => Observable; + toAsync(func: (arg1: T1, arg2: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2) => Observable; + toAsync(func: (arg1: T1, arg2?: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2) => Observable; + toAsync(func: (arg1?: T1, arg2?: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2) => Observable; + toAsync(func: (arg1: T1, ...args: T2[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, ...args: T2[]) => Observable; + toAsync(func: (arg1?: T1, ...args: T2[]) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, ...args: T2[]) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3?: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3?: T3) => Observable; + toAsync(func: (arg1: T1, arg2?: T2, arg3?: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, arg3?: T3) => Observable; + toAsync(func: (arg1?: T1, arg2?: T2, arg3?: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, arg3?: T3) => Observable; + toAsync(func: (arg1: T1, arg2: T2, ...args: T3[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, ...args: T3[]) => Observable; + toAsync(func: (arg1: T1, arg2?: T2, ...args: T3[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, ...args: T3[]) => Observable; + toAsync(func: (arg1?: T1, arg2?: T2, ...args: T3[]) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, ...args: T3[]) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, arg4?: T4) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3?: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3?: T3, arg4?: T4) => Observable; + toAsync(func: (arg1: T1, arg2?: T2, arg3?: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, arg3?: T3, arg4?: T4) => Observable; + toAsync(func: (arg1?: T1, arg2?: T2, arg3?: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, arg3?: T3, arg4?: T4) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, ...args: T4[]) => Observable; + toAsync(func: (arg1: T1, arg2: T2, arg3?: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3?: T3, ...args: T4[]) => Observable; + toAsync(func: (arg1: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => Observable; + toAsync(func: (arg1?: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => Observable; + } +} + +declare module "rx-lite-async" { + export = Rx; +} diff --git a/rx-lite-async/rx-lite-async-tests.ts b/rx-lite-async/rx-lite-async-tests.ts new file mode 100644 index 0000000000..a8119fbb82 --- /dev/null +++ b/rx-lite-async/rx-lite-async-tests.ts @@ -0,0 +1,27 @@ +// Tests for RxJS-Async TypeScript definitions +// Tests by Igor Oleinikov + +namespace Rx.Tests.Async { + + var obsNum: Rx.Observable; + var obsStr: Rx.Observable; + var sch: Rx.IScheduler; + + function start() { + obsNum = Rx.Observable.start(()=> 10, obsStr, sch); + obsNum = Rx.Observable.start(() => 10, obsStr); + obsNum = Rx.Observable.start(()=> 10); + } + + function toAsync() { + obsNum = Rx.Observable.toAsync(()=> 1, sch)(); + obsNum = Rx.Observable.toAsync((a1: number)=> a1)(1); + obsStr = Rx.Observable.toAsync((a1: string, a2: number)=> a1 + a2.toFixed(0))("", 1); + obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date)=> a1 + a2.toFixed(0) + a3.toDateString())("", 1, new Date()); + obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date, a4: boolean)=> a1 + a2.toFixed(0) + a3.toDateString() + (a4 ? 1 : 0))("", 1, new Date(), false); + } + + function startAsync() { + var o: Rx.Observable = Rx.Observable.startAsync(() => >{}); + } +} diff --git a/rx-lite-async/tsconfig.json b/rx-lite-async/tsconfig.json new file mode 100644 index 0000000000..24c1c4d4c3 --- /dev/null +++ b/rx-lite-async/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rx-lite-async-tests.ts" + ] +} diff --git a/rx-lite-async/tslint.json b/rx-lite-async/tslint.json new file mode 100644 index 0000000000..cfdf2986e5 --- /dev/null +++ b/rx-lite-async/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/rx-lite-backpressure/index.d.ts b/rx-lite-backpressure/index.d.ts new file mode 100644 index 0000000000..2584cb8a36 --- /dev/null +++ b/rx-lite-backpressure/index.d.ts @@ -0,0 +1,52 @@ +// Type definitions for rx-lite-backpressure 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + export interface Observable { + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausable(pauser); + * @param pauser The observable sequence used to pause the underlying sequence. + * @returns The observable sequence which is paused based upon the pauser. + */ + pausable(pauser?: Observable): PausableObservable; + + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, + * and yields the values that were buffered while paused. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausableBuffered(pauser); + * @param pauser The observable sequence used to pause the underlying sequence. + * @returns The observable sequence which is paused based upon the pauser. + */ + pausableBuffered(pauser?: Observable): PausableObservable; + + /** + * Attaches a controller to the observable sequence with the ability to queue. + * @example + * var source = Rx.Observable.interval(100).controlled(); + * source.request(3); // Reads 3 values + */ + controlled(enableQueue?: boolean): ControlledObservable; + } + + export interface ControlledObservable extends Observable { + request(numberOfItems?: number): IDisposable; + } + + export interface PausableObservable extends Observable { + pause(): void; + resume(): void; + } +} + +declare module "rx-lite-backpressure" { + export = Rx; +} diff --git a/rx/rx.backpressure-tests.ts b/rx-lite-backpressure/rx-lite-backpressure-tests.ts similarity index 71% rename from rx/rx.backpressure-tests.ts rename to rx-lite-backpressure/rx-lite-backpressure-tests.ts index 7db4aed25f..6c312691f7 100644 --- a/rx/rx.backpressure-tests.ts +++ b/rx-lite-backpressure/rx-lite-backpressure-tests.ts @@ -1,11 +1,8 @@ // Tests for RxJS-BackPressure TypeScript definitions // Tests by Igor Oleinikov -/// -/// - function testPausable() { - var o: Rx.Observable; + var o: Rx.Observable = {} as any; var pauser = new Rx.Subject(); @@ -14,7 +11,7 @@ function testPausable() { } function testControlled() { - var o: Rx.Observable; + var o: Rx.Observable = {} as any; var c = o.controlled(); var d: Rx.IDisposable = c.request(); diff --git a/rx-lite-backpressure/tsconfig.json b/rx-lite-backpressure/tsconfig.json new file mode 100644 index 0000000000..312408129e --- /dev/null +++ b/rx-lite-backpressure/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rx-lite-backpressure-tests.ts" + ] +} diff --git a/rx-lite-backpressure/tslint.json b/rx-lite-backpressure/tslint.json new file mode 100644 index 0000000000..cfdf2986e5 --- /dev/null +++ b/rx-lite-backpressure/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/rx-lite-coincidence/index.d.ts b/rx-lite-coincidence/index.d.ts new file mode 100644 index 0000000000..0361d025c2 --- /dev/null +++ b/rx-lite-coincidence/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for rx-lite-coincidence 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Carl de Billy , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + + interface Observable { + join( + right: Observable, + leftDurationSelector: (leftItem: T) => Observable, + rightDurationSelector: (rightItem: TRight) => Observable, + resultSelector: (leftItem: T, rightItem: TRight) => TResult): Observable; + + groupJoin( + right: Observable, + leftDurationSelector: (leftItem: T) => Observable, + rightDurationSelector: (rightItem: TRight) => Observable, + resultSelector: (leftItem: T, rightItem: Observable) => TResult): Observable; + + window(windowOpenings: Observable): Observable>; + window(windowClosingSelector: () => Observable): Observable>; + window(windowOpenings: Observable, windowClosingSelector: () => Observable): Observable>; + + buffer(bufferOpenings: Observable): Observable; + buffer(bufferClosingSelector: () => Observable): Observable; + buffer(bufferOpenings: Observable, bufferClosingSelector: () => Observable): Observable; + + /** + * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. + * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. + * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. + * @returns An observable that triggers on successive pairs of observations from the input observable as an array. + */ + pairwise(): Observable; + + /** + * Returns two observables which partition the observations of the source by the given function. + * The first will trigger observations for those values for which the predicate returns true. + * The second will trigger observations for those values where the predicate returns false. + * The predicate is executed once for each subscribed observer. + * Both also propagate all error observations arising from the source and each completes + * when the source completes. + * @param predicate + * The function to determine which output Observable will trigger a particular observation. + * @returns + * An array of observables. The first triggers when the predicate returns true, + * and the second triggers when the predicate returns false. + */ + partition(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Array>; + } +} + +declare module "rx-lite-coincidence" { + export = Rx; +} diff --git a/rx-lite-coincidence/tsconfig.json b/rx-lite-coincidence/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-coincidence/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-coincidence/tslint.json b/rx-lite-coincidence/tslint.json new file mode 100644 index 0000000000..bd7d2217e3 --- /dev/null +++ b/rx-lite-coincidence/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false, + "no-single-declare-module": false + } +} diff --git a/rx-lite-experimental/index.d.ts b/rx-lite-experimental/index.d.ts new file mode 100644 index 0000000000..9659d9fec6 --- /dev/null +++ b/rx-lite-experimental/index.d.ts @@ -0,0 +1,321 @@ +// Type definitions for rx-lite-experimental 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + + interface Observable { + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + let(selector: (source: Observable) => Observable): Observable; + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + letBind(selector: (source: Observable) => Observable): Observable; + + /** + * Repeats source as long as condition holds emulating a do while loop. + * @param condition The condition which determines if the source will be repeated. + * @returns An observable sequence which is repeated as long as the condition holds. + */ + doWhile(condition: () => boolean): Observable; + + /** + * Expands an observable sequence by recursively invoking selector. + * + * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. + * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. + * @returns An observable sequence containing all the elements produced by the recursive expansion. + */ + expand(selector: (item: T) => Observable, scheduler?: IScheduler): Observable; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * + * @param second Second observable sequence or promise. + * @param resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + forkJoin(second: Observable, resultSelector: (left: T, right: TSecond) => TResult): Observable; + forkJoin(second: IPromise, resultSelector: (left: T, right: TSecond) => TResult): Observable; + + /** + * Comonadic bind operator. + * @param selector A transform function to apply to each element. + * @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns An observable sequence which results from the comonadic bind operation. + */ + manySelect(selector: (item: Observable, index: number, source: Observable) => TResult, scheduler?: IScheduler): Observable; + } + + interface ObservableStatic { + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, elseSource: Observable): Observable; + if(condition: () => boolean, thenSource: Observable, elseSource: IPromise): Observable; + if(condition: () => boolean, thenSource: IPromise, elseSource: Observable): Observable; + if(condition: () => boolean, thenSource: IPromise, elseSource: IPromise): Observable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, scheduler?: IScheduler): Observable; + if(condition: () => boolean, thenSource: IPromise, scheduler?: IScheduler): Observable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, elseSource: Observable): Observable; + ifThen(condition: () => boolean, thenSource: Observable, elseSource: IPromise): Observable; + ifThen(condition: () => boolean, thenSource: IPromise, elseSource: Observable): Observable; + ifThen(condition: () => boolean, thenSource: IPromise, elseSource: IPromise): Observable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, scheduler?: IScheduler): Observable; + ifThen(condition: () => boolean, thenSource: IPromise, scheduler?: IScheduler): Observable; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => Observable): Observable; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => Observable): Observable; + + /** + * Repeats source as long as condition holds emulating a while loop. + * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; + while(condition: () => boolean, source: IPromise): Observable; + + /** + * Repeats source as long as condition holds emulating a while loop. + * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; + whileDo(condition: () => boolean, source: IPromise): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; + case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; + case(selector: () => string, sources: { [key: string]: Observable; }, elseSource: IPromise): Observable; + case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: IPromise): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; + case(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; + case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; + case(selector: () => number, sources: { [key: number]: Observable; }, elseSource: IPromise): Observable; + case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: IPromise): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; + case(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; + switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; + switchCase(selector: () => string, sources: { [key: string]: Observable; }, elseSource: IPromise): Observable; + switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: IPromise): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; + switchCase(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; + switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; + switchCase(selector: () => number, sources: { [key: number]: Observable; }, elseSource: IPromise): Observable; + switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: IPromise): Observable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; + switchCase(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * res = Rx.Observable.forkJoin([obs1, obs2]); + * @param sources Array of source sequences or promises. + * @returns An observable sequence with an array collecting the last elements of all the input sequences. + */ + forkJoin(sources: Array>): Observable; + forkJoin(sources: Array>): Observable; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @param args Source sequences or promises. + * @returns An observable sequence with an array collecting the last elements of all the input sequences. + */ + forkJoin(...args: Array>): Observable; + forkJoin(...args: Array>): Observable; + } +} + +declare module "rx-lite-experimental" { + export = Rx; +} diff --git a/rx-lite-experimental/tsconfig.json b/rx-lite-experimental/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-experimental/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-experimental/tslint.json b/rx-lite-experimental/tslint.json new file mode 100644 index 0000000000..bd7d2217e3 --- /dev/null +++ b/rx-lite-experimental/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false, + "no-single-declare-module": false + } +} diff --git a/rx-lite-joinpatterns/index.d.ts b/rx-lite-joinpatterns/index.d.ts new file mode 100644 index 0000000000..658c93d1a4 --- /dev/null +++ b/rx-lite-joinpatterns/index.d.ts @@ -0,0 +1,60 @@ +// Type definitions for rx-lite-joinpatterns 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + + interface Pattern1 { + and(other: Observable): Pattern2; + thenDo(selector: (item1: T1) => TR): Plan; + } + interface Pattern2 { + and(other: Observable): Pattern3; + thenDo(selector: (item1: T1, item2: T2) => TR): Plan; + } + interface Pattern3 { + and(other: Observable): Pattern4; + thenDo(selector: (item1: T1, item2: T2, item3: T3) => TR): Plan; + } + interface Pattern4 { + and(other: Observable): Pattern5; + thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4) => TR): Plan; + } + interface Pattern5 { + and(other: Observable): Pattern6; + thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TR): Plan; + } + interface Pattern6 { + and(other: Observable): Pattern7; + thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6) => TR): Plan; + } + interface Pattern7 { + and(other: Observable): Pattern8; + thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7) => TR): Plan; + } + interface Pattern8 { + and(other: Observable): Pattern9; + thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8) => TR): Plan; + } + interface Pattern9 { + thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8, item9: T9) => TR): Plan; + } + + interface Plan { } + + interface Observable { + and(other: Observable): Pattern2; + thenDo(selector: (item1: T) => TR): Plan; + } + + interface ObservableStatic { + when(plan: Plan): Observable; + } +} + +declare module "rx-lite-joinpatterns" { + export = Rx; +} diff --git a/rx-lite-joinpatterns/tsconfig.json b/rx-lite-joinpatterns/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-joinpatterns/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-joinpatterns/tslint.json b/rx-lite-joinpatterns/tslint.json new file mode 100644 index 0000000000..587e1d39df --- /dev/null +++ b/rx-lite-joinpatterns/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "../tslint.json", + "rules": { + "interface-name": false, + "no-empty-interface": false, + "no-single-declare-module": false + } +} diff --git a/rx-lite-testing/index.d.ts b/rx-lite-testing/index.d.ts new file mode 100644 index 0000000000..2fda5bfbb1 --- /dev/null +++ b/rx-lite-testing/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for rx-lite-testing 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + export interface TestScheduler extends VirtualTimeScheduler { + createColdObservable(...records: Recorded[]): Observable; + createHotObservable(...records: Recorded[]): Observable; + createObserver(): MockObserver; + + startWithTiming(create: () => Observable, createdAt: number, subscribedAt: number, disposedAt: number): MockObserver; + startWithDispose(create: () => Observable, disposedAt: number): MockObserver; + startWithCreate(create: () => Observable): MockObserver; + } + + export var TestScheduler: { + new (): TestScheduler; + }; + + export class Recorded { + constructor(time: number, value: any, equalityComparer?: (x: any, y: any) => boolean); + equals(other: Recorded): boolean; + toString(): string; + time: number; + value: any; + } + + export var ReactiveTest: { + created: number; + subscribed: number; + disposed: number; + + onNext(ticks: number, value: any): Recorded; + onError(ticks: number, exception: any): Recorded; + onCompleted(ticks: number): Recorded; + + subscribe(subscribeAt: number, unsubscribeAt?: number): Subscription; + }; + + export class Subscription { + constructor(subscribeAt: number, unsubscribeAt?: number); + equals(other: Subscription): boolean; + } + + export interface MockObserver extends Observer { + messages: Recorded[]; + } + + interface MockObserverStatic extends ObserverStatic { + new (scheduler: IScheduler): MockObserver; + } + + export var MockObserver: MockObserverStatic; +} + +declare module "rx-lite-testing" { + export = Rx; +} diff --git a/rx-lite-testing/tsconfig.json b/rx-lite-testing/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-testing/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-testing/tslint.json b/rx-lite-testing/tslint.json new file mode 100644 index 0000000000..cfdf2986e5 --- /dev/null +++ b/rx-lite-testing/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/rx-lite-time/index.d.ts b/rx-lite-time/index.d.ts new file mode 100644 index 0000000000..38c553dbf1 --- /dev/null +++ b/rx-lite-time/index.d.ts @@ -0,0 +1,65 @@ +// Type definitions for rx-lite-time 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Carl de Billy , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + export interface Observable { + delaySubscription(dueTime: number, scheduler?: IScheduler): Observable; + delayWithSelector(delayDurationSelector: (item: T) => number): Observable; + delayWithSelector(subscriptionDelay: number, delayDurationSelector: (item: T) => number): Observable; + + timeoutWithSelector(firstTimeout: Observable, timeoutdurationSelector?: (item: T) => Observable, other?: Observable): Observable; + + debounceWithSelector(debounceDurationSelector: (item: T) => Observable): Observable; + /** + * @deprecated use #debounceWithSelector instead. + */ + throttleWithSelector(debounceDurationSelector: (item: T) => Observable): Observable; + + skipLastWithTime(duration: number, scheduler?: IScheduler): Observable; + takeLastWithTime(duration: number, timerScheduler?: IScheduler, loopScheduler?: IScheduler): Observable; + + takeLastBufferWithTime(duration: number, scheduler?: IScheduler): Observable; + takeWithTime(duration: number, scheduler?: IScheduler): Observable; + skipWithTime(duration: number, scheduler?: IScheduler): Observable; + + skipUntilWithTime(startTime: Date, scheduler?: IScheduler): Observable; + skipUntilWithTime(duration: number, scheduler?: IScheduler): Observable; + takeUntilWithTime(endTime: Date, scheduler?: IScheduler): Observable; + takeUntilWithTime(duration: number, scheduler?: IScheduler): Observable; + + windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable>; + windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable>; + windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable>; + bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; + bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable; + bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; + } + + interface ObservableStatic { + timer(dueTime: Date, period: number, scheduler?: IScheduler): Observable; + timer(dueTime: Date, scheduler?: IScheduler): Observable; + + generateWithRelativeTime( + initialState: TState, + condition: (state: TState) => boolean, + iterate: (state: TState) => TState, + resultSelector: (state: TState) => TResult, + timeSelector: (state: TState) => number, + scheduler?: IScheduler): Observable; + generateWithAbsoluteTime( + initialState: TState, + condition: (state: TState) => boolean, + iterate: (state: TState) => TState, + resultSelector: (state: TState) => TResult, + timeSelector: (state: TState) => Date, + scheduler?: IScheduler): Observable; + } +} + +declare module "rx-lite-time" { + export = Rx; +} diff --git a/rx-lite-time/tsconfig.json b/rx-lite-time/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-time/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-time/tslint.json b/rx-lite-time/tslint.json new file mode 100644 index 0000000000..bd7d2217e3 --- /dev/null +++ b/rx-lite-time/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false, + "no-single-declare-module": false + } +} diff --git a/rx-lite-virtualtime/index.d.ts b/rx-lite-virtualtime/index.d.ts new file mode 100644 index 0000000000..617282ccc6 --- /dev/null +++ b/rx-lite-virtualtime/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for rx-lite-virtualtime 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: gsino , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Rx { + export interface VirtualTimeScheduler extends Scheduler { + //protected constructor(initialClock: TAbsolute, comparer: (first: TAbsolute, second: TAbsolute) => number); + + advanceBy(time: TRelative): void; + advanceTo(time: TAbsolute): void; + scheduleAbsolute(dueTime: TAbsolute, action: () => void): IDisposable; + scheduleAbsoluteWithState(state: TState, dueTime: TAbsolute, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; + scheduleRelative(dueTime: TRelative, action: () => void): IDisposable; + scheduleRelativeWithState(state: TState, dueTime: TRelative, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; + sleep(time: TRelative): void; + start(): IDisposable; + stop(): void; + + isEnabled: boolean; + + /* protected abstract */ add(from: TAbsolute, by: TRelative): TAbsolute; + /* protected abstract */ toDateTimeOffset(duetime: TAbsolute): number; + /* protected abstract */ toRelative(duetime: number): TRelative; + + /* protected */ getNext(): internals.ScheduledItem; + } + + export interface HistoricalScheduler extends VirtualTimeScheduler { + } + + export var HistoricalScheduler: { + new (initialClock: number, comparer: (first: number, second: number) => number): HistoricalScheduler; + }; +} + +declare module "rx-lite-virtualtime" { + export = Rx; +} diff --git a/rx-lite-virtualtime/tsconfig.json b/rx-lite-virtualtime/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/rx-lite-virtualtime/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/rx-lite-virtualtime/tslint.json b/rx-lite-virtualtime/tslint.json new file mode 100644 index 0000000000..587e1d39df --- /dev/null +++ b/rx-lite-virtualtime/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "../tslint.json", + "rules": { + "interface-name": false, + "no-empty-interface": false, + "no-single-declare-module": false + } +} diff --git a/rx-lite/index.d.ts b/rx-lite/index.d.ts new file mode 100644 index 0000000000..eea7a2bfad --- /dev/null +++ b/rx-lite/index.d.ts @@ -0,0 +1,704 @@ +// Type definitions for rx-lite 4.0 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: gsino , Igor Oleinikov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare namespace Rx { + export namespace internals { + function isEqual(left: any, right: any): boolean; + function addRef(xs: Observable, r: { getDisposable(): IDisposable; }): Observable; + + // Priority Queue for Scheduling + export class PriorityQueue { + constructor(capacity: number); + + length: number; + + isHigherPriority(left: number, right: number): boolean; + percolate(index: number): void; + heapify(index: number): void; + peek(): ScheduledItem; + removeAt(index: number): void; + dequeue(): ScheduledItem; + enqueue(item: ScheduledItem): void; + remove(item: ScheduledItem): boolean; + + static count: number; + } + + export class ScheduledItem { + constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number); + + scheduler: IScheduler; + state: TTime; + action: (scheduler: IScheduler, state: any) => IDisposable; + dueTime: TTime; + comparer: (x: TTime, y: TTime) => number; + disposable: SingleAssignmentDisposable; + + invoke(): void; + compareTo(other: ScheduledItem): number; + isCancelled(): boolean; + invokeCore(): IDisposable; + } + } + + export namespace config { + export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }; + } + + export namespace helpers { + function noop(): void; + function notDefined(value: any): boolean; + function identity(value: T): T; + function defaultNow(): number; + function defaultComparer(left: any, right: any): boolean; + function defaultSubComparer(left: any, right: any): number; + function defaultKeySerializer(key: any): string; + function defaultError(err: any): void; + function isPromise(p: any): boolean; + function asArray(...args: T[]): T[]; + function not(value: any): boolean; + function isFunction(value: any): boolean; + } + + export class CompositeDisposable implements IDisposable { + constructor(...disposables: IDisposable[]); + constructor(disposables: IDisposable[]); + + isDisposed: boolean; + length: number; + + dispose(): void; + add(item: IDisposable): void; + remove(item: IDisposable): boolean; + toArray(): IDisposable[]; + } + + export class Disposable implements IDisposable { + constructor(action: () => void); + + static create(action: () => void): IDisposable; + static empty: IDisposable; + + dispose(): void; + } + + // Single assignment + export class SingleAssignmentDisposable implements IDisposable { + constructor(); + + isDisposed: boolean; + current: IDisposable; + + dispose(): void; + getDisposable(): IDisposable; + setDisposable(value: IDisposable): void; + } + + // SerialDisposable it's an alias of SingleAssignmentDisposable + export class SerialDisposable extends SingleAssignmentDisposable { + constructor(); + } + + export class RefCountDisposable implements IDisposable { + constructor(disposable: IDisposable); + + dispose(): void; + + isDisposed: boolean; + getDisposable(): IDisposable; + } + + export interface IScheduler { + now(): number; + isScheduler(value: any): boolean; + + schedule(action: () => void): IDisposable; + scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; + scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable; + scheduleWithAbsoluteAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; + scheduleWithRelative(dueTime: number, action: () => void): IDisposable; + scheduleWithRelativeAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; + + scheduleRecursive(action: (action: () => void) => void): IDisposable; + scheduleRecursiveWithState(state: TState, action: (state: TState, action: (state: TState) => void) => void): IDisposable; + scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; + scheduleRecursiveWithAbsoluteAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; + scheduleRecursiveWithRelative(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; + scheduleRecursiveWithRelativeAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; + + schedulePeriodic(period: number, action: () => void): IDisposable; + schedulePeriodicWithState(state: TState, period: number, action: (state: TState) => TState): IDisposable; + } + + export interface Scheduler extends IScheduler { + } + + export interface SchedulerStatic { + new ( + now: () => number, + schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, + scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, + scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable): Scheduler; + + normalize(timeSpan: number): number; + + immediate: IScheduler; + currentThread: ICurrentThreadScheduler; + default: IScheduler; // alias for Scheduler.timeout + timeout: IScheduler; + } + + export var Scheduler: SchedulerStatic; + + // Current Thread IScheduler + interface ICurrentThreadScheduler extends IScheduler { + scheduleRequired(): boolean; + } + + // Notifications + export class Notification { + accept(observer: IObserver): void; + accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult; + toObservable(scheduler?: IScheduler): Observable; + hasValue: boolean; + equals(other: Notification): boolean; + kind: string; + value: T; + exception: any; + + static createOnNext(value: T): Notification; + static createOnError(exception: any): Notification; + static createOnCompleted(): Notification; + } + + // Observer + export interface IObserver { + onNext(value: T): void; + onError(exception: any): void; + onCompleted(): void; + } + + export interface Observer extends IObserver { + toNotifier(): (notification: Notification) => void; + asObserver(): Observer; + } + + interface ObserverStatic { + create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; + fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer; + } + + export var Observer: ObserverStatic; + + export interface IObservable { + subscribe(observer: Observer): IDisposable; + subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; + + subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable; + subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable; + subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable; + } + + export interface Observable extends IObservable { + forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe + toArray(): Observable; + + catch(handler: (exception: Error) => IPromise | Observable): Observable; + catch(second: Observable): Observable; + catchException(handler: (exception: Error) => IPromise | Observable): Observable; // alias for catch + catchException(second: Observable): Observable; // alias for catch + combineLatest(second: Observable | IPromise): Observable<[T, T2]>; + combineLatest(second: Observable | IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(second: Observable | IPromise, third: Observable | IPromise): Observable<[T, T2, T3]>; + combineLatest(second: Observable | IPromise, third: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise): Observable<[T, T2, T3, T4]>; + combineLatest(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise): Observable<[T, T2, T3, T4, T5]>; + combineLatest(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + combineLatest(souces: (Observable | IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + withLatestFrom(second: Observable | IPromise): Observable<[T, T2]>; + withLatestFrom(second: Observable | IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(second: Observable | IPromise, third: Observable | IPromise): Observable<[T, T2, T3]>; + withLatestFrom(second: Observable | IPromise, third: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise): Observable<[T, T2, T3, T4]>; + withLatestFrom(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise): Observable<[T, T2, T3, T4, T5]>; + withLatestFrom(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + withLatestFrom(souces: (Observable | IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + concat(...sources: (Observable | IPromise)[]): Observable; + concat(sources: (Observable | IPromise)[]): Observable; + concatAll(): Observable; + concatObservable(): Observable; // alias for concatAll + concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => R[]): Observable; // alias for selectConcat + concatMap(sequence: Observable): Observable; // alias for selectConcat + concatMap(sequence: R[]): Observable; // alias for selectConcat + merge(maxConcurrent: number): T; + merge(other: Observable): Observable; + merge(other: IPromise): Observable; + mergeAll(): Observable; + mergeObservable(): Observable; // alias for mergeAll + skipUntil(other: Observable): Observable; + skipUntil(other: IPromise): Observable; + switch(): T; + switchLatest(): T; // alias for switch + takeUntil(other: Observable): Observable; + takeUntil(other: IPromise): Observable; + zip(second: Observable | IPromise): Observable<[T, T2]>; + zip(second: Observable | IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + zip(second: Observable | IPromise, third: Observable | IPromise): Observable<[T, T2, T3]>; + zip(second: Observable | IPromise, third: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + zip(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise): Observable<[T, T2, T3, T4]>; + zip(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise): Observable<[T, T2, T3, T4, T5]>; + zip(second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + zip(second: (Observable | IPromise)[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; + + asObservable(): Observable; + dematerialize(): Observable; + distinctUntilChanged(skipParameter: boolean, comparer: (x: T, y: T) => boolean): Observable; + distinctUntilChanged(keySelector?: (value: T) => TValue, comparer?: (x: TValue, y: TValue) => boolean): Observable; + do(observer: Observer): Observable; + do(onNext?: (value: T) => void, onError?: (exception: Error) => void, onCompleted?: () => void): Observable; + doAction(observer: Observer): Observable; // alias for do + doAction(onNext?: (value: T) => void, onError?: (exception: Error) => void, onCompleted?: () => void): Observable; // alias for do + tap(observer: Observer): Observable; // alias for do + tap(onNext?: (value: T) => void, onError?: (exception: Error) => void, onCompleted?: () => void): Observable; // alias for do + + doOnNext(onNext: (value: T) => void, thisArg?: any): Observable; + doOnError(onError: (exception: any) => void, thisArg?: any): Observable; + doOnCompleted(onCompleted: () => void, thisArg?: any): Observable; + tapOnNext(onNext: (value: T) => void, thisArg?: any): Observable; + tapOnError(onError: (exception: any) => void, thisArg?: any): Observable; + tapOnCompleted(onCompleted: () => void, thisArg?: any): Observable; + + finally(action: () => void): Observable; + finallyAction(action: () => void): Observable; // alias for finally + ignoreElements(): Observable; + materialize(): Observable>; + repeat(repeatCount?: number): Observable; + retry(retryCount?: number): Observable; + retryWhen(notifier: (errors: Observable) => Observable): Observable; + + /** + * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. + * For aggregation behavior with no intermediate results, see Observable.aggregate. + * @example + * var res = source.scan(function (acc, x) { return acc + x; }); + * var res = source.scan(function (acc, x) { return acc + x; }, 0); + * @param accumulator An accumulator function to be invoked on each element. + * @param seed The initial accumulator value. + * @returns An observable sequence containing the accumulated values. + */ + scan(accumulator: (acc: TAcc, value: T, index?: number, source?: Observable) => TAcc, seed: TAcc): Observable; + scan(accumulator: (acc: T, value: T, index?: number, source?: Observable) => T): Observable; + + skipLast(count: number): Observable; + startWith(...values: T[]): Observable; + startWith(scheduler: IScheduler, ...values: T[]): Observable; + takeLast(count: number): Observable; + takeLastBuffer(count: number): Observable; + + select(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; + map(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for select + pluck(prop: string): Observable; + selectMany(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; + selectMany(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; + selectMany(selector: (value: T) => Observable): Observable; + selectMany(selector: (value: T) => IPromise): Observable; + selectMany(other: Observable): Observable; + selectMany(other: IPromise): Observable; + selectMany(selector: (value: T) => TResult[]): Observable; // alias for selectMany + flatMap(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany + flatMap(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany + flatMap(selector: (value: T) => Observable): Observable; // alias for selectMany + flatMap(selector: (value: T) => IPromise): Observable; // alias for selectMany + flatMap(other: Observable): Observable; // alias for selectMany + flatMap(other: IPromise): Observable; // alias for selectMany + flatMap(selector: (value: T) => TResult[]): Observable; // alias for selectMany + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + selectManyObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + flatMapObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; + + selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; + selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; + selectConcat(selector: (value: T, index: number) => Observable): Observable; + selectConcat(selector: (value: T, index: number) => IPromise): Observable; + selectConcat(sequence: Observable): Observable; + + /** + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param [thisArg] Object to use as this when executing callback. + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + selectSwitch(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; + /** + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param [thisArg] Object to use as this when executing callback. + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + flatMapLatest(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; // alias for selectSwitch + /** + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param [thisArg] Object to use as this when executing callback. + * @since 2.2.28 + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + switchMap(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for selectSwitch + + skip(count: number): Observable; + skipWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + take(count: number, scheduler?: IScheduler): Observable; + takeWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + where(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + filter(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for where + + /** + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * @param promiseCtor The constructor of the promise. + * @returns An ES6 compatible promise with the last value from the observable sequence. + */ + toPromise>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise; + /** + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * + * // With config + * Rx.config.Promise = RSVP.Promise; + * var promise = Rx.Observable.return(42).toPromise(); + * @param [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. + * @returns An ES6 compatible promise with the last value from the observable sequence. + */ + toPromise(promiseCtor?: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }): IPromise; + + // Experimental Flattening + + /** + * Performs a exclusive waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * Can be applied on `Observable>` or `Observable>`. + * @since 2.2.28 + * @returns A exclusive observable with only the results that happen when subscribed. + */ + exclusive(): Observable; + + /** + * Performs a exclusive map waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * Can be applied on `Observable>` or `Observable>`. + * @since 2.2.28 + * @param selector Selector to invoke for every item in the current subscription. + * @param [thisArg] An optional context to invoke with the selector parameter. + * @returns {An exclusive observable with only the results that happen when subscribed. + */ + exclusiveMap(selector: (value: I, index: number, source: Observable) => R, thisArg?: any): Observable; + + publish(): ConnectableObservable; + } + + interface ConnectableObservable extends Observable { + connect(): Disposable; + } + + interface ObservableStatic { + create(subscribe: (observer: Observer) => IDisposable): Observable; + create(subscribe: (observer: Observer) => () => void): Observable; + create(subscribe: (observer: Observer) => void): Observable; + createWithDisposable(subscribe: (observer: Observer) => IDisposable): Observable; + defer(observableFactory: () => Observable): Observable; + defer(observableFactory: () => IPromise): Observable; + empty(scheduler?: IScheduler): Observable; + + /** + * This method creates a new Observable sequence from an array object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param mapFn Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: T[], mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; + /** + * This method creates a new Observable sequence from an array object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param [mapFn] Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: T[], mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; + + /** + * This method creates a new Observable sequence from an array-like object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param mapFn Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: { length: number; [index: number]: T; }, mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; + /** + * This method creates a new Observable sequence from an array-like object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param [mapFn] Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: { length: number; [index: number]: T; }, mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; + + /** + * This method creates a new Observable sequence from an array-like or iterable object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param [mapFn] Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(iterable: any, mapFn?: (value: any, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; + + fromArray(array: T[], scheduler?: IScheduler): Observable; + fromArray(array: { length: number; [index: number]: T; }, scheduler?: IScheduler): Observable; + + generate(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable; + never(): Observable; + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * + * @example + * var res = Rx.Observable.of(1, 2, 3); + * @since 2.2.28 + * @returns The observable sequence whose elements are pulled from the given arguments. + */ + of(...values: T[]): Observable; + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * @example + * var res = Rx.Observable.ofWithScheduler(Rx.Scheduler.timeout, 1, 2, 3); + * @since 2.2.28 + * @param [scheduler] A scheduler to use for scheduling the arguments. + * @returns The observable sequence whose elements are pulled from the given arguments. + */ + ofWithScheduler(scheduler?: IScheduler, ...values: T[]): Observable; + range(start: number, count: number, scheduler?: IScheduler): Observable; + repeat(value: T, repeatCount?: number, scheduler?: IScheduler): Observable; + return(value: T, scheduler?: IScheduler): Observable; + /** + * @since 2.2.28 + */ + just(value: T, scheduler?: IScheduler): Observable; // alias for return + returnValue(value: T, scheduler?: IScheduler): Observable; // alias for return + throw(exception: Error, scheduler?: IScheduler): Observable; + throwException(exception: Error, scheduler?: IScheduler): Observable; // alias for throw + throwError(error: Error, scheduler?: IScheduler): Observable; // alias for throw + + catch(sources: IPromise[] | Observable[]): Observable; + catch(...sources: Observable[]): Observable; + catch(...sources: IPromise[]): Observable; + catchException(sources: IPromise[] | Observable[]): Observable; // alias for catch + catchException(...sources: Observable[]): Observable; // alias for catch + catchException(...sources: IPromise[]): Observable; // alias for catch + catchError(sources: IPromise[] | Observable[]): Observable; // alias for catch + catchError(...sources: Observable[]): Observable; // alias for catch + catchError(...sources: IPromise[]): Observable; // alias for catch + + combineLatest(first: Observable | IPromise, second: Observable | IPromise): Observable<[T, T2]>; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise): Observable<[T, T2, T3]>; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise): Observable<[T, T2, T3, T4]>; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise): Observable<[T, T2, T3, T4, T5]>; + combineLatest(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + combineLatest(sources: (Observable | IPromise)[]): Observable; + combineLatest(sources: (Observable | IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise): Observable<[T, T2]>; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise): Observable<[T, T2, T3]>; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise): Observable<[T, T2, T3, T4]>; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise): Observable<[T, T2, T3, T4, T5]>; + withLatestFrom(first: Observable | IPromise, second: Observable | IPromise, third: Observable | IPromise, fourth: Observable | IPromise, fifth: Observable | IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + withLatestFrom(souces: (Observable | IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + + concat(...sources: Observable[]): Observable; + concat(...sources: IPromise[]): Observable; + concat(sources: IPromise[] | Observable[]): Observable; + merge(...sources: Observable[]): Observable; + merge(...sources: IPromise[]): Observable; + merge(sources: IPromise[] | Observable[]): Observable; + merge(scheduler: IScheduler, ...sources: Observable[]): Observable; + merge(scheduler: IScheduler, ...sources: IPromise[]): Observable; + merge(scheduler: IScheduler, sources: IPromise[] | Observable[]): Observable; + + pairs(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>; + + zip(first: Observable | IPromise, sources: Observable | IPromise | (Observable | IPromise)[]): Observable<[T1, T2]>; + zip(first: Observable | IPromise, sources: (Observable | IPromise)[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; + zip(source1: Observable | IPromise, source2: Observable | IPromise, resultSelector: (item1: T1, item2: T2) => TResult): Observable; + zip(source1: Observable | IPromise, source2: Observable | IPromise, source3: Observable | IPromise): Observable<[T1, T2, T3]>; + zip(source1: Observable | IPromise, source2: Observable | IPromise, source3: Observable | IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; + zip(source1: Observable | IPromise, source2: Observable | IPromise, source3: Observable | IPromise, source4: Observable | IPromise): Observable<[T1, T2, T3, T4]>; + zip(source1: Observable | IPromise, source2: Observable | IPromise, source3: Observable | IPromise, source4: Observable | IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable | IPromise, source2: Observable | IPromise, source3: Observable | IPromise, source4: Observable | IPromise, source5: Observable | IPromise): Observable<[T1, T2, T3, T4, T5]>; + zip(source1: Observable | IPromise, source2: Observable | IPromise, source3: Observable | IPromise, source4: Observable | IPromise, source5: Observable | IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable; + zipArray(...sources: (Observable | IPromise)[]): Observable; + zipArray(sources: (Observable | IPromise)[]): Observable; + + /** + * Converts a Promise to an Observable sequence + * @param promise An ES6 Compliant promise. + * @returns An Observable sequence which wraps the existing promise success and failure. + */ + fromPromise(promise: IPromise): Observable; + + prototype: any; + } + + export var Observable: ObservableStatic; +} + +// Async + +declare namespace Rx { + export namespace config { + /** + * Configuration option to determine whether to use native events only + */ + export var useNativeEvents: boolean; + } + + interface ObservableStatic { + fromCallback: { + // with single result callback without selector + (func: (callback: (result: TResult) => any) => any, context?: any): () => Observable; + (func: (arg1: T1, callback: (result: TResult) => any) => any, context?: any): (arg1: T1) => Observable; + (func: (arg1: T1, arg2: T2, callback: (result: TResult) => any) => any, context?: any): (arg1: T1, arg2: T2) => Observable; + (func: (arg1: T1, arg2: T2, arg3: T3, callback: (result: TResult) => any) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; + // with any callback with selector + (func: (callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): () => Observable; + (func: (arg1: T1, callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): (arg1: T1) => Observable; + (func: (arg1: T1, arg2: T2, callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): (arg1: T1, arg2: T2) => Observable; + (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): (arg1: T1, arg2: T2, arg3: T3) => Observable; + // with any callback without selector + (func: (callback: Function) => any, context?: any): () => Observable; + (func: (arg1: T1, callback: Function) => any, context?: any): (arg1: T1) => Observable; + (func: (arg1: T1, arg2: T2, callback: Function) => any, context?: any): (arg1: T1, arg2: T2) => Observable; + (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; + // with any function with selector + (func: Function, context: any, selector: (args: TCallbackResult[]) => TResult): (...args: any[]) => Observable; + // with any function without selector + (func: Function, context?: any): (...args: any[]) => Observable; + }; + + fromNodeCallback: { + // with single result callback without selector + (func: (callback: (err: any, result: T) => any) => any, context?: any): () => Observable; + (func: (arg1: T1, callback: (err: any, result: T) => any) => any, context?: any): (arg1: T1) => Observable; + (func: (arg1: T1, arg2: T2, callback: (err: any, result: T) => any) => any, context?: any): (arg1: T1, arg2: T2) => Observable; + (func: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: T) => any) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; + // with any callback with selector + (func: (callback: Function) => any, context: any, selector: (results: TC[]) => TR): () => Observable; + (func: (arg1: T1, callback: Function) => any, context: any, selector: (results: TC[]) => TR): (arg1: T1) => Observable; + (func: (arg1: T1, arg2: T2, callback: Function) => any, context: any, selector: (results: TC[]) => TR): (arg1: T1, arg2: T2) => Observable; + (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context: any, selector: (results: TC[]) => TR): (arg1: T1, arg2: T2, arg3: T3) => Observable; + // with any callback without selector + (func: (callback: Function) => any, context?: any): () => Observable; + (func: (arg1: T1, callback: Function) => any, context?: any): (arg1: T1) => Observable; + (func: (arg1: T1, arg2: T2, callback: Function) => any, context?: any): (arg1: T1, arg2: T2) => Observable; + (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; + // with any function with selector + (func: Function, context: any, selector: (results: TC[]) => T): (...args: any[]) => Observable; + // with any function without selector + (func: Function, context?: any): (...args: any[]) => Observable; + }; + + fromEvent(element: NodeList, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEvent(element: Node, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEvent(element: { on: (name: string, cb: (e: any) => any) => void; off: (name: string, cb: (e: any) => any) => void }, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[]) => T): Observable; + } +} + +// time + +declare namespace Rx { + export interface TimeInterval { + value: T; + interval: number; + } + + export interface Timestamp { + value: T; + timestamp: number; + } + + export interface Observable { + delay(dueTime: Date, scheduler?: IScheduler): Observable; + delay(dueTime: number, scheduler?: IScheduler): Observable; + + debounce(dueTime: number, scheduler?: IScheduler): Observable; + throttleWithTimeout(dueTime: number, scheduler?: IScheduler): Observable; + /** + * @deprecated use #debounce or #throttleWithTimeout instead. + */ + throttle(dueTime: number, scheduler?: IScheduler): Observable; + + timeInterval(scheduler?: IScheduler): Observable>; + + timestamp(scheduler?: IScheduler): Observable>; + + sample(interval: number, scheduler?: IScheduler): Observable; + sample(sampler: Observable, scheduler?: IScheduler): Observable; + + timeout(dueTime: Date, other?: Observable, scheduler?: IScheduler): Observable; + timeout(dueTime: number, other?: Observable, scheduler?: IScheduler): Observable; + } + + interface ObservableStatic { + interval(period: number, scheduler?: IScheduler): Observable; + interval(dutTime: number, period: number, scheduler?: IScheduler): Observable; + timer(dueTime: number, period: number, scheduler?: IScheduler): Observable; + timer(dueTime: number, scheduler?: IScheduler): Observable; + } +} + +declare module "rx-lite" { + export = Rx; +} diff --git a/rx-lite/rx-lite-tests.ts b/rx-lite/rx-lite-tests.ts new file mode 100644 index 0000000000..8422bfd9f2 --- /dev/null +++ b/rx-lite/rx-lite-tests.ts @@ -0,0 +1,152 @@ +import * as Rx from 'rx-lite'; + +namespace Tests.Async { + + var obsNum: Rx.Observable; + var obsStr: Rx.Observable; + var sch: Rx.IScheduler; + + function fromCallback() { + // 0 arguments + var func0: (cb: (result: number) => void) => void = () => { }; + obsNum = Rx.Observable.fromCallback(func0)(); + obsNum = Rx.Observable.fromCallback(func0, obsStr)(); + obsNum = Rx.Observable.fromCallback(func0, obsStr, (results: number[]) => results[0])(); + + // 1 argument + var func1: (a: string, cb: (result: number) => void) => number = () => 0; + obsNum = Rx.Observable.fromCallback(func1)(""); + obsNum = Rx.Observable.fromCallback(func1, {})(""); + obsNum = Rx.Observable.fromCallback(func1, {}, (results: number[]) => results[0])(""); + + // 2 arguments + var func2: (a: number, b: string, cb: (result: string) => number) => Date = () => new Date(); + obsStr = Rx.Observable.fromCallback(func2)(1, ""); + obsStr = Rx.Observable.fromCallback(func2, {})(1, ""); + obsStr = Rx.Observable.fromCallback(func2, {}, (results: string[]) => results[0])(1, ""); + + // 3 arguments + var func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date = () => new Date(); + obsStr = Rx.Observable.fromCallback(func3)(1, "", true); + obsStr = Rx.Observable.fromCallback(func3, {})(1, "", true); + obsStr = Rx.Observable.fromCallback(func3, {}, (results: string[]) => results[0])(1, "", true); + + // multiple results + var func0m: (cb: (result1: number, result2: number, result3: number) => void) => void = () => { }; + obsNum = Rx.Observable.fromCallback(func0m, obsStr, (results: number[]) => results[0])(); + var func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void = () => { }; + obsNum = Rx.Observable.fromCallback(func1m, obsStr, (results: number[]) => results[0])(""); + var func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void = () => { }; + obsStr = Rx.Observable.fromCallback(func2m, obsStr, (results: string[]) => results[0])("", 10); + } + + function toPromise() { + var promiseImpl: { + new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Rx.IPromise; + } = undefined as any; + + Rx.config.Promise = promiseImpl; + + var p: Rx.IPromise = obsNum.toPromise(promiseImpl); + + p = obsNum.toPromise(); + + p = p.then(x => x); + p = p.then(x => p); + p = p.then(undefined, reason => 10); + //p = p.then(undefined, reason => p); + + var ps: Rx.IPromise = p.then(undefined, reason => "error"); + ps = p.then(x => ""); + ps = p.then(x => ps); + } +} + +function test_scan() { + + /* Without a seed */ + const source1: Rx.Observable = Rx.Observable.range(1, 3) + .scan((acc, x, i, source) => acc + x); + + /* With a seed */ + const source2: Rx.Observable = Rx.Observable.range(1, 3) + .scan((acc, x, i, source) => acc + x, '...'); + +} + +function test_concatAll() { + /* concatAll Example */ + var source = Rx.Observable.range(0, 3) + .map(function (x) { return Rx.Observable.range(x, 3); }) + .concatAll(); + + var subscription = source.subscribe( + function (x) { + console.log('Next: %s', x); + }, + function (err) { + console.log('Error: %s', err); + }, + function () { + console.log('Completed'); + }); +} + +function test_mergeAll() { + /* mergeAll example */ + var source = Rx.Observable.range(0, 3) + .map(function (x) { return Rx.Observable.range(x, 3); }) + .mergeAll(); + + var subscription = source.subscribe( + function (x) { + console.log('Next: %s', x); + }, + function (err) { + console.log('Error: %s', err); + }, + function () { + console.log('Completed'); + }); + +} + +// from https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/publish.md +function test_publish() { + var interval = Rx.Observable.interval(1000); + + var source = interval + .take(2) + .doAction(function (x) { + console.log('Side effect'); + }); + + var published = source.publish(); + + published.subscribe(createObserver('SourceA')); + published.subscribe(createObserver('SourceB')); + + var connection = published.connect(); + + function createObserver(tag: string) { + return Rx.Observer.create( + function (x) { + console.log('Next: ' + tag + x); + }, + function (err) { + console.log('Error: ' + err); + }, + function () { + console.log('Completed'); + }); + } + + // => Side effect + // => Next: SourceA0 + // => Next: SourceB0 + // => Side effect + // => Next: SourceA1 + // => Next: SourceB1 + // => Completed + // => Completed +} diff --git a/rx-lite/tsconfig.json b/rx-lite/tsconfig.json new file mode 100644 index 0000000000..94b69bfab2 --- /dev/null +++ b/rx-lite/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rx-lite-tests.ts" + ] +} diff --git a/rx-lite/tslint.json b/rx-lite/tslint.json new file mode 100644 index 0000000000..9dd4e0d05f --- /dev/null +++ b/rx-lite/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false, + "no-empty-interface": false, + "forbidden-types": false, + "interface-name": false, + "array-type": false, + "no-single-declare-module": false + } +} diff --git a/rx.wamp/rx.wamp-tests.ts b/rx.wamp/rx.wamp-tests.ts index 340be02b64..2b6d4c95bc 100644 --- a/rx.wamp/rx.wamp-tests.ts +++ b/rx.wamp/rx.wamp-tests.ts @@ -1,5 +1,5 @@ -/// +/// import * as autobahn from "autobahn"; import {IWampEvent} from "rx.wamp"; diff --git a/rx/index.d.ts b/rx/index.d.ts index a3540fbd02..7edaa9c1b2 100644 --- a/rx/index.d.ts +++ b/rx/index.d.ts @@ -1,62 +1,20 @@ -// Type definitions for RxJS 4.1 -// Project: http://rx.codeplex.com/ -// Definitions by: gsino , Igor Oleinikov , Mizunashi Mana +// Type definitions for rx 4.1 +// Project: https://github.com/Reactive-Extensions/RxJS +// Definitions by: Carl de Billy , gsino , Igor Oleinikov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - -declare namespace Rx { - export interface IScheduler { - catch(handler: (exception: any) => boolean): IScheduler; - catchException(handler: (exception: any) => boolean): IScheduler; - } - - // Observer - export interface Observer { - checked(): Observer; - } - - interface ObserverStatic { - /** - * Schedules the invocation of observer methods on the given scheduler. - * @param scheduler Scheduler to schedule observer messages on. - * @returns Observer whose messages are scheduled on the given scheduler. - */ - notifyOn(scheduler: IScheduler): Observer; - } - - export interface Observable { - observeOn(scheduler: IScheduler): Observable; - subscribeOn(scheduler: IScheduler): Observable; - - amb(rightSource: IPromise | Observable): Observable; - onErrorResumeNext(second: IPromise | Observable): Observable; - bufferWithCount(count: number, skip?: number): Observable; - windowWithCount(count: number, skip?: number): Observable>; - defaultIfEmpty(defaultValue?: T): Observable; - distinct(skipParameter: boolean, valueSerializer: (value: T) => string): Observable; - distinct(keySelector?: (value: T) => TKey, keySerializer?: (key: TKey) => string): Observable; - groupBy(keySelector: (value: T) => TKey, skipElementSelector?: boolean, keySerializer?: (key: TKey) => string): Observable>; - groupBy(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, keySerializer?: (key: TKey) => string): Observable>; - groupByUntil(keySelector: (value: T) => TKey, skipElementSelector: boolean, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; - groupByUntil(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; - } - - interface ObservableStatic { - using(resourceFactory: () => TResource, observableFactory: (resource: TResource) => Observable): Observable; - amb(...sources: IPromise[]): Observable; - amb(...sources: Observable[]): Observable; - amb(sources: IPromise[] | Observable[]): Observable; - onErrorResumeNext(...sources: IPromise[]): Observable; - onErrorResumeNext(...sources: Observable[]): Observable; - onErrorResumeNext(sources: IPromise[] | Observable[]): Observable; - } - - interface GroupedObservable extends Observable { - key: TKey; - underlyingObservable: Observable; - } -} +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// declare module "rx" { export = Rx; diff --git a/rx/rx-lite.d.ts b/rx/rx-lite.d.ts deleted file mode 100644 index 7db2ed6bc8..0000000000 --- a/rx/rx-lite.d.ts +++ /dev/null @@ -1,627 +0,0 @@ -// This file contains common part of defintions for rx.d.ts and rx.lite.d.ts -// Do not include the file separately. - -declare namespace Rx { - export namespace internals { - function isEqual(left: any, right: any): boolean; - function addRef(xs: Observable, r: { getDisposable(): IDisposable; }): Observable; - - // Priority Queue for Scheduling - export class PriorityQueue { - constructor(capacity: number); - - length: number; - - isHigherPriority(left: number, right: number): boolean; - percolate(index: number): void; - heapify(index: number): void; - peek(): ScheduledItem; - removeAt(index: number): void; - dequeue(): ScheduledItem; - enqueue(item: ScheduledItem): void; - remove(item: ScheduledItem): boolean; - - static count: number; - } - - export class ScheduledItem { - constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number); - - scheduler: IScheduler; - state: TTime; - action: (scheduler: IScheduler, state: any) => IDisposable; - dueTime: TTime; - comparer: (x: TTime, y: TTime) => number; - disposable: SingleAssignmentDisposable; - - invoke(): void; - compareTo(other: ScheduledItem): number; - isCancelled(): boolean; - invokeCore(): IDisposable; - } - } - - export namespace config { - export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }; - } - - export namespace helpers { - function noop(): void; - function notDefined(value: any): boolean; - function identity(value: T): T; - function defaultNow(): number; - function defaultComparer(left: any, right: any): boolean; - function defaultSubComparer(left: any, right: any): number; - function defaultKeySerializer(key: any): string; - function defaultError(err: any): void; - function isPromise(p: any): boolean; - function asArray(...args: T[]): T[]; - function not(value: any): boolean; - function isFunction(value: any): boolean; - } - - export interface IDisposable { - dispose(): void; - } - - export class CompositeDisposable implements IDisposable { - constructor (...disposables: IDisposable[]); - constructor (disposables: IDisposable[]); - - isDisposed: boolean; - length: number; - - dispose(): void; - add(item: IDisposable): void; - remove(item: IDisposable): boolean; - toArray(): IDisposable[]; - } - - export class Disposable implements IDisposable { - constructor(action: () => void); - - static create(action: () => void): IDisposable; - static empty: IDisposable; - - dispose(): void; - } - - // Single assignment - export class SingleAssignmentDisposable implements IDisposable { - constructor(); - - isDisposed: boolean; - current: IDisposable; - - dispose(): void ; - getDisposable(): IDisposable; - setDisposable(value: IDisposable): void ; - } - - // SerialDisposable it's an alias of SingleAssignmentDisposable - export class SerialDisposable extends SingleAssignmentDisposable { - constructor(); - } - - export class RefCountDisposable implements IDisposable { - constructor(disposable: IDisposable); - - dispose(): void; - - isDisposed: boolean; - getDisposable(): IDisposable; - } - - export interface IScheduler { - now(): number; - isScheduler(value: any): boolean; - - schedule(action: () => void): IDisposable; - scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; - scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable; - scheduleWithAbsoluteAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; - scheduleWithRelative(dueTime: number, action: () => void): IDisposable; - scheduleWithRelativeAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; - - scheduleRecursive(action: (action: () => void) => void): IDisposable; - scheduleRecursiveWithState(state: TState, action: (state: TState, action: (state: TState) => void) => void): IDisposable; - scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; - scheduleRecursiveWithAbsoluteAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; - scheduleRecursiveWithRelative(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; - scheduleRecursiveWithRelativeAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; - - schedulePeriodic(period: number, action: () => void): IDisposable; - schedulePeriodicWithState(state: TState, period: number, action: (state: TState) => TState): IDisposable; - } - - export interface Scheduler extends IScheduler { - } - - export interface SchedulerStatic { - new ( - now: () => number, - schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, - scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, - scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable): Scheduler; - - normalize(timeSpan: number): number; - - immediate: IScheduler; - currentThread: ICurrentThreadScheduler; - default: IScheduler; // alias for Scheduler.timeout - timeout: IScheduler; - } - - export var Scheduler: SchedulerStatic; - - // Current Thread IScheduler - interface ICurrentThreadScheduler extends IScheduler { - scheduleRequired(): boolean; - } - - // Notifications - export class Notification { - accept(observer: IObserver): void; - accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult; - toObservable(scheduler?: IScheduler): Observable; - hasValue: boolean; - equals(other: Notification): boolean; - kind: string; - value: T; - exception: any; - - static createOnNext(value: T): Notification; - static createOnError(exception: any): Notification; - static createOnCompleted(): Notification; - } - - /** - * Promise A+ - */ - export interface IPromise { - then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise; - then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; - then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise; - then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise; - } - - // Observer - export interface IObserver { - onNext(value: T): void; - onError(exception: any): void; - onCompleted(): void; - } - - export interface Observer extends IObserver { - toNotifier(): (notification: Notification) => void; - asObserver(): Observer; - } - - interface ObserverStatic { - create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; - fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer; - } - - export var Observer: ObserverStatic; - - export interface IObservable { - subscribe(observer: Observer): IDisposable; - subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; - - subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable; - subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable; - subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable; - } - - export interface Observable extends IObservable { - forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe - toArray(): Observable; - - catch(handler: (exception: Error) => IPromise | Observable): Observable; - catch(second: Observable): Observable; - catchException(handler: (exception: Error) => IPromise | Observable): Observable; // alias for catch - catchException(second: Observable): Observable; // alias for catch - combineLatest(second: Observable|IPromise): Observable<[T, T2]>; - combineLatest(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - combineLatest(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - combineLatest(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; - withLatestFrom(second: Observable|IPromise): Observable<[T, T2]>; - withLatestFrom(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; - concat(...sources: (Observable|IPromise)[]): Observable; - concat(sources: (Observable|IPromise)[]): Observable; - concatAll(): Observable; - concatObservable(): Observable; // alias for concatAll - concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => R[]): Observable; // alias for selectConcat - concatMap(sequence: Observable): Observable; // alias for selectConcat - concatMap(sequence: R[]): Observable; // alias for selectConcat - merge(maxConcurrent: number): T; - merge(other: Observable): Observable; - merge(other: IPromise): Observable; - mergeAll(): Observable; - mergeObservable(): Observable; // alias for mergeAll - skipUntil(other: Observable): Observable; - skipUntil(other: IPromise): Observable; - switch(): T; - switchLatest(): T; // alias for switch - takeUntil(other: Observable): Observable; - takeUntil(other: IPromise): Observable; - zip(second: Observable|IPromise): Observable<[T, T2]>; - zip(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - zip(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - zip(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - zip(second: (Observable|IPromise)[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; - - asObservable(): Observable; - dematerialize(): Observable; - distinctUntilChanged(skipParameter: boolean, comparer: (x: T, y: T) => boolean): Observable; - distinctUntilChanged(keySelector?: (value: T) => TValue, comparer?: (x: TValue, y: TValue) => boolean): Observable; - do(observer: Observer): Observable; - do(onNext?: (value: T) => void, onError?: (exception: Error) => void, onCompleted?: () => void): Observable; - doAction(observer: Observer): Observable; // alias for do - doAction(onNext?: (value: T) => void, onError?: (exception: Error) => void, onCompleted?: () => void): Observable; // alias for do - tap(observer: Observer): Observable; // alias for do - tap(onNext?: (value: T) => void, onError?: (exception: Error) => void, onCompleted?: () => void): Observable; // alias for do - - doOnNext(onNext: (value: T) => void, thisArg?: any): Observable; - doOnError(onError: (exception: any) => void, thisArg?: any): Observable; - doOnCompleted(onCompleted: () => void, thisArg?: any): Observable; - tapOnNext(onNext: (value: T) => void, thisArg?: any): Observable; - tapOnError(onError: (exception: any) => void, thisArg?: any): Observable; - tapOnCompleted(onCompleted: () => void, thisArg?: any): Observable; - - finally(action: () => void): Observable; - finallyAction(action: () => void): Observable; // alias for finally - ignoreElements(): Observable; - materialize(): Observable>; - repeat(repeatCount?: number): Observable; - retry(retryCount?: number): Observable; - retryWhen(notifier: (errors: Observable) => Observable): Observable; - - /** - * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. - * For aggregation behavior with no intermediate results, see Observable.aggregate. - * @example - * var res = source.scan(function (acc, x) { return acc + x; }); - * var res = source.scan(function (acc, x) { return acc + x; }, 0); - * @param accumulator An accumulator function to be invoked on each element. - * @param seed The initial accumulator value. - * @returns An observable sequence containing the accumulated values. - */ - scan(accumulator: (acc: TAcc, value: T, index?: number, source?: Observable) => TAcc, seed: TAcc): Observable; - scan(accumulator: (acc: T, value: T, index?: number, source?: Observable) => T): Observable; - - skipLast(count: number): Observable; - startWith(...values: T[]): Observable; - startWith(scheduler: IScheduler, ...values: T[]): Observable; - takeLast(count: number): Observable; - takeLastBuffer(count: number): Observable; - - select(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; - map(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for select - pluck(prop: string): Observable; - selectMany(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; - selectMany(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; - selectMany(selector: (value: T) => Observable): Observable; - selectMany(selector: (value: T) => IPromise): Observable; - selectMany(other: Observable): Observable; - selectMany(other: IPromise): Observable; - selectMany(selector: (value: T) => TResult[]): Observable; // alias for selectMany - flatMap(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany - flatMap(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany - flatMap(selector: (value: T) => Observable): Observable; // alias for selectMany - flatMap(selector: (value: T) => IPromise): Observable; // alias for selectMany - flatMap(other: Observable): Observable; // alias for selectMany - flatMap(other: IPromise): Observable; // alias for selectMany - flatMap(selector: (value: T) => TResult[]): Observable; // alias for selectMany - - /** - * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. - * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. - * @param {Function} onError A transform function to apply when an error occurs in the source sequence. - * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. - * @param {Any} [thisArg] An optional "this" to use to invoke each transform. - * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. - */ - selectManyObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; - - /** - * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. - * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. - * @param {Function} onError A transform function to apply when an error occurs in the source sequence. - * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. - * @param {Any} [thisArg] An optional "this" to use to invoke each transform. - * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. - */ - flatMapObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; - - selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; - selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; - selectConcat(selector: (value: T, index: number) => Observable): Observable; - selectConcat(selector: (value: T, index: number) => IPromise): Observable; - selectConcat(sequence: Observable): Observable; - - /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then - * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param [thisArg] Object to use as this when executing callback. - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences - * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - selectSwitch(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; - /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then - * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param [thisArg] Object to use as this when executing callback. - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences - * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - flatMapLatest(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; // alias for selectSwitch - /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then - * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param [thisArg] Object to use as this when executing callback. - * @since 2.2.28 - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences - * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - switchMap(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for selectSwitch - - skip(count: number): Observable; - skipWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - take(count: number, scheduler?: IScheduler): Observable; - takeWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - where(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - filter(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for where - - /** - * Converts an existing observable sequence to an ES6 Compatible Promise - * @example - * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); - * @param promiseCtor The constructor of the promise. - * @returns An ES6 compatible promise with the last value from the observable sequence. - */ - toPromise>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise; - /** - * Converts an existing observable sequence to an ES6 Compatible Promise - * @example - * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); - * - * // With config - * Rx.config.Promise = RSVP.Promise; - * var promise = Rx.Observable.return(42).toPromise(); - * @param [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. - * @returns An ES6 compatible promise with the last value from the observable sequence. - */ - toPromise(promiseCtor?: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }): IPromise; - - // Experimental Flattening - - /** - * Performs a exclusive waiting for the first to finish before subscribing to another observable. - * Observables that come in between subscriptions will be dropped on the floor. - * Can be applied on `Observable>` or `Observable>`. - * @since 2.2.28 - * @returns A exclusive observable with only the results that happen when subscribed. - */ - exclusive(): Observable; - - /** - * Performs a exclusive map waiting for the first to finish before subscribing to another observable. - * Observables that come in between subscriptions will be dropped on the floor. - * Can be applied on `Observable>` or `Observable>`. - * @since 2.2.28 - * @param selector Selector to invoke for every item in the current subscription. - * @param [thisArg] An optional context to invoke with the selector parameter. - * @returns {An exclusive observable with only the results that happen when subscribed. - */ - exclusiveMap(selector: (value: I, index: number, source: Observable) => R, thisArg?: any): Observable; - - publish(): ConnectableObservable; - } - - interface ConnectableObservable extends Observable { - connect(): Disposable; - } - - interface ObservableStatic { - create(subscribe: (observer: Observer) => IDisposable): Observable; - create(subscribe: (observer: Observer) => () => void): Observable; - create(subscribe: (observer: Observer) => void): Observable; - createWithDisposable(subscribe: (observer: Observer) => IDisposable): Observable; - defer(observableFactory: () => Observable): Observable; - defer(observableFactory: () => IPromise): Observable; - empty(scheduler?: IScheduler): Observable; - - /** - * This method creates a new Observable sequence from an array object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param mapFn Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: T[], mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; - /** - * This method creates a new Observable sequence from an array object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param [mapFn] Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: T[], mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; - - /** - * This method creates a new Observable sequence from an array-like object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param mapFn Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: { length: number; [index: number]: T; }, mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; - /** - * This method creates a new Observable sequence from an array-like object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param [mapFn] Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: { length: number; [index: number]: T; }, mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; - - /** - * This method creates a new Observable sequence from an array-like or iterable object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param [mapFn] Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(iterable: any, mapFn?: (value: any, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; - - fromArray(array: T[], scheduler?: IScheduler): Observable; - fromArray(array: { length: number; [index: number]: T; }, scheduler?: IScheduler): Observable; - - generate(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable; - never(): Observable; - - /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * - * @example - * var res = Rx.Observable.of(1, 2, 3); - * @since 2.2.28 - * @returns The observable sequence whose elements are pulled from the given arguments. - */ - of(...values: T[]): Observable; - - /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * @example - * var res = Rx.Observable.ofWithScheduler(Rx.Scheduler.timeout, 1, 2, 3); - * @since 2.2.28 - * @param [scheduler] A scheduler to use for scheduling the arguments. - * @returns The observable sequence whose elements are pulled from the given arguments. - */ - ofWithScheduler(scheduler?: IScheduler, ...values: T[]): Observable; - range(start: number, count: number, scheduler?: IScheduler): Observable; - repeat(value: T, repeatCount?: number, scheduler?: IScheduler): Observable; - return(value: T, scheduler?: IScheduler): Observable; - /** - * @since 2.2.28 - */ - just(value: T, scheduler?: IScheduler): Observable; // alias for return - returnValue(value: T, scheduler?: IScheduler): Observable; // alias for return - throw(exception: Error, scheduler?: IScheduler): Observable; - throwException(exception: Error, scheduler?: IScheduler): Observable; // alias for throw - throwError(error: Error, scheduler?: IScheduler): Observable; // alias for throw - - catch(sources: IPromise[] | Observable[]): Observable; - catch(...sources: Observable[]): Observable; - catch(...sources: IPromise[]): Observable; - catchException(sources: IPromise[] | Observable[]): Observable; // alias for catch - catchException(...sources: Observable[]): Observable; // alias for catch - catchException(...sources: IPromise[]): Observable; // alias for catch - catchError(sources: IPromise[] | Observable[]): Observable; // alias for catch - catchError(...sources: Observable[]): Observable; // alias for catch - catchError(...sources: IPromise[]): Observable; // alias for catch - - combineLatest(first: Observable|IPromise, second: Observable|IPromise): Observable<[T, T2]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - combineLatest(sources: (Observable|IPromise)[]): Observable; - combineLatest(sources: (Observable|IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; - - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise): Observable<[T, T2]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; - - concat(...sources: Observable[]): Observable; - concat(...sources: IPromise[]): Observable; - concat(sources: IPromise[] | Observable[]): Observable; - merge(...sources: Observable[]): Observable; - merge(...sources: IPromise[]): Observable; - merge(sources: IPromise[] | Observable[]): Observable; - merge(scheduler: IScheduler, ...sources: Observable[]): Observable; - merge(scheduler: IScheduler, ...sources: IPromise[]): Observable; - merge(scheduler: IScheduler, sources: IPromise[] | Observable[]): Observable; - - pairs(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>; - - zip(first: Observable | IPromise, sources: Observable | IPromise | (Observable | IPromise)[]): Observable<[T1, T2]>; - zip(first: Observable|IPromise, sources: (Observable|IPromise)[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, resultSelector: (item1: T1, item2: T2) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise): Observable<[T1, T2, T3]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise): Observable<[T1, T2, T3, T4]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, source5: Observable|IPromise): Observable<[T1, T2, T3, T4, T5]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, source5: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable; - zipArray(...sources: (Observable|IPromise)[]): Observable; - zipArray(sources: (Observable|IPromise)[]): Observable; - - /** - * Converts a Promise to an Observable sequence - * @param promise An ES6 Compliant promise. - * @returns An Observable sequence which wraps the existing promise success and failure. - */ - fromPromise(promise: IPromise): Observable; - - prototype: any; - } - - export var Observable: ObservableStatic; - - interface ISubject extends Observable, Observer, IDisposable { - hasObservers(): boolean; - } - - export interface Subject extends ISubject { - } - - interface SubjectStatic { - new (): Subject; - create(observer?: Observer, observable?: Observable): ISubject; - } - - export var Subject: SubjectStatic; - - export interface AsyncSubject extends Subject { - } - - interface AsyncSubjectStatic { - new (): AsyncSubject; - } - - export var AsyncSubject: AsyncSubjectStatic; -} diff --git a/rx/rx-tests.ts b/rx/rx-tests.ts deleted file mode 100644 index 26b616a254..0000000000 --- a/rx/rx-tests.ts +++ /dev/null @@ -1,90 +0,0 @@ -import * as Rx from 'rx'; - -function test_scan() { - - /* Without a seed */ - const source1: Rx.Observable = Rx.Observable.range(1, 3) - .scan((acc, x, i, source) => acc + x); - - /* With a seed */ - const source2: Rx.Observable = Rx.Observable.range(1, 3) - .scan((acc, x, i, source) => acc + x, '...'); - -} - -function test_concatAll() { - /* concatAll Example */ - var source = Rx.Observable.range(0, 3) - .map(function (x) { return Rx.Observable.range(x, 3); }) - .concatAll(); - - var subscription = source.subscribe( - function (x) { - console.log('Next: %s', x); - }, - function (err) { - console.log('Error: %s', err); - }, - function () { - console.log('Completed'); - }); -} - -function test_mergeAll() { - /* mergeAll example */ - var source = Rx.Observable.range(0, 3) - .map(function (x) { return Rx.Observable.range(x, 3); }) - .mergeAll(); - - var subscription = source.subscribe( - function (x) { - console.log('Next: %s', x); - }, - function (err) { - console.log('Error: %s', err); - }, - function () { - console.log('Completed'); - }); - -} - -// from https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/publish.md -function test_publish() { - var interval = Rx.Observable.interval(1000); - - var source = interval - .take(2) - .doAction(function (x) { - console.log('Side effect'); - }); - - var published = source.publish(); - - published.subscribe(createObserver('SourceA')); - published.subscribe(createObserver('SourceB')); - - var connection = published.connect(); - - function createObserver(tag: string) { - return Rx.Observer.create( - function (x) { - console.log('Next: ' + tag + x); - }, - function (err) { - console.log('Error: ' + err); - }, - function () { - console.log('Completed'); - }); - } - - // => Side effect - // => Next: SourceA0 - // => Next: SourceB0 - // => Side effect - // => Next: SourceA1 - // => Next: SourceB1 - // => Completed - // => Completed -} diff --git a/rx/rx.aggregates.d.ts b/rx/rx.aggregates.d.ts deleted file mode 100644 index 68b2ed50ec..0000000000 --- a/rx/rx.aggregates.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Type definitions for RxJS-Aggregates v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: Carl de Billy , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Rx { - export interface Observable { - finalValue(): Observable; - aggregate(accumulator: (acc: T, value: T) => T): Observable; - aggregate(seed: TAcc, accumulator: (acc: TAcc, value: T) => TAcc): Observable; - - reduce(accumulator: (acc: T, value: T) => T): Observable; - reduce(accumulator: (acc: TAcc, value: T) => TAcc, seed: TAcc): Observable; // TS0.9.5: won't work https://typescript.codeplex.com/discussions/471751 - - any(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - some(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for any - - isEmpty(): Observable; - all(predicate?: (value: T) => boolean, thisArg?: any): Observable; - every(predicate?: (value: T) => boolean, thisArg?: any): Observable; // alias for all - contains(value: T): Observable; - contains(value: TOther, comparer: (value1: T, value2: TOther) => boolean): Observable; - count(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - sum(keySelector?: (value: T, index: number, source: Observable) => number, thisArg?: any): Observable; - minBy(keySelector: (item: T) => TKey, comparer: (value1: TKey, value2: TKey) => number): Observable; - minBy(keySelector: (item: T) => number): Observable; - min(comparer?: (value1: T, value2: T) => number): Observable; - maxBy(keySelector: (item: T) => TKey, comparer: (value1: TKey, value2: TKey) => number): Observable; - maxBy(keySelector: (item: T) => number): Observable; - max(comparer?: (value1: T, value2: T) => number): Observable; - average(keySelector?: (value: T, index: number, source: Observable) => number, thisArg?: any): Observable; - - sequenceEqual(second: Observable, comparer: (value1: T, value2: TOther) => number): Observable; - sequenceEqual(second: IPromise, comparer: (value1: T, value2: TOther) => number): Observable; - sequenceEqual(second: Observable): Observable; - sequenceEqual(second: IPromise): Observable; - sequenceEqual(second: TOther[], comparer: (value1: T, value2: TOther) => number): Observable; - sequenceEqual(second: T[]): Observable; - - elementAt(index: number): Observable; - single(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - first(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - last(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - find(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - findIndex(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - } -} - -declare module "rx.aggregates" { - export = Rx; -} diff --git a/rx/rx.all.d.ts b/rx/rx.all.d.ts deleted file mode 100644 index b10d74053b..0000000000 --- a/rx/rx.all.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Type definitions for RxJS-All v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: Carl de Billy , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// - -declare module "rx.all" { - export = Rx; -} diff --git a/rx/rx.async-lite.d.ts b/rx/rx.async-lite.d.ts deleted file mode 100644 index eb92134341..0000000000 --- a/rx/rx.async-lite.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -// This file contains common part of defintions for rx.async.d.ts and rx.lite.d.ts -// Do not include the file separately. - -/* tslint:disable:forbidden-types */ - -/// - -declare namespace Rx { - export namespace config { - /** - * Configuration option to determine whether to use native events only - */ - export var useNativeEvents: boolean; - } - - interface ObservableStatic { - /** - * Invokes the asynchronous function, surfacing the result through an observable sequence. - * @param functionAsync Asynchronous function which returns a Promise to run. - * @returns An observable sequence exposing the function's result value, or an exception. - */ - startAsync(functionAsync: () => IPromise): Observable; - - fromCallback: { - // with single result callback without selector - (func: (callback: (result: TResult) => any) => any, context?: any): () => Observable; - (func: (arg1: T1, callback: (result: TResult) => any) => any, context?: any): (arg1: T1) => Observable; - (func: (arg1: T1, arg2: T2, callback: (result: TResult) => any) => any, context?: any): (arg1: T1, arg2: T2) => Observable; - (func: (arg1: T1, arg2: T2, arg3: T3, callback: (result: TResult) => any) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; - // with any callback with selector - (func: (callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): () => Observable; - (func: (arg1: T1, callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): (arg1: T1) => Observable; - (func: (arg1: T1, arg2: T2, callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): (arg1: T1, arg2: T2) => Observable; - (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context: any, selector: (args: TCallbackResult[]) => TResult): (arg1: T1, arg2: T2, arg3: T3) => Observable; - // with any callback without selector - (func: (callback: Function) => any, context?: any): () => Observable; - (func: (arg1: T1, callback: Function) => any, context?: any): (arg1: T1) => Observable; - (func: (arg1: T1, arg2: T2, callback: Function) => any, context?: any): (arg1: T1, arg2: T2) => Observable; - (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; - // with any function with selector - (func: Function, context: any, selector: (args: TCallbackResult[]) => TResult): (...args: any[]) => Observable; - // with any function without selector - (func: Function, context?: any): (...args: any[]) => Observable; - }; - - fromNodeCallback: { - // with single result callback without selector - (func: (callback: (err: any, result: T) => any) => any, context?: any): () => Observable; - (func: (arg1: T1, callback: (err: any, result: T) => any) => any, context?: any): (arg1: T1) => Observable; - (func: (arg1: T1, arg2: T2, callback: (err: any, result: T) => any) => any, context?: any): (arg1: T1, arg2: T2) => Observable; - (func: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: T) => any) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; - // with any callback with selector - (func: (callback: Function) => any, context: any, selector: (results: TC[]) => TR): () => Observable; - (func: (arg1: T1, callback: Function) => any, context: any, selector: (results: TC[]) => TR): (arg1: T1) => Observable; - (func: (arg1: T1, arg2: T2, callback: Function) => any, context: any, selector: (results: TC[]) => TR): (arg1: T1, arg2: T2) => Observable; - (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context: any, selector: (results: TC[]) => TR): (arg1: T1, arg2: T2, arg3: T3) => Observable; - // with any callback without selector - (func: (callback: Function) => any, context?: any): () => Observable; - (func: (arg1: T1, callback: Function) => any, context?: any): (arg1: T1) => Observable; - (func: (arg1: T1, arg2: T2, callback: Function) => any, context?: any): (arg1: T1, arg2: T2) => Observable; - (func: (arg1: T1, arg2: T2, arg3: T3, callback: Function) => any, context?: any): (arg1: T1, arg2: T2, arg3: T3) => Observable; - // with any function with selector - (func: Function, context: any, selector: (results: TC[]) => T): (...args: any[]) => Observable; - // with any function without selector - (func: Function, context?: any): (...args: any[]) => Observable; - }; - - fromEvent(element: NodeList, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEvent(element: Node, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEvent(element: {on: (name: string, cb: (e: any) => any) => void; off: (name: string, cb: (e: any) => any) => void}, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[]) => T): Observable; - } -} diff --git a/rx/rx.async-tests.ts b/rx/rx.async-tests.ts deleted file mode 100644 index 0a3ee573fc..0000000000 --- a/rx/rx.async-tests.ts +++ /dev/null @@ -1,82 +0,0 @@ -// Tests for RxJS-Async TypeScript definitions -// Tests by Igor Oleinikov - -namespace Rx.Tests.Async { - - var obsNum: Rx.Observable; - var obsStr: Rx.Observable; - var sch: Rx.IScheduler; - - function start() { - obsNum = Rx.Observable.start(()=> 10, obsStr, sch); - obsNum = Rx.Observable.start(() => 10, obsStr); - obsNum = Rx.Observable.start(()=> 10); - } - - function toAsync() { - obsNum = Rx.Observable.toAsync(()=> 1, sch)(); - obsNum = Rx.Observable.toAsync((a1: number)=> a1)(1); - obsStr = Rx.Observable.toAsync((a1: string, a2: number)=> a1 + a2.toFixed(0))("", 1); - obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date)=> a1 + a2.toFixed(0) + a3.toDateString())("", 1, new Date()); - obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date, a4: boolean)=> a1 + a2.toFixed(0) + a3.toDateString() + (a4 ? 1 : 0))("", 1, new Date(), false); - } - - function fromCallback() { - // 0 arguments - var func0: (cb: (result: number)=> void)=> void; - obsNum = Rx.Observable.fromCallback(func0)(); - obsNum = Rx.Observable.fromCallback(func0, obsStr)(); - obsNum = Rx.Observable.fromCallback(func0, obsStr, (results: number[]) => results[0])(); - - // 1 argument - var func1: (a: string, cb: (result: number)=> void)=> number; - obsNum = Rx.Observable.fromCallback(func1)(""); - obsNum = Rx.Observable.fromCallback(func1, {})(""); - obsNum = Rx.Observable.fromCallback(func1, {}, (results: number[]) => results[0])(""); - - // 2 arguments - var func2: (a: number, b: string, cb: (result: string) => number) => Date; - obsStr = Rx.Observable.fromCallback(func2)(1, ""); - obsStr = Rx.Observable.fromCallback(func2, {})(1, ""); - obsStr = Rx.Observable.fromCallback(func2, {}, (results: string[]) => results[0])(1, ""); - - // 3 arguments - var func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date; - obsStr = Rx.Observable.fromCallback(func3)(1, "", true); - obsStr = Rx.Observable.fromCallback(func3, {})(1, "", true); - obsStr = Rx.Observable.fromCallback(func3, {}, (results: string[]) => results[0])(1, "", true); - - // multiple results - var func0m: (cb: (result1: number, result2: number, result3: number) => void) => void; - obsNum = Rx.Observable.fromCallback(func0m, obsStr, (results: number[]) => results[0])(); - var func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void; - obsNum = Rx.Observable.fromCallback(func1m, obsStr, (results: number[]) => results[0])(""); - var func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void; - obsStr = Rx.Observable.fromCallback(func2m, obsStr, (results: string[]) => results[0])("", 10); - } - - function toPromise() { - var promiseImpl: { - new(resolver: (resolvePromise: (value: T)=> void, rejectPromise: (reason: any)=> void)=> void): Rx.IPromise; - }; - - Rx.config.Promise = promiseImpl; - - var p: IPromise = obsNum.toPromise(promiseImpl); - - p = obsNum.toPromise(); - - p = p.then(x=> x); - p = p.then(x=> p); - p = p.then(undefined, reason=> 10); - p = p.then(undefined, reason=> p); - - var ps: IPromise = p.then(undefined, reason=> "error"); - ps = p.then(x=> ""); - ps = p.then(x=> ps); - } - - function startAsync() { - var o: Rx.Observable = Rx.Observable.startAsync(() => >null); - } -} diff --git a/rx/rx.async.d.ts b/rx/rx.async.d.ts deleted file mode 100644 index 582e94c723..0000000000 --- a/rx/rx.async.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Type definitions for RxJS-Async v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: zoetrope , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Rx { - interface ObservableStatic { - start(func: () => T, context?: any, scheduler?: IScheduler): Observable; - - toAsync(func: () => TResult, context?: any, scheduler?: IScheduler): () => Observable; - toAsync(func: (arg1: T1) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1) => Observable; - toAsync(func: (arg1?: T1) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1) => Observable; - toAsync(func: (...args: T1[]) => TResult, context?: any, scheduler?: IScheduler): (...args: T1[]) => Observable; - toAsync(func: (arg1: T1, arg2: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2) => Observable; - toAsync(func: (arg1: T1, arg2?: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2) => Observable; - toAsync(func: (arg1?: T1, arg2?: T2) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2) => Observable; - toAsync(func: (arg1: T1, ...args: T2[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, ...args: T2[]) => Observable; - toAsync(func: (arg1?: T1, ...args: T2[]) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, ...args: T2[]) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3?: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3?: T3) => Observable; - toAsync(func: (arg1: T1, arg2?: T2, arg3?: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, arg3?: T3) => Observable; - toAsync(func: (arg1?: T1, arg2?: T2, arg3?: T3) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, arg3?: T3) => Observable; - toAsync(func: (arg1: T1, arg2: T2, ...args: T3[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, ...args: T3[]) => Observable; - toAsync(func: (arg1: T1, arg2?: T2, ...args: T3[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, ...args: T3[]) => Observable; - toAsync(func: (arg1?: T1, arg2?: T2, ...args: T3[]) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, ...args: T3[]) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, arg4?: T4) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3?: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3?: T3, arg4?: T4) => Observable; - toAsync(func: (arg1: T1, arg2?: T2, arg3?: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, arg3?: T3, arg4?: T4) => Observable; - toAsync(func: (arg1?: T1, arg2?: T2, arg3?: T3, arg4?: T4) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, arg3?: T3, arg4?: T4) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3: T3, ...args: T4[]) => Observable; - toAsync(func: (arg1: T1, arg2: T2, arg3?: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2: T2, arg3?: T3, ...args: T4[]) => Observable; - toAsync(func: (arg1: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => Observable; - toAsync(func: (arg1?: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => TResult, context?: any, scheduler?: IScheduler): (arg1?: T1, arg2?: T2, arg3?: T3, ...args: T4[]) => Observable; - } -} - -declare module "rx.async" { - export = Rx; -} diff --git a/rx/rx.backpressure-lite.d.ts b/rx/rx.backpressure-lite.d.ts deleted file mode 100644 index 40563ba134..0000000000 --- a/rx/rx.backpressure-lite.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file contains common part of defintions for rx.backpressure.d.ts and rx.lite.d.ts -// Do not include the file separately. - -/// - -declare namespace Rx { - export interface Observable { - /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausable(pauser); - * @param pauser The observable sequence used to pause the underlying sequence. - * @returns The observable sequence which is paused based upon the pauser. - */ - pausable(pauser?: Observable): PausableObservable; - - /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, - * and yields the values that were buffered while paused. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausableBuffered(pauser); - * @param pauser The observable sequence used to pause the underlying sequence. - * @returns The observable sequence which is paused based upon the pauser. - */ - pausableBuffered(pauser?: Observable): PausableObservable; - - /** - * Attaches a controller to the observable sequence with the ability to queue. - * @example - * var source = Rx.Observable.interval(100).controlled(); - * source.request(3); // Reads 3 values - */ - controlled(enableQueue?: boolean): ControlledObservable; - } - - export interface ControlledObservable extends Observable { - request(numberOfItems?: number): IDisposable; - } - - export interface PausableObservable extends Observable { - pause(): void; - resume(): void; - } -} diff --git a/rx/rx.backpressure.d.ts b/rx/rx.backpressure.d.ts deleted file mode 100644 index 71f38354e2..0000000000 --- a/rx/rx.backpressure.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Type definitions for RxJS-BackPressure v2.3.12 -// Project: http://rx.codeplex.com/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare module "rx.backpressure" { - export = Rx; -} diff --git a/rx/rx.binding-lite.d.ts b/rx/rx.binding-lite.d.ts deleted file mode 100644 index a877e56ad3..0000000000 --- a/rx/rx.binding-lite.d.ts +++ /dev/null @@ -1,71 +0,0 @@ -// This file contains common part of defintions for rx.binding.d.ts and rx.lite.d.ts -// Do not include the file separately. - -/// - -declare namespace Rx { - export interface BehaviorSubject extends Subject { - getValue(): T; - } - - interface BehaviorSubjectStatic { - new (initialValue: T): BehaviorSubject; - } - - export var BehaviorSubject: BehaviorSubjectStatic; - - export interface ReplaySubject extends Subject { - } - - interface ReplaySubjectStatic { - new (bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject; - } - - export var ReplaySubject: ReplaySubjectStatic; - - interface ConnectableObservable extends Observable { - connect(): IDisposable; - refCount(): Observable; - } - - interface ConnectableObservableStatic { - new (): ConnectableObservable; - } - - export var ConnectableObservable: ConnectableObservableStatic; - - export interface Observable { - multicast(subject: Observable): ConnectableObservable; - multicast(subjectSelector: () => ISubject, selector: (source: ConnectableObservable) => Observable): Observable; - publish(): ConnectableObservable; - publish(selector: (source: ConnectableObservable) => Observable): Observable; - /** - * Returns an observable sequence that shares a single subscription to the underlying sequence. - * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - * - * @example - * var res = source.share(); - * - * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. - */ - share(): Observable; - publishLast(): ConnectableObservable; - publishLast(selector: (source: ConnectableObservable) => Observable): Observable; - publishValue(initialValue: T): ConnectableObservable; - publishValue(selector: (source: ConnectableObservable) => Observable, initialValue: T): Observable; - /** - * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue. - * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - * - * @example - * var res = source.shareValue(42); - * - * @param initialValue Initial value received by observers upon subscription. - * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. - */ - shareValue(initialValue: T): Observable; - replay(selector?: boolean, bufferSize?: number, window?: number, scheduler?: IScheduler): ConnectableObservable; // hack to catch first omitted parameter - replay(selector: (source: ConnectableObservable) => Observable, bufferSize?: number, window?: number, scheduler?: IScheduler): Observable; - shareReplay(bufferSize?: number, window?: number, scheduler?: IScheduler): Observable; - } -} diff --git a/rx/rx.binding.d.ts b/rx/rx.binding.d.ts deleted file mode 100644 index 5dab889ca1..0000000000 --- a/rx/rx.binding.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Type definitions for RxJS-Binding v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: Carl de Billy , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare module "rx.binding" { - export = Rx; -} diff --git a/rx/rx.coincidence-lite.d.ts b/rx/rx.coincidence-lite.d.ts deleted file mode 100644 index 824b561829..0000000000 --- a/rx/rx.coincidence-lite.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file contains common part of defintions for rx.time.d.ts and rx.lite.d.ts -// Do not include the file separately. - -/// - -declare namespace Rx { - - interface Observable { - /** - * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. - * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. - * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. - * @returns An observable that triggers on successive pairs of observations from the input observable as an array. - */ - pairwise(): Observable; - - /** - * Returns two observables which partition the observations of the source by the given function. - * The first will trigger observations for those values for which the predicate returns true. - * The second will trigger observations for those values where the predicate returns false. - * The predicate is executed once for each subscribed observer. - * Both also propagate all error observations arising from the source and each completes - * when the source completes. - * @param predicate - * The function to determine which output Observable will trigger a particular observation. - * @returns - * An array of observables. The first triggers when the predicate returns true, - * and the second triggers when the predicate returns false. - */ - partition(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable[]; - } -} diff --git a/rx/rx.coincidence.d.ts b/rx/rx.coincidence.d.ts deleted file mode 100644 index a39f224367..0000000000 --- a/rx/rx.coincidence.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Type definitions for RxJS-Coincidence v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: Carl de Billy , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Rx { - - interface Observable { - join( - right: Observable, - leftDurationSelector: (leftItem: T) => Observable, - rightDurationSelector: (rightItem: TRight) => Observable, - resultSelector: (leftItem: T, rightItem: TRight) => TResult): Observable; - - groupJoin( - right: Observable, - leftDurationSelector: (leftItem: T) => Observable, - rightDurationSelector: (rightItem: TRight) => Observable, - resultSelector: (leftItem: T, rightItem: Observable) => TResult): Observable; - - window(windowOpenings: Observable): Observable>; - window(windowClosingSelector: () => Observable): Observable>; - window(windowOpenings: Observable, windowClosingSelector: () => Observable): Observable>; - - buffer(bufferOpenings: Observable): Observable; - buffer(bufferClosingSelector: () => Observable): Observable; - buffer(bufferOpenings: Observable, bufferClosingSelector: () => Observable): Observable; - } -} - -declare module "rx.coincidence" { - export = Rx; -} diff --git a/rx/rx.experimental.d.ts b/rx/rx.experimental.d.ts deleted file mode 100644 index 3f4dd40752..0000000000 --- a/rx/rx.experimental.d.ts +++ /dev/null @@ -1,321 +0,0 @@ -// Type definitions for RxJS-Experimental v2.2.28 -// Project: https://github.com/Reactive-Extensions/RxJS/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Rx { - - interface Observable { - /** - * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. - * This operator allows for a fluent style of writing queries that use the same sequence multiple times. - * - * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. - * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. - */ - let(selector: (source: Observable) => Observable): Observable; - - /** - * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. - * This operator allows for a fluent style of writing queries that use the same sequence multiple times. - * - * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. - * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. - */ - letBind(selector: (source: Observable) => Observable): Observable; - - /** - * Repeats source as long as condition holds emulating a do while loop. - * @param condition The condition which determines if the source will be repeated. - * @returns An observable sequence which is repeated as long as the condition holds. - */ - doWhile(condition: () => boolean): Observable; - - /** - * Expands an observable sequence by recursively invoking selector. - * - * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. - * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. - * @returns An observable sequence containing all the elements produced by the recursive expansion. - */ - expand(selector: (item: T) => Observable, scheduler?: IScheduler): Observable; - - /** - * Runs two observable sequences in parallel and combines their last elemenets. - * - * @param second Second observable sequence or promise. - * @param resultSelector Result selector function to invoke with the last elements of both sequences. - * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences. - */ - forkJoin(second: Observable, resultSelector: (left: T, right: TSecond) => TResult): Observable; - forkJoin(second: IPromise, resultSelector: (left: T, right: TSecond) => TResult): Observable; - - /** - * Comonadic bind operator. - * @param selector A transform function to apply to each element. - * @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. - * @returns An observable sequence which results from the comonadic bind operation. - */ - manySelect(selector: (item: Observable, index: number, source: Observable) => TResult, scheduler?: IScheduler): Observable; - } - - interface ObservableStatic { - /** - * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, elseSource: Observable): Observable; - if(condition: () => boolean, thenSource: Observable, elseSource: IPromise): Observable; - if(condition: () => boolean, thenSource: IPromise, elseSource: Observable): Observable; - if(condition: () => boolean, thenSource: IPromise, elseSource: IPromise): Observable; - - /** - * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, scheduler?: IScheduler): Observable; - if(condition: () => boolean, thenSource: IPromise, scheduler?: IScheduler): Observable; - - /** - * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, elseSource: Observable): Observable; - ifThen(condition: () => boolean, thenSource: Observable, elseSource: IPromise): Observable; - ifThen(condition: () => boolean, thenSource: IPromise, elseSource: Observable): Observable; - ifThen(condition: () => boolean, thenSource: IPromise, elseSource: IPromise): Observable; - - /** - * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, scheduler?: IScheduler): Observable; - ifThen(condition: () => boolean, thenSource: IPromise, scheduler?: IScheduler): Observable; - - /** - * Concatenates the observable sequences obtained by running the specified result selector for each element in source. - * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => Observable): Observable; - - /** - * Concatenates the observable sequences obtained by running the specified result selector for each element in source. - * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => Observable): Observable; - - /** - * Repeats source as long as condition holds emulating a while loop. - * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; - while(condition: () => boolean, source: IPromise): Observable; - - /** - * Repeats source as long as condition holds emulating a while loop. - * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; - whileDo(condition: () => boolean, source: IPromise): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; - case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; - case(selector: () => string, sources: { [key: string]: Observable; }, elseSource: IPromise): Observable; - case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: IPromise): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; - case(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; - case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; - case(selector: () => number, sources: { [key: number]: Observable; }, elseSource: IPromise): Observable; - case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: IPromise): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; - case(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; - switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; - switchCase(selector: () => string, sources: { [key: string]: Observable; }, elseSource: IPromise): Observable; - switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: IPromise): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; - switchCase(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; - switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; - switchCase(selector: () => number, sources: { [key: number]: Observable; }, elseSource: IPromise): Observable; - switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: IPromise): Observable; - - /** - * Uses selector to determine which source in sources to use. - * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; - switchCase(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; - - /** - * Runs all observable sequences in parallel and collect their last elements. - * - * @example - * res = Rx.Observable.forkJoin([obs1, obs2]); - * @param sources Array of source sequences or promises. - * @returns An observable sequence with an array collecting the last elements of all the input sequences. - */ - forkJoin(sources: Observable[]): Observable; - forkJoin(sources: IPromise[]): Observable; - - /** - * Runs all observable sequences in parallel and collect their last elements. - * - * @example - * res = Rx.Observable.forkJoin(obs1, obs2, ...); - * @param args Source sequences or promises. - * @returns An observable sequence with an array collecting the last elements of all the input sequences. - */ - forkJoin(...args: Observable[]): Observable; - forkJoin(...args: IPromise[]): Observable; - } -} - -declare module "rx.experimental" { - export = Rx; -} diff --git a/rx/rx.joinpatterns.d.ts b/rx/rx.joinpatterns.d.ts deleted file mode 100644 index 49080f7058..0000000000 --- a/rx/rx.joinpatterns.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -// Type definitions for RxJS-Join v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Rx { - - interface Pattern1 { - and(other: Observable): Pattern2; - thenDo(selector: (item1: T1) => TR): Plan; - } - interface Pattern2 { - and(other: Observable): Pattern3; - thenDo(selector: (item1: T1, item2: T2) => TR): Plan; - } - interface Pattern3 { - and(other: Observable): Pattern4; - thenDo(selector: (item1: T1, item2: T2, item3: T3) => TR): Plan; - } - interface Pattern4 { - and(other: Observable): Pattern5; - thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4) => TR): Plan; - } - interface Pattern5 { - and(other: Observable): Pattern6; - thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TR): Plan; - } - interface Pattern6 { - and(other: Observable): Pattern7; - thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6) => TR): Plan; - } - interface Pattern7 { - and(other: Observable): Pattern8; - thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7) => TR): Plan; - } - interface Pattern8 { - and(other: Observable): Pattern9; - thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8) => TR): Plan; - } - interface Pattern9 { - thenDo(selector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5, item6: T6, item7: T7, item8: T8, item9: T9) => TR): Plan; - } - - interface Plan { } - - interface Observable { - and(other: Observable): Pattern2; - thenDo(selector: (item1: T) => TR): Plan; - } - - interface ObservableStatic { - when(plan: Plan): Observable; - } -} - -declare module "rx.joinpatterns" { - export = Rx; -} diff --git a/rx/rx.lite.d.ts b/rx/rx.lite.d.ts deleted file mode 100644 index 69348a19a7..0000000000 --- a/rx/rx.lite.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Type definitions for RxJS-Lite v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: gsino , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// -/// - -declare module "rx-lite" { - export = Rx; -} diff --git a/rx/rx.testing.d.ts b/rx/rx.testing.d.ts deleted file mode 100644 index 2415e3fe30..0000000000 --- a/rx/rx.testing.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Type definitions for RxJS-Testing v2.2.28 -// Project: https://github.com/Reactive-Extensions/RxJS/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Rx { - export interface TestScheduler extends VirtualTimeScheduler { - createColdObservable(...records: Recorded[]): Observable; - createHotObservable(...records: Recorded[]): Observable; - createObserver(): MockObserver; - - startWithTiming(create: () => Observable, createdAt: number, subscribedAt: number, disposedAt: number): MockObserver; - startWithDispose(create: () => Observable, disposedAt: number): MockObserver; - startWithCreate(create: () => Observable): MockObserver; - } - - export var TestScheduler: { - new (): TestScheduler; - }; - - export class Recorded { - constructor(time: number, value: any, equalityComparer?: (x: any, y: any) => boolean); - equals(other: Recorded): boolean; - toString(): string; - time: number; - value: any; - } - - export var ReactiveTest: { - created: number; - subscribed: number; - disposed: number; - - onNext(ticks: number, value: any): Recorded; - onNext(ticks: number, predicate: (value: any) => boolean): Recorded; - onError(ticks: number, exception: any): Recorded; - onError(ticks: number, predicate: (exception: any) => boolean): Recorded; - onCompleted(ticks: number): Recorded; - - subscribe(subscribeAt: number, unsubscribeAt?: number): Subscription; - }; - - export class Subscription { - constructor(subscribeAt: number, unsubscribeAt?: number); - equals(other: Subscription): boolean; - } - - export interface MockObserver extends Observer { - messages: Recorded[]; - } - - interface MockObserverStatic extends ObserverStatic { - new (scheduler: IScheduler): MockObserver; - } - - export var MockObserver: MockObserverStatic; -} - -declare module "rx.testing" { - export = Rx; -} diff --git a/rx/rx.time-lite.d.ts b/rx/rx.time-lite.d.ts deleted file mode 100644 index 07ff338942..0000000000 --- a/rx/rx.time-lite.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file contains common part of defintions for rx.time.d.ts and rx.lite.d.ts -// Do not include the file separately. - -/// - -declare namespace Rx { - export interface TimeInterval { - value: T; - interval: number; - } - - export interface Timestamp { - value: T; - timestamp: number; - } - - export interface Observable { - delay(dueTime: Date, scheduler?: IScheduler): Observable; - delay(dueTime: number, scheduler?: IScheduler): Observable; - - debounce(dueTime: number, scheduler?: IScheduler): Observable; - throttleWithTimeout(dueTime: number, scheduler?: IScheduler): Observable; - /** - * @deprecated use #debounce or #throttleWithTimeout instead. - */ - throttle(dueTime: number, scheduler?: IScheduler): Observable; - - timeInterval(scheduler?: IScheduler): Observable>; - - timestamp(scheduler?: IScheduler): Observable>; - - sample(interval: number, scheduler?: IScheduler): Observable; - sample(sampler: Observable, scheduler?: IScheduler): Observable; - - timeout(dueTime: Date, other?: Observable, scheduler?: IScheduler): Observable; - timeout(dueTime: number, other?: Observable, scheduler?: IScheduler): Observable; - } - - interface ObservableStatic { - interval(period: number, scheduler?: IScheduler): Observable; - interval(dutTime: number, period: number, scheduler?: IScheduler): Observable; - timer(dueTime: number, period: number, scheduler?: IScheduler): Observable; - timer(dueTime: number, scheduler?: IScheduler): Observable; - } -} diff --git a/rx/rx.time.d.ts b/rx/rx.time.d.ts deleted file mode 100644 index 84f23b0cfe..0000000000 --- a/rx/rx.time.d.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Type definitions for RxJS-Time v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: Carl de Billy , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Rx { - export interface Observable { - delaySubscription(dueTime: number, scheduler?: IScheduler): Observable; - delayWithSelector(delayDurationSelector: (item: T) => number): Observable; - delayWithSelector(subscriptionDelay: number, delayDurationSelector: (item: T) => number): Observable; - - timeoutWithSelector(firstTimeout: Observable, timeoutdurationSelector?: (item: T) => Observable, other?: Observable): Observable; - - debounceWithSelector(debounceDurationSelector: (item: T) => Observable): Observable; - /** - * @deprecated use #debounceWithSelector instead. - */ - throttleWithSelector(debounceDurationSelector: (item: T) => Observable): Observable; - - skipLastWithTime(duration: number, scheduler?: IScheduler): Observable; - takeLastWithTime(duration: number, timerScheduler?: IScheduler, loopScheduler?: IScheduler): Observable; - - takeLastBufferWithTime(duration: number, scheduler?: IScheduler): Observable; - takeWithTime(duration: number, scheduler?: IScheduler): Observable; - skipWithTime(duration: number, scheduler?: IScheduler): Observable; - - skipUntilWithTime(startTime: Date, scheduler?: IScheduler): Observable; - skipUntilWithTime(duration: number, scheduler?: IScheduler): Observable; - takeUntilWithTime(endTime: Date, scheduler?: IScheduler): Observable; - takeUntilWithTime(duration: number, scheduler?: IScheduler): Observable; - - windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable>; - windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable>; - windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable>; - bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; - bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable; - bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; - } - - interface ObservableStatic { - timer(dueTime: Date, period: number, scheduler?: IScheduler): Observable; - timer(dueTime: Date, scheduler?: IScheduler): Observable; - - generateWithRelativeTime( - initialState: TState, - condition: (state: TState) => boolean, - iterate: (state: TState) => TState, - resultSelector: (state: TState) => TResult, - timeSelector: (state: TState) => number, - scheduler?: IScheduler): Observable; - generateWithAbsoluteTime( - initialState: TState, - condition: (state: TState) => boolean, - iterate: (state: TState) => TState, - resultSelector: (state: TState) => TResult, - timeSelector: (state: TState) => Date, - scheduler?: IScheduler): Observable; - } -} - -declare module "rx.time" { - export = Rx; -} diff --git a/rx/rx.virtualtime.d.ts b/rx/rx.virtualtime.d.ts deleted file mode 100644 index 908eeebb6d..0000000000 --- a/rx/rx.virtualtime.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Type definitions for RxJS-VirtualTime v2.2.28 -// Project: http://rx.codeplex.com/ -// Definitions by: gsino , Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Rx { - export interface VirtualTimeScheduler extends Scheduler { - //protected constructor(initialClock: TAbsolute, comparer: (first: TAbsolute, second: TAbsolute) => number); - - advanceBy(time: TRelative): void; - advanceTo(time: TAbsolute): void; - scheduleAbsolute(dueTime: TAbsolute, action: () => void): IDisposable; - scheduleAbsoluteWithState(state: TState, dueTime: TAbsolute, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; - scheduleRelative(dueTime: TRelative, action: () => void): IDisposable; - scheduleRelativeWithState(state: TState, dueTime: TRelative, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; - sleep(time: TRelative): void; - start(): IDisposable; - stop(): void; - - isEnabled: boolean; - - /* protected abstract */ add(from: TAbsolute, by: TRelative): TAbsolute; - /* protected abstract */ toDateTimeOffset(duetime: TAbsolute): number; - /* protected abstract */ toRelative(duetime: number): TRelative; - - /* protected */ getNext(): internals.ScheduledItem; - } - - export interface HistoricalScheduler extends VirtualTimeScheduler { - } - - export var HistoricalScheduler: { - new (initialClock: number, comparer: (first: number, second: number) => number): HistoricalScheduler; - }; -} - -declare module "rx.virtualtime" { - export = Rx; -} diff --git a/rx/tsconfig.json b/rx/tsconfig.json index 8e6b3c2523..87eb6217d4 100644 --- a/rx/tsconfig.json +++ b/rx/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -14,27 +14,6 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "rx-tests.ts", - "rx-lite.d.ts", - "rx.aggregates.d.ts", - "rx.all.d.ts", - "rx.async-lite.d.ts", - "rx.async-tests.ts", - "rx.async.d.ts", - "rx.backpressure-lite.d.ts", - "rx.backpressure-tests.ts", - "rx.backpressure.d.ts", - "rx.binding-lite.d.ts", - "rx.binding.d.ts", - "rx.coincidence-lite.d.ts", - "rx.coincidence.d.ts", - "rx.experimental.d.ts", - "rx.joinpatterns.d.ts", - "rx.lite.d.ts", - "rx.testing.d.ts", - "rx.time-lite.d.ts", - "rx.time.d.ts", - "rx.virtualtime.d.ts" + "index.d.ts" ] } diff --git a/rx/tslint.json b/rx/tslint.json index ece70de3a1..cfdf2986e5 100644 --- a/rx/tslint.json +++ b/rx/tslint.json @@ -1,13 +1,6 @@ { "extends": "../tslint.json", "rules": { - "array-type": [ - false - ], - "dt-header": false, - "interface-name": false, - "no-empty-interface": false, - "unified-signatures": false, "no-single-declare-module": false } } From 7c6e2e4521f362dc00634a8242cf615ba53c6f37 Mon Sep 17 00:00:00 2001 From: KostiaTretiak Date: Wed, 4 Jan 2017 02:03:07 +0200 Subject: [PATCH 073/181] Fixed declarations for 'assert-plus'. --- assert-plus/index.d.ts | 90 +++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/assert-plus/index.d.ts b/assert-plus/index.d.ts index 920419ba60..2bbcb428de 100644 --- a/assert-plus/index.d.ts +++ b/assert-plus/index.d.ts @@ -10,137 +10,137 @@ import {Stream} from 'stream'; /** * */ -export function array(options: any[], message ?: string): void; +export function array(arr: any[], message ?: string): void; /** * */ -export function bool(options: boolean, message ?: string): void; +export function bool(bool: boolean, message ?: string): void; /** * */ -export function buffer(options: Buffer, message ?: string): void; +export function buffer(buffer: Buffer, message ?: string): void; /** * */ -export function func(options: any, message ?: string): void; +export function func(func: any, message ?: string): void; /** * */ -export function number(options: number, message ?: string): void; +export function number(number: number, message ?: string): void; /** * */ -export function finite(options: number, message ?: string): void; +export function finite(finite: number, message ?: string): void; /** * */ -export function object(options: any, message ?: string): void; +export function object(obj: any, message ?: string): void; /** * */ -export function string(options: string, message ?: string): void; +export function string(str: string, message ?: string): void; /** * */ -export function stream(options: Stream, message ?: string): void; +export function stream(stream: Stream, message ?: string): void; /** * */ -export function date(options: Date, message ?: string): void; +export function date(date: Date, message ?: string): void; /** * */ -export function regexp(options: RegExp, message ?: string): void; +export function regexp(regexp: RegExp, message ?: string): void; /** * */ -export function uuid(options: string, message ?: string): void; +export function uuid(uuid: string, message ?: string): void; /** * */ -export function arrayOfArray(options: any[][], message ?: string): void; +export function arrayOfArray(arr: any[][], message ?: string): void; /** * */ -export function arrayOfBool(options: boolean[], message ?: string): void; +export function arrayOfBool(arr: boolean[], message ?: string): void; /** * */ -export function arrayOfBuffer(options: Buffer[], message ?: string): void; +export function arrayOfBuffer(arr: Buffer[], message ?: string): void; /** * */ -export function arrayOfFunc(options: any[], message ?: string): void; +export function arrayOfFunc(arr: any[], message ?: string): void; /** * */ -export function arrayOfNumber(options: number[], message ?: string): void; +export function arrayOfNumber(arr: number[], message ?: string): void; /** * */ -export function arrayOfFinite(options: number[], message ?: string): void; +export function arrayOfFinite(arr: number[], message ?: string): void; /** * */ -export function arrayOfObject(options: any[], message ?: string): void; +export function arrayOfObject(arr: any[], message ?: string): void; /** * */ -export function arrayOfString(options: string[], message ?: string): void; +export function arrayOfString(arr: string[], message ?: string): void; /** * */ -export function arrayOfStream(options: Stream[], message ?: string): void; +export function arrayOfStream(arr: Stream[], message ?: string): void; /** * */ -export function arrayOfDate(options: Date[], message ?: string): void; +export function arrayOfDate(arr: Date[], message ?: string): void; /** * */ -export function arrayOfRegexp(options: RegExp[], message ?: string): void; +export function arrayOfRegexp(arr: RegExp[], message ?: string): void; /** * */ -export function arrayOfUuid(options: string[], message ?: string): void; +export function arrayOfUuid(arr: string[], message ?: string): void; /** * */ -export function optionalArray(options ?: any[], message ?: string): void; +export function optionalArray(arr ?: any[], message ?: string): void; /** * */ -export function optionalBool(options ?: boolean, message ?: string): void; +export function optionalBool(bool ?: boolean, message ?: string): void; /** * */ -export function optionalBuffer(options ?: Buffer, message ?: string): void; +export function optionalBuffer(buffer ?: Buffer, message ?: string): void; /** * @@ -190,62 +190,62 @@ export function optionalUuid(options ?: string, message ?: string): void; /** * */ -export function optionalArrayOfArray(options ?: any[][], message ?: string): void; +export function optionalArrayOfArray(arr ?: any[][], message ?: string): void; /** * */ -export function optionalArrayOfBool(options ?: boolean[], message ?: string): void; +export function optionalArrayOfBool(arr ?: boolean[], message ?: string): void; /** * */ -export function optionalArrayOfBuffer(options ?: Buffer[], message ?: string): void; +export function optionalArrayOfBuffer(arr ?: Buffer[], message ?: string): void; /** * */ -export function optionalArrayOfFunc(options ?: any[], message ?: string): void; +export function optionalArrayOfFunc(arr ?: any[], message ?: string): void; /** * */ -export function optionalArrayOfNumber(options ?: number[], message ?: string): void; +export function optionalArrayOfNumber(arr ?: number[], message ?: string): void; /** * */ -export function optionalArrayOfFinite(options ?: number[], message ?: string): void; +export function optionalArrayOfFinite(arr ?: number[], message ?: string): void; /** * */ -export function optionalArrayOfObject(options ?: any[], message ?: string): void; +export function optionalArrayOfObject(arr ?: any[], message ?: string): void; /** * */ -export function optionalArrayOfString(options ?: string[], message ?: string): void; +export function optionalArrayOfString(arr ?: string[], message ?: string): void; /** * */ -export function optionalArrayOfStream(options ?: Stream[], message ?: string): void; +export function optionalArrayOfStream(arr ?: Stream[], message ?: string): void; /** * */ -export function optionalArrayOfDate(options ?: Date[], message ?: string): void; +export function optionalArrayOfDate(arr ?: Date[], message ?: string): void; /** * */ -export function optionalArrayOfRegexp(options ?: RegExp[], message ?: string): void; +export function optionalArrayOfRegexp(arr ?: RegExp[], message ?: string): void; /** * */ -export function optionalArrayOfUuid(options ?: string[], message ?: string): void; +export function optionalArrayOfUuid(arr ?: string[], message ?: string): void; /** * @@ -316,7 +316,7 @@ export function ok(options: any, message ?: string): void; * a `message` property set equal to the value of the `message` parameter. * If the `message` parameter is undefined, a default error message is assigned. */ -export function equal(actual: any, expected: any, message ?: string): void; +export function equal(actual: T, expected: T, message ?: string): void; /** * Tests shallow, coercive inequality with the not equal comparison operator ( `!=` ). @@ -338,7 +338,7 @@ export function equal(actual: any, expected: any, message ?: string): void; * a `message` property set equal to the value of the `message` parameter. * If the `message` parameter is undefined, a default error message is assigned. */ -export function notEqual(actual: any, expected: any, message ?: string): void; +export function notEqual(actual: T, expected: T, message ?: string): void; /** * Tests for deep equality between the `actual` and `expected` parameters. @@ -361,7 +361,7 @@ export function notEqual(actual: any, expected: any, message ?: string): void; * set equal to the value of the `message` parameter. If the `message` parameter is undefined, * a default error message is assigned. */ -export function deepEqual(actual: any, expected: any, message ?: string): void; +export function deepEqual(actual: T, expected: T, message ?: string): void; /** * Tests for any deep inequality. Opposite of `assert.deepEqual()`. @@ -391,7 +391,7 @@ export function deepEqual(actual: any, expected: any, message ?: string): void; * a `message` property set equal to the value of the `message` parameter. * If the `message` parameter is undefined, a default error message is assigned. */ -export function notDeepEqual(actual: any, expected: any, message ?: string): void; +export function notDeepEqual(actual: T, expected: T, message ?: string): void; /** * Tests strict equality as determined by the strict equality operator ( `===` ). @@ -413,7 +413,7 @@ export function notDeepEqual(actual: any, expected: any, message ?: string): voi * a `message` property set equal to the value of the `message` parameter. * If the `message` parameter is undefined, a default error message is assigned. */ -export function strictEqual(actual: any, expected: any, message ?: string): void; +export function strictEqual(actual: T, expected: T, message ?: string): void; /** * Tests strict inequality as determined by the strict not equal operator ( `!==` ). @@ -435,7 +435,7 @@ export function strictEqual(actual: any, expected: any, message ?: string): void * set equal to the value of the `message` parameter. If the `message` parameter is undefined, * a default error message is assigned. */ -export function notStrictEqual(actual: any, expected: any, message ?: string): void; +export function notStrictEqual(actual: T, expected: T, message ?: string): void; /** * From 24001b96570112bb9acd91f056f02c446fd8e28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Marques?= Date: Wed, 4 Jan 2017 12:28:57 +0000 Subject: [PATCH 074/181] Fix spelling of paragraphGap option --- pdfkit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdfkit/index.d.ts b/pdfkit/index.d.ts index 6d5272875b..630a5bcfcd 100644 --- a/pdfkit/index.d.ts +++ b/pdfkit/index.d.ts @@ -108,7 +108,7 @@ declare namespace PDFKit.Mixins { /** The amount in PDF points (72 per inch) to indent each paragraph of text */ indent?: number; /** the amount of space between each paragraph of text */ - paragrahGap?: number; + paragraphGap?: number; /** the amount of space between each line of text */ lineGap?: number; /** the amount of space between each word in the text */ From d5b790f578c4ea05107c7d9461699aad3d64e02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Marques?= Date: Wed, 4 Jan 2017 12:30:32 +0000 Subject: [PATCH 075/181] Allow document size to be specified as a string (e.g. "a4") --- pdfkit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdfkit/index.d.ts b/pdfkit/index.d.ts index 630a5bcfcd..0666fb67e9 100644 --- a/pdfkit/index.d.ts +++ b/pdfkit/index.d.ts @@ -230,7 +230,7 @@ declare namespace PDFKit { compress?: boolean; info?: DocumentInfo; autoFirstPage?: boolean; - size?: number[]; + size?: number[]|string; margin?: number; margins?: { top: number; left: number; bottom: number; right: number }; layout?: "portrait" | "landscape"; From 2a888886b149dd146814e7a91185267ad37f16cc Mon Sep 17 00:00:00 2001 From: Dolan Date: Wed, 4 Jan 2017 14:25:46 +0000 Subject: [PATCH 076/181] Typings for xml2json (#13711) * typings for xml2json * carried out suggestions made by andy-ms * fixed: 9:1 unified-signatures These overloads can be combined into one signature taking `{} | string`. --- xml2json/index.d.ts | 70 ++++++++++++++++++++++++++++++++++++++ xml2json/tsconfig.json | 20 +++++++++++ xml2json/tslint.json | 1 + xml2json/xml2json-tests.ts | 24 +++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 xml2json/index.d.ts create mode 100644 xml2json/tsconfig.json create mode 100644 xml2json/tslint.json create mode 100644 xml2json/xml2json-tests.ts diff --git a/xml2json/index.d.ts b/xml2json/index.d.ts new file mode 100644 index 0000000000..380174a270 --- /dev/null +++ b/xml2json/index.d.ts @@ -0,0 +1,70 @@ +// Type definitions for xml2json 0.10 +// Project: https://github.com/buglabs/node-xml2json +// Definitions by: Dolan Miu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export function toJson(xml: string, options?: { object?: false } & JsonOptions): string; +export function toJson(xml: string, options?: { object: true } & JsonOptions): {}; + +export function toXml(json: {} | string, options?: XmlOptions): string; + +export interface XmlOptions { + /** + * Sanitizes the following characters present in element values (default false): + * @example + * var chars = { + * '<': '<', + * '>': '>', + * '(': '(', + * ')': ')', + * '#': '#', + * '&': '&', + * '"': '"', + * "'": ''' + * }; + * @example + */ + sanitize?: boolean; +} + +export interface JsonOptions { + /** + * Returns a Javascript object instead of a JSON string. + */ + // object?: boolean; // This is now overloaded in the toJson method + /** + * Makes the JSON reversible to XML. + * xml2json tranforms CDATA content to JSON, but it doesn't generate a reversible structure. + */ + reversible?: boolean; + /** + * Makes type coercion. + * i.e.: numbers and booleans present in attributes and element values are converted from string to its correspondent data types. + * Coerce can be optionally defined as an object with specific methods of coercion based on attribute name or tag name, with fallback to default coercion. + */ + coerce?: boolean; + /** + * Sanitizes the following characters present in element values (default true): + * @example + * var chars = { + * '<': '<', + * '>': '>', + * '(': '(', + * ')': ')', + * '#': '#', + * '&': '&', + * '"': '"', + * "'": ''' + * }; + * @example + */ + sanitize?: boolean; + /** + * Removes leading and trailing whitespaces as well as line terminators in element values. + * Defaults to true. + */ + trim?: boolean; + /** + * XML child nodes are always treated as arrays + */ + arrayNotation?: boolean; +} diff --git a/xml2json/tsconfig.json b/xml2json/tsconfig.json new file mode 100644 index 0000000000..ace1857003 --- /dev/null +++ b/xml2json/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "xml2json-tests.ts" + ] +} \ No newline at end of file diff --git a/xml2json/tslint.json b/xml2json/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/xml2json/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file diff --git a/xml2json/xml2json-tests.ts b/xml2json/xml2json-tests.ts new file mode 100644 index 0000000000..ede4486f2c --- /dev/null +++ b/xml2json/xml2json-tests.ts @@ -0,0 +1,24 @@ +import * as parser from 'xml2json' + +var xml = "bar"; + +// xml to json +var jsonString: string = parser.toJson(xml); + +// json to xml +var xml: string = parser.toXml(jsonString); + +// xml to json in object mode and JsonOptions +var jsonObject: Object = parser.toJson(xml, { + object: true, + reversible: false, + coerce: false, + sanitize: true, + trim: true, + arrayNotation: false +}); + +// json to xml with XmlOptions +var xml: string = parser.toXml(jsonObject, { + sanitize: true +}); From 52350a2c51e1afb0d90f02481f9fc0d4319fccbb Mon Sep 17 00:00:00 2001 From: stonio Date: Wed, 4 Jan 2017 15:26:41 +0100 Subject: [PATCH 077/181] Update index.d.ts Fix basic typo --- jquery/index.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jquery/index.d.ts b/jquery/index.d.ts index b7cbefa019..889f644c06 100644 --- a/jquery/index.d.ts +++ b/jquery/index.d.ts @@ -111,7 +111,7 @@ interface JQueryAjaxSettings { */ method?: string; /** - * A mime type to override the XHR mime type. (version added: 1.5.1) + * A MIME type to override the XHR MIME type. (version added: 1.5.1) */ mimeType?: string; /** @@ -139,7 +139,7 @@ interface JQueryAjaxSettings { */ timeout?: number; /** - * Set this to true if you wish to use the traditional style of param serialization. + * Set this to true if you wish to use the traditional style of parameter serialization. */ traditional?: boolean; /** @@ -184,7 +184,7 @@ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { */ then(doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => R|JQueryPromise, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise; /** - * Property containing the parsed response if the response Content-Type is json + * Property containing the parsed response if the response content type is json */ responseJSON?: any; /** @@ -1220,7 +1220,7 @@ interface JQueryStatic { * * @param value The value to search for. * @param array An array through which to search. - * @param fromIndex he index of the array at which to begin the search. The default is 0, which will search the whole array. + * @param fromIndex the index of the array at which to begin the search. The default is 0, which will search the whole array. * @see {@link https://api.jquery.com/jQuery.inArray/} */ inArray(value: T, array: T[], fromIndex?: number): number; @@ -1240,7 +1240,7 @@ interface JQueryStatic { */ isEmptyObject(obj: any): boolean; /** - * Determine if the argument passed is a Javascript function object. + * Determine if the argument passed is a JavaScript function object. * * @param obj Object to test whether or not it is a function. * @see {@link https://api.jquery.com/jQuery.isFunction/} @@ -1270,7 +1270,7 @@ interface JQueryStatic { /** * Check to see if a DOM node is within an XML document (or is an XML document). * - * @param node he DOM node that will be checked to see if it's in an XML document. + * @param node the DOM node that will be checked to see if it's in an XML document. * @see {@link https://api.jquery.com/jQuery.isXMLDoc/} */ isXMLDoc(node: Node): boolean; @@ -1833,7 +1833,7 @@ interface JQuery { * Store arbitrary data associated with the matched elements. * * @param key A string naming the piece of data to set. - * @param value The new data value; it can be any Javascript type including Array or Object. + * @param value The new data value; it can be any JavaScript type including Array or Object. * @see {@link https://api.jquery.com/data/#data-key-value} */ data(key: string, value: any): JQuery; From e715f19af9287e20b3d729dfc902e4f11f95ba09 Mon Sep 17 00:00:00 2001 From: "Colton J. Provias" Date: Wed, 4 Jan 2017 09:39:32 -0500 Subject: [PATCH 078/181] Adding extension functions to Codec (#13718) --- msgpack-lite/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/msgpack-lite/index.d.ts b/msgpack-lite/index.d.ts index b017690006..400d22b2e7 100644 --- a/msgpack-lite/index.d.ts +++ b/msgpack-lite/index.d.ts @@ -53,6 +53,10 @@ declare module "msgpack-lite" { new (options?: any): Codec; options: any; init (): void; + addExtPacker (etype: number, Class: any, packer: (value: any) => any): void; + getExtPacker (value: any): (value: any) => any; + addExtUnpacker (etype: number, unpacker: (value: any) => any): void; + getExtUnpacker (etype: number): (value: any) => any; } export function encode(input: any, options?: BufferOptions): any; From e8761854cdadd8a71a91c228ad69bb0a20b7956e Mon Sep 17 00:00:00 2001 From: stonio Date: Wed, 4 Jan 2017 16:56:52 +0100 Subject: [PATCH 079/181] Update index.d.ts --- jquery/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery/index.d.ts b/jquery/index.d.ts index 889f644c06..e0bf072983 100644 --- a/jquery/index.d.ts +++ b/jquery/index.d.ts @@ -67,7 +67,7 @@ interface JQueryAjaxSettings { */ crossDomain?: boolean; /** - * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). + * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be key-value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). */ data?: any; /** @@ -1220,7 +1220,7 @@ interface JQueryStatic { * * @param value The value to search for. * @param array An array through which to search. - * @param fromIndex the index of the array at which to begin the search. The default is 0, which will search the whole array. + * @param fromIndex The index of the array at which to begin the search. The default is 0, which will search the whole array. * @see {@link https://api.jquery.com/jQuery.inArray/} */ inArray(value: T, array: T[], fromIndex?: number): number; @@ -1270,7 +1270,7 @@ interface JQueryStatic { /** * Check to see if a DOM node is within an XML document (or is an XML document). * - * @param node the DOM node that will be checked to see if it's in an XML document. + * @param node The DOM node that will be checked to see if it's in an XML document. * @see {@link https://api.jquery.com/jQuery.isXMLDoc/} */ isXMLDoc(node: Node): boolean; From e8088fd229eb49f1868eddbec06b73e4d55d816e Mon Sep 17 00:00:00 2001 From: Josh Hargreaves Date: Wed, 4 Jan 2017 17:07:44 +0000 Subject: [PATCH 080/181] Add missing onMomentum* properties to ScrollView. (#13732) Added missing definitions for onMomentumScrollBegin & onMomentumScrollEnd. --- react-native/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 57e670575e..3bb716d1db 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -5634,6 +5634,16 @@ declare module "react" { * Fires when a user has finished scrolling. */ onScrollEndDrag?: (event?: NativeSyntheticEvent) => void + + /** + * Fires when scroll view has finished moving + */ + onMomentumScrollEnd?: (event?: NativeSyntheticEvent) => void + + /** + * Fires when scroll view has begun moving + */ + onMomentumScrollBegin?: (event?: NativeSyntheticEvent) => void /** * When true the scroll view stops on multiples of the scroll view's size From 25ecee95138cb451fd66f25d730dac76e4e0d61a Mon Sep 17 00:00:00 2001 From: Aluan Haddad Date: Wed, 4 Jan 2017 12:20:13 -0500 Subject: [PATCH 081/181] Added the brand property to the StripeCardData and fix style issues, lint (#13084) * Add the "brand" field to StipeCardData Added the StipeCardDataBrand type. Added the `brand` property to the `StripeCardData` declaration with the type `'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'` Reference: https://stripe.com/docs/api#card_object * Run linter, fix issues. set --strictNullChecks. Unsure about ambient declaration: Removed as it seemed to be in error: 1. case was not correct 2. the export was the type of the global which is unconditionally defined. 3. this module does not seem a suitable candidate for a UMD declaration. * Use header version of 0.0; explain Stripe versioning in comments * Restore global * Added tests --- stripe/index.d.ts | 45 +++++++++++++++++++----------------------- stripe/stripe-tests.ts | 25 +++++++++++++++++++++++ stripe/tsconfig.json | 7 ++++--- stripe/tslint.json | 3 +++ 4 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 stripe/stripe-tests.ts create mode 100644 stripe/tslint.json diff --git a/stripe/index.d.ts b/stripe/index.d.ts index 2f8c895298..fdfa1db96e 100644 --- a/stripe/index.d.ts +++ b/stripe/index.d.ts @@ -1,8 +1,10 @@ -// Type definitions for stripe +// Type definitions for stripe 0.0 // Project: https://stripe.com/ // Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon , Adam Cmiel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare const Stripe: StripeStatic; + interface StripeStatic { applePay: StripeApplePay; setPublishableKey(key: string): void; @@ -49,6 +51,8 @@ interface StripeError { param?: string; } +type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'; + interface StripeCardData { object: string; last4: string; @@ -62,18 +66,17 @@ interface StripeCardData { address_state?: string; address_zip?: string; address_country?: string; + brand?: StripeCardDataBrand; createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; } -interface StripeBankAccount -{ - createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void; +interface StripeBankAccount { + createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void; validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; } -interface StripeBankTokenParams -{ +interface StripeBankTokenParams { country: string; currency: string; account_number: number | string; @@ -82,8 +85,7 @@ interface StripeBankTokenParams account_holder_type: string; } -interface StripeBankTokenResponse -{ +interface StripeBankTokenResponse { id: string; bank_account: { country: string; @@ -100,13 +102,7 @@ interface StripeBankTokenResponse error?: StripeError; } -declare var Stripe: StripeStatic; -declare module "Stripe" { - export = StripeStatic; -} - -interface StripeApplePay -{ +interface StripeApplePay { checkAvailability(resopnseHandler: (result: boolean) => void): void; buildSession(data: StripeApplePayPaymentRequest, onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void, @@ -117,8 +113,7 @@ type StripeApplePayBillingContactField = 'postalAddress' | 'name'; type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email'; type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; -interface StripeApplePayPaymentRequest -{ +interface StripeApplePayPaymentRequest { billingContact: StripeApplePayPaymentContact; countryCode: string; currencyCode: string; @@ -132,30 +127,26 @@ interface StripeApplePayPaymentRequest } // https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types -interface StripeApplePayLineItem -{ +interface StripeApplePayLineItem { type: 'pending' | 'final'; label: string; amount: number; } -interface StripeApplePaySessionResult -{ +interface StripeApplePaySessionResult { token: StripeTokenResponse; shippingContact?: StripeApplePayPaymentContact; shippingMethod?: StripeApplePayShippingMethod; } -interface StripeApplePayShippingMethod -{ +interface StripeApplePayShippingMethod { label: string; detail: string; amount: number; identifier: string; } -interface StripeApplePayPaymentContact -{ +interface StripeApplePayPaymentContact { emailAddress: string; phoneNumber: string; givenName: string; @@ -166,3 +157,7 @@ interface StripeApplePayPaymentContact postalCode: string; countryCode: string; } + +// The Stripe client side APIs are not made available to package managers for direct installation. +// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only +// A release date versioning schema is used to version these APIs. diff --git a/stripe/stripe-tests.ts b/stripe/stripe-tests.ts new file mode 100644 index 0000000000..44aa09d216 --- /dev/null +++ b/stripe/stripe-tests.ts @@ -0,0 +1,25 @@ +function success(card: StripeCardData) { + console.log(card.brand && card.brand.toString()); +} + +const cardNumber = '4242424242424242'; + +const isValid = Stripe.validateCardNumber(cardNumber); +if (isValid) { + const tokenData: StripeTokenData = { + number: cardNumber, + exp_month: 1, + exp_year: 2100, + cvc: '111' + }; + Stripe.card.createToken(tokenData, (status, response) => { + if (response.error) { + console.error(response.error.message); + if (response.error.param) { + console.error(response.error.param); + } + } else { + success(response.card); + } + }); +} diff --git a/stripe/tsconfig.json b/stripe/tsconfig.json index 79b9eb6b27..265882db3c 100644 --- a/stripe/tsconfig.json +++ b/stripe/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -13,6 +13,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "stripe-tests.ts" ] -} \ No newline at end of file +} diff --git a/stripe/tslint.json b/stripe/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/stripe/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From b06425da6dbb6f64c7363dd5273eb49318012eb5 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Wed, 4 Jan 2017 10:36:58 -0800 Subject: [PATCH 082/181] Enzyme: add signature for exists method (#13720) --- enzyme/enzyme-tests.tsx | 4 ++++ enzyme/index.d.ts | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index a97c33051e..dfa0f1ee96 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -125,6 +125,10 @@ namespace ShallowWrapperTest { boolVal = shallowWrapper.isEmpty() } + function test_exists() { + boolVal = shallowWrapper.exists() + } + function test_not() { elementWrapper = shallowWrapper.find('.foo').not('.bar'); } diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 63907a5c58..229e3d3a34 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Enzyme v2.5.1 +// Type definitions for Enzyme v2.7.0 // Project: https://github.com/airbnb/enzyme -// Definitions by: Marian Palkus , Cap3 , Ivo Stratev +// Definitions by: Marian Palkus , Cap3 , Ivo Stratev , Tom Crockett // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react"; @@ -101,11 +101,16 @@ interface CommonWrapper { is(selector: EnzymeSelector): boolean; /** - * Returns whether or not the current node is empty. - */ - isEmpty(): boolean; + * Returns whether or not the current node is empty. + */ + isEmpty(): boolean; - /** + /** + * Returns whether or not the current node exists. + */ + exists(): boolean; + + /** * Returns a new wrapper with only the nodes of the current wrapper that don't match the provided selector. * This method is effectively the negation or inverse of filter. * @param selector From 559daaaea990b03da29030f03d5b835c80c9b228 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 4 Jan 2017 11:04:09 -0800 Subject: [PATCH 083/181] Fix ace tests (#13734) They formerly did not run because the `/// `s for tests were not placed at the top of the file, so they were regular comments. --- ace/all-tests.ts | 26 ------- ace/tests/ace-anchor-tests.ts | 71 +++++++++---------- ace/tests/ace-background_tokenizer-tests.ts | 6 +- ace/tests/ace-default-tests.ts | 3 - ace/tests/ace-document-tests.ts | 5 +- ace/tests/ace-edit_session-tests.ts | 3 +- ace/tests/ace-editor1-tests.ts | 5 +- ...ce-editor_highlight_selected_word-tests.ts | 2 +- ace/tests/ace-editor_navigation-tests.ts | 5 +- ace/tests/ace-editor_text_edit-tests.ts | 5 +- ace/tests/ace-multi_select-tests.ts | 7 +- ace/tests/ace-placeholder-tests.ts | 5 +- ace/tests/ace-range-tests.ts | 5 +- ace/tests/ace-range_list-tests.ts | 5 +- ace/tests/ace-search-tests.ts | 5 +- ace/tests/ace-selection-tests.ts | 7 +- ace/tests/ace-token_iterator-tests.ts | 6 +- ace/tests/ace-virtual_renderer-tests.ts | 5 +- ace/tsconfig.json | 30 ++++++-- 19 files changed, 73 insertions(+), 133 deletions(-) delete mode 100644 ace/all-tests.ts diff --git a/ace/all-tests.ts b/ace/all-tests.ts deleted file mode 100644 index 7a7ef50a75..0000000000 --- a/ace/all-tests.ts +++ /dev/null @@ -1,26 +0,0 @@ - - -var exports: any; -var assert: any; -var MockRenderer: any = null; -var JavaScriptMode: any = null; - -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// - - - diff --git a/ace/tests/ace-anchor-tests.ts b/ace/tests/ace-anchor-tests.ts index 2cec45ce1d..c92e45bb0a 100644 --- a/ace/tests/ace-anchor-tests.ts +++ b/ace/tests/ace-anchor-tests.ts @@ -1,132 +1,129 @@ - - -var assert: any; -var exports = { +const aceAnchorTests = { "test create anchor" : function() { var doc = new AceAjax.Document("juhu"); var anchor = new AceAjax.Anchor(doc, 0, 0); - + assert.position(anchor.getPosition(), 0, 0); assert.equal(anchor.getDocument(), doc); }, - + "test insert text in same row before cursor should move anchor column": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.insert({row: 1, column: 1}, "123"); assert.position(anchor.getPosition(), 1, 7); }, - + "test insert lines before cursor should move anchor row": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.insertLines(1, ["123", "456"]); - assert.position(anchor.getPosition(), 3, 4); + assert.position(anchor.getPosition(), 3, 4); }, - + "test insert new line before cursor should move anchor column": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.insertNewLine({row: 0, column: 0}); - assert.position(anchor.getPosition(), 2, 4); + assert.position(anchor.getPosition(), 2, 4); }, - + "test insert new line in anchor line before anchor should move anchor column and row": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.insertNewLine({row: 1, column: 2}); assert.position(anchor.getPosition(), 2, 2); }, - + "test delete text in anchor line before anchor should move anchor column": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.remove(new AceAjax.Range(1, 1, 1, 3)); assert.position(anchor.getPosition(), 1, 2); }, - + "test remove range which contains the anchor should move the anchor to the start of the range": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 0, 3); - + doc.remove(new AceAjax.Range(0, 1, 1, 3)); assert.position(anchor.getPosition(), 0, 1); }, - + "test delete character before the anchor should have no effect": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.remove(new AceAjax.Range(1, 4, 1, 5)); assert.position(anchor.getPosition(), 1, 4); }, - + "test delete lines in anchor line before anchor should move anchor row": function() { var doc = new AceAjax.Document("juhu\n1\n2\nkinners"); var anchor = new AceAjax.Anchor(doc, 3, 4); - + doc.removeLines(1, 2); assert.position(anchor.getPosition(), 1, 4); }, - + "test remove new line before the cursor": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.removeNewLine(0); assert.position(anchor.getPosition(), 0, 8); }, - + "test delete range which contains the anchor should move anchor to the end of the range": function() { var doc = new AceAjax.Document("juhu\nkinners"); var anchor = new AceAjax.Anchor(doc, 1, 4); - + doc.remove(new AceAjax.Range(0, 2, 1, 2)); assert.position(anchor.getPosition(), 0, 4); }, - + "test delete line which contains the anchor should move anchor to the end of the range": function() { var doc = new AceAjax.Document("juhu\nkinners\n123"); var anchor = new AceAjax.Anchor(doc, 1, 5); - + doc.removeLines(1, 1); assert.position(anchor.getPosition(), 1, 0); }, - + "test remove after the anchor should have no effect": function() { var doc = new AceAjax.Document("juhu\nkinners\n123"); var anchor = new AceAjax.Anchor(doc, 1, 2); - + doc.remove(new AceAjax.Range(1, 4, 2, 2)); assert.position(anchor.getPosition(), 1, 2); }, - + "test anchor changes triggered by document changes should emit change event": function(next) { var doc = new AceAjax.Document("juhu\nkinners\n123"); var anchor = new AceAjax.Anchor(doc, 1, 5); - + anchor.on("change", function(e) { assert.position(anchor.getPosition(), 0, 0); next(); }); - + doc.remove(new AceAjax.Range(0, 0, 2, 1)); }, - + "test only fire change event if position changes": function() { var doc = new AceAjax.Document("juhu\nkinners\n123"); var anchor = new AceAjax.Anchor(doc, 1, 5); - + anchor.on("change", function(e) { assert.fail(); }); - + doc.remove(new AceAjax.Range(2, 0, 2, 1)); } }; diff --git a/ace/tests/ace-background_tokenizer-tests.ts b/ace/tests/ace-background_tokenizer-tests.ts index b77a9e0072..b053ba21b2 100644 --- a/ace/tests/ace-background_tokenizer-tests.ts +++ b/ace/tests/ace-background_tokenizer-tests.ts @@ -1,7 +1,3 @@ - - -var assert: any; - function forceTokenize(session) { for (var i = 0, l = session.getLength(); i < l; i++) session.getTokens(i) @@ -13,7 +9,7 @@ function testStates(session, states) { assert.ok(l == states.length) } -var exports = { +const aceBackgroundTokenizerTests = { "test background tokenizer update on session change": function() { var doc = new AceAjax.EditSession([ diff --git a/ace/tests/ace-default-tests.ts b/ace/tests/ace-default-tests.ts index 5ea89425ad..a9c74326b2 100644 --- a/ace/tests/ace-default-tests.ts +++ b/ace/tests/ace-default-tests.ts @@ -1,6 +1,3 @@ - - -var assert: any; var editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.getSession().setMode("ace/mode/javascript"); diff --git a/ace/tests/ace-document-tests.ts b/ace/tests/ace-document-tests.ts index 8760717d61..2f9c2e4b30 100644 --- a/ace/tests/ace-document-tests.ts +++ b/ace/tests/ace-document-tests.ts @@ -1,7 +1,4 @@ - - -var assert: any; -var exports = { +const aceDocumentTests = { "test: insert text in line": function() { var doc = new AceAjax.Document(["12", "34"]); diff --git a/ace/tests/ace-edit_session-tests.ts b/ace/tests/ace-edit_session-tests.ts index c057cb1297..4713495f7a 100644 --- a/ace/tests/ace-edit_session-tests.ts +++ b/ace/tests/ace-edit_session-tests.ts @@ -1,7 +1,6 @@ var lang: any; -var assert: any; function createFoldTestSession() { var lines = [ @@ -27,7 +26,7 @@ function assertArray(a, b) { } } -var exports = { +const aceEditSessionTests = { "test: find matching opening bracket in Text mode": function() { var session = new AceAjax.EditSession(["(()(", "())))"]); diff --git a/ace/tests/ace-editor1-tests.ts b/ace/tests/ace-editor1-tests.ts index c14d344dae..c2dd625aba 100644 --- a/ace/tests/ace-editor1-tests.ts +++ b/ace/tests/ace-editor1-tests.ts @@ -1,7 +1,4 @@ - - -var assert: any; -var exports = { +const aceEditor1Tests = { setUp: function(next) { this.session1 = new AceAjax.EditSession(["abc", "def"]); diff --git a/ace/tests/ace-editor_highlight_selected_word-tests.ts b/ace/tests/ace-editor_highlight_selected_word-tests.ts index da17d37c81..5c5ad7ec27 100644 --- a/ace/tests/ace-editor_highlight_selected_word-tests.ts +++ b/ace/tests/ace-editor_highlight_selected_word-tests.ts @@ -30,7 +30,7 @@ function callHighlighterUpdate(session: AceAjax.IEditSession, firstRow: number, var assert: any; var renderer: AceAjax.VirtualRenderer; -var exports = { +const aceEditorHighlighSelectedWorkTests = { setUp: function(next) { var session = new AceAjax.EditSession(lipsum); var editor = new AceAjax.Editor(renderer, session); diff --git a/ace/tests/ace-editor_navigation-tests.ts b/ace/tests/ace-editor_navigation-tests.ts index 407b1af5de..3813eda98b 100644 --- a/ace/tests/ace-editor_navigation-tests.ts +++ b/ace/tests/ace-editor_navigation-tests.ts @@ -1,8 +1,5 @@ - - -var assert: any; var renderer: AceAjax.VirtualRenderer; -var exports = { +const aceEditorNavigationTests = { createEditSession: function (rows, cols) { var line = new Array(cols + 1).join("a"); var text = new Array(rows).join(line + "\n") + line; diff --git a/ace/tests/ace-editor_text_edit-tests.ts b/ace/tests/ace-editor_text_edit-tests.ts index b170fd051c..6eb1ea0cf4 100644 --- a/ace/tests/ace-editor_text_edit-tests.ts +++ b/ace/tests/ace-editor_text_edit-tests.ts @@ -1,9 +1,6 @@ - - -var assert: any; var renderer: AceAjax.VirtualRenderer; var mode: any; -var exports = { +const aceEditorTextEditTests = { "test: delete line from the middle": function () { var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n")); var editor = new AceAjax.Editor(renderer, session); diff --git a/ace/tests/ace-multi_select-tests.ts b/ace/tests/ace-multi_select-tests.ts index cc571cfee3..b43012360f 100644 --- a/ace/tests/ace-multi_select-tests.ts +++ b/ace/tests/ace-multi_select-tests.ts @@ -1,8 +1,3 @@ - - -var assert: any; -var editor: any; -var renderer: any; var exec = function (name?, times?, args?) { do { editor.commands.exec(name, editor, args); @@ -12,7 +7,7 @@ var testRanges = function (str) { assert.equal(editor.selection.getAllRanges() + "", str + ""); } -var exports = { +const aceMultiSelectTests = { name: "ACE multi_select.js", diff --git a/ace/tests/ace-placeholder-tests.ts b/ace/tests/ace-placeholder-tests.ts index ba0b27ca88..b5a7ac15c6 100644 --- a/ace/tests/ace-placeholder-tests.ts +++ b/ace/tests/ace-placeholder-tests.ts @@ -1,9 +1,6 @@ - - -var assert: any; var renderer: AceAjax.VirtualRenderer; var mode: any; -var exports = { +const acePlaceholderTests = { "test: simple at the end appending of text": function () { var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode); diff --git a/ace/tests/ace-range-tests.ts b/ace/tests/ace-range-tests.ts index a32c74fbde..3fde5cbbae 100644 --- a/ace/tests/ace-range-tests.ts +++ b/ace/tests/ace-range-tests.ts @@ -1,7 +1,4 @@ - - -var assert: any; -var exports = { +const aceRangeTests = { name: "ACE range.js", diff --git a/ace/tests/ace-range_list-tests.ts b/ace/tests/ace-range_list-tests.ts index f1f06214f9..900a360dc5 100644 --- a/ace/tests/ace-range_list-tests.ts +++ b/ace/tests/ace-range_list-tests.ts @@ -1,6 +1,3 @@ - - -var assert: any; function flatten(rangeList) { var points = []; rangeList.ranges.forEach(function (r) { @@ -12,7 +9,7 @@ function testRangeList(rangeList, points) { assert.equal("" + flatten(rangeList), "" + points); } -var exports = { +const aceRangeListTests = { name: "ACE range_list.js", diff --git a/ace/tests/ace-search-tests.ts b/ace/tests/ace-search-tests.ts index 4857d5bfdc..c3a1a7c598 100644 --- a/ace/tests/ace-search-tests.ts +++ b/ace/tests/ace-search-tests.ts @@ -1,7 +1,4 @@ - - -var assert: any; -var exports = { +const aceSearchTests = { "test: configure the search object": function () { var search = new AceAjax.Search(); search.set({ diff --git a/ace/tests/ace-selection-tests.ts b/ace/tests/ace-selection-tests.ts index ab151b88bc..be7da64331 100644 --- a/ace/tests/ace-selection-tests.ts +++ b/ace/tests/ace-selection-tests.ts @@ -1,7 +1,4 @@ - - -var assert: any; -var exports = { +const aceSelectionTests = { createSession: function (rows, cols) { var line = new Array(cols + 1).join("a"); var text = new Array(rows).join(line + "\n") + line; @@ -126,7 +123,7 @@ var exports = { }, "test: moveCursor word left with umlauts": function () { - var session = new AceAjax.EditSession(" Fuß Füße"); + var session = new AceAjax.EditSession(" Fu� F��e"); var selection = session.getSelection(); selection.moveCursorTo(0, 9) diff --git a/ace/tests/ace-token_iterator-tests.ts b/ace/tests/ace-token_iterator-tests.ts index 27856a7434..dbec07052d 100644 --- a/ace/tests/ace-token_iterator-tests.ts +++ b/ace/tests/ace-token_iterator-tests.ts @@ -1,8 +1,4 @@ - - -var assert: any; -var mode: any; -var exports = { +const aceTokenIteratorTests = { "test: token iterator initialization in JavaScript document": function () { var lines = [ "function foo(items) {", diff --git a/ace/tests/ace-virtual_renderer-tests.ts b/ace/tests/ace-virtual_renderer-tests.ts index 71b1d86bf1..74bcec2fa8 100644 --- a/ace/tests/ace-virtual_renderer-tests.ts +++ b/ace/tests/ace-virtual_renderer-tests.ts @@ -1,7 +1,4 @@ - - -var assert: any; -var exports = { +const aceVirtualRendererTests = { "test: screen2text the column should be rounded to the next character edge": function () { var el = document.createElement("div"); diff --git a/ace/tsconfig.json b/ace/tsconfig.json index bde471bd60..e5a0d270c3 100644 --- a/ace/tsconfig.json +++ b/ace/tsconfig.json @@ -1,13 +1,9 @@ { - "files": [ - "index.d.ts", - "all-tests.ts" - ], "compilerOptions": { "module": "commonjs", "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, + "noImplicitAny": false, + "noImplicitThis": false, "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ @@ -16,5 +12,25 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - } + }, + "files": [ + "index.d.ts", + "tests/ace-anchor-tests.ts", + "tests/ace-background_tokenizer-tests.ts", + "tests/ace-default-tests.ts", + "tests/ace-document-tests.ts", + "tests/ace-edit_session-tests.ts", + "tests/ace-editor1-tests.ts", + "tests/ace-editor_highlight_selected_word-tests.ts", + "tests/ace-editor_navigation-tests.ts", + "tests/ace-editor_text_edit-tests.ts", + "tests/ace-multi_select-tests.ts", + "tests/ace-placeholder-tests.ts", + "tests/ace-range-tests.ts", + "tests/ace-range_list-tests.ts", + "tests/ace-search-tests.ts", + "tests/ace-selection-tests.ts", + "tests/ace-token_iterator-tests.ts", + "tests/ace-virtual_renderer-tests.ts" + ] } \ No newline at end of file From bf1450711a526897579e0ff08585d4196eece313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Marques?= Date: Wed, 4 Jan 2017 19:26:56 +0000 Subject: [PATCH 084/181] Add pg-query-stream typings (#13729) --- pg-query-stream/index.d.ts | 20 ++++++++++++++++++++ pg-query-stream/pg-query-stream-tests.ts | 19 +++++++++++++++++++ pg-query-stream/tsconfig.json | 20 ++++++++++++++++++++ pg-query-stream/tslint.json | 1 + 4 files changed, 60 insertions(+) create mode 100644 pg-query-stream/index.d.ts create mode 100644 pg-query-stream/pg-query-stream-tests.ts create mode 100644 pg-query-stream/tsconfig.json create mode 100644 pg-query-stream/tslint.json diff --git a/pg-query-stream/index.d.ts b/pg-query-stream/index.d.ts new file mode 100644 index 0000000000..1a7a694a6a --- /dev/null +++ b/pg-query-stream/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for pg-query-stream 1.0 +// Project: https://github.com/brianc/node-pg-query-stream +// Definitions by: António Marques +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace QueryStream { + interface Options { + highWaterMark?: number; + batchSize?: number; + } +} + +declare class QueryStream { + batchSize: number; + text: string; + values?: any[]; + constructor(text: string, values?: any[], options?: QueryStream.Options); +} + +export = QueryStream; diff --git a/pg-query-stream/pg-query-stream-tests.ts b/pg-query-stream/pg-query-stream-tests.ts new file mode 100644 index 0000000000..6c4c034102 --- /dev/null +++ b/pg-query-stream/pg-query-stream-tests.ts @@ -0,0 +1,19 @@ +import * as QueryStream from 'pg-query-stream'; +import * as pg from 'pg'; + +const options: QueryStream.Options = { + highWaterMark: 1000, + batchSize: 100 +}; + +const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000], options); + +pg.connect('', (err, client, done) => { + const stream = client.query(query); + stream.on('end', () => { + client.end(); + }); + stream.on('data', (data: any) => { + console.log(data); + }); +}); diff --git a/pg-query-stream/tsconfig.json b/pg-query-stream/tsconfig.json new file mode 100644 index 0000000000..ff01b055f9 --- /dev/null +++ b/pg-query-stream/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pg-query-stream-tests.ts" + ] +} diff --git a/pg-query-stream/tslint.json b/pg-query-stream/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/pg-query-stream/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3d6a15ee1612520d8d4751adce8f2009292a37bb Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 4 Jan 2017 12:07:53 -0800 Subject: [PATCH 085/181] Strip BOM from all files (#13735) --- accounting/accounting-tests.ts | 2 +- ace/tests/ace-range-tests.ts | 2 +- angular-gettext/angular-gettext-tests.ts | 2 +- angular-jwt/angular-jwt-tests.ts | 2 +- angular-media-queries/match-media-tests.ts | 2 +- angular-xeditable/angular-xeditable-tests.ts | 2 +- auth0-angular/auth0-angular-tests.ts | 2 +- azure/azure-tests.ts | 2 +- backbone.radio/backbone.radio-tests.ts | 2 +- bingmaps/Microsoft.Maps.AdvancedShapes.d.ts | 2 +- bingmaps/Microsoft.Maps.Directions.d.ts | 2 +- bingmaps/Microsoft.Maps.Search.d.ts | 2 +- bingmaps/Microsoft.Maps.Themes.BingTheme.d.ts | 2 +- bingmaps/Microsoft.Maps.Traffic.d.ts | 2 +- bingmaps/Microsoft.Maps.VenueMaps.d.ts | 2 +- bingmaps/bingmaps-tests.ts | 2 +- bootstrap-datepicker/bootstrap-datepicker-tests.ts | 2 +- bootstrap-touchspin/bootstrap-touchspin-tests.ts | 2 +- bytes/bytes-tests.ts | 2 +- cal-heatmap/cal-heatmap-tests.ts | 2 +- canvasjs/canvasjs-tests.ts | 2 +- chrome/chrome-app-tests.ts | 2 +- cli-color/cli-color-tests.ts | 2 +- codemirror/codemirror-runmode.d.ts | 2 +- cordova-plugin-app-version/cordova-plugin-app-version-tests.ts | 2 +- cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts | 2 +- cordova-plugin-insomnia/cordova-plugin-insomnia-tests.ts | 2 +- .../cordova-plugin-x-socialsharing-tests.ts | 2 +- cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts | 2 +- core-js/core-js-tests.ts | 2 +- d3-dsv/v0/index.d.ts | 2 +- d3.cloud.layout/d3.cloud.layout-tests.ts | 2 +- depd/depd-tests.ts | 2 +- devexpress-web/devexpress-web-tests.ts | 2 +- documentdb-server/documentdb-server-tests.ts | 2 +- dojo/dojox.NodeList.d.ts | 2 +- dojo/dojox.analytics.d.ts | 2 +- dojo/dojox.app.d.ts | 2 +- dojo/dojox.atom.d.ts | 2 +- dojo/dojox.av.d.ts | 2 +- dojo/dojox.calc.d.ts | 2 +- dojo/dojox.calendar.d.ts | 2 +- dojo/dojox.charting.d.ts | 2 +- dojo/dojox.collections.d.ts | 2 +- dojo/dojox.color.d.ts | 2 +- dojo/dojox.css3.d.ts | 2 +- dojo/dojox.data.d.ts | 2 +- dojo/dojox.date.d.ts | 2 +- dojo/dojox.dgauges.d.ts | 2 +- dojo/dojox.dnd.d.ts | 2 +- dojo/dojox.drawing.d.ts | 2 +- dojo/dojox.dtl.d.ts | 2 +- dojo/dojox.editor.d.ts | 2 +- dojo/dojox.embed.d.ts | 2 +- dojo/dojox.encoding.d.ts | 2 +- dojo/dojox.flash.d.ts | 2 +- dojo/dojox.form.d.ts | 2 +- dojo/dojox.fx.d.ts | 2 +- dojo/dojox.gantt.d.ts | 2 +- dojo/dojox.gauges.d.ts | 2 +- dojo/dojox.geo.d.ts | 2 +- dojo/dojox.gesture.d.ts | 2 +- dojo/dojox.gfx.d.ts | 2 +- dojo/dojox.gfx3d.d.ts | 2 +- dojo/dojox.grid.d.ts | 2 +- dojo/dojox.help.d.ts | 2 +- dojo/dojox.highlight.d.ts | 2 +- dojo/dojox.html.d.ts | 2 +- dojo/dojox.image.d.ts | 2 +- dojo/dojox.io.d.ts | 2 +- dojo/dojox.jq.d.ts | 2 +- dojo/dojox.json.d.ts | 2 +- dojo/dojox.jsonPath.d.ts | 2 +- dojo/dojox.lang.d.ts | 2 +- dojo/dojox.layout.d.ts | 2 +- dojo/dojox.main.d.ts | 2 +- dojo/dojox.math.d.ts | 2 +- dojo/dojox.mdnd.d.ts | 2 +- dojo/dojox.mobile.d.ts | 2 +- dojo/dojox.mvc.d.ts | 2 +- dojo/dojox.rails.d.ts | 2 +- dojo/dojox.robot.d.ts | 2 +- dojo/dojox.rpc.d.ts | 2 +- dojo/dojox.secure.d.ts | 2 +- dojo/dojox.sketch.d.ts | 2 +- dojo/dojox.socket.d.ts | 2 +- dojo/dojox.sql.d.ts | 2 +- dojo/dojox.string.d.ts | 2 +- dojo/dojox.testing.d.ts | 2 +- dojo/dojox.timing.d.ts | 2 +- dojo/dojox.treemap.d.ts | 2 +- dojo/dojox.uuid.d.ts | 2 +- dojo/dojox.validate.d.ts | 2 +- dojo/dojox.widget.d.ts | 2 +- dojo/dojox.xml.d.ts | 2 +- dot/dot-tests.ts | 2 +- electron/github-electron-main-tests.ts | 2 +- electron/github-electron-renderer-tests.ts | 2 +- flight/flight-tests.ts | 2 +- flux/flux-tests.ts | 2 +- fromjs/fromjs-tests.ts | 2 +- gridstack/gridstack-tests.ts | 2 +- gsap/gsap-tests.ts | 2 +- gulp-util/gulp-util-tests.ts | 2 +- hellosign-embedded/hellosign-embedded-tests.ts | 2 +- http-string-parser/http-string-parser-tests.ts | 2 +- httperr/httperr-tests.ts | 2 +- .../hypertext-application-language-tests.ts | 2 +- is/is_js-tests.ts | 2 +- ix.js/l2o-tests.ts | 2 +- jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts | 2 +- jointjs/README.md | 2 +- jqgrid/jqgrid-tests.ts | 2 +- jquery-jsonrpcclient/jquery-jsonrpcclient-tests.ts | 2 +- jquery-mousewheel/jquery-mousewheel-tests.ts | 2 +- .../jquery-validation-unobtrusive-tests.ts | 2 +- jquery.are-you-sure/jquery.are-you-sure-tests.ts | 2 +- jquery.blockui/jquery.blockUI-tests.ts | 2 +- jquery.colorbox/jquery.colorbox-tests.ts | 2 +- jquery.fancytree/jquery.fancytree-tests.ts | 2 +- jquery.finger/jquery.finger-tests.ts | 2 +- jquery.menuaim/jquery.menuaim-tests.ts | 2 +- jquery.pjax.falsandtru/jquery.pjax-tests.ts | 2 +- jquery.postmessage/jquery.postMessage-tests.ts | 2 +- jquery.prettyphoto/jquery.prettyphoto-tests.ts | 2 +- jquery.timeago/jquery.timeago-tests.ts | 2 +- jsnlog/jsnlog-tests.ts | 2 +- jstree/jstree-tests.ts | 2 +- jsts/jsts-tests.ts | 2 +- knockout.deferred.updates/knockout.deferred.updates-tests.ts | 2 +- knockout.punches/knockout.punches-tests.ts | 2 +- ladda/ladda-tests.ts | 2 +- later/later-tests.ts | 2 +- less/less-tests.ts | 2 +- .../localforage-cordovasqlitedriver-tests.ts | 2 +- localforage/localForage-tests.ts | 2 +- log4javascript/log4javascript-tests.ts | 2 +- lokijs/lokijs-tests.ts | 2 +- lscache/lscache-tests.ts | 2 +- lz-string/lz-string-tests.ts | 2 +- magicsuggest/magicsuggest-tests.ts | 2 +- maskedinput/maskedinput-tests.ts | 2 +- merge-descriptors/merge-descriptors-tests.ts | 2 +- minilog/minilog-tests.ts | 2 +- mysql/mysql-tests.ts | 2 +- ng-file-upload/ng-file-upload-tests.ts | 2 +- ngprogress-lite/ngprogress-lite-tests.ts | 2 +- ngprogress/ngprogress-tests.ts | 2 +- nopt/nopt-tests.ts | 2 +- notify.js/notify.js.tests.ts | 2 +- npm/npm-tests.ts | 2 +- nvd3/nvd3-test-candlestick.ts | 2 +- nvd3/nvd3-test-candlestickChart.ts | 2 +- nvd3/nvd3-test-cumulativeLineChart.ts | 2 +- nvd3/nvd3-test-discreteBarChart.ts | 2 +- nvd3/nvd3-test-donutChart.ts | 2 +- nvd3/nvd3-test-furiousLegend.ts | 2 +- nvd3/nvd3-test-line.ts | 2 +- nvd3/nvd3-test-lineChart.ts | 2 +- nvd3/nvd3-test-lineChartLogScale.ts | 2 +- nvd3/nvd3-test-lineChartSVGResize.ts | 2 +- nvd3/nvd3-test-linePlusBarChart.ts | 2 +- nvd3/nvd3-test-lineWithFocusChart.ts | 2 +- nvd3/nvd3-test-lineWithFocusChartx2AxisLabel.ts | 2 +- nvd3/nvd3-test-monitoringChart.ts | 2 +- nvd3/nvd3-test-multiChart.ts | 2 +- nvd3/nvd3-test-multibarChart.ts | 2 +- nvd3/nvd3-test-multibarChart2.ts | 2 +- nvd3/nvd3-test-multibarHorizontalChart.ts | 2 +- nvd3/nvd3-test-scatter.ts | 2 +- nvd3/nvd3-test-scatterChart.ts | 2 +- nvd3/nvd3-test-scatterPlusLineChart.ts | 2 +- nvd3/nvd3-test-sparkLine.ts | 2 +- nvd3/nvd3-test-sparkLinePlus.ts | 2 +- nvd3/nvd3-test-stackArea.ts | 2 +- nvd3/nvd3-test-stackAreaChart.ts | 2 +- nvd3/nvd3-test-sunburst.ts | 2 +- nvd3/nvd3-test-timeSeries.ts | 2 +- on-headers/on-headers-tests.ts | 2 +- openlayers/openlayers-3.6.0-tests.ts | 2 +- openpgp/openpgp-tests.ts | 2 +- page/page-tests.ts | 2 +- pixi-spine/pixi-spine-tests.ts | 2 +- pixi.js/pixi.js-tests.ts | 2 +- pixi.js/v3/pixi.js-tests.ts | 2 +- playerframework/playerframework-tests.ts | 2 +- poly2tri/poly2tri-tests.ts | 2 +- purl/purl-jquery.d.ts | 2 +- ractive/ractive-tests.ts | 2 +- react-mdl/react-mdl-tests.tsx | 2 +- recaptcha/recaptcha-tests.ts | 2 +- sendgrid/sendgrid-1.1.0.d.ts | 2 +- sendgrid/sendgrid-tests.ts | 2 +- sequelize-fixtures/sequelize-fixtures-tests.ts | 2 +- sharepoint/SharePoint-tests.ts | 2 +- simplemde/simplemde-tests.ts | 2 +- stack-mapper/stack-mapper-tests.ts | 2 +- steam/steam-tests.ts | 2 +- strophe/strophe-tests.ts | 2 +- stylus/stylus-tests.ts | 2 +- sylvester/sylvester-tests.ts | 2 +- tar/tar-tests.ts | 2 +- three/tests/canvas/canvas_camera_orthographic.ts | 2 +- three/tests/canvas/canvas_geometry_cube.ts | 2 +- three/tests/canvas/canvas_interactive_cubes_tween.ts | 2 +- three/tests/canvas/canvas_lights_pointlights.ts | 2 +- three/tests/canvas/canvas_materials.ts | 2 +- three/tests/canvas/canvas_particles_floor.ts | 2 +- three/tests/css3d/css3d_periodictable.ts | 2 +- three/tests/css3d/css3d_sprites.ts | 2 +- three/tests/examples/detector.ts | 2 +- three/tests/math/test_unit_math.ts | 2 +- three/tests/three-tests-setup.ts | 2 +- three/tests/webgl/webgl_animation_cloth.ts | 2 +- three/tests/webgl/webgl_animation_skinning_morph.ts | 2 +- three/tests/webgl/webgl_buffergeometry.ts | 2 +- three/tests/webgl/webgl_camera.ts | 2 +- three/tests/webgl/webgl_custom_attributes.ts | 2 +- three/tests/webgl/webgl_geometries.ts | 2 +- three/tests/webgl/webgl_helpers.ts | 2 +- three/tests/webgl/webgl_interactive_cubes.ts | 2 +- three/tests/webgl/webgl_interactive_raycasting_points.ts | 2 +- three/tests/webgl/webgl_lensflares.ts | 2 +- three/tests/webgl/webgl_lights_hemisphere.ts | 2 +- three/tests/webgl/webgl_lines_colors.ts | 2 +- three/tests/webgl/webgl_loader_awd.ts | 2 +- three/tests/webgl/webgl_materials.ts | 2 +- three/tests/webgl/webgl_morphtargets.ts | 2 +- three/tests/webgl/webgl_points_billboards.ts | 2 +- three/tests/webgl/webgl_postprocessing.ts | 2 +- three/tests/webgl/webgl_shader.ts | 2 +- three/tests/webgl/webgl_sprites.ts | 2 +- tmp/tmp-tests.ts | 2 +- twitter/twitter-tests.ts | 2 +- twix/twix-tests.ts | 2 +- typeahead/typeahead-tests.ts | 2 +- typescript-stl/typescript-stl-tests.ts | 2 +- .../uk.co.workingedge.phonegap.plugin.istablet-tests.ts | 2 +- .../uk.co.workingedge.phonegap.plugin.launchnavigator-tests.ts | 2 +- valdr-message/valdr-message-tests.ts | 2 +- valdr/valdr-tests.ts | 2 +- webrtc/MediaStream-tests.ts | 2 +- webspeechapi/webspeechapi-tests.ts | 2 +- whatwg-fetch/whatwg-fetch-tests.ts | 2 +- whatwg-streams/whatwg-streams-tests.ts | 2 +- x-editable/x-editable-tests.ts | 2 +- xrm/xrm-6.d.ts | 2 +- xrm/xrm-7.0.d.ts | 2 +- yargs/yargs-tests.ts | 2 +- 249 files changed, 249 insertions(+), 249 deletions(-) diff --git a/accounting/accounting-tests.ts b/accounting/accounting-tests.ts index eff00e33b9..0c11683c65 100644 --- a/accounting/accounting-tests.ts +++ b/accounting/accounting-tests.ts @@ -1,4 +1,4 @@ -// formatMoney +// formatMoney // Default usage: accounting.formatMoney(12345678); // $12,345,678.00 diff --git a/ace/tests/ace-range-tests.ts b/ace/tests/ace-range-tests.ts index 3fde5cbbae..bf71dfc3b7 100644 --- a/ace/tests/ace-range-tests.ts +++ b/ace/tests/ace-range-tests.ts @@ -1,4 +1,4 @@ -const aceRangeTests = { +const aceRangeTests = { name: "ACE range.js", diff --git a/angular-gettext/angular-gettext-tests.ts b/angular-gettext/angular-gettext-tests.ts index 4529b97e4c..d7c330c3eb 100644 --- a/angular-gettext/angular-gettext-tests.ts +++ b/angular-gettext/angular-gettext-tests.ts @@ -1,4 +1,4 @@ - + namespace angular_gettext_tests { diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts index c1232dcab4..b20b2eea9d 100644 --- a/angular-jwt/angular-jwt-tests.ts +++ b/angular-jwt/angular-jwt-tests.ts @@ -1,4 +1,4 @@ -/// +/// var app = angular.module("angular-jwt-tests", ["angular-jwt"]); diff --git a/angular-media-queries/match-media-tests.ts b/angular-media-queries/match-media-tests.ts index e24c43c073..a652b982d8 100644 --- a/angular-media-queries/match-media-tests.ts +++ b/angular-media-queries/match-media-tests.ts @@ -1,4 +1,4 @@ - + var myApp = angular.module('testModule', ['matchMedia']); diff --git a/angular-xeditable/angular-xeditable-tests.ts b/angular-xeditable/angular-xeditable-tests.ts index 57a3e53863..31add7ae56 100644 --- a/angular-xeditable/angular-xeditable-tests.ts +++ b/angular-xeditable/angular-xeditable-tests.ts @@ -1,4 +1,4 @@ -var myApp = angular.module('testModule', ['xeditable']); +var myApp = angular.module('testModule', ['xeditable']); myApp.run(["editableOptions", (editableOptions: angular.xeditable.IEditableOptions) => { diff --git a/auth0-angular/auth0-angular-tests.ts b/auth0-angular/auth0-angular-tests.ts index f9700c1410..e35b0a7627 100644 --- a/auth0-angular/auth0-angular-tests.ts +++ b/auth0-angular/auth0-angular-tests.ts @@ -1,4 +1,4 @@ - + var authProvider: auth0.angular.IAuth0ServiceProvider; diff --git a/azure/azure-tests.ts b/azure/azure-tests.ts index 2d60803d3b..e763346d84 100644 --- a/azure/azure-tests.ts +++ b/azure/azure-tests.ts @@ -1,4 +1,4 @@ -import Azure = require("azure"); +import Azure = require("azure"); var ts = new Azure.TableService(); diff --git a/backbone.radio/backbone.radio-tests.ts b/backbone.radio/backbone.radio-tests.ts index 1c0685780f..e0adecb925 100644 --- a/backbone.radio/backbone.radio-tests.ts +++ b/backbone.radio/backbone.radio-tests.ts @@ -1,4 +1,4 @@ - + /// import * as Backbone from 'backbone'; diff --git a/bingmaps/Microsoft.Maps.AdvancedShapes.d.ts b/bingmaps/Microsoft.Maps.AdvancedShapes.d.ts index 32ac20a874..e261e1d0ce 100644 --- a/bingmaps/Microsoft.Maps.AdvancedShapes.d.ts +++ b/bingmaps/Microsoft.Maps.AdvancedShapes.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft.Maps.AdvancedShapes 7.0 +// Type definitions for Microsoft.Maps.AdvancedShapes 7.0 // Project: http://msdn.microsoft.com/en-us/library/hh921952.aspx // Definitions by: Eric Todd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/bingmaps/Microsoft.Maps.Directions.d.ts b/bingmaps/Microsoft.Maps.Directions.d.ts index e9f2fa9cf1..710efd7b02 100644 --- a/bingmaps/Microsoft.Maps.Directions.d.ts +++ b/bingmaps/Microsoft.Maps.Directions.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft.Maps.Directions 7.0 +// Type definitions for Microsoft.Maps.Directions 7.0 // Project: http://msdn.microsoft.com/en-us/library/hh312813.aspx // Definitions by: Eric Todd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/bingmaps/Microsoft.Maps.Search.d.ts b/bingmaps/Microsoft.Maps.Search.d.ts index 21011ab1cd..d5fcb3e255 100644 --- a/bingmaps/Microsoft.Maps.Search.d.ts +++ b/bingmaps/Microsoft.Maps.Search.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft.Maps.Search 7.0 +// Type definitions for Microsoft.Maps.Search 7.0 // Project: http://msdn.microsoft.com/en-us/library/hh868061.aspx // Definitions by: Eric Todd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/bingmaps/Microsoft.Maps.Themes.BingTheme.d.ts b/bingmaps/Microsoft.Maps.Themes.BingTheme.d.ts index e13be2603b..43faf0bd71 100644 --- a/bingmaps/Microsoft.Maps.Themes.BingTheme.d.ts +++ b/bingmaps/Microsoft.Maps.Themes.BingTheme.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft.Maps.Themes 7.0 +// Type definitions for Microsoft.Maps.Themes 7.0 // Project: http://msdn.microsoft.com/en-us/library/hh868061.aspx // Definitions by: Eric Todd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/bingmaps/Microsoft.Maps.Traffic.d.ts b/bingmaps/Microsoft.Maps.Traffic.d.ts index 353ec39b7c..003f874cd1 100644 --- a/bingmaps/Microsoft.Maps.Traffic.d.ts +++ b/bingmaps/Microsoft.Maps.Traffic.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft.Maps.Traffic 7.0 +// Type definitions for Microsoft.Maps.Traffic 7.0 // Project: http://msdn.microsoft.com/en-us/library/hh312840.aspx // Definitions by: Eric Todd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/bingmaps/Microsoft.Maps.VenueMaps.d.ts b/bingmaps/Microsoft.Maps.VenueMaps.d.ts index 51b41815f5..79076d30ea 100644 --- a/bingmaps/Microsoft.Maps.VenueMaps.d.ts +++ b/bingmaps/Microsoft.Maps.VenueMaps.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft.Maps.VenueMaps 7.0 +// Type definitions for Microsoft.Maps.VenueMaps 7.0 // Project: http://msdn.microsoft.com/en-us/library/hh312797.aspx // Definitions by: Eric Todd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/bingmaps/bingmaps-tests.ts b/bingmaps/bingmaps-tests.ts index d50efb0e62..239e33094a 100644 --- a/bingmaps/bingmaps-tests.ts +++ b/bingmaps/bingmaps-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/bootstrap-datepicker/bootstrap-datepicker-tests.ts b/bootstrap-datepicker/bootstrap-datepicker-tests.ts index 8175b32738..cedc28c93c 100644 --- a/bootstrap-datepicker/bootstrap-datepicker-tests.ts +++ b/bootstrap-datepicker/bootstrap-datepicker-tests.ts @@ -1,4 +1,4 @@ -/// +/// function tests_simple() { $('#datepicker').datepicker(); $('#datepicker').datepicker({ diff --git a/bootstrap-touchspin/bootstrap-touchspin-tests.ts b/bootstrap-touchspin/bootstrap-touchspin-tests.ts index d3c37d87d7..c8a6a713f9 100644 --- a/bootstrap-touchspin/bootstrap-touchspin-tests.ts +++ b/bootstrap-touchspin/bootstrap-touchspin-tests.ts @@ -1,4 +1,4 @@ -/// +/// $(function () { diff --git a/bytes/bytes-tests.ts b/bytes/bytes-tests.ts index 482b54afd2..9c7f7abd5d 100644 --- a/bytes/bytes-tests.ts +++ b/bytes/bytes-tests.ts @@ -1,4 +1,4 @@ -import bytes = require('bytes'); +import bytes = require('bytes'); // 1024*1024 = 1048576 console.log(bytes(104857)); diff --git a/cal-heatmap/cal-heatmap-tests.ts b/cal-heatmap/cal-heatmap-tests.ts index f19a88c3c1..47020b811c 100644 --- a/cal-heatmap/cal-heatmap-tests.ts +++ b/cal-heatmap/cal-heatmap-tests.ts @@ -1,4 +1,4 @@ - + /// /// diff --git a/canvasjs/canvasjs-tests.ts b/canvasjs/canvasjs-tests.ts index cfc67ab128..e9120ec9c3 100644 --- a/canvasjs/canvasjs-tests.ts +++ b/canvasjs/canvasjs-tests.ts @@ -1,4 +1,4 @@ - + namespace CanvasJS.Tests { // Column Chart diff --git a/chrome/chrome-app-tests.ts b/chrome/chrome-app-tests.ts index 31695c8efc..6dbd06d9e2 100644 --- a/chrome/chrome-app-tests.ts +++ b/chrome/chrome-app-tests.ts @@ -1,4 +1,4 @@ - + import runtime = chrome.app.runtime; import cwindow = chrome.app.window; diff --git a/cli-color/cli-color-tests.ts b/cli-color/cli-color-tests.ts index 0c4261da19..d6f8897720 100644 --- a/cli-color/cli-color-tests.ts +++ b/cli-color/cli-color-tests.ts @@ -1,4 +1,4 @@ - + /// import clc = require('cli-color'); diff --git a/codemirror/codemirror-runmode.d.ts b/codemirror/codemirror-runmode.d.ts index 116c092cd2..8c8e4fe7eb 100644 --- a/codemirror/codemirror-runmode.d.ts +++ b/codemirror/codemirror-runmode.d.ts @@ -1,4 +1,4 @@ -// Type definitions for CodeMirror +// Type definitions for CodeMirror // Project: https://github.com/marijnh/CodeMirror // Definitions by: Joseph Vaughan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts index 980d1343ef..3a8f335fdf 100644 --- a/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts +++ b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts @@ -1,4 +1,4 @@ -/// +/// cordova.getAppVersion.getAppName() .then(appName=> { diff --git a/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts b/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts index 3c5c19064a..4b4d4f7635 100644 --- a/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts +++ b/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts @@ -1,4 +1,4 @@ -/// +/// function registerDelegates() { diff --git a/cordova-plugin-insomnia/cordova-plugin-insomnia-tests.ts b/cordova-plugin-insomnia/cordova-plugin-insomnia-tests.ts index f5bbd6b2ca..a52cc96f8b 100644 --- a/cordova-plugin-insomnia/cordova-plugin-insomnia-tests.ts +++ b/cordova-plugin-insomnia/cordova-plugin-insomnia-tests.ts @@ -1,4 +1,4 @@ -window.plugins.insomnia.allowSleepAgain( +window.plugins.insomnia.allowSleepAgain( () => { console.log("success"); }, () => { console.log("fail"); } ); diff --git a/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts index fa1589c04f..62e44e3e77 100755 --- a/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts +++ b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts @@ -1,4 +1,4 @@ -/// +/// window.plugins.socialsharing.iPadPopupCoordinates = function () { return "100,100,200,300"; diff --git a/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts b/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts index fec3c119d2..29451c4753 100644 --- a/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts +++ b/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts @@ -1,4 +1,4 @@ -/// +/// cordova.plugins.diagnostic.isLocationAvailable(function(available){ console.log("Location is " + (available ? "available" : "not available")); diff --git a/core-js/core-js-tests.ts b/core-js/core-js-tests.ts index 08370370a0..42cd770b86 100644 --- a/core-js/core-js-tests.ts +++ b/core-js/core-js-tests.ts @@ -1,4 +1,4 @@ - + interface Point { x: number; y: number; } interface Point3D extends Point { z: number; } diff --git a/d3-dsv/v0/index.d.ts b/d3-dsv/v0/index.d.ts index b798c4fcbe..ce39d46468 100644 --- a/d3-dsv/v0/index.d.ts +++ b/d3-dsv/v0/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for d3-dsv +// Type definitions for d3-dsv // Project: https://www.npmjs.com/package/d3-dsv // Definitions by: Jason Swearingen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/d3.cloud.layout/d3.cloud.layout-tests.ts b/d3.cloud.layout/d3.cloud.layout-tests.ts index 489af26357..b2e0349cd4 100644 --- a/d3.cloud.layout/d3.cloud.layout-tests.ts +++ b/d3.cloud.layout/d3.cloud.layout-tests.ts @@ -1,4 +1,4 @@ -/// +/// interface ICompTextSize{ text:string; diff --git a/depd/depd-tests.ts b/depd/depd-tests.ts index 99330a757d..62a4470f15 100644 --- a/depd/depd-tests.ts +++ b/depd/depd-tests.ts @@ -1,4 +1,4 @@ -import depd = require('depd'); +import depd = require('depd'); var deprecate = depd("depd-tests"); diff --git a/devexpress-web/devexpress-web-tests.ts b/devexpress-web/devexpress-web-tests.ts index 0f182ad19a..8a76a68f26 100644 --- a/devexpress-web/devexpress-web-tests.ts +++ b/devexpress-web/devexpress-web-tests.ts @@ -1,4 +1,4 @@ -/// +/// declare var hiddenField: ASPxClientHiddenField; declare var mainCallbackPanel: ASPxClientCallbackPanel; diff --git a/documentdb-server/documentdb-server-tests.ts b/documentdb-server/documentdb-server-tests.ts index 0cc3dc55bd..aa5c45b73d 100644 --- a/documentdb-server/documentdb-server-tests.ts +++ b/documentdb-server/documentdb-server-tests.ts @@ -1,4 +1,4 @@ - + // Samples taken from http://dl.windowsazure.com/documentDB/jsserverdocs/Collection.html function chain() { diff --git a/dojo/dojox.NodeList.d.ts b/dojo/dojox.NodeList.d.ts index 8718756b5c..ae2d2db3bb 100644 --- a/dojo/dojox.NodeList.d.ts +++ b/dojo/dojox.NodeList.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.analytics.d.ts b/dojo/dojox.analytics.d.ts index 7ed7a5f3b5..c18b00d74f 100644 --- a/dojo/dojox.analytics.d.ts +++ b/dojo/dojox.analytics.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.app.d.ts b/dojo/dojox.app.d.ts index add6a1dbb8..3115a55ea1 100644 --- a/dojo/dojox.app.d.ts +++ b/dojo/dojox.app.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.atom.d.ts b/dojo/dojox.atom.d.ts index 8990f88ac0..7a1025e671 100644 --- a/dojo/dojox.atom.d.ts +++ b/dojo/dojox.atom.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.av.d.ts b/dojo/dojox.av.d.ts index be7e88fe8d..81bcb769d5 100644 --- a/dojo/dojox.av.d.ts +++ b/dojo/dojox.av.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.calc.d.ts b/dojo/dojox.calc.d.ts index 6d67f544c6..3ab996cc27 100644 --- a/dojo/dojox.calc.d.ts +++ b/dojo/dojox.calc.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.calendar.d.ts b/dojo/dojox.calendar.d.ts index 87230e3195..d4e54d7afb 100644 --- a/dojo/dojox.calendar.d.ts +++ b/dojo/dojox.calendar.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.charting.d.ts b/dojo/dojox.charting.d.ts index 4e543d0eaa..0f69eee3d4 100644 --- a/dojo/dojox.charting.d.ts +++ b/dojo/dojox.charting.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.collections.d.ts b/dojo/dojox.collections.d.ts index 61f9f35fb1..1da50a5cd3 100644 --- a/dojo/dojox.collections.d.ts +++ b/dojo/dojox.collections.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.color.d.ts b/dojo/dojox.color.d.ts index 0ea9b03dd4..2d306bb1d2 100644 --- a/dojo/dojox.color.d.ts +++ b/dojo/dojox.color.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.css3.d.ts b/dojo/dojox.css3.d.ts index 43c2b3fe62..cfb67cd222 100644 --- a/dojo/dojox.css3.d.ts +++ b/dojo/dojox.css3.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.data.d.ts b/dojo/dojox.data.d.ts index 54b143462a..a5f7b48369 100644 --- a/dojo/dojox.data.d.ts +++ b/dojo/dojox.data.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.date.d.ts b/dojo/dojox.date.d.ts index 2fc28fd591..d67dad871d 100644 --- a/dojo/dojox.date.d.ts +++ b/dojo/dojox.date.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.dgauges.d.ts b/dojo/dojox.dgauges.d.ts index cbbfd2ecab..fa7c573fed 100644 --- a/dojo/dojox.dgauges.d.ts +++ b/dojo/dojox.dgauges.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.dnd.d.ts b/dojo/dojox.dnd.d.ts index fc7474d005..0168bc2d11 100644 --- a/dojo/dojox.dnd.d.ts +++ b/dojo/dojox.dnd.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.drawing.d.ts b/dojo/dojox.drawing.d.ts index 211acc9bb0..c2130d4898 100644 --- a/dojo/dojox.drawing.d.ts +++ b/dojo/dojox.drawing.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.dtl.d.ts b/dojo/dojox.dtl.d.ts index f6355a2084..07bbacaed6 100644 --- a/dojo/dojox.dtl.d.ts +++ b/dojo/dojox.dtl.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.editor.d.ts b/dojo/dojox.editor.d.ts index 19eceb9390..54fc087fb5 100644 --- a/dojo/dojox.editor.d.ts +++ b/dojo/dojox.editor.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.embed.d.ts b/dojo/dojox.embed.d.ts index fcb41822ee..55b4f994ca 100644 --- a/dojo/dojox.embed.d.ts +++ b/dojo/dojox.embed.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.encoding.d.ts b/dojo/dojox.encoding.d.ts index 9b823723aa..871971888e 100644 --- a/dojo/dojox.encoding.d.ts +++ b/dojo/dojox.encoding.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.flash.d.ts b/dojo/dojox.flash.d.ts index 17679a18d0..0bc0efd887 100644 --- a/dojo/dojox.flash.d.ts +++ b/dojo/dojox.flash.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.form.d.ts b/dojo/dojox.form.d.ts index 8de71b1d1f..5fc071bb2d 100644 --- a/dojo/dojox.form.d.ts +++ b/dojo/dojox.form.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.fx.d.ts b/dojo/dojox.fx.d.ts index 50e735fee6..07f1e3f7d0 100644 --- a/dojo/dojox.fx.d.ts +++ b/dojo/dojox.fx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.gantt.d.ts b/dojo/dojox.gantt.d.ts index d41a30ba44..d82babe11a 100644 --- a/dojo/dojox.gantt.d.ts +++ b/dojo/dojox.gantt.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.gauges.d.ts b/dojo/dojox.gauges.d.ts index 2bd28edeb2..8f8e8e6c93 100644 --- a/dojo/dojox.gauges.d.ts +++ b/dojo/dojox.gauges.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.geo.d.ts b/dojo/dojox.geo.d.ts index b28314b758..f572e250a1 100644 --- a/dojo/dojox.geo.d.ts +++ b/dojo/dojox.geo.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.gesture.d.ts b/dojo/dojox.gesture.d.ts index b1cd948db3..4e9c1224ec 100644 --- a/dojo/dojox.gesture.d.ts +++ b/dojo/dojox.gesture.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.gfx.d.ts b/dojo/dojox.gfx.d.ts index 1fb6612aea..6a676431d1 100644 --- a/dojo/dojox.gfx.d.ts +++ b/dojo/dojox.gfx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.gfx3d.d.ts b/dojo/dojox.gfx3d.d.ts index 0d8388f39f..42483ab8d4 100644 --- a/dojo/dojox.gfx3d.d.ts +++ b/dojo/dojox.gfx3d.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.grid.d.ts b/dojo/dojox.grid.d.ts index 53ad4424c0..33088bcb17 100644 --- a/dojo/dojox.grid.d.ts +++ b/dojo/dojox.grid.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.help.d.ts b/dojo/dojox.help.d.ts index 3dcc4761fd..a97a9bad17 100644 --- a/dojo/dojox.help.d.ts +++ b/dojo/dojox.help.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.highlight.d.ts b/dojo/dojox.highlight.d.ts index f33c32b81e..f541f93ee3 100644 --- a/dojo/dojox.highlight.d.ts +++ b/dojo/dojox.highlight.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.html.d.ts b/dojo/dojox.html.d.ts index cd97ffebf7..a116cff33e 100644 --- a/dojo/dojox.html.d.ts +++ b/dojo/dojox.html.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.image.d.ts b/dojo/dojox.image.d.ts index 4dd000ca6f..d0f6f28e2b 100644 --- a/dojo/dojox.image.d.ts +++ b/dojo/dojox.image.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.io.d.ts b/dojo/dojox.io.d.ts index d37ed6659c..cb6ce24251 100644 --- a/dojo/dojox.io.d.ts +++ b/dojo/dojox.io.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.jq.d.ts b/dojo/dojox.jq.d.ts index a63f4075de..073bfe7b53 100644 --- a/dojo/dojox.jq.d.ts +++ b/dojo/dojox.jq.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.json.d.ts b/dojo/dojox.json.d.ts index 1aa4a492cd..7f8e26e5b5 100644 --- a/dojo/dojox.json.d.ts +++ b/dojo/dojox.json.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.jsonPath.d.ts b/dojo/dojox.jsonPath.d.ts index f76fcc98b6..bc2125e5cc 100644 --- a/dojo/dojox.jsonPath.d.ts +++ b/dojo/dojox.jsonPath.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.lang.d.ts b/dojo/dojox.lang.d.ts index e31e6d2922..4774941552 100644 --- a/dojo/dojox.lang.d.ts +++ b/dojo/dojox.lang.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.layout.d.ts b/dojo/dojox.layout.d.ts index aa056eae59..026b64ed9e 100644 --- a/dojo/dojox.layout.d.ts +++ b/dojo/dojox.layout.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.main.d.ts b/dojo/dojox.main.d.ts index abc3b6a031..9f7f830f1f 100644 --- a/dojo/dojox.main.d.ts +++ b/dojo/dojox.main.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.math.d.ts b/dojo/dojox.math.d.ts index 88f411c6d7..668f4260cf 100644 --- a/dojo/dojox.math.d.ts +++ b/dojo/dojox.math.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.mdnd.d.ts b/dojo/dojox.mdnd.d.ts index e8fd4b7e84..ce71f1727e 100644 --- a/dojo/dojox.mdnd.d.ts +++ b/dojo/dojox.mdnd.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.mobile.d.ts b/dojo/dojox.mobile.d.ts index 03e8b2714c..beabf49d39 100644 --- a/dojo/dojox.mobile.d.ts +++ b/dojo/dojox.mobile.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.mvc.d.ts b/dojo/dojox.mvc.d.ts index 292eb0d355..73395d8589 100644 --- a/dojo/dojox.mvc.d.ts +++ b/dojo/dojox.mvc.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.rails.d.ts b/dojo/dojox.rails.d.ts index e175b01de3..f874ae14e9 100644 --- a/dojo/dojox.rails.d.ts +++ b/dojo/dojox.rails.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.robot.d.ts b/dojo/dojox.robot.d.ts index 5ec5833cab..ad55a30bc9 100644 --- a/dojo/dojox.robot.d.ts +++ b/dojo/dojox.robot.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.rpc.d.ts b/dojo/dojox.rpc.d.ts index 3bb8757e1a..018094eb1d 100644 --- a/dojo/dojox.rpc.d.ts +++ b/dojo/dojox.rpc.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.secure.d.ts b/dojo/dojox.secure.d.ts index 77e5d66342..7ff0efbba5 100644 --- a/dojo/dojox.secure.d.ts +++ b/dojo/dojox.secure.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.sketch.d.ts b/dojo/dojox.sketch.d.ts index ed0030e743..abf242063b 100644 --- a/dojo/dojox.sketch.d.ts +++ b/dojo/dojox.sketch.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.socket.d.ts b/dojo/dojox.socket.d.ts index a26e398763..8458f1bd87 100644 --- a/dojo/dojox.socket.d.ts +++ b/dojo/dojox.socket.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.sql.d.ts b/dojo/dojox.sql.d.ts index 418c7474d2..46e5e940d0 100644 --- a/dojo/dojox.sql.d.ts +++ b/dojo/dojox.sql.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.string.d.ts b/dojo/dojox.string.d.ts index 0b437d7a14..ee897d378f 100644 --- a/dojo/dojox.string.d.ts +++ b/dojo/dojox.string.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.testing.d.ts b/dojo/dojox.testing.d.ts index 03f5478faf..7f2d3e57b8 100644 --- a/dojo/dojox.testing.d.ts +++ b/dojo/dojox.testing.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.timing.d.ts b/dojo/dojox.timing.d.ts index 61137f5e24..7bf71b2ff1 100644 --- a/dojo/dojox.timing.d.ts +++ b/dojo/dojox.timing.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.treemap.d.ts b/dojo/dojox.treemap.d.ts index 917a23ebf4..bf30422406 100644 --- a/dojo/dojox.treemap.d.ts +++ b/dojo/dojox.treemap.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.uuid.d.ts b/dojo/dojox.uuid.d.ts index 7ca4075ca6..be068b31a2 100644 --- a/dojo/dojox.uuid.d.ts +++ b/dojo/dojox.uuid.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.validate.d.ts b/dojo/dojox.validate.d.ts index 4d144d5e43..9e4461f667 100644 --- a/dojo/dojox.validate.d.ts +++ b/dojo/dojox.validate.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.widget.d.ts b/dojo/dojox.widget.d.ts index f0ec86f0f1..9e8ce6563e 100644 --- a/dojo/dojox.widget.d.ts +++ b/dojo/dojox.widget.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dojo/dojox.xml.d.ts b/dojo/dojox.xml.d.ts index 215a16ad59..e28e419c5b 100644 --- a/dojo/dojox.xml.d.ts +++ b/dojo/dojox.xml.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dojo v1.9 +// Type definitions for Dojo v1.9 // Project: http://dojotoolkit.org // Definitions by: Michael Van Sickle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/dot/dot-tests.ts b/dot/dot-tests.ts index fb189e3c34..0987f9eb46 100644 --- a/dot/dot-tests.ts +++ b/dot/dot-tests.ts @@ -1,4 +1,4 @@ - + var headertmpl = "

{{=it.title}}

"; diff --git a/electron/github-electron-main-tests.ts b/electron/github-electron-main-tests.ts index ce5bbf8e2e..9912b62eea 100644 --- a/electron/github-electron-main-tests.ts +++ b/electron/github-electron-main-tests.ts @@ -1,4 +1,4 @@ - + import { app, autoUpdater, diff --git a/electron/github-electron-renderer-tests.ts b/electron/github-electron-renderer-tests.ts index ad07c6c0e6..1d1da23069 100644 --- a/electron/github-electron-renderer-tests.ts +++ b/electron/github-electron-renderer-tests.ts @@ -1,4 +1,4 @@ - + import { ipcRenderer, remote, diff --git a/flight/flight-tests.ts b/flight/flight-tests.ts index d96b19221c..bd2f22d1c3 100644 --- a/flight/flight-tests.ts +++ b/flight/flight-tests.ts @@ -1,4 +1,4 @@ - + declare var el: Element; declare var els: Element[]; declare var mixinFn: Function; diff --git a/flux/flux-tests.ts b/flux/flux-tests.ts index c2a3a6c90a..57c8fb3b20 100644 --- a/flux/flux-tests.ts +++ b/flux/flux-tests.ts @@ -1,4 +1,4 @@ -import flux = require('flux') +import flux = require('flux') import FluxUtils = require('flux/utils') import React = require('react') diff --git a/fromjs/fromjs-tests.ts b/fromjs/fromjs-tests.ts index b0e4ada0bf..090fba87fc 100644 --- a/fromjs/fromjs-tests.ts +++ b/fromjs/fromjs-tests.ts @@ -1,4 +1,4 @@ - + var array = [1, 2, 3, 4]; from(array).each(function (value, key) { console.log('Value ' + value + ' at index ' + key); diff --git a/gridstack/gridstack-tests.ts b/gridstack/gridstack-tests.ts index 7ad4877f5b..96aa14b19f 100644 --- a/gridstack/gridstack-tests.ts +++ b/gridstack/gridstack-tests.ts @@ -1,4 +1,4 @@ -/// +/// diff --git a/gsap/gsap-tests.ts b/gsap/gsap-tests.ts index 885e00c765..49d5ce19d0 100644 --- a/gsap/gsap-tests.ts +++ b/gsap/gsap-tests.ts @@ -1,4 +1,4 @@ - + var tween = TweenLite .to(document.getElementById('some-div'), 1, { diff --git a/gulp-util/gulp-util-tests.ts b/gulp-util/gulp-util-tests.ts index 0616401310..651f9bff9b 100644 --- a/gulp-util/gulp-util-tests.ts +++ b/gulp-util/gulp-util-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// import gulp = require('gulp'); diff --git a/hellosign-embedded/hellosign-embedded-tests.ts b/hellosign-embedded/hellosign-embedded-tests.ts index a5685aa065..281bbef2ab 100644 --- a/hellosign-embedded/hellosign-embedded-tests.ts +++ b/hellosign-embedded/hellosign-embedded-tests.ts @@ -1,4 +1,4 @@ -HelloSign.init('abc123'); +HelloSign.init('abc123'); // some options HelloSign.open({ diff --git a/http-string-parser/http-string-parser-tests.ts b/http-string-parser/http-string-parser-tests.ts index 4d7526dc49..51fa0d5cef 100644 --- a/http-string-parser/http-string-parser-tests.ts +++ b/http-string-parser/http-string-parser-tests.ts @@ -1,4 +1,4 @@ -import parser = require("http-string-parser"); +import parser = require("http-string-parser"); function test_request(): void { var result = parser.parseRequest("HTTP/1.1 GET /\r\nHost: www.example.com\r\n\r\n"); diff --git a/httperr/httperr-tests.ts b/httperr/httperr-tests.ts index e0b186549a..ee1f6d8567 100644 --- a/httperr/httperr-tests.ts +++ b/httperr/httperr-tests.ts @@ -1,4 +1,4 @@ -import httperr = require('httperr'); +import httperr = require('httperr'); // ---------------------------------------- // Basic usage example from: https://github.com/pluma/httperr/blob/1.0.0/README.md diff --git a/hypertext-application-language/hypertext-application-language-tests.ts b/hypertext-application-language/hypertext-application-language-tests.ts index 652b467d1a..509facb82f 100644 --- a/hypertext-application-language/hypertext-application-language-tests.ts +++ b/hypertext-application-language/hypertext-application-language-tests.ts @@ -1,4 +1,4 @@ -// Link object +// Link object // Fields format: var link:Hal.Link = { diff --git a/is/is_js-tests.ts b/is/is_js-tests.ts index fd0dee9c1f..674d5ff761 100644 --- a/is/is_js-tests.ts +++ b/is/is_js-tests.ts @@ -1,4 +1,4 @@ - + //#region Type checks diff --git a/ix.js/l2o-tests.ts b/ix.js/l2o-tests.ts index 41cc7bdc49..7b35b71a9e 100644 --- a/ix.js/l2o-tests.ts +++ b/ix.js/l2o-tests.ts @@ -1,4 +1,4 @@ -/// +/// var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string var ec_nn = (a: number, b: number) => a === b; //equality comparer on number,number diff --git a/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts b/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts index e14f89b7ad..27509d7383 100644 --- a/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts +++ b/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts @@ -1,4 +1,4 @@ - + /// all("A data driven test is a suite with multiple specs", diff --git a/jointjs/README.md b/jointjs/README.md index c15dce6c58..0974814b34 100644 --- a/jointjs/README.md +++ b/jointjs/README.md @@ -1,4 +1,4 @@ -# JointJS Definitions Usage Notes +# JointJS Definitions Usage Notes TypeScript definitions for the JointJS framework available at http://www.jointjs.com diff --git a/jqgrid/jqgrid-tests.ts b/jqgrid/jqgrid-tests.ts index 0d64c59fe1..7354f527dc 100644 --- a/jqgrid/jqgrid-tests.ts +++ b/jqgrid/jqgrid-tests.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery jqgrid Plugin 1.3 +// Type definitions for jQuery jqgrid Plugin 1.3 // Definitions by: Lokesh Peta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/jquery-jsonrpcclient/jquery-jsonrpcclient-tests.ts b/jquery-jsonrpcclient/jquery-jsonrpcclient-tests.ts index 30596aa477..f680dbb688 100644 --- a/jquery-jsonrpcclient/jquery-jsonrpcclient-tests.ts +++ b/jquery-jsonrpcclient/jquery-jsonrpcclient-tests.ts @@ -1,4 +1,4 @@ -/// +/// var foo = new $.JsonRpcClient({ ajaxUrl: '/backend/jsonrpc' }); foo.call( diff --git a/jquery-mousewheel/jquery-mousewheel-tests.ts b/jquery-mousewheel/jquery-mousewheel-tests.ts index 706906b2ee..42b8382de9 100644 --- a/jquery-mousewheel/jquery-mousewheel-tests.ts +++ b/jquery-mousewheel/jquery-mousewheel-tests.ts @@ -1,4 +1,4 @@ -$('#my_elem').on('mousewheel', (event: JQueryMousewheel.JQueryMousewheelEventObject) => { +$('#my_elem').on('mousewheel', (event: JQueryMousewheel.JQueryMousewheelEventObject) => { console.log(event.deltaX, event.deltaY, event.deltaFactor, event.deltaMode, event.absDelta); }); diff --git a/jquery-validation-unobtrusive/jquery-validation-unobtrusive-tests.ts b/jquery-validation-unobtrusive/jquery-validation-unobtrusive-tests.ts index ac57a4130a..6f1fb65bba 100644 --- a/jquery-validation-unobtrusive/jquery-validation-unobtrusive-tests.ts +++ b/jquery-validation-unobtrusive/jquery-validation-unobtrusive-tests.ts @@ -1,4 +1,4 @@ - + // Test overloads for `add` method $.validator.unobtrusive.adapters.add("adapter", () => { }); diff --git a/jquery.are-you-sure/jquery.are-you-sure-tests.ts b/jquery.are-you-sure/jquery.are-you-sure-tests.ts index 4e10c1429f..cd400f90c1 100644 --- a/jquery.are-you-sure/jquery.are-you-sure-tests.ts +++ b/jquery.are-you-sure/jquery.are-you-sure-tests.ts @@ -1,4 +1,4 @@ -// Type definitions for jquery.are-you-sure.js +// Type definitions for jquery.are-you-sure.js // Project: https://github.com/codedance/jquery.AreYouSure // Definitions by: Jon Egerton // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/jquery.blockui/jquery.blockUI-tests.ts b/jquery.blockui/jquery.blockUI-tests.ts index 325ec6dc26..c24230a093 100644 --- a/jquery.blockui/jquery.blockUI-tests.ts +++ b/jquery.blockui/jquery.blockUI-tests.ts @@ -1,4 +1,4 @@ - + $.blockUI(); var opt: JQBlockUIOptions = { diff --git a/jquery.colorbox/jquery.colorbox-tests.ts b/jquery.colorbox/jquery.colorbox-tests.ts index 48762f9e9c..66d54240db 100644 --- a/jquery.colorbox/jquery.colorbox-tests.ts +++ b/jquery.colorbox/jquery.colorbox-tests.ts @@ -1,4 +1,4 @@ -/// +/// //Image gallery var gallery : JQuery = $('a.gallery').colorbox({ rel: 'gal' }); diff --git a/jquery.fancytree/jquery.fancytree-tests.ts b/jquery.fancytree/jquery.fancytree-tests.ts index 8e1c4a1603..4fa52c790a 100644 --- a/jquery.fancytree/jquery.fancytree-tests.ts +++ b/jquery.fancytree/jquery.fancytree-tests.ts @@ -1,4 +1,4 @@ -$("#tree").fancytree({ +$("#tree").fancytree({ source: [ { title: "Node 1", key: "1" }, { diff --git a/jquery.finger/jquery.finger-tests.ts b/jquery.finger/jquery.finger-tests.ts index f0e8457dbf..3f35e7322c 100644 --- a/jquery.finger/jquery.finger-tests.ts +++ b/jquery.finger/jquery.finger-tests.ts @@ -1,4 +1,4 @@ -/// +/// $.Finger.doubleTapInterval = 400; $.Finger.flickDuration = 250; diff --git a/jquery.menuaim/jquery.menuaim-tests.ts b/jquery.menuaim/jquery.menuaim-tests.ts index d1f83e322e..e2a1b36aff 100644 --- a/jquery.menuaim/jquery.menuaim-tests.ts +++ b/jquery.menuaim/jquery.menuaim-tests.ts @@ -1,4 +1,4 @@ -/// +/// $('div').menuAim({ activate: function () { }, diff --git a/jquery.pjax.falsandtru/jquery.pjax-tests.ts b/jquery.pjax.falsandtru/jquery.pjax-tests.ts index 33a3efa5cf..8bfb91a27e 100644 --- a/jquery.pjax.falsandtru/jquery.pjax-tests.ts +++ b/jquery.pjax.falsandtru/jquery.pjax-tests.ts @@ -1,4 +1,4 @@ - + /// function test_pjax() { diff --git a/jquery.postmessage/jquery.postMessage-tests.ts b/jquery.postmessage/jquery.postMessage-tests.ts index f7db3a8f50..9c9ae62f4f 100644 --- a/jquery.postmessage/jquery.postMessage-tests.ts +++ b/jquery.postmessage/jquery.postMessage-tests.ts @@ -1,4 +1,4 @@ - + /// function test_postMessage() { diff --git a/jquery.prettyphoto/jquery.prettyphoto-tests.ts b/jquery.prettyphoto/jquery.prettyphoto-tests.ts index 54198cc265..4fcbf9ecdf 100644 --- a/jquery.prettyphoto/jquery.prettyphoto-tests.ts +++ b/jquery.prettyphoto/jquery.prettyphoto-tests.ts @@ -1,4 +1,4 @@ -// Tests for prettyPhoto library +// Tests for prettyPhoto library /// diff --git a/jquery.timeago/jquery.timeago-tests.ts b/jquery.timeago/jquery.timeago-tests.ts index 86abc6fe59..2a852331be 100644 --- a/jquery.timeago/jquery.timeago-tests.ts +++ b/jquery.timeago/jquery.timeago-tests.ts @@ -1,4 +1,4 @@ -/// +/// // Basic usage diff --git a/jsnlog/jsnlog-tests.ts b/jsnlog/jsnlog-tests.ts index 128ad65421..db2b2a2523 100644 --- a/jsnlog/jsnlog-tests.ts +++ b/jsnlog/jsnlog-tests.ts @@ -1,4 +1,4 @@ - + // ---------------------------------------------------------- // JL diff --git a/jstree/jstree-tests.ts b/jstree/jstree-tests.ts index bd35406c71..208ae9b979 100644 --- a/jstree/jstree-tests.ts +++ b/jstree/jstree-tests.ts @@ -1,4 +1,4 @@ - + // gets version of lib var version: string = $.jstree.version; diff --git a/jsts/jsts-tests.ts b/jsts/jsts-tests.ts index 63ca42bc90..20c536ce89 100644 --- a/jsts/jsts-tests.ts +++ b/jsts/jsts-tests.ts @@ -1,4 +1,4 @@ - + import * as jsts from 'jsts'; diff --git a/knockout.deferred.updates/knockout.deferred.updates-tests.ts b/knockout.deferred.updates/knockout.deferred.updates-tests.ts index b60e63afa2..42971a34b2 100644 --- a/knockout.deferred.updates/knockout.deferred.updates-tests.ts +++ b/knockout.deferred.updates/knockout.deferred.updates-tests.ts @@ -1,4 +1,4 @@ - + // Turn *off* deferred updates for computed observables and subscriptions ko.computed.deferUpdates = false; diff --git a/knockout.punches/knockout.punches-tests.ts b/knockout.punches/knockout.punches-tests.ts index 65c8ae3f10..1de89ca570 100644 --- a/knockout.punches/knockout.punches-tests.ts +++ b/knockout.punches/knockout.punches-tests.ts @@ -1,4 +1,4 @@ -/// +/// function test_enable() { diff --git a/ladda/ladda-tests.ts b/ladda/ladda-tests.ts index 15a263f437..2e5af02510 100644 --- a/ladda/ladda-tests.ts +++ b/ladda/ladda-tests.ts @@ -1,4 +1,4 @@ - + // Automatically trigger the loading animation on click Ladda.bind('input[type=submit]'); diff --git a/later/later-tests.ts b/later/later-tests.ts index 6ad634505c..1d8c272f1b 100644 --- a/later/later-tests.ts +++ b/later/later-tests.ts @@ -1,4 +1,4 @@ -import later = require("later"); +import later = require("later"); namespace LaterTest_DefineSchedule { diff --git a/less/less-tests.ts b/less/less-tests.ts index fcd09767a8..1668c965fa 100644 --- a/less/less-tests.ts +++ b/less/less-tests.ts @@ -1,4 +1,4 @@ - + import less = require("less"); diff --git a/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts b/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts index 8778e6ac16..37f7820888 100644 --- a/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts +++ b/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts @@ -1,4 +1,4 @@ - + declare var cordovaSQLiteDriver: LocalForageDriver; () => { diff --git a/localforage/localForage-tests.ts b/localforage/localForage-tests.ts index 6279cbdf89..e3edeba2d0 100644 --- a/localforage/localForage-tests.ts +++ b/localforage/localForage-tests.ts @@ -1,4 +1,4 @@ - + declare let localForage: LocalForage; diff --git a/log4javascript/log4javascript-tests.ts b/log4javascript/log4javascript-tests.ts index 910ab1f4cc..3ba497b890 100644 --- a/log4javascript/log4javascript-tests.ts +++ b/log4javascript/log4javascript-tests.ts @@ -1,4 +1,4 @@ - + function aSimpleLoggingMessageString() { var log = log4javascript.getDefaultLogger(); diff --git a/lokijs/lokijs-tests.ts b/lokijs/lokijs-tests.ts index 435a061852..a020b27535 100644 --- a/lokijs/lokijs-tests.ts +++ b/lokijs/lokijs-tests.ts @@ -1,4 +1,4 @@ - + import Loki = require("lokijs"); diff --git a/lscache/lscache-tests.ts b/lscache/lscache-tests.ts index 7ff0f96dbb..5a97501160 100644 --- a/lscache/lscache-tests.ts +++ b/lscache/lscache-tests.ts @@ -1,4 +1,4 @@ - + // Copied examples directly from lscache github site with slight modifications alert(lscache.supported()); diff --git a/lz-string/lz-string-tests.ts b/lz-string/lz-string-tests.ts index 131bce2105..e9bffed120 100644 --- a/lz-string/lz-string-tests.ts +++ b/lz-string/lz-string-tests.ts @@ -1,4 +1,4 @@ - + var input = "Someting to compress"; var encoded: string; diff --git a/magicsuggest/magicsuggest-tests.ts b/magicsuggest/magicsuggest-tests.ts index ab76034122..46cb799d25 100644 --- a/magicsuggest/magicsuggest-tests.ts +++ b/magicsuggest/magicsuggest-tests.ts @@ -1,4 +1,4 @@ -/// +/// function basicTest() { $('#magicSuggest').magicSuggest(); diff --git a/maskedinput/maskedinput-tests.ts b/maskedinput/maskedinput-tests.ts index 766eda8f9b..6d620ce1b9 100644 --- a/maskedinput/maskedinput-tests.ts +++ b/maskedinput/maskedinput-tests.ts @@ -1,4 +1,4 @@ -// Type definitions for Masked Input plugin for jQuery +// Type definitions for Masked Input plugin for jQuery // Project: http://digitalbush.com/projects/masked-input-plugin // Definitions by: Lokesh Peta // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/merge-descriptors/merge-descriptors-tests.ts b/merge-descriptors/merge-descriptors-tests.ts index 6a5770e178..ca2e326f3b 100644 --- a/merge-descriptors/merge-descriptors-tests.ts +++ b/merge-descriptors/merge-descriptors-tests.ts @@ -1,4 +1,4 @@ -import mixin = require('merge-descriptors'); +import mixin = require('merge-descriptors'); function testAssertion(condition: boolean, errorMessage: string) { if (!condition) { diff --git a/minilog/minilog-tests.ts b/minilog/minilog-tests.ts index adf7c63ed1..8f319ff6ec 100644 --- a/minilog/minilog-tests.ts +++ b/minilog/minilog-tests.ts @@ -1,4 +1,4 @@ -// Type definitions for minilog v2 +// Type definitions for minilog v2 // Project: https://github.com/mixu/minilog // Definitions by: Guido // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/mysql/mysql-tests.ts b/mysql/mysql-tests.ts index 1fdf7b9929..84c501e147 100644 --- a/mysql/mysql-tests.ts +++ b/mysql/mysql-tests.ts @@ -1,4 +1,4 @@ -import fs = require('fs'); +import fs = require('fs'); import mysql = require('mysql'); import stream = require('stream'); diff --git a/ng-file-upload/ng-file-upload-tests.ts b/ng-file-upload/ng-file-upload-tests.ts index 3f3f264c2b..7252231661 100644 --- a/ng-file-upload/ng-file-upload-tests.ts +++ b/ng-file-upload/ng-file-upload-tests.ts @@ -1,4 +1,4 @@ -import * as angular from 'angular'; +import * as angular from 'angular'; "use strict"; diff --git a/ngprogress-lite/ngprogress-lite-tests.ts b/ngprogress-lite/ngprogress-lite-tests.ts index d305595e23..c7df7f9b6b 100644 --- a/ngprogress-lite/ngprogress-lite-tests.ts +++ b/ngprogress-lite/ngprogress-lite-tests.ts @@ -1,4 +1,4 @@ -/// +/// var app = angular.module('testApp', ['ngProgressLite']); diff --git a/ngprogress/ngprogress-tests.ts b/ngprogress/ngprogress-tests.ts index c1c2875d79..e250e9cb0e 100644 --- a/ngprogress/ngprogress-tests.ts +++ b/ngprogress/ngprogress-tests.ts @@ -1,4 +1,4 @@ - + var ngProgress: NgProgress.INgProgress = {}; diff --git a/nopt/nopt-tests.ts b/nopt/nopt-tests.ts index fe014dcb33..f73a3d6159 100644 --- a/nopt/nopt-tests.ts +++ b/nopt/nopt-tests.ts @@ -1,4 +1,4 @@ -/** +/** * Maintained by: jbondc */ diff --git a/notify.js/notify.js.tests.ts b/notify.js/notify.js.tests.ts index c824a6b37b..cf985a891f 100644 --- a/notify.js/notify.js.tests.ts +++ b/notify.js/notify.js.tests.ts @@ -1,4 +1,4 @@ -// setting defaults for notification plugin +// setting defaults for notification plugin $.notify.defaults({ clickToHide: true, autoHide: false, diff --git a/npm/npm-tests.ts b/npm/npm-tests.ts index f288b2fc2a..ccebbdb35a 100644 --- a/npm/npm-tests.ts +++ b/npm/npm-tests.ts @@ -1,4 +1,4 @@ -/** +/** * Test suite created by Maxime LUCE * * Created by using code samples from https://github.com/npm/npm#using-npm-programmatically. diff --git a/nvd3/nvd3-test-candlestick.ts b/nvd3/nvd3-test-candlestick.ts index 6aed19f1a3..933316df19 100644 --- a/nvd3/nvd3-test-candlestick.ts +++ b/nvd3/nvd3-test-candlestick.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_candlestick { var data = [{ values: [ diff --git a/nvd3/nvd3-test-candlestickChart.ts b/nvd3/nvd3-test-candlestickChart.ts index b282f0f522..1b9b277568 100644 --- a/nvd3/nvd3-test-candlestickChart.ts +++ b/nvd3/nvd3-test-candlestickChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_candlestickChart { var data = [{ values: [ diff --git a/nvd3/nvd3-test-cumulativeLineChart.ts b/nvd3/nvd3-test-cumulativeLineChart.ts index e004534615..5a16e28695 100644 --- a/nvd3/nvd3-test-cumulativeLineChart.ts +++ b/nvd3/nvd3-test-cumulativeLineChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_cumulativeLineChart { // Wrapping in nv.addGraph allows for '0 timeout render', stores rendered charts in nv.graphs, // and may do more in the future... it's NOT required diff --git a/nvd3/nvd3-test-discreteBarChart.ts b/nvd3/nvd3-test-discreteBarChart.ts index 65e8ba41ca..2f31a29a0c 100644 --- a/nvd3/nvd3-test-discreteBarChart.ts +++ b/nvd3/nvd3-test-discreteBarChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_discreteBarChart { var historicalBarChart = [ { diff --git a/nvd3/nvd3-test-donutChart.ts b/nvd3/nvd3-test-donutChart.ts index c36b6d9ba5..2215c682f7 100644 --- a/nvd3/nvd3-test-donutChart.ts +++ b/nvd3/nvd3-test-donutChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_donutChart { var testdata = [ { key: "One", y: 5 }, diff --git a/nvd3/nvd3-test-furiousLegend.ts b/nvd3/nvd3-test-furiousLegend.ts index 244dc6f282..5bbc2e38de 100644 --- a/nvd3/nvd3-test-furiousLegend.ts +++ b/nvd3/nvd3-test-furiousLegend.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_furiousLegend { var width = 500, height = 40; diff --git a/nvd3/nvd3-test-line.ts b/nvd3/nvd3-test-line.ts index 048a765efc..f82e250d78 100644 --- a/nvd3/nvd3-test-line.ts +++ b/nvd3/nvd3-test-line.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_line { nv.addGraph({ generate: function () { diff --git a/nvd3/nvd3-test-lineChart.ts b/nvd3/nvd3-test-lineChart.ts index cc355d442e..07b71463e9 100644 --- a/nvd3/nvd3-test-lineChart.ts +++ b/nvd3/nvd3-test-lineChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_lineChart { // Wrapping in nv.addGraph allows for '0 timeout render', stores rendered charts in nv.graphs, and may do more in the future... it's NOT required var chart; diff --git a/nvd3/nvd3-test-lineChartLogScale.ts b/nvd3/nvd3-test-lineChartLogScale.ts index 579342e5fe..73fc28edea 100644 --- a/nvd3/nvd3-test-lineChartLogScale.ts +++ b/nvd3/nvd3-test-lineChartLogScale.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_lineChartLogScale { var chart; var data; diff --git a/nvd3/nvd3-test-lineChartSVGResize.ts b/nvd3/nvd3-test-lineChartSVGResize.ts index ebbebc8840..efc824b187 100644 --- a/nvd3/nvd3-test-lineChartSVGResize.ts +++ b/nvd3/nvd3-test-lineChartSVGResize.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_lineChartSVGResize { nv.addGraph(function () { var chart = nv.models.lineChart(); diff --git a/nvd3/nvd3-test-linePlusBarChart.ts b/nvd3/nvd3-test-linePlusBarChart.ts index feb9a9d474..ec88b315af 100644 --- a/nvd3/nvd3-test-linePlusBarChart.ts +++ b/nvd3/nvd3-test-linePlusBarChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_linePlusBarChart { var testdata = [ { diff --git a/nvd3/nvd3-test-lineWithFocusChart.ts b/nvd3/nvd3-test-lineWithFocusChart.ts index 7ed536a2f6..f98e8336de 100644 --- a/nvd3/nvd3-test-lineWithFocusChart.ts +++ b/nvd3/nvd3-test-lineWithFocusChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_lineWithFocusChart { nv.addGraph(function () { var chart = nv.models.lineWithFocusChart(); diff --git a/nvd3/nvd3-test-lineWithFocusChartx2AxisLabel.ts b/nvd3/nvd3-test-lineWithFocusChartx2AxisLabel.ts index 1b3e2628bc..69026046d4 100644 --- a/nvd3/nvd3-test-lineWithFocusChartx2AxisLabel.ts +++ b/nvd3/nvd3-test-lineWithFocusChartx2AxisLabel.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_lineWithFocusChartx2AxisLabel { nv.addGraph(function () { diff --git a/nvd3/nvd3-test-monitoringChart.ts b/nvd3/nvd3-test-monitoringChart.ts index c8a41df1bd..6ec5f59d68 100644 --- a/nvd3/nvd3-test-monitoringChart.ts +++ b/nvd3/nvd3-test-monitoringChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_monitoringChart { var testdata1 = [ diff --git a/nvd3/nvd3-test-multiChart.ts b/nvd3/nvd3-test-multiChart.ts index 459b69308b..6e809a68f5 100644 --- a/nvd3/nvd3-test-multiChart.ts +++ b/nvd3/nvd3-test-multiChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_multiChart { //todo resolve stream_layersIssue var testdata = stream_layers(9, 10 + Math.random() * 100, .1).map(function (data, i) { // return { diff --git a/nvd3/nvd3-test-multibarChart.ts b/nvd3/nvd3-test-multibarChart.ts index 5ee5e1b76a..19419b2ad7 100644 --- a/nvd3/nvd3-test-multibarChart.ts +++ b/nvd3/nvd3-test-multibarChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_multibarChart { //todo resolve stream_layers var test_data = stream_layers(3, 10 + Math.random() * 100, .1).map(function (data, i) { var test_data = [3, 10 + Math.random() * 100, .1].map(function (data, i) { diff --git a/nvd3/nvd3-test-multibarChart2.ts b/nvd3/nvd3-test-multibarChart2.ts index d2fe6035d2..8ea20a68e1 100644 --- a/nvd3/nvd3-test-multibarChart2.ts +++ b/nvd3/nvd3-test-multibarChart2.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_multibarChart2 { //todo resolve stream_layers var test_data = stream_layers(3, 128, .1).map(function (data, i) { var test_data = [3, 128, .1].map(function (data, i) { diff --git a/nvd3/nvd3-test-multibarHorizontalChart.ts b/nvd3/nvd3-test-multibarHorizontalChart.ts index 85bd14ed1d..748c83e10a 100644 --- a/nvd3/nvd3-test-multibarHorizontalChart.ts +++ b/nvd3/nvd3-test-multibarHorizontalChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_multibarHorizontalChart { var long_short_data = [ { diff --git a/nvd3/nvd3-test-scatter.ts b/nvd3/nvd3-test-scatter.ts index 2939667c07..e9d1595431 100644 --- a/nvd3/nvd3-test-scatter.ts +++ b/nvd3/nvd3-test-scatter.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_scatter { nv.addGraph(function () { diff --git a/nvd3/nvd3-test-scatterChart.ts b/nvd3/nvd3-test-scatterChart.ts index 3175b3e418..ed8a0859a1 100644 --- a/nvd3/nvd3-test-scatterChart.ts +++ b/nvd3/nvd3-test-scatterChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_scatterChart { // register our custom symbols to nvd3 // make sure your path is valid given any size because size scales if the chart scales. diff --git a/nvd3/nvd3-test-scatterPlusLineChart.ts b/nvd3/nvd3-test-scatterPlusLineChart.ts index be89930e65..67459b5593 100644 --- a/nvd3/nvd3-test-scatterPlusLineChart.ts +++ b/nvd3/nvd3-test-scatterPlusLineChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_scatterPlusLineChart { var chart; nv.addGraph(function () { diff --git a/nvd3/nvd3-test-sparkLine.ts b/nvd3/nvd3-test-sparkLine.ts index 35da6b35df..a6c13b00c2 100644 --- a/nvd3/nvd3-test-sparkLine.ts +++ b/nvd3/nvd3-test-sparkLine.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_sparkLine { nv.addGraph({ diff --git a/nvd3/nvd3-test-sparkLinePlus.ts b/nvd3/nvd3-test-sparkLinePlus.ts index e60bddab34..7237260016 100644 --- a/nvd3/nvd3-test-sparkLinePlus.ts +++ b/nvd3/nvd3-test-sparkLinePlus.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_sparkLinePlus { function defaultChartConfig(containerId, data) { nv.addGraph(function () { diff --git a/nvd3/nvd3-test-stackArea.ts b/nvd3/nvd3-test-stackArea.ts index 614397cdcc..6e1a6ec6bc 100644 --- a/nvd3/nvd3-test-stackArea.ts +++ b/nvd3/nvd3-test-stackArea.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_stackArea { nv.addGraph({ generate: function () { diff --git a/nvd3/nvd3-test-stackAreaChart.ts b/nvd3/nvd3-test-stackAreaChart.ts index 2905501819..adf47f3e27 100644 --- a/nvd3/nvd3-test-stackAreaChart.ts +++ b/nvd3/nvd3-test-stackAreaChart.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_stackAreaChart { var histcatexplong = [ { diff --git a/nvd3/nvd3-test-sunburst.ts b/nvd3/nvd3-test-sunburst.ts index dabdee2ae9..54b82fa720 100644 --- a/nvd3/nvd3-test-sunburst.ts +++ b/nvd3/nvd3-test-sunburst.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_sunburst { var chart; diff --git a/nvd3/nvd3-test-timeSeries.ts b/nvd3/nvd3-test-timeSeries.ts index f27a5f9935..a284ddf39f 100644 --- a/nvd3/nvd3-test-timeSeries.ts +++ b/nvd3/nvd3-test-timeSeries.ts @@ -1,4 +1,4 @@ - + namespace nvd3_test_timeSeries { var data = [{ values: [] diff --git a/on-headers/on-headers-tests.ts b/on-headers/on-headers-tests.ts index e9b20c738d..a69f404afe 100644 --- a/on-headers/on-headers-tests.ts +++ b/on-headers/on-headers-tests.ts @@ -1,4 +1,4 @@ -import http = require('http') +import http = require('http') import onHeaders = require('on-headers') http.createServer(onRequest) diff --git a/openlayers/openlayers-3.6.0-tests.ts b/openlayers/openlayers-3.6.0-tests.ts index 52d7535710..93f0c59116 100644 --- a/openlayers/openlayers-3.6.0-tests.ts +++ b/openlayers/openlayers-3.6.0-tests.ts @@ -1,4 +1,4 @@ -/// +/// // Basic type variables for test functions var voidValue: void; diff --git a/openpgp/openpgp-tests.ts b/openpgp/openpgp-tests.ts index 744c76fb53..a4a4200c56 100644 --- a/openpgp/openpgp-tests.ts +++ b/openpgp/openpgp-tests.ts @@ -1,4 +1,4 @@ - + // Open PGP Sample codes diff --git a/page/page-tests.ts b/page/page-tests.ts index 1bd45991b3..9d78998672 100644 --- a/page/page-tests.ts +++ b/page/page-tests.ts @@ -1,4 +1,4 @@ - + import page = require("page"); diff --git a/pixi-spine/pixi-spine-tests.ts b/pixi-spine/pixi-spine-tests.ts index 55478c3392..2f945ecbcc 100644 --- a/pixi-spine/pixi-spine-tests.ts +++ b/pixi-spine/pixi-spine-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace Spine { diff --git a/pixi.js/pixi.js-tests.ts b/pixi.js/pixi.js-tests.ts index 8f86bf0d53..7819dd9603 100644 --- a/pixi.js/pixi.js-tests.ts +++ b/pixi.js/pixi.js-tests.ts @@ -1,4 +1,4 @@ -import PIXI = require("pixi.js"); +import PIXI = require("pixi.js"); namespace basics { export class Basics { diff --git a/pixi.js/v3/pixi.js-tests.ts b/pixi.js/v3/pixi.js-tests.ts index f54da3fb00..0eda38284e 100644 --- a/pixi.js/v3/pixi.js-tests.ts +++ b/pixi.js/v3/pixi.js-tests.ts @@ -1,4 +1,4 @@ -/// +/// namespace basics { export class Basics { diff --git a/playerframework/playerframework-tests.ts b/playerframework/playerframework-tests.ts index dd146e19b3..f64cbb584a 100644 --- a/playerframework/playerframework-tests.ts +++ b/playerframework/playerframework-tests.ts @@ -1,4 +1,4 @@ -var el = document.createElement("div"); +var el = document.createElement("div"); var player = new PlayerFramework.MediaPlayer(el); // Getters diff --git a/poly2tri/poly2tri-tests.ts b/poly2tri/poly2tri-tests.ts index aa780e0d30..578596c8d1 100644 --- a/poly2tri/poly2tri-tests.ts +++ b/poly2tri/poly2tri-tests.ts @@ -1,4 +1,4 @@ - + function initializeCDT(): poly2tri.SweepContext { var contour = [ diff --git a/purl/purl-jquery.d.ts b/purl/purl-jquery.d.ts index 64b258d9e0..a1759a9e0c 100644 --- a/purl/purl-jquery.d.ts +++ b/purl/purl-jquery.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Purl 2.3.1 +// Type definitions for Purl 2.3.1 // Project: https://github.com/allmarkedup/purl // Definitions by: Daniel Ferreira Monteiro Alves // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/ractive/ractive-tests.ts b/ractive/ractive-tests.ts index 5c5eac127b..d8bb4bb64d 100644 --- a/ractive/ractive-tests.ts +++ b/ractive/ractive-tests.ts @@ -1,4 +1,4 @@ - + function test_transition() { var plugin: Ractive.TransitionPlugin = (t: Ractive.Transition, params: Object) => { diff --git a/react-mdl/react-mdl-tests.tsx b/react-mdl/react-mdl-tests.tsx index 7f25f738ae..88ef81a7a4 100644 --- a/react-mdl/react-mdl-tests.tsx +++ b/react-mdl/react-mdl-tests.tsx @@ -1,4 +1,4 @@ -// Test file for react-mdl Definition file +// Test file for react-mdl Definition file import * as React from 'react'; diff --git a/recaptcha/recaptcha-tests.ts b/recaptcha/recaptcha-tests.ts index e270966bda..a8f8a8fe86 100644 --- a/recaptcha/recaptcha-tests.ts +++ b/recaptcha/recaptcha-tests.ts @@ -1,4 +1,4 @@ -var recaptchaOptions: RecaptchaOptions = { +var recaptchaOptions: RecaptchaOptions = { theme : 'custom', custom_theme_widget: 'recaptcha_widget' }; diff --git a/sendgrid/sendgrid-1.1.0.d.ts b/sendgrid/sendgrid-1.1.0.d.ts index 7f644b65b0..d4f7ab7ded 100644 --- a/sendgrid/sendgrid-1.1.0.d.ts +++ b/sendgrid/sendgrid-1.1.0.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sendgrid 1.1.0 +// Type definitions for sendgrid 1.1.0 // Project: https://github.com/sendgrid/sendgrid-nodejs // Definitions by: Maxime LUCE // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/sendgrid/sendgrid-tests.ts b/sendgrid/sendgrid-tests.ts index 180c1f4640..c14b53dff2 100644 --- a/sendgrid/sendgrid-tests.ts +++ b/sendgrid/sendgrid-tests.ts @@ -1,4 +1,4 @@ -/** +/** * Created by using code samples from https://github.com/sendgrid/sendgrid-nodejs#usage */ diff --git a/sequelize-fixtures/sequelize-fixtures-tests.ts b/sequelize-fixtures/sequelize-fixtures-tests.ts index a59c3b157e..ac6fe9dbd7 100644 --- a/sequelize-fixtures/sequelize-fixtures-tests.ts +++ b/sequelize-fixtures/sequelize-fixtures-tests.ts @@ -1,4 +1,4 @@ -import Sequelize = require('sequelize'); +import Sequelize = require('sequelize'); import SequelizeFixtures = require('sequelize-fixtures'); var sequelize = new Sequelize("", ""); diff --git a/sharepoint/SharePoint-tests.ts b/sharepoint/SharePoint-tests.ts index 01643fd65e..6155a0b096 100644 --- a/sharepoint/SharePoint-tests.ts +++ b/sharepoint/SharePoint-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// import * as angular from 'angular'; diff --git a/simplemde/simplemde-tests.ts b/simplemde/simplemde-tests.ts index 350de73bb9..e9be36b7cb 100644 --- a/simplemde/simplemde-tests.ts +++ b/simplemde/simplemde-tests.ts @@ -1,4 +1,4 @@ -function testSimplemde() { +function testSimplemde() { function customMarkdownParser(markdown: string) { return "
" + markdown + "
"; diff --git a/stack-mapper/stack-mapper-tests.ts b/stack-mapper/stack-mapper-tests.ts index 4959e2501b..0d91de51c2 100644 --- a/stack-mapper/stack-mapper-tests.ts +++ b/stack-mapper/stack-mapper-tests.ts @@ -1,4 +1,4 @@ -import stackMapper = require("stack-mapper"); +import stackMapper = require("stack-mapper"); var map: any = {}; var sm: stackMapper.StackMapper = stackMapper(map); diff --git a/steam/steam-tests.ts b/steam/steam-tests.ts index 260761719e..226e15e25e 100644 --- a/steam/steam-tests.ts +++ b/steam/steam-tests.ts @@ -1,4 +1,4 @@ -// Type definitions for steam +// Type definitions for steam // Project: https://github.com/seishun/node-steam // Definitions by: Andrey Kurdyumov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/strophe/strophe-tests.ts b/strophe/strophe-tests.ts index 4e2d42cc9d..45611ae04d 100644 --- a/strophe/strophe-tests.ts +++ b/strophe/strophe-tests.ts @@ -1,4 +1,4 @@ -function log(msg: string): void { +function log(msg: string): void { console.log(msg); } diff --git a/stylus/stylus-tests.ts b/stylus/stylus-tests.ts index 4f17d26a9c..7c5a8b1e45 100644 --- a/stylus/stylus-tests.ts +++ b/stylus/stylus-tests.ts @@ -1,4 +1,4 @@ -/** +/** * Test suite created by Maxime LUCE * * Created by using code samples from https://github.com/LearnBoost/stylus/blob/master/docs/js.md. diff --git a/sylvester/sylvester-tests.ts b/sylvester/sylvester-tests.ts index e6c1ad8d61..b48a9c25b5 100644 --- a/sylvester/sylvester-tests.ts +++ b/sylvester/sylvester-tests.ts @@ -1,4 +1,4 @@ -interface IAny { +interface IAny { a: any; } diff --git a/tar/tar-tests.ts b/tar/tar-tests.ts index 41e645617f..08f304add9 100644 --- a/tar/tar-tests.ts +++ b/tar/tar-tests.ts @@ -1,4 +1,4 @@ -/** +/** * Test suite created by Maxime LUCE * * Created by using code samples from https://github.com/npm/node-tar. diff --git a/three/tests/canvas/canvas_camera_orthographic.ts b/three/tests/canvas/canvas_camera_orthographic.ts index c3b793fb14..d6f094f03f 100644 --- a/three/tests/canvas/canvas_camera_orthographic.ts +++ b/three/tests/canvas/canvas_camera_orthographic.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/canvas_camera_orthographic.html diff --git a/three/tests/canvas/canvas_geometry_cube.ts b/three/tests/canvas/canvas_geometry_cube.ts index 3c704c8f6f..006ee8149c 100644 --- a/three/tests/canvas/canvas_geometry_cube.ts +++ b/three/tests/canvas/canvas_geometry_cube.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/canvas_geometry_cube.html diff --git a/three/tests/canvas/canvas_interactive_cubes_tween.ts b/three/tests/canvas/canvas_interactive_cubes_tween.ts index 0e86e5a2c5..a8d318be5b 100644 --- a/three/tests/canvas/canvas_interactive_cubes_tween.ts +++ b/three/tests/canvas/canvas_interactive_cubes_tween.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/three/tests/canvas/canvas_lights_pointlights.ts b/three/tests/canvas/canvas_lights_pointlights.ts index ce3ac24c33..16fc02cc2f 100644 --- a/three/tests/canvas/canvas_lights_pointlights.ts +++ b/three/tests/canvas/canvas_lights_pointlights.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/canvas_lights_pointlights.html diff --git a/three/tests/canvas/canvas_materials.ts b/three/tests/canvas/canvas_materials.ts index 4518b46ea0..24d5b7d8d9 100644 --- a/three/tests/canvas/canvas_materials.ts +++ b/three/tests/canvas/canvas_materials.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/canvas_materials.html diff --git a/three/tests/canvas/canvas_particles_floor.ts b/three/tests/canvas/canvas_particles_floor.ts index b0725f6dbe..a69dac462d 100644 --- a/three/tests/canvas/canvas_particles_floor.ts +++ b/three/tests/canvas/canvas_particles_floor.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/canvas_particles_floor.html diff --git a/three/tests/css3d/css3d_periodictable.ts b/three/tests/css3d/css3d_periodictable.ts index 022628521c..5083fd4329 100644 --- a/three/tests/css3d/css3d_periodictable.ts +++ b/three/tests/css3d/css3d_periodictable.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/three/tests/css3d/css3d_sprites.ts b/three/tests/css3d/css3d_sprites.ts index 0432009f46..50ec5a219c 100644 --- a/three/tests/css3d/css3d_sprites.ts +++ b/three/tests/css3d/css3d_sprites.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/three/tests/examples/detector.ts b/three/tests/examples/detector.ts index 8b7643592a..b0960c723c 100644 --- a/three/tests/examples/detector.ts +++ b/three/tests/examples/detector.ts @@ -1,4 +1,4 @@ -/// +/// /// diff --git a/three/tests/math/test_unit_math.ts b/three/tests/math/test_unit_math.ts index 5fc52f3798..9ada8464c6 100644 --- a/three/tests/math/test_unit_math.ts +++ b/three/tests/math/test_unit_math.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/three/tests/three-tests-setup.ts b/three/tests/three-tests-setup.ts index e91c233f1b..32d8252981 100644 --- a/three/tests/three-tests-setup.ts +++ b/three/tests/three-tests-setup.ts @@ -1,4 +1,4 @@ -///////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////// // https://github.com/mrdoob/three.js/tree/master/examples ////////////////////////////////////////////////////////////// diff --git a/three/tests/webgl/webgl_animation_cloth.ts b/three/tests/webgl/webgl_animation_cloth.ts index a1cc4917cc..52e36bb04b 100644 --- a/three/tests/webgl/webgl_animation_cloth.ts +++ b/three/tests/webgl/webgl_animation_cloth.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_animation_cloth.html diff --git a/three/tests/webgl/webgl_animation_skinning_morph.ts b/three/tests/webgl/webgl_animation_skinning_morph.ts index 4beb0dde39..167a98d4d2 100644 --- a/three/tests/webgl/webgl_animation_skinning_morph.ts +++ b/three/tests/webgl/webgl_animation_skinning_morph.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_sprites.html diff --git a/three/tests/webgl/webgl_buffergeometry.ts b/three/tests/webgl/webgl_buffergeometry.ts index 8be65dc8a0..a747a17d50 100644 --- a/three/tests/webgl/webgl_buffergeometry.ts +++ b/three/tests/webgl/webgl_buffergeometry.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_buffergeometry.html diff --git a/three/tests/webgl/webgl_camera.ts b/three/tests/webgl/webgl_camera.ts index 6f60b5f3d7..ed695084a2 100644 --- a/three/tests/webgl/webgl_camera.ts +++ b/three/tests/webgl/webgl_camera.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_camera.html diff --git a/three/tests/webgl/webgl_custom_attributes.ts b/three/tests/webgl/webgl_custom_attributes.ts index fc920abd8f..38732c2f67 100644 --- a/three/tests/webgl/webgl_custom_attributes.ts +++ b/three/tests/webgl/webgl_custom_attributes.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_custom_attributes.html diff --git a/three/tests/webgl/webgl_geometries.ts b/three/tests/webgl/webgl_geometries.ts index d1d9764536..e21e0e99c0 100644 --- a/three/tests/webgl/webgl_geometries.ts +++ b/three/tests/webgl/webgl_geometries.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometries.html diff --git a/three/tests/webgl/webgl_helpers.ts b/three/tests/webgl/webgl_helpers.ts index 3cab4ac547..13ed1f4dc0 100644 --- a/three/tests/webgl/webgl_helpers.ts +++ b/three/tests/webgl/webgl_helpers.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_helpers.html diff --git a/three/tests/webgl/webgl_interactive_cubes.ts b/three/tests/webgl/webgl_interactive_cubes.ts index f9a2d2d224..952239b626 100644 --- a/three/tests/webgl/webgl_interactive_cubes.ts +++ b/three/tests/webgl/webgl_interactive_cubes.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_interactive_cubes.html diff --git a/three/tests/webgl/webgl_interactive_raycasting_points.ts b/three/tests/webgl/webgl_interactive_raycasting_points.ts index 798a5a193c..4c1f5ec2c6 100644 --- a/three/tests/webgl/webgl_interactive_raycasting_points.ts +++ b/three/tests/webgl/webgl_interactive_raycasting_points.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_sprites.html diff --git a/three/tests/webgl/webgl_lensflares.ts b/three/tests/webgl/webgl_lensflares.ts index 2f9f748ad5..1223a0dc7c 100644 --- a/three/tests/webgl/webgl_lensflares.ts +++ b/three/tests/webgl/webgl_lensflares.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_lensflares.html diff --git a/three/tests/webgl/webgl_lights_hemisphere.ts b/three/tests/webgl/webgl_lights_hemisphere.ts index 1ea5013f67..95c7aa914b 100644 --- a/three/tests/webgl/webgl_lights_hemisphere.ts +++ b/three/tests/webgl/webgl_lights_hemisphere.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_lights_hemisphere.html diff --git a/three/tests/webgl/webgl_lines_colors.ts b/three/tests/webgl/webgl_lines_colors.ts index 7621f55ad9..bb54df8208 100644 --- a/three/tests/webgl/webgl_lines_colors.ts +++ b/three/tests/webgl/webgl_lines_colors.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_lines_colors.html diff --git a/three/tests/webgl/webgl_loader_awd.ts b/three/tests/webgl/webgl_loader_awd.ts index 8bdf496df0..94c7e73a9b 100644 --- a/three/tests/webgl/webgl_loader_awd.ts +++ b/three/tests/webgl/webgl_loader_awd.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_awd.html diff --git a/three/tests/webgl/webgl_materials.ts b/three/tests/webgl/webgl_materials.ts index a821d8198b..1c6302ea84 100644 --- a/three/tests/webgl/webgl_materials.ts +++ b/three/tests/webgl/webgl_materials.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_materials.html diff --git a/three/tests/webgl/webgl_morphtargets.ts b/three/tests/webgl/webgl_morphtargets.ts index 7e8450b728..9045f5b201 100644 --- a/three/tests/webgl/webgl_morphtargets.ts +++ b/three/tests/webgl/webgl_morphtargets.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_morphtargets.html diff --git a/three/tests/webgl/webgl_points_billboards.ts b/three/tests/webgl/webgl_points_billboards.ts index bc2f133531..93474493c8 100644 --- a/three/tests/webgl/webgl_points_billboards.ts +++ b/three/tests/webgl/webgl_points_billboards.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_particles_billboards.html diff --git a/three/tests/webgl/webgl_postprocessing.ts b/three/tests/webgl/webgl_postprocessing.ts index e9c557f59b..cf0b3ffffe 100644 --- a/three/tests/webgl/webgl_postprocessing.ts +++ b/three/tests/webgl/webgl_postprocessing.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing.html diff --git a/three/tests/webgl/webgl_shader.ts b/three/tests/webgl/webgl_shader.ts index 57825368da..b43044b8f1 100644 --- a/three/tests/webgl/webgl_shader.ts +++ b/three/tests/webgl/webgl_shader.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_shader.html diff --git a/three/tests/webgl/webgl_sprites.ts b/three/tests/webgl/webgl_sprites.ts index a40fb77550..bb7139f5ab 100644 --- a/three/tests/webgl/webgl_sprites.ts +++ b/three/tests/webgl/webgl_sprites.ts @@ -1,4 +1,4 @@ -/// +/// /// // https://github.com/mrdoob/three.js/blob/master/examples/webgl_sprites.html diff --git a/tmp/tmp-tests.ts b/tmp/tmp-tests.ts index fe8b31fd6a..7f8a4cffb3 100644 --- a/tmp/tmp-tests.ts +++ b/tmp/tmp-tests.ts @@ -1,4 +1,4 @@ -import tmp = require('tmp'); +import tmp = require('tmp'); tmp.file((err, path, fd, cleanupCallback) => { if (err) throw err; diff --git a/twitter/twitter-tests.ts b/twitter/twitter-tests.ts index c001e502be..28926c5a7a 100644 --- a/twitter/twitter-tests.ts +++ b/twitter/twitter-tests.ts @@ -1,4 +1,4 @@ - + function load() { twttr.widgets.load(); diff --git a/twix/twix-tests.ts b/twix/twix-tests.ts index 89c4754768..e45d706635 100644 --- a/twix/twix-tests.ts +++ b/twix/twix-tests.ts @@ -1,4 +1,4 @@ - + import * as moment from 'moment'; diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 1441a19397..4f50cb57e2 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -1,4 +1,4 @@ -/// +/// function test_typeahead() { var options: Twitter.Typeahead.Options = {}; diff --git a/typescript-stl/typescript-stl-tests.ts b/typescript-stl/typescript-stl-tests.ts index 830000226d..a495caeeb2 100644 --- a/typescript-stl/typescript-stl-tests.ts +++ b/typescript-stl/typescript-stl-tests.ts @@ -1,2 +1,2 @@ -import std = require("typescript-stl"); +import std = require("typescript-stl"); console.log(std); \ No newline at end of file diff --git a/uk.co.workingedge.phonegap.plugin.istablet/uk.co.workingedge.phonegap.plugin.istablet-tests.ts b/uk.co.workingedge.phonegap.plugin.istablet/uk.co.workingedge.phonegap.plugin.istablet-tests.ts index aaaa459224..f3a6a36300 100644 --- a/uk.co.workingedge.phonegap.plugin.istablet/uk.co.workingedge.phonegap.plugin.istablet-tests.ts +++ b/uk.co.workingedge.phonegap.plugin.istablet/uk.co.workingedge.phonegap.plugin.istablet-tests.ts @@ -1 +1 @@ -console.log("isTablet: "+window.isTablet); +console.log("isTablet: "+window.isTablet); diff --git a/uk.co.workingedge.phonegap.plugin.launchnavigator/uk.co.workingedge.phonegap.plugin.launchnavigator-tests.ts b/uk.co.workingedge.phonegap.plugin.launchnavigator/uk.co.workingedge.phonegap.plugin.launchnavigator-tests.ts index 46d349cf2d..63b02a03d4 100644 --- a/uk.co.workingedge.phonegap.plugin.launchnavigator/uk.co.workingedge.phonegap.plugin.launchnavigator-tests.ts +++ b/uk.co.workingedge.phonegap.plugin.launchnavigator/uk.co.workingedge.phonegap.plugin.launchnavigator-tests.ts @@ -1,4 +1,4 @@ -let app = launchnavigator.APP["GOOGLE_MAPS"]; +let app = launchnavigator.APP["GOOGLE_MAPS"]; let platform = launchnavigator.PLATFORM["ANDROID"]; let destination = "Westminster, London, UK"; diff --git a/valdr-message/valdr-message-tests.ts b/valdr-message/valdr-message-tests.ts index a083adfa90..08af5d32f2 100644 --- a/valdr-message/valdr-message-tests.ts +++ b/valdr-message/valdr-message-tests.ts @@ -1,4 +1,4 @@ -function ValdrMessageTests() { +function ValdrMessageTests() { var valdrMessage: valdr.message.ValdrMessage; valdrMessage.templateUrl = 'valdrMesssageTemplate.html'; diff --git a/valdr/valdr-tests.ts b/valdr/valdr-tests.ts index 52af4a7e45..abab7bdd98 100644 --- a/valdr/valdr-tests.ts +++ b/valdr/valdr-tests.ts @@ -1,4 +1,4 @@ -function ValdrTests() { +function ValdrTests() { var valdr: valdr.Valdr; var validation = valdr.validate('person', 'lastName', 'test'); var isValid = validation.valid; diff --git a/webrtc/MediaStream-tests.ts b/webrtc/MediaStream-tests.ts index a2f8f3f4b4..e45154bd44 100644 --- a/webrtc/MediaStream-tests.ts +++ b/webrtc/MediaStream-tests.ts @@ -1,4 +1,4 @@ -/// +/// var mediaStreamConstraints: MediaStreamConstraints = { audio: true, video: true }; var mediaTrackConstraintSet: MediaTrackConstraintSet = {}; diff --git a/webspeechapi/webspeechapi-tests.ts b/webspeechapi/webspeechapi-tests.ts index 191f58d742..7a8d48bf17 100644 --- a/webspeechapi/webspeechapi-tests.ts +++ b/webspeechapi/webspeechapi-tests.ts @@ -1,4 +1,4 @@ -/* +/* Examples from the spec: https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#examples-recognition */ diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index 39a4cf9d2b..6c5e509749 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -1,4 +1,4 @@ - + function test_HeadersCopiedFromHeaders() { var source = new Headers(); diff --git a/whatwg-streams/whatwg-streams-tests.ts b/whatwg-streams/whatwg-streams-tests.ts index b1735b754f..e26d755df6 100644 --- a/whatwg-streams/whatwg-streams-tests.ts +++ b/whatwg-streams/whatwg-streams-tests.ts @@ -1,4 +1,4 @@ -/// +/// // Examples taken from https://streams.spec.whatwg.org/#creating-examples diff --git a/x-editable/x-editable-tests.ts b/x-editable/x-editable-tests.ts index fbcf560842..c4c03a46be 100644 --- a/x-editable/x-editable-tests.ts +++ b/x-editable/x-editable-tests.ts @@ -1,4 +1,4 @@ -// Type definitions for X-Editable v1.5.1 +// Type definitions for X-Editable v1.5.1 // Project: http://vitalets.github.io/x-editable/index.html // Definitions by: Chris Kirby // Definitions: https://github.com/sirkirby/DefinitelyTyped diff --git a/xrm/xrm-6.d.ts b/xrm/xrm-6.d.ts index 78ab9a6ed4..195fd41e4a 100644 --- a/xrm/xrm-6.d.ts +++ b/xrm/xrm-6.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft Dynamics xRM API v6 +// Type definitions for Microsoft Dynamics xRM API v6 // Project: http://msdn.microsoft.com/en-us/library/gg328255.aspx // Definitions by: David Berry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/xrm/xrm-7.0.d.ts b/xrm/xrm-7.0.d.ts index 3fcb679a40..cf5b92c57c 100644 --- a/xrm/xrm-7.0.d.ts +++ b/xrm/xrm-7.0.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Microsoft Dynamics xRM API v7.0 +// Type definitions for Microsoft Dynamics xRM API v7.0 // Project: http://www.microsoft.com/en-us/download/details.aspx?id=44567 // Definitions by: David Berry , Matt Ngan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 0298df661b..f44e38b545 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -1,4 +1,4 @@ -/// +/// import * as yargs from 'yargs'; From c839a6579f7aab0933ed73a9aa4f35a1aa0a6dd4 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 4 Jan 2017 12:16:33 -0800 Subject: [PATCH 086/181] Add missing `"noImplicitThis": true` (#13736) --- webappsec-credential-management/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/webappsec-credential-management/tsconfig.json b/webappsec-credential-management/tsconfig.json index 52c68b9c2e..11cdce4938 100644 --- a/webappsec-credential-management/tsconfig.json +++ b/webappsec-credential-management/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, + "noImplicitThis": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From bc1da27217d7b57dd43f7f2c182c4ff89bf51392 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 4 Jan 2017 12:57:51 -0800 Subject: [PATCH 087/181] node: path.join arguments must be strings (#13715) --- node/index.d.ts | 11 ++--------- node/node-tests.ts | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index 54f9f53753..a52b0424de 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -2661,14 +2661,7 @@ declare module "path" { * Join all arguments together and normalize the resulting path. * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. * - * @param paths string paths to join. - */ - export function join(...paths: any[]): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths string paths to join. + * @param paths paths to join. */ export function join(...paths: string[]): string; /** @@ -3967,7 +3960,7 @@ declare module "v8" { Enabled = 1 } - interface HeapInfo { + interface HeapInfo { total_heap_size: number; total_heap_size_executable: number; total_physical_size: number; diff --git a/node/node-tests.ts b/node/node-tests.ts index 1be4a870ed..706e8b37f6 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -1034,7 +1034,7 @@ namespace path_tests { //'/foo/bar/baz/asdf' try { - path.join('foo', {}, 'bar'); + path.join('foo', 'bar'); } catch (error) { From 162d8bb7762c8f3e5b06579423562c19f02cccdd Mon Sep 17 00:00:00 2001 From: oosoloviov Date: Wed, 4 Jan 2017 22:59:18 +0200 Subject: [PATCH 088/181] Update index.ts (#13539) Adding this fild will solve the problem of module build failed: Error: Property 'defaults' does not exist on type 'typeof Chart'. And You can use this Chart.defaults.global in ts --- chart.js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index bf23a1cc52..aace24612d 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -392,6 +392,7 @@ interface RadialLinearScale { } declare class Chart { + static defaults: any; constructor (context: CanvasRenderingContext2D | HTMLCanvasElement, options: ChartConfiguration); config: ChartConfiguration; data: ChartData; From a218626522989e244e52ffff95329995207e6039 Mon Sep 17 00:00:00 2001 From: Olivier Date: Wed, 4 Jan 2017 22:01:58 +0100 Subject: [PATCH 089/181] * Add JsDocs on : (#13558) * [`MapOptions`](https://developers.google.com/maps/documentation/javascript/reference#MapOptions) (comments are copied as-is from official Google documentation, so properties zoom and center are indicated as Required, even if there seems to be optionals) * [`MapTypeId`](https://developers.google.com/maps/documentation/javascript/reference#MapTypeId) * [`MapTypeControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#MapTypeControlOptions) * [`PanControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#PanControlOptions) * [`RotateControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#RotateControlOptions) * [`ScaleControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#ScaleControlOptions) * [`StreetViewControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#StreetViewControlOptions) * [`ZoomControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#ZoomControlOptions) * [`ControlPosition`](https://developers.google.com/maps/documentation/javascript/reference#ControlPosition) * [`FullscreenControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#FullscreenControlOptions) * Add Properties [`MapOptions.fullscreenControl`](https://developers.google.com/maps/documentation/javascript/reference#MapOptions) and [`MapOptions.fullscreenControlOptions`](https://developers.google.com/maps/documentation/javascript/reference#MapOptions) * Add property [`MapOptions.signInControl`](https://developers.google.com/maps/documentation/javascript/reference#MapOptions) * Move `clickableIcons` in `MapOptions` interface to respect alphabetic sort of properties. * Remove `mapMaker` property : this property is not documented and does not appear in google maps Javascript. --- googlemaps/index.d.ts | 196 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 194 insertions(+), 2 deletions(-) diff --git a/googlemaps/index.d.ts b/googlemaps/index.d.ts index 010714b831..f19480f034 100644 --- a/googlemaps/index.d.ts +++ b/googlemaps/index.d.ts @@ -58,53 +58,185 @@ declare namespace google.maps { } export interface MapOptions { + /** + * Color used for the background of the Map div. This color will be visible when + * tiles have not yet loaded as the user pans. This option can only be set when + * the map is initialized. + */ backgroundColor?: string; + /** The initial Map center. Required. */ center?: LatLng|LatLngLiteral; + /** + * When false, map icons are not clickable. A map icon represents a point of + * interest, also known as a POI. By default map icons are clickable. + */ + clickableIcons?: boolean + /** Enables/disables all default UI. May be overridden individually. */ disableDefaultUI?: boolean; - clickableIcons?: boolean; + /** Enables/disables zoom and center on double click. Enabled by default. */ disableDoubleClickZoom?: boolean; + /** If false, prevents the map from being dragged. Dragging is enabled by default. */ draggable?: boolean; + /** + * The name or url of the cursor to display when mousing over a draggable map. + * This property uses the css cursor attribute to change the icon. As with the + * css property, you must specify at least one fallback cursor that is not a URL. + * For example: draggableCursor: 'url(http://www.example.com/icon.png), auto;'. + */ draggableCursor?: string; + /** + * The name or url of the cursor to display when the map is being dragged. This + * property uses the css cursor attribute to change the icon. As with the css + * property, you must specify at least one fallback cursor that is not a URL. + * For example: draggingCursor: 'url(http://www.example.com/icon.png), auto;'. + */ draggingCursor?: string; + /** The enabled/disabled state of the Fullscreen control. */ + fullscreenControl?: boolean; + /** The display options for the Fullscreen control. */ + fullscreenControlOptions?: FullscreenControlOptions; + /** + * The heading for aerial imagery in degrees measured clockwise from cardinal + * direction North. Headings are snapped to the nearest available angle for + * which imagery is available. + */ heading?: number; + /** + * If false, prevents the map from being controlled by the keyboard. Keyboard + * shortcuts are enabled by default. + */ keyboardShortcuts?: boolean; - mapMaker?: boolean; + /** The initial enabled/disabled state of the Map type control. */ mapTypeControl?: boolean; + /** The initial display options for the Map type control. */ mapTypeControlOptions?: MapTypeControlOptions; + /** The initial Map mapTypeId. Defaults to ROADMAP. */ mapTypeId?: MapTypeId; + /** + * The maximum zoom level which will be displayed on the map. If omitted, or set + * to null, the maximum zoom from the current map type is used instead. Valid + * values: Integers between zero, and up to the supported maximum zoom level. + */ maxZoom?: number; + /** + * The minimum zoom level which will be displayed on the map. If omitted, or set + * to null, the minimum zoom from the current map type is used instead. Valid + * values: Integers between zero, and up to the supported maximum zoom level. + */ minZoom?: number; + /** If true, do not clear the contents of the Map div. */ noClear?: boolean; overviewMapControl?: boolean; overviewMapControlOptions?: OverviewMapControlOptions; + /** + * The enabled/disabled state of the Pan control. + * Note: The Pan control is not available in the new set of controls introduced + * in v3.22 of the Google Maps JavaScript API. While using v3.22 and v3.23, you + * can choose to use the earlier set of controls rather than the new controls, + * thus making the Pan control available as part of the old control set. + * See {@link https://developers.google.com/maps/articles/v322-controls-diff|What's New in the v3.22 Map Controls}. + */ panControl?: boolean; + /** + * The display options for the Pan control. + * Note: The Pan control is not available in the new set of controls introduced + * in v3.22 of the Google Maps JavaScript API. While using v3.22 and v3.23, you + * can choose to use the earlier set of controls rather than the new controls, + * thus making the Pan control available as part of the old control set. + * See {@link https://developers.google.com/maps/articles/v322-controls-diff|What's New in the v3.22 Map Controls}. + */ panControlOptions?: PanControlOptions; + /** The enabled/disabled state of the Rotate control. */ rotateControl?: boolean; + /** The display options for the Rotate control. */ rotateControlOptions?: RotateControlOptions; + /** The initial enabled/disabled state of the Scale control. */ scaleControl?: boolean; + /** The initial display options for the Scale control. */ scaleControlOptions?: ScaleControlOptions; + /** If false, disables scrollwheel zooming on the map. The scrollwheel is enabled by default. */ scrollwheel?: boolean; + /** + * The enabled/disabled state of the sign in control. This option only applies if + * signed_in=true has been passed as a URL parameter in the bootstrap request. + * You may want to use this option to hide the map's sign in control if you have + * provided another way for your users to sign in, such as the Google Sign-In + * button. This option does not affect the visibility of the Google avatar shown + * when the user is already signed in. + */ + signInControl?: boolean; + /** + * A StreetViewPanorama to display when the Street View pegman is dropped on the + * map. If no panorama is specified, a default StreetViewPanorama will be + * displayed in the map's div when the pegman is dropped. + */ streetView?: StreetViewPanorama; + /** + * The initial enabled/disabled state of the Street View Pegman control. This + * control is part of the default UI, and should be set to false when displaying + * a map type on which the Street View road overlay should not appear + * (e.g. a non-Earth map type). + */ streetViewControl?: boolean; + /** The initial display options for the Street View Pegman control. */ streetViewControlOptions?: StreetViewControlOptions; + /** + * Styles to apply to each of the default map types. Note that for + * satellite/hybrid and terrain modes, these styles will only apply to labels + * and geometry. + */ styles?: MapTypeStyle[]; + /** + * Controls the automatic switching behavior for the angle of incidence of the + * map. The only allowed values are 0 and 45. The value 0 causes the map to + * always use a 0° overhead view regardless of the zoom level and viewport. The + * value 45 causes the tilt angle to automatically switch to 45 whenever 45° + * imagery is available for the current zoom level and viewport, and switch back + * to 0 whenever 45° imagery is not available (this is the default behavior). + * 45° imagery is only available for satellite and hybrid map types, within some + * locations, and at some zoom levels. Note: getTilt returns the current tilt + * angle, not the value specified by this option. Because getTilt and this option + * refer to different things, do not bind() the tilt property; doing so may yield + * unpredictable effects. + */ tilt?: number; + /** + * The initial Map zoom level. Required. Valid values: Integers between zero, and + * up to the supported maximum zoom level. + */ zoom?: number; + /** The enabled/disabled state of the Zoom control. */ zoomControl?: boolean; + /** The display options for the Zoom control. */ zoomControlOptions?: ZoomControlOptions; } + /** + * Identifiers for common MapTypes. Specify these by value, or by using the + * constant's name. For example, 'satellite' or google.maps.MapTypeId.SATELLITE. + */ export enum MapTypeId { + /** This map type displays a transparent layer of major streets on satellite images. */ HYBRID, + /** This map type displays a normal street map. */ ROADMAP, + /** This map type displays satellite images. */ SATELLITE, + /** This map type displays maps with physical features such as terrain and vegetation. */ TERRAIN } /***** Controls *****/ + /** Options for the rendering of the map type control. */ export interface MapTypeControlOptions { + /** IDs of map types to show in the control. */ mapTypeIds?: (MapTypeId|string)[]; + /** + * Position id. Used to specify the position of the control on the map. + * The default position is TOP_RIGHT. + */ position?: ControlPosition; + /** Style id. Used to select what style of map type control to display. */ style?: MapTypeControlStyle; } @@ -118,15 +250,27 @@ declare namespace google.maps { opened?: boolean; } + /** Options for the rendering of the pan control. */ export interface PanControlOptions { + /** + * Position id. Used to specify the position of the control on the map. + * The default position is TOP_LEFT. + */ position?: ControlPosition; } + /** Options for the rendering of the rotate control. */ export interface RotateControlOptions { + /** + * Position id. Used to specify the position of the control on the map. + * The default position is TOP_LEFT. + */ position?: ControlPosition; } + /** Options for the rendering of the scale control. */ export interface ScaleControlOptions { + /** Style id. Used to select what style of scale control to display. */ style?: ScaleControlStyle; } @@ -134,11 +278,25 @@ declare namespace google.maps { DEFAULT } + /** Options for the rendering of the Street View pegman control on the map. */ export interface StreetViewControlOptions { + /** + * Position id. Used to specify the position of the control on the map. The + * default position is embedded within the navigation (zoom and pan) controls. + * If this position is empty or the same as that specified in the + * zoomControlOptions or panControlOptions, the Street View control will be + * displayed as part of the navigation controls. Otherwise, it will be displayed + * separately. + */ position?: ControlPosition; } + /** Options for the rendering of the zoom control. */ export interface ZoomControlOptions { + /** + * Position id. Used to specify the position of the control on the map. + * The default position is TOP_LEFT. + */ position?: ControlPosition; style?: ZoomControlStyle; } @@ -149,18 +307,47 @@ declare namespace google.maps { SMALL } + /** + * Identifiers used to specify the placement of controls on the map. Controls are + * positioned relative to other controls in the same layout position. Controls that + * are added first are positioned closer to the edge of the map. + */ export enum ControlPosition { + /** Elements are positioned in the center of the bottom row. */ BOTTOM_CENTER, + /** + * Elements are positioned in the bottom left and flow towards the middle. + * Elements are positioned to the right of the Google logo. + */ BOTTOM_LEFT, + /** + * Elements are positioned in the bottom right and flow towards the middle. + * Elements are positioned to the left of the copyrights. + */ BOTTOM_RIGHT, + /** + * Elements are positioned on the left, above bottom-left elements, and flow upwards. + */ LEFT_BOTTOM, + /** Elements are positioned in the center of the left side. */ LEFT_CENTER, + /** + * Elements are positioned on the left, below top-left elements, and flow downwards. + */ LEFT_TOP, + /** + * Elements are positioned on the right, above bottom-right elements, and flow upwards. + */ RIGHT_BOTTOM, + /** Elements are positioned in the center of the right side. */ RIGHT_CENTER, + /** Elements are positioned on the right, below top-right elements, and flow downwards. */ RIGHT_TOP, + /** Elements are positioned in the center of the top row. */ TOP_CENTER, + /** Elements are positioned in the top left and flow towards the middle. */ TOP_LEFT, + /** Elements are positioned in the top right and flow towards the middle. */ TOP_RIGHT } @@ -1605,7 +1792,12 @@ declare namespace google.maps { setZoom(zoom: number): void; } + /** Options for the rendering of the fullscreen control. */ export interface FullscreenControlOptions { + /** + * Position id. Used to specify the position of the control on the map. + * The default position is RIGHT_TOP. + */ position?: ControlPosition; } From 844164f7c048e2a128cfc5cfd1b7a921cab5ff72 Mon Sep 17 00:00:00 2001 From: James Nail Date: Wed, 4 Jan 2017 16:13:52 -0500 Subject: [PATCH 090/181] enhanced cors package, up to v2.8 (#13593) * enhanced cors package, up to v2.8 * added missing test cases --- cors/cors-tests.ts | 39 ++++++++++++++++++++++++++++++++++++++- cors/index.d.ts | 16 +++++++++++----- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/cors/cors-tests.ts b/cors/cors-tests.ts index 186e006726..f43b9ee153 100644 --- a/cors/cors-tests.ts +++ b/cors/cors-tests.ts @@ -6,5 +6,42 @@ var app = express(); app.use(cors()); app.use(cors({ maxAge: 100, - credentials: true + credentials: true, + optionsSuccessStatus: 200 })); +app.use(cors({ + methods: 'GET,POST,PUT', + exposedHeaders: 'Content-Range,X-Content-Range', + allowedHeaders: 'Content-Type,Authorization' +})); +app.use(cors({ + methods: ['GET', 'POST', 'PUT', 'DELETE'], + exposedHeaders: ['Content-Range', 'X-Content-Range'], + allowedHeaders: ['Content-Type', 'Authorization'] +})); +app.use(cors({ + origin: true +})); +app.use(cors({ + origin: 'http://example.com' +})); +app.use(cors({ + origin: /example\.com$/ +})); +app.use(cors({ + origin: ['http://example.com', 'http://fakeurl.com'] +})); +app.use(cors({ + origin: [/example\.com$/, /fakeurl\.com$/] +})); +app.use(cors({ + origin: (requestOrigin, cb) => { + try { + var allow = requestOrigin.indexOf('.edu') !== -1; + cb(null, allow); + } catch (err) { + cb(err); + } + } +})); + diff --git a/cors/index.d.ts b/cors/index.d.ts index 74761eb7d6..ecad80d187 100644 --- a/cors/index.d.ts +++ b/cors/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cors +// Type definitions for cors 2.8 // Project: https://github.com/troygoode/node-cors/ // Definitions by: Mihhail Lapushkin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,15 +8,21 @@ import express = require('express'); +type CustomOrigin = ( + requestOrigin: string, + callback: (err: Error, allow?: boolean) => void +) => void; + declare namespace e { interface CorsOptions { - origin?: any; - methods?: any; - allowedHeaders?: any; - exposedHeaders?: any; + origin?: boolean | string | RegExp | string[] | RegExp[] | CustomOrigin; + methods?: string | string[]; + allowedHeaders?: string | string[]; + exposedHeaders?: string | string[]; credentials?: boolean; maxAge?: number; preflightContinue?: boolean; + optionsSuccessStatus?: number; } } From 6d6e460e2ae87f6726ae6b0281b313bfd69385b8 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 4 Jan 2017 22:16:58 +0100 Subject: [PATCH 091/181] Disallow arbitrary objects in clipboard.write. (#13595) --- electron/github-electron-renderer-tests.ts | 1 + electron/index.d.ts | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/electron/github-electron-renderer-tests.ts b/electron/github-electron-renderer-tests.ts index 1d1da23069..108e9fa1a8 100644 --- a/electron/github-electron-renderer-tests.ts +++ b/electron/github-electron-renderer-tests.ts @@ -95,6 +95,7 @@ clipboard.clear(); clipboard.write({ html: '', text: 'Hello World!', + bookmark: "Bookmark name", image: clipboard.readImage() }); diff --git a/electron/index.d.ts b/electron/index.d.ts index 7a0a018666..1812c1cc7a 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -1864,12 +1864,7 @@ declare namespace Electron { /** * Writes data to the clipboard. */ - write(data: { - text?: string; - rtf?: string; - html?: string; - image?: NativeImage; - }, type?: ClipboardType): void; + write(data: { text: string; bookmark?: string; } | { rtf: string; } | { html: string; } | { image: NativeImage; }, type?: ClipboardType): void; /** * @returns An Object containing title and url keys representing the bookmark in the clipboard. * From 5358bfd10aed37bcd5752d3388af0a29f06819c0 Mon Sep 17 00:00:00 2001 From: avidenic Date: Wed, 4 Jan 2017 23:33:32 +0100 Subject: [PATCH 092/181] added typings for jQuery Mask plugin (#13706) * added typings for jQuery Mask plugin * turned on null strict checking * type fix * added missing semicolon --- jquery-mask-plugin/index.d.ts | 75 +++++++++++ .../jquery-mask-plugin-tests.ts | 119 ++++++++++++++++++ jquery-mask-plugin/tsconfig.json | 20 +++ jquery-mask-plugin/tslint.json | 3 + 4 files changed, 217 insertions(+) create mode 100644 jquery-mask-plugin/index.d.ts create mode 100644 jquery-mask-plugin/jquery-mask-plugin-tests.ts create mode 100644 jquery-mask-plugin/tsconfig.json create mode 100644 jquery-mask-plugin/tslint.json diff --git a/jquery-mask-plugin/index.d.ts b/jquery-mask-plugin/index.d.ts new file mode 100644 index 0000000000..61f3a69359 --- /dev/null +++ b/jquery-mask-plugin/index.d.ts @@ -0,0 +1,75 @@ +// Type definitions for jQuery Mask Plugin 1.14 +// Project: https://igorescobar.github.io/jQuery-Mask-Plugin/ +// Definitions by: Anže Videnič , Igor Escobar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace jQueryMask { + + interface Invalid { + p: number; + v: string; + e: string; + } + + interface Options { + maskElements?: string; + dataMaskAttr?: string; + dataMask?: boolean; + watchInterval?: number; + watchInputs?: boolean; + watchDataMask?: boolean; + byPassKeys?: number[]; + translation?: Translation; + selectOnFocus?: boolean; + reverse?: boolean; + clearIfNotMatch?: boolean; + onComplete?(value: string, e: Event, $element: JQuery, options: Options): void; + onKeyPress?(value: string, e: Event, $element: JQuery, options: Options): void; + onChange?(value: string, e: Event, $element: JQuery, options: Options): void; + onInvalid?(value: string, e: Event, $element: JQuery, invalid: Invalid[], options: Options): void; + } + + interface Pattern { + pattern?: RegExp; + recursive?: boolean; + optional?: boolean; + fallback?: string; + } + + interface Translation { + [key: string]: Pattern | {} | undefined; + placeholder?: string; + } + +} + +interface JQuery { + + /** + * Applies the mask to the matching selector elements. + * @param mask should be a string or a function. + * @param options should be an options object. + * @returns The element. + */ + mask(mask: ((value: string) => string) | string, options?: jQueryMask.Options): JQuery; + + /** + * Seek and destroy. + * @returns The element. + */ + unmask(): JQuery; + + /** + * Gets the value of the field without the mask. + * @returns Value without the mask. + */ + cleanVal(): string; + + /** + * Gets masked value programmatically + * @returns Masked value. + */ + masked(value: string): string; +} \ No newline at end of file diff --git a/jquery-mask-plugin/jquery-mask-plugin-tests.ts b/jquery-mask-plugin/jquery-mask-plugin-tests.ts new file mode 100644 index 0000000000..269bc0719e --- /dev/null +++ b/jquery-mask-plugin/jquery-mask-plugin-tests.ts @@ -0,0 +1,119 @@ + +// basic usage +$(document).ready(function () { + $('.date').mask('00/00/0000'); + $('.time').mask('00:00:00'); + $('.date_time').mask('00/00/0000 00:00:00'); + $('.cep').mask('00000-000'); + $('.phone').mask('0000-0000'); + $('.phone_with_ddd').mask('(00) 0000-0000'); + $('.phone_us').mask('(000) 000-0000'); + $('.mixed').mask('AAA 000-S0S'); + $('.cpf').mask('000.000.000-00', { reverse: true }); + $('.cnpj').mask('00.000.000/0000-00', { reverse: true }); + $('.money').mask('000.000.000.000.000,00', { reverse: true }); + $('.money2').mask("#.##0,00", { reverse: true }); + $('.ip_address').mask('0ZZ.0ZZ.0ZZ.0ZZ', { + translation: { + 'Z': { + pattern: /[0-9]/, optional: true + } + } + }); + $('.ip_address').mask('099.099.099.099'); + $('.percent').mask('##0,00%', { reverse: true }); + $('.clear-if-not-match').mask("00/00/0000", { clearIfNotMatch: true }); + $('.placeholder').mask("00/00/0000", { + translation: { + placeholder: "__/__/____" + } + }); + $('.fallback').mask("00r00r0000", { + translation: { + 'r': { + pattern: /[\/]/, + fallback: '/' + }, + placeholder: "__/__/____" + } + }); + $('.selectonfocus').mask("00/00/0000", { selectOnFocus: true }); +}); + +// callback examples +let options: jQueryMask.Options = { + onComplete: function (cep: Object) { + alert('CEP Completed!:' + cep); + }, + onKeyPress: function (cep: Object, event: Event, currentField: JQuery, options: jQueryMask.Options) { + console.log('An key was pressed!:', cep, ' event: ', event, + 'currentField: ', currentField, ' options: ', options); + }, + onChange: function (cep: Object) { + console.log('cep changed! ', cep); + }, + onInvalid: function (val: Object, e: Event, f: JQuery, invalid: jQueryMask.Invalid[], options: jQueryMask.Options) { + var error = invalid[0]; + console.log("Digit: ", error.v, " is invalid for the position: ", error.p, ". We expect something like: ", error.e); + } +}; + +$('.cep_with_callback').mask('00000-000', options); + +// on the fly mask changed +options = { + onKeyPress: function (cep, e, field, options) { + let masks: string[] = ['00000-000', '0-00-00-00']; + let mask: string = (cep.length > 7) ? masks[1] : masks[0]; + $('.crazy_cep').mask(mask, options); + } +}; + +$('.crazy_cep').mask('00000-000', options); + +// mask as a function +let maskBehavior: (value: string) => string = function (val: string) { + return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; +}; + +options = { + onKeyPress: function(val: string, e: Event, field: JQuery, options: jQueryMask.Options) { + field.mask(maskBehavior.apply({}, arguments), options); + } +}; + +$('.sp_celphones').mask(maskBehavior, options); + +// translation +// now the digit 0 on your mask pattern will be interpreted +// as valid characters like 0,1,2,3,4,5,6,7,8,9 and * +$('.your-field').mask('00/00/0000', {'translation': {0: {pattern: /[0-9*]/}}}); + +// optional digits +// way 1 +$('.ip_address').mask('099.099.099.099'); +// way 2 +$('.ip_address').mask('0ZZ.0ZZ.0ZZ.0ZZ', {translation: {'Z': {pattern: /[0-9]/, optional: true}}}); + +// recursive digits +$('.money_example').mask('#.##0,00', {reverse: true}); + +// fallback digits +$('.field_with_fallback').mask("00r00r0000", { + translation: { + 'r': { + pattern: /[\/]/, + fallback: '/' + }, + placeholder: "__/__/____" + } +}); + +// Removing the mask +$('.date').unmask(); + +// Getting the unmasked typed value +$('.date').cleanVal(); + +// Getting a masked value programmatically +$('.date').masked('19840807'); \ No newline at end of file diff --git a/jquery-mask-plugin/tsconfig.json b/jquery-mask-plugin/tsconfig.json new file mode 100644 index 0000000000..e805aac8db --- /dev/null +++ b/jquery-mask-plugin/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery-mask-plugin-tests.ts" + ] +} \ No newline at end of file diff --git a/jquery-mask-plugin/tslint.json b/jquery-mask-plugin/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/jquery-mask-plugin/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From c65a20d6df0b4aacc5c7da651cc135495a5be662 Mon Sep 17 00:00:00 2001 From: Bowen Ni Date: Wed, 4 Jan 2017 15:31:24 -0800 Subject: [PATCH 093/181] Update 'ncp' to version 2.0.0 (#13742) * Update ncp-tests.ts * Update index.d.ts --- ncp/index.d.ts | 3 ++- ncp/ncp-tests.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ncp/index.d.ts b/ncp/index.d.ts index 9d0d32caea..19f80d7b9e 100644 --- a/ncp/index.d.ts +++ b/ncp/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ncp v0.5.1 +// Type definitions for ncp v2.0.0 // Project: https://github.com/AvianFlu/ncp // Definitions by: Bart van der Schoor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,6 +12,7 @@ interface Options { filter?: RegExp | ((filename: string) => boolean); transform?: (read: NodeJS.ReadableStream, write: NodeJS.WritableStream) => void; clobber?: boolean; + dereference?: boolean; stopOnErr?: boolean; errs?: NodeJS.WritableStream; } diff --git a/ncp/ncp-tests.ts b/ncp/ncp-tests.ts index 694d96e22b..008084d0ff 100644 --- a/ncp/ncp-tests.ts +++ b/ncp/ncp-tests.ts @@ -17,6 +17,9 @@ opts = { opts = { clobber: false }; +opts = { + dereference: false +}; opts = { stopOnErr: false }; From 08fca8e2d3421c9f7a9b0a9212315c08f1548738 Mon Sep 17 00:00:00 2001 From: Paul Lockwood Date: Wed, 4 Jan 2017 17:19:37 -0700 Subject: [PATCH 094/181] First attempt adding browser-bunyan types (#13717) * First attempt adding browser-bunyan types * package.json only need dependencies * Addressed all comments made by andy-ms https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13717 * export * from "@types/bunyan" -> export * from "bunyan"; Trying literally how andy-ms suggested * Adding package version as-per base64-js example * Changed back to copy/paste version of typings - browser-bunyan is a fork of bunyan - Errors from Travis CI were not helping so it seems wise to revert to a known good * Resolved linting issues - Tested with: yarn lint -- browser-bunyan * Trying: export * from "bunyan"; - as suggested by andy-ms --- browser-bunyan/browser-bunyan-tests.ts | 8 ++++++++ browser-bunyan/index.d.ts | 8 ++++++++ browser-bunyan/tsconfig.json | 20 ++++++++++++++++++++ browser-bunyan/tslint.json | 1 + 4 files changed, 37 insertions(+) create mode 100644 browser-bunyan/browser-bunyan-tests.ts create mode 100644 browser-bunyan/index.d.ts create mode 100644 browser-bunyan/tsconfig.json create mode 100644 browser-bunyan/tslint.json diff --git a/browser-bunyan/browser-bunyan-tests.ts b/browser-bunyan/browser-bunyan-tests.ts new file mode 100644 index 0000000000..656a8eb002 --- /dev/null +++ b/browser-bunyan/browser-bunyan-tests.ts @@ -0,0 +1,8 @@ +import * as bunyan from "browser-bunyan"; + +var log = bunyan.createLogger({ + name: 'play', + serializers: bunyan.stdSerializers +}); +log.debug({foo: 'bar'}, 'hi at debug') +log.trace('hi at trace') diff --git a/browser-bunyan/index.d.ts b/browser-bunyan/index.d.ts new file mode 100644 index 0000000000..df5116f1c4 --- /dev/null +++ b/browser-bunyan/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for browser-bunyan 0.4 +// Project: https://github.com/philmander/browser-bunyan +// Definitions by: Paul Lockwood +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export * from "bunyan"; + +export function ConsoleFormattedStream(): void; diff --git a/browser-bunyan/tsconfig.json b/browser-bunyan/tsconfig.json new file mode 100644 index 0000000000..695ae41ca5 --- /dev/null +++ b/browser-bunyan/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "browser-bunyan-tests.ts" + ] +} diff --git a/browser-bunyan/tslint.json b/browser-bunyan/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/browser-bunyan/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3796367a4f13b4a07dc8423392b128f34d0a9a1b Mon Sep 17 00:00:00 2001 From: JJJ Date: Thu, 5 Jan 2017 11:12:39 +0800 Subject: [PATCH 095/181] Add clndr types (#13721) * Add clndr types * remove unused import * export interfaces --- clndr/clndr-tests.ts | 86 ++++++++++ clndr/index.d.ts | 387 +++++++++++++++++++++++++++++++++++++++++++ clndr/package.json | 5 + clndr/tsconfig.json | 20 +++ clndr/tslint.json | 1 + 5 files changed, 499 insertions(+) create mode 100644 clndr/clndr-tests.ts create mode 100644 clndr/index.d.ts create mode 100644 clndr/package.json create mode 100644 clndr/tsconfig.json create mode 100644 clndr/tslint.json diff --git a/clndr/clndr-tests.ts b/clndr/clndr-tests.ts new file mode 100644 index 0000000000..ca904f13b2 --- /dev/null +++ b/clndr/clndr-tests.ts @@ -0,0 +1,86 @@ +import * as Clndr from 'clndr'; + +let options: Clndr.ClndrOptions = { + template: '', + startWithMonth: "YYYY-MM-DD", + weekOffset: 0, + daysOfTheWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + targets: { + day: 'day', + empty: 'empty', + nextButton: 'clndr-next-button', + todayButton: 'clndr-today-button', + previousButton: 'clndr-previous-button', + nextYearButton: 'clndr-next-year-button', + previousYearButton: 'clndr-previous-year-button', + }, + classes: { + past: "past", + today: "today", + event: "event", + selected: "selected", + inactive: "inactive", + lastMonth: "last-month", + nextMonth: "next-month", + adjacentMonth: "adjacent-month", + }, + clickEvents: { + click: function (target) { }, + today: function (month) { }, + nextMonth: function (month) { }, + previousMonth: function (month) { }, + onMonthChange: function (month) { }, + nextYear: function (month) { }, + previousYear: function (month) { }, + onYearChange: function (month) { }, + nextInterval: function (start, end) { }, + previousInterval: function (start, end) { }, + onIntervalChange: function (start, end) { } + }, + useTouchEvents: false, + ready: function () { }, + doneRendering: function () { }, + events: [], + dateParameter: 'date', + multiDayEvents: { + endDate: 'endDate', + startDate: 'startDate', + singleDay: 'date' + }, + showAdjacentMonths: true, + adjacentDaysChangeMonth: false, + forceSixRows: null, + trackSelectedDate: false, + selectedDate: null, + ignoreInactiveDaysInSelection: null, + lengthOfTime: { + months: null, + days: null, + interval: 1 + }, + extras: { }, + render: function (data) { + return '
'; + }, + constraints: { + startDate: '2017-12-22', + endDate: '2018-01-09' + }, + moment: null +}; + +let myCalendar = $('.parent-element').clndr(options); + +myCalendar + .forward() + .back() + .setMonth(0) + .setMonth('February') + .nextYear() + .previousYear() + .setYear(1997) + .today() + .setEvents([]) + .addEvents([]) + .removeEvents(event => { return event.id === 'idToRemove'; }) + .destroy(); \ No newline at end of file diff --git a/clndr/index.d.ts b/clndr/index.d.ts new file mode 100644 index 0000000000..12d84a6088 --- /dev/null +++ b/clndr/index.d.ts @@ -0,0 +1,387 @@ +// Type definitions for clndr 1.4 +// Project: https://github.com/kylestetz/CLNDR +// Definitions by: jasperjn +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as moment from 'moment'; + +export as namespace Clndr; + +/** + * The clndr instance + */ +export interface ClndrInstance { + /** + * Go to the next month + */ + forward(): this; + /** + * Go to the previous month + */ + back(): this; + /** + * Set the month using a number from 0-11 or a month name + */ + setMonth(month: number | string): this; + /** + * Go to the next year + */ + nextYear(): this; + /** + * Go to the previous year + */ + previousYear(): this; + /** + * Set the year + */ + setYear(year: number): this; + /** + * Go to today + */ + today(): this; + /** + * Change the events. Note that this triggers a re-render of the calendar. + */ + setEvents(events: any[]): this; + /** + * Add events. Note that this triggers a re-render of the calendar. + */ + addEvents(events: any[]): this; + /** + * Remove events. All events for which the passed in function returns true will + * be removed from the calendar. Note that this triggers a re-render of the + * calendar. + */ + removeEvents(filter: (event: any) => boolean): this; + /** + * Destroy the clndr instance. This will empty the DOM node containing the + * calendar. + */ + destroy(): void; +} + +export interface ClndrOptions { + /** + * the template: this could be stored in markup as a + * or pulled in as a string + */ + template?: string; + /** + * determines which month to start with using either a date string or a moment object. + */ + startWithMonth?: string | moment.Moment; + /** + * Start the week off on Sunday (0), Monday (1), etc. Sunday is the default. + * WARNING: if you are dealing with i18n and multiple languages, you + * probably don't want this! See the "Internationalization" section below + * for more. + */ + weekOffset?: number; + /** + * An array of day abbreviation labels. If you have moment.js set to a + * different language, it will guess these for you! If for some reason that + * doesn't work, use this... + * WARNING: if you are dealing with i18n and multiple languages, you + * probably don't want this! See the "Internationalization" section below + * for more. + */ + daysOfTheWeek?: string[]; + /** + * the target classnames that CLNDR will look for to bind events. these are the defaults. + */ + targets?: Targets; + /** + * Custom classes to avoid styling issues. pass in only the classnames that + * you wish to override. These are the defaults. + */ + classes?: Classes; + /** + * callbacks! + */ + clickEvents?: ClickEvents; + /** + * Use the 'touchstart' event instead of 'click' + */ + useTouchEvents?: boolean; + /** + * This is called only once after clndr has been initialized and rendered. + * use this to bind custom event handlers that don't need to be re-attached + * every time the month changes (most event handlers fall in this category). + * Hint: this.element refers to the parent element that holds the clndr, + * and is a great place to attach handlers that don't get tossed out every + * time the clndr is re-rendered. + */ + ready?(): void; + /** + * A callback when the calendar is done rendering. This is a good place + * to bind custom event handlers (also see the 'ready' option above). + */ + doneRendering?(): void; + /** an array of event objects */ + events?: any[]; + /** + * if you're supplying an events array, dateParameter points to the field in your event object containing a date string. It's set to 'date' by default. + */ + dateParameter?: string; + /** + * CLNDR can accept events lasting more than one day! just pass in the + * multiDayEvents option and specify what the start and end fields are + * called within your event objects. See the example file for a working + * instance of this. + */ + multiDayEvents?: MultiDayEvents; + /** + * show the numbers of days in months adjacent to the current month (and populate them with their events). defaults to true. + */ + showAdjacentMonths?: boolean; + /** + * when days from adjacent months are clicked, switch the current month. + * fires nextMonth/previousMonth/onMonthChange click callbacks. defaults to false. + */ + adjacentDaysChangeMonth?: boolean; + /** + * Always make the calendar six rows tall (42 days) so that every month has + * a consistent height. defaults to 'false'. + */ + forceSixRows?: boolean | null; + /** + * Set this to true, if you want the plugin to track the last clicked day. + * If trackSelectedDate is true, "selected" class will always be applied + * only to the most recently clicked date; otherwise - selectedDate will + * not change. + */ + trackSelectedDate?: boolean; + /** + * Set this, if you want a date to be "selected" (see classes.selected) + * after plugin init. Defualts to null, no initially selected date. + */ + selectedDate?: any; + /** + * Set this to true if you don't want `inactive` dates to be selectable. + * This will only matter if you are using the `constraints` option. + */ + ignoreInactiveDaysInSelection?: boolean | null; + // CLNDR can render in any time interval! + // You can specify if you want to render one or more months, or one ore more + // days in the calendar, as well as the paging interval whenever forward or + // back is triggered. If both months and days are null, CLNDR will default + // to the standard monthly view. + lengthOfTime?: LengthOfTime; + /** + * Any other data variables you want access to in your template. This gets + * passed into the template function. + */ + extras?: any; + /** + * If you want to use a different templating language, here's your ticket. + * Precompile your template (before you call clndr), pass the data from the + * render function into your template, and return the result. The result + * must be a string containing valid markup. The keyword 'this' is set to + * the clndr instance in case you need access to any other properties. + * More under 'Template Rendering Engine' below. + */ + render?(data: RenderData): void; + // If you want to prevent the user from navigating the calendar outside + // of a certain date range (e.g. if you are making a datepicker), specify + // either the startDate, endDate, or both in the constraints option. You + // can change these while the calendar is on the page... See documentation + // below for more on this! + constraints?: Constraints; + /** + * Optionally, you can pass a Moment instance to use instead of the global + */ + moment?: moment.Moment | null; +} + +export interface ClickEvents { + /** + * Fired whenever a calendar box is clicked. Returns a 'target' object + * containing the DOM element, any events, and the date as a moment.js + * object. + */ + click?(target: Target): void; + /** + * Fired when a user goes to the current month and year. Returns a + * moment.js object set to the correct month. + */ + today?(month: moment.Moment): void; + /** + * Fired when a user goes forward a month. Returns a moment.js object + * set to the correct month. + */ + nextMonth?(month: moment.Moment): void; + /** + * Fired when a user goes back a month. Returns a moment.js object set + * to the correct month. + * + */ + previousMonth?(month: moment.Moment): void; + /** + * Fires any time the month changes as a result of a click action. + * Returns a moment.js object set to the correct month. + */ + onMonthChange?(month: moment.Moment): void; + /** + * Fired when the next year button is clicked. Returns a moment.js + * object set to the correct month and year. + */ + nextYear?(month: moment.Moment): void; + /** + * Fired when the previous year button is clicked. Returns a moment.js + * object set to the correct month and year. + */ + previousYear?(month: moment.Moment): void; + /** + * Fires any time the year changes as a result of a click action. If + * onMonthChange is also set, it is fired BEFORE onYearChange. Returns + * a moment.js object set to the correct month and year. + */ + onYearChange?(month: moment.Moment): void; + /** + * Fired when a user goes forward a period. Returns moment.js objects + * for the updated start and end date. + */ + nextInterval?(start: moment.Moment, end: moment.Moment): void; + /** + * Fired when a user goes back an interval. Returns moment.js objects for + * the updated start and end date. + */ + previousInterval?(start: moment.Moment, end: moment.Moment): void; + /** + * Fired whenever the time period changes as configured in lengthOfTime. + * Returns moment.js objects for the updated start and end date. + */ + onIntervalChange?(start: moment.Moment, end: moment.Moment): void; +} + +export interface Target { + date: moment.Moment; + element: Element; + events: any[]; +} + +/** + * the target classnames that CLNDR will look for to bind events. these are the defaults. + */ +export interface Targets { + day?: string; + empty?: string; + nextButton?: string; + todayButton?: string; + previousButton?: string; + nextYearButton?: string; + previousYearButton?: string; +} + +/** + * Custom classes to avoid styling issues. pass in only the classnames that + * you wish to override. These are the defaults. + */ +export interface Classes { + past?: string; + today?: string; + event?: string; + selected?: string; + inactive?: string; + lastMonth?: string; + nextMonth?: string; + adjacentMonth?: string; +} + +/** + * CLNDR can accept events lasting more than one day! just pass in the + * multiDayEvents option and specify what the start and end fields are + * called within your event objects. See the example file for a working + * instance of this. + */ +export interface MultiDayEvents { + endDate?: string; + startDate?: string; + /** + * If you also have single day events with a different date field, + * use the singleDay property and point it to the date field. + */ + singleDay?: string; +} + +/** + * CLNDR can render in any time interval! + * You can specify if you want to render one or more months, or one ore more + * days in the calendar, as well as the paging interval whenever forward or + * back is triggered. If both months and days are null, CLNDR will default + * to the standard monthly view. + */ +export interface LengthOfTime { + /** + * Set to an integer if you want to render one or more months, otherwise + * leave this null + */ + months?: number | null; + /** + * Set to an integer if you want to render one or more days, otherwise + * leave this null. Setting this to 14 would render a 2-week calendar. + * + */ + days?: number | null; + /** + * This is the amount of months or days that will move forward/back when + * paging the calendar. With days=14 and interval=7, you would have a + * 2-week calendar that pages forward and backward 1 week at a time. + */ + interval?: number; +} + +export interface RenderData { + days: CalendarDay[]; + daysOfTheWeek: string[]; + eventsLastMonth: any[]; + eventsNextMonth: any[]; + eventsThisInterval?: any[]; + eventsThisMonth: any[]; + extras?: any; + intervalEnd?: moment.Moment; + intervalStart?: moment.Moment; + month: string; + months: Month[]; + numberOfRows: number; + year: number; +} + +export interface Month { + days: CalendarDay[]; + month: moment.Moment; +} + +export interface CalendarDay { + classes: string; + date: moment.Moment; + day: number; + events: any[]; + properties: CalendarDayProperties; +} + +export interface CalendarDayProperties { + isToday: boolean; + isInactive: boolean; + isAdjacentMonth: boolean; +} + +/** + * If you want to prevent the user from navigating the calendar outside + * of a certain date range (e.g. if you are making a datepicker), specify + * either the startDate, endDate, or both in the constraints option. You + * can change these while the calendar is on the page... See documentation + * below for more on this! + */ +export interface Constraints { + startDate?: string; + endDate?: string; +} + +declare global { + interface JQuery { + clndr(options?: ClndrOptions): ClndrInstance; + } +} diff --git a/clndr/package.json b/clndr/package.json new file mode 100644 index 0000000000..21243d59df --- /dev/null +++ b/clndr/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "moment": ">=2.8.3" + } +} \ No newline at end of file diff --git a/clndr/tsconfig.json b/clndr/tsconfig.json new file mode 100644 index 0000000000..ba5b4cfb6d --- /dev/null +++ b/clndr/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clndr-tests.ts" + ] +} diff --git a/clndr/tslint.json b/clndr/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/clndr/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From d20a983f78abfcda79fc85c66a5f0736e45ab99f Mon Sep 17 00:00:00 2001 From: Michael Loughry Date: Wed, 4 Jan 2017 22:17:35 -0800 Subject: [PATCH 096/181] Allow @types/webpack-env to coexist with @types/node (#13741) * Allow @types/webpack-env to coexist with @types/node - Took suggestion from `rikoe` in issue #11324 * Increment header version --- webpack-env/index.d.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/webpack-env/index.d.ts b/webpack-env/index.d.ts index 4831f298e1..777014c506 100644 --- a/webpack-env/index.d.ts +++ b/webpack-env/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack (module API) 1.12 +// Type definitions for webpack (module API) 1.13 // Project: https://github.com/webpack/webpack // Definitions by: use-strict // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -35,7 +35,7 @@ declare namespace __WebpackModuleApi { * * The module id is a number in webpack (in contrast to node.js where it is a string, the filename). */ - resolve(path: string): number; + resolve(path: string): number | string; /** * Like require.resolve, but doesn’t include the module into the bundle. It’s a weak dependency. */ @@ -180,7 +180,10 @@ declare namespace __WebpackModuleApi { } } -declare var require: __WebpackModuleApi.RequireFunction; +interface NodeRequire extends __WebpackModuleApi.RequireFunction { +} + +declare var require: NodeRequire; /** * The resource query of the current module. @@ -229,4 +232,6 @@ declare var __non_webpack_require__: any; */ declare var DEBUG: boolean; -declare var module: __WebpackModuleApi.Module; +interface NodeModule extends __WebpackModuleApi.Module {} + +declare var module: NodeModule; From 7655929542763b1eb3bf2f162ad982ca4efd932a Mon Sep 17 00:00:00 2001 From: Irmantas Zenkus Date: Thu, 5 Jan 2017 10:07:08 +0200 Subject: [PATCH 097/181] Type definitions for siema --- siema/index.d.ts | 28 ++++++++++++++++++++++++++++ siema/siema-tests.ts | 17 +++++++++++++++++ siema/tsconfig.json | 20 ++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 siema/index.d.ts create mode 100644 siema/siema-tests.ts create mode 100644 siema/tsconfig.json diff --git a/siema/index.d.ts b/siema/index.d.ts new file mode 100644 index 0000000000..7f9fed8cf5 --- /dev/null +++ b/siema/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for siema +// Project: https://github.com/pawelgrzybek/siema +// Definitions by: Irmantas Zenkus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare module 'siema' { + interface SiemaOptions { + selector?: string; + duration?: number; + easing?: string; + perPage?: number; + startIndex?: number; + draggable?: boolean; + threshold?: number; + loop?: boolean; + } + + class Siema { + public currentSlide: number; + + constructor(options?: SiemaOptions); + + public next(): void; + public prev(): void; + public goTo(index: number): void; + } + + export = Siema; +} diff --git a/siema/siema-tests.ts b/siema/siema-tests.ts new file mode 100644 index 0000000000..b576e8dac6 --- /dev/null +++ b/siema/siema-tests.ts @@ -0,0 +1,17 @@ +import Siema = require('siema'); + +const siema = new Siema({ + selector: '.siema', + duration: 200, + easing: 'ease-out', + perPage: 1, + startIndex: 0, + draggable: true, + threshold: 20, + loop: false, +}); + +siema.next(); +siema.prev(); +siema.goTo(0); +siema.currentSlide; diff --git a/siema/tsconfig.json b/siema/tsconfig.json new file mode 100644 index 0000000000..b7b76fb08a --- /dev/null +++ b/siema/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "siema-tests.ts" + ] +} From 763a5e57a8e1285bbec15faba46668f2d9e747c3 Mon Sep 17 00:00:00 2001 From: cervengoc Date: Thu, 5 Jan 2017 11:11:47 +0100 Subject: [PATCH 098/181] Add ko.ignoreDependencies --- knockout/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knockout/index.d.ts b/knockout/index.d.ts index 3d1b51f249..a28d06a220 100644 --- a/knockout/index.d.ts +++ b/knockout/index.d.ts @@ -529,6 +529,8 @@ interface KnockoutStatic { renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; + ignoreDependencies(callback: () => T): T; + expressionRewriting: { bindingRewriteValidators: any[]; twoWayBindings: any; From fcd23452babab7cea0d650a7f7e62023054690d6 Mon Sep 17 00:00:00 2001 From: jKey Lu Date: Thu, 5 Jan 2017 22:50:17 +0800 Subject: [PATCH 099/181] Type definitions for keygrip --- keygrip/index.d.ts | 19 +++++++++++++++++++ keygrip/keygrip-tests.ts | 4 ++++ keygrip/tsconfig.json | 20 ++++++++++++++++++++ keygrip/tslint.json | 1 + 4 files changed, 44 insertions(+) create mode 100644 keygrip/index.d.ts create mode 100644 keygrip/keygrip-tests.ts create mode 100644 keygrip/tsconfig.json create mode 100644 keygrip/tslint.json diff --git a/keygrip/index.d.ts b/keygrip/index.d.ts new file mode 100644 index 0000000000..b5929aaec6 --- /dev/null +++ b/keygrip/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for keygrip 1.0 +// Project: https://github.com/crypto-utils/keygrip +// Definitions by: jKey Lu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare interface Keygrip { + sign(data: any): string; + verify(data: any, digest: string): boolean; + index(data: any, digest: string): number; +} + +declare interface KeygripFunction { + new (keys: string[], algorithm?: string, encoding?: string): Keygrip; + (keys: string[], algorithm?: string, encoding?: string): Keygrip; +} + +declare const Keygrip: KeygripFunction; + +export = Keygrip; diff --git a/keygrip/keygrip-tests.ts b/keygrip/keygrip-tests.ts new file mode 100644 index 0000000000..afa66e04b1 --- /dev/null +++ b/keygrip/keygrip-tests.ts @@ -0,0 +1,4 @@ +import * as Keygrip from 'keygrip'; + +let keys = Keygrip(['123']); +let hash = keys.sign('abc'); diff --git a/keygrip/tsconfig.json b/keygrip/tsconfig.json new file mode 100644 index 0000000000..07650e90f3 --- /dev/null +++ b/keygrip/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "keygrip-tests.ts" + ] +} diff --git a/keygrip/tslint.json b/keygrip/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/keygrip/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 7f88646e1725c23ed4200c7585a6790160ed4fcc Mon Sep 17 00:00:00 2001 From: jKey Lu Date: Thu, 5 Jan 2017 22:56:21 +0800 Subject: [PATCH 100/181] Fix koa-compose typings and remove koa-compose 2.3.1 (#13751) * Fix koa-compose typings * remove koa-compose 2.3.1 --- koa-compose/index.d.ts | 13 ++++--------- koa-compose/koa-compose-2.3.1-tests.ts | 15 --------------- koa-compose/koa-compose-2.3.1.d.ts | 19 ------------------- koa-compose/koa-compose-tests.ts | 4 ++-- 4 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 koa-compose/koa-compose-2.3.1-tests.ts delete mode 100644 koa-compose/koa-compose-2.3.1.d.ts diff --git a/koa-compose/index.d.ts b/koa-compose/index.d.ts index c27bc3f328..6e466b9d28 100644 --- a/koa-compose/index.d.ts +++ b/koa-compose/index.d.ts @@ -1,19 +1,14 @@ -// Type definitions for koa v3.0.0 +// Type definitions for koa-compose 3.2 // Project: https://github.com/koajs/compose // Definitions by: jKey Lu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function compose(middleware: compose.Middleware[]): compose.ComposedMiddleware; +declare function compose(middleware: Array>): compose.ComposedMiddleware; declare namespace compose { - interface Middleware { - (context: any, next?: () => Promise): Promise; - } - - interface ComposedMiddleware { - (context: any): Promise; - } + type Middleware = (context: T, next: () => Promise) => any; + type ComposedMiddleware = (context: T, next?: Middleware) => Promise; } export = compose; diff --git a/koa-compose/koa-compose-2.3.1-tests.ts b/koa-compose/koa-compose-2.3.1-tests.ts deleted file mode 100644 index 3eb2db890a..0000000000 --- a/koa-compose/koa-compose-2.3.1-tests.ts +++ /dev/null @@ -1,15 +0,0 @@ - - -import compose = require('koa-compose'); - -var fn1: compose.Middleware = function *(next: void) { - console.log('in fn1'); - yield next; -} - -var fn2: compose.Middleware = function *(next: void) { - console.log('in fn2'); - yield next; -} - -var fn = compose([fn1, fn2]); \ No newline at end of file diff --git a/koa-compose/koa-compose-2.3.1.d.ts b/koa-compose/koa-compose-2.3.1.d.ts deleted file mode 100644 index be6c16498d..0000000000 --- a/koa-compose/koa-compose-2.3.1.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Type definitions for koa v2.3.1 -// Project: https://github.com/koajs/compose -// Definitions by: jKey Lu -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -declare function compose(middleware: compose.Middleware[]): compose.ComposedMiddleware; - -declare namespace compose { - interface Middleware { - (next?: void): IterableIterator; - } - - interface ComposedMiddleware { - (): IterableIterator; - } -} - -export = compose; diff --git a/koa-compose/koa-compose-tests.ts b/koa-compose/koa-compose-tests.ts index e5046b6413..2b2a65038e 100644 --- a/koa-compose/koa-compose-tests.ts +++ b/koa-compose/koa-compose-tests.ts @@ -1,13 +1,13 @@ import compose = require('koa-compose'); -var fn1: compose.Middleware = function(context: any, next: () => Promise): Promise { +var fn1: compose.Middleware = function(context: any, next: () => Promise): Promise { return Promise .resolve(console.log('in fn1')) .then(() => next()); }; -var fn2: compose.Middleware = function(context: any, next: () => Promise): Promise { +var fn2: compose.Middleware = function(context: any, next: () => Promise): Promise { return Promise .resolve(console.log('in fn2')) .then(() => next()); From fc5b949e7885af2f5f9731b0a67a07644879acff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=BCndig?= Date: Thu, 5 Jan 2017 15:57:15 +0100 Subject: [PATCH 101/181] Added definitions for KyleAMathews/deepmerge (#13752) --- deepmerge/deepmerge-tests.ts | 13 +++++++++++++ deepmerge/index.d.ts | 17 +++++++++++++++++ deepmerge/tsconfig.json | 20 ++++++++++++++++++++ deepmerge/tslint.json | 1 + 4 files changed, 51 insertions(+) create mode 100644 deepmerge/deepmerge-tests.ts create mode 100644 deepmerge/index.d.ts create mode 100644 deepmerge/tsconfig.json create mode 100644 deepmerge/tslint.json diff --git a/deepmerge/deepmerge-tests.ts b/deepmerge/deepmerge-tests.ts new file mode 100644 index 0000000000..7854f7adf1 --- /dev/null +++ b/deepmerge/deepmerge-tests.ts @@ -0,0 +1,13 @@ +import * as deepmerge from "deepmerge"; + +const x = { foo: { bar: 3 }, + array: [ { does: 'work', too: [ 1, 2, 3 ] } ] } +const y = { foo: { baz: 4 }, + quux: 5, + array: [ { does: 'work', too: [ 4, 5, 6 ] }, { really: 'yes' } ] } + +const expected = { foo: { bar: 3, baz: 4 }, + array: [ { does: 'work', too: [ 1, 2, 3, 4, 5, 6 ] }, { really: 'yes' } ], + quux: 5 } + +const result = deepmerge(x, y); \ No newline at end of file diff --git a/deepmerge/index.d.ts b/deepmerge/index.d.ts new file mode 100644 index 0000000000..bf70f62e46 --- /dev/null +++ b/deepmerge/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for deepmerge 1.3 +// Project: https://github.com/KyleAMathews/deepmerge +// Definitions by: marvinscharle +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = deepmerge; + +declare function deepmerge(x: T, y: T, options?: deepmerge.Options): T; + +declare namespace deepmerge { + interface Options { + clone?: boolean; + arrayMerge?: (destination: T, source: T, options?: Options) => T; + } + + function all(objects: T[], options?: Options): T; +} \ No newline at end of file diff --git a/deepmerge/tsconfig.json b/deepmerge/tsconfig.json new file mode 100644 index 0000000000..750aeec703 --- /dev/null +++ b/deepmerge/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "deepmerge-tests.ts" + ] +} diff --git a/deepmerge/tslint.json b/deepmerge/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/deepmerge/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From a1cbc2a5dca8a74eb561eb6933546168471523b7 Mon Sep 17 00:00:00 2001 From: BrunoLM Date: Thu, 5 Jan 2017 14:30:40 -0200 Subject: [PATCH 102/181] Add definitions for mockdate package (#13754) * Add mockdate package definition file * Fix mockdate comments * Apply revision checks on mockdate Add tslint.json Enable strciNullChecks Change definition to export functions intead of default. * Fix mockdate to export as namespace --- mockdate/index.d.ts | 18 ++++++++++++++++++ mockdate/mockdate-tests.ts | 9 +++++++++ mockdate/tsconfig.json | 20 ++++++++++++++++++++ mockdate/tslint.json | 1 + 4 files changed, 48 insertions(+) create mode 100644 mockdate/index.d.ts create mode 100644 mockdate/mockdate-tests.ts create mode 100644 mockdate/tsconfig.json create mode 100644 mockdate/tslint.json diff --git a/mockdate/index.d.ts b/mockdate/index.d.ts new file mode 100644 index 0000000000..ca97a79d75 --- /dev/null +++ b/mockdate/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for mockdate 2.0 +// Project: https://github.com/boblauer/MockDate +// Definitions by: Bruno Leonardo Michels +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace MockDate; + +/** + * Change the Date implementation to mock a specific date. + * @param Date to be set as current + * @param timezoneOffset? The value that should be returned by new Date().getTimezoneOffset() + */ +export function set(date: { valueOf(): number; } | number | string, timezoneOffset?: number): void; + +/** + * Restore the original Date object back to the native implementation. + */ +export function reset(): void; diff --git a/mockdate/mockdate-tests.ts b/mockdate/mockdate-tests.ts new file mode 100644 index 0000000000..e7854a6526 --- /dev/null +++ b/mockdate/mockdate-tests.ts @@ -0,0 +1,9 @@ +import * as mockdate from 'mockdate'; + +mockdate.set(new Date()); +mockdate.set('2017-01-05'); +mockdate.set(new Date().getTime()); + +mockdate.set(new Date(), 0); + +mockdate.reset(); diff --git a/mockdate/tsconfig.json b/mockdate/tsconfig.json new file mode 100644 index 0000000000..9b92b9f946 --- /dev/null +++ b/mockdate/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mockdate-tests.ts" + ] +} diff --git a/mockdate/tslint.json b/mockdate/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/mockdate/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From ff2d63b83b81c4afa8d451276fc0eb78f9248b38 Mon Sep 17 00:00:00 2001 From: Martin D Date: Thu, 5 Jan 2017 12:26:08 -0500 Subject: [PATCH 103/181] TinyMCE typings (WIP) (#13728) * TinyMCE typings * TinyMCE declaration file * Update tsconfig.json Changed `strictNullChecks` to true and added `noImplicitThis` * Update index.d.ts Added namespace * Update index.d.ts --- tinymce/index.d.ts | 44 ++++++++++++++++++++++++++++++++++++++++ tinymce/tinymce-tests.ts | 12 +++++++++++ tinymce/tsconfig.json | 20 ++++++++++++++++++ tinymce/tslint.json | 1 + 4 files changed, 77 insertions(+) create mode 100644 tinymce/index.d.ts create mode 100644 tinymce/tinymce-tests.ts create mode 100644 tinymce/tsconfig.json create mode 100644 tinymce/tslint.json diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts new file mode 100644 index 0000000000..f760671a8e --- /dev/null +++ b/tinymce/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for TinyMCE 4.5 +// Project: https://github.com/tinymce/tinymce +// Definitions by: Martin Duparc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Work In Progress + +declare namespace TinyMCE { + export interface Observable { + off: (name?: string, callback?: () => void) => any; + on: (name: string, callback: () => void) => any; + fire: (name: string, args?: any, bubble?: boolean) => Event; + } + + export interface Editor extends Observable { + destroy: (automatic: boolean) => void; + remove: () => void; + hide: () => void; + show: () => void; + getContent: (args?: any) => string; + setContent: (content: string, args?: any) => string; + focus: (skip_focus?: boolean) => void; + undoManager: UndoManager; + settings: any; + getDoc: () => Document; + editorUpload: any; + } + + export interface UndoManager { + undo: () => any; + clear: () => void; + hasUndo: () => boolean; + } + + export interface Static extends Observable { + init: (settings: any) => void; + execCommand: (c: string, u: boolean, v: string) => boolean; + activeEditor: Editor; + get: (id: string) => Editor; + triggerSave: () => void; + } +} + +declare var tinymce: TinyMCE.Static; diff --git a/tinymce/tinymce-tests.ts b/tinymce/tinymce-tests.ts new file mode 100644 index 0000000000..3b3f3386f1 --- /dev/null +++ b/tinymce/tinymce-tests.ts @@ -0,0 +1,12 @@ +tinymce.init( + { + selector: '.tinymce-editable', + height: 145, + plugins: [ + 'autolink table contextmenu paste code link textcolor colorpicker image imagetools' + ], + menubar: 'edit insert table tools', + toolbar: 'undo redo | styleselect bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | link image', + content_css: 'page.css' + } +); \ No newline at end of file diff --git a/tinymce/tsconfig.json b/tinymce/tsconfig.json new file mode 100644 index 0000000000..313fa73f47 --- /dev/null +++ b/tinymce/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "tinymce-tests.ts" + ] +} diff --git a/tinymce/tslint.json b/tinymce/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/tinymce/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 5757550c40d21532db4446fe31d6879fa45ddab8 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 5 Jan 2017 09:36:46 -0800 Subject: [PATCH 104/181] Do not use `Node` and `NodeList` in rx-lite defintions (#13737) * Fix https://github.com/DefinitelyTyped/DefinitelyTyped/issues/13733: Do not use `Node` and `NodeList` and instead define `DOMEventTarget` - Also adds NodeEventTarget support * Fix lint errors * Make selector take variable number of arguments * Make selector take variable number of arguments --- rx-lite/index.d.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/rx-lite/index.d.ts b/rx-lite/index.d.ts index eea7a2bfad..fb5056c478 100644 --- a/rx-lite/index.d.ts +++ b/rx-lite/index.d.ts @@ -649,13 +649,27 @@ declare namespace Rx { (func: Function, context?: any): (...args: any[]) => Observable; }; - fromEvent(element: NodeList, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEvent(element: Node, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEvent(element: { on: (name: string, cb: (e: any) => any) => void; off: (name: string, cb: (e: any) => any) => void }, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[]) => T): Observable; + fromEvent(element: ArrayLike | DOMEventTarget | NodeEventTarget| NativeEventTarget, eventName: string, selector?: (...args: any[]) => T): Observable; + + fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (...args: any[]) => T): Observable; + } + + interface NodeEventTarget { + addListener: (name: string, cb: (e: any) => any) => void; + } + + interface NativeEventTarget { + on: (name: string, cb: (e: any) => any) => void; + off: (name: string, cb: (e: any) => any) => void; + } + + interface DOMEventTarget { + addEventListener(type: string, listener: (e: any) => any, useCapture: boolean): void; + removeEventListener(type: string, listener: (e: any) => any, useCapture: boolean): void; } } + // time declare namespace Rx { From 8b1d75f1b7f4555be6994c3d602b329e80857135 Mon Sep 17 00:00:00 2001 From: Pierre Chaussalet Date: Thu, 5 Jan 2017 10:52:30 -0800 Subject: [PATCH 105/181] Fix appendHash property type in hasher --- hasher/hasher-tests.ts | 2 ++ hasher/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hasher/hasher-tests.ts b/hasher/hasher-tests.ts index 5e988c7601..e250f4dad5 100644 --- a/hasher/hasher-tests.ts +++ b/hasher/hasher-tests.ts @@ -11,4 +11,6 @@ hasher.init(); //initialize hasher (start listening for history changes) hasher.setHash('foo'); //change hash value (generates new history record) +hasher.appendHash = '?test=true'; + hasher.prependHash = '!'; //default value is "/" diff --git a/hasher/index.d.ts b/hasher/index.d.ts index b71b6b1d2b..180290145a 100644 --- a/hasher/index.d.ts +++ b/hasher/index.d.ts @@ -13,7 +13,7 @@ declare namespace HasherJs { // {string} hasher.appendHash // String that should always be added to the end of Hash value. - appendHash(): string; + appendHash: string; // default value: ''; // will be automatically removed from `hasher.getHash()` From 989a69ee7c89ba91f738783c66d9a1d70e8093a1 Mon Sep 17 00:00:00 2001 From: Tristan Jones Date: Thu, 5 Jan 2017 11:11:57 -0800 Subject: [PATCH 106/181] Node emoji (#13764) * Added definitions for node-emoji * Added test for node-emoji --- node-emoji/index.d.ts | 1353 ++++++++++++++++++++++++++++++++ node-emoji/node-emoji-tests.ts | 12 + node-emoji/tsconfig.json | 20 + node-emoji/tslint.json | 1 + 4 files changed, 1386 insertions(+) create mode 100644 node-emoji/index.d.ts create mode 100644 node-emoji/node-emoji-tests.ts create mode 100644 node-emoji/tsconfig.json create mode 100644 node-emoji/tslint.json diff --git a/node-emoji/index.d.ts b/node-emoji/index.d.ts new file mode 100644 index 0000000000..52fc6fd6b9 --- /dev/null +++ b/node-emoji/index.d.ts @@ -0,0 +1,1353 @@ +// Type definitions for node-emoji 1.4 +// Project: https://github.com/omnidan/node-emoji#readme +// Definitions by: Tristan Jones +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export const emoji: { + "+1": string; + "-1": string; + "100": string; + "1234": string; + "8ball": string; + a: string; + ab: string; + abc: string; + abcd: string; + accept: string; + admission_tickets: string; + aerial_tramway: string; + airplane: string; + airplane_arriving: string; + airplane_departure: string; + alarm_clock: string; + alembic: string; + alien: string; + ambulance: string; + amphora: string; + anchor: string; + angel: string; + anger: string; + angry: string; + anguished: string; + ant: string; + apple: string; + aquarius: string; + aries: string; + arrow_backward: string; + arrow_double_down: string; + arrow_double_up: string; + arrow_down: string; + arrow_down_small: string; + arrow_forward: string; + arrow_heading_down: string; + arrow_heading_up: string; + arrow_left: string; + arrow_lower_left: string; + arrow_lower_right: string; + arrow_right: string; + arrow_right_hook: string; + arrow_up: string; + arrow_up_down: string; + arrow_up_small: string; + arrow_upper_left: string; + arrow_upper_right: string; + arrows_clockwise: string; + arrows_counterclockwise: string; + art: string; + articulated_lorry: string; + astonished: string; + athletic_shoe: string; + atm: string; + atom_symbol: string; + b: string; + baby: string; + baby_bottle: string; + baby_chick: string; + baby_symbol: string; + back: string; + badminton_racquet_and_shuttlecock: string; + baggage_claim: string; + balloon: string; + ballot_box_with_ballot: string; + ballot_box_with_check: string; + bamboo: string; + banana: string; + bangbang: string; + bank: string; + bar_chart: string; + barber: string; + barely_sunny: string; + baseball: string; + basketball: string; + bath: string; + bathtub: string; + battery: string; + beach_with_umbrella: string; + bear: string; + bed: string; + bee: string; + beer: string; + beers: string; + beetle: string; + beginner: string; + bell: string; + bellhop_bell: string; + bento: string; + bicyclist: string; + bike: string; + bikini: string; + biohazard_sign: string; + bird: string; + birthday: string; + black_circle: string; + black_circle_for_record: string; + black_joker: string; + black_large_square: string; + black_left_pointing_double_triangle_with_vertical_bar: string; + black_medium_small_square: string; + black_medium_square: string; + black_nib: string; + black_right_pointing_double_triangle_with_vertical_bar: string; + black_right_pointing_triangle_with_double_vertical_bar: string; + black_small_square: string; + black_square_button: string; + black_square_for_stop: string; + blossom: string; + blowfish: string; + blue_book: string; + blue_car: string; + blue_heart: string; + blush: string; + boar: string; + boat: string; + bomb: string; + book: string; + bookmark: string; + bookmark_tabs: string; + books: string; + boom: string; + boot: string; + bouquet: string; + bow: string; + bow_and_arrow: string; + bowling: string; + boy: string; + bread: string; + bride_with_veil: string; + bridge_at_night: string; + briefcase: string; + broken_heart: string; + bug: string; + building_construction: string; + bulb: string; + bullettrain_front: string; + bullettrain_side: string; + burrito: string; + bus: string; + busstop: string; + bust_in_silhouette: string; + busts_in_silhouette: string; + cactus: string; + cake: string; + calendar: string; + calling: string; + camel: string; + camera: string; + camera_with_flash: string; + camping: string; + cancer: string; + candle: string; + candy: string; + capital_abcd: string; + capricorn: string; + car: string; + card_file_box: string; + card_index: string; + card_index_dividers: string; + carousel_horse: string; + cat: string; + cat2: string; + cd: string; + chains: string; + champagne: string; + chart: string; + chart_with_downwards_trend: string; + chart_with_upwards_trend: string; + checkered_flag: string; + cheese_wedge: string; + cherries: string; + cherry_blossom: string; + chestnut: string; + chicken: string; + children_crossing: string; + chipmunk: string; + chocolate_bar: string; + christmas_tree: string; + church: string; + cinema: string; + circus_tent: string; + city_sunrise: string; + city_sunset: string; + cityscape: string; + cl: string; + clap: string; + clapper: string; + classical_building: string; + clipboard: string; + clock1: string; + clock10: string; + clock1030: string; + clock11: string; + clock1130: string; + clock12: string; + clock1230: string; + clock130: string; + clock2: string; + clock230: string; + clock3: string; + clock330: string; + clock4: string; + clock430: string; + clock5: string; + clock530: string; + clock6: string; + clock630: string; + clock7: string; + clock730: string; + clock8: string; + clock830: string; + clock9: string; + clock930: string; + closed_book: string; + closed_lock_with_key: string; + closed_umbrella: string; + cloud: string; + clubs: string; + cn: string; + cocktail: string; + coffee: string; + coffin: string; + cold_sweat: string; + collision: string; + comet: string; + compression: string; + computer: string; + confetti_ball: string; + confounded: string; + confused: string; + congratulations: string; + construction: string; + construction_worker: string; + control_knobs: string; + convenience_store: string; + cookie: string; + cool: string; + cop: string; + copyright: string; + corn: string; + couch_and_lamp: string; + couple: string; + couple_with_heart: string; + couplekiss: string; + cow: string; + cow2: string; + crab: string; + credit_card: string; + crescent_moon: string; + cricket_bat_and_ball: string; + crocodile: string; + crossed_flags: string; + crossed_swords: string; + crown: string; + cry: string; + crying_cat_face: string; + crystal_ball: string; + cupid: string; + curly_loop: string; + currency_exchange: string; + curry: string; + custard: string; + customs: string; + cyclone: string; + dagger_knife: string; + dancer: string; + dancers: string; + dango: string; + dark_sunglasses: string; + dart: string; + dash: string; + date: string; + de: string; + deciduous_tree: string; + department_store: string; + derelict_house_building: string; + desert: string; + desert_island: string; + desktop_computer: string; + diamond_shape_with_a_dot_inside: string; + diamonds: string; + disappointed: string; + disappointed_relieved: string; + dizzy: string; + dizzy_face: string; + do_not_litter: string; + dog: string; + dog2: string; + dollar: string; + dolls: string; + dolphin: string; + door: string; + double_vertical_bar: string; + doughnut: string; + dove_of_peace: string; + dragon: string; + dragon_face: string; + dress: string; + dromedary_camel: string; + droplet: string; + dvd: string; + "e-mail": string; + ear: string; + ear_of_rice: string; + earth_africa: string; + earth_americas: string; + earth_asia: string; + egg: string; + eggplant: string; + eight: string; + eight_pointed_black_star: string; + eight_spoked_asterisk: string; + electric_plug: string; + elephant: string; + email: string; + end: string; + envelope: string; + envelope_with_arrow: string; + es: string; + euro: string; + european_castle: string; + european_post_office: string; + evergreen_tree: string; + exclamation: string; + expressionless: string; + eye: string; + eyeglasses: string; + eyes: string; + face_with_head_bandage: string; + face_with_rolling_eyes: string; + face_with_thermometer: string; + facepunch: string; + factory: string; + fallen_leaf: string; + family: string; + fast_forward: string; + fax: string; + fearful: string; + feet: string; + ferris_wheel: string; + ferry: string; + field_hockey_stick_and_ball: string; + file_cabinet: string; + file_folder: string; + film_frames: string; + film_projector: string; + fire: string; + fire_engine: string; + fireworks: string; + first_quarter_moon: string; + first_quarter_moon_with_face: string; + fish: string; + fish_cake: string; + fishing_pole_and_fish: string; + fist: string; + five: string; + "flag-ac": string; + "flag-ad": string; + "flag-ae": string; + "flag-af": string; + "flag-ag": string; + "flag-ai": string; + "flag-al": string; + "flag-am": string; + "flag-ao": string; + "flag-aq": string; + "flag-ar": string; + "flag-as": string; + "flag-at": string; + "flag-au": string; + "flag-aw": string; + "flag-ax": string; + "flag-az": string; + "flag-ba": string; + "flag-bb": string; + "flag-bd": string; + "flag-be": string; + "flag-bf": string; + "flag-bg": string; + "flag-bh": string; + "flag-bi": string; + "flag-bj": string; + "flag-bl": string; + "flag-bm": string; + "flag-bn": string; + "flag-bo": string; + "flag-bq": string; + "flag-br": string; + "flag-bs": string; + "flag-bt": string; + "flag-bv": string; + "flag-bw": string; + "flag-by": string; + "flag-bz": string; + "flag-ca": string; + "flag-cc": string; + "flag-cd": string; + "flag-cf": string; + "flag-cg": string; + "flag-ch": string; + "flag-ci": string; + "flag-ck": string; + "flag-cl": string; + "flag-cm": string; + "flag-cn": string; + "flag-co": string; + "flag-cp": string; + "flag-cr": string; + "flag-cu": string; + "flag-cv": string; + "flag-cw": string; + "flag-cx": string; + "flag-cy": string; + "flag-cz": string; + "flag-de": string; + "flag-dg": string; + "flag-dj": string; + "flag-dk": string; + "flag-dm": string; + "flag-do": string; + "flag-dz": string; + "flag-ea": string; + "flag-ec": string; + "flag-ee": string; + "flag-eg": string; + "flag-eh": string; + "flag-er": string; + "flag-es": string; + "flag-et": string; + "flag-eu": string; + "flag-fi": string; + "flag-fj": string; + "flag-fk": string; + "flag-fm": string; + "flag-fo": string; + "flag-fr": string; + "flag-ga": string; + "flag-gb": string; + "flag-gd": string; + "flag-ge": string; + "flag-gf": string; + "flag-gg": string; + "flag-gh": string; + "flag-gi": string; + "flag-gl": string; + "flag-gm": string; + "flag-gn": string; + "flag-gp": string; + "flag-gq": string; + "flag-gr": string; + "flag-gs": string; + "flag-gt": string; + "flag-gu": string; + "flag-gw": string; + "flag-gy": string; + "flag-hk": string; + "flag-hm": string; + "flag-hn": string; + "flag-hr": string; + "flag-ht": string; + "flag-hu": string; + "flag-ic": string; + "flag-id": string; + "flag-ie": string; + "flag-il": string; + "flag-im": string; + "flag-in": string; + "flag-io": string; + "flag-iq": string; + "flag-ir": string; + "flag-is": string; + "flag-it": string; + "flag-je": string; + "flag-jm": string; + "flag-jo": string; + "flag-jp": string; + "flag-ke": string; + "flag-kg": string; + "flag-kh": string; + "flag-ki": string; + "flag-km": string; + "flag-kn": string; + "flag-kp": string; + "flag-kr": string; + "flag-kw": string; + "flag-ky": string; + "flag-kz": string; + "flag-la": string; + "flag-lb": string; + "flag-lc": string; + "flag-li": string; + "flag-lk": string; + "flag-lr": string; + "flag-ls": string; + "flag-lt": string; + "flag-lu": string; + "flag-lv": string; + "flag-ly": string; + "flag-ma": string; + "flag-mc": string; + "flag-md": string; + "flag-me": string; + "flag-mf": string; + "flag-mg": string; + "flag-mh": string; + "flag-mk": string; + "flag-ml": string; + "flag-mm": string; + "flag-mn": string; + "flag-mo": string; + "flag-mp": string; + "flag-mq": string; + "flag-mr": string; + "flag-ms": string; + "flag-mt": string; + "flag-mu": string; + "flag-mv": string; + "flag-mw": string; + "flag-mx": string; + "flag-my": string; + "flag-mz": string; + "flag-na": string; + "flag-nc": string; + "flag-ne": string; + "flag-nf": string; + "flag-ng": string; + "flag-ni": string; + "flag-nl": string; + "flag-no": string; + "flag-np": string; + "flag-nr": string; + "flag-nu": string; + "flag-nz": string; + "flag-om": string; + "flag-pa": string; + "flag-pe": string; + "flag-pf": string; + "flag-pg": string; + "flag-ph": string; + "flag-pk": string; + "flag-pl": string; + "flag-pm": string; + "flag-pn": string; + "flag-pr": string; + "flag-ps": string; + "flag-pt": string; + "flag-pw": string; + "flag-py": string; + "flag-qa": string; + "flag-re": string; + "flag-ro": string; + "flag-rs": string; + "flag-ru": string; + "flag-rw": string; + "flag-sa": string; + "flag-sb": string; + "flag-sc": string; + "flag-sd": string; + "flag-se": string; + "flag-sg": string; + "flag-sh": string; + "flag-si": string; + "flag-sj": string; + "flag-sk": string; + "flag-sl": string; + "flag-sm": string; + "flag-sn": string; + "flag-so": string; + "flag-sr": string; + "flag-ss": string; + "flag-st": string; + "flag-sv": string; + "flag-sx": string; + "flag-sy": string; + "flag-sz": string; + "flag-ta": string; + "flag-tc": string; + "flag-td": string; + "flag-tf": string; + "flag-tg": string; + "flag-th": string; + "flag-tj": string; + "flag-tk": string; + "flag-tl": string; + "flag-tm": string; + "flag-tn": string; + "flag-to": string; + "flag-tr": string; + "flag-tt": string; + "flag-tv": string; + "flag-tw": string; + "flag-tz": string; + "flag-ua": string; + "flag-ug": string; + "flag-um": string; + "flag-us": string; + "flag-uy": string; + "flag-uz": string; + "flag-va": string; + "flag-vc": string; + "flag-ve": string; + "flag-vg": string; + "flag-vi": string; + "flag-vn": string; + "flag-vu": string; + "flag-wf": string; + "flag-ws": string; + "flag-xk": string; + "flag-ye": string; + "flag-yt": string; + "flag-za": string; + "flag-zm": string; + "flag-zw": string; + flags: string; + flashlight: string; + fleur_de_lis: string; + flipper: string; + floppy_disk: string; + flower_playing_cards: string; + flushed: string; + fog: string; + foggy: string; + football: string; + footprints: string; + fork_and_knife: string; + fountain: string; + four: string; + four_leaf_clover: string; + fr: string; + frame_with_picture: string; + free: string; + fried_shrimp: string; + fries: string; + frog: string; + frowning: string; + fuelpump: string; + full_moon: string; + full_moon_with_face: string; + funeral_urn: string; + game_die: string; + gb: string; + gear: string; + gem: string; + gemini: string; + ghost: string; + gift: string; + gift_heart: string; + girl: string; + globe_with_meridians: string; + goat: string; + golf: string; + golfer: string; + grapes: string; + green_apple: string; + green_book: string; + green_heart: string; + grey_exclamation: string; + grey_question: string; + grimacing: string; + grin: string; + grinning: string; + guardsman: string; + guitar: string; + gun: string; + haircut: string; + hamburger: string; + hammer: string; + hammer_and_pick: string; + hammer_and_wrench: string; + hamster: string; + hand: string; + handbag: string; + hankey: string; + hash: string; + hatched_chick: string; + hatching_chick: string; + headphones: string; + hear_no_evil: string; + heart: string; + heart_decoration: string; + heart_eyes: string; + heart_eyes_cat: string; + heartbeat: string; + heartpulse: string; + hearts: string; + heavy_check_mark: string; + heavy_division_sign: string; + heavy_dollar_sign: string; + heavy_exclamation_mark: string; + heavy_heart_exclamation_mark_ornament: string; + heavy_minus_sign: string; + heavy_multiplication_x: string; + heavy_plus_sign: string; + helicopter: string; + helmet_with_white_cross: string; + herb: string; + hibiscus: string; + high_brightness: string; + high_heel: string; + hocho: string; + hole: string; + honey_pot: string; + honeybee: string; + horse: string; + horse_racing: string; + hospital: string; + hot_pepper: string; + hotdog: string; + hotel: string; + hotsprings: string; + hourglass: string; + hourglass_flowing_sand: string; + house: string; + house_buildings: string; + house_with_garden: string; + hugging_face: string; + hushed: string; + ice_cream: string; + ice_hockey_stick_and_puck: string; + ice_skate: string; + icecream: string; + id: string; + ideograph_advantage: string; + imp: string; + inbox_tray: string; + incoming_envelope: string; + information_desk_person: string; + information_source: string; + innocent: string; + interrobang: string; + iphone: string; + it: string; + izakaya_lantern: string; + jack_o_lantern: string; + japan: string; + japanese_castle: string; + japanese_goblin: string; + japanese_ogre: string; + jeans: string; + joy: string; + joy_cat: string; + joystick: string; + jp: string; + kaaba: string; + key: string; + keyboard: string; + keycap_star: string; + keycap_ten: string; + kimono: string; + kiss: string; + kissing: string; + kissing_cat: string; + kissing_closed_eyes: string; + kissing_heart: string; + kissing_smiling_eyes: string; + knife: string; + knife_fork_plate: string; + koala: string; + koko: string; + kr: string; + label: string; + lantern: string; + large_blue_circle: string; + large_blue_diamond: string; + large_orange_diamond: string; + last_quarter_moon: string; + last_quarter_moon_with_face: string; + latin_cross: string; + laughing: string; + leaves: string; + ledger: string; + left_luggage: string; + left_right_arrow: string; + left_speech_bubble: string; + leftwards_arrow_with_hook: string; + lemon: string; + leo: string; + leopard: string; + level_slider: string; + libra: string; + light_rail: string; + lightning: string; + lightning_cloud: string; + link: string; + linked_paperclips: string; + lion_face: string; + lips: string; + lipstick: string; + lock: string; + lock_with_ink_pen: string; + lollipop: string; + loop: string; + loud_sound: string; + loudspeaker: string; + love_hotel: string; + love_letter: string; + low_brightness: string; + lower_left_ballpoint_pen: string; + lower_left_crayon: string; + lower_left_fountain_pen: string; + lower_left_paintbrush: string; + m: string; + mag: string; + mag_right: string; + mahjong: string; + mailbox: string; + mailbox_closed: string; + mailbox_with_mail: string; + mailbox_with_no_mail: string; + man: string; + "man-heart-man": string; + "man-kiss-man": string; + "man-man-boy": string; + "man-man-boy-boy": string; + "man-man-girl": string; + "man-man-girl-boy": string; + "man-man-girl-girl": string; + "man-woman-boy": string; + "man-woman-boy-boy": string; + "man-woman-girl": string; + "man-woman-girl-boy": string; + "man-woman-girl-girl": string; + man_and_woman_holding_hands: string; + man_in_business_suit_levitating: string; + man_with_gua_pi_mao: string; + man_with_turban: string; + mans_shoe: string; + mantelpiece_clock: string; + maple_leaf: string; + mask: string; + massage: string; + meat_on_bone: string; + medal: string; + mega: string; + melon: string; + memo: string; + menorah_with_nine_branches: string; + mens: string; + metro: string; + microphone: string; + microscope: string; + middle_finger: string; + milky_way: string; + minibus: string; + minidisc: string; + mobile_phone_off: string; + money_mouth_face: string; + money_with_wings: string; + moneybag: string; + monkey: string; + monkey_face: string; + monorail: string; + moon: string; + mortar_board: string; + mosque: string; + mostly_sunny: string; + motor_boat: string; + motorway: string; + mount_fuji: string; + mountain: string; + mountain_bicyclist: string; + mountain_cableway: string; + mountain_railway: string; + mouse: string; + mouse2: string; + movie_camera: string; + moyai: string; + muscle: string; + mushroom: string; + musical_keyboard: string; + musical_note: string; + musical_score: string; + mute: string; + nail_care: string; + name_badge: string; + national_park: string; + necktie: string; + negative_squared_cross_mark: string; + nerd_face: string; + neutral_face: string; + new: string; + new_moon: string; + new_moon_with_face: string; + newspaper: string; + ng: string; + night_with_stars: string; + nine: string; + no_bell: string; + no_bicycles: string; + no_entry: string; + no_entry_sign: string; + no_good: string; + no_mobile_phones: string; + no_mouth: string; + no_pedestrians: string; + no_smoking: string; + "non-potable_water": string; + nose: string; + notebook: string; + notebook_with_decorative_cover: string; + notes: string; + nut_and_bolt: string; + o: string; + o2: string; + ocean: string; + octopus: string; + oden: string; + office: string; + oil_drum: string; + ok: string; + ok_hand: string; + ok_woman: string; + old_key: string; + older_man: string; + older_woman: string; + om_symbol: string; + on: string; + oncoming_automobile: string; + oncoming_bus: string; + oncoming_police_car: string; + oncoming_taxi: string; + one: string; + open_book: string; + open_file_folder: string; + open_hands: string; + open_mouth: string; + ophiuchus: string; + orange_book: string; + orthodox_cross: string; + outbox_tray: string; + ox: string; + package: string; + page_facing_up: string; + page_with_curl: string; + pager: string; + palm_tree: string; + panda_face: string; + paperclip: string; + parking: string; + part_alternation_mark: string; + partly_sunny: string; + partly_sunny_rain: string; + passenger_ship: string; + passport_control: string; + paw_prints: string; + peace_symbol: string; + peach: string; + pear: string; + pencil: string; + pencil2: string; + penguin: string; + pensive: string; + performing_arts: string; + persevere: string; + person_frowning: string; + person_with_ball: string; + person_with_blond_hair: string; + person_with_pouting_face: string; + phone: string; + pick: string; + pig: string; + pig2: string; + pig_nose: string; + pill: string; + pineapple: string; + pisces: string; + pizza: string; + place_of_worship: string; + point_down: string; + point_left: string; + point_right: string; + point_up: string; + point_up_2: string; + police_car: string; + poodle: string; + poop: string; + popcorn: string; + post_office: string; + postal_horn: string; + postbox: string; + potable_water: string; + pouch: string; + poultry_leg: string; + pound: string; + pouting_cat: string; + pray: string; + prayer_beads: string; + princess: string; + printer: string; + punch: string; + purple_heart: string; + purse: string; + pushpin: string; + put_litter_in_its_place: string; + question: string; + rabbit: string; + rabbit2: string; + racehorse: string; + racing_car: string; + racing_motorcycle: string; + radio: string; + radio_button: string; + radioactive_sign: string; + rage: string; + railway_car: string; + railway_track: string; + rain_cloud: string; + rainbow: string; + raised_hand: string; + raised_hand_with_fingers_splayed: string; + raised_hands: string; + raising_hand: string; + ram: string; + ramen: string; + rat: string; + recycle: string; + red_car: string; + red_circle: string; + registered: string; + relaxed: string; + relieved: string; + reminder_ribbon: string; + repeat: string; + repeat_one: string; + restroom: string; + reversed_hand_with_middle_finger_extended: string; + revolving_hearts: string; + rewind: string; + ribbon: string; + rice: string; + rice_ball: string; + rice_cracker: string; + rice_scene: string; + right_anger_bubble: string; + ring: string; + robot_face: string; + rocket: string; + rolled_up_newspaper: string; + roller_coaster: string; + rooster: string; + rose: string; + rosette: string; + rotating_light: string; + round_pushpin: string; + rowboat: string; + ru: string; + rugby_football: string; + runner: string; + running: string; + running_shirt_with_sash: string; + sa: string; + sagittarius: string; + sailboat: string; + sake: string; + sandal: string; + santa: string; + satellite: string; + satisfied: string; + saxophone: string; + scales: string; + school: string; + school_satchel: string; + scissors: string; + scorpion: string; + scorpius: string; + scream: string; + scream_cat: string; + scroll: string; + seat: string; + secret: string; + see_no_evil: string; + seedling: string; + seven: string; + shamrock: string; + shaved_ice: string; + sheep: string; + shell: string; + shield: string; + shinto_shrine: string; + ship: string; + shirt: string; + shit: string; + shoe: string; + shopping_bags: string; + shower: string; + showman: string; + sign_of_the_horns: string; + signal_strength: string; + six: string; + six_pointed_star: string; + ski: string; + skier: string; + "skin-tone-2": string; + "skin-tone-3": string; + "skin-tone-4": string; + "skin-tone-5": string; + "skin-tone-6": string; + skull: string; + skull_and_crossbones: string; + sleeping: string; + sleeping_accommodation: string; + sleepy: string; + sleuth_or_spy: string; + slightly_frowning_face: string; + slightly_smiling_face: string; + slot_machine: string; + small_airplane: string; + small_blue_diamond: string; + small_orange_diamond: string; + small_red_triangle: string; + small_red_triangle_down: string; + smile: string; + smile_cat: string; + smiley: string; + smiley_cat: string; + smiling_imp: string; + smirk: string; + smirk_cat: string; + smoking: string; + snail: string; + snake: string; + snow_capped_mountain: string; + snow_cloud: string; + snowboarder: string; + snowflake: string; + snowman: string; + sob: string; + soccer: string; + soon: string; + sos: string; + sound: string; + space_invader: string; + spades: string; + spaghetti: string; + sparkle: string; + sparkler: string; + sparkles: string; + sparkling_heart: string; + speak_no_evil: string; + speaker: string; + speaking_head_in_silhouette: string; + speech_balloon: string; + speedboat: string; + spider: string; + spider_web: string; + spiral_calendar_pad: string; + spiral_note_pad: string; + "spock-hand": string; + sports_medal: string; + stadium: string; + star: string; + star2: string; + star_and_crescent: string; + star_of_david: string; + stars: string; + station: string; + statue_of_liberty: string; + steam_locomotive: string; + stew: string; + stopwatch: string; + straight_ruler: string; + strawberry: string; + stuck_out_tongue: string; + stuck_out_tongue_closed_eyes: string; + stuck_out_tongue_winking_eye: string; + studio_microphone: string; + sun_behind_cloud: string; + sun_behind_rain_cloud: string; + sun_small_cloud: string; + sun_with_face: string; + sunflower: string; + sunglasses: string; + sunny: string; + sunrise: string; + sunrise_over_mountains: string; + surfer: string; + sushi: string; + suspension_railway: string; + sweat: string; + sweat_drops: string; + sweat_smile: string; + sweet_potato: string; + swimmer: string; + symbols: string; + synagogue: string; + syringe: string; + table_tennis_paddle_and_ball: string; + taco: string; + tada: string; + tanabata_tree: string; + tangerine: string; + taurus: string; + taxi: string; + tea: string; + telephone: string; + telephone_receiver: string; + telescope: string; + tennis: string; + tent: string; + the_horns: string; + thermometer: string; + thinking_face: string; + thought_balloon: string; + three: string; + three_button_mouse: string; + thumbsdown: string; + thumbsup: string; + thunder_cloud_and_rain: string; + ticket: string; + tiger: string; + tiger2: string; + timer_clock: string; + tired_face: string; + tm: string; + toilet: string; + tokyo_tower: string; + tomato: string; + tongue: string; + top: string; + tophat: string; + tornado: string; + tornado_cloud: string; + trackball: string; + tractor: string; + traffic_light: string; + train: string; + train2: string; + tram: string; + triangular_flag_on_post: string; + triangular_ruler: string; + trident: string; + triumph: string; + trolleybus: string; + trophy: string; + tropical_drink: string; + tropical_fish: string; + truck: string; + trumpet: string; + tshirt: string; + tulip: string; + turkey: string; + turtle: string; + tv: string; + twisted_rightwards_arrows: string; + two: string; + two_hearts: string; + two_men_holding_hands: string; + two_women_holding_hands: string; + u5272: string; + u5408: string; + u55b6: string; + u6307: string; + u6708: string; + u6709: string; + u6e80: string; + u7121: string; + u7533: string; + u7981: string; + u7a7a: string; + uk: string; + umbrella: string; + umbrella_on_ground: string; + unamused: string; + underage: string; + unicorn_face: string; + unlock: string; + up: string; + upside_down_face: string; + us: string; + v: string; + vertical_traffic_light: string; + vhs: string; + vibration_mode: string; + video_camera: string; + video_game: string; + violin: string; + virgo: string; + volcano: string; + volleyball: string; + vs: string; + walking: string; + waning_crescent_moon: string; + waning_gibbous_moon: string; + warning: string; + wastebasket: string; + watch: string; + water_buffalo: string; + watermelon: string; + wave: string; + waving_black_flag: string; + waving_white_flag: string; + wavy_dash: string; + waxing_crescent_moon: string; + waxing_gibbous_moon: string; + wc: string; + weary: string; + wedding: string; + weight_lifter: string; + whale: string; + whale2: string; + wheel_of_dharma: string; + wheelchair: string; + white_check_mark: string; + white_circle: string; + white_flower: string; + white_frowning_face: string; + white_large_square: string; + white_medium_small_square: string; + white_medium_square: string; + white_small_square: string; + white_square_button: string; + wind_blowing_face: string; + wind_chime: string; + wine_glass: string; + wink: string; + wolf: string; + woman: string; + "woman-heart-woman": string; + "woman-kiss-woman": string; + "woman-woman-boy": string; + "woman-woman-boy-boy": string; + "woman-woman-girl": string; + "woman-woman-girl-boy": string; + "woman-woman-girl-girl": string; + womans_clothes: string; + womans_hat: string; + womens: string; + world_map: string; + worried: string; + wrench: string; + writing_hand: string; + x: string; + yellow_heart: string; + yen: string; + yin_yang: string; + yum: string; + zap: string; + zero: string; + zipper_mouth_face: string; + zzz: string; +}; + +export function emojify(str: string, on_missing?: (emoji_name: string) => string): string; +export function get(emoji: string): string; +export function random(): string; +export function which(emoji_code: string): string; diff --git a/node-emoji/node-emoji-tests.ts b/node-emoji/node-emoji-tests.ts new file mode 100644 index 0000000000..ebd71391fd --- /dev/null +++ b/node-emoji/node-emoji-tests.ts @@ -0,0 +1,12 @@ +import emoji = require('node-emoji'); + +let coffee: string = emoji.get('coffee'); +let result: string = emoji.random(); + +let cofee_name: string = emoji.which('☕️'); + +let emoji_string: string = emoji.emojify('I :heart: :coffee:! - :hushed::star::heart_eyes: ::: test : : :+1:+'); + +let emoji_string2: string = emoji.emojify('I :unknown_emoji: :star: :another_one:', (name: string) => name); + +let emoji_direct: string = emoji.emoji.coffee; diff --git a/node-emoji/tsconfig.json b/node-emoji/tsconfig.json new file mode 100644 index 0000000000..cf3dadcb94 --- /dev/null +++ b/node-emoji/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-emoji-tests.ts" + ] +} diff --git a/node-emoji/tslint.json b/node-emoji/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/node-emoji/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From a31c3dd12f6457b6b4e5d45b1f63475f4e04717c Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 5 Jan 2017 11:23:53 -0800 Subject: [PATCH 107/181] Clarify pull request template: new packages must be linted (#13760) --- PULL_REQUEST_TEMPLATE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 68f322eddc..4d9a7aab6f 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -14,6 +14,7 @@ If adding a new definition: - [ ] The package does not provide its own types, and you can not add them. - [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package. - [ ] Create it with `npm run new-package package-name`, not by basing it on an existing project. +- [ ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, and `strictNullChecks` set to `true`. If changing an existing definition: - [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <> From f82552638c8745c93444a4ff4ed87febeb67a776 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Thu, 5 Jan 2017 19:38:53 +0000 Subject: [PATCH 108/181] Improve keyMirror types & tests (#13738) Using mapped types from Typescript 2.1. The type returned is as we might expect from keyMirror. In the test case of: keyMirror({key1: null, key2: null}) We get the type: { key1: 'key1'; key2: 'key2'; } Instead of: { [key: string]: string; } Which is what we got before. Both check lines in the test file fail with the previous type definition. --- keymirror/index.d.ts | 3 ++- keymirror/keymirror-tests.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/keymirror/index.d.ts b/keymirror/index.d.ts index 1f2b6c01da..9a1996df83 100644 --- a/keymirror/index.d.ts +++ b/keymirror/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/STRML/keyMirror // Definitions by: Johannes Fahrenkrug // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -declare function KeyMirror(obj: {}): { [key: string]: string }; +declare function KeyMirror(obj: T): {[K in keyof T]: K}; export = KeyMirror; diff --git a/keymirror/keymirror-tests.ts b/keymirror/keymirror-tests.ts index ace29f9947..7c5dd41141 100644 --- a/keymirror/keymirror-tests.ts +++ b/keymirror/keymirror-tests.ts @@ -1,3 +1,13 @@ import keyMirror = require('keymirror'); -keyMirror({key1: null, key2: null}); +const result = keyMirror({key1: null, key2: null}); + +type Key = 'key1' | 'key2'; + +function test(value: Key) {} + +// Check that it can be accessed via [] and typechecks against the 'Key' type +test(result['key2']); + +// Check that it can be accessed as a property and typechecks against the 'Key' type +test(result.key2); From 470febda1f8c1de466c90b50e24b794d2d8466b3 Mon Sep 17 00:00:00 2001 From: Jan Molak Date: Thu, 5 Jan 2017 19:53:37 +0000 Subject: [PATCH 109/181] Support for Cucumber event listeners for TypeScript (#13552) * Added the Listener and Event types so that you can register custom cucumber event listeners in TypeScript Contribution based on the [Serenity/JS implementation](https://github.com/jan-molak/serenity-js/blob/3e733369f4fd456239c4d97ef20ae4447e407799/src/serenity-cucumber/cucumber.d.ts) * Removed myself from the list of contributors, because being there apparently breaks some regex somewhere .... * Replaced non-existent 'assert' type reference with a dummy implementation based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/4869992bc079b88280b9ff91213528904109e8ae/json-merge-patch/json-merge-patch-tests.ts * Added myself to the list of contributors as per @andy-ms instructions. Thanks! --- cucumber/cucumber-tests.ts | 14 +++- cucumber/index.d.ts | 136 ++++++++++++++++++++++++++++++++++++- 2 files changed, 148 insertions(+), 2 deletions(-) diff --git a/cucumber/cucumber-tests.ts b/cucumber/cucumber-tests.ts index 515322078d..dd92ee7c19 100644 --- a/cucumber/cucumber-tests.ts +++ b/cucumber/cucumber-tests.ts @@ -1,5 +1,5 @@ -import * as cucumber from "cucumber"; import * as assert from "power-assert"; +import cucumber = require("cucumber"); function StepSample() { type Callback = cucumber.CallbackStepDefinition; @@ -96,3 +96,15 @@ function StepSample() { cucumber.clearSupportCodeFns(); } +function registerListener(): cucumber.EventListener { + let listener = Object.assign(cucumber.Listener(), { + handleBeforeScenarioEvent: (scenario: cucumber.events.ScenarioPayload, callback: () => void) => { + + // do some interesting stuff ... + + callback(); + } + }); + + return listener; +} diff --git a/cucumber/index.d.ts b/cucumber/index.d.ts index 8756b77ea6..154e6707cc 100644 --- a/cucumber/index.d.ts +++ b/cucumber/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cucumber-js // Project: https://github.com/cucumber/cucumber-js -// Definitions by: Abraão Alves +// Definitions by: Abraão Alves , Jan Molak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = cucumber; @@ -70,6 +70,140 @@ declare namespace cucumber { Around(code: AroundCode):void; setDefaultTimeout(time:number): void; registerHandler(handlerOption:string, code:(event:any, callback:CallbackStepDefinition) =>void): void; + registerListener(listener: EventListener): void; + } + + export class EventListener { + hear(event: events.Event, callback: ()=>void): void; + hasHandlerForEvent(event: events.Event): boolean; + buildHandlerNameForEvent(event: events.Event): string; + getHandlerForEvent(event: events.Event): EventHook; + buildHandlerName(shortName: string): string; + setHandlerForEvent(shortName: string, handler: EventListener): void; + } + + export function Listener(): EventListener; + + export namespace events { + + interface Event { + getName(): string; + getPayloadItem(name: string): EventPayload; + } + + interface EventPayload { + } + + interface FeaturesPayload extends EventPayload { + getFeatures(): any[]; // https://github.com/cucumber/cucumber-js/blob/dc698bf5bc10d591fa7adeec5fa21b2d90dc9679/lib/cucumber/runtime.js#L34 + } + + interface FeaturesResultPayload extends EventPayload { + getDuration(): any; + getScenarioCounts(): any; + getStepCounts(): any; + isSuccessful(): boolean; + } + + interface FeaturePayload extends EventPayload { + getStepKeywordByLines(): any; + getScenarioKeyword(): string; + getKeyword(): string; + getName(): string; + getDescription(): string; + getUri(): string; + getLine(): number; + getTags(): Tag[]; + getScenarios(): ScenarioPayload[]; + getPayloadItem(): FeaturePayload; + } + + interface ScenarioPayload extends EventPayload { + getName(): string; + getKeyword(): string; + getDescription(): string; + getFeature(): FeaturePayload; + getUri(): string; + getUris(): string[]; + getLine(): number; + getLines(): number[]; + getTags(): Tag[]; + getSteps(): any[]; + getPayloadItem(): ScenarioPayload; + } + + interface ScenarioResultPayload extends EventPayload { + getFailureException(): Error; + getScenario(): any; + getStatus(): any; + } + + interface StepPayload extends EventPayload { + isHidden(): boolean; + isOutlineStep(): boolean; + getKeyword(): string; + getName(): string; + hasUri(): boolean; + getUri(): string; + getLine(): number; + getPreviousStep(): any; + hasPreviousStep(): boolean; + getAttachment(): any; + getAttachmentContents(): any; + getDocString(): string; + getDataTable(): any; + hasAttachment(): boolean; + hasDocString(): boolean; + hasDataTable(): boolean; + ensureDataTableIsAttached(): void; + isOutcomeStep(): boolean; + isEventStep(): boolean; + hasOutcomeStepKeyword(): boolean; + hasEventStepKeyword(): boolean; + isRepeatingOutcomeStep(): boolean; + isRepeatingEventStep(): boolean; + hasRepeatStepKeyword(): boolean; + isPrecededByOutcomeStep(): boolean; + isPrecededByEventStep(): boolean; + } + + interface StepResultPayload extends EventPayload { + getAmbiguousStepDefinitions(): any[]; + getAttachments(): any[]; + getDuration(): any; + getFailureException(): Error; + getStep(): any; + getStepDefinition(): any; + getStatus(): any; + hasAttachments(): boolean; + } + + } + + interface Tag { + getName(): string; + getLine(): number; + } + + export interface Scenario { + getKeyword(): string; + getName(): string; + getDescription(): string; + getUri(): string; + getLine(): number; + getTags(): Tag[]; + getException(): Error; + getAttachments(): any[]; + attach(data: any, mimeType?: string, callback?: (err?: any) => void): void; + isSuccessful(): boolean; + isFailed(): boolean; + isPending(): boolean; + isUndefined(): boolean; + isSkipped(): boolean; + } + + interface EventHook { + (event: events.Event, callback?: ()=>void): void; } export interface SupportCodeConsumer { From 93357460d2d30f7a85304f9e2fcd91eaae926552 Mon Sep 17 00:00:00 2001 From: Craig Date: Thu, 5 Jan 2017 11:56:02 -0800 Subject: [PATCH 110/181] chore(selenium-webdriver): split apart test files (#13573) - splitting apart test files - fix single and double quotes for consistency - replace " for ' - updated ActionSequence sendKeys (https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/lib/actions.js#L368) - updated WebElement sendKeys (https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/lib/webdriver.js#L2056) --- selenium-webdriver/chrome-tests.ts | 61 ++++++ selenium-webdriver/chrome.d.ts | 24 +-- selenium-webdriver/edge.d.ts | 8 +- selenium-webdriver/executors.d.ts | 4 +- selenium-webdriver/firefox-tests.ts | 54 ++++++ selenium-webdriver/firefox.d.ts | 6 +- selenium-webdriver/http.d.ts | 14 +- selenium-webdriver/ie.d.ts | 8 +- ...nium-webdriver-tests.ts => index-tests.ts} | 156 +++------------ selenium-webdriver/index.d.ts | 181 ++++++++++-------- selenium-webdriver/opera.d.ts | 12 +- selenium-webdriver/remote.d.ts | 4 +- selenium-webdriver/safari.d.ts | 4 +- selenium-webdriver/tsconfig.json | 8 +- 14 files changed, 289 insertions(+), 255 deletions(-) create mode 100644 selenium-webdriver/chrome-tests.ts create mode 100644 selenium-webdriver/firefox-tests.ts rename selenium-webdriver/{selenium-webdriver-tests.ts => index-tests.ts} (88%) diff --git a/selenium-webdriver/chrome-tests.ts b/selenium-webdriver/chrome-tests.ts new file mode 100644 index 0000000000..2fce6bf6ca --- /dev/null +++ b/selenium-webdriver/chrome-tests.ts @@ -0,0 +1,61 @@ +import * as chrome from 'selenium-webdriver/chrome'; +import * as remote from 'selenium-webdriver/remote'; +import * as webdriver from 'selenium-webdriver'; + +function TestChromeDriver() { + var driver: chrome.Driver = new chrome.Driver(); + driver = new chrome.Driver(webdriver.Capabilities.chrome()); + driver = new chrome.Driver(webdriver.Capabilities.chrome(), + new remote.DriverService('executable', new chrome.Options()), + new webdriver.promise.ControlFlow()); + + var baseDriver: webdriver.WebDriver = driver; +} + +function TestChromeOptions() { + var options: chrome.Options = new chrome.Options(); + options = chrome.Options.fromCapabilities(webdriver.Capabilities.chrome()); + + options = options.addArguments('a', 'b', 'c'); + options = options.addExtensions('a', 'b', 'c'); + options = options.excludeSwitches('a', 'b', 'c'); + options = options.detachDriver(true); + options = options.setChromeBinaryPath('path'); + options = options.setChromeLogFile('logfile'); + options = options.setLocalState('state'); + options = options.androidActivity('com.example.Activity'); + options = options.androidDeviceSerial('emulator-5554'); + options = options.androidChrome(); + options = options.androidPackage('com.android.chrome'); + options = options.androidProcess('com.android.chrome'); + options = options.androidUseRunningApp(true); + options = options.setLoggingPrefs(new webdriver.logging.Preferences()); + options = options.setPerfLoggingPrefs({ + enableNetwork: true, enablePage: true, enableTimeline: true, + tracingCategories: 'category', bufferUsageReportingInterval: 1000 }); + options = options.setProxy({ proxyType: 'proxyType' }); + options = options.setUserPreferences('preferences'); + var capabilities: webdriver.Capabilities = options.toCapabilities(); + capabilities = options.toCapabilities(webdriver.Capabilities.chrome()); +} + +function TestServiceBuilder() { + var builder: chrome.ServiceBuilder = new chrome.ServiceBuilder(); + builder = new chrome.ServiceBuilder('exe'); + + var anything: any = builder.build(); + builder = builder.usingPort(8080); + builder = builder.setAdbPort(5037); + builder = builder.loggingTo('path'); + builder = builder.enableVerboseLogging(); + builder = builder.setNumHttpThreads(5); + builder = builder.setUrlBasePath('path'); + builder = builder.setStdio('config'); + builder = builder.setStdio(['A', 'B']); + builder = builder.withEnvironment({ 'A': 'a', 'B': 'b' }); +} + +function TestChromeModule() { + var service: any = chrome.getDefaultService(); + chrome.setDefaultService(new remote.DriverService('executable', new chrome.Options())); +} diff --git a/selenium-webdriver/chrome.d.ts b/selenium-webdriver/chrome.d.ts index 55717d596d..2ecff8d2f8 100644 --- a/selenium-webdriver/chrome.d.ts +++ b/selenium-webdriver/chrome.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace chrome { /** @@ -58,9 +58,9 @@ declare namespace chrome { /** * Add additional command line arguments to use when launching the Chrome - * browser. Each argument may be specified with or without the "--" prefix - * (e.g. "--foo" and "foo"). Arguments with an associated value should be - * delimited by an "=": "foo=bar". + * browser. Each argument may be specified with or without the '--' prefix + * (e.g. '--foo' and 'foo'). Arguments with an associated value should be + * delimited by an '=': 'foo=bar'. * @param {...(string|!Array.)} var_args The arguments to add. * @return {!Options} A self reference. */ @@ -69,7 +69,7 @@ declare namespace chrome { /** * List of Chrome command line switches to exclude that ChromeDriver by default - * passes when starting Chrome. Do not prefix switches with "--". + * passes when starting Chrome. Do not prefix switches with '--'. * * @param {...(string|!Array)} var_args The switches to exclude. * @return {!Options} A self reference. @@ -91,7 +91,7 @@ declare namespace chrome { /** * Sets the path to the Chrome binary to use. On Mac OS X, this path should * reference the actual Chrome executable, not just the application binary - * (e.g. "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"). + * (e.g. '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'). * * The binary path be absolute or relative to the chromedriver server * executable, but it must exist on the machine that will launch Chrome. @@ -114,7 +114,7 @@ declare namespace chrome { /** - * Sets the user preferences for Chrome's user profile. See the "Preferences" + * Sets the user preferences for Chrome's user profile. See the 'Preferences' * file in Chrome's user data directory for examples. * @param {!Object} prefs Dictionary of user preferences to use. * @return {!Options} A self reference. @@ -157,7 +157,7 @@ declare namespace chrome { /** - * Sets preferences for the "Local State" file in Chrome's user data + * Sets preferences for the 'Local State' file in Chrome's user data * directory. * @param {!Object} state Dictionary of local state preferences. * @return {!Options} A self reference. @@ -362,8 +362,8 @@ declare namespace chrome { /** - * Sets the base path for WebDriver REST commands (e.g. "/wd/hub"). - * By default, the driver will accept commands relative to "/". + * Sets the base path for WebDriver REST commands (e.g. '/wd/hub'). + * By default, the driver will accept commands relative to '/'. * @param {string} path The base path to use. * @return {!ServiceBuilder} A self reference. */ @@ -415,4 +415,4 @@ declare namespace chrome { function setDefaultService(service: remote.DriverService): void; } -export = chrome; \ No newline at end of file +export = chrome; diff --git a/selenium-webdriver/edge.d.ts b/selenium-webdriver/edge.d.ts index 3bbc78ec83..fd59756c3d 100644 --- a/selenium-webdriver/edge.d.ts +++ b/selenium-webdriver/edge.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace edge { @@ -44,7 +44,7 @@ declare namespace edge { /** * Sets the page load strategy for Edge. - * Supported values are "normal", "eager", and "none"; + * Supported values are 'normal', 'eager', and 'none'; * * @param {string} pageLoadStrategy The page load strategy to use. * @return {!Options} A self reference. @@ -126,4 +126,4 @@ declare namespace edge { function setDefaultService(service: remote.DriverService): void; } -export = edge; \ No newline at end of file +export = edge; diff --git a/selenium-webdriver/executors.d.ts b/selenium-webdriver/executors.d.ts index 016345f27b..6cded31fec 100644 --- a/selenium-webdriver/executors.d.ts +++ b/selenium-webdriver/executors.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace executors { /** @@ -12,4 +12,4 @@ declare namespace executors { function createExecutor(url: string | webdriver.promise.Promise, opt_agent?: string, opt_proxy?: string): webdriver.Executor; } -export = executors; \ No newline at end of file +export = executors; diff --git a/selenium-webdriver/firefox-tests.ts b/selenium-webdriver/firefox-tests.ts new file mode 100644 index 0000000000..7ebe0aa856 --- /dev/null +++ b/selenium-webdriver/firefox-tests.ts @@ -0,0 +1,54 @@ +import * as firefox from 'selenium-webdriver/firefox'; +import * as remote from 'selenium-webdriver/remote'; +import * as webdriver from 'selenium-webdriver'; + +function TestBinary() { + var binary: firefox.Binary = new firefox.Binary(); + binary = new firefox.Binary('exe'); + + binary.addArguments('A', 'B', 'C'); + var promise: webdriver.promise.Promise = binary.kill(); + binary.launch('profile').then(function (result: any) { }); +} + +function TestFirefoxDriver() { + var driver: firefox.Driver = new firefox.Driver(); + driver = new firefox.Driver(webdriver.Capabilities.firefox()); + driver = new firefox.Driver(webdriver.Capabilities.firefox(), new webdriver.promise.ControlFlow()); + + var baseDriver: webdriver.WebDriver = driver; +} + +function TestFirefoxOptions() { + var options: firefox.Options = new firefox.Options(); + + options = options.setBinary('binary'); + options = options.setBinary(new firefox.Binary()); + options = options.setLoggingPreferences(new webdriver.logging.Preferences()); + options = options.setProfile('profile'); + options = options.setProfile(new firefox.Profile()); + options = options.setProxy({ proxyType: 'proxy' }); + var capabilities: webdriver.Capabilities = options.toCapabilities(); +} + +function TestFirefoxProfile() { + var profile: firefox.Profile = new firefox.Profile(); + profile = new firefox.Profile('dir'); + + var bool: boolean = profile.acceptUntrustedCerts(); + profile.addExtension('ext'); + bool = profile.assumeUntrustedCertIssuer(); + profile.encode().then(function (prof: string) { }); + var num: number = profile.getPort(); + var anything: any = profile.getPreference('key'); + bool = profile.nativeEventsEnabled(); + profile.setAcceptUntrustedCerts(true); + profile.setAssumeUntrustedCertIssuer(true); + profile.setNativeEventsEnabled(true); + profile.setPort(8080); + profile.setPreference('key', 'value'); + profile.setPreference('key', 5); + profile.setPreference('key', true); + var stringPromise: webdriver.promise.Promise = profile.writeToDisk(); + stringPromise = profile.writeToDisk(true); +} diff --git a/selenium-webdriver/firefox.d.ts b/selenium-webdriver/firefox.d.ts index f8e1d2a804..25542f144f 100644 --- a/selenium-webdriver/firefox.d.ts +++ b/selenium-webdriver/firefox.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace firefox { /** @@ -254,4 +254,4 @@ declare namespace firefox { } } -export = firefox; \ No newline at end of file +export = firefox; diff --git a/selenium-webdriver/http.d.ts b/selenium-webdriver/http.d.ts index 3b32f29fac..b4ade88430 100644 --- a/selenium-webdriver/http.d.ts +++ b/selenium-webdriver/http.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace http { /** @@ -9,7 +9,7 @@ declare namespace http { function headersToString(headers: any): string; /** - * Represents a HTTP request message. This class is a "partial" request and only + * Represents a HTTP request message. This class is a 'partial' request and only * defines the path on the server to send a request to. It is each client's * responsibility to build the full URL for the final request. * @final @@ -108,15 +108,15 @@ declare namespace http { /** * Defines a new command for use with this executor. When a command is sent, * the {@code path} will be preprocessed using the command's parameters; any - * path segments prefixed with ":" will be replaced by the parameter of the - * same name. For example, given "/person/:name" and the parameters - * "{name: 'Bob'}", the final command path will be "/person/Bob". + * path segments prefixed with ':' will be replaced by the parameter of the + * same name. For example, given '/person/:name' and the parameters + * '{name: 'Bob'}', the final command path will be '/person/Bob'. * * @param {string} name The command name. * @param {string} method The HTTP method to use when sending this command. * @param {string} path The path to send the command to, relative to * the WebDriver server's command root and of the form - * "/path/:variable/segment". + * '/path/:variable/segment'. */ defineCommand(name: string, method: string, path: string): void; @@ -153,4 +153,4 @@ declare namespace http { function buildPath(path: string, parameters: Object): string; } -export = http; \ No newline at end of file +export = http; diff --git a/selenium-webdriver/ie.d.ts b/selenium-webdriver/ie.d.ts index 2489c1fd1a..5d9b51c64d 100644 --- a/selenium-webdriver/ie.d.ts +++ b/selenium-webdriver/ie.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace ie { @@ -39,7 +39,7 @@ declare namespace ie { /** * Whether to disable the protected mode settings check when the session is * created. Disbling this setting may lead to significant instability as the - * browser may become unresponsive/hang. Only "best effort" support is provided + * browser may become unresponsive/hang. Only 'best effort' support is provided * when using this capability. * * For more information, refer to the IEDriver's @@ -63,7 +63,7 @@ declare namespace ie { * Sets the initial URL loaded when IE starts. This is intended to be used with * {@link #ignoreProtectedModeSettings} to allow the user to initialize IE in * the proper Protected Mode zone. Setting this option may cause browser - * instability or flaky and unresponsive code. Only "best effort" support is + * instability or flaky and unresponsive code. Only 'best effort' support is * provided when using this option. * * @param {string} url The initial browser URL. @@ -208,4 +208,4 @@ declare namespace ie { } -export = ie; \ No newline at end of file +export = ie; diff --git a/selenium-webdriver/selenium-webdriver-tests.ts b/selenium-webdriver/index-tests.ts similarity index 88% rename from selenium-webdriver/selenium-webdriver-tests.ts rename to selenium-webdriver/index-tests.ts index 5288debd96..ba2acb91ef 100644 --- a/selenium-webdriver/selenium-webdriver-tests.ts +++ b/selenium-webdriver/index-tests.ts @@ -1,117 +1,12 @@ -import * as webdriver from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; -import * as remote from "selenium-webdriver/remote"; -import * as executors from "selenium-webdriver/executors"; -import * as firefox from "selenium-webdriver/firefox"; -import * as testing from "selenium-webdriver/testing"; - -function TestChromeDriver() { - var driver: chrome.Driver = new chrome.Driver(); - driver = new chrome.Driver(webdriver.Capabilities.chrome()); - driver = new chrome.Driver(webdriver.Capabilities.chrome(), new remote.DriverService('executable', new chrome.Options()), new webdriver.promise.ControlFlow()); - - var baseDriver: webdriver.WebDriver = driver; -} - -function TestChromeOptions() { - var options: chrome.Options = new chrome.Options(); - options = chrome.Options.fromCapabilities(webdriver.Capabilities.chrome()); - - options = options.addArguments("a", "b", "c"); - options = options.addExtensions("a", "b", "c"); - options = options.excludeSwitches("a", "b", "c"); - options = options.detachDriver(true); - options = options.setChromeBinaryPath("path"); - options = options.setChromeLogFile("logfile"); - options = options.setLocalState("state"); - options = options.androidActivity("com.example.Activity"); - options = options.androidDeviceSerial("emulator-5554"); - options = options.androidChrome(); - options = options.androidPackage("com.android.chrome"); - options = options.androidProcess("com.android.chrome"); - options = options.androidUseRunningApp(true); - options = options.setLoggingPrefs(new webdriver.logging.Preferences()); - options = options.setPerfLoggingPrefs({ enableNetwork: true, enablePage: true, enableTimeline: true, tracingCategories: "category", bufferUsageReportingInterval: 1000 }); - options = options.setProxy({ proxyType: "proxyType" }); - options = options.setUserPreferences("preferences"); - var capabilities: webdriver.Capabilities = options.toCapabilities(); - capabilities = options.toCapabilities(webdriver.Capabilities.chrome()); -} - -function TestServiceBuilder() { - var builder: chrome.ServiceBuilder = new chrome.ServiceBuilder(); - builder = new chrome.ServiceBuilder("exe"); - - var anything: any = builder.build(); - builder = builder.usingPort(8080); - builder = builder.setAdbPort(5037); - builder = builder.loggingTo("path"); - builder = builder.enableVerboseLogging(); - builder = builder.setNumHttpThreads(5); - builder = builder.setUrlBasePath("path"); - builder = builder.setStdio("config"); - builder = builder.setStdio(["A", "B"]); - builder = builder.withEnvironment({ "A": "a", "B": "b" }); -} - -function TestChromeModule() { - var service: any = chrome.getDefaultService(); - chrome.setDefaultService(new remote.DriverService('executable', new chrome.Options())); -} - -function TestBinary() { - var binary: firefox.Binary = new firefox.Binary(); - binary = new firefox.Binary("exe"); - - binary.addArguments("A", "B", "C"); - var promise: webdriver.promise.Promise = binary.kill(); - binary.launch("profile").then(function (result: any) { }); -} - -function TestFirefoxDriver() { - var driver: firefox.Driver = new firefox.Driver(); - driver = new firefox.Driver(webdriver.Capabilities.firefox()); - driver = new firefox.Driver(webdriver.Capabilities.firefox(), new webdriver.promise.ControlFlow()); - - var baseDriver: webdriver.WebDriver = driver; -} - -function TestFirefoxOptions() { - var options: firefox.Options = new firefox.Options(); - - options = options.setBinary("binary"); - options = options.setBinary(new firefox.Binary()); - options = options.setLoggingPreferences(new webdriver.logging.Preferences()); - options = options.setProfile("profile"); - options = options.setProfile(new firefox.Profile()); - options = options.setProxy({ proxyType: "proxy" }); - var capabilities: webdriver.Capabilities = options.toCapabilities(); -} - -function TestFirefoxProfile() { - var profile: firefox.Profile = new firefox.Profile(); - profile = new firefox.Profile("dir"); - - var bool: boolean = profile.acceptUntrustedCerts(); - profile.addExtension("ext"); - bool = profile.assumeUntrustedCertIssuer(); - profile.encode().then(function (prof: string) { }); - var num: number = profile.getPort(); - var anything: any = profile.getPreference("key"); - bool = profile.nativeEventsEnabled(); - profile.setAcceptUntrustedCerts(true); - profile.setAssumeUntrustedCertIssuer(true); - profile.setNativeEventsEnabled(true); - profile.setPort(8080); - profile.setPreference("key", "value"); - profile.setPreference("key", 5); - profile.setPreference("key", true); - var stringPromise: webdriver.promise.Promise = profile.writeToDisk(); - stringPromise = profile.writeToDisk(true); -} +import * as webdriver from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; +import * as firefox from 'selenium-webdriver/firefox'; +import * as remote from 'selenium-webdriver/remote'; +import * as executors from 'selenium-webdriver/executors'; +import * as testing from 'selenium-webdriver/testing'; function TestExecutors() { - var exec: webdriver.Executor = executors.createExecutor("url"); + var exec: webdriver.Executor = executors.createExecutor('url'); var promise: webdriver.promise.Promise; exec = executors.createExecutor(promise); } @@ -133,7 +28,7 @@ function TestBuilder() { builder = builder.setEnableNativeEvents(true); builder = builder.setFirefoxOptions(new firefox.Options()); builder = builder.setLoggingPrefs(new webdriver.logging.Preferences()); - builder = builder.setLoggingPrefs({ "key": "value" }); + builder = builder.setLoggingPrefs({ 'key': 'value' }); builder = builder.setProxy({ proxyType: 'type' }); builder = builder.setScrollBehavior(1); builder = builder.usingServer('http://someserver'); @@ -191,7 +86,8 @@ function TestActionSequence() { sequence = sequence.mouseUp(element, webdriver.Button.LEFT); // SendKeys - sequence = sequence.sendKeys("A", "B", "C"); + sequence = sequence.sendKeys('A', 'B', 'C'); + sequence = sequence.sendKeys('A', webdriver.Key.NULL); sequence.perform().then(function () { }); } @@ -228,7 +124,7 @@ function TestAlert() { alert.accept().then(function () { }); alert.dismiss().then(function () { }); alert.getText().then(function (text: string) { }); - alert.sendKeys("ABC").then(function () { }); + alert.sendKeys('ABC').then(function () { }); } function TestBrowser() { @@ -268,7 +164,7 @@ function TestCapabilities() { capabilities = capabilities.set(webdriver.Capability.VERSION, { abc: 'def' }); capabilities = capabilities.set(webdriver.Capability.VERSION, null); capabilities = capabilities.setLoggingPrefs(new webdriver.logging.Preferences()); - capabilities = capabilities.setLoggingPrefs({ "key": "value" }); + capabilities = capabilities.setLoggingPrefs({ 'key': 'value' }); capabilities = capabilities.setProxy({ proxyType: 'Type' }); capabilities = capabilities.setEnableNativeEvents(true); capabilities = capabilities.setScrollBehavior(1); @@ -315,11 +211,11 @@ function TestCommand() { var command: webdriver.Command = new webdriver.Command(webdriver.CommandName.ADD_COOKIE); var name: string = command.getName(); - var param: any = command.getParameter("param"); + var param: any = command.getParameter('param'); var params: any = command.getParameters(); - command = command.setParameter("param", 123); + command = command.setParameter('param', 123); command = command.setParameters({ param: 123 }); } @@ -544,7 +440,7 @@ function TestBy() { locator = webdriver.By.tagName('tag'); locator = webdriver.By.xpath('xpath'); - // Can import "By" without import declarations + // Can import 'By' without import declarations var By = webdriver.By; var locatorHash: webdriver.ByHash; @@ -689,7 +585,7 @@ function TestWebDriverWindow() { function TestWebDriver() { var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android()); var sessionPromise: webdriver.promise.Promise; - var executor: webdriver.Executor = executors.createExecutor("http://someserver"); + var executor: webdriver.Executor = executors.createExecutor('http://someserver'); var flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow(); var driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor); driver = new webdriver.WebDriver(session, executor, flow); @@ -810,7 +706,10 @@ function TestWebElement() { booleanPromise = element.isEnabled(); booleanPromise = element.isSelected(); voidPromise = element.sendKeys('A', 'B', 'C'); + voidPromise = element.sendKeys(1, 2, 3); + voidPromise = element.sendKeys(webdriver.Key.BACK_SPACE); voidPromise = element.sendKeys(stringPromise, stringPromise, stringPromise); + voidPromise = element.sendKeys('A', 1, webdriver.Key.BACK_SPACE, stringPromise); voidPromise = element.submit(); element.getId().then(function (id: string) { }); element.getRawId().then(function (id: string) { }); @@ -834,7 +733,7 @@ function TestWebElementPromise() { elementPromise.then(); elementPromise.then(function (element: webdriver.WebElement) { }); elementPromise.then(function (element: webdriver.WebElement) { }, function (error: any) { }); - elementPromise.then(function (element: webdriver.WebElement) { return "foo"; }, function (error: any) { }).then(function (result: string) { }); + elementPromise.then(function (element: webdriver.WebElement) { return 'foo'; }, function (error: any) { }).then(function (result: string) { }); elementPromise.thenCatch(function (error: any) { }).then(function (value: any) { }); @@ -886,7 +785,7 @@ function TestLoggingEntry() { function TestPromiseModule() { var cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError(); - cancellationError = new webdriver.promise.CancellationError("message"); + cancellationError = new webdriver.promise.CancellationError('message'); var str: string = cancellationError.message; str = cancellationError.name; @@ -1079,7 +978,7 @@ function TestPromiseClass() { function TestThenableClass() { var thenable: webdriver.promise.Promise = new webdriver.promise.Promise((resolve, reject) => { - resolve("a"); + resolve('a'); }); thenable.cancel('Abort'); @@ -1123,6 +1022,7 @@ function TestErrorCode() { errorCode = new webdriver.error.UnknownMethodError().code(); errorCode = new webdriver.error.UnsupportedOperationError().code(); } + async function TestAsyncAwaitable() { var thenable: webdriver.promise.Promise = new webdriver.promise.Promise((resolve, reject) => resolve('foo')); var str: string = await thenable; @@ -1135,17 +1035,17 @@ function TestTestingModule() { testing.beforeEach(function () { }); - testing.describe("My test suite", function () { - testing.it("My test", function () { + testing.describe('My test suite', function () { + testing.it('My test', function () { }); - testing.iit("My exclusive test.", function () { + testing.iit('My exclusive test.', function () { }); }); - testing.xdescribe("My disabled suite", function () { - testing.xit("My disabled test.", function () { + testing.xdescribe('My disabled suite', function () { + testing.xit('My disabled test.', function () { }); }); diff --git a/selenium-webdriver/index.d.ts b/selenium-webdriver/index.d.ts index 4f37fdb92f..17fba9ceae 100644 --- a/selenium-webdriver/index.d.ts +++ b/selenium-webdriver/index.d.ts @@ -3,12 +3,12 @@ // Definitions by: Bill Armstrong , Yuki Kokubun , Craig Nishina // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as chrome from "./chrome"; -import * as edge from "./edge"; -import * as firefox from "./firefox"; -import * as ie from "./ie"; -import * as opera from "./opera"; -import * as safari from "./safari"; +import * as chrome from './chrome'; +import * as edge from './edge'; +import * as firefox from './firefox'; +import * as ie from './ie'; +import * as opera from './opera'; +import * as safari from './safari'; declare namespace webdriver { @@ -393,8 +393,8 @@ declare namespace webdriver { /** * An object used to log debugging messages. Loggers use a hierarchical, - * dot-separated naming scheme. For instance, "foo" is considered the parent of - * the "foo.bar" and an ancestor of "foo.bar.baz". + * dot-separated naming scheme. For instance, 'foo' is considered the parent of + * the 'foo.bar' and an ancestor of 'foo.bar.baz'. * * Each logger may be assigned a {@linkplain #setLevel log level}, which * controls which level of messages will be reported to the @@ -603,7 +603,7 @@ declare namespace webdriver { /** * Determines whether a {@code value} should be treated as a promise. - * Any object whose "then" property is a function will be considered a promise. + * Any object whose 'then' property is a function will be considered a promise. * * @param {*} value The value to test. * @return {boolean} Whether the value is a promise. @@ -741,7 +741,7 @@ declare namespace webdriver { * }); * * @param {!Function} generatorFn The generator function to execute. - * @param {Object=} opt_self The object to use as "this" when invoking the + * @param {Object=} opt_self The object to use as 'this' when invoking the * initial generator. * @param {...*} var_args Any arguments to pass to the initial generator. * @return {!ManagedPromise} A promise that will resolve to the @@ -1136,7 +1136,7 @@ declare namespace webdriver { /** * Represents a value that will be resolved at some point in the future. This - * class represents the protected "producer" half of a Promise - each Deferred + * class represents the protected 'producer' half of a Promise - each Deferred * has a {@code promise} property that may be returned to consumers for * registering callbacks, reserving the ability to resolve the deferred to the * producer. @@ -1377,7 +1377,7 @@ declare namespace webdriver { class Condition { /** * @param {string} message A descriptive error message. Should complete the - * sentence "Waiting [...]" + * sentence 'Waiting [...]' * @param {function(!webdriver.WebDriver): OUT} fn The condition function to * evaluate on each iteration of the wait loop. * @constructor @@ -1661,9 +1661,9 @@ declare namespace webdriver { META: string; // alias for Windows key /** - * Simulate pressing many keys at once in a "chord". Takes a sequence of + * Simulate pressing many keys at once in a 'chord'. Takes a sequence of * keys or strings, appends each of the values to a string, - * and adds the chord termination key ({@link webdriver.Key.NULL}) and returns + * and adds the chord termination key ({@link webdriver.Key.NULL}) and returns * the resulting string. * * Note: when the low-level webdriver key handlers see Keys.NULL, active @@ -1671,8 +1671,8 @@ declare namespace webdriver { * * @param {...string} var_args The key sequence to concatenate. * @return {string} The null-terminated key sequence. - */ - chord: (...var_args: string[]) => string; + */ + chord: (...var_args: Array) => string; } /** @@ -1786,7 +1786,7 @@ declare namespace webdriver { mouseUp(opt_elementOrButton?: WebElement | string, opt_button?: string): ActionSequence; /** - * Convenience function for performing a "drag and drop" manuever. The target + * Convenience function for performing a 'drag and drop' manuever. The target * element may be moved to the location of another element, or by an offset (in * pixels). * @@ -1863,13 +1863,14 @@ declare namespace webdriver { /** * Simulates typing multiple keys. Each modifier key encountered in the * sequence will not be released until it is encountered again. All key events - * will be targetted at the currently focused element. - * @param {...(string|!webdriver.Key|!Array.<(string|!webdriver.Key)>)} var_args + * will be targeted at the currently focused element. + * + * @param {...(string|!input.Key|!Array<(string|!input.Key)>)} var_args * The keys to type. - * @return {!webdriver.ActionSequence} A self reference. + * @return {!ActionSequence} A self reference. * @throws {Error} If the key is not a valid modifier key. */ - sendKeys(...var_args: Array): ActionSequence; + sendKeys(...var_args: Array>): ActionSequence; //endregion } @@ -2023,7 +2024,7 @@ declare namespace webdriver { /** * Retrieves the message text displayed with this alert. For instance, if the - * alert were opened with alert("hello"), then this would return "hello". + * alert were opened with alert('hello'), then this would return 'hello'. * @return {!webdriver.promise.Promise} A promise that will be resolved to the * text displayed with this alert. */ @@ -2263,7 +2264,7 @@ declare namespace webdriver { * option always takes precedence over {@code SELENIUM_SERVER_JAR}. * * - {@code SELENIUM_SERVER_JAR}: defines the path to the - * + * * standalone Selenium server jar to use. The server will be started the * first time a WebDriver instance and be killed when the process exits. * @@ -2381,8 +2382,8 @@ declare namespace webdriver { /** * Sets the default action to take with an unexpected alert before returning * an error. - * @param {string} beahvior The desired behavior; should be "accept", "dismiss", - * or "ignore". Defaults to "dismiss". + * @param {string} beahvior The desired behavior; should be 'accept', 'dismiss', + * or 'ignore'. Defaults to 'dismiss'. * @return {!Builder} A self reference. */ setAlertBehavior(behavior: string): Builder; @@ -2562,7 +2563,7 @@ declare namespace webdriver { /** * Locates eleemnts by the ID attribute. This locator uses the CSS selector - * `*[id="$ID"]`, _not_ `document.getElementById`. + * `*[id='$ID']`, _not_ `document.getElementById`. * * @param {string} id The ID to search for. * @return {!By} The new locator. @@ -2753,7 +2754,7 @@ declare namespace webdriver { /** * Defines how the driver should handle unexpected alerts. The value should - * be one of "accept", "dismiss", or "ignore. + * be one of 'accept', 'dismiss', or 'ignore. */ UNEXPECTED_ALERT_BEHAVIOR: string; @@ -2834,8 +2835,8 @@ declare namespace webdriver { /** * Sets the default action to take with an unexpected alert before returning * an error. - * @param {string} behavior The desired behavior; should be "accept", "dismiss", - * or "ignore". Defaults to "dismiss". + * @param {string} behavior The desired behavior; should be 'accept', 'dismiss', + * or 'ignore'. Defaults to 'dismiss'. * @return {!webdriver.Capabilities} A self reference. */ setAlertBehavior(behavior: string): Capabilities; @@ -3637,7 +3638,7 @@ declare namespace webdriver { /** * Used with {@link webdriver.WebElement#sendKeys WebElement#sendKeys} on file - * input elements ({@code }) to detect when the entered key + * input elements ({@code }) to detect when the entered key * sequence defines the path to a file. * * By default, {@linkplain webdriver.WebElement WebElement's} will enter all @@ -3915,7 +3916,7 @@ declare namespace webdriver { * driver.executeAsyncScript(function() { * var callback = arguments[arguments.length - 1]; * var xhr = new XMLHttpRequest(); - * xhr.open("GET", "/resource/data.json", true); + * xhr.open('GET', '/resource/data.json', true); * xhr.onreadystatechange = function() { * if (xhr.readyState == 4) { * callback(xhr.responseText); @@ -4193,46 +4194,62 @@ declare namespace webdriver { click(): webdriver.promise.Promise; /** - * Schedules a command to type a sequence on the DOM element represented by this - * instance. - *

+ * Schedules a command to type a sequence on the DOM element represented by + * this instance. + * * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is - * processed in the keysequence, that key state is toggled until one of the + * processed in the key sequence, that key state is toggled until one of the * following occurs: - *

    - *
  • The modifier key is encountered again in the sequence. At this point the - * state of the key is toggled (along with the appropriate keyup/down events). - *
  • - *
  • The {@code webdriver.Key.NULL} key is encountered in the sequence. When - * this key is encountered, all modifier keys current in the down state are - * released (with accompanying keyup events). The NULL key can be used to - * simulate common keyboard shortcuts: - * - * element.sendKeys("text was", - * webdriver.Key.CONTROL, "a", webdriver.Key.NULL, - * "now text is"); - * // Alternatively: - * element.sendKeys("text was", - * webdriver.Key.chord(webdriver.Key.CONTROL, "a"), - * "now text is"); - *
  • - *
  • The end of the keysequence is encountered. When there are no more keys - * to type, all depressed modifier keys are released (with accompanying keyup - * events). - *
  • - *
- * Note: On browsers where native keyboard events are not yet - * supported (e.g. Firefox on OS X), key events will be synthesized. Special - * punctionation keys will be synthesized according to a standard QWERTY en-us + * + * - The modifier key is encountered again in the sequence. At this point the + * state of the key is toggled (along with the appropriate keyup/down + * events). + * - The {@link input.Key.NULL} key is encountered in the sequence. When + * this key is encountered, all modifier keys current in the down state are + * released (with accompanying keyup events). The NULL key can be used to + * simulate common keyboard shortcuts: + * + * element.sendKeys('text was', + * Key.CONTROL, 'a', Key.NULL, + * 'now text is'); + * // Alternatively: + * element.sendKeys('text was', + * Key.chord(Key.CONTROL, 'a'), + * 'now text is'); + * + * - The end of the key sequence is encountered. When there are no more keys + * to type, all depressed modifier keys are released (with accompanying + * keyup events). + * + * If this element is a file input ({@code }), the + * specified key sequence should specify the path to the file to attach to + * the element. This is analogous to the user clicking 'Browse...' and entering + * the path into the file select dialog. + * + * var form = driver.findElement(By.css('form')); + * var element = form.findElement(By.css('input[type=file]')); + * element.sendKeys('/path/to/file.txt'); + * form.submit(); + * + * For uploads to function correctly, the entered path must reference a file + * on the _browser's_ machine, not the local machine running this script. When + * running against a remote Selenium server, a {@link input.FileDetector} + * may be used to transparently copy files to the remote machine before + * attempting to upload them in the browser. + * + * __Note:__ On browsers where native keyboard events are not supported + * (e.g. Firefox on OS X), key events will be synthesized. Special + * punctuation keys will be synthesized according to a standard QWERTY en-us * keyboard layout. * - * @param {...string} var_args The sequence of keys to - * type. All arguments will be joined into a single sequence (var_args is - * permitted for convenience). + * @param {...(number|string|!IThenable<(number|string)>)} var_args The + * sequence of keys to type. Number keys may be referenced numerically or + * by string (1 or '1'). All arguments will be joined into a single + * sequence. * @return {!webdriver.promise.Promise} A promise that will be resolved when all * keys have been typed. */ - sendKeys(...var_args: string[]): webdriver.promise.Promise; + sendKeys(...var_args: Array>): webdriver.promise.Promise; /** * Schedules a command to query for the tag/node name of this element. @@ -4264,9 +4281,9 @@ declare namespace webdriver { * page has been loaded. More exactly, this method will return the value of the * given attribute, unless that attribute is not present, in which case the * value of the property with the same name is returned. If neither value is - * set, null is returned. The "style" attribute is converted as best can be to a + * set, null is returned. The 'style' attribute is converted as best can be to a * text representation with a trailing semi-colon. The following are deemed to - * be "boolean" attributes and will be returned as thus: + * be 'boolean' attributes and will be returned as thus: * *

async, autofocus, autoplay, checked, compact, complete, controls, declare, * defaultchecked, defaultselected, defer, disabled, draggable, ended, @@ -4278,8 +4295,8 @@ declare namespace webdriver { *

Finally, the following commonly mis-capitalized attribute/property names * are evaluated as expected: *

    - *
  • "class" - *
  • "readonly" + *
  • 'class' + *
  • 'readonly' *
* @param {string} attributeName The name of the attribute to query. * @return {!webdriver.promise.Promise} A promise that will be resolved with the @@ -4629,21 +4646,21 @@ declare namespace webdriver { * released (with accompanying keyup events). The NULL key can be used to * simulate common keyboard shortcuts: * - * element.sendKeys("text was", - * webdriver.Key.CONTROL, "a", webdriver.Key.NULL, - * "now text is"); + * element.sendKeys('text was', + * webdriver.Key.CONTROL, 'a', webdriver.Key.NULL, + * 'now text is'); * // Alternatively: - * element.sendKeys("text was", - * webdriver.Key.chord(webdriver.Key.CONTROL, "a"), - * "now text is"); + * element.sendKeys('text was', + * webdriver.Key.chord(webdriver.Key.CONTROL, 'a'), + * 'now text is'); * * - The end of the keysequence is encountered. When there are no more keys * to type, all depressed modifier keys are released (with accompanying keyup * events). * - * If this element is a file input ({@code }), the + * If this element is a file input ({@code }), the * specified key sequence should specify the path to the file to attach to - * the element. This is analgous to the user clicking "Browse..." and entering + * the element. This is analgous to the user clicking 'Browse...' and entering * the path into the file select dialog. * * var form = driver.findElement(By.css('form')); @@ -4667,7 +4684,7 @@ declare namespace webdriver { * @return {!webdriver.promise.Promise.} A promise that will be resolved * when all keys have been typed. */ - sendKeys(...var_args: Array>): webdriver.promise.Promise; + sendKeys(...var_args: Array>): webdriver.promise.Promise; /** * Schedules a command to query for the tag/node name of this element. @@ -4699,10 +4716,10 @@ declare namespace webdriver { * the page has been loaded. More exactly, this method will return the value of * the given attribute, unless that attribute is not present, in which case the * value of the property with the same name is returned. If neither value is - * set, null is returned (for example, the "value" property of a textarea - * element). The "style" attribute is converted as best can be to a + * set, null is returned (for example, the 'value' property of a textarea + * element). The 'style' attribute is converted as best can be to a * text representation with a trailing semi-colon. The following are deemed to - * be "boolean" attributes and will return either "true" or null: + * be 'boolean' attributes and will return either 'true' or null: * * async, autofocus, autoplay, checked, compact, complete, controls, declare, * defaultchecked, defaultselected, defer, disabled, draggable, ended, @@ -4714,8 +4731,8 @@ declare namespace webdriver { * Finally, the following commonly mis-capitalized attribute/property names * are evaluated as expected: * - * - "class" - * - "readonly" + * - 'class' + * - 'readonly' * * @param {string} attributeName The name of the attribute to query. * @return {!webdriver.promise.Promise.} A promise that will be diff --git a/selenium-webdriver/opera.d.ts b/selenium-webdriver/opera.d.ts index d0eee8d858..0d3aee1a13 100644 --- a/selenium-webdriver/opera.d.ts +++ b/selenium-webdriver/opera.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace opera { /** @@ -101,9 +101,9 @@ declare namespace opera { /** * Add additional command line arguments to use when launching the Opera - * browser. Each argument may be specified with or without the "--" prefix - * (e.g. "--foo" and "foo"). Arguments with an associated value should be - * delimited by an "=": "foo=bar". + * browser. Each argument may be specified with or without the '--' prefix + * (e.g. '--foo' and 'foo'). Arguments with an associated value should be + * delimited by an '=': 'foo=bar'. * @param {...(string|!Array.)} var_args The arguments to add. * @return {!Options} A self reference. */ @@ -174,4 +174,4 @@ declare namespace opera { } } -export = opera; \ No newline at end of file +export = opera; diff --git a/selenium-webdriver/remote.d.ts b/selenium-webdriver/remote.d.ts index e49a62d939..d3cadb746a 100644 --- a/selenium-webdriver/remote.d.ts +++ b/selenium-webdriver/remote.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace remote { /** @@ -68,4 +68,4 @@ declare namespace remote { } } -export = remote; \ No newline at end of file +export = remote; diff --git a/selenium-webdriver/safari.d.ts b/selenium-webdriver/safari.d.ts index a374c31d25..82fd835b20 100644 --- a/selenium-webdriver/safari.d.ts +++ b/selenium-webdriver/safari.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace safari { class Server { } @@ -90,4 +90,4 @@ declare namespace safari { } } -export = safari; \ No newline at end of file +export = safari; diff --git a/selenium-webdriver/tsconfig.json b/selenium-webdriver/tsconfig.json index 0f00ce9165..89e3b4fd9f 100644 --- a/selenium-webdriver/tsconfig.json +++ b/selenium-webdriver/tsconfig.json @@ -15,16 +15,18 @@ }, "files": [ "index.d.ts", + "index-tests.ts", "chrome.d.ts", + "chrome-tests.ts", "edge.d.ts", "executors.d.ts", "firefox.d.ts", + "firefox-tests.ts", "http.d.ts", "ie.d.ts", "opera.d.ts", "remote.d.ts", "safari.d.ts", - "testing.d.ts", - "selenium-webdriver-tests.ts" + "testing.d.ts" ] -} \ No newline at end of file +} From 694b16f5b06c933a96346b814a11fc2f440ebaeb Mon Sep 17 00:00:00 2001 From: denisname Date: Thu, 5 Jan 2017 20:57:15 +0100 Subject: [PATCH 111/181] CKEditor: add properties in buttonDefinition (#13636) * CKEditor add icon in buttonDefinition Add icon and iconOffset optional properties in buttonDefinition interface * Test Add test * Confirm to style --- ckeditor/ckeditor-tests.ts | 26 ++++++++++++++++++++++++++ ckeditor/index.d.ts | 2 ++ 2 files changed, 28 insertions(+) diff --git a/ckeditor/ckeditor-tests.ts b/ckeditor/ckeditor-tests.ts index f0aa64cc07..3ec9b64fd5 100644 --- a/ckeditor/ckeditor-tests.ts +++ b/ckeditor/ckeditor-tests.ts @@ -270,6 +270,32 @@ function test_dom_window() { alert(size.height); } +function test_adding_command_and_buttons() { + var textarea = document.createElement('textarea'); + var instance = CKEDITOR.replace(textarea); + + instance.addCommand( 'aCommand', { + exec: function( editor: CKEDITOR.editor ) { + // empty logic + return true; + } + }); + + instance.ui.addButton( 'firstButton', { + icon: 'http://www.example.com/assets/images/icons.png', + iconOffset: -32, + label: 'Label 1', + command: 'aCommand', + toolbar: 'tools' + }); + + instance.ui.addButton( 'secondButton', { + label: 'Label 2', + command: 'aCommand', + toolbar: 'tools' + }); +} + function test_adding_dialog_by_path() { CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' ); } diff --git a/ckeditor/index.d.ts b/ckeditor/index.d.ts index f95875501c..271ca0b678 100644 --- a/ckeditor/index.d.ts +++ b/ckeditor/index.d.ts @@ -1255,6 +1255,8 @@ declare namespace CKEDITOR { } interface buttonDefinition { + icon?: string; + iconOffset?: number; label : string; command : string; toolbar : string; From ce5eb0cc2c065553da248bab5f08f91575a37873 Mon Sep 17 00:00:00 2001 From: Ben Katz Date: Thu, 5 Jan 2017 22:02:09 +0200 Subject: [PATCH 112/181] fix enzyme CommonWrapper.reduce function to return R instead of R[] (#13763) --- enzyme/enzyme-tests.tsx | 12 ++++++------ enzyme/index.d.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index dfa0f1ee96..035f0dfcd7 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -277,14 +277,14 @@ namespace ShallowWrapperTest { } function test_reduce() { - const total: number[] = + const total: number = shallowWrapper.reduce( (amount: number, n: ShallowWrapper) => amount + n.props().numberProp ); } function test_reduceRight() { - const total: number[] = + const total: number = shallowWrapper.reduceRight( (amount: number, n: ShallowWrapper) => amount + n.prop('amount') ); @@ -557,14 +557,14 @@ namespace ReactWrapperTest { } function test_reduce() { - const total: number[] = + const total: number = reactWrapper.reduce( (amount: number, n: ReactWrapper) => amount + n.prop('amount') ); } function test_reduceRight() { - const total: number[] = + const total: number = reactWrapper.reduceRight( (amount: number, n: ReactWrapper) => amount + n.prop('amount') ); @@ -799,14 +799,14 @@ namespace CheerioWrapperTest { } function test_reduce() { - const total: number[] = + const total: number = cheerioWrapper.reduce( (amount: number, n: CheerioWrapper) => amount + n.prop('amount') ); } function test_reduceRight() { - const total: number[] = + const total: number = cheerioWrapper.reduceRight( (amount: number, n: CheerioWrapper) => amount + n.prop('amount') ); diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 229e3d3a34..94b60fc199 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -346,7 +346,7 @@ interface CommonWrapper { * @param fn * @param initialValue */ - reduce(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[]; + reduce(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R; /** * Applies the provided reducing function to every node in the wrapper to reduce to a single value. @@ -354,7 +354,7 @@ interface CommonWrapper { * @param fn * @param initialValue */ - reduceRight(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[]; + reduceRight(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R; /** * Returns whether or not any of the nodes in the wrapper match the provided selector. From 5bce8fab2ee167fde0b249672bc38ef1c37abec7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 5 Jan 2017 12:05:44 -0800 Subject: [PATCH 113/181] Merge more from `types-2.0` to `master (#13770) * Add memoizee definitions * Fix common issues, added doc * Removed blank line * fix test * Fix test methods * Fix check style * Fix check style * Fixing semver header * Fixing semver header * `memoizee`: Clean up types * Types 2.0 - Fix JS-quantities (#12739) * Enable strict null checking per readme FAQ. * Add tslint.json. * Improve test file with project spec. * Fix js-quantities d.ts, with adjustment of test. * Add trailing newline to tslint. * Simplify functional interface per linter. * js-quantities: add readme examples to tests * js-quantities: fix & clean declaration * d3-selection: Mark before param of insert() as optional (#13090) Selection.insert functions perfectly well without a `before` selector -- it does so in many d3 official examples. This corrects the type signature to mark it as optional. * [react-intl] bugfix for #12716 (#12906) * fix for issue introduced in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12716 * injectIntl is now usable as class decorator * fixed test * use inferface instead of type * format document * fix chai-json-schema styling (#13537) * googlemaps: Allow Marker.setAnimation(null) and Marker.setMap(null) (#13240) * googlemaps: Allow Marker.setAnimation(null) * Also, turn on strictNullChecks * Allow new google.maps.Map(null) since it's technically possible with Google's example code from the docs Signed-off-by: Iqbal Yusuf * googlemaps: Allow Marker.setMap(null) * Also, add more test code from the Google Maps API documentation Signed-off-by: Grant Hutchins * Added the brand property to the StripeCardData and fix style issues, lint (#13084) * Add the "brand" field to StipeCardData Added the StipeCardDataBrand type. Added the `brand` property to the `StripeCardData` declaration with the type `'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'` Reference: https://stripe.com/docs/api#card_object * Run linter, fix issues. set --strictNullChecks. Unsure about ambient declaration: Removed as it seemed to be in error: 1. case was not correct 2. the export was the type of the global which is unconditionally defined. 3. this module does not seem a suitable candidate for a UMD declaration. * Use header version of 0.0; explain Stripe versioning in comments * Restore global * Added tests --- chai-json-schema/index.d.ts | 24 +- chai-json-schema/tslint.json | 6 +- d3-selection/d3-selection-tests.ts | 77 +- d3-selection/index.d.ts | 2 +- googlemaps/google.maps-tests.ts | 95 +- googlemaps/index.d.ts | 8 +- googlemaps/tsconfig.json | 4 +- js-quantities/index.d.ts | 132 ++- js-quantities/js-quantities-tests.ts | 1503 +++++++++++++++++++++++++- js-quantities/tsconfig.json | 4 +- js-quantities/tslint.json | 3 + memoizee/index.d.ts | 29 + memoizee/memoizee-tests.ts | 61 ++ memoizee/tsconfig.json | 20 + memoizee/tslint.json | 1 + react-intl/index.d.ts | 8 +- react-intl/react-intl-tests.tsx | 53 +- stripe/index.d.ts | 45 +- stripe/stripe-tests.ts | 25 + stripe/tsconfig.json | 7 +- stripe/tslint.json | 3 + 21 files changed, 1902 insertions(+), 208 deletions(-) create mode 100644 js-quantities/tslint.json create mode 100644 memoizee/index.d.ts create mode 100644 memoizee/memoizee-tests.ts create mode 100644 memoizee/tsconfig.json create mode 100644 memoizee/tslint.json create mode 100644 stripe/stripe-tests.ts create mode 100644 stripe/tslint.json diff --git a/chai-json-schema/index.d.ts b/chai-json-schema/index.d.ts index e3e4934c76..e66e2c96af 100644 --- a/chai-json-schema/index.d.ts +++ b/chai-json-schema/index.d.ts @@ -6,19 +6,19 @@ // // -declare namespace Chai { - export interface Assert { - jsonSchema(value: any, schema: any, msg?: string): void; - notJsonSchema(value: any, schema: any, msg?: string): void; - } +declare global { + namespace Chai { + export interface Assert { + jsonSchema(value: any, schema: any, msg?: string): void; + notJsonSchema(value: any, schema: any, msg?: string): void; + } - export interface LanguageChains { - jsonSchema(schema: any, msg?: string): void; + export interface LanguageChains { + jsonSchema(schema: any, msg?: string): void; + } } } -declare module "chai-json-schema" { - function chaiJsonSchema(chai: any, utils: any): void; - namespace chaiJsonSchema {} - export = chaiJsonSchema; -} +declare function chaiJsonSchema(chai: any, utils: any): void; +declare namespace chaiJsonSchema { } +export = chaiJsonSchema; diff --git a/chai-json-schema/tslint.json b/chai-json-schema/tslint.json index 83a03ce890..377cc837d4 100644 --- a/chai-json-schema/tslint.json +++ b/chai-json-schema/tslint.json @@ -1,5 +1 @@ -{ "extends": "../tslint.json", - "rules": { - "no-single-declare-module": false - } -} +{ "extends": "../tslint.json" } diff --git a/d3-selection/d3-selection-tests.ts b/d3-selection/d3-selection-tests.ts index b1f776c442..042fba622a 100644 --- a/d3-selection/d3-selection-tests.ts +++ b/d3-selection/d3-selection-tests.ts @@ -846,60 +846,43 @@ newDiv2 = body.append(function (d, i, g) { // without insert<...> typing returned selection has group element of type BaseType let newParagraph: d3Selection.Selection; newParagraph = body.insert('p', 'p.second-paragraph'); +newParagraph = body.insert('p'); + +// Two arguments; the first can be string, selection , or a + +const typeValueFunction = function ( + this: HTMLBodyElement, + d: BodyDatum, + i: number, + g: HTMLBodyElement[] | d3Selection.ArrayLike +) { + return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement +} + +const beforeValueFunction = function ( + this: HTMLBodyElement, + d: BodyDatum, + i: number, + g: HTMLBodyElement[] | d3Selection.ArrayLike +) { + return this.children[0]; +} let newParagraph2: d3Selection.Selection; + +// 2 args, with 3 possibilities each, makes 9 possible combinations: newParagraph2 = body.insert('p', 'p.second-paragraph'); +newParagraph2 = body.insert('p', beforeValueFunction); +newParagraph2 = body.insert('p'); newParagraph2 = body.insert(d3Selection.creator('p'), 'p.second-paragraph'); -newParagraph2 = body.insert(function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement -}, 'p.second-paragraph'); +newParagraph2 = body.insert(d3Selection.creator('p'), beforeValueFunction); +newParagraph2 = body.insert(d3Selection.creator('p')); -// newParagraph2 = body.insert(function(d) { -// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type parameter, HTMLAnchorElement returned -// }, 'p.second-paragraph'); +newParagraph2 = body.insert(typeValueFunction, 'p.second-paragraph'); +newParagraph2 = body.insert(typeValueFunction, beforeValueFunction); +newParagraph2 = body.insert(typeValueFunction); -// newParagraph2 = body.insert(function(d) { -// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type inference, HTMLAnchorElement returned -// }, 'p.second-paragraph'); - -newParagraph2 = body.insert(d3Selection.creator('p'), function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.children[0]; // this type HTMLBodyElement -}); - -newParagraph2 = body.insert( - // type - function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement - }, - // before - function (d, i, g) { - let that: HTMLBodyElement = this; - // let that2: SVGElement = this; // fails, type mismatch - let datum: BodyDatum = d; - let index: number = i; - let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; - console.log('Body element foo property: ', d.foo); // data of type BodyDatum - return this.children[0]; // this type HTMLBodyElement - }); // sort(...) ----------------------------------------------------------------------------- diff --git a/d3-selection/index.d.ts b/d3-selection/index.d.ts index 65703f66ff..1d0ab9472c 100644 --- a/d3-selection/index.d.ts +++ b/d3-selection/index.d.ts @@ -519,7 +519,7 @@ interface Selection( type: string | ValueFn, - before: string | ValueFn + before?: string | ValueFn ): Selection; /** diff --git a/googlemaps/google.maps-tests.ts b/googlemaps/google.maps-tests.ts index fd4e10f6e6..0be531a89f 100644 --- a/googlemaps/google.maps-tests.ts +++ b/googlemaps/google.maps-tests.ts @@ -141,19 +141,102 @@ var mapTypeStyle: google.maps.MapTypeStyle ={ stylers: [], }; -// https://developers.google.com/maps/documentation/javascript/adding-a-google-map -function initMap() { - var uluru = {lat: -25.363, lng: 131.044}; +// https://developers.google.com/maps/documentation/javascript/markers +function initMap1() { + var myLatLng = {lat: -25.363, lng: 131.044}; + var map = new google.maps.Map(document.getElementById('map'), { zoom: 4, - center: uluru + center: myLatLng }); + var marker = new google.maps.Marker({ - position: uluru, + position: myLatLng, + map: map, + title: 'Hello World!' + }); +} + +var myLatlng = new google.maps.LatLng(-25.363882,131.044922); +var mapOptions = { + zoom: 4, + center: myLatlng +} +var map = new google.maps.Map(document.getElementById("map"), mapOptions); + +var marker = new google.maps.Marker({ + position: myLatlng, + title:"Hello World!" +}); + +// To add the marker to the map, call setMap(); +marker.setMap(map); + +marker.setMap(null); + +// The following example creates a marker in Stockholm, Sweden using a DROP +// animation. Clicking on the marker will toggle the animation between a BOUNCE +// animation and no animation. + +var marker: google.maps.Marker; + +function initMap2() { + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 13, + center: {lat: 59.325, lng: 18.070} + }); + + marker = new google.maps.Marker({ + map: map, + draggable: true, + animation: google.maps.Animation.DROP, + position: {lat: 59.327, lng: 18.067} + }); + marker.addListener('click', toggleBounce); +} + +function toggleBounce() { + if (marker.getAnimation() !== null) { + marker.setAnimation(null); + } else { + marker.setAnimation(google.maps.Animation.BOUNCE); + } +} + +// In the following example, markers appear when the user clicks on the map. +// Each marker is labeled with a single alphabetical character. +var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; +var labelIndex = 0; + +function initialize() { + var bangalore = { lat: 12.97, lng: 77.59 }; + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 12, + center: bangalore + }); + + // This event listener calls addMarker() when the map is clicked. + google.maps.event.addListener(map, 'click', function(event: any) { + addMarker(event.latLng, map); + }); + + // Add a marker at the center of the map. + addMarker(bangalore, map); +} + +// Adds a marker to the map. +function addMarker(location: google.maps.LatLngLiteral, map: google.maps.Map) { + // Add the marker at the clicked location, and add the next-available label + // from the array of alphabetical characters. + var marker = new google.maps.Marker({ + position: location, + label: labels[labelIndex++ % labels.length], map: map }); } +google.maps.event.addDomListener(window, 'load', initialize); + /***** OverlayView *****/ // https://developers.google.com/maps/documentation/javascript/customoverlays var div = document.createElement('div'); @@ -183,4 +266,4 @@ var rectangle = new google.maps.Rectangle({ east: -116.234, west: -116.251 } -}); \ No newline at end of file +}); diff --git a/googlemaps/index.d.ts b/googlemaps/index.d.ts index f19480f034..fefca3ea89 100644 --- a/googlemaps/index.d.ts +++ b/googlemaps/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Maps JavaScript API 3.25 // Project: https://developers.google.com/maps/ -// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin +// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin , Grant Hutchins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* @@ -30,7 +30,7 @@ THE SOFTWARE. declare namespace google.maps { /***** Map *****/ export class Map extends MVCObject { - constructor(mapDiv: Element, opts?: MapOptions); + constructor(mapDiv: Element|null, opts?: MapOptions); fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void; getBounds(): LatLngBounds; getCenter(): LatLng; @@ -536,14 +536,14 @@ declare namespace google.maps { getTitle(): string; getVisible(): boolean; getZIndex(): number; - setAnimation(animation: Animation): void; + setAnimation(animation: Animation|null): void; setAttribution(attribution: Attribution): void; setClickable(flag: boolean): void; setCursor(cursor: string): void; setDraggable(flag: boolean): void; setIcon(icon: string|Icon|Symbol): void; setLabel(label: string|MarkerLabel): void; - setMap(map: Map|StreetViewPanorama): void; + setMap(map: Map|StreetViewPanorama|null): void; setOpacity(opacity: number): void; setOptions(options: MarkerOptions): void; setPlace(place: Place): void; diff --git a/googlemaps/tsconfig.json b/googlemaps/tsconfig.json index dc12fbf795..0382e30210 100644 --- a/googlemaps/tsconfig.json +++ b/googlemaps/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -17,4 +17,4 @@ "index.d.ts", "google.maps-tests.ts" ] -} \ No newline at end of file +} diff --git a/js-quantities/index.d.ts b/js-quantities/index.d.ts index a2e3c2d96c..5d4a8df304 100644 --- a/js-quantities/index.d.ts +++ b/js-quantities/index.d.ts @@ -1,79 +1,73 @@ -// Type definitions for JS-quantities +// Type definitions for JS-quantities 1.6 // Project: http://gentooboontoo.github.io/js-quantities/ -// Definitions by: William Comartin +// Definitions by: William Rummler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare var Qty: QtyModule.QtyStatic; - -declare namespace QtyModule { - interface QtyStatic { - (value: string): Qty; - (value: number): Qty; - (value: number, unit: string): Qty; - (value: Qty): Qty; - } - - interface Qty { - version: string; - - scalar: number; - baseScalar: number; - - parse(value: string): Qty; - - swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number; - - getkinds(): string[]; - - getUnits(kind:string): string[]; - - getAliases(unitName:string): string[]; - - formatter(scalar:number, units:string):string; - - toFloat(): number; - - isUnitless(): boolean; - - isCompatible(other:string|Qty): boolean; - - isInverse(other:string|Qty): boolean - - kind(): string; - - isBase(): boolean; - - toBase(): Qty; +declare const Qty: Qty.Type; +declare interface Qty { + readonly numerator: string[]; + readonly denominator: string[]; + readonly scalar: number; + readonly baseScalar: number; + readonly initValue: string; units(): string; - - eq(other:Qty): boolean; - lt(other:Qty): boolean; - lte(other:Qty): boolean; - gt(other:Qty): boolean; - gte(other:Qty): boolean; - - toPrec(precQuantity: Qty|string|number): Qty; - - toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string; - - format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string; - - compareTo(other:Qty|string): number; - - same(other: Qty): boolean; - + isCompatible(value: Qty.UnitSource): boolean; + kind(): string; + isUnitless(): boolean; + isBase(): boolean; + toBase(): Qty; + toFloat(): number; + to(value: Qty.UnitSource): Qty; inverse(): Qty; + eq(value: Qty.UnitSource): boolean; + same(value: Qty.UnitSource): boolean; + lt(value: Qty.UnitSource): boolean; + lte(value: Qty.UnitSource): boolean; + gt(value: Qty.UnitSource): boolean; + gte(value: Qty.UnitSource): boolean; + compareTo(value: Qty): Qty.ComparisonResult; + add(value: Qty.Source): Qty; + sub(value: Qty.Source): Qty; + mul(value: Qty.Source): Qty; + div(value: Qty.Source): Qty; + toPrec(value: Qty.Source): Qty; + toString(valueOrPrecision?: Qty.Source): string; + toString(value: string, precision: number): string; + format(formatter?: Qty.Formatter): string; + format(value: string, formatter?: Qty.Formatter): string; +} - isDegrees(): boolean; +declare namespace Qty { - isTemperature(): boolean; + interface Type { + (value: Source): Qty; + (value: number, unit: string): Qty; + new (value: Source): Qty; + new (value: number, unit: string): Qty; + parse(value: string): Qty; + getKinds(): string[]; + getUnits(kind?: string): string[]; + getAliases(unit: string): string[]; + swiftConverter(sourceUnit: string, targetUnit: string): Converter; + formatter: Formatter; + readonly Error: any; + mulSafe(n1: number, n2: number): number; + divSafe(n1: number, n2: number): number; + } - to(other:string|Qty): Qty; + interface Converter { + (sourceValue: number): number; + (sourceValues: number[]): number[]; + } - add(other:string|Qty): Qty; - sub(other:string|Qty): Qty; - mul(other:number|string|Qty): Qty; - div(other:number|string|Qty): Qty; - } -} \ No newline at end of file + type Formatter = (scalar: number, unit: string) => string; + + type ComparisonResult = -1 | 0 | 1; + + type Source = UnitSource | number; + + type UnitSource = Qty | string; +} + +export default Qty; diff --git a/js-quantities/js-quantities-tests.ts b/js-quantities/js-quantities-tests.ts index c09867634a..b1916bb626 100644 --- a/js-quantities/js-quantities-tests.ts +++ b/js-quantities/js-quantities-tests.ts @@ -1,7 +1,1502 @@ -var Val1 = Qty('1 m') +import "../jasmine"; +import Qty from "."; -var Val2 = Qty(1); +// From project readme -var Val3 = Qty(1, 'm'); +let qty: Qty; -var Val4 = Qty(Val1); \ No newline at end of file +qty = new Qty('23 ft'); // constructor +qty = Qty('23 ft'); // factory + +qty = new Qty(124, 'cm'); // => 1.24 meter +qty = Qty(124, 'cm'); // => 1.24 meter + +qty = Qty('1m'); // => 1 meter +qty = Qty('m'); // => 1 meter (scalar defaults to 1) + +qty = Qty('1 N*m'); +qty = Qty('1 N m'); // * is optional + +qty = Qty('1 m/s'); + +qty = Qty('1 m^2/s^2'); +qty = Qty('1 m^2 s^-2'); // negative powers +qty = Qty('1 m2 s-2'); // ^ is optional + +qty = Qty('1 m^2 kg^2 J^2/s^2 A'); + +qty = Qty('1.5'); // unitless quantity +qty = Qty(1.5); // number as initializing value + +qty = Qty('1 attoparsec/microfortnight'); + +let qtyCopy: Qty; + +qtyCopy = Qty(qty); // quantity could be copied when used as initializing value + +Qty.parse('1 m'); // => 1 meter +Qty.parse('foo'); // => null + +Qty.getKinds(); // => Array of names of every well-known kind of units + +Qty.getUnits('currency'); // => [ 'dollar', 'cents' ] +// Or all alphabetically sorted +Qty.getUnits(); // => [ 'acre','Ah','ampere','AMU','angstrom'] + +Qty.getAliases('m'); // => [ 'm', 'meter', 'meters', 'metre', 'metres' ] + +const qty1 = Qty('1m'); +const qty2 = Qty('2m'); + +qty1.isCompatible(qty2); // => true or false + +qty.kind(); // => 'length', 'area', etc... + +qty.isUnitless(); // => true or false +qty.isBase(); // => true if quantity is represented with base units + +qty.toBase(); // converts to SI units (10 cm => 0.1 m) (new instance) + +qty.toFloat(); // returns scalar of unitless quantity (otherwise throws error) + +qty.to('m'); // converts quantity to meter if compatible or throws an error (new instance) +qty1.to(qty2); // converts quantity to same unit of qty2 if compatible or throws an error (new instance) + +qty.inverse(); // converts quantity to its inverse ('100 m/s' => '.01 s/m') +// Inverses can be used, but there is no special checking to +// rename the units +Qty('10ohm').inverse(); // '.1/ohm' (not '.1S', although they are equivalent) +// however, the 'to' command will convert between inverses also +Qty('10ohm').to('S'); // '.1S' + +var convert = Qty.swiftConverter('m/h', 'ft/s'); // Configures converter + +// Converting single value +var converted = convert(2500); // => 2.278.. + +// Converting large array of values +var convertedSerie = convert([2500, 5000]); // => [2.278.., 4.556.., ...] + +qty1.eq(qty2); // => true if both quantities are equal (1m == 100cm => true) +qty1.same(qty2); // => true if both quantities are same (1m == 100cm => false) +qty1.lt(qty2); // => true if qty1 is stricty less than qty2 +qty1.lte(qty2); // => true if qty1 is less than or equal to qty2 +qty1.gt(qty2); // => true if qty1 is stricty greater than qty2 +qty1.gte(qty2); // => true if qty1 is greater than or equal to qty2 + +qty1.compareTo(qty2); // => -1 if qty1 < qty2, => 0 if qty1 == qty2, => 1 if qty1 > qty2 + +qty = Qty('5.17 ft'); +qty.toPrec('ft'); // => 5 ft +qty.toPrec('0.5 ft'); // => 5 ft +qty.toPrec('0.25 ft'); // => 5.25 ft +qty.toPrec('0.1 ft'); // => 5.2 ft +qty.toPrec('0.05 ft'); // => 5.15 ft +qty.toPrec('0.01 ft'); // => 5.17 ft +qty.toPrec('0.00001 ft'); // => 5.17 ft +qty.toPrec('2 ft'); // => 6 ft +qty.toPrec('2'); // => 6 ft + +qty = Qty('6.3782 m'); +qty.toPrec('dm'); // => 6.4 m +qty.toPrec('cm'); // => 6.38 m +qty.toPrec('mm'); // => 6.378 m +qty.toPrec('5 cm'); // => 6.4 m +qty.toPrec('10 m'); // => 10 m +qty.toPrec(0.1); // => 6.3 m + +qty = Qty('1.146 MPa'); +qty.toPrec('0.1 bar'); // => 1.15 MPa + +qty = Qty('1.146 MPa'); +qty.toString(); // => '1.146 MPa' + +qty = Qty('1.146 MPa'); +qty.toString('bar'); // => '11.46 bar' +qty.to('bar').toString(); // => '11.46 bar' + +qty = Qty('1.146 MPa'); +qty.toPrec(0.1).toString(); // => '1.1 MPa' +qty.to('bar').toPrec(0.1).toString(); // => '11.5 bar' + +qty = Qty('1.1234 m'); +qty.format(); // same units, default formatter => '1.234 m' +qty.format('cm'); // converted to 'cm', default formatter => '123.45 cm' + +var configurableRoundingFormatter = function (maxDecimals: number) { + return function (scalar: number, units: string) { + var pow = Math.pow(10, maxDecimals); + var rounded = Math.round(scalar * pow) / pow; + + return rounded + ' ' + units; + }; +}; + +qty = Qty('1.1234 m'); + +// same units, custom formatter => '1.12 m' +qty.format(configurableRoundingFormatter(2)); + +// convert to 'cm', custom formatter => '123.4 cm' +qty.format('cm', configurableRoundingFormatter(1)); + +Qty.formatter = configurableRoundingFormatter(2); +qty = Qty('1.1234 m'); +qty.format(); // same units, current default formatter => '1.12 m' + +Qty('37 tempC').to('tempF'); // => 98.6 tempF + +let scalar: number = 42; + +Qty('100 tempC').add('10 degC'); // 110 tempC +Qty('100 tempC').sub('10 degC'); // 90 tempC +Qty('100 tempC').add('50 tempC'); // throws error +Qty('100 tempC').sub('50 tempC'); // 50 degC +Qty('50 tempC').sub('100 tempC'); // -50 degC +Qty('100 tempC').mul(scalar); // 100*scalar tempC +Qty('100 tempC').div(scalar); // 100/scalar tempC +Qty('100 tempC').mul(qty); // throws error +Qty('100 tempC').div(qty); // throws error +Qty('100 tempC*unit'); // throws error +Qty('100 tempC/unit'); // throws error +Qty('100 unit/tempC'); // throws error +Qty('100 tempC').inverse(); // throws error + +Qty('100 tempC').to('degC'); // => 100 degC + +Qty('100 degC').to('tempC'); // => -173.15 tempC + +Qty('0 tempC').add('100 degC'); // => 100 tempC + +try { + // code triggering an error inside JS-quantities +} catch (e) { + if (e instanceof Qty.Error) { + // ... + } else { + // ... + } +} + +// From project spec + +describe("js-quantities", function () { + "use strict"; + + describe("initialization", function () { + it("should create unit only", function () { + var qty = Qty("m"); + expect(qty.numerator).toEqual([""]); + expect(qty.scalar).toBe(1); + }); + + it("should create unitless", function () { + var qty = Qty("1"); + expect(qty.toFloat()).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + qty = Qty("1.5"); + expect(qty.toFloat()).toBe(1.5); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create unitless from numbers", function () { + var qty = Qty(1.5); + expect(qty.toFloat()).toBe(1.5); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create from numbers with explicit units", function () { + var qty = Qty(1.5, "m"); + expect(qty.scalar).toBe(1.5); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("temperatures should have base unit in kelvin", function () { + var qty = Qty("1 tempK").toBase(); + expect(qty.scalar).toBe(1); + expect(qty.units()).toBe("tempK"); + + qty = Qty("1 tempR").toBase(); + expect(qty.scalar).toBe(5 / 9); + expect(qty.units()).toBe("tempK"); + + qty = Qty("0 tempC").toBase(); + expect(qty.scalar).toBe(273.15); + expect(qty.units()).toBe("tempK"); + + qty = Qty("0 tempF").toBase(); + expect(qty.scalar).toBeCloseTo(255.372, 3); + expect(qty.units()).toBe("tempK"); + }); + + it("temperature degrees should have base unit in kelvin", function () { + var qty = Qty("1 degK").toBase(); + expect(qty.scalar).toBe(1); + expect(qty.units()).toBe("degK"); + + qty = Qty("1 degR").toBase(); + expect(qty.scalar).toBe(5 / 9); + expect(qty.units()).toBe("degK"); + + qty = Qty("1 degC").toBase(); + expect(qty.scalar).toBe(1); + expect(qty.units()).toBe("degK"); + + qty = Qty("1 degF").toBase(); + expect(qty.scalar).toBe(5 / 9); + expect(qty.units()).toBe("degK"); + }); + + it("should not create temperatures below absolute zero", function () { + expect(function () { Qty("-1 tempK"); }).toThrow("Temperatures must not be less than absolute zero"); + expect(function () { Qty("-273.16 tempC"); }).toThrow("Temperatures must not be less than absolute zero"); + expect(function () { Qty("-459.68 tempF"); }).toThrow("Temperatures must not be less than absolute zero"); + expect(function () { Qty("-1 tempR"); }).toThrow("Temperatures must not be less than absolute zero"); + + var qty = Qty("1 tempK"); + expect(function () { qty.mul("-1"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("0 tempK"); + expect(function () { qty.sub("1 degK"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("-273.15 tempC"); + expect(function () { qty.sub("1 degC"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("-459.67 tempF"); + expect(function () { qty.sub("1 degF"); }).toThrow("Temperatures must not be less than absolute zero"); + + qty = Qty("0 tempR"); + expect(function () { qty.sub("1 degR"); }).toThrow("Temperatures must not be less than absolute zero"); + }); + + it("should create simple", function () { + var qty = Qty("1m"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create negative", function () { + var qty = Qty("-1m"); + expect(qty.scalar).toBe(-1); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create compound", function () { + var qty = Qty("1 N*m"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create pressure units in term of height of water", function () { + var qty = Qty("1 inH2O"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + + qty = Qty("1 cmH2O"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + }); + + it("should create with denominator", function () { + var qty = Qty("1 m/s"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual([""]); + expect(qty.denominator).toEqual([""]); + }); + + it("should create with denominator only", function () { + var qty = Qty("1 /s"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual([""]); + + qty = Qty("1 1/s"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual([""]); + + qty = Qty("1 s^-1"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual([""]); + }); + + it("should create with powers", function () { + var qty = Qty("1 m^2/s^2"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["", ""]); + qty = Qty("1 m^2 kg^2 J^2/s^2"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", "", "", "", "", ""]); + expect(qty.denominator).toEqual(["", ""]); + qty = Qty("1 m^2/s^2*J^3"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["", "", "", "", ""]); + }); + + it("should create with zero power", function () { + var qty = Qty("1 m^0"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["<1>"]); + expect(qty.denominator).toEqual(["<1>"]); + }); + + it("should create with negative powers", function () { + var qty = Qty("1 m^2 s^-2"); + expect(qty.scalar).toBe(1); + expect(qty.numerator).toEqual(["", ""]); + expect(qty.denominator).toEqual(["", ""]); + expect(qty.same(Qty("1 m^2/s^2"))).toBe(true); + }); + + it("should accept powers without ^ syntax (simple)", function () { + var qty1 = Qty("1 m2"); + var qty2 = Qty("1 m^2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should accept powers without ^ syntax (negative power)", function () { + var qty1 = Qty("1 m-2"); + var qty2 = Qty("1 m^-2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should accept powers without ^ syntax (compound)", function () { + var qty1 = Qty("1 m^2 kg^2 J^2/s^2"); + var qty2 = Qty("1 m2 kg2 J2/s2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should accept powers without ^ syntax (compound and negative power)", function () { + var qty1 = Qty("1 m^2 kg^2 J^2 s^-2"); + var qty2 = Qty("1 m2 kg2 J2 s-2"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should throw 'Unit not recognized' error when initializing with an invalid unit", function () { + expect(function () { Qty("aa"); }).toThrow("Unit not recognized"); + expect(function () { Qty("m/aa"); }).toThrow("Unit not recognized"); + expect(function () { Qty("m-"); }).toThrow("Unit not recognized"); + expect(function () { Qty("N*m"); }).not.toThrow("Unit not recognized"); + // mm is millimeter, but mmm is not a valid unit + expect(function () { Qty("mmm"); }).toThrow("Unit not recognized"); + }); + + it("should accept empty string as unitless 1", function () { + expect(Qty("").same(Qty("1"))).toBe(true); + expect(Qty(" ").same(Qty("1"))).toBe(true); + }); + + it("should throw error when passing NaN", function () { + expect( + function () { Qty(NaN); } + ).toThrow("Only string, number or quantity accepted as single " + + "initialization value"); + }); + + it("should throw 'Unit not recognized' error when initializing with an invalid unit and a 0 exponent", function () { + expect(function () { Qty("3p0"); }).toThrow("Unit not recognized"); + expect(function () { Qty("3p-0"); }).toThrow("Unit not recognized"); + }); + + it("should set baseScalar", function () { + var qty = Qty("0.018 MPa"); + expect(qty.baseScalar).toBe(18000); + + qty = Qty("66 cm3"); + expect(qty.baseScalar).toBe(0.000066); + }); + + it("should keep init value as is", function () { + var initValue = " 66 cm3 "; + var qty = Qty(initValue); + + expect(qty.initValue).toEqual(initValue); + }); + + it("should allow whitespace-wrapped value", function () { + expect(function () { Qty(" 2 MPa "); }).not.toThrow(); + }); + + it("should allow whitespaces between sign and scalar", function () { + var qty = Qty("- 1m"); + + expect(qty.scalar).toEqual(-1); + expect(qty.units()).toEqual("m"); + }); + + it("should throw an error when parsing negative quantity " + + "with no scalar", function () { + expect(function () { Qty("-m"); }).toThrow("Unit not recognized"); + }); + }); + + describe("isCompatible", function () { + it("should return true with compatible quantities", function () { + var qty1 = Qty("1 m*kg/s"); + var qty2 = Qty("1 in*pound/min"); + expect(qty1.isCompatible(qty2)).toBe(true); + qty2 = Qty("1 in/min"); + expect(qty1.isCompatible(qty2)).toBe(false); + }); + + it("should return true with dimensionless quantities", function () { + var qty1 = Qty("1"); + var qty2 = Qty("2"); + expect(qty1.isCompatible(qty2)).toBe(true); + }); + }); + + describe("conversion", function () { + it("should convert to base units", function () { + var qty = Qty("100 cm"); + expect(qty.toBase().scalar).toBe(1); + expect(qty.toBase().units()).toBe("m"); + qty = Qty("10 cm"); + expect(qty.toBase().scalar).toBe(0.1); + expect(qty.toBase().units()).toBe("m"); + qty = Qty("0.3 mm^2 ms^-2"); + expect(qty.toBase().scalar).toBe(0.3); + expect(qty.toBase().units()).toBe("m2/s2"); + }); + + it("should convert to compatible units", function () { + var qty = Qty("10 cm"); + expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048)); + qty = Qty("2m^3"); + expect(qty.to("l").scalar).toBe(2000); + + qty = Qty("10 cm"); + expect(qty.to(Qty("m")).scalar).toBe(0.1); + expect(qty.to(Qty("20m")).scalar).toBe(0.1); + + qty = Qty("1 m3"); + expect(qty.to("cm3").scalar).toBe(1000000); + + qty = Qty("1 cm3"); + expect(qty.to("mm3").scalar).toBe(1000); + + qty = Qty("550 cm3"); + expect(qty.to("cm^3").scalar).toBe(550); + + qty = Qty("0.000773 m3"); + expect(qty.to("cm^3").scalar).toBe(773); + }); + + describe('percents', function () { + it("should convert from % to unitless", function () { + expect(Qty("10 %").to("").same(Qty("0.1"))).toBe(true); + }); + + it("should convert from unitless to %", function () { + expect(Qty("0.1").to("%").same(Qty("10 %"))).toBe(true); + }); + }); + + it("should convert temperatures to compatible units", function () { + var qty = Qty("0 tempK"); + expect(qty.to("tempC").scalar).toBe(-273.15); + + qty = Qty("0 tempF"); + expect(qty.to("tempK").scalar).toBeCloseTo(255.372, 3); + + qty = Qty("32 tempF"); + expect(qty.to("tempC").scalar).toBe(0); + + qty = Qty("0 tempC"); + expect(qty.to("tempF").scalar).toBeCloseTo(32, 10); + }); + + it("should convert temperature degrees to compatible units", function () { + var qty = Qty("0 degK"); + expect(qty.to("degC").scalar).toBe(0); + + qty = Qty("1 degK/s"); + expect(qty.to("degC/min").scalar).toBe(60); + + qty = Qty("100 cm/degF"); + expect(qty.to("m/degF").scalar).toBe(1); + + qty = Qty("10 degC"); + expect(qty.to("degF").scalar).toBe(18); + }); + + it("should convert temperature degrees to temperatures", function () { + // according to ruby-units, deg -> temp conversion adds the degress to 0 kelvin before converting + var qty = Qty("100 degC"); + expect(qty.to("tempC").scalar).toBeCloseTo(-173.15, 10); + + qty = Qty("273.15 degC"); + expect(qty.to("tempC").scalar).toBe(0); + + qty = Qty("460.67 degF"); + expect(qty.to("tempF").scalar).toBeCloseTo(1, 10); + }); + + it("should convert temperatures to temperature degrees", function () { + // according to ruby-units, temp -> deg conversion always uses the 0 relative degrees + var qty = Qty("100 tempC"); + expect(qty.to("degC").scalar).toBe(100); + + qty = Qty("0 tempK"); + expect(qty.to("degC").scalar).toBe(0); + + qty = Qty("0 tempF"); + expect(qty.to("degK").scalar).toBe(0); + + qty = Qty("18 tempF"); + expect(qty.to("degC").scalar).toBe(10); + + qty = Qty("10 tempC"); + expect(qty.to("degF").scalar).toBe(18); + }); + + it("should calculate inverses", function () { + var qty = Qty("1 ohm"); + var result = qty.to("siemens"); + expect(result.scalar).toBe(1); + expect(result.kind()).toBe("conductance"); + + qty = Qty("10 ohm"); + result = qty.to("siemens"); + expect(result.scalar).toBe(0.1); + expect(result.kind()).toBe("conductance"); + + qty = Qty("10 siemens"); + result = qty.to("ohm"); + expect(result.scalar).toBe(0.1); + expect(result.kind()).toBe("resistance"); + + qty = Qty("10 siemens"); + result = qty.inverse(); + expect(result.eq(".1 ohm")).toBe(true); + expect(result.kind()).toBe("resistance"); + + // cannot inverse a quantity with a 0 scalar + qty = Qty("0 ohm"); + expect(function () { qty.inverse(); }).toThrow("Divide by zero"); + + qty = Qty("10 ohm").inverse(); + result = qty.to("S"); + expect(result.scalar).toBe(0.1); + expect(result.kind()).toBe("conductance"); + + qty = Qty("12 in").inverse(); + // TODO: Swap toBeCloseTo with toBe once divSafe is fixed + expect(qty.to("ft").scalar).toBeCloseTo(1, 10); + }); + + it("should return itself if target units are the same", function () { + var qty = Qty("123 cm3"); + + expect(qty.to("cm3")).toBe(qty); + expect(qty.to("cm^3")).toBe(qty); + + qty = Qty("123 mcg"); + expect(qty.to("ug")).toBe(qty); + }); + + it("should be cached", function () { + var qty = Qty("100 m"), + converted = qty.to("ft"); + + expect(qty.to("ft") === converted).toBe(true); + }); + }); + + describe("comparison", function () { + it("should return true when comparing equal quantities", function () { + var qty1 = Qty("1cm"); + var qty2 = Qty("10mm"); + expect(qty1.eq(qty2)).toBe(true); + }); + + it("should compare compatible quantities", function () { + var qty1 = Qty("1cm"); + var qty2 = Qty("1mm"); + var qty3 = Qty("10mm"); + var qty4 = Qty("28A"); + expect(qty1.compareTo(qty2)).toBe(1); + expect(qty2.compareTo(qty1)).toBe(-1); + expect(qty1.compareTo(qty3)).toBe(0); + expect(function () { qty1.compareTo(qty4); }).toThrow("Incompatible units"); + + expect(qty1.lt(qty2)).toBe(false); + expect(qty1.lt(qty3)).toBe(false); + expect(qty1.lte(qty3)).toBe(true); + expect(qty1.gte(qty3)).toBe(true); + expect(qty1.gt(qty2)).toBe(true); + expect(qty2.gt(qty1)).toBe(false); + }); + + it("should compare identical quantities", function () { + var qty1 = Qty("1cm"); + var qty2 = Qty("1cm"); + var qty3 = Qty("10mm"); + expect(qty1.same(qty2)).toBe(true); + expect(qty1.same(qty3)).toBe(false); + }); + + it("should accept strings as parameter", function () { + var qty = Qty("1 cm"); + expect(qty.lt("0.5 cm")).toBe(false); + expect(qty.lte("1 cm")).toBe(true); + expect(qty.gte("3 mm")).toBe(true); + expect(qty.gt("5 m")).toBe(false); + }); + + }); + + describe("non-ASCII character", function () { + describe("µ", function () { + it("should be supported as prefix", function () { + // µ as greek letter + expect(Qty("1 \u03BCm").eq(Qty("1 um"))).toBe(true); + // µ as micro sign + expect(Qty("1 \u00B5m").eq(Qty("1 um"))).toBe(true); + }); + }); + + describe("Ω", function () { + it("should be accepted as unit for ohm", function () { + // Ω as greek letter + expect(Qty("1 \u03A9").eq(Qty("1 ohm"))).toBe(true); + // Ω as ohm sign + expect(Qty("1 \u2126").eq(Qty("1 ohm"))).toBe(true); + }); + }); + }); + + describe("math", function () { + + it("should add quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + expect(qty1.add(qty2).scalar).toBe(5.5); + + expect(qty1.add("3m").scalar).toBe(5.5); + + qty2 = Qty("3cm"); + var result = qty1.add(qty2); + expect(result.scalar).toBe(2.53); + expect(result.units()).toBe("m"); + + result = qty2.add(qty1); + expect(result.scalar).toBe(253); + expect(result.units()).toBe("cm"); + + // make sure adding 2 of the same non-base units work + result = Qty("5cm").add("3cm"); + expect(result.scalar).toBe(8); + expect(result.units()).toBe("cm"); + }); + + it("should fail to add unlike quantities", function () { + var qty1 = Qty("3m"); + var qty2 = Qty("2s"); + expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); + }); + + it("should fail to add inverse quantities", function () { + var qty1 = Qty("10S"); + var qty2 = qty1.inverse(); + expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); + + qty1 = Qty("10S"); + qty2 = Qty("0.1ohm"); + expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); + }); + + it("should subtract quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + expect(qty1.sub(qty2).scalar).toBe(-0.5); + + expect(qty1.sub("2m").scalar).toBe(0.5); + expect(qty1.sub("-2m").scalar).toBe(4.5); + + qty2 = Qty("3cm"); + var result = qty1.sub(qty2); + expect(result.scalar).toBe(2.47); + expect(result.units()).toBe("m"); + + result = qty2.sub(qty1); + expect(result.scalar).toBe(-247); + expect(result.units()).toBe("cm"); + }); + + it("should fail to subtract unlike quantities", function () { + var qty1 = Qty("3m"); + var qty2 = Qty("2s"); + expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); + }); + + it("should fail to subtract inverse quantities", function () { + var qty1 = Qty("10S"); + var qty2 = qty1.inverse(); + expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); + + qty1 = Qty("10S"); + qty2 = Qty("0.1ohm"); + expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); + expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); + }); + + it("should multiply quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + var result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + expect(result.units()).toBe("m2"); + expect(result.kind()).toBe("area"); + + qty2 = Qty("3cm"); + result = qty1.mul(qty2); + expect(result.scalar).toBe(0.075); + expect(result.units()).toBe("m2"); + + result = qty2.mul(qty1); + expect(result.scalar).toBe(750); + expect(result.units()).toBe("cm2"); + + result = qty1.mul(3.5); + expect(result.scalar).toBe(8.75); + expect(result.units()).toBe("m"); + + result = qty1.mul(0); + expect(result.scalar).toBe(0); + expect(result.units()).toBe("m"); + + result = qty1.mul(Qty("0m")); + expect(result.scalar).toBe(0); + expect(result.units()).toBe("m2"); + + qty2 = Qty("1.458 m"); + result = qty1.mul(qty2); + expect(result.scalar).toBe(3.645); + expect(result.units()).toBe("m2"); + }); + + it("should multiply unlike quantities", function () { + var qty1 = Qty("2.5 m"); + var qty2 = Qty("3 N"); + + var result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + + qty1 = Qty("2.5 m^2"); + qty2 = Qty("3 kg/m^2"); + + result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + expect(result.units()).toBe("kg"); + }); + + it("should multiply inverse quantities", function () { + var qty1 = Qty("10S"); + var qty2 = Qty(".5S").inverse(); // 2/S + var qty3 = qty1.inverse(); // .1/S + + var result = qty1.mul(qty2); + expect(result.scalar).toBe(20); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + // swapping operands should give the same outcome + result = qty2.mul(qty1); + expect(result.scalar).toBe(20); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + + result = qty1.mul(qty3); + expect(result.scalar).toBe(1); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + // swapping operands should give the same outcome + result = qty3.mul(qty1); + expect(result.scalar).toBe(1); + expect(result.isUnitless()).toBe(true); + expect(result.units()).toBe(""); + }); + + it("should divide quantities", function () { + var qty1 = Qty("2.5m"); + var qty2 = Qty("3m"); + var qty3 = Qty("0m"); + + expect(function () { qty1.div(qty3); }).toThrow("Divide by zero"); + expect(function () { qty1.div(0); }).toThrow("Divide by zero"); + expect(qty3.div(qty1).scalar).toBe(0); + + var result = qty1.div(qty2); + expect(result.scalar).toBe(2.5 / 3); + expect(result.units()).toBe(""); + expect(result.kind()).toBe("unitless"); + + var qty4 = Qty("3cm"); + result = qty1.div(qty4); + expect(result.scalar).toBe(2.5 / 0.03); + expect(result.units()).toBe(""); + + result = qty4.div(qty1); + expect(result.scalar).toBe(0.012); + expect(result.units()).toBe(""); + + result = qty1.div(3.5); + expect(result.scalar).toBe(2.5 / 3.5); + expect(result.units()).toBe("m"); + }); + + it("should divide unlike quantities", function () { + var qty1 = Qty("7.5kg"); + var qty2 = Qty("2.5m^2"); + + var result = qty1.div(qty2); + expect(result.scalar).toBe(3); + expect(result.units()).toBe("kg/m2"); + }); + + it("should divide inverse quantities", function () { + var qty1 = Qty("10 S"); + var qty2 = Qty(".5 S").inverse(); // 2/S + var qty3 = qty1.inverse(); // .1/S + + var result = qty1.div(qty2); + expect(result.scalar).toBe(5); + expect(result.units()).toBe("S2"); + + result = qty2.div(qty1); + expect(result.scalar).toBe(0.2); + expect(result.units()).toBe("1/S2"); + + result = qty1.div(qty3); + expect(result.scalar).toBe(100); + expect(result.units()).toBe("S2"); + + result = qty3.div(qty1); + expect(result.scalar).toBe(0.01); + expect(result.units()).toBe("1/S2"); + }); + + }); + + describe("math with temperatures", function () { + + it("should add temperature degrees", function () { + var qty = Qty("2degC"); + expect(qty.add("3degF").scalar).toBeCloseTo(11 / 3, 10); + expect(qty.add("-1degC").scalar).toBe(1); + + qty = Qty("2 degC"); + var result = qty.add("2 degF"); + expect(result.scalar).toBe(28 / 9); + expect(result.units()).toBe("degC"); + + qty = Qty("2degK"); + result = qty.add("3degC"); + expect(result.scalar).toBe(5); + expect(result.units()).toBe("degK"); + + qty = Qty("2degC"); + result = qty.add("2degK"); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("degC"); + }); + + it("should not add two temperatures", function () { + var qty = Qty("2tempC"); + expect(function () { qty.add("1 tempF"); }).toThrow("Cannot add two temperatures"); + expect(function () { qty.add("1 tempC"); }).toThrow("Cannot add two temperatures"); + }); + + it("should add temperatures to degrees", function () { + var qty = Qty("2degC"); + var result = qty.add("3tempF"); + expect(result.scalar).toBe(33 / 5); + expect(result.units()).toBe("tempF"); + + result = qty.add("-1tempC"); + expect(result.scalar).toBe(1); + expect(result.units()).toBe("tempC"); + + qty = Qty("2 tempC"); + result = qty.add("2 degF"); + expect(result.scalar).toBe(28 / 9); + expect(result.units()).toBe("tempC"); + }); + + it("should subtract degrees from degrees", function () { + var qty = Qty("2degC"); + expect(qty.sub("1.5degK").scalar).toBe(0.5); + expect(qty.sub("-2degC").scalar).toBe(4); + expect(qty.sub("1degF").scalar).toBe(2 - 5 / 9); + expect(qty.sub("-1degC").scalar).toBe(3); + + var result = qty.sub("degC"); + expect(result.scalar).toBe(1); + expect(result.units()).toBe("degC"); + }); + + it("should subtract degrees from temperatures", function () { + var qty = Qty("2tempC"); + expect(qty.sub("1.5degK").scalar).toBe(0.5); + expect(qty.sub("-2degC").scalar).toBe(4); + expect(qty.sub("1degF").scalar).toBe(2 - 5 / 9); + expect(qty.sub("-1degC").scalar).toBe(3); + + var result = qty.sub("degC"); + expect(result.scalar).toBe(1); + expect(result.units()).toBe("tempC"); + }); + + it("should subtract temperatures from temperatures", function () { + var qty = Qty("2tempC"); + + var result = qty.sub("1.5tempK"); + expect(result.scalar).toBe(273.65); + expect(result.units()).toBe("degC"); + + result = qty.sub("-2tempC"); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("degC"); + + result = qty.sub("32tempF"); + expect(result.scalar).toBe(2); + expect(result.units()).toBe("degC"); + }); + + it("should not subtract temperatures from degrees", function () { + var qty = Qty("2degC"); + expect(function () { qty.sub("1 tempF"); }).toThrow("Cannot subtract a temperature from a differential degree unit"); + expect(function () { qty.sub("1 tempC"); }).toThrow("Cannot subtract a temperature from a differential degree unit"); + }); + + it("should multiply temperature degrees", function () { + var qty = Qty("2degF"); + var result = qty.mul(3); + expect(result.scalar).toBe(6); + expect(result.units()).toBe("degF"); + + result = qty.mul("3degF"); + expect(result.scalar).toBe(6); + expect(result.units()).toBe("degF2"); + + // TODO: Should we convert degrees ("2 degK" to "degC") before we do the math? + qty = Qty("2degC"); + result = qty.mul("2degK"); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("degC*degK"); + + qty = Qty("2degC"); + result = qty.mul("degF"); + expect(result.scalar).toBe(2); + expect(result.units()).toBe("degC*degF"); + }); + + it("should not multiply temperatures except by scalar", function () { + var qty = Qty("2tempF"); + expect(function () { qty.mul("1 tempC"); }).toThrow("Cannot multiply by temperatures"); + expect(function () { qty.mul("1 degC"); }).toThrow("Cannot multiply by temperatures"); + expect(function () { Qty("1 tempC*s"); }).toThrow("Cannot multiply by temperatures"); + + var result = qty.mul(2); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("tempF"); + + result = Qty("2").mul(qty); + expect(result.scalar).toBe(4); + expect(result.units()).toBe("tempF"); + }); + + it("should multiply temperature degrees with unlike quantities", function () { + var qty1 = Qty("2.5 degF"); + var qty2 = Qty("3 m"); + + var result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + + qty1 = Qty("2.5 degF"); + qty2 = Qty("3 kg/degF"); + + result = qty1.mul(qty2); + expect(result.scalar).toBe(7.5); + expect(result.units()).toBe("kg"); + }); + + it("should divide temperature degrees with unlike quantities", function () { + var qty1 = Qty("7.5degF"); + var qty2 = Qty("2.5m^2"); + + var result = qty1.div(qty2); + expect(result.scalar).toBe(3); + expect(result.units()).toBe("degF/m2"); + }); + + it("should divide temperature degree quantities", function () { + var qty = Qty("2.5 degF"); + + expect(function () { qty.div("0 degF"); }).toThrow("Divide by zero"); + expect(function () { qty.div(0); }).toThrow("Divide by zero"); + expect(Qty("0 degF").div(qty).scalar).toBe(0); + expect(Qty("0 degF").div(qty).units()).toBe(""); + + var result = qty.div("3 degF"); + expect(result.scalar).toBe(2.5 / 3); + expect(result.units()).toBe(""); + expect(result.kind()).toBe("unitless"); + + result = qty.div(3); + expect(result.scalar).toBe(2.5 / 3); + expect(result.units()).toBe("degF"); + expect(result.kind()).toBe("temperature"); + + // TODO: Should we convert "2 degC" to "degF" before we do the math? + result = qty.div("2 degC"); + expect(result.scalar).toBe(1.25); + expect(result.units()).toBe("degF/degC"); + }); + + it("should not divide with temperatures except by scalar", function () { + expect(function () { Qty("tempF").div("1 tempC"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("tempF").div("1 degC"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("2").div("tempF"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("2 tempF/s"); }).toThrow("Cannot divide with temperatures"); + expect(function () { Qty("2 s/tempF"); }).toThrow("Cannot divide with temperatures"); + + // inverse is division: 1/x + expect(function () { Qty("tempF").inverse(); }).toThrow("Cannot divide with temperatures"); + + var result = Qty("4 tempF").div(2); + expect(result.scalar).toBe(2); + expect(result.units()).toBe("tempF"); + }); + + }); + + describe("errors", function () { + it("should be instance of Qty.Error", function () { + try { + Qty("aa"); + } catch (e) { + expect(e instanceof Qty.Error).toBeTruthy(); + } + }); + }); + + describe("utility methods", function () { + + it("should accept string as parameter for compatibility tests", function () { + var qty = Qty("1 mm"); + + expect(qty.isCompatible("2 mm")).toBe(true); + expect(qty.isCompatible("2 mm^3")).toBe(false); + }); + + it("should return kind", function () { + var qty = Qty("1 mm"); + expect(qty.kind()).toBe("length"); + + qty = Qty("1 N"); + expect(qty.kind()).toBe("force"); + }); + + it("should know if a quantity is in base units", function () { + var qty = Qty("100 cm"); + expect(qty.isBase()).toBe(false); + + qty = Qty("1m"); + expect(qty.isBase()).toBe(true); + }); + + it("should return unit part of quantities", function () { + var qty = Qty("1"); + expect(qty.units()).toBe(""); + qty = Qty("1 /s"); + expect(qty.units()).toBe("1/s"); + qty = Qty("100 cm"); + expect(qty.units()).toBe("cm"); + qty = Qty("100 cm/s"); + expect(qty.units()).toBe("cm/s"); + qty = Qty("1 cm^2"); + expect(qty.units()).toBe("cm2"); + qty = Qty("1 cm^2/s^2"); + expect(qty.units()).toBe("cm2/s2"); + qty = Qty("1 cm^2*J^3/s^2*A^2"); + expect(qty.units()).toBe("cm2*J3/s2*A2"); + }); + + }); + + describe("toString", function () { + it("should generate readable human output", function () { + var qty = Qty("2m"); + expect(qty.toString()).toBe("2 m"); + expect(qty.toString("cm")).toBe("200 cm"); + expect(qty.toString("km")).toBe("0.002 km"); + expect(function () { qty.toString("A"); }).toThrow("Incompatible units"); + + qty = Qty("24.5m/s"); + expect(qty.toString()).toBe("24.5 m/s"); + expect(function () { qty.toString("m"); }).toThrow("Incompatible units"); + expect(qty.toString("km/h")).toBe("88.2 km/h"); + + qty = Qty("254kg/m^2"); + expect(qty.toString()).toBe("254 kg/m2"); + + qty = Qty("2"); + expect(qty.toString()).toBe("2"); + }); + + it("should round readable human output when max decimals is specified", function () { + var qty = (Qty("2m")).div(3); + expect(qty.toString("cm", 2)).toBe("66.67 cm"); + + qty = Qty("2.8m"); + expect(qty.toString("m", 0)).toBe("3 m"); + expect(qty.toString("cm", 0)).toBe("280 cm"); + qty = Qty("2.818m"); + expect(qty.toString("cm", 0)).toBe("282 cm"); + }); + + it("should round to max decimals", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.toString(3)).toBe("2.988 m"); + expect(qty.toString(0)).toBe("3 m"); + }); + + it("should round according to precision passed as quantity", function () { + var qty = Qty("5.17 ft"); + + expect(qty.toString(Qty("ft"))).toBe("5 ft"); + expect(qty.toString(Qty("2 ft"))).toBe("6 ft"); + expect(qty.toString(Qty("0.5 ft"))).toBe("5 ft"); + expect(qty.toString(Qty("0.1 ft"))).toBe("5.2 ft"); + expect(qty.toString(Qty("0.05 ft"))).toBe("5.15 ft"); + expect(qty.toString(Qty("0.01 ft"))).toBe("5.17 ft"); + expect(qty.toString(Qty("0.0001 ft"))).toBe("5.17 ft"); + }); + + it("should return same output with successive calls", function () { + var qty = Qty("123 cm3"); + expect(qty.toString("cm3", 0)).toBe("123 cm3"); + expect(qty.toString("cm3", 0)).toBe("123 cm3"); + }); + + it("should return identical output when called with no parameters or same units", function () { + var qty = Qty("123 cm3"); + expect(qty.toString()).toBe(qty.toString("cm3")); + }); + + }); + + describe("format", function () { + describe("provided default formatter", function () { + it("should be applied to output", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.format()).toBe("2.987654321 m"); + }); + }); + + describe("custom formatter", function () { + var roundingFormatter = function (maxDecimals: number) { + return function (scalar: number, units: string) { + var pow = Math.pow(10, maxDecimals); + var rounded = Math.round(scalar * pow) / pow; + + return rounded + " " + units; + }; + }; + + it("should be applied to output", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.format(roundingFormatter(3))).toBe("2.988 m"); + expect(qty.format(roundingFormatter(0))).toBe("3 m"); + }); + + it("should be applied after conversion to target units", function () { + var qty = (Qty("2m")).div(3); + expect(qty.format("cm", roundingFormatter(2))).toBe("66.67 cm"); + + var intRoundingFormatter = roundingFormatter(0); + qty = Qty("2.8m"); + expect(qty.format("m", intRoundingFormatter)).toBe("3 m"); + expect(qty.format("cm", intRoundingFormatter)).toBe("280 cm"); + qty = Qty("2.818m"); + expect(qty.format("cm", intRoundingFormatter)).toBe("282 cm"); + }); + + describe("globally set as default formatter", function () { + var previousFormatter: Qty.Formatter; + + beforeEach(function () { + previousFormatter = Qty.formatter; + Qty.formatter = roundingFormatter(3); + }); + + afterEach(function () { + // Restore previous formatter + Qty.formatter = previousFormatter; + }); + + it("should be applied when no formatter is passed", function () { + var qty = (Qty("2.987654321 m")); + + expect(qty.format()).toBe("2.988 m"); + }); + }); + }); + }); + + describe("precision rounding", function () { + it("should round according to precision passed as quantity with same units", function () { + var qty = Qty("5.17 ft"); + + expect(qty.toPrec(Qty("ft")).toString()).toBe("5 ft"); + expect(qty.toPrec(Qty("2 ft")).toString()).toBe("6 ft"); + expect(qty.toPrec(Qty("10 ft")).toString()).toBe("10 ft"); + expect(qty.toPrec(Qty("0.5 ft")).toString()).toBe("5 ft"); + expect(qty.toPrec(Qty("0.1 ft")).toString()).toBe("5.2 ft"); + expect(qty.toPrec(Qty("0.05 ft")).toString()).toBe("5.15 ft"); + expect(qty.toPrec(Qty("0.01 ft")).toString()).toBe("5.17 ft"); + expect(qty.toPrec(Qty("0.0001 ft")).toString()).toBe("5.17 ft"); + expect(qty.toPrec(Qty("0.25 ft")).toString()).toBe("5.25 ft"); + }); + + it("should allow string as precision parameter", function () { + var qty = Qty("5.17 ft"); + + expect(qty.toPrec("ft").toString()).toBe("5 ft"); + expect(qty.toPrec("0.5 ft").toString()).toBe("5 ft"); + expect(qty.toPrec("0.05 ft").toString()).toBe("5.15 ft"); + }); + + it("should round according to precision passed as quantity with different prefixes", function () { + var qty = Qty("6.3782 m"); + + expect(qty.toPrec(Qty("dm")).toString()).toBe("6.4 m"); + expect(qty.toPrec(Qty("cm")).toString()).toBe("6.38 m"); + expect(qty.toPrec(Qty("mm")).toString()).toBe("6.378 m"); + + expect(qty.toPrec(Qty("5 cm")).toString()).toBe("6.4 m"); + }); + + it("should round according to precision passed as quantity with different compatible units", function () { + var qty = Qty("1.146 MPa"); + expect(qty.toPrec(Qty("0.1 bar")).toString()).toBe("1.15 MPa"); + expect(qty.toPrec(Qty("0.01 MPa")).toString()).toBe("1.15 MPa"); + expect(qty.toPrec(Qty("dbar")).toString()).toBe("1.15 MPa"); + + // Tests below are mainly a safety net because not sure if there is + // any usefulness to do things like that + qty = Qty("5.171234568 ft"); + expect(qty.toPrec(Qty("m")).toString()).toBe("6.561679790026248 ft"); + expect(qty.toPrec(Qty("dm")).toString()).toBe("5.249343832020998 ft"); + expect(qty.toPrec(Qty("cm")).toString()).toBe("5.183727034120736 ft"); + expect(qty.toPrec(Qty("mm")).toString()).toBe("5.170603674540684 ft"); + }); + }); + + describe("mulSafe", function () { + it("should multiply while trying to avoid numerical errors", function () { + expect(Qty.mulSafe(0.1, 0.1)).toBe(0.01); + expect(Qty.mulSafe(1e-11, 123.456789)).toBe(1.23456789e-9); + expect(Qty.mulSafe(6e-12, 100000)).toBe(6e-7); + }); + }); + + describe("divSafe", function () { + it("should divide while trying to avoid numerical errors", function () { + expect(Qty.divSafe(0.000773, 0.000001)).toBe(773); + // TODO uncomment and fix + //expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2); + }); + }); + + describe("Qty.parse", function () { + it("should not throw if parsed argument is a string", function () { + expect(function () { Qty.parse("foo"); }).not.toThrow("Argument should be a string"); + }); + + it("should return parsed quantity when passing a valid quantity", function () { + expect((Qty.parse("2.5 m") instanceof Qty)).toBe(true); + }); + + it("should return null when passing an invalid quantity", function () { + expect(Qty.parse("aa")).toBeNull(); + }); + }); + + describe("Qty.swiftConverter", function () { + it("should return a function", function () { + expect(typeof Qty.swiftConverter("m/h", "ft/s")).toBe("function"); + }); + + it("should throw when passing incompatible units", function () { + expect(function () { Qty.swiftConverter("m", "s"); }).toThrow("Incompatible units"); + }); + + describe("converter", function () { + describe("single value", function () { + it("should convert value", function () { + // TODO Same test but with m/h -> ft/s triggers rounding issue + // (For the sake of speed, converter does not check and fix rounding issues) + var converter = Qty.swiftConverter("m/h", "m/s"); + + expect(converter(2500)).toEqual(Qty("2500 m/h").to("m/s").scalar); + }); + + it("should returned value unchanged when units are identical", function () { + var converter = Qty.swiftConverter("m/h", "m/h"); + + expect(converter(2500)).toEqual(2500); + }); + + it("should convert temperatures", function () { + var converter = Qty.swiftConverter("tempF", "tempC"); + + expect(converter(32)).toEqual(0); + }); + + it("should convert degrees", function () { + var converter = Qty.swiftConverter("degC", "degF"); + + expect(converter(10)).toEqual(18); + }); + }); + + describe("array of values", function () { + it("should be converted", function () { + var converter = Qty.swiftConverter("MPa", "bar"), + values = [250, 10, 15], + expected = [2500, 100, 150]; + + expect(converter(values)).toEqual(expected); + }); + }); + }); + }); + + describe("Qty.getKinds", function () { + it("should return an array of kind names", function () { + expect(Qty.getKinds()).toContain("resistance"); + }); + + it("should not contain duplicate kind names", function () { + var kinds = Qty.getKinds(); + var map: { [key: string]: number } = {}; + kinds.forEach(function (kind) { + map[kind] = 1; + }); + expect(kinds.length).toEqual(Object.keys(map).length); + }); + }); + + describe("Qty.getUnits", function () { + it("should return an array of units of kind", function () { + expect(Qty.getUnits("currency")).toContain("dollar"); + }); + it("should return an array of all units without arg", function () { + expect(Qty.getUnits()).toContain("sievert"); + }); + it("should throw unknown kind", function () { + expect(function () { Qty.getUnits('bogusKind'); }).toThrow("Kind not recognized"); + }); + }); + + describe("Qty.getAliases", function () { + it("should return array of alternative names for unit", function () { + expect(Qty.getAliases("m")).toContain("meter"); + expect(Qty.getAliases("meter")).toContain("metre"); + expect(Qty.getAliases("N")).toContain("newton"); + }); + }); + + describe("information", function () { + describe("bits and bytes", function () { + it("should have 'information' as kind", function () { + expect(Qty("3 b").kind()).toBe("information"); + expect(Qty("5 B").kind()).toBe("information"); + }); + + it("could be pluralized", function () { + expect(Qty("3 bits").eq(Qty("3 b"))).toBe(true); + expect(Qty("5 bytes").eq(Qty("5 B"))).toBe(true); + }); + }); + + describe("rate", function () { + it("should accept bps and Bps aliases", function () { + expect(Qty("3 bps").eq(Qty("3 b/s"))).toBe(true); + expect(Qty("5 Bps").eq(Qty("5 B/s"))).toBe(true); + }); + + it("should be parsed when prefixed", function () { + expect(Qty("3 kbps").eq(Qty("3 kb/s"))).toBe(true); + expect(Qty("5 MBps").eq(Qty("5 MB/s"))).toBe(true); + }); + + it("should have 'information_rate' as kind", function () { + expect(Qty("3 bps").kind()).toBe("information_rate"); + expect(Qty("5 Bps").kind()).toBe("information_rate"); + }); + }); + }); + + describe("non regression tests", function () { + describe("Wh (#38)", function () { + it("should be parsed", function () { + expect(Qty("Wh").eq(Qty("3600 J"))).toBe(true); + }); + + it("should be parsed when prefixed", function () { + expect(Qty("kWh").eq(Qty("1000 Wh"))).toBe(true); + }); + }); + + describe("Ah (#25)", function () { + it("should be parsed", function () { + expect(Qty("Ah").eq(Qty("3600 C"))).toBe(true); + }); + + it("should be parsed when prefixed", function () { + expect(Qty("mAh").eq(Qty("3.6 C"))).toBe(true); + }); + }); + + describe("Farad (#67)", function () { + it('should be equal to its definition', function () { + expect(Qty("1 F").eq(Qty("1 C").div(Qty("1 V")))).toBe(true); + }); + + it('should not be defined as base unit', function () { + var qty = Qty("F"); + + expect(qty.isBase()).toBe(false); + expect(qty.toBase().units()).toEqual("s4*A2/m2*kg"); + }); + + it('should be parsed when prefixed', function () { + var qty = Qty("100 nF"); + + expect(qty.eq(Qty("100 F").div(1e9))).toBe(true); + expect(qty.baseScalar).toEqual(1e-7); + }); + }); + }); +}); diff --git a/js-quantities/tsconfig.json b/js-quantities/tsconfig.json index 8c2a810060..c41d2d2197 100644 --- a/js-quantities/tsconfig.json +++ b/js-quantities/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -17,4 +17,4 @@ "index.d.ts", "js-quantities-tests.ts" ] -} \ No newline at end of file +} diff --git a/js-quantities/tslint.json b/js-quantities/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/js-quantities/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts new file mode 100644 index 0000000000..456641dc59 --- /dev/null +++ b/memoizee/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for memoizee 0.4 +// Project: https://github.com/medikoo/memoizee +// Definitions by: Juan Picado +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace memoizee { + interface Options { + length?: number; + maxAge?: number; + max?: number; + preFetch?: number | true; + promise?: boolean; + dispose?: (value: any) => void; + async?: boolean; + primitive?: boolean; + normalizer?: (value: any) => void; + resolvers?: Array<(arg: any) => any>; + } + + interface Memoized { + delete: F; + clear: F & (() => void); + } +} + +// tslint:disable:forbidden-types +declare function memoizee(f: F, options?: memoizee.Options): F & memoizee.Memoized; + +export = memoizee; diff --git a/memoizee/memoizee-tests.ts b/memoizee/memoizee-tests.ts new file mode 100644 index 0000000000..e8e73a2d6a --- /dev/null +++ b/memoizee/memoizee-tests.ts @@ -0,0 +1,61 @@ +import memoize = require('memoizee'); + +var fn = function (one: string, two?: number, three?: any) { /* ... */ }; + +let memoized = memoize(fn); +memoized('foo', 3, 'bar'); +memoized('foo', 3, 'bar'); +memoized = memoize(fn, { length: 2 }); +memoized('foo'); +memoized('foo', undefined); +memoized('foo', 3, {}); +memoized('foo', 3, 13); +memoized('foo', undefined); +memoized('foo', undefined); +memoized('foo', 3, {}); +memoized('foo', 3, 13); +memoized('foo', 3, 13); +memoized = memoize(fn, { primitive: true }); +memoized('/path/one'); +memoized('/path/one'); +memoized = memoize(fn, { dispose: function (value:number) { /*…*/ } }); +var foo3 = memoized('foo', 3); +var bar7 = memoized('bar', 7); +memoized.clear('foo', 3); // Dispose called with foo3 value +memoized.clear('bar', 7); // Dispose called with bar7 value +memoized.delete('foo', 0); +var mFn = memoize(function (hash:any) { + // body of memoized function +}, { normalizer: function (args:any) { + // args is arguments object as accessible in memoized function + return JSON.stringify(args[0]); +} }); + +mFn({ foo: 'bar' }); + +memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] }); +memoized(String(12), [1,2,3].length); +memoized("12", Number(true)); +memoized(String({ toString: function () { return "12"; } }), Number({})); + +{ + var afn = function (a:number, b:number) { + return new Promise(function (res) { res(a + b); }); + }; + let memoized = memoize(afn, { promise: true }); + memoized(3, 7); + memoized(3, 7); +} + +memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 }); + +memoized('foo', 3); +memoized('foo', 3); + +setTimeout(function () { + memoized('foo', 3); +}, 500); + +setTimeout(function () { + memoized('foo', 3); +}, 1300); diff --git a/memoizee/tsconfig.json b/memoizee/tsconfig.json new file mode 100644 index 0000000000..c2ccff1cab --- /dev/null +++ b/memoizee/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "memoizee-tests.ts" + ] +} diff --git a/memoizee/tslint.json b/memoizee/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/memoizee/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file diff --git a/react-intl/index.d.ts b/react-intl/index.d.ts index 80a2372e12..e0d9d3f623 100644 --- a/react-intl/index.d.ts +++ b/react-intl/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-intl 2.2.0 // Project: http://formatjs.io/react/ -// Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi +// Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi , Till Wolff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -13,7 +13,7 @@ declare namespace ReactIntl { pluralRuleFunction?: (n: number, ord: boolean) => string; } - function injectIntl(component: React.ComponentClass | React.StatelessComponent): React.ComponentClass; + function injectIntl | React.StatelessComponent>(component: T): T; function addLocaleData(data: Locale[] | Locale): void; @@ -45,6 +45,10 @@ declare namespace ReactIntl { formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string; } + interface InjectedIntlProps { + intl?: InjectedIntl + } + namespace IntlComponent { interface DateTimeFormatProps { /* diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx index cd484c17b4..160a37bc0f 100644 --- a/react-intl/react-intl-tests.tsx +++ b/react-intl/react-intl-tests.tsx @@ -9,20 +9,20 @@ import * as React from "react" import * as reactMixin from "react-mixin" import { -IntlProvider, -InjectedIntl, -addLocaleData, -hasLocaleData, -injectIntl, -intlShape, -defineMessages, -FormattedRelative, -FormattedMessage, -FormattedHTMLMessage, -FormattedNumber, -FormattedPlural, -FormattedDate, -FormattedTime + IntlProvider, + InjectedIntl, + addLocaleData, + hasLocaleData, + injectIntl, + intlShape, + defineMessages, + FormattedRelative, + FormattedMessage, + FormattedHTMLMessage, + FormattedNumber, + FormattedPlural, + FormattedDate, + FormattedTime } from "react-intl" import reactIntlEn = require("react-intl/locale-data/en"); @@ -31,7 +31,8 @@ addLocaleData(reactIntlEn); console.log(hasLocaleData("en")); interface SomeComponentProps { - intl: InjectedIntl + className: string, + intl?: InjectedIntl } class SomeComponent extends React.Component { @@ -47,14 +48,14 @@ class SomeComponent extends React.Component { const formattedPlural = intl.formatPlural(1, { one: "hai!" }); const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); - return
+ return
+ initialNow={new Date()} /> { many="haiku" /> { timeZoneName="short" /> { {(formattedNum: string) => ( {formattedNum} - ) } - -
+ )} + +
} } @@ -159,9 +160,9 @@ class TestApp extends React.Component<{}, {}> { "hello": "Hello, {name}!" }; return ( - - - + + + ); } } diff --git a/stripe/index.d.ts b/stripe/index.d.ts index 2f8c895298..fdfa1db96e 100644 --- a/stripe/index.d.ts +++ b/stripe/index.d.ts @@ -1,8 +1,10 @@ -// Type definitions for stripe +// Type definitions for stripe 0.0 // Project: https://stripe.com/ // Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon , Adam Cmiel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare const Stripe: StripeStatic; + interface StripeStatic { applePay: StripeApplePay; setPublishableKey(key: string): void; @@ -49,6 +51,8 @@ interface StripeError { param?: string; } +type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'; + interface StripeCardData { object: string; last4: string; @@ -62,18 +66,17 @@ interface StripeCardData { address_state?: string; address_zip?: string; address_country?: string; + brand?: StripeCardDataBrand; createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; } -interface StripeBankAccount -{ - createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void; +interface StripeBankAccount { + createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void; validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; } -interface StripeBankTokenParams -{ +interface StripeBankTokenParams { country: string; currency: string; account_number: number | string; @@ -82,8 +85,7 @@ interface StripeBankTokenParams account_holder_type: string; } -interface StripeBankTokenResponse -{ +interface StripeBankTokenResponse { id: string; bank_account: { country: string; @@ -100,13 +102,7 @@ interface StripeBankTokenResponse error?: StripeError; } -declare var Stripe: StripeStatic; -declare module "Stripe" { - export = StripeStatic; -} - -interface StripeApplePay -{ +interface StripeApplePay { checkAvailability(resopnseHandler: (result: boolean) => void): void; buildSession(data: StripeApplePayPaymentRequest, onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void, @@ -117,8 +113,7 @@ type StripeApplePayBillingContactField = 'postalAddress' | 'name'; type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email'; type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; -interface StripeApplePayPaymentRequest -{ +interface StripeApplePayPaymentRequest { billingContact: StripeApplePayPaymentContact; countryCode: string; currencyCode: string; @@ -132,30 +127,26 @@ interface StripeApplePayPaymentRequest } // https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types -interface StripeApplePayLineItem -{ +interface StripeApplePayLineItem { type: 'pending' | 'final'; label: string; amount: number; } -interface StripeApplePaySessionResult -{ +interface StripeApplePaySessionResult { token: StripeTokenResponse; shippingContact?: StripeApplePayPaymentContact; shippingMethod?: StripeApplePayShippingMethod; } -interface StripeApplePayShippingMethod -{ +interface StripeApplePayShippingMethod { label: string; detail: string; amount: number; identifier: string; } -interface StripeApplePayPaymentContact -{ +interface StripeApplePayPaymentContact { emailAddress: string; phoneNumber: string; givenName: string; @@ -166,3 +157,7 @@ interface StripeApplePayPaymentContact postalCode: string; countryCode: string; } + +// The Stripe client side APIs are not made available to package managers for direct installation. +// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only +// A release date versioning schema is used to version these APIs. diff --git a/stripe/stripe-tests.ts b/stripe/stripe-tests.ts new file mode 100644 index 0000000000..44aa09d216 --- /dev/null +++ b/stripe/stripe-tests.ts @@ -0,0 +1,25 @@ +function success(card: StripeCardData) { + console.log(card.brand && card.brand.toString()); +} + +const cardNumber = '4242424242424242'; + +const isValid = Stripe.validateCardNumber(cardNumber); +if (isValid) { + const tokenData: StripeTokenData = { + number: cardNumber, + exp_month: 1, + exp_year: 2100, + cvc: '111' + }; + Stripe.card.createToken(tokenData, (status, response) => { + if (response.error) { + console.error(response.error.message); + if (response.error.param) { + console.error(response.error.param); + } + } else { + success(response.card); + } + }); +} diff --git a/stripe/tsconfig.json b/stripe/tsconfig.json index cdcaca971c..7c33ab65c5 100644 --- a/stripe/tsconfig.json +++ b/stripe/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -14,6 +14,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "stripe-tests.ts" ] -} \ No newline at end of file +} diff --git a/stripe/tslint.json b/stripe/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/stripe/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From a0951d1210f5710119030c92d424fa2433380389 Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Thu, 5 Jan 2017 15:33:14 -0500 Subject: [PATCH 114/181] d3-ease: * [Fix]: Added interfaces and changed definitions for three classes of easing functions, which can be parameterized. Fixes #13767. * [Enhancement]: Activated `strictNullChecks` after validation * [Chore]: Added JSDoc comments * [Chore]: Added linting config file. --- d3-ease/d3-ease-tests.ts | 71 ++++++++-- d3-ease/index.d.ts | 296 +++++++++++++++++++++++++++++++++++++-- d3-ease/tsconfig.json | 4 +- d3-ease/tslint.json | 3 + 4 files changed, 345 insertions(+), 29 deletions(-) create mode 100644 d3-ease/tslint.json diff --git a/d3-ease/d3-ease-tests.ts b/d3-ease/d3-ease-tests.ts index cad8b0013b..84e34aa064 100644 --- a/d3-ease/d3-ease-tests.ts +++ b/d3-ease/d3-ease-tests.ts @@ -8,7 +8,8 @@ import * as d3Ease from 'd3-ease'; -let t_in: number, t_out: number; +let t_in: number = 0.5; +let t_out: number; t_out = d3Ease.easeLinear(t_in); @@ -22,10 +23,24 @@ t_out = d3Ease.easeCubicIn(t_in); t_out = d3Ease.easeCubicOut(t_in); t_out = d3Ease.easeCubicInOut(t_in); -t_out = d3Ease.easePoly(t_in); -t_out = d3Ease.easePolyIn(t_in); -t_out = d3Ease.easePolyOut(t_in); -t_out = d3Ease.easePolyInOut(t_in); + +let easePolyFactory: d3Ease.PolynomialEasingFactory; + +easePolyFactory = d3Ease.easePoly; +easePolyFactory = d3Ease.easePoly.exponent(2); +t_out = easePolyFactory(t_in); + +easePolyFactory = d3Ease.easePolyIn; +easePolyFactory = d3Ease.easePolyIn.exponent(2); +t_out = easePolyFactory(t_in); + +easePolyFactory = d3Ease.easePolyOut; +easePolyFactory = d3Ease.easePolyOut.exponent(2); +t_out = easePolyFactory(t_in); + +easePolyFactory = d3Ease.easePolyInOut; +easePolyFactory = d3Ease.easePolyInOut.exponent(2); +t_out = easePolyFactory(t_in); t_out = d3Ease.easeSin(t_in); t_out = d3Ease.easeSinIn(t_in); @@ -47,12 +62,42 @@ t_out = d3Ease.easeBounceIn(t_in); t_out = d3Ease.easeBounceOut(t_in); t_out = d3Ease.easeBounceInOut(t_in); -t_out = d3Ease.easeBack(t_in); -t_out = d3Ease.easeBackIn(t_in); -t_out = d3Ease.easeBackOut(t_in); -t_out = d3Ease.easeBackInOut(t_in); +let easeBackFactory: d3Ease.BackEasingFactory; -t_out = d3Ease.easeElastic(t_in); -t_out = d3Ease.easeElasticIn(t_in); -t_out = d3Ease.easeElasticOut(t_in); -t_out = d3Ease.easeElasticInOut(t_in); +easeBackFactory = d3Ease.easeBack; +easeBackFactory = d3Ease.easeBack.overshoot(2); +t_out = easeBackFactory(t_in); + +easeBackFactory = d3Ease.easeBackIn; +easeBackFactory = d3Ease.easeBackIn.overshoot(2); +t_out = easeBackFactory(t_in); + +easeBackFactory = d3Ease.easeBackOut; +easeBackFactory = d3Ease.easeBackOut.overshoot(2); +t_out = easeBackFactory(t_in); + +easeBackFactory = d3Ease.easeBackInOut; +easeBackFactory = d3Ease.easeBackInOut.overshoot(2); +t_out = easeBackFactory(t_in); + +let easeElasticFactory: d3Ease.ElasticEasingFactory; + +easeElasticFactory = d3Ease.easeElastic; +easeElasticFactory = d3Ease.easeElastic.amplitude(1.5); +easeElasticFactory = d3Ease.easeElastic.period(0.4); +t_out = easeElasticFactory(t_in); + +easeElasticFactory = d3Ease.easeElasticIn; +easeElasticFactory = d3Ease.easeElasticIn.amplitude(1.5); +easeElasticFactory = d3Ease.easeElasticIn.period(0.4); +t_out = easeElasticFactory(t_in); + +easeElasticFactory = d3Ease.easeElasticOut; +easeElasticFactory = d3Ease.easeElasticOut.amplitude(1.5); +easeElasticFactory = d3Ease.easeElasticOut.period(0.4); +t_out = easeElasticFactory(t_in); + +easeElasticFactory = d3Ease.easeElasticInOut; +easeElasticFactory = d3Ease.easeElasticInOut.amplitude(1.5); +easeElasticFactory = d3Ease.easeElasticInOut.period(0.4); +t_out = easeElasticFactory(t_in); diff --git a/d3-ease/index.d.ts b/d3-ease/index.d.ts index c1138145d5..704b55e5e0 100644 --- a/d3-ease/index.d.ts +++ b/d3-ease/index.d.ts @@ -1,56 +1,324 @@ -// Type definitions for D3JS d3-ease module v1.0.1 +// Type definitions for D3JS d3-ease module 1.0 // Project: https://github.com/d3/d3-ease/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Last module patch version validated against: 1.0.1 + // -------------------------------------------------------------------------- // Easing Functions // -------------------------------------------------------------------------- - +/** + * Linear easing; the identity function; linear(t) returns t. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeLinear(normalizedTime: number): number; +/** + * Symmetric quadratic easing; scales quadIn for t in [0, 0.5] and quadOut for t in [0.5, 1]. Also equivalent to poly.exponent(2). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeQuad(normalizedTime: number): number; + +/** + * Quadratic easing; equivalent to polyIn.exponent(2). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeQuadIn(normalizedTime: number): number; + +/** + * Reverse quadratic easing; equivalent to 1 - quadIn(1 - t). Also equivalent to polyOut.exponent(2). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeQuadOut(normalizedTime: number): number; + +/** + * Symmetric quadratic easing; scales quadIn for t in [0, 0.5] and quadOut for t in [0.5, 1]. Also equivalent to poly.exponent(2). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeQuadInOut(normalizedTime: number): number; +/** + * Symmetric cubic easing; scales cubicIn for t in [0, 0.5] and cubicOut for t in [0.5, 1]. Also equivalent to poly.exponent(3). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCubic(normalizedTime: number): number; + +/** + * Cubic easing; equivalent to polyIn.exponent(3). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCubicIn(normalizedTime: number): number; + +/** + * Reverse cubic easing; equivalent to 1 - cubicIn(1 - t). Also equivalent to polyOut.exponent(3). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCubicOut(normalizedTime: number): number; + +/** + * Symmetric cubic easing; scales cubicIn for t in [0, 0.5] and cubicOut for t in [0.5, 1]. Also equivalent to poly.exponent(3). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCubicInOut(normalizedTime: number): number; -export function easePoly(normalizedTime: number): number; -export function easePolyIn(normalizedTime: number): number; -export function easePolyOut(normalizedTime: number): number; -export function easePolyInOut(normalizedTime: number): number; +/** + * Polynomial easing function factory + */ +export interface PolynomialEasingFactory { + /** + * Calculate eased time. + * @param normalizedTime Normalized time typically in the range [0, 1] + */ + (normalizedTime: number): number; + /** + * Returns a new polynomial easing with the specified exponent e. + * If the exponent is not specified, it defaults to 3, equivalent to cubic. + * + * @param e Exponent for polynomial easing. + */ + exponent(e: number): PolynomialEasingFactory; +} +/** + * Symmetric polynomial easing/easing factory; scales polyIn for t in [0, 0.5] and polyOut for t in [0.5, 1]. + * If the exponent is not specified, it defaults to 3, equivalent to cubic. + */ +export var easePoly: PolynomialEasingFactory; +/** + * Polynomial easing/easing factory; raises t to the specified exponent. + * If the exponent is not specified, it defaults to 3, equivalent to cubicIn. + */ +export var easePolyIn: PolynomialEasingFactory; + +/** + * Reverse polynomial easing/easing factory; equivalent to 1 - polyIn(1 - t). + * If the exponent is not specified, it defaults to 3, equivalent to cubicOut. + */ +export var easePolyOut: PolynomialEasingFactory; + +/** + * Symmetric polynomial easing/easing factory; scales polyIn for t in [0, 0.5] and polyOut for t in [0.5, 1]. + * If the exponent is not specified, it defaults to 3, equivalent to cubic. + */ +export var easePolyInOut: PolynomialEasingFactory; + + +/** + * Symmetric sinusoidal easing; scales sinIn for t in [0, 0.5] and sinOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeSin(normalizedTime: number): number; + +/** + * Sinusoidal easing; returns sin(t). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeSinIn(normalizedTime: number): number; + +/** + * Reverse sinusoidal easing; equivalent to 1 - sinIn(1 - t). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeSinOut(normalizedTime: number): number; + +/** + * Symmetric sinusoidal easing; scales sinIn for t in [0, 0.5] and sinOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeSinInOut(normalizedTime: number): number; +/** + * Symmetric exponential easing; scales expIn for t in [0, 0.5] and expOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeExp(normalizedTime: number): number; + +/** + * Exponential easing; raises 2 to the exponent 10 * (t - 1). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeExpIn(normalizedTime: number): number; + +/** + * Reverse exponential easing; equivalent to 1 - expIn(1 - t). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeExpOut(normalizedTime: number): number; + +/** + * Symmetric exponential easing; scales expIn for t in [0, 0.5] and expOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeExpInOut(normalizedTime: number): number; +/** + * Symmetric circular easing; scales circleIn for t in [0, 0.5] and circleOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCircle(normalizedTime: number): number; + +/** + * Circular easing. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCircleIn(normalizedTime: number): number; + +/** + * Reverse circular easing; equivalent to 1 - circleIn(1 - t). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCircleOut(normalizedTime: number): number; + +/** + * Symmetric circular easing; scales circleIn for t in [0, 0.5] and circleOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeCircleInOut(normalizedTime: number): number; +/** + * Reverse bounce easing; equivalent to 1 - bounceIn(1 - t). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeBounce(normalizedTime: number): number; + +/** + * Bounce easing, like a rubber ball. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeBounceIn(normalizedTime: number): number; + +/** + * Reverse bounce easing; equivalent to 1 - bounceIn(1 - t). + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeBounceOut(normalizedTime: number): number; + +/** + * Symmetric bounce easing; scales bounceIn for t in [0, 0.5] and bounceOut for t in [0.5, 1]. + * + * @param normalizedTime Normalized time typically in the range [0, 1] + */ export function easeBounceInOut(normalizedTime: number): number; -export function easeBack(normalizedTime: number): number; -export function easeBackIn(normalizedTime: number): number; -export function easeBackOut(normalizedTime: number): number; -export function easeBackInOut(normalizedTime: number): number; -export function easeElastic(normalizedTime: number): number; -export function easeElasticIn(normalizedTime: number): number; -export function easeElasticOut(normalizedTime: number): number; -export function easeElasticInOut(normalizedTime: number): number; +/** + * Anticipatory easing function factory + */ +export interface BackEasingFactory { + /** + * Calculate eased time. + * @param normalizedTime Normalized time typically in the range [0, 1] + */ + (normalizedTime: number): number; + /** + * Returns a new back easing with the specified overshoot s. + * The degree of overshoot is configurable; if not specified, it defaults to 1.70158. + * + * @param s Overshoot parameter + */ + overshoot(s: number): BackEasingFactory; +} + +/** + * Symmetric anticipatory easing; scales backIn for t in [0, 0.5] and backOut for t in [0.5, 1]. + * The degree of overshoot is configurable; it not specified, it defaults to 1.70158. + */ +export var easeBack: BackEasingFactory; + +/** + * Anticipatory easing, like a dancer bending his knees before jumping off the floor. + * The degree of overshoot is configurable; it not specified, it defaults to 1.70158. + */ +export var easeBackIn: BackEasingFactory; + +/** + * Reverse anticipatory easing; equivalent to 1 - backIn(1 - t). + * The degree of overshoot is configurable; it not specified, it defaults to 1.70158. + */ +export var easeBackOut: BackEasingFactory; + +/** + * Symmetric anticipatory easing; scales backIn for t in [0, 0.5] and backOut for t in [0.5, 1]. + * The degree of overshoot is configurable; it not specified, it defaults to 1.70158. + */ +export var easeBackInOut: BackEasingFactory; + + +/** + * Elastic easing function factory + */ +export interface ElasticEasingFactory { + /** + * Calculate eased time. + * @param normalizedTime Normalized time typically in the range [0, 1] + */ + (normalizedTime: number): number; + /** + * Returns a new elastic easing with the specified amplitude a. + * Defaults to 1,if not specified. + * + * @param a Amplitude for elastic easing. + */ + amplitude(a: number): ElasticEasingFactory; + /** + * Returns a new elastic easing with the specified amplitude a. + * Defaults to 0.3,if not specified. + * + * @param p Period for elastic easing. + */ + period(p: number): ElasticEasingFactory; +} + +/** + * Reverse elastic easing; equivalent to 1 - elasticIn(1 - t). + * The amplitude and period of the oscillation are configurable; + * if not specified, they default to 1 and 0.3, respectively. + */ +export var easeElastic: ElasticEasingFactory; + +/** + * Elastic easing, like a rubber band. + * The amplitude and period of the oscillation are configurable; + * if not specified, they default to 1 and 0.3, respectively. + */ +export var easeElasticIn: ElasticEasingFactory; + +/** + * Reverse elastic easing; equivalent to 1 - elasticIn(1 - t). + * The amplitude and period of the oscillation are configurable; + * if not specified, they default to 1 and 0.3, respectively. + */ +export var easeElasticOut: ElasticEasingFactory; + +/** + * Symmetric elastic easing; scales elasticIn for t in [0, 0.5] and elasticOut for t in [0.5, 1]. + * The amplitude and period of the oscillation are configurable; + * if not specified, they default to 1 and 0.3, respectively. + */ +export var easeElasticInOut: ElasticEasingFactory; diff --git a/d3-ease/tsconfig.json b/d3-ease/tsconfig.json index dc6c989229..286fd42f7f 100644 --- a/d3-ease/tsconfig.json +++ b/d3-ease/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -17,4 +17,4 @@ "index.d.ts", "d3-ease-tests.ts" ] -} \ No newline at end of file +} diff --git a/d3-ease/tslint.json b/d3-ease/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/d3-ease/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From f2d8c8ac18ab1153e7da137cd6a08ab18a1ff761 Mon Sep 17 00:00:00 2001 From: Bradford Wagner Date: Thu, 5 Jan 2017 15:37:43 -0500 Subject: [PATCH 115/181] Feature/fine uploader (#13768) * Adding FineUploader typings * noImplicitThis true * adding tslint.json * tslint.json -> tslint * fixing some lintings * fixing lintings * removing version * added typescript version * defaults that are null/undefined now are | null/undefined respectively * removed minor version from fineuploader definition, removed typescript 2 version --- fine-uploader/index.d.ts | 336 +++++++++++++++++++++++++++++ fine-uploader/test/blobs.ts | 11 + fine-uploader/test/callbacks.ts | 61 ++++++ fine-uploader/test/camera.ts | 16 ++ fine-uploader/test/chunking.ts | 28 +++ fine-uploader/test/core.ts | 19 ++ fine-uploader/test/cors.ts | 15 ++ fine-uploader/test/deleteFile.ts | 30 +++ fine-uploader/test/extraButtons.ts | 25 +++ fine-uploader/test/form.ts | 15 ++ fine-uploader/test/message.ts | 23 ++ fine-uploader/test/method.ts | 142 ++++++++++++ fine-uploader/test/paste.ts | 16 ++ fine-uploader/test/request.ts | 34 +++ fine-uploader/test/resume.ts | 17 ++ fine-uploader/test/retry.ts | 17 ++ fine-uploader/test/scaling.ts | 31 +++ fine-uploader/test/session.ts | 28 +++ fine-uploader/test/text.ts | 15 ++ fine-uploader/test/validation.ts | 24 +++ fine-uploader/test/workarounds.ts | 15 ++ fine-uploader/tsconfig.json | 39 ++++ fine-uploader/tslint.json | 1 + 23 files changed, 958 insertions(+) create mode 100644 fine-uploader/index.d.ts create mode 100644 fine-uploader/test/blobs.ts create mode 100644 fine-uploader/test/callbacks.ts create mode 100644 fine-uploader/test/camera.ts create mode 100644 fine-uploader/test/chunking.ts create mode 100644 fine-uploader/test/core.ts create mode 100644 fine-uploader/test/cors.ts create mode 100644 fine-uploader/test/deleteFile.ts create mode 100644 fine-uploader/test/extraButtons.ts create mode 100644 fine-uploader/test/form.ts create mode 100644 fine-uploader/test/message.ts create mode 100644 fine-uploader/test/method.ts create mode 100644 fine-uploader/test/paste.ts create mode 100644 fine-uploader/test/request.ts create mode 100644 fine-uploader/test/resume.ts create mode 100644 fine-uploader/test/retry.ts create mode 100644 fine-uploader/test/scaling.ts create mode 100644 fine-uploader/test/session.ts create mode 100644 fine-uploader/test/text.ts create mode 100644 fine-uploader/test/validation.ts create mode 100644 fine-uploader/test/workarounds.ts create mode 100644 fine-uploader/tsconfig.json create mode 100644 fine-uploader/tslint.json diff --git a/fine-uploader/index.d.ts b/fine-uploader/index.d.ts new file mode 100644 index 0000000000..b888708d97 --- /dev/null +++ b/fine-uploader/index.d.ts @@ -0,0 +1,336 @@ +// Type definitions for FineUploader for 5.11 +// Project: http://fineuploader.com/ +// Definitions by: Bradford Wagner +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace qq { + interface BlobsOptions { + defaultName?: string; + } + + interface CameraOptions { + button?: HTMLElement; + ios?: boolean; + } + + interface ChunkingOptions { + concurrent?: ChunkingConcurrentOptions; + enabled?: boolean; // default false + mandatory?: boolean; // default false + partSize?: number; // default 2,000,000 + paramNames?: ChunkingParamNames; + success?: ChunkingSuccess; + } + + interface ChunkingConcurrentOptions { + enabled?: boolean; // default false + } + + interface ChunkingParamNames { + chunkSize?: string; // default: qqchunksize + partByteOffset?: string; // default: qqpartbyteoffset + partIndex?: string; // default: qqpartindex + totalParts?: string; // default: qqtotalparts + } + + interface ChunkingSuccess { + endpoint?: string | null; // default: null + } + + interface CorsOptions { + allowXdr?: boolean; // default: false + expected?: boolean; // default: false + sendCredentials: boolean; // default: false + } + + interface DeleteFileOptions { + customHeader?: H; // default: {} + enabled?: boolean; // default false + endpoint?: string; // default: /server/upload + method?: string; // default: DELETE + params?: P; // default: {} + } + + interface ExtraButtonsOptions { + element: HTMLElement | undefined; // default: undefined + fileInputTitle?: string; // default: file input + folders?: boolean; // default: false + multiple?: boolean; // default: true + validation?: V; // default: 'validation' + } + + interface FormOptions { + element?: string | HTMLElement; // default: qq-form + autoUpload?: boolean; // default: false + interceptSubmit?: boolean; // default: true + } + + interface MessagesOptions { + emptyError?: string; // default: {file} is empty, please select files again without it. + maxHeightImageError?: string; // default: Image is too tall. + maxWidthImageError?: string; // default: Image is too wide. + minHeightImageError?: string; // default: Image is not tall enough. + minWidthImageError?: string; // default: Image is not wide enough. + minSizeError?: string; // default: {file} is too small, minimum file size is {minSizeLimit}. + noFilesError?: string; // default: No files to upload. + onLeave?: string; // default: The files are being uploaded, if you leave now the upload will be canceled. + retryFailTooManyItemsError?: string; // default: Too many items ({netItems}) would be uploaded. Item limit is {itemLimit}. + typeError?: string; // default: {file} has an invalid extension. Valid extension(s): {extensions}. + unsupportedBrowserIos8Safari?: string; // default: Unrecoverable error - this browser does not permit file uploading of any kind due to serious bugs in iOS8 Safari. Please use iOS8 Chrome until Apple fixes these issues. + } + + interface PasteOptions { + defaultName?: string; // default: pasted_image + targetElement?: HTMLElement | null; // default: null + } + + interface ResumeOptions { + recordsExpireIn?: number; // default: 7 + enabled?: boolean; // default: false + paramNames?: ResumeParamNameOptions; + } + + interface ResumeParamNameOptions { + resuming: string; // default: qqresume + } + + interface RetryOptions { + autoAttemptDelay?: number; // default: 5 + enableAuto?: boolean; // default: false + maxAutoAttempts?: number; // default: 3 + preventRetryResponseProperty?: string; // default: preventRetry + } + + interface RequestOptions { + customHeaders?: H; // default: {} + endpoint?: string; // default: /server/upload + filenameParam?: string; // default: qqfilename + forceMultipart?: boolean; // default: true + inputName?: string; // default: qqfile + method?: string; // default: POST + params?: P; // default: {} + paramsInBody?: boolean; // default: true + uuid?: string; // default: qquuid + totalFileSizeName?: string; // default: qqtotalfilesize + } + + interface ScalingOptions { + customResizer?: (blob: File | Blob, height: number, image: HTMLImageElement, sourceCanvas: HTMLCanvasElement, targetCanvas: HTMLCanvasElement, width: number) => Promise | undefined; // default: undefined + defaultQuality?: number; // default: 80 + defaultType?: string | null; // default: null + failureText?: string; // default: Failed to scale + includeExif?: boolean; // default: false + orient?: boolean; // default: true + sendOriginal?: boolean; // default: false + sizes?: Size[]; // default: [] + } + + /** + * From Documentation: + * An array containing size objects that describe scaled versions of each submitted image that should be generated and uploaded. A size object should usually contain a name String property (which will be appended to the file name of the scaled file), and must always contain a maxSize integer property. A type MIME string property is optional. + */ + interface Size { + name: string; + maxSize: number; + type?: string; + } + + interface SessionOptions { + customHeaders?: H; // default: {} + endpoint?: string | null; // default: null + params?: P; // default: {} + refreshOnReset?: boolean; // default: true + } + + interface TextOptions { + defaultResponseError?: string; // default: Upload failure reason unknown + fileInputTitle?: string; // default: file input + sizeSymbols?: string[]; // default: ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'] + } + + interface ValidationOptions { + acceptFiles?: MimeType[] | null; // default: null + allowExtensions?: string[]; // default: [] + itemLimit?: number; // default: 0 + minSizeLimit?: number; // default: 0 + sizeLimit?: number; // default: 0 + stopOnFirstInvalidFile: boolean; // default: true + image?: ValidationImageOptions; + } + + interface ValidationImageOptions { + maxHeight?: number; // default: 0 + maxWidth?: number; // default: 0 + minWidth?: number; // default: 0 + minHeight?: number; // default: 0 + } + + interface WorkaroundOptions { + iosEmptyVideos?: boolean; // default: true + ios8BrowserCrash?: boolean; // default: false + ios8SafariUploads?: boolean; // default: true + } + + interface ChunkData { + partIndex: number; + startByte: number; + endByte: number; + totalParts: number; + } + + interface ValidateMetadata { + name: string; + size?: number; + } + + interface CallbackOptions { + onAutoRetry?: (id: number, name: string, attemptNumber: number) => void; + onCancel?: (id: number, name: string) => void; + onComplete?: (id: number, name: string, responseJSON: T, xhr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript + onAllComplete?: (succeeded: number[], failed: number[]) => void; + onDelete?: (id: number) => void; + onDeleteComplete?: (id: number, xhr: XMLHttpRequest, isError: boolean) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript + onError?: (id: number, name: string, errorReason: string, xhr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript + onManualRetry?: (id: number, name: string) => boolean; // return false to prevent this and all future retries + onPasteReceived?: (blob: Blob) => void; + onProgress?: (id: number, name: string, uploadedBytes: number, totalBytes: number) => void; + onResume?: (id: number, name: string, chunkData: T) => void; + onSessionRequestComplete?: (response: T[], success: boolean, xhrOrXdr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript + onStatusChange?: (id: number, oldStatus: string, newStatus: string) => void; + onSubmit?: (id: number, name: string) => void; + onSubmitDelete?: (id: number) => void; + onSubmitted?: (id: number, name: string) => void; + onTotalProgress?: (totalUploadedBytes: number, totalBytes: number) => void; + onUpload?: (id: number, name: string) => void; + onUploadChunk?: (id: number, name: string, chunkData: ChunkData) => void; + onUploadChunkSuccess?: (id: number, chunkData: ChunkData, responseJSON: T, xhr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript + onValidate?: (data: ValidateMetadata, buttonContainer: HTMLElement) => void; + onValidateBatch?: (fileOrBlobDataArray: ValidateMetadata[], buttomContainer: HTMLElement) => void; + } + + interface BasicOptions { + // core options + autoUpload?: boolean; // default true + button?: HTMLElement; + debug?: boolean; + disableCancelForFormUploads?: boolean; + formatFileName?: (rawFileName: string) => string; // rawFilename to display filename + maxConnections?: number; + multiple?: boolean; + + blobs?: BlobsOptions; + camera?: CameraOptions; + chunking?: ChunkingOptions; + cors?: CorsOptions; + deleteFile?: DeleteFileOptions; + extraButtons?: ExtraButtonsOptions; + form?: FormOptions; + messages?: MessagesOptions; + paste?: PasteOptions; + resume?: ResumeOptions; + retry?: RetryOptions; + request?: RequestOptions; + scaling?: ScalingOptions; + session?: SessionOptions; + text?: TextOptions; + validation?: ValidationOptions; + workarounds?: WorkaroundOptions; + + callbacks?: CallbackOptions; + } + + interface BlobWrapper { + blob: Blob; + name: string; + } + + interface CanvasWrapper { + canvas: HTMLCanvasElement; + name: string; + quality: number; // 1-100 + type: MimeType; + } + + interface ResizeInfo { + blob: File | Blob; + height: number; + image: HTMLImageElement; + sourceCanvas: HTMLCanvasElement; + targetCanvas: HTMLCanvasElement; + width: number; + } + + interface ResumableItem { + name: string; + uuid: string; + partIdx: number; + } + + interface FilterOption { + id?: number; + uuid?: string; + originalName?: string; + name?: string; + status?: string; + size?: number; + } + + interface ScaleImageOptions { + maxSize: number; + orient?: boolean; // default: true + type?: string; // default: type or reference image + quality?: number; // 0-100 - default: 80 + includeExif?: boolean; // default: false + customResizer?: (resizeInfo: ResizeInfo) => Promise; + } + + class FineUploaderBasic { + constructor(options: BasicOptions) + + addFiles(files: File[] | HTMLInputElement[] | Blob[] | BlobWrapper[] | HTMLCanvasElement[] | CanvasWrapper[] | FileList, params: T, endpoint: string): void; + addInitialFiles(initialFiles: T[]): void; + cancel(id: number): void; + cancelAll(): void; + clearStoredFiles(): void; + continueUpload(id: number): boolean; // true if successful + deleteFile(id: number): void; + + /** + * TODO: need someone who has used this to update the returned promise related fields + */ + drawThumbnail(id: number, targetContainer: HTMLElement, maxSize: number, fromServer: boolean, customResizer: (resizeInfo: ResizeInfo) => Promise): Promise + getButton(id: number): HTMLElement; + getFile(id: number): File | Blob; + getInProgress(): number; + getName(id: number): string; + getParentId(scaledFileId: number): number; + getRemainingAllowedItems(): number; + getResumableFilesData(): ResumableItem[]; + getSize(id: number): number; + getUploads(filter: FilterOption): T | T[]; + getUuid(id: number): string; + log(message: string, level: string): void; + pauseUpload(id: number): boolean; // true if successful + reset(): void; + retry(id: number): void; + scaleImage(id: number, options: ScaleImageOptions): Promise; + setCustomHeaders(customHeaders: H, id: number): void; + setEndpoint(path: string, identifier: number | HTMLElement): void; + setDeleteFileCustomHeaders(customHeaders: H, id: number): void; + setDeleteFileEndpoint(path: string, identifier: number | HTMLElement): void; + setDeleteFileParams

(params: P, id: number): void; + setItemLimit(newItemLimit: number): void; + setForm(formElementOrId: HTMLFormElement | string): void; + setName(id: number, name: string): void; + setParams

(params: P, id: number): void; + setUuid(id: number, uuid: string): void; + uploadStoredFiles(): void; // throws NoFilesError + + // ui + addExtraDropzone(element: HTMLElement): void; + getDropTarget(id: number): HTMLElement; + getId(element: HTMLElement): number; + getItemByFileId(id: number): HTMLElement; + removeExtraDropzone(element: HTMLElement): void; + } +} diff --git a/fine-uploader/test/blobs.ts b/fine-uploader/test/blobs.ts new file mode 100644 index 0000000000..a8f3ab3370 --- /dev/null +++ b/fine-uploader/test/blobs.ts @@ -0,0 +1,11 @@ +/// + +function testBlob() { + let config: qq.BasicOptions = { + blobs: { + defaultName: "hi.png" + } + }; + + let uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/callbacks.ts b/fine-uploader/test/callbacks.ts new file mode 100644 index 0000000000..273f792dd9 --- /dev/null +++ b/fine-uploader/test/callbacks.ts @@ -0,0 +1,61 @@ +/// + +class CallbacksTest { + constructor(private opts: qq.CallbackOptions) { + + } + + testCallbacks() { + let opts = this.opts; + + type CustomType = { + myTypeOfClass: string; + }; + + opts.onAutoRetry = (id, name, attemptNumber) => {}; + + opts.onCancel = (id, name) => {}; + + opts.onComplete = (id: number, name: string, responseJSON: CustomType, xhr: XMLHttpRequest) => {}; + + opts.onAllComplete = (succeeded, failed) => {}; + + opts.onDelete = (id) => {}; + + opts.onDeleteComplete = (id, xhr, isError) => {}; + + opts.onError = (id, name, errorReason, xhr) => {}; + + opts.onManualRetry = (id, name) => { + return true; + }; + + opts.onPasteReceived = (blob) => {}; + + opts.onProgress = (id, name, uploadedBytes, totalBytes) => {}; + + opts.onResume = (id: number, name: string, chunkData: CustomType) => {}; + + opts.onSessionRequestComplete = (response: CustomType[], success: boolean, xhrOrXdr: XMLHttpRequest) => {}; + + opts.onStatusChange = (id, oldStatus, newStatus) => {}; + + opts.onSubmit = (id, name) => {}; + + opts.onSubmitDelete = (id) => {}; + + opts.onSubmitted = (id, name) => {}; + + opts.onTotalProgress = (totalUploadedBytes, totalBytes) => {}; + + opts.onUpload = (id, name) => {}; + + opts.onUploadChunk = (id, name, chunkData) => {}; + + opts.onUploadChunkSuccess = (id: number, chunkData: qq.ChunkData, responseJSON: CustomType, xhr: XMLHttpRequest) => {}; + + opts.onValidate = (data, buttonContainer) => {}; + + opts.onValidateBatch = (fileOrBlobDataArray, buttonContaine) => {}; + } +} diff --git a/fine-uploader/test/camera.ts b/fine-uploader/test/camera.ts new file mode 100644 index 0000000000..0186080032 --- /dev/null +++ b/fine-uploader/test/camera.ts @@ -0,0 +1,16 @@ +/// + +function cameraTest() { + const cameraButton = new HTMLButtonElement(); + + const cameraOptions: qq.CameraOptions = { + button: cameraButton, + ios: false + } + + const config: qq.BasicOptions = { + camera: cameraOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/chunking.ts b/fine-uploader/test/chunking.ts new file mode 100644 index 0000000000..4c914f029a --- /dev/null +++ b/fine-uploader/test/chunking.ts @@ -0,0 +1,28 @@ +/// + +function chunkingTest() { + + const chunkingOptions: qq.ChunkingOptions = { + concurrent: { + enabled: false + }, + enabled: true, + mandatory: true, + partSize: 1000000, + paramNames: { + chunkSize: "chunkSize", + partByteOffset: "partByteOffset", + partIndex: "partIndex", + totalParts: "totalParts" + }, + success: { + endpoint: "/some/web/endpoint/yaySuccesss" + } + }; + + const config: qq.BasicOptions = { + chunking: chunkingOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/core.ts b/fine-uploader/test/core.ts new file mode 100644 index 0000000000..a91a5b157d --- /dev/null +++ b/fine-uploader/test/core.ts @@ -0,0 +1,19 @@ +/// + +function testCore() { + let button: HTMLElement = new HTMLButtonElement() + + let config: qq.BasicOptions = { + autoUpload: true, + button: button, + debug: true, + disableCancelForFormUploads: true, + formatFileName: (rawFileName: string) => { + return "hi"; + }, + maxConnections: 10, + multiple: true + }; + + let uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/cors.ts b/fine-uploader/test/cors.ts new file mode 100644 index 0000000000..d0abddff37 --- /dev/null +++ b/fine-uploader/test/cors.ts @@ -0,0 +1,15 @@ +/// + +function corsTest() { + const corsOptions: qq.CorsOptions = { + allowXdr: true, + expected: true, + sendCredentials: true + } + + const config: qq.BasicOptions = { + cors: corsOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/deleteFile.ts b/fine-uploader/test/deleteFile.ts new file mode 100644 index 0000000000..7372f1135f --- /dev/null +++ b/fine-uploader/test/deleteFile.ts @@ -0,0 +1,30 @@ +/// + +function deleteFileTest() { + interface CustomHeader { + myOption: string; + } + + interface CustomParams { + myParam: string; + } + + let deleteFileOptions: qq.DeleteFileOptions = { + customHeader: { + myOption: "ewwww" + }, + enabled: true, + endpoint: "/my/server/location/delete", + method: "POST", + params: { + myParam: "u" + } + }; + + + let config: qq.BasicOptions = { + deleteFile: deleteFileOptions + }; + + let uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/extraButtons.ts b/fine-uploader/test/extraButtons.ts new file mode 100644 index 0000000000..abc2194c30 --- /dev/null +++ b/fine-uploader/test/extraButtons.ts @@ -0,0 +1,25 @@ +/// + +function extraButtons() { + type Validation = { + myValue: string + }; + + let element: HTMLElement = new HTMLElement(); + + let extraButtonOptions: qq.ExtraButtonsOptions = { + element: element, + fileInputTitle: "inputTitle", + folders: true, + multiple: false, + validation: { + myValue: "ew" + } + }; + + let config: qq.BasicOptions = { + extraButtons: extraButtonOptions + }; + + let uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/form.ts b/fine-uploader/test/form.ts new file mode 100644 index 0000000000..d280de7a03 --- /dev/null +++ b/fine-uploader/test/form.ts @@ -0,0 +1,15 @@ +/// + +function formTest() { + let formOptions: qq.FormOptions = { + element: "qq-form", + autoUpload: true, + interceptSubmit: true + }; + + let config: qq.BasicOptions = { + form: formOptions + }; + + let uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/message.ts b/fine-uploader/test/message.ts new file mode 100644 index 0000000000..fa3d11adb6 --- /dev/null +++ b/fine-uploader/test/message.ts @@ -0,0 +1,23 @@ +/// + +function messageTest() { + let messageOptions: qq.MessagesOptions = { + emptyError: "emptyError", + maxHeightImageError: "maxHeightImageError", + maxWidthImageError: "error occurred", + minHeightImageError: "error occurred", + minWidthImageError: "error occurred", + minSizeError: "error occurred", + noFilesError: "error occurred", + onLeave: "error occurred", + retryFailTooManyItemsError: "error occurred", + typeError: "error occurred", + unsupportedBrowserIos8Safari: "error occurred" + }; + + let config: qq.BasicOptions = { + messages: messageOptions + }; + + let uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/method.ts b/fine-uploader/test/method.ts new file mode 100644 index 0000000000..27e5144aa0 --- /dev/null +++ b/fine-uploader/test/method.ts @@ -0,0 +1,142 @@ +/// + +class TestMethods { + constructor(private uploader: qq.FineUploaderBasic) { + } + + testAddFiles() { + type ParamType = { + field: string; + }; + + const params: ParamType = { + field: 'hiiiii' + }; + + this.uploader.addFiles( + new FileList(), + params, + "/my/happy/endpoint" + ); + } + + testAddInitialFiles() { + type InitialFiles = { + myField: number; + }; + + const initialFiles: InitialFiles[] = [{ + myField: 1324 + }]; + + this.uploader.addInitialFiles(initialFiles); + } + + testDrawThumbnail() { + const promise: Promise = this.uploader.drawThumbnail( + 1234, + new HTMLElement(), + 1234565, + false, + (resizeInfo) => { + return new Promise(() => { + return new Blob(); + }); + } + ) + } + + testGetUploads() { + type ResponseType = { + hi: string; + } + let response: ResponseType | ResponseType[] = this.uploader.getUploads({ + status: "proggresssssssesees" + }); + } + + testSetCustomHeaders() { + type CustomHeader = { + customField: number + }; + + this.uploader.setCustomHeaders({ + customField: 1234 + }, 1234); + } + + testSetDeleteCustomHeaders() { + type CustomHeader = { + customField: number + }; + + this.uploader.setDeleteFileCustomHeaders({ + customField: 1234 + }, 1234); + } + + testSetDeleteFileParams() { + type CustomParams = { + paramField: boolean; + } + this.uploader.setDeleteFileParams({ + paramField: false + }, 1234); + } + + testSetParams() { + type CustomParams = { + customParams: number; + }; + + this.uploader.setParams({ + customParams: 1234 + }, 1234); + } + + bulkTests() { + this.uploader.cancel(1); + this.uploader.cancelAll(); + this.uploader.clearStoredFiles(); + const shouldContinue: boolean = this.uploader.continueUpload(1234); + this.uploader.deleteFile(1234); + let elem: HTMLElement = this.uploader.getButton(1234); + let fileOrBlob: File | Blob = this.uploader.getFile(1234); + let num: number = this.uploader.getInProgress(); + let s: string = this.uploader.getName(1234); + num = this.uploader.getParentId(1234); + num = this.uploader.getRemainingAllowedItems(); + const resumables: qq.ResumableItem[] = this.uploader.getResumableFilesData(); + num = this.uploader.getSize(1234); + s = this.uploader.getUuid(1234); + this.uploader.log("why am i doing this?", "info"); + let b: boolean = this.uploader.pauseUpload(1234); + this.uploader.reset(); + this.uploader.retry(1234); + const blobPromise: Promise = this.uploader.scaleImage(1234, { + maxSize: 20, + orient: false, + type: "png", + quality: 10, + includeExif: false, + }); + this.uploader.setEndpoint("/my/path/is/my/own", 1234); + this.uploader.setEndpoint("/my/path/is/my/own", new HTMLElement()); + this.uploader.setDeleteFileEndpoint("/some/path", 1234); + this.uploader.setDeleteFileEndpoint("/some/path", new HTMLElement()); + this.uploader.setItemLimit(1234); + this.uploader.setForm(new HTMLFormElement()); + this.uploader.setForm("myFormElement"); + this.uploader.setName(1234, "myCustomName"); + this.uploader.setUuid(1234, "12341234"); + this.uploader.uploadStoredFiles(); + } + + uiTests() { + this.uploader.addExtraDropzone(new HTMLElement()); + let elem: HTMLElement = this.uploader.getDropTarget(1234); + let n: number = this.uploader.getId(elem); + elem = this.uploader.getItemByFileId(n); + this.uploader.removeExtraDropzone(elem); + } +} diff --git a/fine-uploader/test/paste.ts b/fine-uploader/test/paste.ts new file mode 100644 index 0000000000..5122238c75 --- /dev/null +++ b/fine-uploader/test/paste.ts @@ -0,0 +1,16 @@ +/// + +function pasteTest() { + const targetElement: HTMLElement = new HTMLElement(); + + const pasteOptions: qq.PasteOptions = { + defaultName: "pasted_image", + targetElement: targetElement + } + + const config: qq.BasicOptions = { + paste: pasteOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/request.ts b/fine-uploader/test/request.ts new file mode 100644 index 0000000000..a93ee6edb2 --- /dev/null +++ b/fine-uploader/test/request.ts @@ -0,0 +1,34 @@ +/// + +function requestTest() { + type CustomHeader = { + customHeader: string; + }; + + type CustomParam = { + customParam: boolean; + }; + + const requestOptions: qq.RequestOptions = { + customHeaders: { + customHeader: "my custom header hehehehee" + }, + endpoint: "/my/custom/endpoint", + filenameParam: "newFilenameParam", + forceMultipart: true, + inputName: "filenameParamMapping", + method: "POST", + params: { + customParam: false + }, + paramsInBody: false, + uuid: "asdf123456", + totalFileSizeName: "totalFileSize" + }; + + const config: qq.BasicOptions = { + request: requestOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} \ No newline at end of file diff --git a/fine-uploader/test/resume.ts b/fine-uploader/test/resume.ts new file mode 100644 index 0000000000..2b4d475bc0 --- /dev/null +++ b/fine-uploader/test/resume.ts @@ -0,0 +1,17 @@ +/// + +function resumeTest() { + const resumeOptions: qq.ResumeOptions = { + recordsExpireIn: 10, + enabled: true, + paramNames: { + resuming: "ew you" + } + }; + + const config: qq.BasicOptions = { + resume: resumeOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/retry.ts b/fine-uploader/test/retry.ts new file mode 100644 index 0000000000..6b94b93002 --- /dev/null +++ b/fine-uploader/test/retry.ts @@ -0,0 +1,17 @@ +/// + +function retryTest() { + + const retryOptions: qq.RetryOptions = { + autoAttemptDelay: 1, + enableAuto: true, + maxAutoAttempts: 32, + preventRetryResponseProperty: "preventRetry" + }; + + const config: qq.BasicOptions = { + retry: retryOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} \ No newline at end of file diff --git a/fine-uploader/test/scaling.ts b/fine-uploader/test/scaling.ts new file mode 100644 index 0000000000..e57089d103 --- /dev/null +++ b/fine-uploader/test/scaling.ts @@ -0,0 +1,31 @@ +/// + +function scalingTest() { + const scalingOptions: qq.ScalingOptions = { + customResizer: (blob, height, image, sourceCanvas, targetCanvas, width) => { + const promise = new Promise(() => { + return blob; + }); + return promise; + }, + defaultQuality: 10, + defaultType: "JPEG", + failureText: "you have failed me for the last time", + includeExif: true, + orient: false, + sendOriginal: true, + sizes: [ + { + maxSize: 10, + name: "i am added to name", + type: "mime type" + } + ] + }; + + const config: qq.BasicOptions = { + scaling: scalingOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/session.ts b/fine-uploader/test/session.ts new file mode 100644 index 0000000000..9728c657b5 --- /dev/null +++ b/fine-uploader/test/session.ts @@ -0,0 +1,28 @@ +/// + +function sessionTest() { + type CustomHeader = { + customHeader: string; + }; + + type CustomParam = { + customParam: boolean; + }; + + const sessionOptions: qq.SessionOptions = { + customHeaders: { + customHeader: "customHeader" + }, + endpoint: "/mysession/endpoint", + params: { + customParam: false + }, + refreshOnReset: false + }; + + const config: qq.BasicOptions = { + session: sessionOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/text.ts b/fine-uploader/test/text.ts new file mode 100644 index 0000000000..4b52a96570 --- /dev/null +++ b/fine-uploader/test/text.ts @@ -0,0 +1,15 @@ +/// + +function textTest() { + const textOptions: qq.TextOptions = { + defaultResponseError: "you have failed me for the last time", + fileInputTitle: "file input title", + sizeSymbols: ['kb'] + }; + + const config: qq.BasicOptions = { + text: textOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/validation.ts b/fine-uploader/test/validation.ts new file mode 100644 index 0000000000..fb0b1276ea --- /dev/null +++ b/fine-uploader/test/validation.ts @@ -0,0 +1,24 @@ +/// + +function validationTest() { + + const validationOptions: qq.ValidationOptions = { + acceptFiles: [new MimeType()], + allowExtensions: ['csv, xls'], + itemLimit: 5, + sizeLimit: 10000000, + stopOnFirstInvalidFile: false, + image: { + maxHeight: 10, + maxWidth: 10, + minHeight: 1, + minWidth: 1 + } + }; + + const config: qq.BasicOptions = { + validation: validationOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/test/workarounds.ts b/fine-uploader/test/workarounds.ts new file mode 100644 index 0000000000..2acfac455b --- /dev/null +++ b/fine-uploader/test/workarounds.ts @@ -0,0 +1,15 @@ +/// + +function workaroundsTest() { + const workaroundOptions: qq.WorkaroundOptions = { + iosEmptyVideos: false, + ios8BrowserCrash: false, + ios8SafariUploads: false + }; + + const config: qq.BasicOptions = { + workarounds: workaroundOptions + }; + + const uploader = new qq.FineUploaderBasic(config); +} diff --git a/fine-uploader/tsconfig.json b/fine-uploader/tsconfig.json new file mode 100644 index 0000000000..e4339da404 --- /dev/null +++ b/fine-uploader/tsconfig.json @@ -0,0 +1,39 @@ +{ + "files": [ + "index.d.ts", + "test/blobs.ts", + "test/camera.ts", + "test/chunking.ts", + "test/core.ts", + "test/cors.ts", + "test/deleteFile.ts", + "test/extraButtons.ts", + "test/form.ts", + "test/message.ts", + "test/paste.ts", + "test/resume.ts", + "test/retry.ts", + "test/request.ts", + "test/scaling.ts", + "test/session.ts", + "test/text.ts", + "test/validation.ts", + "test/workarounds.ts", + "test/method.ts", + "test/callbacks.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/fine-uploader/tslint.json b/fine-uploader/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fine-uploader/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From dc028e0a39e2d57f2141489f7a9ee569fcb1f38b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 5 Jan 2017 12:43:24 -0800 Subject: [PATCH 116/181] Revert "Merge more from `types-2.0` to `master (#13770)" This reverts commit 5bce8fab2ee167fde0b249672bc38ef1c37abec7. --- chai-json-schema/index.d.ts | 24 +- chai-json-schema/tslint.json | 6 +- d3-selection/d3-selection-tests.ts | 77 +- d3-selection/index.d.ts | 2 +- googlemaps/google.maps-tests.ts | 95 +- googlemaps/index.d.ts | 8 +- googlemaps/tsconfig.json | 4 +- js-quantities/index.d.ts | 132 +-- js-quantities/js-quantities-tests.ts | 1503 +------------------------- js-quantities/tsconfig.json | 4 +- js-quantities/tslint.json | 3 - memoizee/index.d.ts | 29 - memoizee/memoizee-tests.ts | 61 -- memoizee/tsconfig.json | 20 - memoizee/tslint.json | 1 - react-intl/index.d.ts | 8 +- react-intl/react-intl-tests.tsx | 53 +- stripe/index.d.ts | 45 +- stripe/stripe-tests.ts | 25 - stripe/tsconfig.json | 7 +- stripe/tslint.json | 3 - 21 files changed, 208 insertions(+), 1902 deletions(-) delete mode 100644 js-quantities/tslint.json delete mode 100644 memoizee/index.d.ts delete mode 100644 memoizee/memoizee-tests.ts delete mode 100644 memoizee/tsconfig.json delete mode 100644 memoizee/tslint.json delete mode 100644 stripe/stripe-tests.ts delete mode 100644 stripe/tslint.json diff --git a/chai-json-schema/index.d.ts b/chai-json-schema/index.d.ts index e66e2c96af..e3e4934c76 100644 --- a/chai-json-schema/index.d.ts +++ b/chai-json-schema/index.d.ts @@ -6,19 +6,19 @@ // // -declare global { - namespace Chai { - export interface Assert { - jsonSchema(value: any, schema: any, msg?: string): void; - notJsonSchema(value: any, schema: any, msg?: string): void; - } +declare namespace Chai { + export interface Assert { + jsonSchema(value: any, schema: any, msg?: string): void; + notJsonSchema(value: any, schema: any, msg?: string): void; + } - export interface LanguageChains { - jsonSchema(schema: any, msg?: string): void; - } + export interface LanguageChains { + jsonSchema(schema: any, msg?: string): void; } } -declare function chaiJsonSchema(chai: any, utils: any): void; -declare namespace chaiJsonSchema { } -export = chaiJsonSchema; +declare module "chai-json-schema" { + function chaiJsonSchema(chai: any, utils: any): void; + namespace chaiJsonSchema {} + export = chaiJsonSchema; +} diff --git a/chai-json-schema/tslint.json b/chai-json-schema/tslint.json index 377cc837d4..83a03ce890 100644 --- a/chai-json-schema/tslint.json +++ b/chai-json-schema/tslint.json @@ -1 +1,5 @@ -{ "extends": "../tslint.json" } +{ "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/d3-selection/d3-selection-tests.ts b/d3-selection/d3-selection-tests.ts index 042fba622a..b1f776c442 100644 --- a/d3-selection/d3-selection-tests.ts +++ b/d3-selection/d3-selection-tests.ts @@ -846,43 +846,60 @@ newDiv2 = body.append(function (d, i, g) { // without insert<...> typing returned selection has group element of type BaseType let newParagraph: d3Selection.Selection; newParagraph = body.insert('p', 'p.second-paragraph'); -newParagraph = body.insert('p'); - -// Two arguments; the first can be string, selection , or a - -const typeValueFunction = function ( - this: HTMLBodyElement, - d: BodyDatum, - i: number, - g: HTMLBodyElement[] | d3Selection.ArrayLike -) { - return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement -} - -const beforeValueFunction = function ( - this: HTMLBodyElement, - d: BodyDatum, - i: number, - g: HTMLBodyElement[] | d3Selection.ArrayLike -) { - return this.children[0]; -} let newParagraph2: d3Selection.Selection; - -// 2 args, with 3 possibilities each, makes 9 possible combinations: newParagraph2 = body.insert('p', 'p.second-paragraph'); -newParagraph2 = body.insert('p', beforeValueFunction); -newParagraph2 = body.insert('p'); newParagraph2 = body.insert(d3Selection.creator('p'), 'p.second-paragraph'); -newParagraph2 = body.insert(d3Selection.creator('p'), beforeValueFunction); -newParagraph2 = body.insert(d3Selection.creator('p')); +newParagraph2 = body.insert(function (d, i, g) { + let that: HTMLBodyElement = this; + // let that2: SVGElement = this; // fails, type mismatch + let datum: BodyDatum = d; + let index: number = i; + let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; + console.log('Body element foo property: ', d.foo); // data of type BodyDatum + return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement +}, 'p.second-paragraph'); -newParagraph2 = body.insert(typeValueFunction, 'p.second-paragraph'); -newParagraph2 = body.insert(typeValueFunction, beforeValueFunction); -newParagraph2 = body.insert(typeValueFunction); +// newParagraph2 = body.insert(function(d) { +// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type parameter, HTMLAnchorElement returned +// }, 'p.second-paragraph'); +// newParagraph2 = body.insert(function(d) { +// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type inference, HTMLAnchorElement returned +// }, 'p.second-paragraph'); + +newParagraph2 = body.insert(d3Selection.creator('p'), function (d, i, g) { + let that: HTMLBodyElement = this; + // let that2: SVGElement = this; // fails, type mismatch + let datum: BodyDatum = d; + let index: number = i; + let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; + console.log('Body element foo property: ', d.foo); // data of type BodyDatum + return this.children[0]; // this type HTMLBodyElement +}); + +newParagraph2 = body.insert( + // type + function (d, i, g) { + let that: HTMLBodyElement = this; + // let that2: SVGElement = this; // fails, type mismatch + let datum: BodyDatum = d; + let index: number = i; + let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; + console.log('Body element foo property: ', d.foo); // data of type BodyDatum + return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement + }, + // before + function (d, i, g) { + let that: HTMLBodyElement = this; + // let that2: SVGElement = this; // fails, type mismatch + let datum: BodyDatum = d; + let index: number = i; + let group: HTMLBodyElement[] | d3Selection.ArrayLike = g; + console.log('Body element foo property: ', d.foo); // data of type BodyDatum + return this.children[0]; // this type HTMLBodyElement + }); // sort(...) ----------------------------------------------------------------------------- diff --git a/d3-selection/index.d.ts b/d3-selection/index.d.ts index 1d0ab9472c..65703f66ff 100644 --- a/d3-selection/index.d.ts +++ b/d3-selection/index.d.ts @@ -519,7 +519,7 @@ interface Selection( type: string | ValueFn, - before?: string | ValueFn + before: string | ValueFn ): Selection; /** diff --git a/googlemaps/google.maps-tests.ts b/googlemaps/google.maps-tests.ts index 0be531a89f..fd4e10f6e6 100644 --- a/googlemaps/google.maps-tests.ts +++ b/googlemaps/google.maps-tests.ts @@ -141,102 +141,19 @@ var mapTypeStyle: google.maps.MapTypeStyle ={ stylers: [], }; -// https://developers.google.com/maps/documentation/javascript/markers -function initMap1() { - var myLatLng = {lat: -25.363, lng: 131.044}; - +// https://developers.google.com/maps/documentation/javascript/adding-a-google-map +function initMap() { + var uluru = {lat: -25.363, lng: 131.044}; var map = new google.maps.Map(document.getElementById('map'), { zoom: 4, - center: myLatLng + center: uluru }); - var marker = new google.maps.Marker({ - position: myLatLng, - map: map, - title: 'Hello World!' - }); -} - -var myLatlng = new google.maps.LatLng(-25.363882,131.044922); -var mapOptions = { - zoom: 4, - center: myLatlng -} -var map = new google.maps.Map(document.getElementById("map"), mapOptions); - -var marker = new google.maps.Marker({ - position: myLatlng, - title:"Hello World!" -}); - -// To add the marker to the map, call setMap(); -marker.setMap(map); - -marker.setMap(null); - -// The following example creates a marker in Stockholm, Sweden using a DROP -// animation. Clicking on the marker will toggle the animation between a BOUNCE -// animation and no animation. - -var marker: google.maps.Marker; - -function initMap2() { - var map = new google.maps.Map(document.getElementById('map'), { - zoom: 13, - center: {lat: 59.325, lng: 18.070} - }); - - marker = new google.maps.Marker({ - map: map, - draggable: true, - animation: google.maps.Animation.DROP, - position: {lat: 59.327, lng: 18.067} - }); - marker.addListener('click', toggleBounce); -} - -function toggleBounce() { - if (marker.getAnimation() !== null) { - marker.setAnimation(null); - } else { - marker.setAnimation(google.maps.Animation.BOUNCE); - } -} - -// In the following example, markers appear when the user clicks on the map. -// Each marker is labeled with a single alphabetical character. -var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; -var labelIndex = 0; - -function initialize() { - var bangalore = { lat: 12.97, lng: 77.59 }; - var map = new google.maps.Map(document.getElementById('map'), { - zoom: 12, - center: bangalore - }); - - // This event listener calls addMarker() when the map is clicked. - google.maps.event.addListener(map, 'click', function(event: any) { - addMarker(event.latLng, map); - }); - - // Add a marker at the center of the map. - addMarker(bangalore, map); -} - -// Adds a marker to the map. -function addMarker(location: google.maps.LatLngLiteral, map: google.maps.Map) { - // Add the marker at the clicked location, and add the next-available label - // from the array of alphabetical characters. - var marker = new google.maps.Marker({ - position: location, - label: labels[labelIndex++ % labels.length], + position: uluru, map: map }); } -google.maps.event.addDomListener(window, 'load', initialize); - /***** OverlayView *****/ // https://developers.google.com/maps/documentation/javascript/customoverlays var div = document.createElement('div'); @@ -266,4 +183,4 @@ var rectangle = new google.maps.Rectangle({ east: -116.234, west: -116.251 } -}); +}); \ No newline at end of file diff --git a/googlemaps/index.d.ts b/googlemaps/index.d.ts index fefca3ea89..f19480f034 100644 --- a/googlemaps/index.d.ts +++ b/googlemaps/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Maps JavaScript API 3.25 // Project: https://developers.google.com/maps/ -// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin , Grant Hutchins +// Definitions by: Folia A/S , Chris Wrench , Kiarash Ghiaseddin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* @@ -30,7 +30,7 @@ THE SOFTWARE. declare namespace google.maps { /***** Map *****/ export class Map extends MVCObject { - constructor(mapDiv: Element|null, opts?: MapOptions); + constructor(mapDiv: Element, opts?: MapOptions); fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void; getBounds(): LatLngBounds; getCenter(): LatLng; @@ -536,14 +536,14 @@ declare namespace google.maps { getTitle(): string; getVisible(): boolean; getZIndex(): number; - setAnimation(animation: Animation|null): void; + setAnimation(animation: Animation): void; setAttribution(attribution: Attribution): void; setClickable(flag: boolean): void; setCursor(cursor: string): void; setDraggable(flag: boolean): void; setIcon(icon: string|Icon|Symbol): void; setLabel(label: string|MarkerLabel): void; - setMap(map: Map|StreetViewPanorama|null): void; + setMap(map: Map|StreetViewPanorama): void; setOpacity(opacity: number): void; setOptions(options: MarkerOptions): void; setPlace(place: Place): void; diff --git a/googlemaps/tsconfig.json b/googlemaps/tsconfig.json index 0382e30210..dc12fbf795 100644 --- a/googlemaps/tsconfig.json +++ b/googlemaps/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": true, + "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ "../" @@ -17,4 +17,4 @@ "index.d.ts", "google.maps-tests.ts" ] -} +} \ No newline at end of file diff --git a/js-quantities/index.d.ts b/js-quantities/index.d.ts index 5d4a8df304..a2e3c2d96c 100644 --- a/js-quantities/index.d.ts +++ b/js-quantities/index.d.ts @@ -1,73 +1,79 @@ -// Type definitions for JS-quantities 1.6 +// Type definitions for JS-quantities // Project: http://gentooboontoo.github.io/js-quantities/ -// Definitions by: William Rummler +// Definitions by: William Comartin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare const Qty: Qty.Type; +declare var Qty: QtyModule.QtyStatic; + +declare namespace QtyModule { + interface QtyStatic { + (value: string): Qty; + (value: number): Qty; + (value: number, unit: string): Qty; + (value: Qty): Qty; + } + + interface Qty { + version: string; + + scalar: number; + baseScalar: number; + + parse(value: string): Qty; + + swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number; + + getkinds(): string[]; + + getUnits(kind:string): string[]; + + getAliases(unitName:string): string[]; + + formatter(scalar:number, units:string):string; -declare interface Qty { - readonly numerator: string[]; - readonly denominator: string[]; - readonly scalar: number; - readonly baseScalar: number; - readonly initValue: string; - units(): string; - isCompatible(value: Qty.UnitSource): boolean; - kind(): string; - isUnitless(): boolean; - isBase(): boolean; - toBase(): Qty; toFloat(): number; - to(value: Qty.UnitSource): Qty; + + isUnitless(): boolean; + + isCompatible(other:string|Qty): boolean; + + isInverse(other:string|Qty): boolean + + kind(): string; + + isBase(): boolean; + + toBase(): Qty; + + units(): string; + + eq(other:Qty): boolean; + lt(other:Qty): boolean; + lte(other:Qty): boolean; + gt(other:Qty): boolean; + gte(other:Qty): boolean; + + toPrec(precQuantity: Qty|string|number): Qty; + + toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string; + + format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string; + + compareTo(other:Qty|string): number; + + same(other: Qty): boolean; + inverse(): Qty; - eq(value: Qty.UnitSource): boolean; - same(value: Qty.UnitSource): boolean; - lt(value: Qty.UnitSource): boolean; - lte(value: Qty.UnitSource): boolean; - gt(value: Qty.UnitSource): boolean; - gte(value: Qty.UnitSource): boolean; - compareTo(value: Qty): Qty.ComparisonResult; - add(value: Qty.Source): Qty; - sub(value: Qty.Source): Qty; - mul(value: Qty.Source): Qty; - div(value: Qty.Source): Qty; - toPrec(value: Qty.Source): Qty; - toString(valueOrPrecision?: Qty.Source): string; - toString(value: string, precision: number): string; - format(formatter?: Qty.Formatter): string; - format(value: string, formatter?: Qty.Formatter): string; -} -declare namespace Qty { + isDegrees(): boolean; - interface Type { - (value: Source): Qty; - (value: number, unit: string): Qty; - new (value: Source): Qty; - new (value: number, unit: string): Qty; - parse(value: string): Qty; - getKinds(): string[]; - getUnits(kind?: string): string[]; - getAliases(unit: string): string[]; - swiftConverter(sourceUnit: string, targetUnit: string): Converter; - formatter: Formatter; - readonly Error: any; - mulSafe(n1: number, n2: number): number; - divSafe(n1: number, n2: number): number; - } + isTemperature(): boolean; - interface Converter { - (sourceValue: number): number; - (sourceValues: number[]): number[]; - } + to(other:string|Qty): Qty; - type Formatter = (scalar: number, unit: string) => string; - - type ComparisonResult = -1 | 0 | 1; - - type Source = UnitSource | number; - - type UnitSource = Qty | string; -} - -export default Qty; + add(other:string|Qty): Qty; + sub(other:string|Qty): Qty; + mul(other:number|string|Qty): Qty; + div(other:number|string|Qty): Qty; + } +} \ No newline at end of file diff --git a/js-quantities/js-quantities-tests.ts b/js-quantities/js-quantities-tests.ts index b1916bb626..c09867634a 100644 --- a/js-quantities/js-quantities-tests.ts +++ b/js-quantities/js-quantities-tests.ts @@ -1,1502 +1,7 @@ -import "../jasmine"; -import Qty from "."; +var Val1 = Qty('1 m') -// From project readme +var Val2 = Qty(1); -let qty: Qty; +var Val3 = Qty(1, 'm'); -qty = new Qty('23 ft'); // constructor -qty = Qty('23 ft'); // factory - -qty = new Qty(124, 'cm'); // => 1.24 meter -qty = Qty(124, 'cm'); // => 1.24 meter - -qty = Qty('1m'); // => 1 meter -qty = Qty('m'); // => 1 meter (scalar defaults to 1) - -qty = Qty('1 N*m'); -qty = Qty('1 N m'); // * is optional - -qty = Qty('1 m/s'); - -qty = Qty('1 m^2/s^2'); -qty = Qty('1 m^2 s^-2'); // negative powers -qty = Qty('1 m2 s-2'); // ^ is optional - -qty = Qty('1 m^2 kg^2 J^2/s^2 A'); - -qty = Qty('1.5'); // unitless quantity -qty = Qty(1.5); // number as initializing value - -qty = Qty('1 attoparsec/microfortnight'); - -let qtyCopy: Qty; - -qtyCopy = Qty(qty); // quantity could be copied when used as initializing value - -Qty.parse('1 m'); // => 1 meter -Qty.parse('foo'); // => null - -Qty.getKinds(); // => Array of names of every well-known kind of units - -Qty.getUnits('currency'); // => [ 'dollar', 'cents' ] -// Or all alphabetically sorted -Qty.getUnits(); // => [ 'acre','Ah','ampere','AMU','angstrom'] - -Qty.getAliases('m'); // => [ 'm', 'meter', 'meters', 'metre', 'metres' ] - -const qty1 = Qty('1m'); -const qty2 = Qty('2m'); - -qty1.isCompatible(qty2); // => true or false - -qty.kind(); // => 'length', 'area', etc... - -qty.isUnitless(); // => true or false -qty.isBase(); // => true if quantity is represented with base units - -qty.toBase(); // converts to SI units (10 cm => 0.1 m) (new instance) - -qty.toFloat(); // returns scalar of unitless quantity (otherwise throws error) - -qty.to('m'); // converts quantity to meter if compatible or throws an error (new instance) -qty1.to(qty2); // converts quantity to same unit of qty2 if compatible or throws an error (new instance) - -qty.inverse(); // converts quantity to its inverse ('100 m/s' => '.01 s/m') -// Inverses can be used, but there is no special checking to -// rename the units -Qty('10ohm').inverse(); // '.1/ohm' (not '.1S', although they are equivalent) -// however, the 'to' command will convert between inverses also -Qty('10ohm').to('S'); // '.1S' - -var convert = Qty.swiftConverter('m/h', 'ft/s'); // Configures converter - -// Converting single value -var converted = convert(2500); // => 2.278.. - -// Converting large array of values -var convertedSerie = convert([2500, 5000]); // => [2.278.., 4.556.., ...] - -qty1.eq(qty2); // => true if both quantities are equal (1m == 100cm => true) -qty1.same(qty2); // => true if both quantities are same (1m == 100cm => false) -qty1.lt(qty2); // => true if qty1 is stricty less than qty2 -qty1.lte(qty2); // => true if qty1 is less than or equal to qty2 -qty1.gt(qty2); // => true if qty1 is stricty greater than qty2 -qty1.gte(qty2); // => true if qty1 is greater than or equal to qty2 - -qty1.compareTo(qty2); // => -1 if qty1 < qty2, => 0 if qty1 == qty2, => 1 if qty1 > qty2 - -qty = Qty('5.17 ft'); -qty.toPrec('ft'); // => 5 ft -qty.toPrec('0.5 ft'); // => 5 ft -qty.toPrec('0.25 ft'); // => 5.25 ft -qty.toPrec('0.1 ft'); // => 5.2 ft -qty.toPrec('0.05 ft'); // => 5.15 ft -qty.toPrec('0.01 ft'); // => 5.17 ft -qty.toPrec('0.00001 ft'); // => 5.17 ft -qty.toPrec('2 ft'); // => 6 ft -qty.toPrec('2'); // => 6 ft - -qty = Qty('6.3782 m'); -qty.toPrec('dm'); // => 6.4 m -qty.toPrec('cm'); // => 6.38 m -qty.toPrec('mm'); // => 6.378 m -qty.toPrec('5 cm'); // => 6.4 m -qty.toPrec('10 m'); // => 10 m -qty.toPrec(0.1); // => 6.3 m - -qty = Qty('1.146 MPa'); -qty.toPrec('0.1 bar'); // => 1.15 MPa - -qty = Qty('1.146 MPa'); -qty.toString(); // => '1.146 MPa' - -qty = Qty('1.146 MPa'); -qty.toString('bar'); // => '11.46 bar' -qty.to('bar').toString(); // => '11.46 bar' - -qty = Qty('1.146 MPa'); -qty.toPrec(0.1).toString(); // => '1.1 MPa' -qty.to('bar').toPrec(0.1).toString(); // => '11.5 bar' - -qty = Qty('1.1234 m'); -qty.format(); // same units, default formatter => '1.234 m' -qty.format('cm'); // converted to 'cm', default formatter => '123.45 cm' - -var configurableRoundingFormatter = function (maxDecimals: number) { - return function (scalar: number, units: string) { - var pow = Math.pow(10, maxDecimals); - var rounded = Math.round(scalar * pow) / pow; - - return rounded + ' ' + units; - }; -}; - -qty = Qty('1.1234 m'); - -// same units, custom formatter => '1.12 m' -qty.format(configurableRoundingFormatter(2)); - -// convert to 'cm', custom formatter => '123.4 cm' -qty.format('cm', configurableRoundingFormatter(1)); - -Qty.formatter = configurableRoundingFormatter(2); -qty = Qty('1.1234 m'); -qty.format(); // same units, current default formatter => '1.12 m' - -Qty('37 tempC').to('tempF'); // => 98.6 tempF - -let scalar: number = 42; - -Qty('100 tempC').add('10 degC'); // 110 tempC -Qty('100 tempC').sub('10 degC'); // 90 tempC -Qty('100 tempC').add('50 tempC'); // throws error -Qty('100 tempC').sub('50 tempC'); // 50 degC -Qty('50 tempC').sub('100 tempC'); // -50 degC -Qty('100 tempC').mul(scalar); // 100*scalar tempC -Qty('100 tempC').div(scalar); // 100/scalar tempC -Qty('100 tempC').mul(qty); // throws error -Qty('100 tempC').div(qty); // throws error -Qty('100 tempC*unit'); // throws error -Qty('100 tempC/unit'); // throws error -Qty('100 unit/tempC'); // throws error -Qty('100 tempC').inverse(); // throws error - -Qty('100 tempC').to('degC'); // => 100 degC - -Qty('100 degC').to('tempC'); // => -173.15 tempC - -Qty('0 tempC').add('100 degC'); // => 100 tempC - -try { - // code triggering an error inside JS-quantities -} catch (e) { - if (e instanceof Qty.Error) { - // ... - } else { - // ... - } -} - -// From project spec - -describe("js-quantities", function () { - "use strict"; - - describe("initialization", function () { - it("should create unit only", function () { - var qty = Qty("m"); - expect(qty.numerator).toEqual([""]); - expect(qty.scalar).toBe(1); - }); - - it("should create unitless", function () { - var qty = Qty("1"); - expect(qty.toFloat()).toBe(1); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual(["<1>"]); - qty = Qty("1.5"); - expect(qty.toFloat()).toBe(1.5); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("should create unitless from numbers", function () { - var qty = Qty(1.5); - expect(qty.toFloat()).toBe(1.5); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("should create from numbers with explicit units", function () { - var qty = Qty(1.5, "m"); - expect(qty.scalar).toBe(1.5); - expect(qty.numerator).toEqual([""]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("temperatures should have base unit in kelvin", function () { - var qty = Qty("1 tempK").toBase(); - expect(qty.scalar).toBe(1); - expect(qty.units()).toBe("tempK"); - - qty = Qty("1 tempR").toBase(); - expect(qty.scalar).toBe(5 / 9); - expect(qty.units()).toBe("tempK"); - - qty = Qty("0 tempC").toBase(); - expect(qty.scalar).toBe(273.15); - expect(qty.units()).toBe("tempK"); - - qty = Qty("0 tempF").toBase(); - expect(qty.scalar).toBeCloseTo(255.372, 3); - expect(qty.units()).toBe("tempK"); - }); - - it("temperature degrees should have base unit in kelvin", function () { - var qty = Qty("1 degK").toBase(); - expect(qty.scalar).toBe(1); - expect(qty.units()).toBe("degK"); - - qty = Qty("1 degR").toBase(); - expect(qty.scalar).toBe(5 / 9); - expect(qty.units()).toBe("degK"); - - qty = Qty("1 degC").toBase(); - expect(qty.scalar).toBe(1); - expect(qty.units()).toBe("degK"); - - qty = Qty("1 degF").toBase(); - expect(qty.scalar).toBe(5 / 9); - expect(qty.units()).toBe("degK"); - }); - - it("should not create temperatures below absolute zero", function () { - expect(function () { Qty("-1 tempK"); }).toThrow("Temperatures must not be less than absolute zero"); - expect(function () { Qty("-273.16 tempC"); }).toThrow("Temperatures must not be less than absolute zero"); - expect(function () { Qty("-459.68 tempF"); }).toThrow("Temperatures must not be less than absolute zero"); - expect(function () { Qty("-1 tempR"); }).toThrow("Temperatures must not be less than absolute zero"); - - var qty = Qty("1 tempK"); - expect(function () { qty.mul("-1"); }).toThrow("Temperatures must not be less than absolute zero"); - - qty = Qty("0 tempK"); - expect(function () { qty.sub("1 degK"); }).toThrow("Temperatures must not be less than absolute zero"); - - qty = Qty("-273.15 tempC"); - expect(function () { qty.sub("1 degC"); }).toThrow("Temperatures must not be less than absolute zero"); - - qty = Qty("-459.67 tempF"); - expect(function () { qty.sub("1 degF"); }).toThrow("Temperatures must not be less than absolute zero"); - - qty = Qty("0 tempR"); - expect(function () { qty.sub("1 degR"); }).toThrow("Temperatures must not be less than absolute zero"); - }); - - it("should create simple", function () { - var qty = Qty("1m"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual([""]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("should create negative", function () { - var qty = Qty("-1m"); - expect(qty.scalar).toBe(-1); - expect(qty.numerator).toEqual([""]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("should create compound", function () { - var qty = Qty("1 N*m"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["", ""]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("should create pressure units in term of height of water", function () { - var qty = Qty("1 inH2O"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual([""]); - - qty = Qty("1 cmH2O"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual([""]); - }); - - it("should create with denominator", function () { - var qty = Qty("1 m/s"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual([""]); - expect(qty.denominator).toEqual([""]); - }); - - it("should create with denominator only", function () { - var qty = Qty("1 /s"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual([""]); - - qty = Qty("1 1/s"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual([""]); - - qty = Qty("1 s^-1"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual([""]); - }); - - it("should create with powers", function () { - var qty = Qty("1 m^2/s^2"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["", ""]); - expect(qty.denominator).toEqual(["", ""]); - qty = Qty("1 m^2 kg^2 J^2/s^2"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["", "", "", "", "", ""]); - expect(qty.denominator).toEqual(["", ""]); - qty = Qty("1 m^2/s^2*J^3"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["", ""]); - expect(qty.denominator).toEqual(["", "", "", "", ""]); - }); - - it("should create with zero power", function () { - var qty = Qty("1 m^0"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["<1>"]); - expect(qty.denominator).toEqual(["<1>"]); - }); - - it("should create with negative powers", function () { - var qty = Qty("1 m^2 s^-2"); - expect(qty.scalar).toBe(1); - expect(qty.numerator).toEqual(["", ""]); - expect(qty.denominator).toEqual(["", ""]); - expect(qty.same(Qty("1 m^2/s^2"))).toBe(true); - }); - - it("should accept powers without ^ syntax (simple)", function () { - var qty1 = Qty("1 m2"); - var qty2 = Qty("1 m^2"); - expect(qty1.eq(qty2)).toBe(true); - }); - - it("should accept powers without ^ syntax (negative power)", function () { - var qty1 = Qty("1 m-2"); - var qty2 = Qty("1 m^-2"); - expect(qty1.eq(qty2)).toBe(true); - }); - - it("should accept powers without ^ syntax (compound)", function () { - var qty1 = Qty("1 m^2 kg^2 J^2/s^2"); - var qty2 = Qty("1 m2 kg2 J2/s2"); - expect(qty1.eq(qty2)).toBe(true); - }); - - it("should accept powers without ^ syntax (compound and negative power)", function () { - var qty1 = Qty("1 m^2 kg^2 J^2 s^-2"); - var qty2 = Qty("1 m2 kg2 J2 s-2"); - expect(qty1.eq(qty2)).toBe(true); - }); - - it("should throw 'Unit not recognized' error when initializing with an invalid unit", function () { - expect(function () { Qty("aa"); }).toThrow("Unit not recognized"); - expect(function () { Qty("m/aa"); }).toThrow("Unit not recognized"); - expect(function () { Qty("m-"); }).toThrow("Unit not recognized"); - expect(function () { Qty("N*m"); }).not.toThrow("Unit not recognized"); - // mm is millimeter, but mmm is not a valid unit - expect(function () { Qty("mmm"); }).toThrow("Unit not recognized"); - }); - - it("should accept empty string as unitless 1", function () { - expect(Qty("").same(Qty("1"))).toBe(true); - expect(Qty(" ").same(Qty("1"))).toBe(true); - }); - - it("should throw error when passing NaN", function () { - expect( - function () { Qty(NaN); } - ).toThrow("Only string, number or quantity accepted as single " + - "initialization value"); - }); - - it("should throw 'Unit not recognized' error when initializing with an invalid unit and a 0 exponent", function () { - expect(function () { Qty("3p0"); }).toThrow("Unit not recognized"); - expect(function () { Qty("3p-0"); }).toThrow("Unit not recognized"); - }); - - it("should set baseScalar", function () { - var qty = Qty("0.018 MPa"); - expect(qty.baseScalar).toBe(18000); - - qty = Qty("66 cm3"); - expect(qty.baseScalar).toBe(0.000066); - }); - - it("should keep init value as is", function () { - var initValue = " 66 cm3 "; - var qty = Qty(initValue); - - expect(qty.initValue).toEqual(initValue); - }); - - it("should allow whitespace-wrapped value", function () { - expect(function () { Qty(" 2 MPa "); }).not.toThrow(); - }); - - it("should allow whitespaces between sign and scalar", function () { - var qty = Qty("- 1m"); - - expect(qty.scalar).toEqual(-1); - expect(qty.units()).toEqual("m"); - }); - - it("should throw an error when parsing negative quantity " + - "with no scalar", function () { - expect(function () { Qty("-m"); }).toThrow("Unit not recognized"); - }); - }); - - describe("isCompatible", function () { - it("should return true with compatible quantities", function () { - var qty1 = Qty("1 m*kg/s"); - var qty2 = Qty("1 in*pound/min"); - expect(qty1.isCompatible(qty2)).toBe(true); - qty2 = Qty("1 in/min"); - expect(qty1.isCompatible(qty2)).toBe(false); - }); - - it("should return true with dimensionless quantities", function () { - var qty1 = Qty("1"); - var qty2 = Qty("2"); - expect(qty1.isCompatible(qty2)).toBe(true); - }); - }); - - describe("conversion", function () { - it("should convert to base units", function () { - var qty = Qty("100 cm"); - expect(qty.toBase().scalar).toBe(1); - expect(qty.toBase().units()).toBe("m"); - qty = Qty("10 cm"); - expect(qty.toBase().scalar).toBe(0.1); - expect(qty.toBase().units()).toBe("m"); - qty = Qty("0.3 mm^2 ms^-2"); - expect(qty.toBase().scalar).toBe(0.3); - expect(qty.toBase().units()).toBe("m2/s2"); - }); - - it("should convert to compatible units", function () { - var qty = Qty("10 cm"); - expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048)); - qty = Qty("2m^3"); - expect(qty.to("l").scalar).toBe(2000); - - qty = Qty("10 cm"); - expect(qty.to(Qty("m")).scalar).toBe(0.1); - expect(qty.to(Qty("20m")).scalar).toBe(0.1); - - qty = Qty("1 m3"); - expect(qty.to("cm3").scalar).toBe(1000000); - - qty = Qty("1 cm3"); - expect(qty.to("mm3").scalar).toBe(1000); - - qty = Qty("550 cm3"); - expect(qty.to("cm^3").scalar).toBe(550); - - qty = Qty("0.000773 m3"); - expect(qty.to("cm^3").scalar).toBe(773); - }); - - describe('percents', function () { - it("should convert from % to unitless", function () { - expect(Qty("10 %").to("").same(Qty("0.1"))).toBe(true); - }); - - it("should convert from unitless to %", function () { - expect(Qty("0.1").to("%").same(Qty("10 %"))).toBe(true); - }); - }); - - it("should convert temperatures to compatible units", function () { - var qty = Qty("0 tempK"); - expect(qty.to("tempC").scalar).toBe(-273.15); - - qty = Qty("0 tempF"); - expect(qty.to("tempK").scalar).toBeCloseTo(255.372, 3); - - qty = Qty("32 tempF"); - expect(qty.to("tempC").scalar).toBe(0); - - qty = Qty("0 tempC"); - expect(qty.to("tempF").scalar).toBeCloseTo(32, 10); - }); - - it("should convert temperature degrees to compatible units", function () { - var qty = Qty("0 degK"); - expect(qty.to("degC").scalar).toBe(0); - - qty = Qty("1 degK/s"); - expect(qty.to("degC/min").scalar).toBe(60); - - qty = Qty("100 cm/degF"); - expect(qty.to("m/degF").scalar).toBe(1); - - qty = Qty("10 degC"); - expect(qty.to("degF").scalar).toBe(18); - }); - - it("should convert temperature degrees to temperatures", function () { - // according to ruby-units, deg -> temp conversion adds the degress to 0 kelvin before converting - var qty = Qty("100 degC"); - expect(qty.to("tempC").scalar).toBeCloseTo(-173.15, 10); - - qty = Qty("273.15 degC"); - expect(qty.to("tempC").scalar).toBe(0); - - qty = Qty("460.67 degF"); - expect(qty.to("tempF").scalar).toBeCloseTo(1, 10); - }); - - it("should convert temperatures to temperature degrees", function () { - // according to ruby-units, temp -> deg conversion always uses the 0 relative degrees - var qty = Qty("100 tempC"); - expect(qty.to("degC").scalar).toBe(100); - - qty = Qty("0 tempK"); - expect(qty.to("degC").scalar).toBe(0); - - qty = Qty("0 tempF"); - expect(qty.to("degK").scalar).toBe(0); - - qty = Qty("18 tempF"); - expect(qty.to("degC").scalar).toBe(10); - - qty = Qty("10 tempC"); - expect(qty.to("degF").scalar).toBe(18); - }); - - it("should calculate inverses", function () { - var qty = Qty("1 ohm"); - var result = qty.to("siemens"); - expect(result.scalar).toBe(1); - expect(result.kind()).toBe("conductance"); - - qty = Qty("10 ohm"); - result = qty.to("siemens"); - expect(result.scalar).toBe(0.1); - expect(result.kind()).toBe("conductance"); - - qty = Qty("10 siemens"); - result = qty.to("ohm"); - expect(result.scalar).toBe(0.1); - expect(result.kind()).toBe("resistance"); - - qty = Qty("10 siemens"); - result = qty.inverse(); - expect(result.eq(".1 ohm")).toBe(true); - expect(result.kind()).toBe("resistance"); - - // cannot inverse a quantity with a 0 scalar - qty = Qty("0 ohm"); - expect(function () { qty.inverse(); }).toThrow("Divide by zero"); - - qty = Qty("10 ohm").inverse(); - result = qty.to("S"); - expect(result.scalar).toBe(0.1); - expect(result.kind()).toBe("conductance"); - - qty = Qty("12 in").inverse(); - // TODO: Swap toBeCloseTo with toBe once divSafe is fixed - expect(qty.to("ft").scalar).toBeCloseTo(1, 10); - }); - - it("should return itself if target units are the same", function () { - var qty = Qty("123 cm3"); - - expect(qty.to("cm3")).toBe(qty); - expect(qty.to("cm^3")).toBe(qty); - - qty = Qty("123 mcg"); - expect(qty.to("ug")).toBe(qty); - }); - - it("should be cached", function () { - var qty = Qty("100 m"), - converted = qty.to("ft"); - - expect(qty.to("ft") === converted).toBe(true); - }); - }); - - describe("comparison", function () { - it("should return true when comparing equal quantities", function () { - var qty1 = Qty("1cm"); - var qty2 = Qty("10mm"); - expect(qty1.eq(qty2)).toBe(true); - }); - - it("should compare compatible quantities", function () { - var qty1 = Qty("1cm"); - var qty2 = Qty("1mm"); - var qty3 = Qty("10mm"); - var qty4 = Qty("28A"); - expect(qty1.compareTo(qty2)).toBe(1); - expect(qty2.compareTo(qty1)).toBe(-1); - expect(qty1.compareTo(qty3)).toBe(0); - expect(function () { qty1.compareTo(qty4); }).toThrow("Incompatible units"); - - expect(qty1.lt(qty2)).toBe(false); - expect(qty1.lt(qty3)).toBe(false); - expect(qty1.lte(qty3)).toBe(true); - expect(qty1.gte(qty3)).toBe(true); - expect(qty1.gt(qty2)).toBe(true); - expect(qty2.gt(qty1)).toBe(false); - }); - - it("should compare identical quantities", function () { - var qty1 = Qty("1cm"); - var qty2 = Qty("1cm"); - var qty3 = Qty("10mm"); - expect(qty1.same(qty2)).toBe(true); - expect(qty1.same(qty3)).toBe(false); - }); - - it("should accept strings as parameter", function () { - var qty = Qty("1 cm"); - expect(qty.lt("0.5 cm")).toBe(false); - expect(qty.lte("1 cm")).toBe(true); - expect(qty.gte("3 mm")).toBe(true); - expect(qty.gt("5 m")).toBe(false); - }); - - }); - - describe("non-ASCII character", function () { - describe("µ", function () { - it("should be supported as prefix", function () { - // µ as greek letter - expect(Qty("1 \u03BCm").eq(Qty("1 um"))).toBe(true); - // µ as micro sign - expect(Qty("1 \u00B5m").eq(Qty("1 um"))).toBe(true); - }); - }); - - describe("Ω", function () { - it("should be accepted as unit for ohm", function () { - // Ω as greek letter - expect(Qty("1 \u03A9").eq(Qty("1 ohm"))).toBe(true); - // Ω as ohm sign - expect(Qty("1 \u2126").eq(Qty("1 ohm"))).toBe(true); - }); - }); - }); - - describe("math", function () { - - it("should add quantities", function () { - var qty1 = Qty("2.5m"); - var qty2 = Qty("3m"); - expect(qty1.add(qty2).scalar).toBe(5.5); - - expect(qty1.add("3m").scalar).toBe(5.5); - - qty2 = Qty("3cm"); - var result = qty1.add(qty2); - expect(result.scalar).toBe(2.53); - expect(result.units()).toBe("m"); - - result = qty2.add(qty1); - expect(result.scalar).toBe(253); - expect(result.units()).toBe("cm"); - - // make sure adding 2 of the same non-base units work - result = Qty("5cm").add("3cm"); - expect(result.scalar).toBe(8); - expect(result.units()).toBe("cm"); - }); - - it("should fail to add unlike quantities", function () { - var qty1 = Qty("3m"); - var qty2 = Qty("2s"); - expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); - expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); - }); - - it("should fail to add inverse quantities", function () { - var qty1 = Qty("10S"); - var qty2 = qty1.inverse(); - expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); - expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); - - qty1 = Qty("10S"); - qty2 = Qty("0.1ohm"); - expect(function () { qty1.add(qty2); }).toThrow("Incompatible units"); - expect(function () { qty2.add(qty1); }).toThrow("Incompatible units"); - }); - - it("should subtract quantities", function () { - var qty1 = Qty("2.5m"); - var qty2 = Qty("3m"); - expect(qty1.sub(qty2).scalar).toBe(-0.5); - - expect(qty1.sub("2m").scalar).toBe(0.5); - expect(qty1.sub("-2m").scalar).toBe(4.5); - - qty2 = Qty("3cm"); - var result = qty1.sub(qty2); - expect(result.scalar).toBe(2.47); - expect(result.units()).toBe("m"); - - result = qty2.sub(qty1); - expect(result.scalar).toBe(-247); - expect(result.units()).toBe("cm"); - }); - - it("should fail to subtract unlike quantities", function () { - var qty1 = Qty("3m"); - var qty2 = Qty("2s"); - expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); - expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); - }); - - it("should fail to subtract inverse quantities", function () { - var qty1 = Qty("10S"); - var qty2 = qty1.inverse(); - expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); - expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); - - qty1 = Qty("10S"); - qty2 = Qty("0.1ohm"); - expect(function () { qty1.sub(qty2); }).toThrow("Incompatible units"); - expect(function () { qty2.sub(qty1); }).toThrow("Incompatible units"); - }); - - it("should multiply quantities", function () { - var qty1 = Qty("2.5m"); - var qty2 = Qty("3m"); - var result = qty1.mul(qty2); - expect(result.scalar).toBe(7.5); - expect(result.units()).toBe("m2"); - expect(result.kind()).toBe("area"); - - qty2 = Qty("3cm"); - result = qty1.mul(qty2); - expect(result.scalar).toBe(0.075); - expect(result.units()).toBe("m2"); - - result = qty2.mul(qty1); - expect(result.scalar).toBe(750); - expect(result.units()).toBe("cm2"); - - result = qty1.mul(3.5); - expect(result.scalar).toBe(8.75); - expect(result.units()).toBe("m"); - - result = qty1.mul(0); - expect(result.scalar).toBe(0); - expect(result.units()).toBe("m"); - - result = qty1.mul(Qty("0m")); - expect(result.scalar).toBe(0); - expect(result.units()).toBe("m2"); - - qty2 = Qty("1.458 m"); - result = qty1.mul(qty2); - expect(result.scalar).toBe(3.645); - expect(result.units()).toBe("m2"); - }); - - it("should multiply unlike quantities", function () { - var qty1 = Qty("2.5 m"); - var qty2 = Qty("3 N"); - - var result = qty1.mul(qty2); - expect(result.scalar).toBe(7.5); - - qty1 = Qty("2.5 m^2"); - qty2 = Qty("3 kg/m^2"); - - result = qty1.mul(qty2); - expect(result.scalar).toBe(7.5); - expect(result.units()).toBe("kg"); - }); - - it("should multiply inverse quantities", function () { - var qty1 = Qty("10S"); - var qty2 = Qty(".5S").inverse(); // 2/S - var qty3 = qty1.inverse(); // .1/S - - var result = qty1.mul(qty2); - expect(result.scalar).toBe(20); - expect(result.isUnitless()).toBe(true); - expect(result.units()).toBe(""); - // swapping operands should give the same outcome - result = qty2.mul(qty1); - expect(result.scalar).toBe(20); - expect(result.isUnitless()).toBe(true); - expect(result.units()).toBe(""); - - result = qty1.mul(qty3); - expect(result.scalar).toBe(1); - expect(result.isUnitless()).toBe(true); - expect(result.units()).toBe(""); - // swapping operands should give the same outcome - result = qty3.mul(qty1); - expect(result.scalar).toBe(1); - expect(result.isUnitless()).toBe(true); - expect(result.units()).toBe(""); - }); - - it("should divide quantities", function () { - var qty1 = Qty("2.5m"); - var qty2 = Qty("3m"); - var qty3 = Qty("0m"); - - expect(function () { qty1.div(qty3); }).toThrow("Divide by zero"); - expect(function () { qty1.div(0); }).toThrow("Divide by zero"); - expect(qty3.div(qty1).scalar).toBe(0); - - var result = qty1.div(qty2); - expect(result.scalar).toBe(2.5 / 3); - expect(result.units()).toBe(""); - expect(result.kind()).toBe("unitless"); - - var qty4 = Qty("3cm"); - result = qty1.div(qty4); - expect(result.scalar).toBe(2.5 / 0.03); - expect(result.units()).toBe(""); - - result = qty4.div(qty1); - expect(result.scalar).toBe(0.012); - expect(result.units()).toBe(""); - - result = qty1.div(3.5); - expect(result.scalar).toBe(2.5 / 3.5); - expect(result.units()).toBe("m"); - }); - - it("should divide unlike quantities", function () { - var qty1 = Qty("7.5kg"); - var qty2 = Qty("2.5m^2"); - - var result = qty1.div(qty2); - expect(result.scalar).toBe(3); - expect(result.units()).toBe("kg/m2"); - }); - - it("should divide inverse quantities", function () { - var qty1 = Qty("10 S"); - var qty2 = Qty(".5 S").inverse(); // 2/S - var qty3 = qty1.inverse(); // .1/S - - var result = qty1.div(qty2); - expect(result.scalar).toBe(5); - expect(result.units()).toBe("S2"); - - result = qty2.div(qty1); - expect(result.scalar).toBe(0.2); - expect(result.units()).toBe("1/S2"); - - result = qty1.div(qty3); - expect(result.scalar).toBe(100); - expect(result.units()).toBe("S2"); - - result = qty3.div(qty1); - expect(result.scalar).toBe(0.01); - expect(result.units()).toBe("1/S2"); - }); - - }); - - describe("math with temperatures", function () { - - it("should add temperature degrees", function () { - var qty = Qty("2degC"); - expect(qty.add("3degF").scalar).toBeCloseTo(11 / 3, 10); - expect(qty.add("-1degC").scalar).toBe(1); - - qty = Qty("2 degC"); - var result = qty.add("2 degF"); - expect(result.scalar).toBe(28 / 9); - expect(result.units()).toBe("degC"); - - qty = Qty("2degK"); - result = qty.add("3degC"); - expect(result.scalar).toBe(5); - expect(result.units()).toBe("degK"); - - qty = Qty("2degC"); - result = qty.add("2degK"); - expect(result.scalar).toBe(4); - expect(result.units()).toBe("degC"); - }); - - it("should not add two temperatures", function () { - var qty = Qty("2tempC"); - expect(function () { qty.add("1 tempF"); }).toThrow("Cannot add two temperatures"); - expect(function () { qty.add("1 tempC"); }).toThrow("Cannot add two temperatures"); - }); - - it("should add temperatures to degrees", function () { - var qty = Qty("2degC"); - var result = qty.add("3tempF"); - expect(result.scalar).toBe(33 / 5); - expect(result.units()).toBe("tempF"); - - result = qty.add("-1tempC"); - expect(result.scalar).toBe(1); - expect(result.units()).toBe("tempC"); - - qty = Qty("2 tempC"); - result = qty.add("2 degF"); - expect(result.scalar).toBe(28 / 9); - expect(result.units()).toBe("tempC"); - }); - - it("should subtract degrees from degrees", function () { - var qty = Qty("2degC"); - expect(qty.sub("1.5degK").scalar).toBe(0.5); - expect(qty.sub("-2degC").scalar).toBe(4); - expect(qty.sub("1degF").scalar).toBe(2 - 5 / 9); - expect(qty.sub("-1degC").scalar).toBe(3); - - var result = qty.sub("degC"); - expect(result.scalar).toBe(1); - expect(result.units()).toBe("degC"); - }); - - it("should subtract degrees from temperatures", function () { - var qty = Qty("2tempC"); - expect(qty.sub("1.5degK").scalar).toBe(0.5); - expect(qty.sub("-2degC").scalar).toBe(4); - expect(qty.sub("1degF").scalar).toBe(2 - 5 / 9); - expect(qty.sub("-1degC").scalar).toBe(3); - - var result = qty.sub("degC"); - expect(result.scalar).toBe(1); - expect(result.units()).toBe("tempC"); - }); - - it("should subtract temperatures from temperatures", function () { - var qty = Qty("2tempC"); - - var result = qty.sub("1.5tempK"); - expect(result.scalar).toBe(273.65); - expect(result.units()).toBe("degC"); - - result = qty.sub("-2tempC"); - expect(result.scalar).toBe(4); - expect(result.units()).toBe("degC"); - - result = qty.sub("32tempF"); - expect(result.scalar).toBe(2); - expect(result.units()).toBe("degC"); - }); - - it("should not subtract temperatures from degrees", function () { - var qty = Qty("2degC"); - expect(function () { qty.sub("1 tempF"); }).toThrow("Cannot subtract a temperature from a differential degree unit"); - expect(function () { qty.sub("1 tempC"); }).toThrow("Cannot subtract a temperature from a differential degree unit"); - }); - - it("should multiply temperature degrees", function () { - var qty = Qty("2degF"); - var result = qty.mul(3); - expect(result.scalar).toBe(6); - expect(result.units()).toBe("degF"); - - result = qty.mul("3degF"); - expect(result.scalar).toBe(6); - expect(result.units()).toBe("degF2"); - - // TODO: Should we convert degrees ("2 degK" to "degC") before we do the math? - qty = Qty("2degC"); - result = qty.mul("2degK"); - expect(result.scalar).toBe(4); - expect(result.units()).toBe("degC*degK"); - - qty = Qty("2degC"); - result = qty.mul("degF"); - expect(result.scalar).toBe(2); - expect(result.units()).toBe("degC*degF"); - }); - - it("should not multiply temperatures except by scalar", function () { - var qty = Qty("2tempF"); - expect(function () { qty.mul("1 tempC"); }).toThrow("Cannot multiply by temperatures"); - expect(function () { qty.mul("1 degC"); }).toThrow("Cannot multiply by temperatures"); - expect(function () { Qty("1 tempC*s"); }).toThrow("Cannot multiply by temperatures"); - - var result = qty.mul(2); - expect(result.scalar).toBe(4); - expect(result.units()).toBe("tempF"); - - result = Qty("2").mul(qty); - expect(result.scalar).toBe(4); - expect(result.units()).toBe("tempF"); - }); - - it("should multiply temperature degrees with unlike quantities", function () { - var qty1 = Qty("2.5 degF"); - var qty2 = Qty("3 m"); - - var result = qty1.mul(qty2); - expect(result.scalar).toBe(7.5); - - qty1 = Qty("2.5 degF"); - qty2 = Qty("3 kg/degF"); - - result = qty1.mul(qty2); - expect(result.scalar).toBe(7.5); - expect(result.units()).toBe("kg"); - }); - - it("should divide temperature degrees with unlike quantities", function () { - var qty1 = Qty("7.5degF"); - var qty2 = Qty("2.5m^2"); - - var result = qty1.div(qty2); - expect(result.scalar).toBe(3); - expect(result.units()).toBe("degF/m2"); - }); - - it("should divide temperature degree quantities", function () { - var qty = Qty("2.5 degF"); - - expect(function () { qty.div("0 degF"); }).toThrow("Divide by zero"); - expect(function () { qty.div(0); }).toThrow("Divide by zero"); - expect(Qty("0 degF").div(qty).scalar).toBe(0); - expect(Qty("0 degF").div(qty).units()).toBe(""); - - var result = qty.div("3 degF"); - expect(result.scalar).toBe(2.5 / 3); - expect(result.units()).toBe(""); - expect(result.kind()).toBe("unitless"); - - result = qty.div(3); - expect(result.scalar).toBe(2.5 / 3); - expect(result.units()).toBe("degF"); - expect(result.kind()).toBe("temperature"); - - // TODO: Should we convert "2 degC" to "degF" before we do the math? - result = qty.div("2 degC"); - expect(result.scalar).toBe(1.25); - expect(result.units()).toBe("degF/degC"); - }); - - it("should not divide with temperatures except by scalar", function () { - expect(function () { Qty("tempF").div("1 tempC"); }).toThrow("Cannot divide with temperatures"); - expect(function () { Qty("tempF").div("1 degC"); }).toThrow("Cannot divide with temperatures"); - expect(function () { Qty("2").div("tempF"); }).toThrow("Cannot divide with temperatures"); - expect(function () { Qty("2 tempF/s"); }).toThrow("Cannot divide with temperatures"); - expect(function () { Qty("2 s/tempF"); }).toThrow("Cannot divide with temperatures"); - - // inverse is division: 1/x - expect(function () { Qty("tempF").inverse(); }).toThrow("Cannot divide with temperatures"); - - var result = Qty("4 tempF").div(2); - expect(result.scalar).toBe(2); - expect(result.units()).toBe("tempF"); - }); - - }); - - describe("errors", function () { - it("should be instance of Qty.Error", function () { - try { - Qty("aa"); - } catch (e) { - expect(e instanceof Qty.Error).toBeTruthy(); - } - }); - }); - - describe("utility methods", function () { - - it("should accept string as parameter for compatibility tests", function () { - var qty = Qty("1 mm"); - - expect(qty.isCompatible("2 mm")).toBe(true); - expect(qty.isCompatible("2 mm^3")).toBe(false); - }); - - it("should return kind", function () { - var qty = Qty("1 mm"); - expect(qty.kind()).toBe("length"); - - qty = Qty("1 N"); - expect(qty.kind()).toBe("force"); - }); - - it("should know if a quantity is in base units", function () { - var qty = Qty("100 cm"); - expect(qty.isBase()).toBe(false); - - qty = Qty("1m"); - expect(qty.isBase()).toBe(true); - }); - - it("should return unit part of quantities", function () { - var qty = Qty("1"); - expect(qty.units()).toBe(""); - qty = Qty("1 /s"); - expect(qty.units()).toBe("1/s"); - qty = Qty("100 cm"); - expect(qty.units()).toBe("cm"); - qty = Qty("100 cm/s"); - expect(qty.units()).toBe("cm/s"); - qty = Qty("1 cm^2"); - expect(qty.units()).toBe("cm2"); - qty = Qty("1 cm^2/s^2"); - expect(qty.units()).toBe("cm2/s2"); - qty = Qty("1 cm^2*J^3/s^2*A^2"); - expect(qty.units()).toBe("cm2*J3/s2*A2"); - }); - - }); - - describe("toString", function () { - it("should generate readable human output", function () { - var qty = Qty("2m"); - expect(qty.toString()).toBe("2 m"); - expect(qty.toString("cm")).toBe("200 cm"); - expect(qty.toString("km")).toBe("0.002 km"); - expect(function () { qty.toString("A"); }).toThrow("Incompatible units"); - - qty = Qty("24.5m/s"); - expect(qty.toString()).toBe("24.5 m/s"); - expect(function () { qty.toString("m"); }).toThrow("Incompatible units"); - expect(qty.toString("km/h")).toBe("88.2 km/h"); - - qty = Qty("254kg/m^2"); - expect(qty.toString()).toBe("254 kg/m2"); - - qty = Qty("2"); - expect(qty.toString()).toBe("2"); - }); - - it("should round readable human output when max decimals is specified", function () { - var qty = (Qty("2m")).div(3); - expect(qty.toString("cm", 2)).toBe("66.67 cm"); - - qty = Qty("2.8m"); - expect(qty.toString("m", 0)).toBe("3 m"); - expect(qty.toString("cm", 0)).toBe("280 cm"); - qty = Qty("2.818m"); - expect(qty.toString("cm", 0)).toBe("282 cm"); - }); - - it("should round to max decimals", function () { - var qty = (Qty("2.987654321 m")); - - expect(qty.toString(3)).toBe("2.988 m"); - expect(qty.toString(0)).toBe("3 m"); - }); - - it("should round according to precision passed as quantity", function () { - var qty = Qty("5.17 ft"); - - expect(qty.toString(Qty("ft"))).toBe("5 ft"); - expect(qty.toString(Qty("2 ft"))).toBe("6 ft"); - expect(qty.toString(Qty("0.5 ft"))).toBe("5 ft"); - expect(qty.toString(Qty("0.1 ft"))).toBe("5.2 ft"); - expect(qty.toString(Qty("0.05 ft"))).toBe("5.15 ft"); - expect(qty.toString(Qty("0.01 ft"))).toBe("5.17 ft"); - expect(qty.toString(Qty("0.0001 ft"))).toBe("5.17 ft"); - }); - - it("should return same output with successive calls", function () { - var qty = Qty("123 cm3"); - expect(qty.toString("cm3", 0)).toBe("123 cm3"); - expect(qty.toString("cm3", 0)).toBe("123 cm3"); - }); - - it("should return identical output when called with no parameters or same units", function () { - var qty = Qty("123 cm3"); - expect(qty.toString()).toBe(qty.toString("cm3")); - }); - - }); - - describe("format", function () { - describe("provided default formatter", function () { - it("should be applied to output", function () { - var qty = (Qty("2.987654321 m")); - - expect(qty.format()).toBe("2.987654321 m"); - }); - }); - - describe("custom formatter", function () { - var roundingFormatter = function (maxDecimals: number) { - return function (scalar: number, units: string) { - var pow = Math.pow(10, maxDecimals); - var rounded = Math.round(scalar * pow) / pow; - - return rounded + " " + units; - }; - }; - - it("should be applied to output", function () { - var qty = (Qty("2.987654321 m")); - - expect(qty.format(roundingFormatter(3))).toBe("2.988 m"); - expect(qty.format(roundingFormatter(0))).toBe("3 m"); - }); - - it("should be applied after conversion to target units", function () { - var qty = (Qty("2m")).div(3); - expect(qty.format("cm", roundingFormatter(2))).toBe("66.67 cm"); - - var intRoundingFormatter = roundingFormatter(0); - qty = Qty("2.8m"); - expect(qty.format("m", intRoundingFormatter)).toBe("3 m"); - expect(qty.format("cm", intRoundingFormatter)).toBe("280 cm"); - qty = Qty("2.818m"); - expect(qty.format("cm", intRoundingFormatter)).toBe("282 cm"); - }); - - describe("globally set as default formatter", function () { - var previousFormatter: Qty.Formatter; - - beforeEach(function () { - previousFormatter = Qty.formatter; - Qty.formatter = roundingFormatter(3); - }); - - afterEach(function () { - // Restore previous formatter - Qty.formatter = previousFormatter; - }); - - it("should be applied when no formatter is passed", function () { - var qty = (Qty("2.987654321 m")); - - expect(qty.format()).toBe("2.988 m"); - }); - }); - }); - }); - - describe("precision rounding", function () { - it("should round according to precision passed as quantity with same units", function () { - var qty = Qty("5.17 ft"); - - expect(qty.toPrec(Qty("ft")).toString()).toBe("5 ft"); - expect(qty.toPrec(Qty("2 ft")).toString()).toBe("6 ft"); - expect(qty.toPrec(Qty("10 ft")).toString()).toBe("10 ft"); - expect(qty.toPrec(Qty("0.5 ft")).toString()).toBe("5 ft"); - expect(qty.toPrec(Qty("0.1 ft")).toString()).toBe("5.2 ft"); - expect(qty.toPrec(Qty("0.05 ft")).toString()).toBe("5.15 ft"); - expect(qty.toPrec(Qty("0.01 ft")).toString()).toBe("5.17 ft"); - expect(qty.toPrec(Qty("0.0001 ft")).toString()).toBe("5.17 ft"); - expect(qty.toPrec(Qty("0.25 ft")).toString()).toBe("5.25 ft"); - }); - - it("should allow string as precision parameter", function () { - var qty = Qty("5.17 ft"); - - expect(qty.toPrec("ft").toString()).toBe("5 ft"); - expect(qty.toPrec("0.5 ft").toString()).toBe("5 ft"); - expect(qty.toPrec("0.05 ft").toString()).toBe("5.15 ft"); - }); - - it("should round according to precision passed as quantity with different prefixes", function () { - var qty = Qty("6.3782 m"); - - expect(qty.toPrec(Qty("dm")).toString()).toBe("6.4 m"); - expect(qty.toPrec(Qty("cm")).toString()).toBe("6.38 m"); - expect(qty.toPrec(Qty("mm")).toString()).toBe("6.378 m"); - - expect(qty.toPrec(Qty("5 cm")).toString()).toBe("6.4 m"); - }); - - it("should round according to precision passed as quantity with different compatible units", function () { - var qty = Qty("1.146 MPa"); - expect(qty.toPrec(Qty("0.1 bar")).toString()).toBe("1.15 MPa"); - expect(qty.toPrec(Qty("0.01 MPa")).toString()).toBe("1.15 MPa"); - expect(qty.toPrec(Qty("dbar")).toString()).toBe("1.15 MPa"); - - // Tests below are mainly a safety net because not sure if there is - // any usefulness to do things like that - qty = Qty("5.171234568 ft"); - expect(qty.toPrec(Qty("m")).toString()).toBe("6.561679790026248 ft"); - expect(qty.toPrec(Qty("dm")).toString()).toBe("5.249343832020998 ft"); - expect(qty.toPrec(Qty("cm")).toString()).toBe("5.183727034120736 ft"); - expect(qty.toPrec(Qty("mm")).toString()).toBe("5.170603674540684 ft"); - }); - }); - - describe("mulSafe", function () { - it("should multiply while trying to avoid numerical errors", function () { - expect(Qty.mulSafe(0.1, 0.1)).toBe(0.01); - expect(Qty.mulSafe(1e-11, 123.456789)).toBe(1.23456789e-9); - expect(Qty.mulSafe(6e-12, 100000)).toBe(6e-7); - }); - }); - - describe("divSafe", function () { - it("should divide while trying to avoid numerical errors", function () { - expect(Qty.divSafe(0.000773, 0.000001)).toBe(773); - // TODO uncomment and fix - //expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2); - }); - }); - - describe("Qty.parse", function () { - it("should not throw if parsed argument is a string", function () { - expect(function () { Qty.parse("foo"); }).not.toThrow("Argument should be a string"); - }); - - it("should return parsed quantity when passing a valid quantity", function () { - expect((Qty.parse("2.5 m") instanceof Qty)).toBe(true); - }); - - it("should return null when passing an invalid quantity", function () { - expect(Qty.parse("aa")).toBeNull(); - }); - }); - - describe("Qty.swiftConverter", function () { - it("should return a function", function () { - expect(typeof Qty.swiftConverter("m/h", "ft/s")).toBe("function"); - }); - - it("should throw when passing incompatible units", function () { - expect(function () { Qty.swiftConverter("m", "s"); }).toThrow("Incompatible units"); - }); - - describe("converter", function () { - describe("single value", function () { - it("should convert value", function () { - // TODO Same test but with m/h -> ft/s triggers rounding issue - // (For the sake of speed, converter does not check and fix rounding issues) - var converter = Qty.swiftConverter("m/h", "m/s"); - - expect(converter(2500)).toEqual(Qty("2500 m/h").to("m/s").scalar); - }); - - it("should returned value unchanged when units are identical", function () { - var converter = Qty.swiftConverter("m/h", "m/h"); - - expect(converter(2500)).toEqual(2500); - }); - - it("should convert temperatures", function () { - var converter = Qty.swiftConverter("tempF", "tempC"); - - expect(converter(32)).toEqual(0); - }); - - it("should convert degrees", function () { - var converter = Qty.swiftConverter("degC", "degF"); - - expect(converter(10)).toEqual(18); - }); - }); - - describe("array of values", function () { - it("should be converted", function () { - var converter = Qty.swiftConverter("MPa", "bar"), - values = [250, 10, 15], - expected = [2500, 100, 150]; - - expect(converter(values)).toEqual(expected); - }); - }); - }); - }); - - describe("Qty.getKinds", function () { - it("should return an array of kind names", function () { - expect(Qty.getKinds()).toContain("resistance"); - }); - - it("should not contain duplicate kind names", function () { - var kinds = Qty.getKinds(); - var map: { [key: string]: number } = {}; - kinds.forEach(function (kind) { - map[kind] = 1; - }); - expect(kinds.length).toEqual(Object.keys(map).length); - }); - }); - - describe("Qty.getUnits", function () { - it("should return an array of units of kind", function () { - expect(Qty.getUnits("currency")).toContain("dollar"); - }); - it("should return an array of all units without arg", function () { - expect(Qty.getUnits()).toContain("sievert"); - }); - it("should throw unknown kind", function () { - expect(function () { Qty.getUnits('bogusKind'); }).toThrow("Kind not recognized"); - }); - }); - - describe("Qty.getAliases", function () { - it("should return array of alternative names for unit", function () { - expect(Qty.getAliases("m")).toContain("meter"); - expect(Qty.getAliases("meter")).toContain("metre"); - expect(Qty.getAliases("N")).toContain("newton"); - }); - }); - - describe("information", function () { - describe("bits and bytes", function () { - it("should have 'information' as kind", function () { - expect(Qty("3 b").kind()).toBe("information"); - expect(Qty("5 B").kind()).toBe("information"); - }); - - it("could be pluralized", function () { - expect(Qty("3 bits").eq(Qty("3 b"))).toBe(true); - expect(Qty("5 bytes").eq(Qty("5 B"))).toBe(true); - }); - }); - - describe("rate", function () { - it("should accept bps and Bps aliases", function () { - expect(Qty("3 bps").eq(Qty("3 b/s"))).toBe(true); - expect(Qty("5 Bps").eq(Qty("5 B/s"))).toBe(true); - }); - - it("should be parsed when prefixed", function () { - expect(Qty("3 kbps").eq(Qty("3 kb/s"))).toBe(true); - expect(Qty("5 MBps").eq(Qty("5 MB/s"))).toBe(true); - }); - - it("should have 'information_rate' as kind", function () { - expect(Qty("3 bps").kind()).toBe("information_rate"); - expect(Qty("5 Bps").kind()).toBe("information_rate"); - }); - }); - }); - - describe("non regression tests", function () { - describe("Wh (#38)", function () { - it("should be parsed", function () { - expect(Qty("Wh").eq(Qty("3600 J"))).toBe(true); - }); - - it("should be parsed when prefixed", function () { - expect(Qty("kWh").eq(Qty("1000 Wh"))).toBe(true); - }); - }); - - describe("Ah (#25)", function () { - it("should be parsed", function () { - expect(Qty("Ah").eq(Qty("3600 C"))).toBe(true); - }); - - it("should be parsed when prefixed", function () { - expect(Qty("mAh").eq(Qty("3.6 C"))).toBe(true); - }); - }); - - describe("Farad (#67)", function () { - it('should be equal to its definition', function () { - expect(Qty("1 F").eq(Qty("1 C").div(Qty("1 V")))).toBe(true); - }); - - it('should not be defined as base unit', function () { - var qty = Qty("F"); - - expect(qty.isBase()).toBe(false); - expect(qty.toBase().units()).toEqual("s4*A2/m2*kg"); - }); - - it('should be parsed when prefixed', function () { - var qty = Qty("100 nF"); - - expect(qty.eq(Qty("100 F").div(1e9))).toBe(true); - expect(qty.baseScalar).toEqual(1e-7); - }); - }); - }); -}); +var Val4 = Qty(Val1); \ No newline at end of file diff --git a/js-quantities/tsconfig.json b/js-quantities/tsconfig.json index c41d2d2197..8c2a810060 100644 --- a/js-quantities/tsconfig.json +++ b/js-quantities/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": true, + "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ "../" @@ -17,4 +17,4 @@ "index.d.ts", "js-quantities-tests.ts" ] -} +} \ No newline at end of file diff --git a/js-quantities/tslint.json b/js-quantities/tslint.json deleted file mode 100644 index f9e30021f4..0000000000 --- a/js-quantities/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../tslint.json" -} diff --git a/memoizee/index.d.ts b/memoizee/index.d.ts deleted file mode 100644 index 456641dc59..0000000000 --- a/memoizee/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Type definitions for memoizee 0.4 -// Project: https://github.com/medikoo/memoizee -// Definitions by: Juan Picado -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace memoizee { - interface Options { - length?: number; - maxAge?: number; - max?: number; - preFetch?: number | true; - promise?: boolean; - dispose?: (value: any) => void; - async?: boolean; - primitive?: boolean; - normalizer?: (value: any) => void; - resolvers?: Array<(arg: any) => any>; - } - - interface Memoized { - delete: F; - clear: F & (() => void); - } -} - -// tslint:disable:forbidden-types -declare function memoizee(f: F, options?: memoizee.Options): F & memoizee.Memoized; - -export = memoizee; diff --git a/memoizee/memoizee-tests.ts b/memoizee/memoizee-tests.ts deleted file mode 100644 index e8e73a2d6a..0000000000 --- a/memoizee/memoizee-tests.ts +++ /dev/null @@ -1,61 +0,0 @@ -import memoize = require('memoizee'); - -var fn = function (one: string, two?: number, three?: any) { /* ... */ }; - -let memoized = memoize(fn); -memoized('foo', 3, 'bar'); -memoized('foo', 3, 'bar'); -memoized = memoize(fn, { length: 2 }); -memoized('foo'); -memoized('foo', undefined); -memoized('foo', 3, {}); -memoized('foo', 3, 13); -memoized('foo', undefined); -memoized('foo', undefined); -memoized('foo', 3, {}); -memoized('foo', 3, 13); -memoized('foo', 3, 13); -memoized = memoize(fn, { primitive: true }); -memoized('/path/one'); -memoized('/path/one'); -memoized = memoize(fn, { dispose: function (value:number) { /*…*/ } }); -var foo3 = memoized('foo', 3); -var bar7 = memoized('bar', 7); -memoized.clear('foo', 3); // Dispose called with foo3 value -memoized.clear('bar', 7); // Dispose called with bar7 value -memoized.delete('foo', 0); -var mFn = memoize(function (hash:any) { - // body of memoized function -}, { normalizer: function (args:any) { - // args is arguments object as accessible in memoized function - return JSON.stringify(args[0]); -} }); - -mFn({ foo: 'bar' }); - -memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] }); -memoized(String(12), [1,2,3].length); -memoized("12", Number(true)); -memoized(String({ toString: function () { return "12"; } }), Number({})); - -{ - var afn = function (a:number, b:number) { - return new Promise(function (res) { res(a + b); }); - }; - let memoized = memoize(afn, { promise: true }); - memoized(3, 7); - memoized(3, 7); -} - -memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 }); - -memoized('foo', 3); -memoized('foo', 3); - -setTimeout(function () { - memoized('foo', 3); -}, 500); - -setTimeout(function () { - memoized('foo', 3); -}, 1300); diff --git a/memoizee/tsconfig.json b/memoizee/tsconfig.json deleted file mode 100644 index c2ccff1cab..0000000000 --- a/memoizee/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "memoizee-tests.ts" - ] -} diff --git a/memoizee/tslint.json b/memoizee/tslint.json deleted file mode 100644 index 2221e40e4a..0000000000 --- a/memoizee/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../tslint.json" } \ No newline at end of file diff --git a/react-intl/index.d.ts b/react-intl/index.d.ts index e0d9d3f623..80a2372e12 100644 --- a/react-intl/index.d.ts +++ b/react-intl/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-intl 2.2.0 // Project: http://formatjs.io/react/ -// Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi , Till Wolff +// Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -13,7 +13,7 @@ declare namespace ReactIntl { pluralRuleFunction?: (n: number, ord: boolean) => string; } - function injectIntl | React.StatelessComponent>(component: T): T; + function injectIntl(component: React.ComponentClass | React.StatelessComponent): React.ComponentClass; function addLocaleData(data: Locale[] | Locale): void; @@ -45,10 +45,6 @@ declare namespace ReactIntl { formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string; } - interface InjectedIntlProps { - intl?: InjectedIntl - } - namespace IntlComponent { interface DateTimeFormatProps { /* diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx index 160a37bc0f..cd484c17b4 100644 --- a/react-intl/react-intl-tests.tsx +++ b/react-intl/react-intl-tests.tsx @@ -9,20 +9,20 @@ import * as React from "react" import * as reactMixin from "react-mixin" import { - IntlProvider, - InjectedIntl, - addLocaleData, - hasLocaleData, - injectIntl, - intlShape, - defineMessages, - FormattedRelative, - FormattedMessage, - FormattedHTMLMessage, - FormattedNumber, - FormattedPlural, - FormattedDate, - FormattedTime +IntlProvider, +InjectedIntl, +addLocaleData, +hasLocaleData, +injectIntl, +intlShape, +defineMessages, +FormattedRelative, +FormattedMessage, +FormattedHTMLMessage, +FormattedNumber, +FormattedPlural, +FormattedDate, +FormattedTime } from "react-intl" import reactIntlEn = require("react-intl/locale-data/en"); @@ -31,8 +31,7 @@ addLocaleData(reactIntlEn); console.log(hasLocaleData("en")); interface SomeComponentProps { - className: string, - intl?: InjectedIntl + intl: InjectedIntl } class SomeComponent extends React.Component { @@ -48,14 +47,14 @@ class SomeComponent extends React.Component { const formattedPlural = intl.formatPlural(1, { one: "hai!" }); const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); - return

+ return
+ initialNow={new Date() } /> { many="haiku" /> { timeZoneName="short" /> { {(formattedNum: string) => ( {formattedNum} - )} - -
+ ) } + +
} } @@ -160,9 +159,9 @@ class TestApp extends React.Component<{}, {}> { "hello": "Hello, {name}!" }; return ( - - - + + + ); } } diff --git a/stripe/index.d.ts b/stripe/index.d.ts index fdfa1db96e..2f8c895298 100644 --- a/stripe/index.d.ts +++ b/stripe/index.d.ts @@ -1,10 +1,8 @@ -// Type definitions for stripe 0.0 +// Type definitions for stripe // Project: https://stripe.com/ // Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon , Adam Cmiel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare const Stripe: StripeStatic; - interface StripeStatic { applePay: StripeApplePay; setPublishableKey(key: string): void; @@ -51,8 +49,6 @@ interface StripeError { param?: string; } -type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'; - interface StripeCardData { object: string; last4: string; @@ -66,17 +62,18 @@ interface StripeCardData { address_state?: string; address_zip?: string; address_country?: string; - brand?: StripeCardDataBrand; createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; } -interface StripeBankAccount { - createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void; +interface StripeBankAccount +{ + createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void; validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; } -interface StripeBankTokenParams { +interface StripeBankTokenParams +{ country: string; currency: string; account_number: number | string; @@ -85,7 +82,8 @@ interface StripeBankTokenParams { account_holder_type: string; } -interface StripeBankTokenResponse { +interface StripeBankTokenResponse +{ id: string; bank_account: { country: string; @@ -102,7 +100,13 @@ interface StripeBankTokenResponse { error?: StripeError; } -interface StripeApplePay { +declare var Stripe: StripeStatic; +declare module "Stripe" { + export = StripeStatic; +} + +interface StripeApplePay +{ checkAvailability(resopnseHandler: (result: boolean) => void): void; buildSession(data: StripeApplePayPaymentRequest, onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void, @@ -113,7 +117,8 @@ type StripeApplePayBillingContactField = 'postalAddress' | 'name'; type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email'; type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; -interface StripeApplePayPaymentRequest { +interface StripeApplePayPaymentRequest +{ billingContact: StripeApplePayPaymentContact; countryCode: string; currencyCode: string; @@ -127,26 +132,30 @@ interface StripeApplePayPaymentRequest { } // https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types -interface StripeApplePayLineItem { +interface StripeApplePayLineItem +{ type: 'pending' | 'final'; label: string; amount: number; } -interface StripeApplePaySessionResult { +interface StripeApplePaySessionResult +{ token: StripeTokenResponse; shippingContact?: StripeApplePayPaymentContact; shippingMethod?: StripeApplePayShippingMethod; } -interface StripeApplePayShippingMethod { +interface StripeApplePayShippingMethod +{ label: string; detail: string; amount: number; identifier: string; } -interface StripeApplePayPaymentContact { +interface StripeApplePayPaymentContact +{ emailAddress: string; phoneNumber: string; givenName: string; @@ -157,7 +166,3 @@ interface StripeApplePayPaymentContact { postalCode: string; countryCode: string; } - -// The Stripe client side APIs are not made available to package managers for direct installation. -// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only -// A release date versioning schema is used to version these APIs. diff --git a/stripe/stripe-tests.ts b/stripe/stripe-tests.ts deleted file mode 100644 index 44aa09d216..0000000000 --- a/stripe/stripe-tests.ts +++ /dev/null @@ -1,25 +0,0 @@ -function success(card: StripeCardData) { - console.log(card.brand && card.brand.toString()); -} - -const cardNumber = '4242424242424242'; - -const isValid = Stripe.validateCardNumber(cardNumber); -if (isValid) { - const tokenData: StripeTokenData = { - number: cardNumber, - exp_month: 1, - exp_year: 2100, - cvc: '111' - }; - Stripe.card.createToken(tokenData, (status, response) => { - if (response.error) { - console.error(response.error.message); - if (response.error.param) { - console.error(response.error.param); - } - } else { - success(response.card); - } - }); -} diff --git a/stripe/tsconfig.json b/stripe/tsconfig.json index 7c33ab65c5..cdcaca971c 100644 --- a/stripe/tsconfig.json +++ b/stripe/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": true, + "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ "../" @@ -14,7 +14,6 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "stripe-tests.ts" + "index.d.ts" ] -} +} \ No newline at end of file diff --git a/stripe/tslint.json b/stripe/tslint.json deleted file mode 100644 index f9e30021f4..0000000000 --- a/stripe/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../tslint.json" -} From c201695d681efd3b5d19f36089a4071719ee8900 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 5 Jan 2017 14:09:00 -0800 Subject: [PATCH 117/181] Remove `webaudioapi`. It is included in `lib.d.ts`. --- webaudioapi/index.d.ts | 208 ------------------------ webaudioapi/readme.md | 18 --- webaudioapi/tsconfig.json | 20 --- webaudioapi/waa-tests.ts | 333 -------------------------------------- 4 files changed, 579 deletions(-) delete mode 100644 webaudioapi/index.d.ts delete mode 100644 webaudioapi/readme.md delete mode 100644 webaudioapi/tsconfig.json delete mode 100644 webaudioapi/waa-tests.ts diff --git a/webaudioapi/index.d.ts b/webaudioapi/index.d.ts deleted file mode 100644 index 21ecc842a0..0000000000 --- a/webaudioapi/index.d.ts +++ /dev/null @@ -1,208 +0,0 @@ -// Type definitions for Web Audio API -// Project: http://www.w3.org/TR/webaudio/ -// Definitions by: Baruch Berger , Kon , kubosho -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// -// This file refers to the latest published working draft (currently from 10 october 2013) http://www.w3.org/TR/2013/WD-webaudio-20131010/, not to be confused with the latest editor's draft http://webaudio.github.io/web-audio-api/ - -// DEPRECATED: use TypeScript 1.5.3 - -declare var webkitAudioContext: { - new (): AudioContext; -} - -declare var webkitOfflineAudioContext: { - new (numberOfChannels: number, length: number, sampleRate: number): OfflineAudioContext; -} - -declare enum ChannelCountMode { - 'max', - 'clamped-max', - 'explicit' -} - -declare enum ChannelInterpretation { - speakers, - discrete -} - -declare enum PanningModelType { - /** - * A simple and efficient spatialization algorithm using equal-power panning. - */ - equalpower, - - /** - * A higher quality spatialization algorithm using a convolution with measured impulse responses from human subjects. This panning method renders stereo output. - */ - HRTF -} - -declare enum DistanceModelType { - /** - * A linear distance model which calculates distanceGain according to: - * 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance) - */ - linear, - - /** - * An inverse distance model which calculates distanceGain according to: - * refDistance / (refDistance + rolloffFactor * (distance - refDistance)) - */ - inverse, - - /** - * An exponential distance model which calculates distanceGain according to: - * pow(distance / refDistance, -rolloffFactor) - */ - exponential -} - -declare enum BiquadFilterType { - /** - * A lowpass filter allows frequencies below the cutoff frequency to pass through and attenuates frequencies above the cutoff. It implements a standard second-order resonant lowpass filter with 12dB/octave rolloff. - * - * ## frequency - * The cutoff frequency - * ## Q - * Controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. Please note that for this filter type, this value is not a traditional Q, but is a resonance value in decibels. - * ## gain - * Not used in this filter type - */ - lowpass, - - /** - * A highpass filter is the opposite of a lowpass filter. Frequencies above the cutoff frequency are passed through, but frequencies below the cutoff are attenuated. It implements a standard second-order resonant highpass filter with 12dB/octave rolloff. - * - * ## frequency - * The cutoff frequency below which the frequencies are attenuated - * ## Q - * Controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. Please note that for this filter type, this value is not a traditional Q, but is a resonance value in decibels. - * ## gain - * Not used in this filter type - */ - highpass, - - /** - * A bandpass filter allows a range of frequencies to pass through and attenuates the frequencies below and above this frequency range. It implements a second-order bandpass filter. - * - * ## frequency - * The center of the frequency band - * ## Q - * Controls the width of the band. The width becomes narrower as the Q value increases. - * ## gain - * Not used in this filter type - */ - bandpass, - - /** - * The lowshelf filter allows all frequencies through, but adds a boost (or attenuation) to the lower frequencies. It implements a second-order lowshelf filter. - * - * ## frequency - * The upper limit of the frequences where the boost (or attenuation) is applied. - * ## Q - * Not used in this filter type. - * ## gain - * The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated. - */ - lowshelf, - - /** - * The highshelf filter is the opposite of the lowshelf filter and allows all frequencies through, but adds a boost to the higher frequencies. It implements a second-order highshelf filter - * - * ## frequency - * The lower limit of the frequences where the boost (or attenuation) is applied. - * ## Q - * Not used in this filter type. - * ## gain - * The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated. - */ - highshelf, - - /** - * The peaking filter allows all frequencies through, but adds a boost (or attenuation) to a range of frequencies. - * - * ## frequency - * The center frequency of where the boost is applied. - * ## Q - * Controls the width of the band of frequencies that are boosted. A large value implies a narrow width. - * ## gain - * The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated. - */ - peaking, - - /** - * The notch filter (also known as a band-stop or band-rejection filter) is the opposite of a bandpass filter. It allows all frequencies through, except for a set of frequencies. - * - * ## frequency - * The center frequency of where the notch is applied. - * ## Q - * Controls the width of the band of frequencies that are attenuated. A large value implies a narrow width. - * ## gain - * Not used in this filter type. - */ - notch, - - /** - * An allpass filter allows all frequencies through, but changes the phase relationship between the various frequencies. It implements a second-order allpass filter - * - * ## frequency - * The frequency where the center of the phase transition occurs. Viewed another way, this is the frequency with maximal group delay. - * ## Q - * Controls how sharp the phase transition is at the center frequency. A larger value implies a sharper transition and a larger group delay. - * ## gain - * Not used in this filter type. - */ - allpass -} - -declare enum OverSampleType { - 'none', - '2x', - '4x' -} - -declare enum OscillatorType { - sine, - square, - sawtooth, - triangle, - custom -} - -interface AudioContextConstructor { - new(): AudioContext; -} - -interface Window { - AudioContext: AudioContextConstructor; -} - -interface AudioContext { - createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode; -} - -interface MediaStreamAudioSourceNode extends AudioNode { - -} - -interface MediaStreamAudioDestinationNode extends AudioNode { - stream: MediaStream; -} - -interface AudioBuffer { - copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; - - copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; -} - -interface AudioNode { - disconnect(destination: AudioNode): void; -} - -interface AudioContext { - suspend(): Promise; - resume(): Promise; - close(): Promise; - createMediaStreamDestination(): MediaStreamAudioDestinationNode; -} diff --git a/webaudioapi/readme.md b/webaudioapi/readme.md deleted file mode 100644 index 0b30648116..0000000000 --- a/webaudioapi/readme.md +++ /dev/null @@ -1,18 +0,0 @@ -# Web Audio API Definition Notes - - -## The Web Audio API - - -The Web Audio API is currently still under development. However WebKit browsers have started an implementation of the proposed specifications which can be found at: [w3.org](http://www.w3.org/TR/webaudio/). - -The WebKit nightly builds try to keep up with the editors draft version of the specifications [w3.org](https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html) - - -### Adding the reference to your project - - - -or - - diff --git a/webaudioapi/tsconfig.json b/webaudioapi/tsconfig.json deleted file mode 100644 index 6bd7ac4c89..0000000000 --- a/webaudioapi/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "waa-tests.ts" - ] -} \ No newline at end of file diff --git a/webaudioapi/waa-tests.ts b/webaudioapi/waa-tests.ts deleted file mode 100644 index d5727d531b..0000000000 --- a/webaudioapi/waa-tests.ts +++ /dev/null @@ -1,333 +0,0 @@ -// http://www.w3.org/TR/2012/WD-webaudio-20121213/ - - - -declare var dogBarkingBuffer: any; - -()=>{ - var context = new AudioContext(); - - function playSound() { - var source = context.createBufferSource(); - source.buffer = dogBarkingBuffer; - source.connect(context.destination); - source.start(0); - } -}; - -declare var manTalkingBuffer: any; -declare var footstepsBuffer: any; - -()=>{ - - var context = new AudioContext(); - - // Create the effects nodes. - var lowpassFilter = context.createBiquadFilter(); - var waveShaper = context.createWaveShaper(); - var panner = context.createPanner(); - var compressor = context.createDynamicsCompressor(); - var reverb = context.createConvolver(); - - // Create master wet and dry. - var masterDry = context.createGain(); - var masterWet = context.createGain(); - - // Connect final compressor to final destination. - compressor.connect(context.destination); - - // Connect master dry and wet to compressor. - masterDry.connect(compressor); - masterWet.connect(compressor); - - // Connect reverb to master wet. - reverb.connect(masterWet); - - // Create a few sources. - var source1 = context.createBufferSource(); - var source2 = context.createBufferSource(); - var source3 = context.createOscillator(); - - source1.buffer = manTalkingBuffer; - source2.buffer = footstepsBuffer; - source3.frequency.value = 440; - - // Connect source1 - var dry1 = context.createGain(); - var wet1 = context.createGain(); - source1.connect(lowpassFilter); - lowpassFilter.connect(dry1); - lowpassFilter.connect(wet1); - dry1.connect(masterDry); - wet1.connect(reverb); - source1.loop = true; - source1.loopStart = 0; - source1.loopEnd = 300; - - // Connect source2 - var dry2 = context.createGain(); - var wet2 = context.createGain(); - source2.connect(waveShaper); - waveShaper.connect(dry2); - waveShaper.connect(wet2); - dry2.connect(masterDry); - wet2.connect(reverb); - - // Connect source3 - var dry3 = context.createGain(); - var wet3 = context.createGain(); - source3.connect(panner); - panner.connect(dry3); - panner.connect(wet3); - dry3.connect(masterDry); - wet3.connect(reverb); - - // Start the sources now. - source1.start(0); - // MEMO: should be when parameter is 0 - // http://www.w3.org/TR/webaudio/#AudioBufferSourceNode - source2.start(); - source3.start(0); - - // Stop the sources are 2 seconds later. - source1.stop(2); - // MEMO: should be when parameter is 0 - // http://www.w3.org/TR/webaudio/#AudioBufferSourceNode - source2.stop(); - source3.stop(2); -}; - -()=>{ - var context: AudioContext; - var compressor: DynamicsCompressorNode; - var gainNode1: GainNode; - var streamingAudioSource: MediaElementAudioSourceNode; - - // Initial setup of the "long-lived" part of the routing graph - function setupAudioContext() { - context = new AudioContext(); - - compressor = context.createDynamicsCompressor(); - gainNode1 = context.createGain(); - - // Create a streaming audio source. - var audioElement = document.getElementById('audioTagID'); - streamingAudioSource = context.createMediaElementSource(audioElement); - streamingAudioSource.connect(gainNode1); - - gainNode1.connect(compressor); - compressor.connect(context.destination); - } - - // Later in response to some user action (typically mouse or key event) - // a one-shot sound can be played. - function playSound() { - var oneShotSound = context.createBufferSource(); - oneShotSound.buffer = dogBarkingBuffer; - - // Create a filter, panner, and gain node. - var lowpass = context.createBiquadFilter(); - var panner = context.createPanner(); - var gainNode2 = context.createGain(); - - // Make connections - oneShotSound.connect(lowpass); - lowpass.connect(panner); - panner.connect(gainNode2); - gainNode2.connect(compressor); - - // Play 0.75 seconds from now (to play immediately pass in 0) - oneShotSound.start(context.currentTime + 0.75); - } -}; - - -()=>{ - var param:AudioParam; - - var t0 = 0; - var t1 = 0.1; - var t2 = 0.2; - var t3 = 0.3; - var t4 = 0.4; - var t5 = 0.6; - var t6 = 0.7; - var t7 = 1.0; - - var curveLength = 44100; - var curve = new Float32Array(curveLength); - for (var i = 0; i < curveLength; ++i) - curve[i] = Math.sin(Math.PI * i / curveLength); - - param.setValueAtTime(0.2, t0); - param.setValueAtTime(0.3, t1); - param.setValueAtTime(0.4, t2); - param.linearRampToValueAtTime(1, t3); - param.linearRampToValueAtTime(0.15, t4); - param.exponentialRampToValueAtTime(0.75, t5); - param.exponentialRampToValueAtTime(0.05, t6); - param.setValueCurveAtTime(curve, t6, t7 - t6); - -}; - -()=>{ - var param: AudioParam; - - var t0 = 0; - var t1 = 0.1; - var t2 = 0.2; - var t3 = 0.3; - var t4 = 0.4; - var t5 = 0.6; - var t6 = 0.7; - var t7 = 1.0; - - var curveLength = 44100; - var curve = new Float32Array(curveLength); - for (var i = 0; i < curveLength; ++i) - curve[i] = Math.sin(Math.PI * i / curveLength); - - param.setValueAtTime(0.2, t0); - param.setValueAtTime(0.3, t1); - param.setValueAtTime(0.4, t2); - param.linearRampToValueAtTime(1, t3); - param.linearRampToValueAtTime(0.15, t4); - param.exponentialRampToValueAtTime(0.75, t5); - param.exponentialRampToValueAtTime(0.05, t6); - param.setValueCurveAtTime(curve, t6, t7 - t6); -}; - - -()=>{ - var context: AudioContext; - var filterNode: AudioNode; - - var mediaElement = document.getElementById('mediaElementID'); - var sourceNode = context.createMediaElementSource(mediaElement); - sourceNode.connect(filterNode); -}; - -()=>{ - - // Setup routing graph - function setupRoutingGraph() { - var context = new AudioContext(); - - var compressor = context.createDynamicsCompressor(); - - // Send1 effect - var reverb = context.createConvolver(); - // Convolver impulse response may be set here or later - - // Send2 effect - var delay = context.createDelay(); - - // Connect final compressor to final destination - compressor.connect(context.destination); - - // Connect sends 1 & 2 through effects to main mixer - var s1 = context.createGain(); - reverb.connect(s1); - s1.connect(compressor); - - var s2 = context.createGain(); - delay.connect(s2); - s2.connect(compressor); - - // Create a couple of sources - var source1 = context.createBufferSource(); - var source2 = context.createBufferSource(); - source1.buffer = manTalkingBuffer; - source2.buffer = footstepsBuffer; - - // Connect source1 - var g1_1 = context.createGain(); - var g2_1 = context.createGain(); - var g3_1 = context.createGain(); - source1.connect(g1_1); - source1.connect(g2_1); - source1.connect(g3_1); - g1_1.connect(compressor); - g2_1.connect(reverb); - g3_1.connect(delay); - - // Connect source2 - var g1_2 = context.createGain(); - var g2_2 = context.createGain(); - var g3_2 = context.createGain(); - source2.connect(g1_2); - source2.connect(g2_2); - source2.connect(g3_2); - g1_2.connect(compressor); - g2_2.connect(reverb); - g3_2.connect(delay); - - // We now have explicit control over all the volumes g1_1, g2_1, ..., s1, s2 - g2_1.gain.value = 0.2; // For example, set source1 reverb gain - - // Because g2_1.gain is an "AudioParam", - // an automation curve could also be attached to it. - // A "mixing board" UI could be created in canvas or WebGL controlling these gains. - } -}; - -()=>{ - var context: AudioContext; - var compressor: DynamicsCompressorNode; - var gainNode1: GainNode; - var streamingAudioSource: MediaElementAudioSourceNode; - - // Initial setup of the "long-lived" part of the routing graph - function setupAudioContext() { - context = new AudioContext(); - - compressor = context.createDynamicsCompressor(); - gainNode1 = context.createGain(); - - // Create a streaming audio source. - var audioElement = document.getElementById('audioTagID'); - streamingAudioSource = context.createMediaElementSource(audioElement); - streamingAudioSource.connect(gainNode1); - - gainNode1.connect(compressor); - compressor.connect(context.destination); - } - - // Later in response to some user action (typically mouse or key event) - // a one-shot sound can be played. - function playSound() { - var oneShotSound = context.createBufferSource(); - oneShotSound.buffer = dogBarkingBuffer; - - // Create a filter, panner, and gain node. - var lowpass = context.createBiquadFilter(); - var panner = context.createPanner(); - var gainNode2 = context.createGain(); - - // Make connections - oneShotSound.connect(lowpass); - lowpass.connect(panner); - panner.connect(gainNode2); - gainNode2.connect(compressor); - - // Play 0.75 seconds from now (to play immediately pass in 0) - oneShotSound.start(context.currentTime + 0.75); - } -}; - -()=>{ - var context = new webkitOfflineAudioContext(1, 2, 44100.5); - context.oncomplete = function(e) { - context.createBufferSource().buffer; - } - context.startRendering(); -} - -// Test automatic type inference of the audio processing event handler -() => { - var context = new AudioContext(); - var recorder = context.createScriptProcessor(2048, 1, 1); - recorder.onaudioprocess = function (e) { - e.inputBuffer; - }; -} From 433a6c50448f2a4ecd2a91f1ce0a6d3e36f8eb9c Mon Sep 17 00:00:00 2001 From: eejdoowad Date: Thu, 5 Jan 2017 17:23:30 -0500 Subject: [PATCH 118/181] changed tabs to spaces --- chrome/index.d.ts | 9858 ++++++++++++++++++++++----------------------- 1 file changed, 4929 insertions(+), 4929 deletions(-) diff --git a/chrome/index.d.ts b/chrome/index.d.ts index 3414eee560..2822dd421e 100644 --- a/chrome/index.d.ts +++ b/chrome/index.d.ts @@ -22,89 +22,89 @@ interface Window { * Important: This API works only on Chrome OS. */ declare namespace chrome.accessibilityFeatures { - interface AccessibilityFeaturesGetArg { - /** Optional. Whether to return the value that applies to the incognito session (default false). */ - incognito?: boolean; - } + interface AccessibilityFeaturesGetArg { + /** Optional. Whether to return the value that applies to the incognito session (default false). */ + incognito?: boolean; + } - interface AccessibilityFeaturesCallbackArg { - /** The value of the setting. */ - value: any; - /** - * One of - * • not_controllable: cannot be controlled by any extension - * • controlled_by_other_extensions: controlled by extensions with higher precedence - * • controllable_by_this_extension: can be controlled by this extension - * • controlled_by_this_extension: controlled by this extension - */ - levelOfControl: string; - /** Optional. Whether the effective value is specific to the incognito session. This property will only be present if the incognito property in the details parameter of get() was true. */ - incognitoSpecific?: boolean; - } + interface AccessibilityFeaturesCallbackArg { + /** The value of the setting. */ + value: any; + /** + * One of + * • not_controllable: cannot be controlled by any extension + * • controlled_by_other_extensions: controlled by extensions with higher precedence + * • controllable_by_this_extension: can be controlled by this extension + * • controlled_by_this_extension: controlled by this extension + */ + levelOfControl: string; + /** Optional. Whether the effective value is specific to the incognito session. This property will only be present if the incognito property in the details parameter of get() was true. */ + incognitoSpecific?: boolean; + } - interface AccessibilityFeaturesSetArg { - /** - * The value of the setting. - * Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type. - */ - value: any; - /** - * Optional. - * The scope of the ChromeSetting. One of - * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), - * • regular_only: setting for the regular profile only (not inherited by the incognito profile), - * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), - * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). - */ - scope?: string; - } + interface AccessibilityFeaturesSetArg { + /** + * The value of the setting. + * Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type. + */ + value: any; + /** + * Optional. + * The scope of the ChromeSetting. One of + * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), + * • regular_only: setting for the regular profile only (not inherited by the incognito profile), + * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), + * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). + */ + scope?: string; + } - interface AccessibilityFeaturesClearArg { - /** - * Optional. - * The scope of the ChromeSetting. One of - * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), - * • regular_only: setting for the regular profile only (not inherited by the incognito profile), - * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), - * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). - */ - scope?: string; - } + interface AccessibilityFeaturesClearArg { + /** + * Optional. + * The scope of the ChromeSetting. One of + * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), + * • regular_only: setting for the regular profile only (not inherited by the incognito profile), + * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), + * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). + */ + scope?: string; + } - interface AccessibilityFeaturesSetting { - /** - * Gets the value of a setting. - * @param details Which setting to consider. - * @param callback The callback parameter should be a function that looks like this: - * function(object details) {...}; - */ - get(details: AccessibilityFeaturesGetArg, callback: (details: AccessibilityFeaturesCallbackArg) => void): void; - /** - * Sets the value of a setting. - * @param details Which setting to change. - * @param callback Called at the completion of the set operation. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - set(details: AccessibilityFeaturesSetArg, callback?: () => void): void; - /** - * Clears the setting, restoring any default value. - * @param details Which setting to clear. - * @param callback Called at the completion of the clear operation. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - clear(details: AccessibilityFeaturesClearArg, callback?: () => void): void; - } + interface AccessibilityFeaturesSetting { + /** + * Gets the value of a setting. + * @param details Which setting to consider. + * @param callback The callback parameter should be a function that looks like this: + * function(object details) {...}; + */ + get(details: AccessibilityFeaturesGetArg, callback: (details: AccessibilityFeaturesCallbackArg) => void): void; + /** + * Sets the value of a setting. + * @param details Which setting to change. + * @param callback Called at the completion of the set operation. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + set(details: AccessibilityFeaturesSetArg, callback?: () => void): void; + /** + * Clears the setting, restoring any default value. + * @param details Which setting to clear. + * @param callback Called at the completion of the clear operation. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + clear(details: AccessibilityFeaturesClearArg, callback?: () => void): void; + } - var spokenFeedback: AccessibilityFeaturesSetting; - var largeCursor: AccessibilityFeaturesSetting; - var stickyKeys: AccessibilityFeaturesSetting; - var highContrast: AccessibilityFeaturesSetting; - var screenMagnifier: AccessibilityFeaturesSetting; - var autoclick: AccessibilityFeaturesSetting; - var virtualKeyboard: AccessibilityFeaturesSetting; - var animationPolicy: AccessibilityFeaturesSetting; + var spokenFeedback: AccessibilityFeaturesSetting; + var largeCursor: AccessibilityFeaturesSetting; + var stickyKeys: AccessibilityFeaturesSetting; + var highContrast: AccessibilityFeaturesSetting; + var screenMagnifier: AccessibilityFeaturesSetting; + var autoclick: AccessibilityFeaturesSetting; + var virtualKeyboard: AccessibilityFeaturesSetting; + var animationPolicy: AccessibilityFeaturesSetting; } //////////////////// @@ -117,80 +117,80 @@ declare namespace chrome.accessibilityFeatures { */ declare namespace chrome.alarms { interface AlarmCreateInfo { - /** Optional. Length of time in minutes after which the onAlarm event should fire. */ + /** Optional. Length of time in minutes after which the onAlarm event should fire. */ delayInMinutes?: number; - /** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */ + /** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */ periodInMinutes?: number; - /** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */ + /** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */ when?: number; } interface Alarm { - /** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */ + /** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */ periodInMinutes?: number; - /** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */ + /** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */ scheduledTime: number; - /** Name of this alarm. */ + /** Name of this alarm. */ name: string; } interface AlarmEvent extends chrome.events.Event<(alarm: Alarm) => void> {} - /** - * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. - * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute. - * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire. - * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes. - */ + /** + * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. + * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute. + * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire. + * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes. + */ export function create(alarmInfo: AlarmCreateInfo): void; - /** - * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. - * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute. - * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire. - * @param name Optional name to identify this alarm. Defaults to the empty string. - * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes. - */ + /** + * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. + * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute. + * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire. + * @param name Optional name to identify this alarm. Defaults to the empty string. + * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes. + */ export function create(name: string, alarmInfo: AlarmCreateInfo): void; - /** - * Gets an array of all the alarms. - * @param callback The callback parameter should be a function that looks like this: - * function(array of Alarm alarms) {...}; - */ + /** + * Gets an array of all the alarms. + * @param callback The callback parameter should be a function that looks like this: + * function(array of Alarm alarms) {...}; + */ export function getAll(callback: (alarms: Alarm[]) => void): void; - /** - * Clears all alarms. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; - */ + /** + * Clears all alarms. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(boolean wasCleared) {...}; + */ export function clearAll(callback?: (wasCleared: boolean) => void): void; - /** - * Clears the alarm with the given name. - * @param name The name of the alarm to clear. Defaults to the empty string. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; - */ + /** + * Clears the alarm with the given name. + * @param name The name of the alarm to clear. Defaults to the empty string. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(boolean wasCleared) {...}; + */ export function clear(name?: string, callback?: (wasCleared: boolean) => void): void; - /** - * Clears the alarm without a name. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; - */ + /** + * Clears the alarm without a name. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(boolean wasCleared) {...}; + */ export function clear(callback: (wasCleared: boolean) => void): void; - /** - * Retrieves details about the specified alarm. - * @param callback The callback parameter should be a function that looks like this: - * function( Alarm alarm) {...}; - */ + /** + * Retrieves details about the specified alarm. + * @param callback The callback parameter should be a function that looks like this: + * function( Alarm alarm) {...}; + */ export function get(callback: (alarm: Alarm) => void): void; - /** - * Retrieves details about the specified alarm. - * @param name The name of the alarm to get. Defaults to the empty string. - * @param callback The callback parameter should be a function that looks like this: - * function( Alarm alarm) {...}; - */ + /** + * Retrieves details about the specified alarm. + * @param name The name of the alarm to get. Defaults to the empty string. + * @param callback The callback parameter should be a function that looks like this: + * function( Alarm alarm) {...}; + */ export function get(name: string, callback: (alarm: Alarm) => void): void; - /** Fired when an alarm has elapsed. Useful for event pages. */ + /** Fired when an alarm has elapsed. Useful for event pages. */ var onAlarm: AlarmEvent; } @@ -214,12 +214,12 @@ declare namespace chrome.browser { */ export function openTab(options: Options, callback: () => void): void; - /** - * Opens a new tab in a browser window associated with the current application - * and Chrome profile. If no browser window for the Chrome profile is opened, - * a new one is opened prior to creating the new tab. Since Chrome 42 only. - * @param options Configures how the tab should be opened. - */ + /** + * Opens a new tab in a browser window associated with the current application + * and Chrome profile. If no browser window for the Chrome profile is opened, + * a new one is opened prior to creating the new tab. Since Chrome 42 only. + * @param options Configures how the tab should be opened. + */ export function openTab(options: Options): void; } @@ -232,30 +232,30 @@ declare namespace chrome.browser { * Permissions: "bookmarks" */ declare namespace chrome.bookmarks { - /** A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder. */ + /** A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder. */ interface BookmarkTreeNode { - /** Optional. The 0-based position of this node within its parent folder. */ + /** Optional. The 0-based position of this node within its parent folder. */ index?: number; - /** Optional. When this node was created, in milliseconds since the epoch (new Date(dateAdded)). */ + /** Optional. When this node was created, in milliseconds since the epoch (new Date(dateAdded)). */ dateAdded?: number; - /** The text displayed for the node. */ + /** The text displayed for the node. */ title: string; - /** Optional. The URL navigated to when a user clicks the bookmark. Omitted for folders. */ + /** Optional. The URL navigated to when a user clicks the bookmark. Omitted for folders. */ url?: string; - /** Optional. When the contents of this folder last changed, in milliseconds since the epoch. */ + /** Optional. When the contents of this folder last changed, in milliseconds since the epoch. */ dateGroupModified?: number; - /** The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted. */ + /** The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted. */ id: string; - /** Optional. The id of the parent folder. Omitted for the root node. */ + /** Optional. The id of the parent folder. Omitted for the root node. */ parentId?: string; - /** Optional. An ordered list of children of this node. */ + /** Optional. An ordered list of children of this node. */ children?: BookmarkTreeNode[]; - /** - * Optional. - * Since Chrome 37. - * Indicates the reason why this node is unmodifiable. The managed value indicates that this node was configured by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user and the extension (default). - */ - unmodifiable?: any; + /** + * Optional. + * Since Chrome 37. + * Indicates the reason why this node is unmodifiable. The managed value indicates that this node was configured by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user and the extension (default). + */ + unmodifiable?: any; } interface BookmarkRemoveInfo { @@ -293,134 +293,134 @@ declare namespace chrome.bookmarks { interface BookmarkChildrenReordered extends chrome.events.Event<(id: string, reorderInfo: BookmarkReorderInfo) => void> {} - interface BookmarkSearchQuery { - query?: string; - url?: string; - title?: string; - } + interface BookmarkSearchQuery { + query?: string; + url?: string; + title?: string; + } - interface BookmarkCreateArg { - /** Optional. Defaults to the Other Bookmarks folder. */ - parentId?: string; - index?: number; - title?: string; - url?: string; - } + interface BookmarkCreateArg { + /** Optional. Defaults to the Other Bookmarks folder. */ + parentId?: string; + index?: number; + title?: string; + url?: string; + } - interface BookmarkDestinationArg { - parentId?: string; - index?: number; - } + interface BookmarkDestinationArg { + parentId?: string; + index?: number; + } - interface BookmarkChangesArg { - title?: string; - url?: string; - } + interface BookmarkChangesArg { + title?: string; + url?: string; + } - /** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */ + /** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */ var MAX_WRITE_OPERATIONS_PER_HOUR: number; - /** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */ + /** @deprecated since Chrome 38. Bookmark write operations are no longer limited by Chrome. */ var MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; - /** - * Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties. - * @param query A string of words and quoted phrases that are matched against bookmark URLs and titles. - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties. + * @param query A string of words and quoted phrases that are matched against bookmark URLs and titles. + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function search(query: string, callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties. - * @param query An object with one or more of the properties query, url, and title specified. Bookmarks matching all specified properties will be produced. - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ - export function search(query: BookmarkSearchQuery, callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Retrieves the entire Bookmarks hierarchy. - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties. + * @param query An object with one or more of the properties query, url, and title specified. Bookmarks matching all specified properties will be produced. + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ + export function search(query: BookmarkSearchQuery, callback: (results: BookmarkTreeNode[]) => void): void; + /** + * Retrieves the entire Bookmarks hierarchy. + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function getTree(callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Retrieves the recently added bookmarks. - * @param numberOfItems The maximum number of items to return. - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Retrieves the recently added bookmarks. + * @param numberOfItems The maximum number of items to return. + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function getRecent(numberOfItems: number, callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Retrieves the specified BookmarkTreeNode. - * @param id A single string-valued id - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Retrieves the specified BookmarkTreeNode. + * @param id A single string-valued id + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function get(id: string, callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Retrieves the specified BookmarkTreeNode. - * @param idList An array of string-valued ids - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Retrieves the specified BookmarkTreeNode. + * @param idList An array of string-valued ids + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function get(idList: string[], callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( BookmarkTreeNode result) {...}; - */ + /** + * Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( BookmarkTreeNode result) {...}; + */ export function create(bookmark: BookmarkCreateArg, callback?: (result: BookmarkTreeNode) => void): void; - /** - * Moves the specified BookmarkTreeNode to the provided location. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( BookmarkTreeNode result) {...}; - */ + /** + * Moves the specified BookmarkTreeNode to the provided location. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( BookmarkTreeNode result) {...}; + */ export function move(id: string, destination: BookmarkDestinationArg, callback?: (result: BookmarkTreeNode) => void): void; - /** - * Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged. Note: Currently, only 'title' and 'url' are supported. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( BookmarkTreeNode result) {...}; - */ + /** + * Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged. Note: Currently, only 'title' and 'url' are supported. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( BookmarkTreeNode result) {...}; + */ export function update(id: string, changes: BookmarkChangesArg, callback?: (result: BookmarkTreeNode) => void): void; - /** - * Removes a bookmark or an empty bookmark folder. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Removes a bookmark or an empty bookmark folder. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function remove(id: string, callback?: Function): void; - /** - * Retrieves the children of the specified BookmarkTreeNode id. - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Retrieves the children of the specified BookmarkTreeNode id. + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function getChildren(id: string, callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Since Chrome 14. - * Retrieves part of the Bookmarks hierarchy, starting at the specified node. - * @param id The ID of the root of the subtree to retrieve. - * @param callback The callback parameter should be a function that looks like this: - * function(array of BookmarkTreeNode results) {...}; - */ + /** + * Since Chrome 14. + * Retrieves part of the Bookmarks hierarchy, starting at the specified node. + * @param id The ID of the root of the subtree to retrieve. + * @param callback The callback parameter should be a function that looks like this: + * function(array of BookmarkTreeNode results) {...}; + */ export function getSubTree(id: string, callback: (results: BookmarkTreeNode[]) => void): void; - /** - * Recursively removes a bookmark folder. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Recursively removes a bookmark folder. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeTree(id: string, callback?: Function): void; - /** Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents. */ + /** Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents. */ var onRemoved: BookmarkRemovedEvent; - /** Fired when a bookmark import session is ended. */ + /** Fired when a bookmark import session is ended. */ var onImportEnded: BookmarkImportEndedEvent; - /** Fired when a bookmark import session is begun. Expensive observers should ignore onCreated updates until onImportEnded is fired. Observers should still handle other notifications immediately. */ + /** Fired when a bookmark import session is begun. Expensive observers should ignore onCreated updates until onImportEnded is fired. Observers should still handle other notifications immediately. */ var onImportBegan: BookmarkImportBeganEvent; - /** Fired when a bookmark or folder changes. Note: Currently, only title and url changes trigger this. */ + /** Fired when a bookmark or folder changes. Note: Currently, only title and url changes trigger this. */ var onChanged: BookmarkChangedEvent; - /** Fired when a bookmark or folder is moved to a different parent folder. */ + /** Fired when a bookmark or folder is moved to a different parent folder. */ var onMoved: BookmarkMovedEvent; - /** Fired when a bookmark or folder is created. */ + /** Fired when a bookmark or folder is created. */ var onCreated: BookmarkCreatedEvent; - /** Fired when the children of a folder have changed their order due to the order being sorted in the UI. This is not called as a result of a move(). */ + /** Fired when the children of a folder have changed their order due to the order being sorted in the UI. This is not called as a result of a move(). */ var onChildrenReordered: BookmarkChildrenReordered; } @@ -434,105 +434,105 @@ declare namespace chrome.bookmarks { */ declare namespace chrome.browserAction { interface BadgeBackgroundColorDetails { - /** An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is [255, 0, 0, 255]. Can also be a string with a CSS value, with opaque red being #FF0000 or #F00. */ + /** An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is [255, 0, 0, 255]. Can also be a string with a CSS value, with opaque red being #FF0000 or #F00. */ color: any; - /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ + /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number; } interface BadgeTextDetails { - /** Any number of characters can be passed, but only about four can fit in the space. */ + /** Any number of characters can be passed, but only about four can fit in the space. */ text: string; - /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ + /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number; } interface TitleDetails { - /** The string the browser action should display when moused over. */ + /** The string the browser action should display when moused over. */ title: string; - /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ + /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number; } interface TabDetails { - /** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */ + /** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */ tabId?: number; } interface TabIconDetails { - /** Optional. Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' */ + /** Optional. Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' */ path?: any; - /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ + /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number; - /** Optional. Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' */ + /** Optional. Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' */ imageData?: ImageData; } interface PopupDetails { - /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ + /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number; - /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ + /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ popup: string; } interface BrowserClickedEvent extends chrome.events.Event<(tab: chrome.tabs.Tab) => void> {} - /** - * Since Chrome 22. - * Enables the browser action for a tab. By default, browser actions are enabled. - * @param tabId The id of the tab for which you want to modify the browser action. - */ + /** + * Since Chrome 22. + * Enables the browser action for a tab. By default, browser actions are enabled. + * @param tabId The id of the tab for which you want to modify the browser action. + */ export function enable(tabId?: number): void; - /** Sets the background color for the badge. */ + /** Sets the background color for the badge. */ export function setBadgeBackgroundColor(details: BadgeBackgroundColorDetails): void; - /** Sets the badge text for the browser action. The badge is displayed on top of the icon. */ + /** Sets the badge text for the browser action. The badge is displayed on top of the icon. */ export function setBadgeText(details: BadgeTextDetails): void; - /** Sets the title of the browser action. This shows up in the tooltip. */ + /** Sets the title of the browser action. This shows up in the tooltip. */ export function setTitle(details: TitleDetails): void; - /** - * Since Chrome 19. - * Gets the badge text of the browser action. If no tab is specified, the non-tab-specific badge text is returned. - * @param callback The callback parameter should be a function that looks like this: - * function(string result) {...}; - */ + /** + * Since Chrome 19. + * Gets the badge text of the browser action. If no tab is specified, the non-tab-specific badge text is returned. + * @param callback The callback parameter should be a function that looks like this: + * function(string result) {...}; + */ export function getBadgeText(details: TabDetails, callback: (result: string) => void): void; - /** Sets the html document to be opened as a popup when the user clicks on the browser action's icon. */ + /** Sets the html document to be opened as a popup when the user clicks on the browser action's icon. */ export function setPopup(details: PopupDetails): void; - /** - * Since Chrome 22. - * Disables the browser action for a tab. - * @param tabId The id of the tab for which you want to modify the browser action. - */ + /** + * Since Chrome 22. + * Disables the browser action for a tab. + * @param tabId The id of the tab for which you want to modify the browser action. + */ export function disable(tabId?: number): void; - /** - * Since Chrome 19. - * Gets the title of the browser action. - * @param callback The callback parameter should be a function that looks like this: - * function(string result) {...}; - */ + /** + * Since Chrome 19. + * Gets the title of the browser action. + * @param callback The callback parameter should be a function that looks like this: + * function(string result) {...}; + */ export function getTitle(details: TabDetails, callback: (result: string) => void): void; - /** - * Since Chrome 19. - * Gets the background color of the browser action. - * @param callback The callback parameter should be a function that looks like this: - * function( ColorArray result) {...}; - */ + /** + * Since Chrome 19. + * Gets the background color of the browser action. + * @param callback The callback parameter should be a function that looks like this: + * function( ColorArray result) {...}; + */ export function getBadgeBackgroundColor(details: TabDetails, callback: (result: number[]) => void): void; - /** - * Since Chrome 19. - * Gets the html document set as the popup for this browser action. - * @param callback The callback parameter should be a function that looks like this: - * function(string result) {...}; - */ + /** + * Since Chrome 19. + * Gets the html document set as the popup for this browser action. + * @param callback The callback parameter should be a function that looks like this: + * function(string result) {...}; + */ export function getPopup(details: TabDetails, callback: (result: string) => void): void; - /** - * Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function setIcon(details: TabIconDetails, callback?: Function): void; - /** Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. */ + /** Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. */ var onClicked: BrowserClickedEvent; } @@ -546,171 +546,171 @@ declare namespace chrome.browserAction { */ declare namespace chrome.browsingData { interface OriginTypes { - /** Optional. Websites that have been installed as hosted applications (be careful!). */ + /** Optional. Websites that have been installed as hosted applications (be careful!). */ protectedWeb?: boolean; - /** Optional. Extensions and packaged applications a user has installed (be _really_ careful!). */ + /** Optional. Extensions and packaged applications a user has installed (be _really_ careful!). */ extension?: boolean; - /** Optional. Normal websites. */ + /** Optional. Normal websites. */ unprotectedWeb?: boolean; } - /** Options that determine exactly what data will be removed. */ + /** Options that determine exactly what data will be removed. */ interface RemovalOptions { - /** - * Optional. - * Since Chrome 21. - * An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that you really want to remove application data before adding 'protectedWeb' or 'extensions'. - */ + /** + * Optional. + * Since Chrome 21. + * An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that you really want to remove application data before adding 'protectedWeb' or 'extensions'. + */ originTypes?: OriginTypes; - /** Optional. Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the getTime method of the JavaScript Date object). If absent, defaults to 0 (which would remove all browsing data). */ + /** Optional. Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the getTime method of the JavaScript Date object). If absent, defaults to 0 (which would remove all browsing data). */ since?: number; } - /** - * Since Chrome 27. - * A set of data types. Missing data types are interpreted as false. - */ + /** + * Since Chrome 27. + * A set of data types. Missing data types are interpreted as false. + */ interface DataTypeSet { - /** Optional. Websites' WebSQL data. */ + /** Optional. Websites' WebSQL data. */ webSQL?: boolean; - /** Optional. Websites' IndexedDB data. */ + /** Optional. Websites' IndexedDB data. */ indexedDB?: boolean; - /** Optional. The browser's cookies. */ + /** Optional. The browser's cookies. */ cookies?: boolean; - /** Optional. Stored passwords. */ + /** Optional. Stored passwords. */ passwords?: boolean; - /** Optional. Server-bound certificates. */ + /** Optional. Server-bound certificates. */ serverBoundCertificates?: boolean; - /** Optional. The browser's download list. */ + /** Optional. The browser's download list. */ downloads?: boolean; - /** Optional. The browser's cache. Note: when removing data, this clears the entire cache: it is not limited to the range you specify. */ + /** Optional. The browser's cache. Note: when removing data, this clears the entire cache: it is not limited to the range you specify. */ cache?: boolean; - /** Optional. Websites' appcaches. */ + /** Optional. Websites' appcaches. */ appcache?: boolean; - /** Optional. Websites' file systems. */ + /** Optional. Websites' file systems. */ fileSystems?: boolean; - /** Optional. Plugins' data. */ + /** Optional. Plugins' data. */ pluginData?: boolean; - /** Optional. Websites' local storage data. */ + /** Optional. Websites' local storage data. */ localStorage?: boolean; - /** Optional. The browser's stored form data. */ + /** Optional. The browser's stored form data. */ formData?: boolean; - /** Optional. The browser's history. */ + /** Optional. The browser's history. */ history?: boolean; - /** - * Optional. - * Since Chrome 39. - * Service Workers. - */ - serviceWorkers?: boolean; + /** + * Optional. + * Since Chrome 39. + * Service Workers. + */ + serviceWorkers?: boolean; } - interface SettingsCallback { - options: RemovalOptions; - /** All of the types will be present in the result, with values of true if they are both selected to be removed and permitted to be removed, otherwise false. */ - dataToRemove: DataTypeSet; - /** All of the types will be present in the result, with values of true if they are permitted to be removed (e.g., by enterprise policy) and false if not. */ - dataRemovalPermitted: DataTypeSet; - } + interface SettingsCallback { + options: RemovalOptions; + /** All of the types will be present in the result, with values of true if they are both selected to be removed and permitted to be removed, otherwise false. */ + dataToRemove: DataTypeSet; + /** All of the types will be present in the result, with values of true if they are permitted to be removed (e.g., by enterprise policy) and false if not. */ + dataRemovalPermitted: DataTypeSet; + } - /** - * Since Chrome 26. - * Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here. - * @param callback The callback parameter should be a function that looks like this: - * function(object result) {...}; - */ - export function settings(callback: (result: SettingsCallback) => void): void; - /** - * Clears plugins' data. - * @param callback Called when plugins' data has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Since Chrome 26. + * Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here. + * @param callback The callback parameter should be a function that looks like this: + * function(object result) {...}; + */ + export function settings(callback: (result: SettingsCallback) => void): void; + /** + * Clears plugins' data. + * @param callback Called when plugins' data has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removePluginData(options: RemovalOptions, callback?: () => void): void; - /** - * Clears the browser's stored form data (autofill). - * @param callback Called when the browser's form data has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the browser's stored form data (autofill). + * @param callback Called when the browser's form data has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeFormData(options: RemovalOptions, callback?: () => void): void; - /** - * Clears websites' file system data. - * @param callback Called when websites' file systems have been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears websites' file system data. + * @param callback Called when websites' file systems have been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeFileSystems(options: RemovalOptions, callback?: () => void): void; - /** - * Clears various types of browsing data stored in a user's profile. - * @param dataToRemove The set of data types to remove. - * @param callback Called when deletion has completed. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears various types of browsing data stored in a user's profile. + * @param dataToRemove The set of data types to remove. + * @param callback Called when deletion has completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function remove(options: RemovalOptions, dataToRemove: DataTypeSet, callback?: () => void): void; - /** - * Clears the browser's stored passwords. - * @param callback Called when the browser's passwords have been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the browser's stored passwords. + * @param callback Called when the browser's passwords have been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removePasswords(options: RemovalOptions, callback?: () => void): void; - /** - * Clears the browser's cookies and server-bound certificates modified within a particular timeframe. - * @param callback Called when the browser's cookies and server-bound certificates have been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the browser's cookies and server-bound certificates modified within a particular timeframe. + * @param callback Called when the browser's cookies and server-bound certificates have been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeCookies(options: RemovalOptions, callback?: () => void): void; - /** - * Clears websites' WebSQL data. - * @param callback Called when websites' WebSQL databases have been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears websites' WebSQL data. + * @param callback Called when websites' WebSQL databases have been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeWebSQL(options: RemovalOptions, callback?: () => void): void; - /** - * Clears websites' appcache data. - * @param callback Called when websites' appcache data has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears websites' appcache data. + * @param callback Called when websites' appcache data has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeAppcache(options: RemovalOptions, callback?: () => void): void; - /** - * Clears the browser's list of downloaded files (not the downloaded files themselves). - * @param callback Called when the browser's list of downloaded files has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the browser's list of downloaded files (not the downloaded files themselves). + * @param callback Called when the browser's list of downloaded files has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeDownloads(options: RemovalOptions, callback?: () => void): void; - /** - * Clears websites' local storage data. - * @param callback Called when websites' local storage has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears websites' local storage data. + * @param callback Called when websites' local storage has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeLocalStorage(options: RemovalOptions, callback?: () => void): void; - /** - * Clears the browser's cache. - * @param callback Called when the browser's cache has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the browser's cache. + * @param callback Called when the browser's cache has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeCache(options: RemovalOptions, callback?: () => void): void; - /** - * Clears the browser's history. - * @param callback Called when the browser's history has cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the browser's history. + * @param callback Called when the browser's history has cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeHistory(options: RemovalOptions, callback?: () => void): void; - /** - * Clears websites' IndexedDB data. - * @param callback Called when websites' IndexedDB data has been cleared. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears websites' IndexedDB data. + * @param callback Called when websites' IndexedDB data has been cleared. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeIndexedDB(options: RemovalOptions, callback?: () => void): void; } @@ -723,26 +723,26 @@ declare namespace chrome.browsingData { * Manifest: "commands": {...} */ declare namespace chrome.commands { - interface Command { - /** Optional. The name of the Extension Command */ - name?: string; - /** Optional. The Extension Command description */ - description?: string; - /** Optional. The shortcut active for this command, or blank if not active. */ - shortcut?: string; - } + interface Command { + /** Optional. The name of the Extension Command */ + name?: string; + /** Optional. The Extension Command description */ + description?: string; + /** Optional. The shortcut active for this command, or blank if not active. */ + shortcut?: string; + } interface CommandEvent extends chrome.events.Event<(command: string) => void> {} - /** - * Returns all the registered extension commands for this extension and their shortcut (if active). - * @param callback Called to return the registered commands. - * If you specify the callback parameter, it should be a function that looks like this: - * function(array of Command commands) {...}; - */ - export function getAll(callback: (commands: Command[]) => void): void; + /** + * Returns all the registered extension commands for this extension and their shortcut (if active). + * @param callback Called to return the registered commands. + * If you specify the callback parameter, it should be a function that looks like this: + * function(array of Command commands) {...}; + */ + export function getAll(callback: (commands: Command[]) => void): void; - /** Fired when a registered command is activated using a keyboard shortcut. */ + /** Fired when a registered command is activated using a keyboard shortcut. */ var onCommand: CommandEvent; } @@ -756,180 +756,180 @@ declare namespace chrome.commands { */ declare namespace chrome.contentSettings { interface ClearDetails { - /** - * Optional. - * Where to clear the setting (default: regular). - * The scope of the ContentSetting. One of - * * regular: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere), - * * incognito_session_only: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular settings). - */ + /** + * Optional. + * Where to clear the setting (default: regular). + * The scope of the ContentSetting. One of + * * regular: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere), + * * incognito_session_only: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular settings). + */ scope?: string; } interface SetDetails { - /** Optional. The resource identifier for the content type. */ + /** Optional. The resource identifier for the content type. */ resourceIdentifier?: ResourceIdentifier; - /** The setting applied by this rule. See the description of the individual ContentSetting objects for the possible values. */ + /** The setting applied by this rule. See the description of the individual ContentSetting objects for the possible values. */ setting: any; - /** Optional. The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see Content Setting Patterns. */ + /** Optional. The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see Content Setting Patterns. */ secondaryPattern?: string; - /** Optional. Where to set the setting (default: regular). */ + /** Optional. Where to set the setting (default: regular). */ scope?: string; - /** The pattern for the primary URL. For details on the format of a pattern, see Content Setting Patterns. */ + /** The pattern for the primary URL. For details on the format of a pattern, see Content Setting Patterns. */ primaryPattern: string; } interface GetDetails { - /** Optional. The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs. */ + /** Optional. The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs. */ secondaryUrl?: string; - /** Optional. A more specific identifier of the type of content for which the settings should be retrieved. */ + /** Optional. A more specific identifier of the type of content for which the settings should be retrieved. */ resourceIdentifier?: ResourceIdentifier; - /** Optional. Whether to check the content settings for an incognito session. (default false) */ + /** Optional. Whether to check the content settings for an incognito session. (default false) */ incognito?: boolean; - /** The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type. */ + /** The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type. */ primaryUrl: string; } interface ReturnedDetails { - /** The content setting. See the description of the individual ContentSetting objects for the possible values. */ + /** The content setting. See the description of the individual ContentSetting objects for the possible values. */ setting: any; } interface ContentSetting { - /** - * Clear all content setting rules set by this extension. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clear all content setting rules set by this extension. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ clear(details: ClearDetails, callback?: () => void): void; - /** - * Applies a new content setting rule. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Applies a new content setting rule. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ set(details: SetDetails, callback?: () => void): void; - /** - * @param callback The callback parameter should be a function that looks like this: - * function(array of ResourceIdentifier resourceIdentifiers) {...}; - * Parameter resourceIdentifiers: A list of resource identifiers for this content type, or undefined if this content type does not use resource identifiers. - */ + /** + * @param callback The callback parameter should be a function that looks like this: + * function(array of ResourceIdentifier resourceIdentifiers) {...}; + * Parameter resourceIdentifiers: A list of resource identifiers for this content type, or undefined if this content type does not use resource identifiers. + */ getResourceIdentifiers(callback: (resourceIdentifiers?: ResourceIdentifier[]) => void): void; - /** - * Gets the current content setting for a given pair of URLs. - * @param callback The callback parameter should be a function that looks like this: - * function(object details) {...}; - */ + /** + * Gets the current content setting for a given pair of URLs. + * @param callback The callback parameter should be a function that looks like this: + * function(object details) {...}; + */ get(details: GetDetails, callback: (details: ReturnedDetails) => void): void; } - /** The only content type using resource identifiers is contentSettings.plugins. For more information, see Resource Identifiers. */ + /** The only content type using resource identifiers is contentSettings.plugins. For more information, see Resource Identifiers. */ interface ResourceIdentifier { - /** The resource identifier for the given content type. */ + /** The resource identifier for the given content type. */ id: string; - /** Optional. A human readable description of the resource. */ + /** Optional. A human readable description of the resource. */ description?: string; } - /** - * Whether to allow cookies and other local data to be set by websites. One of - * allow: Accept cookies, - * block: Block cookies, - * session_only: Accept cookies only for the current session. - * Default is allow. - * The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame. - */ + /** + * Whether to allow cookies and other local data to be set by websites. One of + * allow: Accept cookies, + * block: Block cookies, + * session_only: Accept cookies only for the current session. + * Default is allow. + * The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame. + */ var cookies: ContentSetting; - /** - * Whether to allow sites to show pop-ups. One of - * allow: Allow sites to show pop-ups, - * block: Don't allow sites to show pop-ups. - * Default is block. - * The primary URL is the URL of the top-level frame. The secondary URL is not used. - */ + /** + * Whether to allow sites to show pop-ups. One of + * allow: Allow sites to show pop-ups, + * block: Don't allow sites to show pop-ups. + * Default is block. + * The primary URL is the URL of the top-level frame. The secondary URL is not used. + */ var popups: ContentSetting; - /** - * Whether to run JavaScript. One of - * allow: Run JavaScript, - * block: Don't run JavaScript. - * Default is allow. - * The primary URL is the URL of the top-level frame. The secondary URL is not used. - */ + /** + * Whether to run JavaScript. One of + * allow: Run JavaScript, + * block: Don't run JavaScript. + * Default is allow. + * The primary URL is the URL of the top-level frame. The secondary URL is not used. + */ var javascript: ContentSetting; - /** - * Whether to allow sites to show desktop notifications. One of - * allow: Allow sites to show desktop notifications, - * block: Don't allow sites to show desktop notifications, - * ask: Ask when a site wants to show desktop notifications. - * Default is ask. - * The primary URL is the URL of the document which wants to show the notification. The secondary URL is not used. - */ + /** + * Whether to allow sites to show desktop notifications. One of + * allow: Allow sites to show desktop notifications, + * block: Don't allow sites to show desktop notifications, + * ask: Ask when a site wants to show desktop notifications. + * Default is ask. + * The primary URL is the URL of the document which wants to show the notification. The secondary URL is not used. + */ var notifications: ContentSetting; - /** - * Whether to run plugins. One of - * allow: Run plugins automatically, - * block: Don't run plugins automatically, - * detect_important_content: Only run automatically those plugins that are detected as the website's main content. - * Default is allow. - * The primary URL is the URL of the top-level frame. The secondary URL is not used. - */ + /** + * Whether to run plugins. One of + * allow: Run plugins automatically, + * block: Don't run plugins automatically, + * detect_important_content: Only run automatically those plugins that are detected as the website's main content. + * Default is allow. + * The primary URL is the URL of the top-level frame. The secondary URL is not used. + */ var plugins: ContentSetting; - /** - * Whether to show images. One of - * allow: Show images, - * block: Don't show images. - * Default is allow. - * The primary URL is the URL of the top-level frame. The secondary URL is the URL of the image. - */ + /** + * Whether to show images. One of + * allow: Show images, + * block: Don't show images. + * Default is allow. + * The primary URL is the URL of the top-level frame. The secondary URL is the URL of the image. + */ var images: ContentSetting; - /** - * Since Chrome 42. - * Whether to allow Geolocation. One of - * allow: Allow sites to track your physical location, - * block: Don't allow sites to track your physical location, - * ask: Ask before allowing sites to track your physical location. - * Default is ask. - * The primary URL is the URL of the document which requested location data. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL). - */ - var location: ContentSetting; - /** - * Since Chrome 42. - * Whether to allow sites to toggle the fullscreen mode. One of - * allow: Allow sites to toggle the fullscreen mode, - * ask: Ask when a site wants to toggle the fullscreen mode. - * Default is ask. - * The primary URL is the URL of the document which requested to toggle the fullscreen mode. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL). - */ - var fullscreen: ContentSetting; - /** - * Since Chrome 42. - * Whether to allow sites to disable the mouse cursor. One of - * allow: Allow sites to disable the mouse cursor, - * block: Don't allow sites to disable the mouse cursor, - * ask: Ask when a site wants to disable the mouse cursor. - * Default is ask. - * The primary URL is the URL of the top-level frame. The secondary URL is not used. - */ - var mouselock: ContentSetting; - /** - * Since Chrome 42. - * Whether to allow sites to run plugins unsandboxed. One of - * allow: Allow sites to run plugins unsandboxed, - * block: Don't allow sites to run plugins unsandboxed, - * ask: Ask when a site wants to run a plugin unsandboxed. - * Default is ask. - * The primary URL is the URL of the top-level frame. The secondary URL is not used. - */ - var unsandboxedPlugins: ContentSetting; - /** - * Since Chrome 42. - * Whether to allow sites to download multiple files automatically. One of - * allow: Allow sites to download multiple files automatically, - * block: Don't allow sites to download multiple files automatically, - * ask: Ask when a site wants to download files automatically after the first file. - * Default is ask. - * The primary URL is the URL of the top-level frame. The secondary URL is not used. - */ - var automaticDownloads: ContentSetting; + /** + * Since Chrome 42. + * Whether to allow Geolocation. One of + * allow: Allow sites to track your physical location, + * block: Don't allow sites to track your physical location, + * ask: Ask before allowing sites to track your physical location. + * Default is ask. + * The primary URL is the URL of the document which requested location data. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL). + */ + var location: ContentSetting; + /** + * Since Chrome 42. + * Whether to allow sites to toggle the fullscreen mode. One of + * allow: Allow sites to toggle the fullscreen mode, + * ask: Ask when a site wants to toggle the fullscreen mode. + * Default is ask. + * The primary URL is the URL of the document which requested to toggle the fullscreen mode. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL). + */ + var fullscreen: ContentSetting; + /** + * Since Chrome 42. + * Whether to allow sites to disable the mouse cursor. One of + * allow: Allow sites to disable the mouse cursor, + * block: Don't allow sites to disable the mouse cursor, + * ask: Ask when a site wants to disable the mouse cursor. + * Default is ask. + * The primary URL is the URL of the top-level frame. The secondary URL is not used. + */ + var mouselock: ContentSetting; + /** + * Since Chrome 42. + * Whether to allow sites to run plugins unsandboxed. One of + * allow: Allow sites to run plugins unsandboxed, + * block: Don't allow sites to run plugins unsandboxed, + * ask: Ask when a site wants to run a plugin unsandboxed. + * Default is ask. + * The primary URL is the URL of the top-level frame. The secondary URL is not used. + */ + var unsandboxedPlugins: ContentSetting; + /** + * Since Chrome 42. + * Whether to allow sites to download multiple files automatically. One of + * allow: Allow sites to download multiple files automatically, + * block: Don't allow sites to download multiple files automatically, + * ask: Ask when a site wants to download files automatically after the first file. + * Default is ask. + * The primary URL is the URL of the top-level frame. The secondary URL is not used. + */ + var automaticDownloads: ContentSetting; } //////////////////// @@ -942,104 +942,104 @@ declare namespace chrome.contentSettings { */ declare namespace chrome.contextMenus { interface OnClickData { - /** - * Optional. - * Since Chrome 35. - * The text for the context selection, if any. - */ + /** + * Optional. + * Since Chrome 35. + * The text for the context selection, if any. + */ selectionText?: string; - /** - * Optional. - * Since Chrome 35. - * A flag indicating the state of a checkbox or radio item after it is clicked. - */ + /** + * Optional. + * Since Chrome 35. + * A flag indicating the state of a checkbox or radio item after it is clicked. + */ checked?: boolean; - /** - * Since Chrome 35. - * The ID of the menu item that was clicked. - */ + /** + * Since Chrome 35. + * The ID of the menu item that was clicked. + */ menuItemId: any; - /** - * Optional. - * Since Chrome 35. - * The URL of the frame of the element where the context menu was clicked, if it was in a frame. - */ + /** + * Optional. + * Since Chrome 35. + * The URL of the frame of the element where the context menu was clicked, if it was in a frame. + */ frameUrl?: string; - /** - * Since Chrome 35. - * A flag indicating whether the element is editable (text input, textarea, etc.). - */ + /** + * Since Chrome 35. + * A flag indicating whether the element is editable (text input, textarea, etc.). + */ editable: boolean; - /** - * Optional. - * Since Chrome 35. - * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. - */ + /** + * Optional. + * Since Chrome 35. + * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. + */ mediaType?: string; - /** - * Optional. - * Since Chrome 35. - * A flag indicating the state of a checkbox or radio item before it was clicked. - */ + /** + * Optional. + * Since Chrome 35. + * A flag indicating the state of a checkbox or radio item before it was clicked. + */ wasChecked?: boolean; - /** - * Since Chrome 35. - * The URL of the page where the menu item was clicked. This property is not set if the click occured in a context where there is no current page, such as in a launcher context menu. - */ + /** + * Since Chrome 35. + * The URL of the page where the menu item was clicked. This property is not set if the click occured in a context where there is no current page, such as in a launcher context menu. + */ pageUrl: string; - /** - * Optional. - * Since Chrome 35. - * If the element is a link, the URL it points to. - */ + /** + * Optional. + * Since Chrome 35. + * If the element is a link, the URL it points to. + */ linkUrl?: string; - /** - * Optional. - * Since Chrome 35. - * The parent ID, if any, for the item clicked. - */ + /** + * Optional. + * Since Chrome 35. + * The parent ID, if any, for the item clicked. + */ parentMenuItemId?: any; - /** - * Optional. - * Since Chrome 35. - * Will be present for elements with a 'src' URL. - */ + /** + * Optional. + * Since Chrome 35. + * Will be present for elements with a 'src' URL. + */ srcUrl?: string; } interface CreateProperties { - /** Optional. Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns. */ + /** Optional. Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns. */ documentUrlPatterns?: string[]; - /** Optional. The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items. */ + /** Optional. The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items. */ checked?: boolean; - /** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */ + /** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */ title?: string; - /** Optional. List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ + /** Optional. List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ contexts?: string[]; - /** - * Optional. - * Since Chrome 20. - * Whether this context menu item is enabled or disabled. Defaults to true. - */ + /** + * Optional. + * Since Chrome 20. + * Whether this context menu item is enabled or disabled. Defaults to true. + */ enabled?: boolean; - /** Optional. Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags. */ + /** Optional. Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags. */ targetUrlPatterns?: string[]; - /** - * Optional. - * A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for chrome.contextMenus.onClicked. - * @param info Information sent when a context menu item is clicked. - * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions. - */ + /** + * Optional. + * A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for chrome.contextMenus.onClicked. + * @param info Information sent when a context menu item is clicked. + * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions. + */ onclick?: (info: OnClickData, tab: chrome.tabs.Tab) => void; - /** Optional. The ID of a parent menu item; this makes the item a child of a previously added item. */ + /** Optional. The ID of a parent menu item; this makes the item a child of a previously added item. */ parentId?: any; - /** Optional. The type of menu item. Defaults to 'normal' if not specified. */ + /** Optional. The type of menu item. Defaults to 'normal' if not specified. */ type?: string; - /** - * Optional. - * Since Chrome 21. - * The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension. - */ + /** + * Optional. + * Since Chrome 21. + * The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension. + */ id?: string; } @@ -1048,76 +1048,76 @@ declare namespace chrome.contextMenus { checked?: boolean; title?: string; contexts?: string[]; - /** Optional. Since Chrome 20. */ + /** Optional. Since Chrome 20. */ enabled?: boolean; targetUrlPatterns?: string[]; onclick?: Function; - /** Optional. Note: You cannot change an item to be a child of one of its own descendants. */ + /** Optional. Note: You cannot change an item to be a child of one of its own descendants. */ parentId?: any; type?: string; } interface MenuClickedEvent extends chrome.events.Event<(info: OnClickData, tab?: chrome.tabs.Tab) => void> {} - /** - * Since Chrome 38. - * The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored. - */ - var ACTION_MENU_TOP_LEVEL_LIMIT: number; + /** + * Since Chrome 38. + * The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored. + */ + var ACTION_MENU_TOP_LEVEL_LIMIT: number; /** - * Removes all context menu items added by this extension. - * @param callback Called when removal is complete. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + * Removes all context menu items added by this extension. + * @param callback Called when removal is complete. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeAll(callback?: () => void): void; - /** - * Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.runtime.lastError). - * @param callback Called when the item has been created in the browser. If there were any problems creating the item, details will be available in chrome.runtime.lastError. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.runtime.lastError). + * @param callback Called when the item has been created in the browser. If there were any problems creating the item, details will be available in chrome.runtime.lastError. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function create(createProperties: CreateProperties, callback?: () => void): void; - /** - * Updates a previously created context menu item. - * @param id The ID of the item to update. - * @param updateProperties The properties to update. Accepts the same values as the create function. - * @param callback Called when the context menu has been updated. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Updates a previously created context menu item. + * @param id The ID of the item to update. + * @param updateProperties The properties to update. Accepts the same values as the create function. + * @param callback Called when the context menu has been updated. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function update(id: string, updateProperties: UpdateProperties, callback?: () => void): void; - /** - * Updates a previously created context menu item. - * @param id The ID of the item to update. - * @param updateProperties The properties to update. Accepts the same values as the create function. - * @param callback Called when the context menu has been updated. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function update(id: number, updateProperties: UpdateProperties, callback?: () => void): void; - /** - * Removes a context menu item. - * @param menuItemId The ID of the context menu item to remove. - * @param callback Called when the context menu has been removed. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function remove(menuItemId: string, callback?: () => void): void; - /** - * Removes a context menu item. - * @param menuItemId The ID of the context menu item to remove. - * @param callback Called when the context menu has been removed. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function remove(menuItemId: number, callback?: () => void): void; + /** + * Updates a previously created context menu item. + * @param id The ID of the item to update. + * @param updateProperties The properties to update. Accepts the same values as the create function. + * @param callback Called when the context menu has been updated. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function update(id: number, updateProperties: UpdateProperties, callback?: () => void): void; + /** + * Removes a context menu item. + * @param menuItemId The ID of the context menu item to remove. + * @param callback Called when the context menu has been removed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function remove(menuItemId: string, callback?: () => void): void; + /** + * Removes a context menu item. + * @param menuItemId The ID of the context menu item to remove. + * @param callback Called when the context menu has been removed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function remove(menuItemId: number, callback?: () => void): void; - /** - * Since Chrome 21. - * Fired when a context menu item is clicked. - */ + /** + * Since Chrome 21. + * Fired when a context menu item is clicked. + */ var onClicked: MenuClickedEvent; } @@ -1130,73 +1130,73 @@ declare namespace chrome.contextMenus { * Permissions: "cookies", host permissions */ declare namespace chrome.cookies { - /** Represents information about an HTTP cookie. */ + /** Represents information about an HTTP cookie. */ interface Cookie { - /** The domain of the cookie (e.g. "www.google.com", "example.com"). */ + /** The domain of the cookie (e.g. "www.google.com", "example.com"). */ domain: string; - /** The name of the cookie. */ + /** The name of the cookie. */ name: string; - /** The ID of the cookie store containing this cookie, as provided in getAllCookieStores(). */ + /** The ID of the cookie store containing this cookie, as provided in getAllCookieStores(). */ storeId: string; - /** The value of the cookie. */ + /** The value of the cookie. */ value: string; - /** True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date. */ + /** True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date. */ session: boolean; - /** True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie). */ + /** True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie). */ hostOnly: boolean; - /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */ + /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */ expirationDate?: number; - /** The path of the cookie. */ + /** The path of the cookie. */ path: string; - /** True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts). */ + /** True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts). */ httpOnly: boolean; - /** True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS). */ + /** True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS). */ secure: boolean; } - /** Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window. */ + /** Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window. */ interface CookieStore { - /** The unique identifier for the cookie store. */ + /** The unique identifier for the cookie store. */ id: string; - /** Identifiers of all the browser tabs that share this cookie store. */ + /** Identifiers of all the browser tabs that share this cookie store. */ tabIds: number[]; } interface GetAllDetails { - /** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */ + /** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */ domain?: string; - /** Optional. Filters the cookies by name. */ + /** Optional. Filters the cookies by name. */ name?: string; - /** Optional. Restricts the retrieved cookies to those that would match the given URL. */ + /** Optional. Restricts the retrieved cookies to those that would match the given URL. */ url?: string; - /** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */ + /** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */ storeId?: string; - /** Optional. Filters out session vs. persistent cookies. */ + /** Optional. Filters out session vs. persistent cookies. */ session?: boolean; - /** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */ + /** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */ path?: string; - /** Optional. Filters the cookies by their Secure property. */ + /** Optional. Filters the cookies by their Secure property. */ secure?: boolean; } interface SetDetails { - /** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */ + /** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */ domain?: string; - /** Optional. The name of the cookie. Empty by default if omitted. */ + /** Optional. The name of the cookie. Empty by default if omitted. */ name?: string; - /** The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. */ + /** The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. */ url: string; - /** Optional. The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */ + /** Optional. The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */ storeId?: string; - /** Optional. The value of the cookie. Empty by default if omitted. */ + /** Optional. The value of the cookie. Empty by default if omitted. */ value?: string; - /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */ + /** Optional. 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; - /** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */ + /** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */ path?: string; - /** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */ + /** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */ httpOnly?: boolean; - /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */ + /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */ secure?: boolean; } @@ -1207,59 +1207,59 @@ declare namespace chrome.cookies { } interface CookieChangeInfo { - /** Information about the cookie that was set or removed. */ + /** Information about the cookie that was set or removed. */ cookie: Cookie; - /** True if a cookie was removed. */ + /** True if a cookie was removed. */ removed: boolean; - /** - * Since Chrome 12. - * The underlying reason behind the cookie's change. - */ + /** + * Since Chrome 12. + * The underlying reason behind the cookie's change. + */ cause: string; } interface CookieChangedEvent extends chrome.events.Event<(changeInfo: CookieChangeInfo) => void> {} - /** - * Lists all existing cookie stores. - * @param callback The callback parameter should be a function that looks like this: - * function(array of CookieStore cookieStores) {...}; - * Parameter cookieStores: All the existing cookie stores. - */ + /** + * Lists all existing cookie stores. + * @param callback The callback parameter should be a function that looks like this: + * function(array of CookieStore cookieStores) {...}; + * Parameter cookieStores: All the existing cookie stores. + */ export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void; - /** - * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. - * @param details Information to filter the cookies being retrieved. - * @param callback The callback parameter should be a function that looks like this: - * function(array of Cookie cookies) {...}; - * Parameter cookies: All the existing, unexpired cookies that match the given cookie info. - */ + /** + * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. + * @param details Information to filter the cookies being retrieved. + * @param callback The callback parameter should be a function that looks like this: + * function(array of Cookie cookies) {...}; + * Parameter cookies: All the existing, unexpired cookies that match the given cookie info. + */ export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void; - /** - * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. - * @param details Details about the cookie being set. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( Cookie cookie) {...}; - * Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "chrome.runtime.lastError" will be set. - */ + /** + * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. + * @param details Details about the cookie being set. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( Cookie cookie) {...}; + * Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "chrome.runtime.lastError" will be set. + */ export function set(details: SetDetails, callback?: (cookie: Cookie | null) => void): void; - /** - * Deletes a cookie by name. - * @param details Information to identify the cookie to remove. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(object details) {...}; - */ + /** + * Deletes a cookie by name. + * @param details Information to identify the cookie to remove. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(object details) {...}; + */ export function remove(details: Details, callback?: (details: Details) => void): void; - /** - * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned. - * @param details Details to identify the cookie being retrieved. - * @param callback The callback parameter should be a function that looks like this: - * function( Cookie cookie) {...}; - * Parameter cookie: Contains details about the cookie. This parameter is null if no such cookie was found. - */ + /** + * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned. + * @param details Details to identify the cookie being retrieved. + * @param callback The callback parameter should be a function that looks like this: + * function( Cookie cookie) {...}; + * Parameter cookie: Contains details about the cookie. This parameter is null if no such cookie was found. + */ export function get(details: Details, callback: (cookie: Cookie | null) => void): void; - /** Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit". */ + /** Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit". */ var onChanged: CookieChangedEvent; } @@ -1273,99 +1273,99 @@ declare namespace chrome.cookies { */ // TODO: Uncomment when Microsoft/TypeScript#8312 is merged in // declare module chrome.debugger { -// /** Debuggee identifier. Either tabId or extensionId must be specified */ +// /** Debuggee identifier. Either tabId or extensionId must be specified */ // interface Debuggee { -// /** Optional. The id of the tab which you intend to debug. */ -// tabId?: number; -// /** -// * Optional. -// * Since Chrome 27. -// * The id of the extension which you intend to debug. Attaching to an extension background page is only possible when 'silent-debugger-extension-api' flag is enabled on the target browser. -// */ -// extensionId?: string; -// /** -// * Optional. -// * Since Chrome 28. -// * The opaque id of the debug target. -// */ -// targetId?: string; +// /** Optional. The id of the tab which you intend to debug. */ +// tabId?: number; +// /** +// * Optional. +// * Since Chrome 27. +// * The id of the extension which you intend to debug. Attaching to an extension background page is only possible when 'silent-debugger-extension-api' flag is enabled on the target browser. +// */ +// extensionId?: string; +// /** +// * Optional. +// * Since Chrome 28. +// * The opaque id of the debug target. +// */ +// targetId?: string; // } // -// /** -// * Since Chrome 28. -// * Debug target information -// */ -// interface TargetInfo { -// /** Target type. */ -// type: string; -// /** Target id. */ -// id: string; -// /** -// * Optional. -// * Since Chrome 30. -// * The tab id, defined if type == 'page'. -// */ -// tabId?: number; -// /** -// * Optional. -// * Since Chrome 30. -// * The extension id, defined if type = 'background_page'. -// */ -// extensionId?: string; -// /** True if debugger is already attached. */ -// attached: boolean; -// /** Target page title. */ -// title: string; -// /** Target URL. */ -// url: string; -// /** Optional. Target favicon URL. */ -// faviconUrl?: string; +// /** +// * Since Chrome 28. +// * Debug target information +// */ +// interface TargetInfo { +// /** Target type. */ +// type: string; +// /** Target id. */ +// id: string; +// /** +// * Optional. +// * Since Chrome 30. +// * The tab id, defined if type == 'page'. +// */ +// tabId?: number; +// /** +// * Optional. +// * Since Chrome 30. +// * The extension id, defined if type = 'background_page'. +// */ +// extensionId?: string; +// /** True if debugger is already attached. */ +// attached: boolean; +// /** Target page title. */ +// title: string; +// /** Target URL. */ +// url: string; +// /** Optional. Target favicon URL. */ +// faviconUrl?: string; // } // // interface DebuggerDetachedEvent extends chrome.events.Event<(source: Debuggee, reason: string) => void> {} // // interface DebuggerEventEvent extends chrome.events.Event<(source: Debuggee, method: string, params?: Object) => void> {} // -// /** -// * Attaches debugger to the given target. -// * @param target Debugging target to which you want to attach. -// * @param requiredVersion Required debugging protocol version ("0.1"). One can only attach to the debuggee with matching major version and greater or equal minor version. List of the protocol versions can be obtained in the documentation pages. -// * @param callback Called once the attach operation succeeds or fails. Callback receives no arguments. If the attach fails, runtime.lastError will be set to the error message. -// * If you specify the callback parameter, it should be a function that looks like this: -// * function() {...}; -// */ +// /** +// * Attaches debugger to the given target. +// * @param target Debugging target to which you want to attach. +// * @param requiredVersion Required debugging protocol version ("0.1"). One can only attach to the debuggee with matching major version and greater or equal minor version. List of the protocol versions can be obtained in the documentation pages. +// * @param callback Called once the attach operation succeeds or fails. Callback receives no arguments. If the attach fails, runtime.lastError will be set to the error message. +// * If you specify the callback parameter, it should be a function that looks like this: +// * function() {...}; +// */ // export function attach(target: Debuggee, requiredVersion: string, callback?: () => void): void; -// /** -// * Detaches debugger from the given target. -// * @param target Debugging target from which you want to detach. -// * @param callback Called once the detach operation succeeds or fails. Callback receives no arguments. If the detach fails, runtime.lastError will be set to the error message. -// * If you specify the callback parameter, it should be a function that looks like this: -// * function() {...}; -// */ +// /** +// * Detaches debugger from the given target. +// * @param target Debugging target from which you want to detach. +// * @param callback Called once the detach operation succeeds or fails. Callback receives no arguments. If the detach fails, runtime.lastError will be set to the error message. +// * If you specify the callback parameter, it should be a function that looks like this: +// * function() {...}; +// */ // export function detach(target: Debuggee, callback?: () => void): void; -// /** -// * Sends given command to the debugging target. -// * @param target Debugging target to which you want to send the command. -// * @param method Method name. Should be one of the methods defined by the remote debugging protocol. -// * @param commandParams Since Chrome 22. -// * JSON object with request parameters. This object must conform to the remote debugging params scheme for given method. -// * @param callback Response body. If an error occurs while posting the message, the callback will be called with no arguments and runtime.lastError will be set to the error message. -// * If you specify the callback parameter, it should be a function that looks like this: -// * function(object result) {...}; -// */ +// /** +// * Sends given command to the debugging target. +// * @param target Debugging target to which you want to send the command. +// * @param method Method name. Should be one of the methods defined by the remote debugging protocol. +// * @param commandParams Since Chrome 22. +// * JSON object with request parameters. This object must conform to the remote debugging params scheme for given method. +// * @param callback Response body. If an error occurs while posting the message, the callback will be called with no arguments and runtime.lastError will be set to the error message. +// * If you specify the callback parameter, it should be a function that looks like this: +// * function(object result) {...}; +// */ // export function sendCommand(target: Debuggee, method: string, commandParams?: Object, callback?: (result?: Object) => void): void; -// /** -// * Since Chrome 28. -// * Returns the list of available debug targets. -// * @param callback The callback parameter should be a function that looks like this: -// * function(array of TargetInfo result) {...}; -// * Parameter result: Array of TargetInfo objects corresponding to the available debug targets. -// */ -// export function getTargets(callback: (result: TargetInfo[]) => void): void; +// /** +// * Since Chrome 28. +// * Returns the list of available debug targets. +// * @param callback The callback parameter should be a function that looks like this: +// * function(array of TargetInfo result) {...}; +// * Parameter result: Array of TargetInfo objects corresponding to the available debug targets. +// */ +// export function getTargets(callback: (result: TargetInfo[]) => void): void; // -// /** Fired when browser terminates debugging session for the tab. This happens when either the tab is being closed or Chrome DevTools is being invoked for the attached tab. */ +// /** Fired when browser terminates debugging session for the tab. This happens when either the tab is being closed or Chrome DevTools is being invoked for the attached tab. */ // var onDetach: DebuggerDetachedEvent; -// /** Fired whenever debugging target issues instrumentation event. */ +// /** Fired whenever debugging target issues instrumentation event. */ // var onEvent: DebuggerEventEvent; // } @@ -1378,62 +1378,62 @@ declare namespace chrome.cookies { * Permissions: "declarativeContent" */ declare namespace chrome.declarativeContent { - interface PageStateUrlDetails { - /** Optional. Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */ - hostContains?: string; - /** Optional. Matches if the host name of the URL is equal to a specified string. */ - hostEquals?: string; - /** Optional. Matches if the host name of the URL starts with a specified string. */ - hostPrefix?: string; - /** Optional. Matches if the host name of the URL ends with a specified string. */ - hostSuffix?: string; - /** Optional. Matches if the path segment of the URL contains a specified string. */ - pathContains?: string; - /** Optional. Matches if the path segment of the URL is equal to a specified string. */ - pathEquals?: string; - /** Optional. Matches if the path segment of the URL starts with a specified string. */ - pathPrefix?: string; - /** Optional. Matches if the path segment of the URL ends with a specified string. */ - pathSuffix?: string; - /** Optional. Matches if the query segment of the URL contains a specified string. */ - queryContains?: string; - /** Optional. Matches if the query segment of the URL is equal to a specified string. */ - queryEquals?: string; - /** Optional. Matches if the query segment of the URL starts with a specified string. */ - queryPrefix?: string; - /** Optional. Matches if the query segment of the URL ends with a specified string. */ - querySuffix?: string; - /** Optional. Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */ - urlContains?: string; - /** Optional. Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */ - urlEquals?: string; - /** Optional. Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */ - urlMatches?: string; - /** Optional. Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */ - originAndPathMatches?: string; - /** Optional. Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */ - urlPrefix?: string; - /** Optional. Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */ - urlSuffix?: string; - /** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ - schemes?: string[]; - /** Optional. Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */ - ports?: (number | number[])[]; - } + interface PageStateUrlDetails { + /** Optional. Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */ + hostContains?: string; + /** Optional. Matches if the host name of the URL is equal to a specified string. */ + hostEquals?: string; + /** Optional. Matches if the host name of the URL starts with a specified string. */ + hostPrefix?: string; + /** Optional. Matches if the host name of the URL ends with a specified string. */ + hostSuffix?: string; + /** Optional. Matches if the path segment of the URL contains a specified string. */ + pathContains?: string; + /** Optional. Matches if the path segment of the URL is equal to a specified string. */ + pathEquals?: string; + /** Optional. Matches if the path segment of the URL starts with a specified string. */ + pathPrefix?: string; + /** Optional. Matches if the path segment of the URL ends with a specified string. */ + pathSuffix?: string; + /** Optional. Matches if the query segment of the URL contains a specified string. */ + queryContains?: string; + /** Optional. Matches if the query segment of the URL is equal to a specified string. */ + queryEquals?: string; + /** Optional. Matches if the query segment of the URL starts with a specified string. */ + queryPrefix?: string; + /** Optional. Matches if the query segment of the URL ends with a specified string. */ + querySuffix?: string; + /** Optional. Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */ + urlContains?: string; + /** Optional. Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */ + urlEquals?: string; + /** Optional. Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */ + urlMatches?: string; + /** Optional. Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */ + originAndPathMatches?: string; + /** Optional. Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */ + urlPrefix?: string; + /** Optional. Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */ + urlSuffix?: string; + /** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ + schemes?: string[]; + /** Optional. Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */ + ports?: (number | number[])[]; + } - /** Matches the state of a web page by various criteria. */ - interface PageStateMatcher { - /** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ - pageUrl?: PageStateUrlDetails; - /** Optional. Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites. */ - css?: string[]; - /** - * Optional. - * Since Chrome 45. Warning: this is the current Beta channel. More information available on the API documentation pages. - * Matches if the bookmarked state of the page is equal to the specified value. Requres the bookmarks permission. - */ - isBookmarked?: boolean; - } + /** Matches the state of a web page by various criteria. */ + interface PageStateMatcher { + /** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ + pageUrl?: PageStateUrlDetails; + /** Optional. Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites. */ + css?: string[]; + /** + * Optional. + * Since Chrome 45. Warning: this is the current Beta channel. More information available on the API documentation pages. + * Matches if the bookmarked state of the page is equal to the specified value. Requres the bookmarks permission. + */ + isBookmarked?: boolean; + } } //////////////////// @@ -1554,27 +1554,27 @@ declare namespace chrome.declarativeWebRequest { * Permissions: "desktopCapture" */ declare namespace chrome.desktopCapture { - /** - * Shows desktop media picker UI with the specified set of sources. - * @param sources Set of sources that should be shown to the user. - * @param callback The callback parameter should be a function that looks like this: - * function(string streamId) {...}; - * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used. - */ + /** + * Shows desktop media picker UI with the specified set of sources. + * @param sources Set of sources that should be shown to the user. + * @param callback The callback parameter should be a function that looks like this: + * function(string streamId) {...}; + * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used. + */ export function chooseDesktopMedia(sources: string[], callback: (streamId: string) => void): number; - /** - * Shows desktop media picker UI with the specified set of sources. - * @param sources Set of sources that should be shown to the user. - * @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches tab.url. - * @param callback The callback parameter should be a function that looks like this: - * function(string streamId) {...}; - * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used. - */ + /** + * Shows desktop media picker UI with the specified set of sources. + * @param sources Set of sources that should be shown to the user. + * @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches tab.url. + * @param callback The callback parameter should be a function that looks like this: + * function(string streamId) {...}; + * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used. + */ export function chooseDesktopMedia(sources: string[], targetTab: chrome.tabs.Tab, callback: (streamId: string) => void): number; - /** - * Hides desktop media picker dialog shown by chooseDesktopMedia(). - * @param desktopMediaRequestId Id returned by chooseDesktopMedia() - */ + /** + * Hides desktop media picker dialog shown by chooseDesktopMedia(). + * @param desktopMediaRequestId Id returned by chooseDesktopMedia() + */ export function cancelChooseDesktopMedia(desktopMediaRequestId: number): void; } @@ -1586,91 +1586,91 @@ declare namespace chrome.desktopCapture { * Availability: Since Chrome 18. */ declare namespace chrome.devtools.inspectedWindow { - /** A resource within the inspected page, such as a document, a script, or an image. */ + /** A resource within the inspected page, such as a document, a script, or an image. */ interface Resource { - /** The URL of the resource. */ + /** The URL of the resource. */ url: string; - /** - * Gets the content of the resource. - * @param callback A function that receives resource content when the request completes. - * The callback parameter should be a function that looks like this: - * function(string content, string encoding) {...}; - * Parameter content: Content of the resource (potentially encoded). - * Parameter encoding: Empty if content is not encoded, encoding name otherwise. Currently, only base64 is supported. - */ + /** + * Gets the content of the resource. + * @param callback A function that receives resource content when the request completes. + * The callback parameter should be a function that looks like this: + * function(string content, string encoding) {...}; + * Parameter content: Content of the resource (potentially encoded). + * Parameter encoding: Empty if content is not encoded, encoding name otherwise. Currently, only base64 is supported. + */ getContent(callback: (content: string, encoding: string) => void): void; - /** - * Sets the content of the resource. - * @param content New content of the resource. Only resources with the text type are currently supported. - * @param commit True if the user has finished editing the resource, and the new content of the resource should be persisted; false if this is a minor change sent in progress of the user editing the resource. - * @param callback A function called upon request completion. - * If you specify the callback parameter, it should be a function that looks like this: - * function(object error) {...}; - * Optional parameter error: Set to undefined if the resource content was set successfully; describes error otherwise. - */ + /** + * Sets the content of the resource. + * @param content New content of the resource. Only resources with the text type are currently supported. + * @param commit True if the user has finished editing the resource, and the new content of the resource should be persisted; false if this is a minor change sent in progress of the user editing the resource. + * @param callback A function called upon request completion. + * If you specify the callback parameter, it should be a function that looks like this: + * function(object error) {...}; + * Optional parameter error: Set to undefined if the resource content was set successfully; describes error otherwise. + */ setContent(content: string, commit: boolean, callback?: (error: Object) => void): void; } interface ReloadOptions { - /** Optional. If specified, the string will override the value of the User-Agent HTTP header that's sent while loading the resources of the inspected page. The string will also override the value of the navigator.userAgent property that's returned to any scripts that are running within the inspected page. */ + /** Optional. If specified, the string will override the value of the User-Agent HTTP header that's sent while loading the resources of the inspected page. The string will also override the value of the navigator.userAgent property that's returned to any scripts that are running within the inspected page. */ userAgent?: string; - /** Optional. When true, the loader will ignore the cache for all inspected page resources loaded before the load event is fired. The effect is similar to pressing Ctrl+Shift+R in the inspected window or within the Developer Tools window. */ + /** Optional. When true, the loader will ignore the cache for all inspected page resources loaded before the load event is fired. The effect is similar to pressing Ctrl+Shift+R in the inspected window or within the Developer Tools window. */ ignoreCache?: boolean; - /** Optional. If specified, the script will be injected into every frame of the inspected page immediately upon load, before any of the frame's scripts. The script will not be injected after subsequent reloads—for example, if the user presses Ctrl+R. */ + /** Optional. If specified, the script will be injected into every frame of the inspected page immediately upon load, before any of the frame's scripts. The script will not be injected after subsequent reloads—for example, if the user presses Ctrl+R. */ injectedScript?: string; - /** - * Optional. - * If specified, this script evaluates into a function that accepts three string arguments: the source to preprocess, the URL of the source, and a function name if the source is an DOM event handler. The preprocessorerScript function should return a string to be compiled by Chrome in place of the input source. In the case that the source is a DOM event handler, the returned source must compile to a single JS function. - * @deprecated Deprecated since Chrome 41. Please avoid using this parameter, it will be removed soon. - */ - preprocessorScript?: string; + /** + * Optional. + * If specified, this script evaluates into a function that accepts three string arguments: the source to preprocess, the URL of the source, and a function name if the source is an DOM event handler. The preprocessorerScript function should return a string to be compiled by Chrome in place of the input source. In the case that the source is a DOM event handler, the returned source must compile to a single JS function. + * @deprecated Deprecated since Chrome 41. Please avoid using this parameter, it will be removed soon. + */ + preprocessorScript?: string; } - interface EvaluationExceptionInfo { - /** Set if the error occurred on the DevTools side before the expression is evaluated. */ - isError: boolean; - /** Set if the error occurred on the DevTools side before the expression is evaluated. */ - code: string; - /** Set if the error occurred on the DevTools side before the expression is evaluated. */ - description: string; - /** Set if the error occurred on the DevTools side before the expression is evaluated, contains the array of the values that may be substituted into the description string to provide more information about the cause of the error. */ - details: any[]; - /** Set if the evaluated code produces an unhandled exception. */ - isException: boolean; - /** Set if the evaluated code produces an unhandled exception. */ - value: string; + interface EvaluationExceptionInfo { + /** Set if the error occurred on the DevTools side before the expression is evaluated. */ + isError: boolean; + /** Set if the error occurred on the DevTools side before the expression is evaluated. */ + code: string; + /** Set if the error occurred on the DevTools side before the expression is evaluated. */ + description: string; + /** Set if the error occurred on the DevTools side before the expression is evaluated, contains the array of the values that may be substituted into the description string to provide more information about the cause of the error. */ + details: any[]; + /** Set if the evaluated code produces an unhandled exception. */ + isException: boolean; + /** Set if the evaluated code produces an unhandled exception. */ + value: string; } interface ResourceAddedEvent extends chrome.events.Event<(resource: Resource) => void> {} interface ResourceContentCommittedEvent extends chrome.events.Event<(resource: Resource, content: string) => void> {} - /** The ID of the tab being inspected. This ID may be used with chrome.tabs.* API. */ + /** The ID of the tab being inspected. This ID may be used with chrome.tabs.* API. */ var tabId: number; - /** Reloads the inspected page. */ + /** Reloads the inspected page. */ export function reload(reloadOptions: ReloadOptions): void; - /** - * Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown. The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation. In either case, the result parameter of the callback is undefined. In the case of a DevTools-side error, the isException parameter is non-null and has isError set to true and code set to an error code. In the case of a JavaScript error, isException is set to true and value is set to the string value of thrown object. - * @param expression An expression to evaluate. - * @param callback A function called when evaluation completes. - * If you specify the callback parameter, it should be a function that looks like this: - * function(object result, object exceptionInfo) {...}; - * Parameter result: The result of evaluation. - * Parameter exceptionInfo: An object providing details if an exception occurred while evaluating the expression. - */ + /** + * Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown. The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation. In either case, the result parameter of the callback is undefined. In the case of a DevTools-side error, the isException parameter is non-null and has isError set to true and code set to an error code. In the case of a JavaScript error, isException is set to true and value is set to the string value of thrown object. + * @param expression An expression to evaluate. + * @param callback A function called when evaluation completes. + * If you specify the callback parameter, it should be a function that looks like this: + * function(object result, object exceptionInfo) {...}; + * Parameter result: The result of evaluation. + * Parameter exceptionInfo: An object providing details if an exception occurred while evaluating the expression. + */ export function eval(expression: string, callback?: (result: Object, exceptionInfo: EvaluationExceptionInfo) => void): void; - /** - * Retrieves the list of resources from the inspected page. - * @param callback A function that receives the list of resources when the request completes. - * The callback parameter should be a function that looks like this: - * function(array of Resource resources) {...}; - */ + /** + * Retrieves the list of resources from the inspected page. + * @param callback A function that receives the list of resources when the request completes. + * The callback parameter should be a function that looks like this: + * function(array of Resource resources) {...}; + */ export function getResources(callback: (resources: Resource[]) => void): void; - /** Fired when a new resource is added to the inspected page. */ + /** Fired when a new resource is added to the inspected page. */ var onResourceAdded: ResourceAddedEvent; - /** Fired when a new revision of the resource is committed (e.g. user saves an edited version of the resource in the Developer Tools). */ + /** Fired when a new revision of the resource is committed (e.g. user saves an edited version of the resource in the Developer Tools). */ var onResourceContentCommitted: ResourceContentCommittedEvent; } @@ -1682,16 +1682,16 @@ declare namespace chrome.devtools.inspectedWindow { * Availability: Since Chrome 18. */ declare namespace chrome.devtools.network { - /** Represents a network request for a document resource (script, image and so on). See HAR Specification for reference. */ + /** Represents a network request for a document resource (script, image and so on). See HAR Specification for reference. */ interface Request { - /** - * Returns content of the response body. - * @param callback A function that receives the response body when the request completes. - * The callback parameter should be a function that looks like this: - * function(string content, string encoding) {...}; - * Parameter content: Content of the response body (potentially encoded). - * Parameter encoding: Empty if content is not encoded, encoding name otherwise. Currently, only base64 is supported. - */ + /** + * Returns content of the response body. + * @param callback A function that receives the response body when the request completes. + * The callback parameter should be a function that looks like this: + * function(string content, string encoding) {...}; + * Parameter content: Content of the response body (potentially encoded). + * Parameter encoding: Empty if content is not encoded, encoding name otherwise. Currently, only base64 is supported. + */ getContent(callback: (content: string, encoding: string) => void): void; } @@ -1699,18 +1699,18 @@ declare namespace chrome.devtools.network { interface NavigatedEvent extends chrome.events.Event<(url: string) => void> {} - /** - * Returns HAR log that contains all known network requests. - * @param callback A function that receives the HAR log when the request completes. - * The callback parameter should be a function that looks like this: - * function(object harLog) {...}; - * Parameter harLog: A HAR log. See HAR specification for details. - */ + /** + * Returns HAR log that contains all known network requests. + * @param callback A function that receives the HAR log when the request completes. + * The callback parameter should be a function that looks like this: + * function(object harLog) {...}; + * Parameter harLog: A HAR log. See HAR specification for details. + */ export function getHAR(callback: (harLog: Object) => void): void; - /** Fired when a network request is finished and all request data are available. */ + /** Fired when a network request is finished and all request data are available. */ var onRequestFinished: RequestFinishedEvent; - /** Fired when the inspected window navigates to a new page. */ + /** Fired when the inspected window navigates to a new page. */ var onNavigated: NavigatedEvent; } @@ -1728,70 +1728,70 @@ declare namespace chrome.devtools.panels { interface PanelSearchEvent extends chrome.events.Event<(action: string, queryString?: string) => void> {} - /** Represents a panel created by extension. */ + /** Represents a panel created by extension. */ interface ExtensionPanel { - /** - * Appends a button to the status bar of the panel. - * @param iconPath Path to the icon of the button. The file should contain a 64x24-pixel image composed of two 32x24 icons. The left icon is used when the button is inactive; the right icon is displayed when the button is pressed. - * @param tooltipText Text shown as a tooltip when user hovers the mouse over the button. - * @param disabled Whether the button is disabled. - */ + /** + * Appends a button to the status bar of the panel. + * @param iconPath Path to the icon of the button. The file should contain a 64x24-pixel image composed of two 32x24 icons. The left icon is used when the button is inactive; the right icon is displayed when the button is pressed. + * @param tooltipText Text shown as a tooltip when user hovers the mouse over the button. + * @param disabled Whether the button is disabled. + */ createStatusBarButton(iconPath: string, tooltipText: string, disabled: boolean): Button; - /** Fired when the user switches to the panel. */ + /** Fired when the user switches to the panel. */ onShown: PanelShownEvent; - /** Fired when the user switches away from the panel. */ + /** Fired when the user switches away from the panel. */ onHidden: PanelHiddenEvent; - /** Fired upon a search action (start of a new search, search result navigation, or search being canceled). */ + /** Fired upon a search action (start of a new search, search result navigation, or search being canceled). */ onSearch: PanelSearchEvent; } interface ButtonClickedEvent extends chrome.events.Event<() => void> {} - /** A button created by the extension. */ + /** A button created by the extension. */ interface Button { - /** - * Updates the attributes of the button. If some of the arguments are omitted or null, the corresponding attributes are not updated. - * @param iconPath Path to the new icon of the button. - * @param tooltipText Text shown as a tooltip when user hovers the mouse over the button. - * @param disabled Whether the button is disabled. - */ + /** + * Updates the attributes of the button. If some of the arguments are omitted or null, the corresponding attributes are not updated. + * @param iconPath Path to the new icon of the button. + * @param tooltipText Text shown as a tooltip when user hovers the mouse over the button. + * @param disabled Whether the button is disabled. + */ update(iconPath?: string | null, tooltipText?: string | null, disabled?: boolean | null): void; - /** Fired when the button is clicked. */ + /** Fired when the button is clicked. */ onClicked: ButtonClickedEvent; } interface SelectionChangedEvent extends chrome.events.Event<() => void> {} - /** Represents the Elements panel. */ + /** Represents the Elements panel. */ interface ElementsPanel { - /** - * Creates a pane within panel's sidebar. - * @param title Text that is displayed in sidebar caption. - * @param callback A callback invoked when the sidebar is created. - * If you specify the callback parameter, it should be a function that looks like this: - * function( ExtensionSidebarPane result) {...}; - * Parameter result: An ExtensionSidebarPane object for created sidebar pane. - */ + /** + * Creates a pane within panel's sidebar. + * @param title Text that is displayed in sidebar caption. + * @param callback A callback invoked when the sidebar is created. + * If you specify the callback parameter, it should be a function that looks like this: + * function( ExtensionSidebarPane result) {...}; + * Parameter result: An ExtensionSidebarPane object for created sidebar pane. + */ createSidebarPane(title: string, callback?: (result: ExtensionSidebarPane) => void): void; - /** Fired when an object is selected in the panel. */ + /** Fired when an object is selected in the panel. */ onSelectionChanged: SelectionChangedEvent; } - /** - * Since Chrome 41. - * Represents the Sources panel. - */ - interface SourcesPanel { - /** - * Creates a pane within panel's sidebar. - * @param title Text that is displayed in sidebar caption. - * @param callback A callback invoked when the sidebar is created. - * If you specify the callback parameter, it should be a function that looks like this: - * function( ExtensionSidebarPane result) {...}; - * Parameter result: An ExtensionSidebarPane object for created sidebar pane. - */ + /** + * Since Chrome 41. + * Represents the Sources panel. + */ + interface SourcesPanel { + /** + * Creates a pane within panel's sidebar. + * @param title Text that is displayed in sidebar caption. + * @param callback A callback invoked when the sidebar is created. + * If you specify the callback parameter, it should be a function that looks like this: + * function( ExtensionSidebarPane result) {...}; + * Parameter result: An ExtensionSidebarPane object for created sidebar pane. + */ createSidebarPane(title: string, callback?: (result: ExtensionSidebarPane) => void): void; - /** Fired when an object is selected in the panel. */ + /** Fired when an object is selected in the panel. */ onSelectionChanged: SelectionChangedEvent; } @@ -1799,95 +1799,95 @@ declare namespace chrome.devtools.panels { interface ExtensionSidebarPaneHiddenEvent extends chrome.events.Event<() => void> {} - /** A sidebar created by the extension. */ + /** A sidebar created by the extension. */ interface ExtensionSidebarPane { - /** - * Sets the height of the sidebar. - * @param height A CSS-like size specification, such as '100px' or '12ex'. - */ + /** + * Sets the height of the sidebar. + * @param height A CSS-like size specification, such as '100px' or '12ex'. + */ setHeight(height: string): void; - /** - * Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane. - * @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch. - * @param rootTitle An optional title for the root of the expression tree. - * @param callback A callback invoked after the sidebar pane is updated with the expression evaluation results. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane. + * @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch. + * @param rootTitle An optional title for the root of the expression tree. + * @param callback A callback invoked after the sidebar pane is updated with the expression evaluation results. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ setExpression(expression: string, rootTitle?: string, callback?: () => void): void; - /** - * Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane. - * @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch. - * @param callback A callback invoked after the sidebar pane is updated with the expression evaluation results. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane. + * @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch. + * @param callback A callback invoked after the sidebar pane is updated with the expression evaluation results. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ setExpression(expression: string, callback?: () => void): void; - /** - * Sets a JSON-compliant object to be displayed in the sidebar pane. - * @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client). - * @param rootTitle An optional title for the root of the expression tree. - * @param callback A callback invoked after the sidebar is updated with the object. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets a JSON-compliant object to be displayed in the sidebar pane. + * @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client). + * @param rootTitle An optional title for the root of the expression tree. + * @param callback A callback invoked after the sidebar is updated with the object. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ setObject(jsonObject: string, rootTitle?: string, callback?: () => void): void; - /** - * Sets a JSON-compliant object to be displayed in the sidebar pane. - * @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client). - * @param callback A callback invoked after the sidebar is updated with the object. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets a JSON-compliant object to be displayed in the sidebar pane. + * @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client). + * @param callback A callback invoked after the sidebar is updated with the object. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ setObject(jsonObject: string, callback?: () => void): void; - /** - * Sets an HTML page to be displayed in the sidebar pane. - * @param path Relative path of an extension page to display within the sidebar. - */ + /** + * Sets an HTML page to be displayed in the sidebar pane. + * @param path Relative path of an extension page to display within the sidebar. + */ setPage(path: string): void; - /** Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it. */ + /** Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it. */ onShown: ExtensionSidebarPaneShownEvent; - /** Fired when the sidebar pane becomes hidden as a result of the user switching away from the panel that hosts the sidebar pane. */ + /** Fired when the sidebar pane becomes hidden as a result of the user switching away from the panel that hosts the sidebar pane. */ onHidden: ExtensionSidebarPaneHiddenEvent; } - /** Elements panel. */ + /** Elements panel. */ var elements: ElementsPanel; - /** - * Since Chrome 38. - * Sources panel. - */ - var sources: SourcesPanel; + /** + * Since Chrome 38. + * Sources panel. + */ + var sources: SourcesPanel; - /** - * Creates an extension panel. - * @param title Title that is displayed next to the extension icon in the Developer Tools toolbar. - * @param iconPath Path of the panel's icon relative to the extension directory. - * @param pagePath Path of the panel's HTML page relative to the extension directory. - * @param callback A function that is called when the panel is created. - * If you specify the callback parameter, it should be a function that looks like this: - * function( ExtensionPanel panel) {...}; - * Parameter panel: An ExtensionPanel object representing the created panel. - */ + /** + * Creates an extension panel. + * @param title Title that is displayed next to the extension icon in the Developer Tools toolbar. + * @param iconPath Path of the panel's icon relative to the extension directory. + * @param pagePath Path of the panel's HTML page relative to the extension directory. + * @param callback A function that is called when the panel is created. + * If you specify the callback parameter, it should be a function that looks like this: + * function( ExtensionPanel panel) {...}; + * Parameter panel: An ExtensionPanel object representing the created panel. + */ export function create(title: string, iconPath: string, pagePath: string, callback?: (panel: ExtensionPanel) => void): void; - /** - * Specifies the function to be called when the user clicks a resource link in the Developer Tools window. To unset the handler, either call the method with no parameters or pass null as the parameter. - * @param callback A function that is called when the user clicks on a valid resource link in Developer Tools window. Note that if the user clicks an invalid URL or an XHR, this function is not called. - * If you specify the callback parameter, it should be a function that looks like this: - * function( devtools.inspectedWindow.Resource resource) {...}; - * Parameter resource: A devtools.inspectedWindow.Resource object for the resource that was clicked. - */ + /** + * Specifies the function to be called when the user clicks a resource link in the Developer Tools window. To unset the handler, either call the method with no parameters or pass null as the parameter. + * @param callback A function that is called when the user clicks on a valid resource link in Developer Tools window. Note that if the user clicks an invalid URL or an XHR, this function is not called. + * If you specify the callback parameter, it should be a function that looks like this: + * function( devtools.inspectedWindow.Resource resource) {...}; + * Parameter resource: A devtools.inspectedWindow.Resource object for the resource that was clicked. + */ export function setOpenResourceHandler(callback?: (resource: chrome.devtools.inspectedWindow.Resource) => void): void; - /** - * Since Chrome 38. - * Requests DevTools to open a URL in a Developer Tools panel. - * @param url The URL of the resource to open. - * @param lineNumber Specifies the line number to scroll to when the resource is loaded. - * @param callback A function that is called when the resource has been successfully loaded. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function openResource(url: string, lineNumber: number, callback: () => void): void; + /** + * Since Chrome 38. + * Requests DevTools to open a URL in a Developer Tools panel. + * @param url The URL of the resource to open. + * @param lineNumber Specifies the line number to scroll to when the resource is loaded. + * @param callback A function that is called when the resource has been successfully loaded. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function openResource(url: string, lineNumber: number, callback: () => void): void; } //////////////////// @@ -1900,28 +1900,28 @@ declare namespace chrome.devtools.panels { * Important: This API works only on Chrome OS. */ declare namespace chrome.documentScan { - interface DocumentScanOptions { - /** Optional. The MIME types that are accepted by the caller. */ - mimeTypes?: string[]; - /** Optional. The number of scanned images allowed (defaults to 1). */ - maxImages?: number; - } + interface DocumentScanOptions { + /** Optional. The MIME types that are accepted by the caller. */ + mimeTypes?: string[]; + /** Optional. The number of scanned images allowed (defaults to 1). */ + maxImages?: number; + } - interface DocumentScanCallbackArg { - /** The data image URLs in a form that can be passed as the "src" value to an image tag. */ - dataUrls: string[]; - /** The MIME type of dataUrls. */ - mimeType: string; - } + interface DocumentScanCallbackArg { + /** The data image URLs in a form that can be passed as the "src" value to an image tag. */ + dataUrls: string[]; + /** The MIME type of dataUrls. */ + mimeType: string; + } - /** - * Performs a document scan. On success, the PNG data will be sent to the callback. - * @param options Object containing scan parameters. - * @param callback Called with the result and data from the scan. - * The callback parameter should be a function that looks like this: - * function(object result) {...}; - */ - export function scan(options: DocumentScanOptions, callback: (result: DocumentScanCallbackArg) => void): void; + /** + * Performs a document scan. On success, the PNG data will be sent to the callback. + * @param options Object containing scan parameters. + * @param callback Called with the result and data from the scan. + * The callback parameter should be a function that looks like this: + * function(object result) {...}; + */ + export function scan(options: DocumentScanOptions, callback: (result: DocumentScanCallbackArg) => void): void; } //////////////////// @@ -1934,58 +1934,58 @@ declare namespace chrome.documentScan { */ declare namespace chrome.downloads { interface HeaderNameValuePair { - /** Name of the HTTP header. */ + /** Name of the HTTP header. */ name: string; - /** Value of the HTTP header. */ + /** Value of the HTTP header. */ value: string; } interface DownloadOptions { - /** Optional. Post body. */ + /** Optional. Post body. */ body?: string; - /** Optional. Use a file-chooser to allow the user to select a filename regardless of whether filename is set or already exists. */ + /** Optional. Use a file-chooser to allow the user to select a filename regardless of whether filename is set or already exists. */ saveAs?: boolean; - /** The URL to download. */ + /** The URL to download. */ url: string; - /** Optional. A file path relative to the Downloads directory to contain the downloaded file, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will cause an error. onDeterminingFilename allows suggesting a filename after the file's MIME type and a tentative filename have been determined. */ + /** Optional. A file path relative to the Downloads directory to contain the downloaded file, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will cause an error. onDeterminingFilename allows suggesting a filename after the file's MIME type and a tentative filename have been determined. */ filename?: string; - /** Optional. Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary containing the keys name and either value or binaryValue, restricted to those allowed by XMLHttpRequest. */ + /** Optional. Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary containing the keys name and either value or binaryValue, restricted to those allowed by XMLHttpRequest. */ headers?: HeaderNameValuePair[]; - /** Optional. The HTTP method to use if the URL uses the HTTP[S] protocol. */ + /** Optional. The HTTP method to use if the URL uses the HTTP[S] protocol. */ method?: string; - /** Optional. The action to take if filename already exists. */ - conflictAction?: string; + /** Optional. The action to take if filename already exists. */ + conflictAction?: string; } interface DownloadDelta { - /** Optional. The change in danger, if any. */ - danger?: StringDelta; - /** Optional. The change in url, if any. */ - url?: StringDelta; - /** Optional. The change in totalBytes, if any. */ - totalBytes?: DoubleDelta; - /** Optional. The change in filename, if any. */ - filename?: StringDelta; - /** Optional. The change in paused, if any. */ - paused?: BooleanDelta; - /** Optional. The change in state, if any. */ - state?: StringDelta; - /** Optional. The change in mime, if any. */ - mime?: StringDelta; - /** Optional. The change in fileSize, if any. */ - fileSize?: DoubleDelta; - /** Optional. The change in startTime, if any. */ - startTime?: DoubleDelta; - /** Optional. The change in error, if any. */ - error?: StringDelta; - /** Optional. The change in endTime, if any. */ - endTime?: DoubleDelta; - /** The id of the DownloadItem that changed. */ + /** Optional. The change in danger, if any. */ + danger?: StringDelta; + /** Optional. The change in url, if any. */ + url?: StringDelta; + /** Optional. The change in totalBytes, if any. */ + totalBytes?: DoubleDelta; + /** Optional. The change in filename, if any. */ + filename?: StringDelta; + /** Optional. The change in paused, if any. */ + paused?: BooleanDelta; + /** Optional. The change in state, if any. */ + state?: StringDelta; + /** Optional. The change in mime, if any. */ + mime?: StringDelta; + /** Optional. The change in fileSize, if any. */ + fileSize?: DoubleDelta; + /** Optional. The change in startTime, if any. */ + startTime?: DoubleDelta; + /** Optional. The change in error, if any. */ + error?: StringDelta; + /** Optional. The change in endTime, if any. */ + endTime?: DoubleDelta; + /** The id of the DownloadItem that changed. */ id: number; - /** Optional. The change in canResume, if any. */ - canResume?: BooleanDelta; - /** Optional. The change in exists, if any. */ - exists?: BooleanDelta; + /** Optional. The change in canResume, if any. */ + canResume?: BooleanDelta; + /** Optional. The change in exists, if any. */ + exists?: BooleanDelta; } interface BooleanDelta { @@ -1993,7 +1993,7 @@ declare namespace chrome.downloads { previous?: boolean; } - /** Since Chrome 34. */ + /** Since Chrome 34. */ interface DoubleDelta { current?: number; previous?: number; @@ -2005,113 +2005,113 @@ declare namespace chrome.downloads { } interface DownloadItem { - /** Number of bytes received so far from the host, without considering file compression. */ + /** Number of bytes received so far from the host, without considering file compression. */ bytesReceived: number; - /** Indication of whether this download is thought to be safe or known to be suspicious. */ + /** Indication of whether this download is thought to be safe or known to be suspicious. */ danger: string; - /** Absolute URL. */ + /** Absolute URL. */ url: string; - /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ + /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ totalBytes: number; - /** Absolute local path. */ + /** Absolute local path. */ filename: string; - /** True if the download has stopped reading data from the host, but kept the connection open. */ + /** True if the download has stopped reading data from the host, but kept the connection open. */ paused: boolean; - /** Indicates whether the download is progressing, interrupted, or complete. */ + /** Indicates whether the download is progressing, interrupted, or complete. */ state: string; - /** The file's MIME type. */ + /** The file's MIME type. */ mime: string; - /** Number of bytes in the whole file post-decompression, or -1 if unknown. */ + /** Number of bytes in the whole file post-decompression, or -1 if unknown. */ fileSize: number; - /** The time when the download began in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){console.log(new Date(item.startTime))})}) */ + /** The time when the download began in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){console.log(new Date(item.startTime))})}) */ startTime: string; - /** Optional. Why the download was interrupted. Several kinds of HTTP errors may be grouped under one of the errors beginning with SERVER_. Errors relating to the network begin with NETWORK_, errors relating to the process of writing the file to the file system begin with FILE_, and interruptions initiated by the user begin with USER_. */ - error?: string; - /** Optional. The time when the download ended in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){if (item.endTime) console.log(new Date(item.endTime))})}) */ - endTime?: string; - /** An identifier that is persistent across browser sessions. */ + /** Optional. Why the download was interrupted. Several kinds of HTTP errors may be grouped under one of the errors beginning with SERVER_. Errors relating to the network begin with NETWORK_, errors relating to the process of writing the file to the file system begin with FILE_, and interruptions initiated by the user begin with USER_. */ + error?: string; + /** Optional. The time when the download ended in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){if (item.endTime) console.log(new Date(item.endTime))})}) */ + endTime?: string; + /** An identifier that is persistent across browser sessions. */ id: number; - /** False if this download is recorded in the history, true if it is not recorded. */ + /** False if this download is recorded in the history, true if it is not recorded. */ incognito: boolean; - /** Absolute URL. */ - referrer: string; - /** Optional. Estimated time when the download will complete in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){if (item.estimatedEndTime) console.log(new Date(item.estimatedEndTime))})}) */ - estimatedEndTime?: string; - /** True if the download is in progress and paused, or else if it is interrupted and can be resumed starting from where it was interrupted. */ - canResume: boolean; - /** Whether the downloaded file still exists. This information may be out of date because Chrome does not automatically watch for file removal. Call search() in order to trigger the check for file existence. When the existence check completes, if the file has been deleted, then an onChanged event will fire. Note that search() does not wait for the existence check to finish before returning, so results from search() may not accurately reflect the file system. Also, search() may be called as often as necessary, but will not check for file existence any more frequently than once every 10 seconds. */ - exists: boolean; - /** Optional. The identifier for the extension that initiated this download if this download was initiated by an extension. Does not change once it is set. */ - byExtensionId?: string; - /** Optional. The localized name of the extension that initiated this download if this download was initiated by an extension. May change if the extension changes its name or if the user changes their locale. */ - byExtensionName?: string; + /** Absolute URL. */ + referrer: string; + /** Optional. Estimated time when the download will complete in ISO 8601 format. May be passed directly to the Date constructor: chrome.downloads.search({}, function(items){items.forEach(function(item){if (item.estimatedEndTime) console.log(new Date(item.estimatedEndTime))})}) */ + estimatedEndTime?: string; + /** True if the download is in progress and paused, or else if it is interrupted and can be resumed starting from where it was interrupted. */ + canResume: boolean; + /** Whether the downloaded file still exists. This information may be out of date because Chrome does not automatically watch for file removal. Call search() in order to trigger the check for file existence. When the existence check completes, if the file has been deleted, then an onChanged event will fire. Note that search() does not wait for the existence check to finish before returning, so results from search() may not accurately reflect the file system. Also, search() may be called as often as necessary, but will not check for file existence any more frequently than once every 10 seconds. */ + exists: boolean; + /** Optional. The identifier for the extension that initiated this download if this download was initiated by an extension. Does not change once it is set. */ + byExtensionId?: string; + /** Optional. The localized name of the extension that initiated this download if this download was initiated by an extension. May change if the extension changes its name or if the user changes their locale. */ + byExtensionName?: string; } interface GetFileIconOptions { - /** Optional. * The size of the returned icon. The icon will be square with dimensions size * size pixels. The default and largest size for the icon is 32x32 pixels. The only supported sizes are 16 and 32. It is an error to specify any other size. + /** Optional. * The size of the returned icon. The icon will be square with dimensions size * size pixels. The default and largest size for the icon is 32x32 pixels. The only supported sizes are 16 and 32. It is an error to specify any other size. */ size?: number; } interface DownloadQuery { - /** Optional. Set elements of this array to DownloadItem properties in order to sort search results. For example, setting orderBy=['startTime'] sorts the DownloadItem by their start time in ascending order. To specify descending order, prefix with a hyphen: '-startTime'. */ - orderBy?: string[]; - /** Optional. Limits results to DownloadItem whose url matches the given regular expression. */ + /** Optional. Set elements of this array to DownloadItem properties in order to sort search results. For example, setting orderBy=['startTime'] sorts the DownloadItem by their start time in ascending order. To specify descending order, prefix with a hyphen: '-startTime'. */ + orderBy?: string[]; + /** Optional. Limits results to DownloadItem whose url matches the given regular expression. */ urlRegex?: string; - /** Optional. Limits results to DownloadItem that ended before the given ms since the epoch. */ + /** Optional. Limits results to DownloadItem that ended before the given ms since the epoch. */ endedBefore?: number; - /** Optional. Limits results to DownloadItem whose totalBytes is greater than the given integer. */ + /** Optional. Limits results to DownloadItem whose totalBytes is greater than the given integer. */ totalBytesGreater?: number; - /** Optional. Indication of whether this download is thought to be safe or known to be suspicious. */ + /** Optional. Indication of whether this download is thought to be safe or known to be suspicious. */ danger?: string; - /** Optional. Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ + /** Optional. Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ totalBytes?: number; - /** Optional. True if the download has stopped reading data from the host, but kept the connection open. */ + /** Optional. True if the download has stopped reading data from the host, but kept the connection open. */ paused?: boolean; - /** Optional. Limits results to DownloadItem whose filename matches the given regular expression. */ + /** Optional. Limits results to DownloadItem whose filename matches the given regular expression. */ filenameRegex?: string; - /** Optional. This array of search terms limits results to DownloadItem whose filename or url contain all of the search terms that do not begin with a dash '-' and none of the search terms that do begin with a dash. */ - query?: string[]; - /** Optional. Limits results to DownloadItem whose totalBytes is less than the given integer. */ + /** Optional. This array of search terms limits results to DownloadItem whose filename or url contain all of the search terms that do not begin with a dash '-' and none of the search terms that do begin with a dash. */ + query?: string[]; + /** Optional. Limits results to DownloadItem whose totalBytes is less than the given integer. */ totalBytesLess?: number; - /** Optional. The id of the DownloadItem to query. */ + /** Optional. The id of the DownloadItem to query. */ id?: number; - /** Optional. Number of bytes received so far from the host, without considering file compression. */ + /** Optional. Number of bytes received so far from the host, without considering file compression. */ bytesReceived?: number; - /** Optional. Limits results to DownloadItem that ended after the given ms since the epoch. */ + /** Optional. Limits results to DownloadItem that ended after the given ms since the epoch. */ endedAfter?: number; - /** Optional. Absolute local path. */ + /** Optional. Absolute local path. */ filename?: string; - /** Optional. Indicates whether the download is progressing, interrupted, or complete. */ + /** Optional. Indicates whether the download is progressing, interrupted, or complete. */ state?: string; - /** Optional. Limits results to DownloadItem that started after the given ms since the epoch. */ + /** Optional. Limits results to DownloadItem that started after the given ms since the epoch. */ startedAfter?: number; - /** Optional. The file's MIME type. */ + /** Optional. The file's MIME type. */ mime?: string; - /** Optional. Number of bytes in the whole file post-decompression, or -1 if unknown. */ + /** Optional. Number of bytes in the whole file post-decompression, or -1 if unknown. */ fileSize?: number; - /** Optional. The time when the download began in ISO 8601 format. */ + /** Optional. The time when the download began in ISO 8601 format. */ startTime?: number; - /** Optional. Absolute URL. */ + /** Optional. Absolute URL. */ url?: string; - /** Optional. Limits results to DownloadItem that started before the given ms since the epoch. */ + /** Optional. Limits results to DownloadItem that started before the given ms since the epoch. */ startedBefore?: number; - /** Optional. The maximum number of matching DownloadItem returned. Defaults to 1000. Set to 0 in order to return all matching DownloadItem. See search for how to page through results. */ + /** Optional. The maximum number of matching DownloadItem returned. Defaults to 1000. Set to 0 in order to return all matching DownloadItem. See search for how to page through results. */ limit?: number; - /** Optional. Why a download was interrupted. */ + /** Optional. Why a download was interrupted. */ error?: number; - /** Optional. The time when the download ended in ISO 8601 format. */ + /** Optional. The time when the download ended in ISO 8601 format. */ endTime?: number; - /** Optional. Whether the downloaded file exists; */ - exists?: boolean; + /** Optional. Whether the downloaded file exists; */ + exists?: boolean; } - interface DownloadFilenameSuggestion { - /** The DownloadItem's new target DownloadItem.filename, as a path relative to the user's default Downloads directory, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will be ignored. */ - filename: string; - /** Optional. The action to take if filename already exists. */ - conflictAction?: string; - } + interface DownloadFilenameSuggestion { + /** The DownloadItem's new target DownloadItem.filename, as a path relative to the user's default Downloads directory, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will be ignored. */ + filename: string; + /** Optional. The action to take if filename already exists. */ + conflictAction?: string; + } interface DownloadChangedEvent extends chrome.events.Event<(downloadDelta: DownloadDelta) => void> {} @@ -2119,107 +2119,107 @@ declare namespace chrome.downloads { interface DownloadErasedEvent extends chrome.events.Event<(downloadId: number) => void> {} - interface DownloadDeterminingFilenameEvent extends chrome.events.Event<(downloadItem: DownloadItem, suggest: (suggestion?: DownloadFilenameSuggestion) => void) => void> {} + interface DownloadDeterminingFilenameEvent extends chrome.events.Event<(downloadItem: DownloadItem, suggest: (suggestion?: DownloadFilenameSuggestion) => void) => void> {} - /** - * Find DownloadItem. Set query to the empty object to get all DownloadItem. To get a specific DownloadItem, set only the id field. To page through a large number of items, set orderBy: ['-startTime'], set limit to the number of items per page, and set startedAfter to the startTime of the last item from the last page. - * @param callback The callback parameter should be a function that looks like this: - * function(array of DownloadItem results) {...}; - */ + /** + * Find DownloadItem. Set query to the empty object to get all DownloadItem. To get a specific DownloadItem, set only the id field. To page through a large number of items, set orderBy: ['-startTime'], set limit to the number of items per page, and set startedAfter to the startTime of the last item from the last page. + * @param callback The callback parameter should be a function that looks like this: + * function(array of DownloadItem results) {...}; + */ export function search(query: DownloadQuery, callback: (results: DownloadItem[]) => void): void; - /** - * Pause the download. If the request was successful the download is in a paused state. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active. - * @param downloadId The id of the download to pause. - * @param callback Called when the pause request is completed. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Pause the download. If the request was successful the download is in a paused state. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active. + * @param downloadId The id of the download to pause. + * @param callback Called when the pause request is completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function pause(downloadId: number, callback?: () => void): void; - /** - * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message. - * @param downloadId The identifier for the download. - * @param callback A URL to an image that represents the download. - * The callback parameter should be a function that looks like this: - * function(string iconURL) {...}; - */ + /** + * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message. + * @param downloadId The identifier for the download. + * @param callback A URL to an image that represents the download. + * The callback parameter should be a function that looks like this: + * function(string iconURL) {...}; + */ export function getFileIcon(downloadId: number, callback: (iconURL: string) => void): void; - /** - * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message. - * @param downloadId The identifier for the download. - * @param callback A URL to an image that represents the download. - * The callback parameter should be a function that looks like this: - * function(string iconURL) {...}; - */ + /** + * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message. + * @param downloadId The identifier for the download. + * @param callback A URL to an image that represents the download. + * The callback parameter should be a function that looks like this: + * function(string iconURL) {...}; + */ export function getFileIcon(downloadId: number, options: GetFileIconOptions, callback: (iconURL: string) => void): void; - /** - * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active. - * @param downloadId The id of the download to resume. - * @param callback Called when the resume request is completed. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active. + * @param downloadId The id of the download to resume. + * @param callback Called when the resume request is completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function resume(downloadId: number, callback?: () => void): void; - /** - * Cancel a download. When callback is run, the download is cancelled, completed, interrupted or doesn't exist anymore. - * @param downloadId The id of the download to cancel. - * @param callback Called when the cancel request is completed. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Cancel a download. When callback is run, the download is cancelled, completed, interrupted or doesn't exist anymore. + * @param downloadId The id of the download to cancel. + * @param callback Called when the cancel request is completed. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function cancel(downloadId: number, callback?: () => void): void; - /** - * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If both filename and saveAs are specified, then the Save As dialog will be displayed, pre-populated with the specified filename. If the download started successfully, callback will be called with the new DownloadItem's downloadId. If there was an error starting the download, then callback will be called with downloadId=undefined and runtime.lastError will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it. - * @param options What to download and how. - * @param callback Called with the id of the new DownloadItem. - * If you specify the callback parameter, it should be a function that looks like this: - * function(integer downloadId) {...}; - */ + /** + * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If both filename and saveAs are specified, then the Save As dialog will be displayed, pre-populated with the specified filename. If the download started successfully, callback will be called with the new DownloadItem's downloadId. If there was an error starting the download, then callback will be called with downloadId=undefined and runtime.lastError will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it. + * @param options What to download and how. + * @param callback Called with the id of the new DownloadItem. + * If you specify the callback parameter, it should be a function that looks like this: + * function(integer downloadId) {...}; + */ export function download(options: DownloadOptions, callback?: (downloadId: number) => void): void; - /** - * Open the downloaded file now if the DownloadItem is complete; otherwise returns an error through runtime.lastError. Requires the "downloads.open" permission in addition to the "downloads" permission. An onChanged event will fire when the item is opened for the first time. - * @param downloadId The identifier for the downloaded file. - */ + /** + * Open the downloaded file now if the DownloadItem is complete; otherwise returns an error through runtime.lastError. Requires the "downloads.open" permission in addition to the "downloads" permission. An onChanged event will fire when the item is opened for the first time. + * @param downloadId The identifier for the downloaded file. + */ export function open(downloadId: number): void; - /** - * Show the downloaded file in its folder in a file manager. - * @param downloadId The identifier for the downloaded file. - */ + /** + * Show the downloaded file in its folder in a file manager. + * @param downloadId The identifier for the downloaded file. + */ export function show(downloadId: number): void; - /** Show the default Downloads folder in a file manager. */ + /** Show the default Downloads folder in a file manager. */ export function showDefaultFolder(): void; - /** - * Erase matching DownloadItem from history without deleting the downloaded file. An onErased event will fire for each DownloadItem that matches query, then callback will be called. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(array of integer erasedIds) {...}; - */ + /** + * Erase matching DownloadItem from history without deleting the downloaded file. An onErased event will fire for each DownloadItem that matches query, then callback will be called. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(array of integer erasedIds) {...}; + */ export function erase(query: DownloadQuery, callback: (erasedIds: number[]) => void): void; - /** - * Remove the downloaded file if it exists and the DownloadItem is complete; otherwise return an error through runtime.lastError. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Remove the downloaded file if it exists and the DownloadItem is complete; otherwise return an error through runtime.lastError. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function removeFile(downloadId: number, callback?: () => void): void; - /** - * Prompt the user to accept a dangerous download. Can only be called from a visible context (tab, window, or page/browser action popup). Does not automatically accept dangerous downloads. If the download is accepted, then an onChanged event will fire, otherwise nothing will happen. When all the data is fetched into a temporary file and either the download is not dangerous or the danger has been accepted, then the temporary file is renamed to the target filename, the |state| changes to 'complete', and onChanged fires. - * @param downloadId The identifier for the DownloadItem. - * @param callback Called when the danger prompt dialog closes. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Prompt the user to accept a dangerous download. Can only be called from a visible context (tab, window, or page/browser action popup). Does not automatically accept dangerous downloads. If the download is accepted, then an onChanged event will fire, otherwise nothing will happen. When all the data is fetched into a temporary file and either the download is not dangerous or the danger has been accepted, then the temporary file is renamed to the target filename, the |state| changes to 'complete', and onChanged fires. + * @param downloadId The identifier for the DownloadItem. + * @param callback Called when the danger prompt dialog closes. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function acceptDanger(downloadId: number, callback: () => void): void; - /** Initiate dragging the downloaded file to another application. Call in a javascript ondragstart handler. */ + /** Initiate dragging the downloaded file to another application. Call in a javascript ondragstart handler. */ export function drag(downloadId: number): void; - /** Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.shelf" permission in addition to the "downloads" permission. */ + /** Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.shelf" permission in addition to the "downloads" permission. */ export function setShelfEnabled(enabled: boolean): void; - /** When any of a DownloadItem's properties except bytesReceived and estimatedEndTime changes, this event fires with the downloadId and an object containing the properties that changed. */ + /** When any of a DownloadItem's properties except bytesReceived and estimatedEndTime changes, this event fires with the downloadId and an object containing the properties that changed. */ var onChanged: DownloadChangedEvent; - /** This event fires with the DownloadItem object when a download begins. */ + /** This event fires with the DownloadItem object when a download begins. */ var onCreated: DownloadCreatedEvent; - /** Fires with the downloadId when a download is erased from history. */ + /** Fires with the downloadId when a download is erased from history. */ var onErased: DownloadErasedEvent; - /** During the filename determination process, extensions will be given the opportunity to override the target DownloadItem.filename. Each extension may not register more than one listener for this event. Each listener must call suggest exactly once, either synchronously or asynchronously. If the listener calls suggest asynchronously, then it must return true. If the listener neither calls suggest synchronously nor returns true, then suggest will be called automatically. The DownloadItem will not complete until all listeners have called suggest. Listeners may call suggest without any arguments in order to allow the download to use downloadItem.filename for its filename, or pass a suggestion object to suggest in order to override the target filename. If more than one extension overrides the filename, then the last extension installed whose listener passes a suggestion object to suggest wins. In order to avoid confusion regarding which extension will win, users should not install extensions that may conflict. If the download is initiated by download and the target filename is known before the MIME type and tentative filename have been determined, pass filename to download instead. */ - var onDeterminingFilename: DownloadDeterminingFilenameEvent; + /** During the filename determination process, extensions will be given the opportunity to override the target DownloadItem.filename. Each extension may not register more than one listener for this event. Each listener must call suggest exactly once, either synchronously or asynchronously. If the listener calls suggest asynchronously, then it must return true. If the listener neither calls suggest synchronously nor returns true, then suggest will be called automatically. The DownloadItem will not complete until all listeners have called suggest. Listeners may call suggest without any arguments in order to allow the download to use downloadItem.filename for its filename, or pass a suggestion object to suggest in order to override the target filename. If more than one extension overrides the filename, then the last extension installed whose listener passes a suggestion object to suggest wins. In order to avoid confusion regarding which extension will win, users should not install extensions that may conflict. If the download is initiated by download and the target filename is known before the MIME type and tentative filename have been determined, pass filename to download instead. */ + var onDeterminingFilename: DownloadDeterminingFilenameEvent; } //////////////////// @@ -2233,55 +2233,55 @@ declare namespace chrome.downloads { * Note: This API is only for extensions pre-installed by policy. */ declare namespace chrome.enterprise.platformKeys { - interface Token { - /** - * Uniquely identifies this Token. - * Static IDs are "user" and "system", referring to the platform's user-specific and the system-wide hardware token, respectively. Any other tokens (with other identifiers) might be returned by enterprise.platformKeys.getTokens. - */ - id: string; - /** - * Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are hardware-backed. - * Only non-extractable RSASSA-PKCS1-V1_5 keys with modulusLength up to 2048 can be generated. Each key can be used for signing data at most once. - * Keys generated on a specific Token cannot be used with any other Tokens, nor can they be used with window.crypto.subtle. Equally, Key objects created with window.crypto.subtle cannot be used with this interface. - */ - subtleCrypto: SubtleCrypto; - } + interface Token { + /** + * Uniquely identifies this Token. + * Static IDs are "user" and "system", referring to the platform's user-specific and the system-wide hardware token, respectively. Any other tokens (with other identifiers) might be returned by enterprise.platformKeys.getTokens. + */ + id: string; + /** + * Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are hardware-backed. + * Only non-extractable RSASSA-PKCS1-V1_5 keys with modulusLength up to 2048 can be generated. Each key can be used for signing data at most once. + * Keys generated on a specific Token cannot be used with any other Tokens, nor can they be used with window.crypto.subtle. Equally, Key objects created with window.crypto.subtle cannot be used with this interface. + */ + subtleCrypto: SubtleCrypto; + } - /** - * Returns the available Tokens. In a regular user's session the list will always contain the user's token with id "user". If a system-wide TPM token is available, the returned list will also contain the system-wide token with id "system". The system-wide token will be the same for all sessions on this device (device in the sense of e.g. a Chromebook). - * @param callback Invoked by getTokens with the list of available Tokens. - * The callback parameter should be a function that looks like this: - * function(array of Token tokens) {...}; - * Parameter tokens: The list of available tokens. - */ - export function getToken(callback: (tokens: Token[]) => void): void; - /** - * Returns the list of all client certificates available from the given token. Can be used to check for the existence and expiration of client certificates that are usable for a certain authentication. - * @param tokenId The id of a Token returned by getTokens. - * @param callback Called back with the list of the available certificates. - * The callback parameter should be a function that looks like this: - * function(array of ArrayBuffer certificates) {...}; - * Parameter certificates: The list of certificates, each in DER encoding of a X.509 certificate. - */ - export function getCertificates(tokenId: string, callback: (certificates: ArrayBuffer) => void): void; - /** - * Imports certificate to the given token if the certified key is already stored in this token. After a successful certification request, this function should be used to store the obtained certificate and to make it available to the operating system and browser for authentication. - * @param tokenId The id of a Token returned by getTokens. - * @param certificate The DER encoding of a X.509 certificate. - * @param callback Called back when this operation is finished. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function importCertificate(tokenId: string, certificate: ArrayBuffer, callback?: () => void): void; - /** - * Removes certificate from the given token if present. Should be used to remove obsolete certificates so that they are not considered during authentication and do not clutter the certificate choice. Should be used to free storage in the certificate store. - * @param tokenId The id of a Token returned by getTokens. - * @param certificate The DER encoding of a X.509 certificate. - * @param callback Called back when this operation is finished. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function removeCertificate(tokenId: string, certificate: ArrayBuffer, callback?: () => void): void; + /** + * Returns the available Tokens. In a regular user's session the list will always contain the user's token with id "user". If a system-wide TPM token is available, the returned list will also contain the system-wide token with id "system". The system-wide token will be the same for all sessions on this device (device in the sense of e.g. a Chromebook). + * @param callback Invoked by getTokens with the list of available Tokens. + * The callback parameter should be a function that looks like this: + * function(array of Token tokens) {...}; + * Parameter tokens: The list of available tokens. + */ + export function getToken(callback: (tokens: Token[]) => void): void; + /** + * Returns the list of all client certificates available from the given token. Can be used to check for the existence and expiration of client certificates that are usable for a certain authentication. + * @param tokenId The id of a Token returned by getTokens. + * @param callback Called back with the list of the available certificates. + * The callback parameter should be a function that looks like this: + * function(array of ArrayBuffer certificates) {...}; + * Parameter certificates: The list of certificates, each in DER encoding of a X.509 certificate. + */ + export function getCertificates(tokenId: string, callback: (certificates: ArrayBuffer) => void): void; + /** + * Imports certificate to the given token if the certified key is already stored in this token. After a successful certification request, this function should be used to store the obtained certificate and to make it available to the operating system and browser for authentication. + * @param tokenId The id of a Token returned by getTokens. + * @param certificate The DER encoding of a X.509 certificate. + * @param callback Called back when this operation is finished. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function importCertificate(tokenId: string, certificate: ArrayBuffer, callback?: () => void): void; + /** + * Removes certificate from the given token if present. Should be used to remove obsolete certificates so that they are not considered during authentication and do not clutter the certificate choice. Should be used to free storage in the certificate store. + * @param tokenId The id of a Token returned by getTokens. + * @param certificate The DER encoding of a X.509 certificate. + * @param callback Called back when this operation is finished. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function removeCertificate(tokenId: string, certificate: ArrayBuffer, callback?: () => void): void; } //////////////////// @@ -2292,138 +2292,138 @@ declare namespace chrome.enterprise.platformKeys { * Availability: Since Chrome 21. */ declare namespace chrome.events { - /** Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ + /** Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ interface UrlFilter { - /** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ + /** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ schemes?: string[]; - /** - * Optional. - * Since Chrome 23. - * Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. - */ + /** + * Optional. + * Since Chrome 23. + * Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. + */ urlMatches?: string; - /** Optional. Matches if the path segment of the URL contains a specified string. */ + /** Optional. Matches if the path segment of the URL contains a specified string. */ pathContains?: string; - /** Optional. Matches if the host name of the URL ends with a specified string. */ + /** Optional. Matches if the host name of the URL ends with a specified string. */ hostSuffix?: string; - /** Optional. Matches if the host name of the URL starts with a specified string. */ + /** Optional. Matches if the host name of the URL starts with a specified string. */ hostPrefix?: string; - /** Optional. Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */ + /** Optional. Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */ hostContains?: string; - /** Optional. Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */ + /** Optional. Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlContains?: string; - /** Optional. Matches if the query segment of the URL ends with a specified string. */ + /** Optional. Matches if the query segment of the URL ends with a specified string. */ querySuffix?: string; - /** Optional. Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */ + /** Optional. Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlPrefix?: string; - /** Optional. Matches if the host name of the URL is equal to a specified string. */ + /** Optional. Matches if the host name of the URL is equal to a specified string. */ hostEquals?: string; - /** Optional. Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */ + /** Optional. Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlEquals?: string; - /** Optional. Matches if the query segment of the URL contains a specified string. */ + /** Optional. Matches if the query segment of the URL contains a specified string. */ queryContains?: string; - /** Optional. Matches if the path segment of the URL starts with a specified string. */ + /** Optional. Matches if the path segment of the URL starts with a specified string. */ pathPrefix?: string; - /** Optional. Matches if the path segment of the URL is equal to a specified string. */ + /** Optional. Matches if the path segment of the URL is equal to a specified string. */ pathEquals?: string; - /** Optional. Matches if the path segment of the URL ends with a specified string. */ + /** Optional. Matches if the path segment of the URL ends with a specified string. */ pathSuffix?: string; - /** Optional. Matches if the query segment of the URL is equal to a specified string. */ + /** Optional. Matches if the query segment of the URL is equal to a specified string. */ queryEquals?: string; - /** Optional. Matches if the query segment of the URL starts with a specified string. */ + /** Optional. Matches if the query segment of the URL starts with a specified string. */ queryPrefix?: string; - /** Optional. Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */ + /** Optional. Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */ urlSuffix?: string; - /** Optional. Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */ + /** Optional. Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */ ports?: any[]; - /** - * Optional. - * Since Chrome 28. - * Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. - */ - originAndPathMatches?: string; + /** + * Optional. + * Since Chrome 28. + * Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. + */ + originAndPathMatches?: string; } - /** An object which allows the addition and removal of listeners for a Chrome event. */ + /** An object which allows the addition and removal of listeners for a Chrome event. */ interface Event { - /** - * Registers an event listener callback to an event. - * @param callback Called when an event occurs. The parameters of this function depend on the type of event. - * The callback parameter should be a function that looks like this: - * function() {...}; - */ + /** + * Registers an event listener callback to an event. + * @param callback Called when an event occurs. The parameters of this function depend on the type of event. + * The callback parameter should be a function that looks like this: + * function() {...}; + */ addListener(callback: T): void; - /** - * Returns currently registered rules. - * @param callback Called with registered rules. - * The callback parameter should be a function that looks like this: - * function(array of Rule rules) {...}; - * Parameter rules: Rules that were registered, the optional parameters are filled with values. - */ + /** + * Returns currently registered rules. + * @param callback Called with registered rules. + * The callback parameter should be a function that looks like this: + * function(array of Rule rules) {...}; + * Parameter rules: Rules that were registered, the optional parameters are filled with values. + */ getRules(callback: (rules: Rule[]) => void): void; - /** - * Returns currently registered rules. - * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are returned. - * @param callback Called with registered rules. - * The callback parameter should be a function that looks like this: - * function(array of Rule rules) {...}; - * Parameter rules: Rules that were registered, the optional parameters are filled with values. - */ + /** + * Returns currently registered rules. + * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are returned. + * @param callback Called with registered rules. + * The callback parameter should be a function that looks like this: + * function(array of Rule rules) {...}; + * Parameter rules: Rules that were registered, the optional parameters are filled with values. + */ getRules(ruleIdentifiers: string[], callback: (rules: Rule[]) => void): void; /** - * @param callback Listener whose registration status shall be tested. - */ + * @param callback Listener whose registration status shall be tested. + */ hasListener(callback: T): boolean; - /** - * Unregisters currently registered rules. - * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are unregistered. - * @param callback Called when rules were unregistered. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Unregisters currently registered rules. + * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are unregistered. + * @param callback Called when rules were unregistered. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ removeRules(ruleIdentifiers?: string[], callback?: () => void): void; - /** - * Unregisters currently registered rules. - * @param callback Called when rules were unregistered. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Unregisters currently registered rules. + * @param callback Called when rules were unregistered. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ removeRules(callback?: () => void): void; - /** - * Registers rules to handle events. - * @param rules Rules to be registered. These do not replace previously registered rules. - * @param callback Called with registered rules. - * If you specify the callback parameter, it should be a function that looks like this: - * function(array of Rule rules) {...}; - * Parameter rules: Rules that were registered, the optional parameters are filled with values. - */ + /** + * Registers rules to handle events. + * @param rules Rules to be registered. These do not replace previously registered rules. + * @param callback Called with registered rules. + * If you specify the callback parameter, it should be a function that looks like this: + * function(array of Rule rules) {...}; + * Parameter rules: Rules that were registered, the optional parameters are filled with values. + */ addRules(rules: Rule[], callback?: (rules: Rule[]) => void): void; - /** - * Deregisters an event listener callback from an event. - * @param callback Listener that shall be unregistered. - * The callback parameter should be a function that looks like this: - * function() {...}; - */ + /** + * Deregisters an event listener callback from an event. + * @param callback Listener that shall be unregistered. + * The callback parameter should be a function that looks like this: + * function() {...}; + */ removeListener(callback: T): void; hasListeners(): boolean; } - /** Description of a declarative rule for handling events. */ + /** Description of a declarative rule for handling events. */ interface Rule { - /** Optional. Optional priority of this rule. Defaults to 100. */ + /** Optional. Optional priority of this rule. Defaults to 100. */ priority?: number; - /** List of conditions that can trigger the actions. */ + /** List of conditions that can trigger the actions. */ conditions: any[]; - /** Optional. Optional identifier that allows referencing this rule. */ + /** Optional. Optional identifier that allows referencing this rule. */ id?: string; - /** List of actions that are triggered if one of the condtions is fulfilled. */ + /** List of actions that are triggered if one of the condtions is fulfilled. */ actions: any[]; - /** - * Optional. - * Since Chrome 28. - * Tags can be used to annotate rules and perform operations on sets of rules. - */ - tags?: string[]; + /** + * Optional. + * Since Chrome 28. + * Tags can be used to annotate rules and perform operations on sets of rules. + */ + tags?: string[]; } } @@ -2436,90 +2436,90 @@ declare namespace chrome.events { */ declare namespace chrome.extension { interface FetchProperties { - /** Optional. The window to restrict the search to. If omitted, returns all views. */ + /** Optional. The window to restrict the search to. If omitted, returns all views. */ windowId?: number; - /** Optional. The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'notification', 'popup'. */ + /** Optional. The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'notification', 'popup'. */ type?: string; } interface LastError { - /** Description of the error that has taken place. */ + /** Description of the error that has taken place. */ message: string; } - interface OnRequestEvent extends chrome.events.Event<((request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void) | ((sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)> {} + interface OnRequestEvent extends chrome.events.Event<((request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void) | ((sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)> {} - /** - * Since Chrome 7. - * True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior. - */ + /** + * Since Chrome 7. + * True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior. + */ var inIncognitoContext: boolean; - /** Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be undefined. */ + /** Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be undefined. */ var lastError: LastError; - /** Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page. */ + /** Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page. */ export function getBackgroundPage(): Window | null; - /** - * Converts a relative path within an extension install directory to a fully-qualified URL. - * @param path A path to a resource within an extension expressed relative to its install directory. - */ + /** + * Converts a relative path within an extension install directory to a fully-qualified URL. + * @param path A path to a resource within an extension expressed relative to its install directory. + */ export function getURL(path: string): string; - /** - * Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery. - * Since Chrome 9. - */ + /** + * Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery. + * Since Chrome 9. + */ export function setUpdateUrlData(data: string): void; - /** Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. */ + /** Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. */ export function getViews(fetchProperties?: FetchProperties): Window[]; - /** - * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox. - * Since Chrome 12. - * @param callback The callback parameter should be a function that looks like this: - * function(boolean isAllowedAccess) {...}; - * Parameter isAllowedAccess: True if the extension can access the 'file://' scheme, false otherwise. - */ + /** + * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox. + * Since Chrome 12. + * @param callback The callback parameter should be a function that looks like this: + * function(boolean isAllowedAccess) {...}; + * Parameter isAllowedAccess: True if the extension can access the 'file://' scheme, false otherwise. + */ export function isAllowedFileSchemeAccess(callback: (isAllowedAccess: boolean) => void): void; - /** - * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox. - * Since Chrome 12. - * @param callback The callback parameter should be a function that looks like this: - * function(boolean isAllowedAccess) {...}; - * Parameter isAllowedAccess: True if the extension has access to Incognito mode, false otherwise. - */ + /** + * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox. + * Since Chrome 12. + * @param callback The callback parameter should be a function that looks like this: + * function(boolean isAllowedAccess) {...}; + * Parameter isAllowedAccess: True if the extension has access to Incognito mode, false otherwise. + */ export function isAllowedIncognitoAccess(callback: (isAllowedAccess: boolean) => void): void; - /** - * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension. - * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage. - * @param extensionId The extension ID of the extension you want to connect to. If omitted, default is your own extension. - * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: - * function(any response) {...}; - * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. - */ - export function sendRequest(extensionId: string, request: any, responseCallback?: (response: any) => void): void; - /** - * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension. - * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage. - * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: - * function(any response) {...}; - * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. - */ - export function sendRequest(request: any, responseCallback?: (response: any) => void): void; - /** - * Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window. - * @deprecated Deprecated since Chrome 33. Please use extension.getViews {type: "tab"}. - */ - export function getExtensionTabs(windowId?: number): Window[]; + /** + * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension. + * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage. + * @param extensionId The extension ID of the extension you want to connect to. If omitted, default is your own extension. + * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: + * function(any response) {...}; + * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. + */ + export function sendRequest(extensionId: string, request: any, responseCallback?: (response: any) => void): void; + /** + * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension. + * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage. + * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this: + * function(any response) {...}; + * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. + */ + export function sendRequest(request: any, responseCallback?: (response: any) => void): void; + /** + * Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window. + * @deprecated Deprecated since Chrome 33. Please use extension.getViews {type: "tab"}. + */ + export function getExtensionTabs(windowId?: number): Window[]; - /** - * Fired when a request is sent from either an extension process or a content script. - * @deprecated Deprecated since Chrome 33. Please use runtime.onMessage. - */ - var onRequest: OnRequestEvent; - /** - * Fired when a request is sent from another extension. - * @deprecated Deprecated since Chrome 33. Please use runtime.onMessageExternal. - */ - var onRequestExternal: OnRequestEvent; + /** + * Fired when a request is sent from either an extension process or a content script. + * @deprecated Deprecated since Chrome 33. Please use runtime.onMessage. + */ + var onRequest: OnRequestEvent; + /** + * Fired when a request is sent from another extension. + * @deprecated Deprecated since Chrome 33. Please use runtime.onMessageExternal. + */ + var onRequestExternal: OnRequestEvent; } //////////////////// @@ -2533,45 +2533,45 @@ declare namespace chrome.extension { */ declare namespace chrome.fileBrowserHandler { interface SelectionParams { - /** - * Optional. - * List of file extensions that the selected file can have. The list is also used to specify what files to be shown in the select file dialog. Files with the listed extensions are only shown in the dialog. Extensions should not include the leading '.'. Example: ['jpg', 'png'] - * Since Chrome 23. - */ + /** + * Optional. + * List of file extensions that the selected file can have. The list is also used to specify what files to be shown in the select file dialog. Files with the listed extensions are only shown in the dialog. Extensions should not include the leading '.'. Example: ['jpg', 'png'] + * Since Chrome 23. + */ allowedFileExtensions?: string[]; - /** Suggested name for the file. */ + /** Suggested name for the file. */ suggestedName: string; } interface SelectionResult { - /** Optional. Selected file entry. It will be null if a file hasn't been selected. */ + /** Optional. Selected file entry. It will be null if a file hasn't been selected. */ entry?: Object | null; - /** Whether the file has been selected. */ + /** Whether the file has been selected. */ success: boolean; } - /** Event details payload for fileBrowserHandler.onExecute event. */ + /** Event details payload for fileBrowserHandler.onExecute event. */ interface FileHandlerExecuteEventDetails { - /** Optional. The ID of the tab that raised this event. Tab IDs are unique within a browser session. */ + /** Optional. The ID of the tab that raised this event. Tab IDs are unique within a browser session. */ tab_id?: number; - /** Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser). */ + /** Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser). */ entries: any[]; } interface FileBrowserHandlerExecuteEvent extends chrome.events.Event<(id: string, details: FileHandlerExecuteEventDetails) => void> {} - /** - * Prompts user to select file path under which file should be saved. When the file is selected, file access permission required to use the file (read, write and create) are granted to the caller. The file will not actually get created during the function call, so function caller must ensure its existence before using it. The function has to be invoked with a user gesture. - * Since Chrome 21. - * @param selectionParams Parameters that will be used while selecting the file. - * @param callback Function called upon completion. - * The callback parameter should be a function that looks like this: - * function(object result) {...}; - * Parameter result: Result of the method. - */ - export function selectFile(selectionParams: SelectionParams, callback: (result: SelectionResult) => void): void; + /** + * Prompts user to select file path under which file should be saved. When the file is selected, file access permission required to use the file (read, write and create) are granted to the caller. The file will not actually get created during the function call, so function caller must ensure its existence before using it. The function has to be invoked with a user gesture. + * Since Chrome 21. + * @param selectionParams Parameters that will be used while selecting the file. + * @param callback Function called upon completion. + * The callback parameter should be a function that looks like this: + * function(object result) {...}; + * Parameter result: Result of the method. + */ + export function selectFile(selectionParams: SelectionParams, callback: (result: SelectionResult) => void): void; - /** Fired when file system action is executed from ChromeOS file browser. */ + /** Fired when file system action is executed from ChromeOS file browser. */ var onExecute: FileBrowserHandlerExecuteEvent; } @@ -2585,346 +2585,346 @@ declare namespace chrome.fileBrowserHandler { * Important: This API works only on Chrome OS. */ declare namespace chrome.fileSystemProvider { - interface OpenedFileInfo { - /** A request ID to be be used by consecutive read/write and close requests. */ - openRequestId: number; - /** The path of the opened file. */ - filePath: string; - /** Whether the file was opened for reading or writing. */ - mode: string; - } + interface OpenedFileInfo { + /** A request ID to be be used by consecutive read/write and close requests. */ + openRequestId: number; + /** The path of the opened file. */ + filePath: string; + /** Whether the file was opened for reading or writing. */ + mode: string; + } - interface FileWatchersInfo { - /** The path of the entry being observed. */ - entryPath: string; - /** Whether watching should include all child entries recursively. It can be true for directories only. */ - recursive: boolean; - /** Optional. Tag used by the last notification for the watcher. */ - lastTag?: string; - } + interface FileWatchersInfo { + /** The path of the entry being observed. */ + entryPath: string; + /** Whether watching should include all child entries recursively. It can be true for directories only. */ + recursive: boolean; + /** Optional. Tag used by the last notification for the watcher. */ + lastTag?: string; + } - interface EntryMetadata { - /** True if it is a directory. */ - isDirectory: boolean; - /** Name of this entry (not full path name). Must not contain '/'. For root it must be empty. */ - name: string; - /** File size in bytes. */ - size: number; - /** The last modified time of this entry. */ - modificationTime: Date; - /** Optional. Mime type for the entry. */ - mimeType?: string; - /** Optional. Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most 32 KB in size. Optional, but can be provided only when explicitly requested by the onGetMetadataRequested event. */ - thumbnail?: string; - } + interface EntryMetadata { + /** True if it is a directory. */ + isDirectory: boolean; + /** Name of this entry (not full path name). Must not contain '/'. For root it must be empty. */ + name: string; + /** File size in bytes. */ + size: number; + /** The last modified time of this entry. */ + modificationTime: Date; + /** Optional. Mime type for the entry. */ + mimeType?: string; + /** Optional. Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most 32 KB in size. Optional, but can be provided only when explicitly requested by the onGetMetadataRequested event. */ + thumbnail?: string; + } - interface FileSystemInfo { - /** The identifier of the file system. */ - fileSystemId: string; - /** A human-readable name for the file system. */ - displayName: string; - /** Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */ - writable: boolean; - /** - * The maximum number of files that can be opened at once. If 0, then not limited. - * @since Since Chrome 42. - */ - openedFilesLimit: number; - /** - * List of currently opened files. - * @since Since Chrome 42. - */ - openedFiles: OpenedFileInfo[]; - /** - * Optional. - * Whether the file system supports the tag field for observing directories. - * @since Since Chrome 45. Warning: this is the current Beta channel. - */ - supportsNotifyTag?: boolean; - /** - * List of watchers. - * @since Since Chrome 45. Warning: this is the current Beta channel. - */ - watchers: FileWatchersInfo[]; - } + interface FileSystemInfo { + /** The identifier of the file system. */ + fileSystemId: string; + /** A human-readable name for the file system. */ + displayName: string; + /** Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */ + writable: boolean; + /** + * The maximum number of files that can be opened at once. If 0, then not limited. + * @since Since Chrome 42. + */ + openedFilesLimit: number; + /** + * List of currently opened files. + * @since Since Chrome 42. + */ + openedFiles: OpenedFileInfo[]; + /** + * Optional. + * Whether the file system supports the tag field for observing directories. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + supportsNotifyTag?: boolean; + /** + * List of watchers. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + watchers: FileWatchersInfo[]; + } - /** @since Since Chrome 45. Warning: this is the current Beta channel. */ - interface GetActionsRequestedOptions { - /** The identifier of the file system related to this operation. */ - fileSystemId: string; - /** The unique identifier of this request. */ - requestId: number; - /** The path of the entry to return the list of actions for. */ - entryPath: string; - } + /** @since Since Chrome 45. Warning: this is the current Beta channel. */ + interface GetActionsRequestedOptions { + /** The identifier of the file system related to this operation. */ + fileSystemId: string; + /** The unique identifier of this request. */ + requestId: number; + /** The path of the entry to return the list of actions for. */ + entryPath: string; + } - /** @since Since Chrome 45. Warning: this is the current Beta channel. */ - interface Action { - /** The identifier of the action. Any string or CommonActionId for common actions. */ - id: string; - /** Optional. The title of the action. It may be ignored for common actions. */ - title?: string; - } + /** @since Since Chrome 45. Warning: this is the current Beta channel. */ + interface Action { + /** The identifier of the action. Any string or CommonActionId for common actions. */ + id: string; + /** Optional. The title of the action. It may be ignored for common actions. */ + title?: string; + } - /** @since Since Chrome 45. Warning: this is the current Beta channel. */ - interface ExecuteActionRequestedOptions { - /** The identifier of the file system related to this operation. */ - fileSystemId: string; - /** The unique identifier of this request. */ - requestId: number; - /** The path of the entry to be used for the action. */ - entryPath: string; - /** The identifier of the action to be executed. */ - actionId: string; - } + /** @since Since Chrome 45. Warning: this is the current Beta channel. */ + interface ExecuteActionRequestedOptions { + /** The identifier of the file system related to this operation. */ + fileSystemId: string; + /** The unique identifier of this request. */ + requestId: number; + /** The path of the entry to be used for the action. */ + entryPath: string; + /** The identifier of the action to be executed. */ + actionId: string; + } - interface MountOptions { - /** The string indentifier of the file system. Must be unique per each extension. */ - fileSystemId: string; - /** A human-readable name for the file system. */ - displayName: string; - /** Optional. Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */ - writable?: boolean; - /** - * Optional. - * The maximum number of files that can be opened at once. If not specified, or 0, then not limited. - * @since Since Chrome 41. - */ - openedFilesLimit?: number; - /** - * Optional. - * Whether the file system supports the tag field for observed directories. - * @since Since Chrome 45. Warning: this is the current Beta channel. - */ - supportsNotifyTag?: boolean; - } + interface MountOptions { + /** The string indentifier of the file system. Must be unique per each extension. */ + fileSystemId: string; + /** A human-readable name for the file system. */ + displayName: string; + /** Optional. Whether the file system supports operations which may change contents of the file system (such as creating, deleting or writing to files). */ + writable?: boolean; + /** + * Optional. + * The maximum number of files that can be opened at once. If not specified, or 0, then not limited. + * @since Since Chrome 41. + */ + openedFilesLimit?: number; + /** + * Optional. + * Whether the file system supports the tag field for observed directories. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + supportsNotifyTag?: boolean; + } - interface UnmountOptions { - /** The identifier of the file system to be unmounted. */ - fileSystemId: string; - } + interface UnmountOptions { + /** The identifier of the file system to be unmounted. */ + fileSystemId: string; + } - interface NotificationChange { - /** The path of the changed entry. */ - entryPath: string; - /** The type of the change which happened to the entry. */ - changeType: string; - } + interface NotificationChange { + /** The path of the changed entry. */ + entryPath: string; + /** The type of the change which happened to the entry. */ + changeType: string; + } - interface NotificationOptions { - /** The identifier of the file system related to this change. */ - fileSystemId: string; - /** The path of the observed entry. */ - observedPath: string; - /** Mode of the observed entry. */ - recursive: boolean; - /** The type of the change which happened to the observed entry. If it is DELETED, then the observed entry will be automatically removed from the list of observed entries. */ - changeType: string; - /** Optional. List of changes to entries within the observed directory (including the entry itself) */ - changes?: NotificationChange[]; - /** Optional. Tag for the notification. Required if the file system was mounted with the supportsNotifyTag option. Note, that this flag is necessary to provide notifications about changes which changed even when the system was shutdown. */ - tag?: string; - } + interface NotificationOptions { + /** The identifier of the file system related to this change. */ + fileSystemId: string; + /** The path of the observed entry. */ + observedPath: string; + /** Mode of the observed entry. */ + recursive: boolean; + /** The type of the change which happened to the observed entry. If it is DELETED, then the observed entry will be automatically removed from the list of observed entries. */ + changeType: string; + /** Optional. List of changes to entries within the observed directory (including the entry itself) */ + changes?: NotificationChange[]; + /** Optional. Tag for the notification. Required if the file system was mounted with the supportsNotifyTag option. Note, that this flag is necessary to provide notifications about changes which changed even when the system was shutdown. */ + tag?: string; + } - interface RequestedEventOptions { - /** The identifier of the file system related to this operation. */ - fileSystemId: string; - /** The unique identifier of this request. */ - requestId: number; - } + interface RequestedEventOptions { + /** The identifier of the file system related to this operation. */ + fileSystemId: string; + /** The unique identifier of this request. */ + requestId: number; + } - interface EntryPathRequestedEventOptions extends RequestedEventOptions { - /** The path of the entry to which this operation is related to. */ - entryPath: string; - } + interface EntryPathRequestedEventOptions extends RequestedEventOptions { + /** The path of the entry to which this operation is related to. */ + entryPath: string; + } - interface MetadataRequestedEventOptions extends EntryPathRequestedEventOptions { - /** Set to true if the thumbnail is requested. */ - thumbnail: boolean; - } + interface MetadataRequestedEventOptions extends EntryPathRequestedEventOptions { + /** Set to true if the thumbnail is requested. */ + thumbnail: boolean; + } - interface DirectoryPathRequestedEventOptions extends RequestedEventOptions { - /** The path of the directory which is to be operated on. */ - directoryPath: string; - } + interface DirectoryPathRequestedEventOptions extends RequestedEventOptions { + /** The path of the directory which is to be operated on. */ + directoryPath: string; + } - interface FilePathRequestedEventOptions extends RequestedEventOptions { - /** The path of the entry for the operation */ - filePath: string; - } + interface FilePathRequestedEventOptions extends RequestedEventOptions { + /** The path of the entry for the operation */ + filePath: string; + } - interface OpenFileRequestedEventOptions extends FilePathRequestedEventOptions { - /** Whether the file will be used for reading or writing. */ - mode: string; - } + interface OpenFileRequestedEventOptions extends FilePathRequestedEventOptions { + /** Whether the file will be used for reading or writing. */ + mode: string; + } - interface OpenedFileRequestedEventOptions extends RequestedEventOptions { - /** A request ID used to open the file. */ - openRequestId: number; - } + interface OpenedFileRequestedEventOptions extends RequestedEventOptions { + /** A request ID used to open the file. */ + openRequestId: number; + } - interface OpenedFileOffsetRequestedEventOptions extends OpenedFileRequestedEventOptions { - /** Position in the file (in bytes) to start reading from. */ - offset: number; - /** Number of bytes to be returned. */ - length: number; - } + interface OpenedFileOffsetRequestedEventOptions extends OpenedFileRequestedEventOptions { + /** Position in the file (in bytes) to start reading from. */ + offset: number; + /** Number of bytes to be returned. */ + length: number; + } - interface DirectoryPathRecursiveRequestedEventOptions extends DirectoryPathRequestedEventOptions { - /** Whether the operation is recursive (for directories only). */ - recursive: boolean; - } + interface DirectoryPathRecursiveRequestedEventOptions extends DirectoryPathRequestedEventOptions { + /** Whether the operation is recursive (for directories only). */ + recursive: boolean; + } - interface EntryPathRecursiveRequestedEventOptions extends EntryPathRequestedEventOptions { - /** Whether the operation is recursive (for directories only). */ - recursive: boolean; - } + interface EntryPathRecursiveRequestedEventOptions extends EntryPathRequestedEventOptions { + /** Whether the operation is recursive (for directories only). */ + recursive: boolean; + } - interface SourceTargetPathRequestedEventOptions extends RequestedEventOptions { - /** The source path for the operation. */ - sourcePath: string; - /** The destination path for the operation. */ - targetPath: string; - } + interface SourceTargetPathRequestedEventOptions extends RequestedEventOptions { + /** The source path for the operation. */ + sourcePath: string; + /** The destination path for the operation. */ + targetPath: string; + } - interface FilePathLengthRequestedEventOptions extends FilePathRequestedEventOptions { - /** Number of bytes to be retained after the operation completes. */ - length: number; - } + interface FilePathLengthRequestedEventOptions extends FilePathRequestedEventOptions { + /** Number of bytes to be retained after the operation completes. */ + length: number; + } - interface OpenedFileIoRequestedEventOptions extends OpenedFileRequestedEventOptions { - /** Position in the file (in bytes) to start operating from. */ - offset: number; - /** Buffer of bytes to be operated on the file. */ - data: ArrayBuffer; - } + interface OpenedFileIoRequestedEventOptions extends OpenedFileRequestedEventOptions { + /** Position in the file (in bytes) to start operating from. */ + offset: number; + /** Buffer of bytes to be operated on the file. */ + data: ArrayBuffer; + } - interface OperationRequestedEventOptions extends RequestedEventOptions { - /** An ID of the request to which this operation is related. */ - operationRequestId: number; - } + interface OperationRequestedEventOptions extends RequestedEventOptions { + /** An ID of the request to which this operation is related. */ + operationRequestId: number; + } - interface RequestedEvent extends chrome.events.Event<(options: RequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface RequestedEvent extends chrome.events.Event<(options: RequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface MetadataRequestedEvent extends chrome.events.Event<(options: MetadataRequestedEventOptions, successCallback: (metadata: EntryMetadata) => void, errorCallback: (error: string) => void) => void> {} + interface MetadataRequestedEvent extends chrome.events.Event<(options: MetadataRequestedEventOptions, successCallback: (metadata: EntryMetadata) => void, errorCallback: (error: string) => void) => void> {} - interface DirectoryPathRequestedEvent extends chrome.events.Event<(options: DirectoryPathRequestedEventOptions, successCallback: (entries: EntryMetadata[], hasMore: boolean) => void, errorCallback: (error: string) => void) => void> {} + interface DirectoryPathRequestedEvent extends chrome.events.Event<(options: DirectoryPathRequestedEventOptions, successCallback: (entries: EntryMetadata[], hasMore: boolean) => void, errorCallback: (error: string) => void) => void> {} - interface OpenFileRequestedEvent extends chrome.events.Event<(options: OpenFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface OpenFileRequestedEvent extends chrome.events.Event<(options: OpenFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface OpenedFileRequestedEvent extends chrome.events.Event<(options: OpenedFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface OpenedFileRequestedEvent extends chrome.events.Event<(options: OpenedFileRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface OpenedFileOffsetRequestedEvent extends chrome.events.Event<(options: OpenedFileOffsetRequestedEventOptions, successCallback: (data: ArrayBuffer, hasMore: boolean) => void, errorCallback: (error: string) => void) => void> {} + interface OpenedFileOffsetRequestedEvent extends chrome.events.Event<(options: OpenedFileOffsetRequestedEventOptions, successCallback: (data: ArrayBuffer, hasMore: boolean) => void, errorCallback: (error: string) => void) => void> {} - interface DirectoryPathRecursiveRequestedEvent extends chrome.events.Event<(options: DirectoryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface DirectoryPathRecursiveRequestedEvent extends chrome.events.Event<(options: DirectoryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface EntryPathRecursiveRequestedEvent extends chrome.events.Event<(options: EntryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface EntryPathRecursiveRequestedEvent extends chrome.events.Event<(options: EntryPathRecursiveRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface FilePathRequestedEvent extends chrome.events.Event<(options: FilePathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface FilePathRequestedEvent extends chrome.events.Event<(options: FilePathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface SourceTargetPathRequestedEvent extends chrome.events.Event<(options: SourceTargetPathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface SourceTargetPathRequestedEvent extends chrome.events.Event<(options: SourceTargetPathRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface FilePathLengthRequestedEvent extends chrome.events.Event<(options: FilePathLengthRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface FilePathLengthRequestedEvent extends chrome.events.Event<(options: FilePathLengthRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface OpenedFileIoRequestedEvent extends chrome.events.Event<(options: OpenedFileIoRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface OpenedFileIoRequestedEvent extends chrome.events.Event<(options: OpenedFileIoRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface OperationRequestedEvent extends chrome.events.Event<(options: OperationRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface OperationRequestedEvent extends chrome.events.Event<(options: OperationRequestedEventOptions, successCallback: Function, errorCallback: (error: string) => void) => void> {} - interface OptionlessRequestedEvent extends chrome.events.Event<(successCallback: Function, errorCallback: (error: string) => void) => void> {} + interface OptionlessRequestedEvent extends chrome.events.Event<(successCallback: Function, errorCallback: (error: string) => void) => void> {} - /** - * Mounts a file system with the given fileSystemId and displayName. displayName will be shown in the left panel of Files.app. displayName can contain any characters including '/', but cannot be an empty string. displayName must be descriptive but doesn't have to be unique. The fileSystemId must not be an empty string. - * Depending on the type of the file system being mounted, the source option must be set appropriately. - * In case of an error, runtime.lastError will be set with a corresponding error code. - * @param callback A generic result callback to indicate success or failure. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function mount(options: MountOptions, callback?: () => void): void; - /** - * Unmounts a file system with the given fileSystemId. It must be called after onUnmountRequested is invoked. Also, the providing extension can decide to perform unmounting if not requested (eg. in case of lost connection, or a file error). - * In case of an error, runtime.lastError will be set with a corresponding error code. - * @param callback A generic result callback to indicate success or failure. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function unmount(options: UnmountOptions, callback?: () => void): void; - /** - * Returns all file systems mounted by the extension. - * @param callback Callback to receive the result of getAll function. - * The callback parameter should be a function that looks like this: - * function(array of FileSystemInfo fileSystems) {...}; - */ - export function getAll(callback: (fileSystems: FileSystemInfo[]) => void): void; - /** - * Returns information about a file system with the passed fileSystemId. - * @since Since Chrome 42. - * @param callback Callback to receive the result of get function. - * The callback parameter should be a function that looks like this: - * function(FileSystemInfo fileSystem) {...}; - */ - export function get(fileSystemId: string, callback: (fileSystem: FileSystemInfo) => void): void; - /** - * Notifies about changes in the watched directory at observedPath in recursive mode. If the file system is mounted with supportsNofityTag, then tag must be provided, and all changes since the last notification always reported, even if the system was shutdown. The last tag can be obtained with getAll. - * To use, the file_system_provider.notify manifest option must be set to true. - * Value of tag can be any string which is unique per call, so it's possible to identify the last registered notification. Eg. if the providing extension starts after a reboot, and the last registered notification's tag is equal to "123", then it should call notify for all changes which happened since the change tagged as "123". It cannot be an empty string. - * Not all providers are able to provide a tag, but if the file system has a changelog, then the tag can be eg. a change number, or a revision number. - * Note that if a parent directory is removed, then all descendant entries are also removed, and if they are watched, then the API must be notified about the fact. Also, if a directory is renamed, then all descendant entries are in fact removed, as there is no entry under their original paths anymore. - * In case of an error, runtime.lastError will be set will a corresponding error code. - * @param callback A generic result callback to indicate success or failure. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function notify(options: NotificationOptions, callback: () => void): void; + /** + * Mounts a file system with the given fileSystemId and displayName. displayName will be shown in the left panel of Files.app. displayName can contain any characters including '/', but cannot be an empty string. displayName must be descriptive but doesn't have to be unique. The fileSystemId must not be an empty string. + * Depending on the type of the file system being mounted, the source option must be set appropriately. + * In case of an error, runtime.lastError will be set with a corresponding error code. + * @param callback A generic result callback to indicate success or failure. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function mount(options: MountOptions, callback?: () => void): void; + /** + * Unmounts a file system with the given fileSystemId. It must be called after onUnmountRequested is invoked. Also, the providing extension can decide to perform unmounting if not requested (eg. in case of lost connection, or a file error). + * In case of an error, runtime.lastError will be set with a corresponding error code. + * @param callback A generic result callback to indicate success or failure. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function unmount(options: UnmountOptions, callback?: () => void): void; + /** + * Returns all file systems mounted by the extension. + * @param callback Callback to receive the result of getAll function. + * The callback parameter should be a function that looks like this: + * function(array of FileSystemInfo fileSystems) {...}; + */ + export function getAll(callback: (fileSystems: FileSystemInfo[]) => void): void; + /** + * Returns information about a file system with the passed fileSystemId. + * @since Since Chrome 42. + * @param callback Callback to receive the result of get function. + * The callback parameter should be a function that looks like this: + * function(FileSystemInfo fileSystem) {...}; + */ + export function get(fileSystemId: string, callback: (fileSystem: FileSystemInfo) => void): void; + /** + * Notifies about changes in the watched directory at observedPath in recursive mode. If the file system is mounted with supportsNofityTag, then tag must be provided, and all changes since the last notification always reported, even if the system was shutdown. The last tag can be obtained with getAll. + * To use, the file_system_provider.notify manifest option must be set to true. + * Value of tag can be any string which is unique per call, so it's possible to identify the last registered notification. Eg. if the providing extension starts after a reboot, and the last registered notification's tag is equal to "123", then it should call notify for all changes which happened since the change tagged as "123". It cannot be an empty string. + * Not all providers are able to provide a tag, but if the file system has a changelog, then the tag can be eg. a change number, or a revision number. + * Note that if a parent directory is removed, then all descendant entries are also removed, and if they are watched, then the API must be notified about the fact. Also, if a directory is renamed, then all descendant entries are in fact removed, as there is no entry under their original paths anymore. + * In case of an error, runtime.lastError will be set will a corresponding error code. + * @param callback A generic result callback to indicate success or failure. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function notify(options: NotificationOptions, callback: () => void): void; - /** Raised when unmounting for the file system with the fileSystemId identifier is requested. In the response, the unmount API method must be called together with successCallback. If unmounting is not possible (eg. due to a pending operation), then errorCallback must be called. */ - var onUnmountRequested: RequestedEvent; - /** Raised when metadata of a file or a directory at entryPath is requested. The metadata must be returned with the successCallback call. In case of an error, errorCallback must be called. */ - var onGetMetadataRequested: MetadataRequestedEvent; - /** Raised when contents of a directory at directoryPath are requested. The results must be returned in chunks by calling the successCallback several times. In case of an error, errorCallback must be called. */ - var onReadDirectoryRequested: DirectoryPathRequestedEvent; - /** Raised when opening a file at filePath is requested. If the file does not exist, then the operation must fail. Maximum number of files opened at once can be specified with MountOptions. */ - var onOpenFileRequested: OpenFileRequestedEvent; - /** Raised when opening a file previously opened with openRequestId is requested to be closed. */ - var onCloseFileRequested: OpenedFileRequestedEvent; - /** Raised when reading contents of a file opened previously with openRequestId is requested. The results must be returned in chunks by calling successCallback several times. In case of an error, errorCallback must be called. */ - var onReadFileRequested: OpenedFileOffsetRequestedEvent; - /** Raised when creating a directory is requested. The operation must fail with the EXISTS error if the target directory already exists. If recursive is true, then all of the missing directories on the directory path must be created. */ - var onCreateDirectoryRequested: DirectoryPathRecursiveRequestedEvent; - /** Raised when deleting an entry is requested. If recursive is true, and the entry is a directory, then all of the entries inside must be recursively deleted as well. */ - var onDeleteEntryRequested: EntryPathRecursiveRequestedEvent; - /** Raised when creating a file is requested. If the file already exists, then errorCallback must be called with the "EXISTS" error code. */ - var onCreateFileRequested: FilePathRequestedEvent; - /** Raised when copying an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ - var onCopyEntryRequested: SourceTargetPathRequestedEvent; - /** Raised when moving an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ - var onMoveEntryRequested: SourceTargetPathRequestedEvent; - /** Raised when truncating a file to a desired length is requested. If an error occurs, then errorCallback must be called. */ - var onTruncateRequested: FilePathLengthRequestedEvent; - /** Raised when writing contents to a file opened previously with openRequestId is requested. */ - var onWriteFileRequested: OpenedFileIoRequestedEvent; - /** Raised when aborting an operation with operationRequestId is requested. The operation executed with operationRequestId must be immediately stopped and successCallback of this abort request executed. If aborting fails, then errorCallback must be called. Note, that callbacks of the aborted operation must not be called, as they will be ignored. Despite calling errorCallback, the request may be forcibly aborted. */ - var onAbortRequested: OperationRequestedEvent; - /** - * Raised when showing a configuration dialog for fileSystemId is requested. If it's handled, the file_system_provider.configurable manfiest option must be set to true. - * @since Since Chrome 44. - */ - var onConfigureRequested: RequestedEvent; - /** - * Raised when showing a dialog for mounting a new file system is requested. If the extension/app is a file handler, then this event shouldn't be handled. Instead app.runtime.onLaunched should be handled in order to mount new file systems when a file is opened. For multiple mounts, the file_system_provider.multiple_mounts manifest option must be set to true. - * @since Since Chrome 44. - */ - var onMountRequested: OptionlessRequestedEvent; - /** - * Raised when setting a new directory watcher is requested. If an error occurs, then errorCallback must be called. - * @since Since Chrome 45. Warning: this is the current Beta channel. - */ - var onAddWatcherRequested: EntryPathRecursiveRequestedEvent; - /** - * Raised when the watcher should be removed. If an error occurs, then errorCallback must be called. - * @since Since Chrome 45. Warning: this is the current Beta channel. - */ - var onRemoveWatcherRequested: EntryPathRecursiveRequestedEvent; + /** Raised when unmounting for the file system with the fileSystemId identifier is requested. In the response, the unmount API method must be called together with successCallback. If unmounting is not possible (eg. due to a pending operation), then errorCallback must be called. */ + var onUnmountRequested: RequestedEvent; + /** Raised when metadata of a file or a directory at entryPath is requested. The metadata must be returned with the successCallback call. In case of an error, errorCallback must be called. */ + var onGetMetadataRequested: MetadataRequestedEvent; + /** Raised when contents of a directory at directoryPath are requested. The results must be returned in chunks by calling the successCallback several times. In case of an error, errorCallback must be called. */ + var onReadDirectoryRequested: DirectoryPathRequestedEvent; + /** Raised when opening a file at filePath is requested. If the file does not exist, then the operation must fail. Maximum number of files opened at once can be specified with MountOptions. */ + var onOpenFileRequested: OpenFileRequestedEvent; + /** Raised when opening a file previously opened with openRequestId is requested to be closed. */ + var onCloseFileRequested: OpenedFileRequestedEvent; + /** Raised when reading contents of a file opened previously with openRequestId is requested. The results must be returned in chunks by calling successCallback several times. In case of an error, errorCallback must be called. */ + var onReadFileRequested: OpenedFileOffsetRequestedEvent; + /** Raised when creating a directory is requested. The operation must fail with the EXISTS error if the target directory already exists. If recursive is true, then all of the missing directories on the directory path must be created. */ + var onCreateDirectoryRequested: DirectoryPathRecursiveRequestedEvent; + /** Raised when deleting an entry is requested. If recursive is true, and the entry is a directory, then all of the entries inside must be recursively deleted as well. */ + var onDeleteEntryRequested: EntryPathRecursiveRequestedEvent; + /** Raised when creating a file is requested. If the file already exists, then errorCallback must be called with the "EXISTS" error code. */ + var onCreateFileRequested: FilePathRequestedEvent; + /** Raised when copying an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ + var onCopyEntryRequested: SourceTargetPathRequestedEvent; + /** Raised when moving an entry (recursively if a directory) is requested. If an error occurs, then errorCallback must be called. */ + var onMoveEntryRequested: SourceTargetPathRequestedEvent; + /** Raised when truncating a file to a desired length is requested. If an error occurs, then errorCallback must be called. */ + var onTruncateRequested: FilePathLengthRequestedEvent; + /** Raised when writing contents to a file opened previously with openRequestId is requested. */ + var onWriteFileRequested: OpenedFileIoRequestedEvent; + /** Raised when aborting an operation with operationRequestId is requested. The operation executed with operationRequestId must be immediately stopped and successCallback of this abort request executed. If aborting fails, then errorCallback must be called. Note, that callbacks of the aborted operation must not be called, as they will be ignored. Despite calling errorCallback, the request may be forcibly aborted. */ + var onAbortRequested: OperationRequestedEvent; + /** + * Raised when showing a configuration dialog for fileSystemId is requested. If it's handled, the file_system_provider.configurable manfiest option must be set to true. + * @since Since Chrome 44. + */ + var onConfigureRequested: RequestedEvent; + /** + * Raised when showing a dialog for mounting a new file system is requested. If the extension/app is a file handler, then this event shouldn't be handled. Instead app.runtime.onLaunched should be handled in order to mount new file systems when a file is opened. For multiple mounts, the file_system_provider.multiple_mounts manifest option must be set to true. + * @since Since Chrome 44. + */ + var onMountRequested: OptionlessRequestedEvent; + /** + * Raised when setting a new directory watcher is requested. If an error occurs, then errorCallback must be called. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + var onAddWatcherRequested: EntryPathRecursiveRequestedEvent; + /** + * Raised when the watcher should be removed. If an error occurs, then errorCallback must be called. + * @since Since Chrome 45. Warning: this is the current Beta channel. + */ + var onRemoveWatcherRequested: EntryPathRecursiveRequestedEvent; } //////////////////// @@ -2936,58 +2936,58 @@ declare namespace chrome.fileSystemProvider { * Permissions: "fontSettings" */ declare namespace chrome.fontSettings { - /** Represents a font name. */ + /** Represents a font name. */ interface FontName { - /** The display name of the font. */ + /** The display name of the font. */ displayName: string; - /** The font ID. */ + /** The font ID. */ fontId: string; } interface DefaultFontSizeDetails { - /** The font size in pixels. */ + /** The font size in pixels. */ pixelSize: number; } interface FontDetails { - /** The generic font family for the font. */ + /** The generic font family for the font. */ genericFamily: string; - /** Optional. The script for the font. If omitted, the global script font setting is affected. */ + /** Optional. The script for the font. If omitted, the global script font setting is affected. */ script?: string; } interface FullFontDetails { - /** The generic font family for which the font setting has changed. */ + /** The generic font family for which the font setting has changed. */ genericFamily: string; - /** The level of control this extension has over the setting. */ + /** The level of control this extension has over the setting. */ levelOfControl: string; - /** Optional. The script code for which the font setting has changed. */ + /** Optional. The script code for which the font setting has changed. */ script?: string; - /** The font ID. See the description in getFont. */ + /** The font ID. See the description in getFont. */ fontId: string; } interface FontDetailsResult { - /** The level of control this extension has over the setting. */ + /** The level of control this extension has over the setting. */ levelOfControl: string; - /** The font ID. Rather than the literal font ID preference value, this may be the ID of the font that the system resolves the preference value to. So, fontId can differ from the font passed to setFont, if, for example, the font is not available on the system. The empty string signifies fallback to the global script font setting. */ + /** The font ID. Rather than the literal font ID preference value, this may be the ID of the font that the system resolves the preference value to. So, fontId can differ from the font passed to setFont, if, for example, the font is not available on the system. The empty string signifies fallback to the global script font setting. */ fontId: string; } interface FontSizeDetails { - /** The font size in pixels. */ + /** The font size in pixels. */ pixelSize: number; - /** The level of control this extension has over the setting. */ + /** The level of control this extension has over the setting. */ levelOfControl: string; } interface SetFontSizeDetails { - /** The font size in pixels. */ + /** The font size in pixels. */ pixelSize: number; } - interface SetFontDetails extends FontDetails { - /** The font ID. The empty string means to fallback to the global script font setting. */ + interface SetFontDetails extends FontDetails { + /** The font ID. The empty string means to fallback to the global script font setting. */ fontId: string; } @@ -2999,98 +2999,98 @@ declare namespace chrome.fontSettings { interface FontChangedEvent extends chrome.events.Event<(details: FullFontDetails) => void> {} - /** - * Sets the default font size. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets the default font size. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function setDefaultFontSize(details: DefaultFontSizeDetails, callback?: Function): void; - /** - * Gets the font for a given script and generic font family. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(object details) {...}; - */ + /** + * Gets the font for a given script and generic font family. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(object details) {...}; + */ export function getFont(details: FontDetails, callback?: (details: FontDetailsResult) => void): void; - /** - * Gets the default font size. - * @param details This parameter is currently unused. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(object details) {...}; - */ - export function getDefaultFontSize(details?: Object, callback?: (options: FontSizeDetails) => void): void; - /** - * Gets the minimum font size. - * @param details This parameter is currently unused. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(object details) {...}; - */ + /** + * Gets the default font size. + * @param details This parameter is currently unused. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(object details) {...}; + */ + export function getDefaultFontSize(details?: Object, callback?: (options: FontSizeDetails) => void): void; + /** + * Gets the minimum font size. + * @param details This parameter is currently unused. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(object details) {...}; + */ export function getMinimumFontSize(details?: FontSizeDetails, callback?: (options: FontSizeDetails) => void): void; - /** - * Sets the minimum font size. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets the minimum font size. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function setMinimumFontSize(details: SetFontSizeDetails, callback?: Function): void; - /** - * Gets the default size for fixed width fonts. - * @param details This parameter is currently unused. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(object details) {...}; - */ + /** + * Gets the default size for fixed width fonts. + * @param details This parameter is currently unused. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(object details) {...}; + */ export function getDefaultFixedFontSize(details?: Object, callback?: (details: FontSizeDetails) => void): void; - /** - * Clears the default font size set by this extension, if any. - * @param details This parameter is currently unused. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the default font size set by this extension, if any. + * @param details This parameter is currently unused. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function clearDefaultFontSize(details?: Object, callback?: Function): void; - /** - * Sets the default size for fixed width fonts. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Sets the default size for fixed width fonts. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function setDefaultFixedFontSize(details: SetFontSizeDetails, callback?: Function): void; - /** - * Clears the font set by this extension, if any. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the font set by this extension, if any. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function clearFont(details: FontDetails, callback?: Function): void; - /** - * Sets the font for a given script and generic font family. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(object details) {...}; - */ + /** + * Sets the font for a given script and generic font family. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(object details) {...}; + */ export function setFont(details: SetFontDetails, callback?: Function): void; - /** - * Clears the minimum font size set by this extension, if any. - * @param details This parameter is currently unused. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the minimum font size set by this extension, if any. + * @param details This parameter is currently unused. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function clearMinimumFontSize(details?: Object, callback?: Function): void; - /** - * Gets a list of fonts on the system. - * @param callback The callback parameter should be a function that looks like this: - * function(array of FontName results) {...}; - */ + /** + * Gets a list of fonts on the system. + * @param callback The callback parameter should be a function that looks like this: + * function(array of FontName results) {...}; + */ export function getFontList(callback: (results: FontName[]) => void): void; - /** - * Clears the default fixed font size set by this extension, if any. - * @param details This parameter is currently unused. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ + /** + * Clears the default fixed font size set by this extension, if any. + * @param details This parameter is currently unused. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ export function clearDefaultFixedFontSize(details: Object, callback?: Function): void; - /** Fired when the default fixed font size setting changes. */ + /** Fired when the default fixed font size setting changes. */ var onDefaultFixedFontSizeChanged: DefaultFixedFontSizeChangedEvent; - /** Fired when the default font size setting changes. */ + /** Fired when the default font size setting changes. */ var onDefaultFontSizeChanged: DefaultFontSizeChangedEvent; - /** Fired when the minimum font size setting changes. */ + /** Fired when the minimum font size setting changes. */ var onMinimumFontSizeChanged: MinimumFontSizeChangedEvent; - /** Fired when a font setting changes. */ + /** Fired when a font setting changes. */ var onFontChanged: FontChangedEvent; } @@ -3103,83 +3103,83 @@ declare namespace chrome.fontSettings { * Permissions: "gcm" */ declare namespace chrome.gcm { - interface OutgoingMessage { - /** The ID of the server to send the message to as assigned by Google API Console. */ - destinationId: string; - /** The ID of the message. It must be unique for each message in scope of the applications. See the Cloud Messaging documentation for advice for picking and handling an ID. */ - messageId: string; - /** Optional. Time-to-live of the message in seconds. If it is not possible to send the message within that time, an onSendError event will be raised. A time-to-live of 0 indicates that the message should be sent immediately or fail if it's not possible. The maximum and a default value of time-to-live is 86400 seconds (1 day). */ - timeToLive?: number; - /** Message data to send to the server. Case-insensitive goog. and google, as well as case-sensitive collapse_key are disallowed as key prefixes. Sum of all key/value pairs should not exceed gcm.MAX_MESSAGE_SIZE. */ - data: Object; - } + interface OutgoingMessage { + /** The ID of the server to send the message to as assigned by Google API Console. */ + destinationId: string; + /** The ID of the message. It must be unique for each message in scope of the applications. See the Cloud Messaging documentation for advice for picking and handling an ID. */ + messageId: string; + /** Optional. Time-to-live of the message in seconds. If it is not possible to send the message within that time, an onSendError event will be raised. A time-to-live of 0 indicates that the message should be sent immediately or fail if it's not possible. The maximum and a default value of time-to-live is 86400 seconds (1 day). */ + timeToLive?: number; + /** Message data to send to the server. Case-insensitive goog. and google, as well as case-sensitive collapse_key are disallowed as key prefixes. Sum of all key/value pairs should not exceed gcm.MAX_MESSAGE_SIZE. */ + data: Object; + } - interface IncomingMessage { - /** The message data. */ - data: Object; - /** - * Optional. - * The sender who issued the message. - * @since Since Chrome 41. - */ - from?: string; - /** - * Optional. - * The collapse key of a message. See Collapsible Messages section of Cloud Messaging documentation for details. - */ - collapseKey?: string; - } + interface IncomingMessage { + /** The message data. */ + data: Object; + /** + * Optional. + * The sender who issued the message. + * @since Since Chrome 41. + */ + from?: string; + /** + * Optional. + * The collapse key of a message. See Collapsible Messages section of Cloud Messaging documentation for details. + */ + collapseKey?: string; + } - interface GcmError { - /** The error message describing the problem. */ - errorMessage: string; - /** Optional. The ID of the message with this error, if error is related to a specific message. */ - messageId?: string; - /** Additional details related to the error, when available. */ - detail: Object; - } + interface GcmError { + /** The error message describing the problem. */ + errorMessage: string; + /** Optional. The ID of the message with this error, if error is related to a specific message. */ + messageId?: string; + /** Additional details related to the error, when available. */ + detail: Object; + } - interface MessageReceptionEvent extends chrome.events.Event<(message: IncomingMessage) => void> {} + interface MessageReceptionEvent extends chrome.events.Event<(message: IncomingMessage) => void> {} - interface MessageDeletionEvent extends chrome.events.Event<() => void> {} + interface MessageDeletionEvent extends chrome.events.Event<() => void> {} - interface GcmErrorEvent extends chrome.events.Event<(error: GcmError) => void> {} + interface GcmErrorEvent extends chrome.events.Event<(error: GcmError) => void> {} - /** The maximum size (in bytes) of all key/value pairs in a message. */ - var MAX_MESSAGE_SIZE: number; + /** The maximum size (in bytes) of all key/value pairs in a message. */ + var MAX_MESSAGE_SIZE: number; - /** - * Registers the application with GCM. The registration ID will be returned by the callback. If register is called again with the same list of senderIds, the same registration ID will be returned. - * @param senderIds A list of server IDs that are allowed to send messages to the application. It should contain at least one and no more than 100 sender IDs. - * @param callback Function called when registration completes. It should check runtime.lastError for error when registrationId is empty. - * The callback parameter should be a function that looks like this: - * function(string registrationId) {...}; - * Parameter registrationId: A registration ID assigned to the application by the GCM. - */ - export function register(senderIds: string[], callback: (registrationId: string) => void): void; - /** - * Unregisters the application from GCM. - * @param callback A function called after the unregistration completes. Unregistration was successful if runtime.lastError is not set. - * The callback parameter should be a function that looks like this: - * function() {...}; - */ - export function unregister(callback: () => void): void; - /** - * Sends a message according to its contents. - * @param message A message to send to the other party via GCM. - * @param callback A function called after the message is successfully queued for sending. runtime.lastError should be checked, to ensure a message was sent without problems. - * The callback parameter should be a function that looks like this: - * function(string messageId) {...}; - * Parameter messageId: The ID of the message that the callback was issued for. - */ - export function send(message: OutgoingMessage, callback: (messageId: string) => void): void; + /** + * Registers the application with GCM. The registration ID will be returned by the callback. If register is called again with the same list of senderIds, the same registration ID will be returned. + * @param senderIds A list of server IDs that are allowed to send messages to the application. It should contain at least one and no more than 100 sender IDs. + * @param callback Function called when registration completes. It should check runtime.lastError for error when registrationId is empty. + * The callback parameter should be a function that looks like this: + * function(string registrationId) {...}; + * Parameter registrationId: A registration ID assigned to the application by the GCM. + */ + export function register(senderIds: string[], callback: (registrationId: string) => void): void; + /** + * Unregisters the application from GCM. + * @param callback A function called after the unregistration completes. Unregistration was successful if runtime.lastError is not set. + * The callback parameter should be a function that looks like this: + * function() {...}; + */ + export function unregister(callback: () => void): void; + /** + * Sends a message according to its contents. + * @param message A message to send to the other party via GCM. + * @param callback A function called after the message is successfully queued for sending. runtime.lastError should be checked, to ensure a message was sent without problems. + * The callback parameter should be a function that looks like this: + * function(string messageId) {...}; + * Parameter messageId: The ID of the message that the callback was issued for. + */ + export function send(message: OutgoingMessage, callback: (messageId: string) => void): void; - /** Fired when a message is received through GCM. */ - var onMessage: MessageReceptionEvent; - /** Fired when a GCM server had to delete messages sent by an app server to the application. See Messages deleted event section of Cloud Messaging documentation for details on handling this event. */ - var onMessagesDeleted: MessageDeletionEvent; - /** Fired when it was not possible to send a message to the GCM server. */ - var onSendError: GcmErrorEvent; + /** Fired when a message is received through GCM. */ + var onMessage: MessageReceptionEvent; + /** Fired when a GCM server had to delete messages sent by an app server to the application. See Messages deleted event section of Cloud Messaging documentation for details on handling this event. */ + var onMessagesDeleted: MessageDeletionEvent; + /** Fired when it was not possible to send a message to the GCM server. */ + var onSendError: GcmErrorEvent; } //////////////////// @@ -3191,63 +3191,63 @@ declare namespace chrome.gcm { * Permissions: "history" */ declare namespace chrome.history { - /** An object encapsulating one visit to a URL. */ + /** An object encapsulating one visit to a URL. */ interface VisitItem { - /** The transition type for this visit from its referrer. */ + /** The transition type for this visit from its referrer. */ transition: string; - /** Optional. When this visit occurred, represented in milliseconds since the epoch. */ + /** Optional. When this visit occurred, represented in milliseconds since the epoch. */ visitTime?: number; - /** The unique identifier for this visit. */ + /** The unique identifier for this visit. */ visitId: string; - /** The visit ID of the referrer. */ + /** The visit ID of the referrer. */ referringVisitId: string; - /** The unique identifier for the item. */ + /** The unique identifier for the item. */ id: string; } - /** An object encapsulating one result of a history query. */ + /** An object encapsulating one result of a history query. */ interface HistoryItem { - /** Optional. The number of times the user has navigated to this page by typing in the address. */ + /** Optional. The number of times the user has navigated to this page by typing in the address. */ typedCount?: number; - /** Optional. The title of the page when it was last loaded. */ + /** Optional. The title of the page when it was last loaded. */ title?: string; - /** Optional. The URL navigated to by a user. */ + /** Optional. The URL navigated to by a user. */ url?: string; - /** Optional. When this page was last loaded, represented in milliseconds since the epoch. */ + /** Optional. When this page was last loaded, represented in milliseconds since the epoch. */ lastVisitTime?: number; - /** Optional. The number of times the user has navigated to this page. */ + /** Optional. The number of times the user has navigated to this page. */ visitCount?: number; - /** The unique identifier for the item. */ + /** The unique identifier for the item. */ id: string; } interface HistoryQuery { - /** A free-text query to the history service. Leave empty to retrieve all pages. */ + /** A free-text query to the history service. Leave empty to retrieve all pages. */ text: string; - /** Optional. The maximum number of results to retrieve. Defaults to 100. */ + /** Optional. The maximum number of results to retrieve. Defaults to 100. */ maxResults?: number; - /** Optional. Limit results to those visited after this date, represented in milliseconds since the epoch. */ + /** Optional. Limit results to those visited after this date, represented in milliseconds since the epoch. */ startTime?: number; - /** Optional. Limit results to those visited before this date, represented in milliseconds since the epoch. */ + /** Optional. Limit results to those visited before this date, represented in milliseconds since the epoch. */ endTime?: number; } interface Url { - /** The URL for the operation. It must be in the format as returned from a call to history.search. */ + /** The URL for the operation. It must be in the format as returned from a call to history.search. */ url: string; } interface Range { - /** Items added to history before this date, represented in milliseconds since the epoch. */ + /** Items added to history before this date, represented in milliseconds since the epoch. */ endTime: number; - /** Items added to history after this date, represented in milliseconds since the epoch. */ + /** Items added to history after this date, represented in milliseconds since the epoch. */ startTime: number; } interface RemovedResult { - /** True if all history was removed. If true, then urls will be empty. */ + /** True if all history was removed. If true, then urls will be empty. */ allHistory: boolean; - /** Optional. */ + /** Optional. */ urls?: string[]; } @@ -3255,46 +3255,46 @@ declare namespace chrome.history { interface HistoryVisitRemovedEvent extends chrome.events.Event<(removed: RemovedResult) => void> {} - /** - * Searches the history for the last visit time of each page matching the query. - * @param callback The callback parameter should be a function that looks like this: - * function(array of HistoryItem results) {...}; - */ + /** + * Searches the history for the last visit time of each page matching the query. + * @param callback The callback parameter should be a function that looks like this: + * function(array of HistoryItem results) {...}; + */ export function search(query: HistoryQuery, callback: (results: HistoryItem[]) => void): void; - /** - * Adds a URL to the history at the current time with a transition type of "link". - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function addUrl(details: Url, callback?: () => void): void; - /** - * Removes all items within the specified date range from the history. Pages will not be removed from the history unless all visits fall within the range. - * @param callback The callback parameter should be a function that looks like this: - * function() {...}; - */ - export function deleteRange(range: Range, callback: () => void): void; - /** - * Deletes all items from the history. - * @param callback The callback parameter should be a function that looks like this: - * function() {...}; - */ - export function deleteAll(callback: () => void): void; - /** - * Retrieves information about visits to a URL. - * @param callback The callback parameter should be a function that looks like this: - * function(array of VisitItem results) {...}; - */ + /** + * Adds a URL to the history at the current time with a transition type of "link". + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function addUrl(details: Url, callback?: () => void): void; + /** + * Removes all items within the specified date range from the history. Pages will not be removed from the history unless all visits fall within the range. + * @param callback The callback parameter should be a function that looks like this: + * function() {...}; + */ + export function deleteRange(range: Range, callback: () => void): void; + /** + * Deletes all items from the history. + * @param callback The callback parameter should be a function that looks like this: + * function() {...}; + */ + export function deleteAll(callback: () => void): void; + /** + * Retrieves information about visits to a URL. + * @param callback The callback parameter should be a function that looks like this: + * function(array of VisitItem results) {...}; + */ export function getVisits(details: Url, callback: (results: VisitItem[]) => void): void; - /** - * Removes all occurrences of the given URL from the history. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function deleteUrl(details: Url, callback?: () => void): void; + /** + * Removes all occurrences of the given URL from the history. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function deleteUrl(details: Url, callback?: () => void): void; - /** Fired when a URL is visited, providing the HistoryItem data for that URL. This event fires before the page has loaded. */ + /** Fired when a URL is visited, providing the HistoryItem data for that URL. This event fires before the page has loaded. */ var onVisited: HistoryVisitedEvent; - /** Fired when one or more URLs are removed from the history service. When all visits have been removed the URL is purged from history. */ + /** Fired when one or more URLs are removed from the history service. When all visits have been removed the URL is purged from history. */ var onVisitRemoved: HistoryVisitRemovedEvent; } @@ -3306,24 +3306,24 @@ declare namespace chrome.history { * @since Chrome 5. */ declare namespace chrome.i18n { - /** - * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use i18n.getUILanguage. - * @param callback The callback parameter should be a function that looks like this: - * function(array of string languages) {...}; - * Parameter languages: Array of the accept languages of the browser, such as en-US,en,zh-CN - */ - export function getAcceptLanguages(callback: (languages: string[]) => void): void; - /** - * Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the getMessage() call is wrong — for example, messageName is not a string or the substitutions array has more than 9 elements — this method returns undefined. - * @param messageName The name of the message, as specified in the messages.json file. - * @param substitutions Optional. Up to 9 substitution strings, if the message requires any. - */ - export function getMessage(messageName: string, substitutions?: any): string; - /** - * Gets the browser UI language of the browser. This is different from i18n.getAcceptLanguages which returns the preferred user languages. - * @since Chrome 35. - */ - export function getUILanguage(): string; + /** + * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use i18n.getUILanguage. + * @param callback The callback parameter should be a function that looks like this: + * function(array of string languages) {...}; + * Parameter languages: Array of the accept languages of the browser, such as en-US,en,zh-CN + */ + export function getAcceptLanguages(callback: (languages: string[]) => void): void; + /** + * Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the getMessage() call is wrong — for example, messageName is not a string or the substitutions array has more than 9 elements — this method returns undefined. + * @param messageName The name of the message, as specified in the messages.json file. + * @param substitutions Optional. Up to 9 substitution strings, if the message requires any. + */ + export function getMessage(messageName: string, substitutions?: any): string; + /** + * Gets the browser UI language of the browser. This is different from i18n.getAcceptLanguages which returns the preferred user languages. + * @since Chrome 35. + */ + export function getUILanguage(): string; } //////////////////// @@ -3335,114 +3335,114 @@ declare namespace chrome.i18n { * @since Chrome 29. */ declare namespace chrome.identity { - /** @since Chrome 32. */ - interface AccountInfo { - /** A unique identifier for the account. This ID will not change for the lifetime of the account. */ - id: string; - } + /** @since Chrome 32. */ + interface AccountInfo { + /** A unique identifier for the account. This ID will not change for the lifetime of the account. */ + id: string; + } - interface TokenDetails { - /** - * Optional. - * Fetching a token may require the user to sign-in to Chrome, or approve the application's requested scopes. If the interactive flag is true, getAuthToken will prompt the user as necessary. When the flag is false or omitted, getAuthToken will return failure any time a prompt would be required. - */ - interactive?: boolean; - /** - * Optional. - * The account ID whose token should be returned. If not specified, the primary account for the profile will be used. - * account is only supported when the "enable-new-profile-management" flag is set. - * @since Chrome 37. - */ - account?: AccountInfo; - /** - * Optional. - * A list of OAuth2 scopes to request. - * When the scopes field is present, it overrides the list of scopes specified in manifest.json. - * @since Chrome 37. - */ - scopes?: string[]; - } + interface TokenDetails { + /** + * Optional. + * Fetching a token may require the user to sign-in to Chrome, or approve the application's requested scopes. If the interactive flag is true, getAuthToken will prompt the user as necessary. When the flag is false or omitted, getAuthToken will return failure any time a prompt would be required. + */ + interactive?: boolean; + /** + * Optional. + * The account ID whose token should be returned. If not specified, the primary account for the profile will be used. + * account is only supported when the "enable-new-profile-management" flag is set. + * @since Chrome 37. + */ + account?: AccountInfo; + /** + * Optional. + * A list of OAuth2 scopes to request. + * When the scopes field is present, it overrides the list of scopes specified in manifest.json. + * @since Chrome 37. + */ + scopes?: string[]; + } - interface UserInfo { - /** An email address for the user account signed into the current profile. Empty if the user is not signed in or the identity.email manifest permission is not specified. */ - email: string; - /** A unique identifier for the account. This ID will not change for the lifetime of the account. Empty if the user is not signed in or (in M41+) the identity.email manifest permission is not specified. */ - id: string; - } + interface UserInfo { + /** An email address for the user account signed into the current profile. Empty if the user is not signed in or the identity.email manifest permission is not specified. */ + email: string; + /** A unique identifier for the account. This ID will not change for the lifetime of the account. Empty if the user is not signed in or (in M41+) the identity.email manifest permission is not specified. */ + id: string; + } - interface TokenInformation { - /** The specific token that should be removed from the cache. */ - token: string; - } + interface TokenInformation { + /** The specific token that should be removed from the cache. */ + token: string; + } - interface WebAuthFlowOptions { - /** The URL that initiates the auth flow. */ - url: string; - /** - * Optional. - * Whether to launch auth flow in interactive mode. - * Since some auth flows may immediately redirect to a result URL, launchWebAuthFlow hides its web view until the first navigation either redirects to the final URL, or finishes loading a page meant to be displayed. - * If the interactive flag is true, the window will be displayed when a page load completes. If the flag is false or omitted, launchWebAuthFlow will return with an error if the initial navigation does not complete the flow. - */ - interactive?: boolean; - } + interface WebAuthFlowOptions { + /** The URL that initiates the auth flow. */ + url: string; + /** + * Optional. + * Whether to launch auth flow in interactive mode. + * Since some auth flows may immediately redirect to a result URL, launchWebAuthFlow hides its web view until the first navigation either redirects to the final URL, or finishes loading a page meant to be displayed. + * If the interactive flag is true, the window will be displayed when a page load completes. If the flag is false or omitted, launchWebAuthFlow will return with an error if the initial navigation does not complete the flow. + */ + interactive?: boolean; + } - interface SignInChangeEvent extends chrome.events.Event<(account: AccountInfo, signedIn: boolean) => void> {} + interface SignInChangeEvent extends chrome.events.Event<(account: AccountInfo, signedIn: boolean) => void> {} - /** - * Retrieves a list of AccountInfo objects describing the accounts present on the profile. - * getAccounts is only supported on dev channel. - * Dev channel only. - */ - export function getAccounts(callback: (accounts: AccountInfo[]) => void): void; - /** - * Gets an OAuth2 access token using the client ID and scopes specified in the oauth2 section of manifest.json. - * The Identity API caches access tokens in memory, so it's ok to call getAuthToken non-interactively any time a token is required. The token cache automatically handles expiration. - * For a good user experience it is important interactive token requests are initiated by UI in your app explaining what the authorization is for. Failing to do this will cause your users to get authorization requests, or Chrome sign in screens if they are not signed in, with with no context. In particular, do not use getAuthToken interactively when your app is first launched. - * @param details Token options. - * @param callback Called with an OAuth2 access token as specified by the manifest, or undefined if there was an error. - * If you specify the callback parameter, it should be a function that looks like this: - * function(string token) {...}; - */ - export function getAuthToken(details: TokenDetails, callback?: (token: string) => void): void; - /** - * Retrieves email address and obfuscated gaia id of the user signed into a profile. - * This API is different from identity.getAccounts in two ways. The information returned is available offline, and it only applies to the primary account for the profile. - * @since Chrome 37. - */ - export function getProfileUserInfo(callback: (userInfo: UserInfo) => void): void; - /** - * Removes an OAuth2 access token from the Identity API's token cache. - * If an access token is discovered to be invalid, it should be passed to removeCachedAuthToken to remove it from the cache. The app may then retrieve a fresh token with getAuthToken. - * @param details Token information. - * @param callback Called when the token has been removed from the cache. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function removeCachedAuthToken(details: TokenInformation, callback?: () => void): void; - /** - * Starts an auth flow at the specified URL. - * This method enables auth flows with non-Google identity providers by launching a web view and navigating it to the first URL in the provider's auth flow. When the provider redirects to a URL matching the pattern https://.chromiumapp.org/*, the window will close, and the final redirect URL will be passed to the callback function. - * For a good user experience it is important interactive auth flows are initiated by UI in your app explaining what the authorization is for. Failing to do this will cause your users to get authorization requests with no context. In particular, do not launch an interactive auth flow when your app is first launched. - * @param details WebAuth flow options. - * @param callback Called with the URL redirected back to your application. - * The callback parameter should be a function that looks like this: - * function(string responseUrl) {...}; - */ - export function launchWebAuthFlow(details: WebAuthFlowOptions, callback: (responseUrl?: string) => void): void; - /** - * Generates a redirect URL to be used in launchWebAuthFlow. - * The generated URLs match the pattern https://.chromiumapp.org/*. - * @since Chrome 33. - * @param path Optional. The path appended to the end of the generated URL. - */ - export function getRedirectURL(path?: string): string; + /** + * Retrieves a list of AccountInfo objects describing the accounts present on the profile. + * getAccounts is only supported on dev channel. + * Dev channel only. + */ + export function getAccounts(callback: (accounts: AccountInfo[]) => void): void; + /** + * Gets an OAuth2 access token using the client ID and scopes specified in the oauth2 section of manifest.json. + * The Identity API caches access tokens in memory, so it's ok to call getAuthToken non-interactively any time a token is required. The token cache automatically handles expiration. + * For a good user experience it is important interactive token requests are initiated by UI in your app explaining what the authorization is for. Failing to do this will cause your users to get authorization requests, or Chrome sign in screens if they are not signed in, with with no context. In particular, do not use getAuthToken interactively when your app is first launched. + * @param details Token options. + * @param callback Called with an OAuth2 access token as specified by the manifest, or undefined if there was an error. + * If you specify the callback parameter, it should be a function that looks like this: + * function(string token) {...}; + */ + export function getAuthToken(details: TokenDetails, callback?: (token: string) => void): void; + /** + * Retrieves email address and obfuscated gaia id of the user signed into a profile. + * This API is different from identity.getAccounts in two ways. The information returned is available offline, and it only applies to the primary account for the profile. + * @since Chrome 37. + */ + export function getProfileUserInfo(callback: (userInfo: UserInfo) => void): void; + /** + * Removes an OAuth2 access token from the Identity API's token cache. + * If an access token is discovered to be invalid, it should be passed to removeCachedAuthToken to remove it from the cache. The app may then retrieve a fresh token with getAuthToken. + * @param details Token information. + * @param callback Called when the token has been removed from the cache. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function removeCachedAuthToken(details: TokenInformation, callback?: () => void): void; + /** + * Starts an auth flow at the specified URL. + * This method enables auth flows with non-Google identity providers by launching a web view and navigating it to the first URL in the provider's auth flow. When the provider redirects to a URL matching the pattern https://.chromiumapp.org/*, the window will close, and the final redirect URL will be passed to the callback function. + * For a good user experience it is important interactive auth flows are initiated by UI in your app explaining what the authorization is for. Failing to do this will cause your users to get authorization requests with no context. In particular, do not launch an interactive auth flow when your app is first launched. + * @param details WebAuth flow options. + * @param callback Called with the URL redirected back to your application. + * The callback parameter should be a function that looks like this: + * function(string responseUrl) {...}; + */ + export function launchWebAuthFlow(details: WebAuthFlowOptions, callback: (responseUrl?: string) => void): void; + /** + * Generates a redirect URL to be used in launchWebAuthFlow. + * The generated URLs match the pattern https://.chromiumapp.org/*. + * @since Chrome 33. + * @param path Optional. The path appended to the end of the generated URL. + */ + export function getRedirectURL(path?: string): string; - /** - * Fired when signin state changes for an account on the user's profile. - * @since Chrome 33. - */ - var onSignInChanged: SignInChangeEvent; + /** + * Fired when signin state changes for an account on the user's profile. + * @since Chrome 33. + */ + var onSignInChanged: SignInChangeEvent; } //////////////////// @@ -3456,22 +3456,22 @@ declare namespace chrome.identity { declare namespace chrome.idle { interface IdleStateChangedEvent extends chrome.events.Event<(newState: string) => void> {} - /** - * Returns "locked" if the system is locked, "idle" if the user has not generated any input for a specified number of seconds, or "active" otherwise. - * @param detectionIntervalInSeconds The system is considered idle if detectionIntervalInSeconds seconds have elapsed since the last user input detected. - * Since Chrome 25. - * @param callback The callback parameter should be a function that looks like this: - * function( IdleState newState) {...}; - */ - export function queryState(detectionIntervalInSeconds: number, callback: (newState: string) => void): void; - /** - * Sets the interval, in seconds, used to determine when the system is in an idle state for onStateChanged events. The default interval is 60 seconds. - * @since Chrome 25. - * @param intervalInSeconds Threshold, in seconds, used to determine when the system is in an idle state. - */ - export function setDetectionInterval(intervalInSeconds: number): void; + /** + * Returns "locked" if the system is locked, "idle" if the user has not generated any input for a specified number of seconds, or "active" otherwise. + * @param detectionIntervalInSeconds The system is considered idle if detectionIntervalInSeconds seconds have elapsed since the last user input detected. + * Since Chrome 25. + * @param callback The callback parameter should be a function that looks like this: + * function( IdleState newState) {...}; + */ + export function queryState(detectionIntervalInSeconds: number, callback: (newState: string) => void): void; + /** + * Sets the interval, in seconds, used to determine when the system is in an idle state for onStateChanged events. The default interval is 60 seconds. + * @since Chrome 25. + * @param intervalInSeconds Threshold, in seconds, used to determine when the system is in an idle state. + */ + export function setDetectionInterval(intervalInSeconds: number): void; - /** Fired when the system changes to an active, idle or locked state. The event fires with "locked" if the screen is locked or the screensaver activates, "idle" if the system is unlocked and the user has not generated any input for a specified number of seconds, and "active" when the user generates input on an idle system. */ + /** Fired when the system changes to an active, idle or locked state. The event fires with "locked" if the screen is locked or the screensaver activates, "idle" if the system is unlocked and the user has not generated any input for a specified number of seconds, and "active" when the user generates input on an idle system. */ var onStateChanged: IdleStateChangedEvent; } @@ -3484,173 +3484,173 @@ declare namespace chrome.idle { * @since Chrome 21. */ declare namespace chrome.input.ime { - /** See http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent */ + /** See http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent */ interface KeyboardEvent { - /** - * Optional. - * Whether or not the SHIFT key is pressed. - */ + /** + * Optional. + * Whether or not the SHIFT key is pressed. + */ shiftKey?: boolean; - /** - * Optional. - * Whether or not the ALT key is pressed. - */ + /** + * Optional. + * Whether or not the ALT key is pressed. + */ altKey?: boolean; - /** The ID of the request. */ + /** The ID of the request. */ requestId: string; - /** Value of the key being pressed */ + /** Value of the key being pressed */ key: string; - /** - * Optional. - * Whether or not the CTRL key is pressed. - */ + /** + * Optional. + * Whether or not the CTRL key is pressed. + */ ctrlKey?: boolean; - /** One of keyup or keydown. */ + /** One of keyup or keydown. */ type: string; - /** - * Optional. - * The extension ID of the sender of this keyevent. - * @since Chrome 34. - */ - extensionId?: string; - /** - * Optional. - * Value of the physical key being pressed. The value is not affected by current keyboard layout or modifier state. - * @since Chrome 26. - */ - code: string; - /** - * Optional. - * The deprecated HTML keyCode, which is system- and implementation-dependent numerical code signifying the unmodified identifier associated with the key pressed. - * @since Chrome 37. - */ - keyCode?: number; - /** - * Optional. - * Whether or not the CAPS_LOCK is enabled. - * @since Chrome 29. - */ - capsLock?: boolean; + /** + * Optional. + * The extension ID of the sender of this keyevent. + * @since Chrome 34. + */ + extensionId?: string; + /** + * Optional. + * Value of the physical key being pressed. The value is not affected by current keyboard layout or modifier state. + * @since Chrome 26. + */ + code: string; + /** + * Optional. + * The deprecated HTML keyCode, which is system- and implementation-dependent numerical code signifying the unmodified identifier associated with the key pressed. + * @since Chrome 37. + */ + keyCode?: number; + /** + * Optional. + * Whether or not the CAPS_LOCK is enabled. + * @since Chrome 29. + */ + capsLock?: boolean; } - /** Describes an input Context */ + /** Describes an input Context */ interface InputContext { - /** This is used to specify targets of text field operations. This ID becomes invalid as soon as onBlur is called. */ + /** This is used to specify targets of text field operations. This ID becomes invalid as soon as onBlur is called. */ contextID: number; - /** Type of value this text field edits, (Text, Number, URL, etc) */ + /** Type of value this text field edits, (Text, Number, URL, etc) */ type: string; - /** - * Whether the text field wants auto-correct. - * @since Chrome 40. - */ - autoCorrect: boolean; - /** - * Whether the text field wants auto-complete. - * @since Chrome 40. - */ - autoComplete: boolean; - /** - * Whether the text field wants spell-check. - * @since Chrome 40. - */ - spellCheck: boolean; - } + /** + * Whether the text field wants auto-correct. + * @since Chrome 40. + */ + autoCorrect: boolean; + /** + * Whether the text field wants auto-complete. + * @since Chrome 40. + */ + autoComplete: boolean; + /** + * Whether the text field wants spell-check. + * @since Chrome 40. + */ + spellCheck: boolean; + } - /** - * A menu item used by an input method to interact with the user from the language menu. - * @since Chrome 30. - */ - interface MenuItem { - /** String that will be passed to callbacks referencing this MenuItem. */ - id: string; - /** Optional. Text displayed in the menu for this item. */ - label?: string; - /** Optional. The type of menu item. */ - style?: string; - /** Optional. Indicates this item is visible. */ - visible?: boolean; - /** Indicates this item should be drawn with a check. */ - checked?: boolean; - /** Indicates this item is enabled. */ - enabled?: boolean; + /** + * A menu item used by an input method to interact with the user from the language menu. + * @since Chrome 30. + */ + interface MenuItem { + /** String that will be passed to callbacks referencing this MenuItem. */ + id: string; + /** Optional. Text displayed in the menu for this item. */ + label?: string; + /** Optional. The type of menu item. */ + style?: string; + /** Optional. Indicates this item is visible. */ + visible?: boolean; + /** Indicates this item should be drawn with a check. */ + checked?: boolean; + /** Indicates this item is enabled. */ + enabled?: boolean; } interface ImeParameters { - /** MenuItems to use. */ - items: MenuItem[]; - /** ID of the engine to use */ + /** MenuItems to use. */ + items: MenuItem[]; + /** ID of the engine to use */ engineID: string; } interface CommitTextParameters { - /** The text to commit */ + /** The text to commit */ text: string; - /** ID of the context where the text will be committed */ + /** ID of the context where the text will be committed */ contextID: number; } - interface CandidateUsage { - /** The title string of details description. */ - title: string; - /** The body string of detail description. */ - body: string; - } + interface CandidateUsage { + /** The title string of details description. */ + title: string; + /** The body string of detail description. */ + body: string; + } - interface CandidateTemplate { - /** The candidate */ - candidate: string; - /** The candidate's id */ - id: number; - /** - * Optional. - * The id to add these candidates under - */ - parentId?: number; - /** - * Optional. - * Short string displayed to next to the candidate, often the shortcut key or index - */ - label?: string; - /** - * Optional. - * Additional text describing the candidate - */ - annotation?: string; - /** - * Optional. - * The usage or detail description of word. - */ - usage?: CandidateUsage; - } + interface CandidateTemplate { + /** The candidate */ + candidate: string; + /** The candidate's id */ + id: number; + /** + * Optional. + * The id to add these candidates under + */ + parentId?: number; + /** + * Optional. + * Short string displayed to next to the candidate, often the shortcut key or index + */ + label?: string; + /** + * Optional. + * Additional text describing the candidate + */ + annotation?: string; + /** + * Optional. + * The usage or detail description of word. + */ + usage?: CandidateUsage; + } interface CandidatesParameters { - /** ID of the context that owns the candidate window. */ + /** ID of the context that owns the candidate window. */ contextID: number; - /** List of candidates to show in the candidate window */ - candidates: CandidateTemplate[]; - } + /** List of candidates to show in the candidate window */ + candidates: CandidateTemplate[]; + } - interface CompositionParameterSegment { - /** Index of the character to start this segment at */ - start: number; - /** Index of the character to end this segment after. */ - end: number; - /** The type of the underline to modify this segment. */ - style: string; + interface CompositionParameterSegment { + /** Index of the character to start this segment at */ + start: number; + /** Index of the character to end this segment after. */ + end: number; + /** The type of the underline to modify this segment. */ + style: string; } interface CompositionParameters { - /** ID of the context where the composition text will be set */ + /** ID of the context where the composition text will be set */ contextID: number; - /** Text to set */ + /** Text to set */ text: string; - /** Optional. List of segments and their associated types. */ - segments: CompositionParameterSegment[]; - /** Position in the text of the cursor. */ + /** Optional. List of segments and their associated types. */ + segments: CompositionParameterSegment[]; + /** Position in the text of the cursor. */ cursor: number; - /** Optional. Position in the text that the selection starts at. */ + /** Optional. Position in the text that the selection starts at. */ selectionStart?: number; - /** Optional. Position in the text that the selection ends at. */ + /** Optional. Position in the text that the selection ends at. */ selectionEnd?: number; } @@ -3659,88 +3659,88 @@ declare namespace chrome.input.ime { engineId: string; } - interface CandidateWindowParameterProperties { - /** - * Optional. - * True to show the cursor, false to hide it. - */ + interface CandidateWindowParameterProperties { + /** + * Optional. + * True to show the cursor, false to hide it. + */ cursorVisible?: boolean; - /** - * Optional. - * True if the candidate window should be rendered vertical, false to make it horizontal. - */ + /** + * Optional. + * True if the candidate window should be rendered vertical, false to make it horizontal. + */ vertical?: boolean; - /** - * Optional. - * The number of candidates to display per page. - */ + /** + * Optional. + * The number of candidates to display per page. + */ pageSize?: number; - /** - * Optional. - * True to display the auxiliary text, false to hide it. - */ + /** + * Optional. + * True to display the auxiliary text, false to hide it. + */ auxiliaryTextVisible?: boolean; - /** - * Optional. - * Text that is shown at the bottom of the candidate window. - */ + /** + * Optional. + * Text that is shown at the bottom of the candidate window. + */ auxiliaryText?: string; - /** - * Optional. - * True to show the Candidate window, false to hide it. - */ + /** + * Optional. + * True to show the Candidate window, false to hide it. + */ visible?: boolean; - /** - * Optional. - * Where to display the candidate window. - * @since Chrome 28. - */ - windowPosition?: string; - } + /** + * Optional. + * Where to display the candidate window. + * @since Chrome 28. + */ + windowPosition?: string; + } - interface CandidateWindowParameter { - /** ID of the engine to set properties on. */ - engineID: string; - properties: CandidateWindowParameterProperties; + interface CandidateWindowParameter { + /** ID of the engine to set properties on. */ + engineID: string; + properties: CandidateWindowParameterProperties; } interface ClearCompositionParameters { - /** ID of the context where the composition will be cleared */ + /** ID of the context where the composition will be cleared */ contextID: number; } interface CursorPositionParameters { - /** ID of the candidate to select. */ + /** ID of the candidate to select. */ candidateID: number; - /** ID of the context that owns the candidate window. */ - contextID: number; - } - - interface SendKeyEventParameters { - /** ID of the context where the key events will be sent, or zero to send key events to non-input field. */ - contextID: number; - /** Data on the key event. */ - keyData: KeyboardEvent[]; - } - - interface DeleteSurroundingTextParameters { - /** ID of the engine receiving the event. */ - engineID: string; - /** ID of the context where the surrounding text will be deleted. */ + /** ID of the context that owns the candidate window. */ contextID: number; - /** The offset from the caret position where deletion will start. This value can be negative. */ - offset: number; - /** The number of characters to be deleted */ - length: number; - } + } - interface SurroundingTextInfo { - /** The text around cursor. */ - text: string; - /** The ending position of the selection. This value indicates caret position if there is no selection. */ - focus: number; - /** The beginning position of the selection. This value indicates caret position if is no selection. */ - anchor: number; + interface SendKeyEventParameters { + /** ID of the context where the key events will be sent, or zero to send key events to non-input field. */ + contextID: number; + /** Data on the key event. */ + keyData: KeyboardEvent[]; + } + + interface DeleteSurroundingTextParameters { + /** ID of the engine receiving the event. */ + engineID: string; + /** ID of the context where the surrounding text will be deleted. */ + contextID: number; + /** The offset from the caret position where deletion will start. This value can be negative. */ + offset: number; + /** The number of characters to be deleted */ + length: number; + } + + interface SurroundingTextInfo { + /** The text around cursor. */ + text: string; + /** The ending position of the selection. This value indicates caret position if there is no selection. */ + focus: number; + /** The beginning position of the selection. This value indicates caret position if is no selection. */ + anchor: number; } interface BlurEvent extends chrome.events.Event<(contextID: number) => void> {} @@ -3759,117 +3759,117 @@ declare namespace chrome.input.ime { interface MenuItemActivatedEvent extends chrome.events.Event<(engineID: string, name: string) => void> {} - interface SurroundingTextChangedEvent extends chrome.events.Event<(engineID: string, surroundingInfo: SurroundingTextInfo) => void> {} + interface SurroundingTextChangedEvent extends chrome.events.Event<(engineID: string, surroundingInfo: SurroundingTextInfo) => void> {} - interface InputResetEvent extends chrome.events.Event<(engineID: string) => void> {} + interface InputResetEvent extends chrome.events.Event<(engineID: string) => void> {} - /** - * Adds the provided menu items to the language menu when this IME is active. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function setMenuItems(parameters: ImeParameters, callback?: () => void): void; - /** - * Commits the provided text to the current input. - * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean success) {...}; - */ + /** + * Adds the provided menu items to the language menu when this IME is active. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function setMenuItems(parameters: ImeParameters, callback?: () => void): void; + /** + * Commits the provided text to the current input. + * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean success) {...}; + */ export function commitText(parameters: CommitTextParameters, callback?: (success: boolean) => void): void; - /** - * Sets the current candidate list. This fails if this extension doesn't own the active IME - * @param callback Called when the operation completes. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean success) {...}; - */ + /** + * Sets the current candidate list. This fails if this extension doesn't own the active IME + * @param callback Called when the operation completes. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean success) {...}; + */ export function setCandidates(parameters: CandidatesParameters, callback?: (success: boolean) => void): void; - /** - * Set the current composition. If this extension does not own the active IME, this fails. - * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean success) {...}; - */ + /** + * Set the current composition. If this extension does not own the active IME, this fails. + * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean success) {...}; + */ export function setComposition(parameters: CompositionParameters, callback?: (success: boolean) => void): void; - /** - * Updates the state of the MenuItems specified - * @param callback Called when the operation completes - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function updateMenuItems(parameters: MenuItemParameters, callback?: () => void): void; - /** - * Sets the properties of the candidate window. This fails if the extension doesn't own the active IME - * @param callback Called when the operation completes. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean success) {...}; - */ - export function setCandidateWindowProperties(parameters: CandidateWindowParameter, callback?: (success: boolean) => void): void; - /** - * Clear the current composition. If this extension does not own the active IME, this fails. - * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean success) {...}; - */ + /** + * Updates the state of the MenuItems specified + * @param callback Called when the operation completes + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function updateMenuItems(parameters: MenuItemParameters, callback?: () => void): void; + /** + * Sets the properties of the candidate window. This fails if the extension doesn't own the active IME + * @param callback Called when the operation completes. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean success) {...}; + */ + export function setCandidateWindowProperties(parameters: CandidateWindowParameter, callback?: (success: boolean) => void): void; + /** + * Clear the current composition. If this extension does not own the active IME, this fails. + * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean success) {...}; + */ export function clearComposition(parameters: ClearCompositionParameters, callback?: (success: boolean) => void): void; - /** - * Set the position of the cursor in the candidate window. This is a no-op if this extension does not own the active IME. - * @param callback Called when the operation completes - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean success) {...}; - */ + /** + * Set the position of the cursor in the candidate window. This is a no-op if this extension does not own the active IME. + * @param callback Called when the operation completes + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean success) {...}; + */ export function setCursorPosition(parameters: CursorPositionParameters, callback?: (success: boolean) => void): void; - /** - * Sends the key events. This function is expected to be used by virtual keyboards. When key(s) on a virtual keyboard is pressed by a user, this function is used to propagate that event to the system. - * @since Chrome 33. - * @param callback Called when the operation completes. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function sendKeyEvents(parameters: SendKeyEventParameters, callback?: () => void): void; - /** - * Hides the input view window, which is popped up automatically by system. If the input view window is already hidden, this function will do nothing. - * @since Chrome 34. - */ - export function hideInputView(): void; - /** - * Deletes the text around the caret. - * @since Chrome 27. - */ - export function deleteSurroundingText(parameters: DeleteSurroundingTextParameters, callback?: () => void): void; - /** - * Indicates that the key event received by onKeyEvent is handled. This should only be called if the onKeyEvent listener is asynchronous. - * @since Chrome 25. - * @param requestId Request id of the event that was handled. This should come from keyEvent.requestId - * @param response True if the keystroke was handled, false if not - */ - export function keyEventHandled(requestId: string, response: boolean): void; + /** + * Sends the key events. This function is expected to be used by virtual keyboards. When key(s) on a virtual keyboard is pressed by a user, this function is used to propagate that event to the system. + * @since Chrome 33. + * @param callback Called when the operation completes. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function sendKeyEvents(parameters: SendKeyEventParameters, callback?: () => void): void; + /** + * Hides the input view window, which is popped up automatically by system. If the input view window is already hidden, this function will do nothing. + * @since Chrome 34. + */ + export function hideInputView(): void; + /** + * Deletes the text around the caret. + * @since Chrome 27. + */ + export function deleteSurroundingText(parameters: DeleteSurroundingTextParameters, callback?: () => void): void; + /** + * Indicates that the key event received by onKeyEvent is handled. This should only be called if the onKeyEvent listener is asynchronous. + * @since Chrome 25. + * @param requestId Request id of the event that was handled. This should come from keyEvent.requestId + * @param response True if the keystroke was handled, false if not + */ + export function keyEventHandled(requestId: string, response: boolean): void; - /** This event is sent when focus leaves a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ + /** This event is sent when focus leaves a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ var onBlur: BlurEvent; - /** This event is sent if this extension owns the active IME. */ + /** This event is sent if this extension owns the active IME. */ var onCandidateClicked: CandidateClickedEvent; - /** This event is sent if this extension owns the active IME. */ + /** This event is sent if this extension owns the active IME. */ var onKeyEvent: KeyEventEvent; - /** This event is sent when an IME is deactivated. It signals that the IME will no longer be receiving onKeyPress events. */ + /** This event is sent when an IME is deactivated. It signals that the IME will no longer be receiving onKeyPress events. */ var onDeactivated: DeactivatedEvent; - /** This event is sent when the properties of the current InputContext change, such as the the type. It is sent to all extensions that are listening to this event, and enabled by the user. */ + /** This event is sent when the properties of the current InputContext change, such as the the type. It is sent to all extensions that are listening to this event, and enabled by the user. */ var onInputContextUpdate: InputContextUpdateEvent; - /** This event is sent when an IME is activated. It signals that the IME will be receiving onKeyPress events. */ + /** This event is sent when an IME is activated. It signals that the IME will be receiving onKeyPress events. */ var onActivate: ActivateEvent; - /** This event is sent when focus enters a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ + /** This event is sent when focus enters a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ var onFocus: FocusEvent; - /** Called when the user selects a menu item */ + /** Called when the user selects a menu item */ var onMenuItemActivated: MenuItemActivatedEvent; - /** - * Called when the editable string around caret is changed or when the caret position is moved. The text length is limited to 100 characters for each back and forth direction. - * @since Chrome 27. - */ - var onSurroundingTextChanged: SurroundingTextChangedEvent; - /** - * This event is sent when chrome terminates ongoing text input session. - * @since Chrome 29. - */ - var onReset: InputResetEvent; + /** + * Called when the editable string around caret is changed or when the caret position is moved. The text length is limited to 100 characters for each back and forth direction. + * @since Chrome 27. + */ + var onSurroundingTextChanged: SurroundingTextChangedEvent; + /** + * This event is sent when chrome terminates ongoing text input session. + * @since Chrome 29. + */ + var onReset: InputResetEvent; } //////////////////// @@ -3881,115 +3881,115 @@ declare namespace chrome.input.ime { * @since Chrome 8. */ declare namespace chrome.management { - /** Information about an installed extension, app, or theme. */ + /** Information about an installed extension, app, or theme. */ interface ExtensionInfo { - /** - * Optional. - * A reason the item is disabled. - * @since Chrome 17. - */ + /** + * Optional. + * A reason the item is disabled. + * @since Chrome 17. + */ disabledReason?: string; - /** Optional. The launch url (only present for apps). */ + /** Optional. The launch url (only present for apps). */ appLaunchUrl?: string; - /** - * The description of this extension, app, or theme. - * @since Chrome 9. - */ + /** + * The description of this extension, app, or theme. + * @since Chrome 9. + */ description: string; - /** - * Returns a list of API based permissions. - * @since Chrome 9. - */ + /** + * Returns a list of API based permissions. + * @since Chrome 9. + */ permissions: string[]; - /** - * Optional. - * A list of icon information. Note that this just reflects what was declared in the manifest, and the actual image at that url may be larger or smaller than what was declared, so you might consider using explicit width and height attributes on img tags referencing these images. See the manifest documentation on icons for more details. - */ + /** + * Optional. + * A list of icon information. Note that this just reflects what was declared in the manifest, and the actual image at that url may be larger or smaller than what was declared, so you might consider using explicit width and height attributes on img tags referencing these images. See the manifest documentation on icons for more details. + */ icons?: IconInfo[]; - /** - * Returns a list of host based permissions. - * @since Chrome 9. - */ + /** + * Returns a list of host based permissions. + * @since Chrome 9. + */ hostPermissions: string[]; - /** Whether it is currently enabled or disabled. */ + /** Whether it is currently enabled or disabled. */ enabled: boolean; - /** - * Optional. - * The URL of the homepage of this extension, app, or theme. - * @since Chrome 11. - */ + /** + * Optional. + * The URL of the homepage of this extension, app, or theme. + * @since Chrome 11. + */ homepageUrl?: string; - /** - * Whether this extension can be disabled or uninstalled by the user. - * @since Chrome 12. - */ + /** + * Whether this extension can be disabled or uninstalled by the user. + * @since Chrome 12. + */ mayDisable: boolean; - /** - * How the extension was installed. - * @since Chrome 22. - */ + /** + * How the extension was installed. + * @since Chrome 22. + */ installType: string; - /** The version of this extension, app, or theme. */ + /** The version of this extension, app, or theme. */ version: string; - /** The extension's unique identifier. */ + /** The extension's unique identifier. */ id: string; - /** - * Whether the extension, app, or theme declares that it supports offline. - * @since Chrome 15. - */ + /** + * Whether the extension, app, or theme declares that it supports offline. + * @since Chrome 15. + */ offlineEnabled: boolean; - /** - * Optional. - * The update URL of this extension, app, or theme. - * @since Chrome 16. - */ + /** + * Optional. + * The update URL of this extension, app, or theme. + * @since Chrome 16. + */ updateUrl?: string; - /** - * The type of this extension, app, or theme. - * @since Chrome 23. - */ + /** + * The type of this extension, app, or theme. + * @since Chrome 23. + */ type: string; - /** The url for the item's options page, if it has one. */ + /** The url for the item's options page, if it has one. */ optionsUrl: string; - /** The name of this extension, app, or theme. */ + /** The name of this extension, app, or theme. */ name: string; - /** - * A short version of the name of this extension, app, or theme. - * @since Chrome 31. - */ - shortName: string; - /** - * True if this is an app. - * @deprecated since Chrome 33. Please use management.ExtensionInfo.type. - */ - isApp: boolean; - /** - * Optional. - * The app launch type (only present for apps). - * @since Chrome 37. - */ - launchType?: string; - /** - * Optional. - * The currently available launch types (only present for apps). - * @since Chrome 37. - */ - availableLaunchTypes?: string[]; + /** + * A short version of the name of this extension, app, or theme. + * @since Chrome 31. + */ + shortName: string; + /** + * True if this is an app. + * @deprecated since Chrome 33. Please use management.ExtensionInfo.type. + */ + isApp: boolean; + /** + * Optional. + * The app launch type (only present for apps). + * @since Chrome 37. + */ + launchType?: string; + /** + * Optional. + * The currently available launch types (only present for apps). + * @since Chrome 37. + */ + availableLaunchTypes?: string[]; } - /** Information about an icon belonging to an extension, app, or theme. */ + /** Information about an icon belonging to an extension, app, or theme. */ interface IconInfo { - /** The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is disabled, for example), append ?grayscale=true to the URL. */ + /** The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is disabled, for example), append ?grayscale=true to the URL. */ url: string; - /** A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24, and 16. */ + /** A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24, and 16. */ size: number; } interface UninstallOptions { - /** - * Optional. - * Whether or not a confirm-uninstall dialog should prompt the user. Defaults to false for self uninstalls. If an extension uninstalls another extension, this parameter is ignored and the dialog is always shown. - */ + /** + * Optional. + * Whether or not a confirm-uninstall dialog should prompt the user. Defaults to false for self uninstalls. If an extension uninstalls another extension, this parameter is ignored and the dialog is always shown. + */ showConfirmDialog?: boolean; } @@ -4001,123 +4001,123 @@ declare namespace chrome.management { interface ManagementEnabledEvent extends chrome.events.Event<(info: ExtensionInfo) => void> {} - /** - * Enables or disables an app or extension. - * @param id This should be the id from an item of management.ExtensionInfo. - * @param enabled Whether this item should be enabled or disabled. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function setEnabled(id: string, enabled: boolean, callback?: () => void): void; - /** - * Returns a list of permission warnings for the given extension id. - * @since Chrome 15. - * @param id The ID of an already installed extension. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(array of string permissionWarnings) {...}; - */ + /** + * Enables or disables an app or extension. + * @param id This should be the id from an item of management.ExtensionInfo. + * @param enabled Whether this item should be enabled or disabled. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function setEnabled(id: string, enabled: boolean, callback?: () => void): void; + /** + * Returns a list of permission warnings for the given extension id. + * @since Chrome 15. + * @param id The ID of an already installed extension. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(array of string permissionWarnings) {...}; + */ export function getPermissionWarningsById(id: string, callback?: (permissionWarnings: string[]) => void): void; - /** - * Returns information about the installed extension, app, or theme that has the given ID. - * @since Chrome 9. - * @param id The ID from an item of management.ExtensionInfo. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( ExtensionInfo result) {...}; - */ + /** + * Returns information about the installed extension, app, or theme that has the given ID. + * @since Chrome 9. + * @param id The ID from an item of management.ExtensionInfo. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( ExtensionInfo result) {...}; + */ export function get(id: string, callback?: (result: ExtensionInfo) => void): void; - /** - * Returns a list of information about installed extensions and apps. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(array of ExtensionInfo result) {...}; - */ + /** + * Returns a list of information about installed extensions and apps. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(array of ExtensionInfo result) {...}; + */ export function getAll(callback?: (result: ExtensionInfo[]) => void): void; - /** - * Returns a list of permission warnings for the given extension manifest string. Note: This function can be used without requesting the 'management' permission in the manifest. - * @since Chrome 15. - * @param manifestStr Extension manifest JSON string. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(array of string permissionWarnings) {...}; - */ + /** + * Returns a list of permission warnings for the given extension manifest string. Note: This function can be used without requesting the 'management' permission in the manifest. + * @since Chrome 15. + * @param manifestStr Extension manifest JSON string. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(array of string permissionWarnings) {...}; + */ export function getPermissionWarningsByManifest(manifestStr: string, callback?: (permissionwarnings: string[]) => void): void; - /** - * Launches an application. - * @param id The extension id of the application. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function launchApp(id: string, callback?: () => void): void; - /** - * Uninstalls a currently installed app or extension. - * @since Chrome 21. - * @param id This should be the id from an item of management.ExtensionInfo. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function uninstall(id: string, options?: UninstallOptions, callback?: () => void): void; - /** - * Uninstalls a currently installed app or extension. - * @deprecated since Chrome 21. The options parameter was added to this function. - * @param id This should be the id from an item of management.ExtensionInfo. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function uninstall(id: string, callback?: () => void): void; - /** - * Returns information about the calling extension, app, or theme. Note: This function can be used without requesting the 'management' permission in the manifest. - * @since Chrome 39. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( ExtensionInfo result) {...}; - */ - export function getSelf(callback?: (result: ExtensionInfo) => void): void; - /** - * Uninstalls the calling extension. - * Note: This function can be used without requesting the 'management' permission in the manifest. - * @since Chrome 26. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function uninstallSelf(options?: UninstallOptions, callback?: () => void): void; - /** - * Uninstalls the calling extension. - * Note: This function can be used without requesting the 'management' permission in the manifest. - * @since Chrome 26. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function uninstallSelf(callback?: () => void): void; - /** - * Display options to create shortcuts for an app. On Mac, only packaged app shortcuts can be created. - * @since Chrome 37. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function createAppShortcut(id: string, callback?: () => void): void; - /** - * Set the launch type of an app. - * @since Chrome 37. - * @param id This should be the id from an app item of management.ExtensionInfo. - * @param launchType The target launch type. Always check and make sure this launch type is in ExtensionInfo.availableLaunchTypes, because the available launch types vary on different platforms and configurations. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function setLaunchType(id: string, launchType: string, callback?: () => void): void; - /** - * Generate an app for a URL. Returns the generated bookmark app. - * @since Chrome 37. - * @param url The URL of a web page. The scheme of the URL can only be "http" or "https". - * @param title The title of the generated app. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function( ExtensionInfo result) {...}; - */ - export function generateAppForLink(url: string, title: string, callback?: (result: ExtensionInfo) => void): void; + /** + * Launches an application. + * @param id The extension id of the application. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function launchApp(id: string, callback?: () => void): void; + /** + * Uninstalls a currently installed app or extension. + * @since Chrome 21. + * @param id This should be the id from an item of management.ExtensionInfo. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function uninstall(id: string, options?: UninstallOptions, callback?: () => void): void; + /** + * Uninstalls a currently installed app or extension. + * @deprecated since Chrome 21. The options parameter was added to this function. + * @param id This should be the id from an item of management.ExtensionInfo. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function uninstall(id: string, callback?: () => void): void; + /** + * Returns information about the calling extension, app, or theme. Note: This function can be used without requesting the 'management' permission in the manifest. + * @since Chrome 39. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( ExtensionInfo result) {...}; + */ + export function getSelf(callback?: (result: ExtensionInfo) => void): void; + /** + * Uninstalls the calling extension. + * Note: This function can be used without requesting the 'management' permission in the manifest. + * @since Chrome 26. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function uninstallSelf(options?: UninstallOptions, callback?: () => void): void; + /** + * Uninstalls the calling extension. + * Note: This function can be used without requesting the 'management' permission in the manifest. + * @since Chrome 26. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function uninstallSelf(callback?: () => void): void; + /** + * Display options to create shortcuts for an app. On Mac, only packaged app shortcuts can be created. + * @since Chrome 37. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function createAppShortcut(id: string, callback?: () => void): void; + /** + * Set the launch type of an app. + * @since Chrome 37. + * @param id This should be the id from an app item of management.ExtensionInfo. + * @param launchType The target launch type. Always check and make sure this launch type is in ExtensionInfo.availableLaunchTypes, because the available launch types vary on different platforms and configurations. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function setLaunchType(id: string, launchType: string, callback?: () => void): void; + /** + * Generate an app for a URL. Returns the generated bookmark app. + * @since Chrome 37. + * @param url The URL of a web page. The scheme of the URL can only be "http" or "https". + * @param title The title of the generated app. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function( ExtensionInfo result) {...}; + */ + export function generateAppForLink(url: string, title: string, callback?: (result: ExtensionInfo) => void): void; - /** Fired when an app or extension has been disabled. */ + /** Fired when an app or extension has been disabled. */ var onDisabled: ManagementDisabledEvent; - /** Fired when an app or extension has been uninstalled. */ + /** Fired when an app or extension has been uninstalled. */ var onUninstalled: ManagementUninstalledEvent; - /** Fired when an app or extension has been installed. */ + /** Fired when an app or extension has been installed. */ var onInstalled: ManagementInstalledEvent; - /** Fired when an app or extension has been enabled. */ + /** Fired when an app or extension has been enabled. */ var onEnabled: ManagementEnabledEvent; } @@ -4131,47 +4131,47 @@ declare namespace chrome.management { * @since Chrome 43. */ declare namespace chrome.networking.config { - interface NetworkInfo { - /** Currently only WiFi supported. */ - Type: string; - /** Optional. A unique identifier of the network. */ - GUID?: string; - /** Optional. A hex-encoded byte sequence. */ - HexSSID?: string; - /** Optional. The decoded SSID of the network (default encoding is UTF-8). To filter for non-UTF-8 SSIDs, use HexSSID instead. */ - SSID?: string; - /** Optional. The basic service set identification (BSSID) uniquely identifying the basic service set. BSSID is represented as a human readable, hex-encoded string with bytes separated by colons, e.g. 45:67:89:ab:cd:ef. */ - BSSID?: string; - /** Optional. Identifier indicating the security type of the network. Valid values are None, WEP-PSK, WPA-PSK and WPA-EAP. */ - Security?: string; - } + interface NetworkInfo { + /** Currently only WiFi supported. */ + Type: string; + /** Optional. A unique identifier of the network. */ + GUID?: string; + /** Optional. A hex-encoded byte sequence. */ + HexSSID?: string; + /** Optional. The decoded SSID of the network (default encoding is UTF-8). To filter for non-UTF-8 SSIDs, use HexSSID instead. */ + SSID?: string; + /** Optional. The basic service set identification (BSSID) uniquely identifying the basic service set. BSSID is represented as a human readable, hex-encoded string with bytes separated by colons, e.g. 45:67:89:ab:cd:ef. */ + BSSID?: string; + /** Optional. Identifier indicating the security type of the network. Valid values are None, WEP-PSK, WPA-PSK and WPA-EAP. */ + Security?: string; + } - interface CaptivePorttalDetectedEvent extends chrome.events.Event<(networkInfo: NetworkInfo) => void> {} + interface CaptivePorttalDetectedEvent extends chrome.events.Event<(networkInfo: NetworkInfo) => void> {} - /** - * Allows an extension to define network filters for the networks it can handle. A call to this function will remove all filters previously installed by the extension before setting the new list. - * @param networks Network filters to set. Every NetworkInfo must either have the SSID or HexSSID set. Other fields will be ignored. - * @param callback Called back when this operation is finished. - * The callback parameter should be a function that looks like this: - * function() {...}; - */ - export function setNetworkFilter(networks: NetworkInfo[], callback: () => void): void; - /** - * Called by the extension to notify the network config API that it finished a captive portal authentication attempt and hand over the result of the attempt. This function must only be called with the GUID of the latest onCaptivePortalDetected event. - * @param GUID Unique network identifier obtained from onCaptivePortalDetected. - * @param result The result of the authentication attempt. - * unhandled: The extension does not handle this network or captive portal (e.g. server end-point not found or not compatible). - * succeeded: The extension handled this network and authenticated successfully. - * rejected: The extension handled this network, tried to authenticate, however was rejected by the server. - * failed: The extension handled this network, tried to authenticate, however failed due to an unspecified error. - * @param callback Called back when this operation is finished. - * If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function finishAuthentication(GUID: string, result: string, callback?: () => void): void; + /** + * Allows an extension to define network filters for the networks it can handle. A call to this function will remove all filters previously installed by the extension before setting the new list. + * @param networks Network filters to set. Every NetworkInfo must either have the SSID or HexSSID set. Other fields will be ignored. + * @param callback Called back when this operation is finished. + * The callback parameter should be a function that looks like this: + * function() {...}; + */ + export function setNetworkFilter(networks: NetworkInfo[], callback: () => void): void; + /** + * Called by the extension to notify the network config API that it finished a captive portal authentication attempt and hand over the result of the attempt. This function must only be called with the GUID of the latest onCaptivePortalDetected event. + * @param GUID Unique network identifier obtained from onCaptivePortalDetected. + * @param result The result of the authentication attempt. + * unhandled: The extension does not handle this network or captive portal (e.g. server end-point not found or not compatible). + * succeeded: The extension handled this network and authenticated successfully. + * rejected: The extension handled this network, tried to authenticate, however was rejected by the server. + * failed: The extension handled this network, tried to authenticate, however failed due to an unspecified error. + * @param callback Called back when this operation is finished. + * If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function finishAuthentication(GUID: string, result: string, callback?: () => void): void; - /** This event fires everytime a captive portal is detected on a network matching any of the currently registered network filters and the user consents to use the extension for authentication. Network filters may be set using the setNetworkFilter. Upon receiving this event the extension should start its authentication attempt with the captive portal. When the extension finishes its attempt, it must call finishAuthentication with the GUID received with this event and the appropriate authentication result. */ - var onCaptivePortalDetected: CaptivePorttalDetectedEvent; + /** This event fires everytime a captive portal is detected on a network matching any of the currently registered network filters and the user consents to use the extension for authentication. Network filters may be set using the setNetworkFilter. Upon receiving this event the extension should start its authentication attempt with the captive portal. When the extension finishes its attempt, it must call finishAuthentication with the GUID received with this event and the appropriate authentication result. */ + var onCaptivePortalDetected: CaptivePorttalDetectedEvent; } //////////////////// @@ -4190,144 +4190,144 @@ declare namespace chrome.notifications { } interface ItemOptions { - /** Title of one item of a list notification. */ + /** Title of one item of a list notification. */ title: string; - /** Additional details about this item. */ + /** Additional details about this item. */ message: string; } interface NotificationOptions { - /** Optional. Which type of notification to display. Required for notifications.create method. */ + /** Optional. Which type of notification to display. Required for notifications.create method. */ type?: string; - /** - * Optional. - * A URL to the sender's avatar, app icon, or a thumbnail for image notifications. - * URLs can be a data URL, a blob URL, or a URL relative to a resource within this extension's .crx file Required for notifications.create method. - */ + /** + * Optional. + * A URL to the sender's avatar, app icon, or a thumbnail for image notifications. + * URLs can be a data URL, a blob URL, or a URL relative to a resource within this extension's .crx file Required for notifications.create method. + */ iconUrl?: string; - /** Optional. Title of the notification (e.g. sender name for email). Required for notifications.create method. */ + /** Optional. Title of the notification (e.g. sender name for email). Required for notifications.create method. */ title?: string; - /** Optional. Main notification content. Required for notifications.create method. */ + /** Optional. Main notification content. Required for notifications.create method. */ message?: string; - /** - * Optional. - * Alternate notification content with a lower-weight font. - * @since Chrome 31. - */ + /** + * Optional. + * Alternate notification content with a lower-weight font. + * @since Chrome 31. + */ contextMessage?: string; - /** Optional. Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default. */ + /** Optional. Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default. */ priority?: number; - /** Optional. A timestamp associated with the notification, in milliseconds past the epoch (e.g. Date.now() + n). */ + /** Optional. A timestamp associated with the notification, in milliseconds past the epoch (e.g. Date.now() + n). */ eventTime?: number; - /** Optional. Text and icons for up to two notification action buttons. */ - buttons?: ButtonOptions[]; - /** Optional. Items for multi-item notifications. */ - items?: ItemOptions[]; - /** - * Optional. - * Current progress ranges from 0 to 100. - * @since Chrome 30. - */ + /** Optional. Text and icons for up to two notification action buttons. */ + buttons?: ButtonOptions[]; + /** Optional. Items for multi-item notifications. */ + items?: ItemOptions[]; + /** + * Optional. + * Current progress ranges from 0 to 100. + * @since Chrome 30. + */ progress?: number; - /** - * Optional. - * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification. - * @since Chrome 32. - */ + /** + * Optional. + * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification. + * @since Chrome 32. + */ isClickable?: boolean; - /** - * Optional. - * A URL to the app icon mask. URLs have the same restrictions as iconUrl. The app icon mask should be in alpha channel, as only the alpha channel of the image will be considered. - * @since Chrome 38. - */ - appIconMaskUrl?: string; - /** Optional. A URL to the image thumbnail for image-type notifications. URLs have the same restrictions as iconUrl. */ - imageUrl?: string; + /** + * Optional. + * A URL to the app icon mask. URLs have the same restrictions as iconUrl. The app icon mask should be in alpha channel, as only the alpha channel of the image will be considered. + * @since Chrome 38. + */ + appIconMaskUrl?: string; + /** Optional. A URL to the image thumbnail for image-type notifications. URLs have the same restrictions as iconUrl. */ + imageUrl?: string; } - interface NotificationClosedEvent extends chrome.events.Event<(notificationId: string, byUser: boolean) => void> {} + interface NotificationClosedEvent extends chrome.events.Event<(notificationId: string, byUser: boolean) => void> {} - interface NotificationClickedEvent extends chrome.events.Event<(notificationId: string) => void> {} + interface NotificationClickedEvent extends chrome.events.Event<(notificationId: string) => void> {} - interface NotificationButtonClickedEvent extends chrome.events.Event<(notificationId: string, buttonIndex: number) => void> {} + interface NotificationButtonClickedEvent extends chrome.events.Event<(notificationId: string, buttonIndex: number) => void> {} - interface NotificationPermissionLevelChangedEvent extends chrome.events.Event<(level: string) => void> {} + interface NotificationPermissionLevelChangedEvent extends chrome.events.Event<(level: string) => void> {} - interface NotificationShowSettingsEvent extends chrome.events.Event<() => void> {} + interface NotificationShowSettingsEvent extends chrome.events.Event<() => void> {} - /** The notification closed, either by the system or by user action. */ - export var onClosed: NotificationClosedEvent; - /** The user clicked in a non-button area of the notification. */ - export var onClicked: NotificationClickedEvent; - /** The user pressed a button in the notification. */ - export var onButtonClicked: NotificationButtonClickedEvent; - /** - * The user changes the permission level. - * @since Chrome 32. - */ - export var onPermissionLevelChanged: NotificationPermissionLevelChangedEvent; - /** - * The user clicked on a link for the app's notification settings. - * @since Chrome 32. - */ - export var onShowSettings: NotificationShowSettingsEvent; + /** The notification closed, either by the system or by user action. */ + export var onClosed: NotificationClosedEvent; + /** The user clicked in a non-button area of the notification. */ + export var onClicked: NotificationClickedEvent; + /** The user pressed a button in the notification. */ + export var onButtonClicked: NotificationButtonClickedEvent; + /** + * The user changes the permission level. + * @since Chrome 32. + */ + export var onPermissionLevelChanged: NotificationPermissionLevelChangedEvent; + /** + * The user clicked on a link for the app's notification settings. + * @since Chrome 32. + */ + export var onShowSettings: NotificationShowSettingsEvent; - /** - * Creates and displays a notification. - * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation. - * The notificationId parameter is required before Chrome 42. - * @param options Contents of the notification. - * @param callback Returns the notification id (either supplied or generated) that represents the created notification. - * The callback is required before Chrome 42. - * If you specify the callback parameter, it should be a function that looks like this: - * function(string notificationId) {...}; - */ - export function create(notificationId: string, options: NotificationOptions, callback?: (notificationId: string) => void): void; - /** - * Creates and displays a notification. - * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation. - * The notificationId parameter is required before Chrome 42. - * @param options Contents of the notification. - * @param callback Returns the notification id (either supplied or generated) that represents the created notification. - * The callback is required before Chrome 42. - * If you specify the callback parameter, it should be a function that looks like this: - * function(string notificationId) {...}; - */ - export function create(options: NotificationOptions, callback?: (notificationId: string) => void): void; - /** - * Updates an existing notification. - * @param notificationId The id of the notification to be updated. This is returned by notifications.create method. - * @param options Contents of the notification to update to. - * @param callback Called to indicate whether a matching notification existed. - * The callback is required before Chrome 42. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasUpdated) {...}; - */ - export function update(notificationId: string, options: NotificationOptions, callback?: (wasUpdated: boolean) => void): void; - /** - * Clears the specified notification. - * @param notificationId The id of the notification to be cleared. This is returned by notifications.create method. - * @param callback Called to indicate whether a matching notification existed. - * The callback is required before Chrome 42. - * If you specify the callback parameter, it should be a function that looks like this: - * function(boolean wasCleared) {...}; - */ - export function clear(notificationId: string, callback?: (wasCleared: boolean) => void): void; - /** - * Retrieves all the notifications. - * @since Chrome 29. - * @param callback Returns the set of notification_ids currently in the system. - * The callback parameter should be a function that looks like this: - * function(object notifications) {...}; - */ - export function getAll(callback: (notifications: Object) => void): void; - /** - * Retrieves whether the user has enabled notifications from this app or extension. - * @since Chrome 32. - * @param callback Returns the current permission level. - * The callback parameter should be a function that looks like this: - * function( PermissionLevel level) {...}; - */ + /** + * Creates and displays a notification. + * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation. + * The notificationId parameter is required before Chrome 42. + * @param options Contents of the notification. + * @param callback Returns the notification id (either supplied or generated) that represents the created notification. + * The callback is required before Chrome 42. + * If you specify the callback parameter, it should be a function that looks like this: + * function(string notificationId) {...}; + */ + export function create(notificationId: string, options: NotificationOptions, callback?: (notificationId: string) => void): void; + /** + * Creates and displays a notification. + * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation. + * The notificationId parameter is required before Chrome 42. + * @param options Contents of the notification. + * @param callback Returns the notification id (either supplied or generated) that represents the created notification. + * The callback is required before Chrome 42. + * If you specify the callback parameter, it should be a function that looks like this: + * function(string notificationId) {...}; + */ + export function create(options: NotificationOptions, callback?: (notificationId: string) => void): void; + /** + * Updates an existing notification. + * @param notificationId The id of the notification to be updated. This is returned by notifications.create method. + * @param options Contents of the notification to update to. + * @param callback Called to indicate whether a matching notification existed. + * The callback is required before Chrome 42. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean wasUpdated) {...}; + */ + export function update(notificationId: string, options: NotificationOptions, callback?: (wasUpdated: boolean) => void): void; + /** + * Clears the specified notification. + * @param notificationId The id of the notification to be cleared. This is returned by notifications.create method. + * @param callback Called to indicate whether a matching notification existed. + * The callback is required before Chrome 42. + * If you specify the callback parameter, it should be a function that looks like this: + * function(boolean wasCleared) {...}; + */ + export function clear(notificationId: string, callback?: (wasCleared: boolean) => void): void; + /** + * Retrieves all the notifications. + * @since Chrome 29. + * @param callback Returns the set of notification_ids currently in the system. + * The callback parameter should be a function that looks like this: + * function(object notifications) {...}; + */ + export function getAll(callback: (notifications: Object) => void): void; + /** + * Retrieves whether the user has enabled notifications from this app or extension. + * @since Chrome 32. + * @param callback Returns the current permission level. + * The callback parameter should be a function that looks like this: + * function( PermissionLevel level) {...}; + */ export function getPermissionLevel(callback: (level: string) => void): void; } @@ -4340,16 +4340,16 @@ declare namespace chrome.notifications { * @since Chrome 9. */ declare namespace chrome.omnibox { - /** A suggest result. */ + /** A suggest result. */ interface SuggestResult { - /** The text that is put into the URL bar, and that is sent to the extension when the user chooses this entry. */ + /** The text that is put into the URL bar, and that is sent to the extension when the user chooses this entry. */ content: string; - /** The text that is displayed in the URL dropdown. Can contain XML-style markup for styling. The supported tags are 'url' (for a literal URL), 'match' (for highlighting text that matched what the user's query), and 'dim' (for dim helper text). The styles can be nested, eg. dimmed match. You must escape the five predefined entities to display them as text: stackoverflow.com/a/1091953/89484 */ + /** The text that is displayed in the URL dropdown. Can contain XML-style markup for styling. The supported tags are 'url' (for a literal URL), 'match' (for highlighting text that matched what the user's query), and 'dim' (for dim helper text). The styles can be nested, eg. dimmed match. You must escape the five predefined entities to display them as text: stackoverflow.com/a/1091953/89484 */ description: string; } interface Suggestion { - /** The text that is displayed in the URL dropdown. Can contain XML-style markup for styling. The supported tags are 'url' (for a literal URL), 'match' (for highlighting text that matched what the user's query), and 'dim' (for dim helper text). The styles can be nested, eg. dimmed match. */ + /** The text that is displayed in the URL dropdown. Can contain XML-style markup for styling. The supported tags are 'url' (for a literal URL), 'match' (for highlighting text that matched what the user's query), and 'dim' (for dim helper text). The styles can be nested, eg. dimmed match. */ description: string; } @@ -4361,19 +4361,19 @@ declare namespace chrome.omnibox { interface OmniboxInputCancelledEvent extends chrome.events.Event<() => void> {} - /** - * Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar. - * @param suggestion A partial SuggestResult object, without the 'content' parameter. - */ + /** + * Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar. + * @param suggestion A partial SuggestResult object, without the 'content' parameter. + */ export function setDefaultSuggestion(suggestion: Suggestion): void; - /** User has accepted what is typed into the omnibox. */ + /** User has accepted what is typed into the omnibox. */ var onInputEntered: OmniboxInputEnteredEvent; - /** User has changed what is typed into the omnibox. */ + /** User has changed what is typed into the omnibox. */ var onInputChanged: OmniboxInputChangedEvent; - /** User has started a keyword input session by typing the extension's keyword. This is guaranteed to be sent exactly once per input session, and before any onInputChanged events. */ + /** User has started a keyword input session by typing the extension's keyword. This is guaranteed to be sent exactly once per input session, and before any onInputChanged events. */ var onInputStarted: OmniboxInputStartedEvent; - /** User has ended the keyword input session without accepting the input. */ + /** User has ended the keyword input session without accepting the input. */ var onInputCancelled: OmniboxInputCancelledEvent; } @@ -4389,80 +4389,80 @@ declare namespace chrome.pageAction { interface PageActionClickedEvent extends chrome.events.Event<(tab: chrome.tabs.Tab) => void> {} interface TitleDetails { - /** The id of the tab for which you want to modify the page action. */ + /** The id of the tab for which you want to modify the page action. */ tabId: number; - /** The tooltip string. */ + /** The tooltip string. */ title: string; } interface GetDetails { - /** Specify the tab to get the title from. */ + /** Specify the tab to get the title from. */ tabId: number; } interface PopupDetails { - /** The id of the tab for which you want to modify the page action. */ + /** The id of the tab for which you want to modify the page action. */ tabId: number; - /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ + /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ popup: string; } interface IconDetails { - /** The id of the tab for which you want to modify the page action. */ + /** The id of the tab for which you want to modify the page action. */ tabId: number; - /** - * Optional. - * @deprecated This argument is ignored. - */ + /** + * Optional. + * @deprecated This argument is ignored. + */ iconIndex?: number; - /** - * Optional. - * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' - */ + /** + * Optional. + * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' + */ imageData?: ImageData; - /** - * Optional. - * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' - */ + /** + * Optional. + * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' + */ path?: any; } - /** - * Shows the page action. The page action is shown whenever the tab is selected. - * @param tabId The id of the tab for which you want to modify the page action. - */ + /** + * Shows the page action. The page action is shown whenever the tab is selected. + * @param tabId The id of the tab for which you want to modify the page action. + */ export function hide(tabId: number): void; - /** - * Shows the page action. The page action is shown whenever the tab is selected. - * @param tabId The id of the tab for which you want to modify the page action. - */ + /** + * Shows the page action. The page action is shown whenever the tab is selected. + * @param tabId The id of the tab for which you want to modify the page action. + */ export function show(tabId: number): void; - /** Sets the title of the page action. This is displayed in a tooltip over the page action. */ + /** Sets the title of the page action. This is displayed in a tooltip over the page action. */ export function setTitle(details: TitleDetails): void; - /** Sets the html document to be opened as a popup when the user clicks on the page action's icon. */ + /** Sets the html document to be opened as a popup when the user clicks on the page action's icon. */ export function setPopup(details: PopupDetails): void; - /** - * Gets the title of the page action. - * @since Chrome 19. - * @param callback The callback parameter should be a function that looks like this: - * function(string result) {...}; - */ + /** + * Gets the title of the page action. + * @since Chrome 19. + * @param callback The callback parameter should be a function that looks like this: + * function(string result) {...}; + */ export function getTitle(details: GetDetails, callback: (result: string) => void): void; - /** - * Gets the html document set as the popup for this page action. - * @since Chrome 19. - * @param callback The callback parameter should be a function that looks like this: - * function(string result) {...}; - */ + /** + * Gets the html document set as the popup for this page action. + * @since Chrome 19. + * @param callback The callback parameter should be a function that looks like this: + * function(string result) {...}; + */ export function getPopup(details: GetDetails, callback: (result: string) => void): void; - /** - * Sets the icon for the page action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function() {...}; - */ - export function setIcon(details: IconDetails, callback?: () => void): void; + /** + * Sets the icon for the page action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function() {...}; + */ + export function setIcon(details: IconDetails, callback?: () => void): void; - /** Fired when a page action icon is clicked. This event will not fire if the page action has a popup. */ + /** Fired when a page action icon is clicked. This event will not fire if the page action has a popup. */ var onClicked: PageActionClickedEvent; } @@ -4476,17 +4476,17 @@ declare namespace chrome.pageAction { */ declare namespace chrome.pageCapture { interface SaveDetails { - /** The id of the tab to save as MHTML. */ + /** The id of the tab to save as MHTML. */ tabId: number; } - /** - * Saves the content of the tab with given id as MHTML. - * @param callback Called when the MHTML has been generated. - * The callback parameter should be a function that looks like this: - * function(binary mhtmlData) {...}; - * Parameter mhtmlData: The MHTML data as a Blob. - */ + /** + * Saves the content of the tab with given id as MHTML. + * @param callback Called when the MHTML has been generated. + * The callback parameter should be a function that looks like this: + * function(binary mhtmlData) {...}; + * Parameter mhtmlData: The MHTML data as a Blob. + */ export function saveAsMHTML(details: SaveDetails, callback: (mhtmlData: any) => void): void; } @@ -4499,68 +4499,68 @@ declare namespace chrome.pageCapture { */ declare namespace chrome.permissions { interface Permissions { - /** - * Optional. - * List of named permissions (does not include hosts or origins). Anything listed here must appear in the optional_permissions list in the manifest. - */ + /** + * Optional. + * List of named permissions (does not include hosts or origins). Anything listed here must appear in the optional_permissions list in the manifest. + */ origins?: string[]; - /** - * Optional. - * List of origin permissions. Anything listed here must be a subset of a host that appears in the optional_permissions list in the manifest. For example, if http://*.example.com/ or http://* appears in optional_permissions, you can request an origin of http://help.example.com/. Any path is ignored. - */ + /** + * Optional. + * List of origin permissions. Anything listed here must be a subset of a host that appears in the optional_permissions list in the manifest. For example, if http://*.example.com/ or http://* appears in optional_permissions, you can request an origin of http://help.example.com/. Any path is ignored. + */ permissions?: string[]; } interface PermissionsRemovedEvent { - /** - * @param callback The callback parameter should be a function that looks like this: - * function( Permissions permissions) {...}; - * Parameter permissions: The permissions that have been removed. - */ + /** + * @param callback The callback parameter should be a function that looks like this: + * function( Permissions permissions) {...}; + * Parameter permissions: The permissions that have been removed. + */ addListener(callback: (permissions: Permissions) => void): void; } interface PermissionsAddedEvent { - /** - * @param callback The callback parameter should be a function that looks like this: - * function( Permissions permissions) {...}; - * Parameter permissions: The newly acquired permissions. - */ + /** + * @param callback The callback parameter should be a function that looks like this: + * function( Permissions permissions) {...}; + * Parameter permissions: The newly acquired permissions. + */ addListener(callback: (permissions: Permissions) => void): void; } - /** - * Checks if the extension has the specified permissions. - * @param callback The callback parameter should be a function that looks like this: - * function(boolean result) {...}; - * Parameter result: True if the extension has the specified permissions. - */ + /** + * Checks if the extension has the specified permissions. + * @param callback The callback parameter should be a function that looks like this: + * function(boolean result) {...}; + * Parameter result: True if the extension has the specified permissions. + */ export function contains(permissions: Permissions, callback: (result: boolean) => void): void; - /** - * Gets the extension's current set of permissions. - * @param callback The callback parameter should be a function that looks like this: - * function( Permissions permissions) {...}; - * Parameter permissions: The extension's active permissions. - */ + /** + * Gets the extension's current set of permissions. + * @param callback The callback parameter should be a function that looks like this: + * function( Permissions permissions) {...}; + * Parameter permissions: The extension's active permissions. + */ export function getAll(callback: (permissions: Permissions) => void): void; - /** - * Requests access to the specified permissions. These permissions must be defined in the optional_permissions field of the manifest. If there are any problems requesting the permissions, runtime.lastError will be set. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean granted) {...}; - * Parameter granted: True if the user granted the specified permissions. - */ + /** + * Requests access to the specified permissions. These permissions must be defined in the optional_permissions field of the manifest. If there are any problems requesting the permissions, runtime.lastError will be set. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(boolean granted) {...}; + * Parameter granted: True if the user granted the specified permissions. + */ export function request(permissions: Permissions, callback?: (granted: boolean) => void): void; - /** - * Removes access to the specified permissions. If there are any problems removing the permissions, runtime.lastError will be set. - * @param callback If you specify the callback parameter, it should be a function that looks like this: - * function(boolean removed) {...}; - * Parameter removed: True if the permissions were removed. - */ + /** + * Removes access to the specified permissions. If there are any problems removing the permissions, runtime.lastError will be set. + * @param callback If you specify the callback parameter, it should be a function that looks like this: + * function(boolean removed) {...}; + * Parameter removed: True if the permissions were removed. + */ export function remove(permissions: Permissions, callback?: (removed: boolean) => void): void; - /** Fired when access to permissions has been removed from the extension. */ + /** Fired when access to permissions has been removed from the extension. */ var onRemoved: PermissionsRemovedEvent; - /** Fired when the extension acquires new permissions. */ + /** Fired when the extension acquires new permissions. */ var onAdded: PermissionsAddedEvent; } @@ -4574,74 +4574,74 @@ declare namespace chrome.permissions { * @since Chrome 45. */ declare namespace chrome.platformKeys { - interface Match { - /** The DER encoding of a X.509 certificate. */ - certificate: ArrayBuffer; - /** The KeyAlgorithm of the certified key. This contains algorithm parameters that are inherent to the key of the certificate (e.g. the key length). Other parameters like the hash function used by the sign function are not included. */ - keyAlgorithm: KeyAlgorithm; - } + interface Match { + /** The DER encoding of a X.509 certificate. */ + certificate: ArrayBuffer; + /** The KeyAlgorithm of the certified key. This contains algorithm parameters that are inherent to the key of the certificate (e.g. the key length). Other parameters like the hash function used by the sign function are not included. */ + keyAlgorithm: KeyAlgorithm; + } - interface ClientCertificateSelectRequestDetails { - /** This field is a list of the types of certificates requested, sorted in order of the server's preference. Only certificates of a type contained in this list will be retrieved. If certificateTypes is the empty list, however, certificates of any type will be returned. */ - certificateTypes: string[]; - /** List of distinguished names of certificate authorities allowed by the server. Each entry must be a DER-encoded X.509 DistinguishedName. */ - certificateAuthorities: ArrayBuffer[]; - } + interface ClientCertificateSelectRequestDetails { + /** This field is a list of the types of certificates requested, sorted in order of the server's preference. Only certificates of a type contained in this list will be retrieved. If certificateTypes is the empty list, however, certificates of any type will be returned. */ + certificateTypes: string[]; + /** List of distinguished names of certificate authorities allowed by the server. Each entry must be a DER-encoded X.509 DistinguishedName. */ + certificateAuthorities: ArrayBuffer[]; + } - interface ClientCertificateSelectDetails { - /** Only certificates that match this request will be returned. */ - request: ClientCertificateSelectRequestDetails; - /** - * Optional. - * If given, the selectClientCertificates operates on this list. Otherwise, obtains the list of all certificates from the platform's certificate stores that are available to this extensions. Entries that the extension doesn't have permission for or which doesn't match the request, are removed. - */ - clientCerts?: ArrayBuffer[]; - /** If true, the filtered list is presented to the user to manually select a certificate and thereby granting the extension access to the certificate(s) and key(s). Only the selected certificate(s) will be returned. If is false, the list is reduced to all certificates that the extension has been granted access to (automatically or manually). */ - interactive: boolean; - } + interface ClientCertificateSelectDetails { + /** Only certificates that match this request will be returned. */ + request: ClientCertificateSelectRequestDetails; + /** + * Optional. + * If given, the selectClientCertificates operates on this list. Otherwise, obtains the list of all certificates from the platform's certificate stores that are available to this extensions. Entries that the extension doesn't have permission for or which doesn't match the request, are removed. + */ + clientCerts?: ArrayBuffer[]; + /** If true, the filtered list is presented to the user to manually select a certificate and thereby granting the extension access to the certificate(s) and key(s). Only the selected certificate(s) will be returned. If is false, the list is reduced to all certificates that the extension has been granted access to (automatically or manually). */ + interactive: boolean; + } - interface ServerCertificateVerificationDetails { - /** Each chain entry must be the DER encoding of a X.509 certificate, the first entry must be the server certificate and each entry must certify the entry preceding it. */ - serverCertificateChain: ArrayBuffer[]; - /** The hostname of the server to verify the certificate for, e.g. the server that presented the serverCertificateChain. */ - hostname: string; - } + interface ServerCertificateVerificationDetails { + /** Each chain entry must be the DER encoding of a X.509 certificate, the first entry must be the server certificate and each entry must certify the entry preceding it. */ + serverCertificateChain: ArrayBuffer[]; + /** The hostname of the server to verify the certificate for, e.g. the server that presented the serverCertificateChain. */ + hostname: string; + } - interface ServerCertificateVerificationResult { - /** The result of the trust verification: true if trust for the given verification details could be established and false if trust is rejected for any reason. */ - trusted: boolean; - /** - * If the trust verification failed, this array contains the errors reported by the underlying network layer. Otherwise, this array is empty. - * Note: This list is meant for debugging only and may not contain all relevant errors. The errors returned may change in future revisions of this API, and are not guaranteed to be forwards or backwards compatible. - */ - debug_errors: string[]; - } + interface ServerCertificateVerificationResult { + /** The result of the trust verification: true if trust for the given verification details could be established and false if trust is rejected for any reason. */ + trusted: boolean; + /** + * If the trust verification failed, this array contains the errors reported by the underlying network layer. Otherwise, this array is empty. + * Note: This list is meant for debugging only and may not contain all relevant errors. The errors returned may change in future revisions of this API, and are not guaranteed to be forwards or backwards compatible. + */ + debug_errors: string[]; + } - /** - * This function filters from a list of client certificates the ones that are known to the platform, match request and for which the extension has permission to access the certificate and its private key. If interactive is true, the user is presented a dialog where he can select from matching certificates and grant the extension access to the certificate. The selected/filtered client certificates will be passed to callback. - * @param callback The callback parameter should be a function that looks like this: - * function(array of Match matches) {...}; - * Parameter matches: The list of certificates that match the request, that the extension has permission for and, if interactive is true, that were selected by the user. - */ - export function selectClientCertificates(details: ClientCertificateSelectDetails, callback: (matches: Match[]) => void): void; - /** - * Passes the key pair of certificate for usage with platformKeys.subtleCrypto to callback. - * @param certificate The certificate of a Match returned by selectClientCertificates. - * @param parameters Determines signature/hash algorithm parameters additionally to the parameters fixed by the key itself. The same parameters are accepted as by WebCrypto's importKey function, e.g. RsaHashedImportParams for a RSASSA-PKCS1-v1_5 key. For RSASSA-PKCS1-v1_5 keys, additionally the parameters { 'hash': { 'name': 'none' } } are supported. The sign function will then apply PKCS#1 v1.5 padding and but not hash the given data. - * @param callback The public and private CryptoKey of a certificate which can only be used with platformKeys.subtleCrypto. - * The callback parameter should be a function that looks like this: - * function(object publicKey, object privateKey) {...}; - * Optional parameter privateKey: Might be null if this extension does not have access to it. - */ - export function getKeyPair(certificate: ArrayBuffer, parameters: Object, callback: (publicKey: CryptoKey, privateKey: CryptoKey | null) => void): void; - /** An implementation of WebCrypto's SubtleCrypto that allows crypto operations on keys of client certificates that are available to this extension. */ - export function subtleCrypto(): SubtleCrypto; - /** - * Checks whether details.serverCertificateChain can be trusted for details.hostname according to the trust settings of the platform. Note: The actual behavior of the trust verification is not fully specified and might change in the future. The API implementation verifies certificate expiration, validates the certification path and checks trust by a known CA. The implementation is supposed to respect the EKU serverAuth and to support subject alternative names. - * @param callback The callback parameter should be a function that looks like this: - * function(object result) {...}; - */ - export function verifyTLSServerCertificate(details: ServerCertificateVerificationDetails, callback: (result: ServerCertificateVerificationResult) => void): void; + /** + * This function filters from a list of client certificates the ones that are known to the platform, match request and for which the extension has permission to access the certificate and its private key. If interactive is true, the user is presented a dialog where he can select from matching certificates and grant the extension access to the certificate. The selected/filtered client certificates will be passed to callback. + * @param callback The callback parameter should be a function that looks like this: + * function(array of Match matches) {...}; + * Parameter matches: The list of certificates that match the request, that the extension has permission for and, if interactive is true, that were selected by the user. + */ + export function selectClientCertificates(details: ClientCertificateSelectDetails, callback: (matches: Match[]) => void): void; + /** + * Passes the key pair of certificate for usage with platformKeys.subtleCrypto to callback. + * @param certificate The certificate of a Match returned by selectClientCertificates. + * @param parameters Determines signature/hash algorithm parameters additionally to the parameters fixed by the key itself. The same parameters are accepted as by WebCrypto's importKey function, e.g. RsaHashedImportParams for a RSASSA-PKCS1-v1_5 key. For RSASSA-PKCS1-v1_5 keys, additionally the parameters { 'hash': { 'name': 'none' } } are supported. The sign function will then apply PKCS#1 v1.5 padding and but not hash the given data. + * @param callback The public and private CryptoKey of a certificate which can only be used with platformKeys.subtleCrypto. + * The callback parameter should be a function that looks like this: + * function(object publicKey, object privateKey) {...}; + * Optional parameter privateKey: Might be null if this extension does not have access to it. + */ + export function getKeyPair(certificate: ArrayBuffer, parameters: Object, callback: (publicKey: CryptoKey, privateKey: CryptoKey | null) => void): void; + /** An implementation of WebCrypto's SubtleCrypto that allows crypto operations on keys of client certificates that are available to this extension. */ + export function subtleCrypto(): SubtleCrypto; + /** + * Checks whether details.serverCertificateChain can be trusted for details.hostname according to the trust settings of the platform. Note: The actual behavior of the trust verification is not fully specified and might change in the future. The API implementation verifies certificate expiration, validates the certification path and checks trust by a known CA. The implementation is supposed to respect the EKU serverAuth and to support subject alternative names. + * @param callback The callback parameter should be a function that looks like this: + * function(object result) {...}; + */ + export function verifyTLSServerCertificate(details: ServerCertificateVerificationDetails, callback: (result: ServerCertificateVerificationResult) => void): void; } //////////////////// @@ -4653,10 +4653,10 @@ declare namespace chrome.platformKeys { * @since Chrome 27. */ declare namespace chrome.power { - /** Requests that power management be temporarily disabled. |level| describes the degree to which power management should be disabled. If a request previously made by the same app is still active, it will be replaced by the new request. */ - export function requestKeepAwake(level: string): void; - /** Releases a request previously made via requestKeepAwake(). */ - export function releaseKeepAwake(): void; + /** Requests that power management be temporarily disabled. |level| describes the degree to which power management should be disabled. If a request previously made by the same app is still active, it will be replaced by the new request. */ + export function requestKeepAwake(level: string): void; + /** Releases a request previously made via requestKeepAwake(). */ + export function releaseKeepAwake(): void; } //////////////////// @@ -4668,53 +4668,53 @@ declare namespace chrome.power { * @since Chrome 44. */ declare namespace chrome.printerProvider { - interface PrinterInfo { - /** Unique printer ID. */ - id: string; - /** Printer's human readable name. */ - name: string; - /** Optional. Printer's human readable description. */ - description?: string; - } + interface PrinterInfo { + /** Unique printer ID. */ + id: string; + /** Printer's human readable name. */ + name: string; + /** Optional. Printer's human readable description. */ + description?: string; + } - interface PrinterCapabilities { - /** Device capabilities in CDD format. */ - capabilities: any; - } + interface PrinterCapabilities { + /** Device capabilities in CDD format. */ + capabilities: any; + } - interface PrintJob { - /** ID of the printer which should handle the job. */ - printerId: string; - /** The print job title. */ - title: string; - /** Print ticket in CJT format. */ - ticket: Object; - /** The document content type. Supported formats are "application/pdf" and "image/pwg-raster". */ - contentType: string; - /** Blob containing the document data to print. Format must match |contentType|. */ - document: Blob; - } + interface PrintJob { + /** ID of the printer which should handle the job. */ + printerId: string; + /** The print job title. */ + title: string; + /** Print ticket in CJT format. */ + ticket: Object; + /** The document content type. Supported formats are "application/pdf" and "image/pwg-raster". */ + contentType: string; + /** Blob containing the document data to print. Format must match |contentType|. */ + document: Blob; + } - interface PrinterRequestedEvent extends chrome.events.Event<(resultCallback: (printerInfo: PrinterInfo[]) => void) => void> {} + interface PrinterRequestedEvent extends chrome.events.Event<(resultCallback: (printerInfo: PrinterInfo[]) => void) => void> {} - interface PrinterInfoRequestedEvent extends chrome.events.Event<(device: any, resultCallback: (printerInfo?: PrinterInfo) => void) => void> {} + interface PrinterInfoRequestedEvent extends chrome.events.Event<(device: any, resultCallback: (printerInfo?: PrinterInfo) => void) => void> {} - interface CapabilityRequestedEvent extends chrome.events.Event<(printerId: string, resultCallback: (capabilities: PrinterCapabilities) => void) => void> {} + interface CapabilityRequestedEvent extends chrome.events.Event<(printerId: string, resultCallback: (capabilities: PrinterCapabilities) => void) => void> {} - interface PrintRequestedEvent extends chrome.events.Event<(printJob: PrintJob, resultCallback: (result: string) => void) => void> {} + interface PrintRequestedEvent extends chrome.events.Event<(printJob: PrintJob, resultCallback: (result: string) => void) => void> {} - /** Event fired when print manager requests printers provided by extensions. */ - export var onGetPrintersRequested: PrinterRequestedEvent; - /** - * Event fired when print manager requests information about a USB device that may be a printer. - * Note: An application should not rely on this event being fired more than once per device. If a connected device is supported it should be returned in the onGetPrintersRequested event. - * @since Chrome 45. - */ - export var onGetUsbPrinterInfoRequested: PrinterInfoRequestedEvent; - /** Event fired when print manager requests printer capabilities. */ - export var onGetCapabilityRequested: CapabilityRequestedEvent; - /** Event fired when print manager requests printing. */ - export var onPrintRequested: PrintRequestedEvent; + /** Event fired when print manager requests printers provided by extensions. */ + export var onGetPrintersRequested: PrinterRequestedEvent; + /** + * Event fired when print manager requests information about a USB device that may be a printer. + * Note: An application should not rely on this event being fired more than once per device. If a connected device is supported it should be returned in the onGetPrintersRequested event. + * @since Chrome 45. + */ + export var onGetUsbPrinterInfoRequested: PrinterInfoRequestedEvent; + /** Event fired when print manager requests printer capabilities. */ + export var onGetCapabilityRequested: CapabilityRequestedEvent; + /** Event fired when print manager requests printing. */ + export var onPrintRequested: PrintRequestedEvent; } //////////////////// @@ -4728,7 +4728,7 @@ declare namespace chrome.printerProvider { */ declare namespace chrome.privacy { interface Services { - /** since Chrome 20. */ + /** since Chrome 20. */ spellingServiceEnabled: chrome.types.ChromeSetting; searchSuggestEnabled: chrome.types.ChromeSetting; instantEnabled: chrome.types.ChromeSetting; @@ -4736,35 +4736,35 @@ declare namespace chrome.privacy { safeBrowsingEnabled: chrome.types.ChromeSetting; autofillEnabled: chrome.types.ChromeSetting; translationServiceEnabled: chrome.types.ChromeSetting; - /** @since Chrome 38. */ - passwordSavingEnabled: chrome.types.ChromeSetting; - /** @since Chrome 42. */ - hotwordSearchEnabled: chrome.types.ChromeSetting; - /** @since Chrome 42. */ - safeBrowsingExtendedReportingEnabled: chrome.types.ChromeSetting; + /** @since Chrome 38. */ + passwordSavingEnabled: chrome.types.ChromeSetting; + /** @since Chrome 42. */ + hotwordSearchEnabled: chrome.types.ChromeSetting; + /** @since Chrome 42. */ + safeBrowsingExtendedReportingEnabled: chrome.types.ChromeSetting; } interface Network { networkPredictionEnabled: chrome.types.ChromeSetting; - /** @since Chrome 42. */ - webRTCMultipleRoutesEnabled: chrome.types.ChromeSetting; - /** @since Chrome 47. Warning: this is the current Dev channel. */ - webRTCNonProxiedUdpEnabled: chrome.types.ChromeSetting; + /** @since Chrome 42. */ + webRTCMultipleRoutesEnabled: chrome.types.ChromeSetting; + /** @since Chrome 47. Warning: this is the current Dev channel. */ + webRTCNonProxiedUdpEnabled: chrome.types.ChromeSetting; } interface Websites { thirdPartyCookiesAllowed: chrome.types.ChromeSetting; referrersEnabled: chrome.types.ChromeSetting; hyperlinkAuditingEnabled: chrome.types.ChromeSetting; - /** @since Chrome 21. */ + /** @since Chrome 21. */ protectedContentEnabled: chrome.types.ChromeSetting; } - /** Settings that enable or disable features that require third-party network services provided by Google and your default search provider. */ + /** Settings that enable or disable features that require third-party network services provided by Google and your default search provider. */ var services: Services; - /** Settings that influence Chrome's handling of network connections in general. */ + /** Settings that influence Chrome's handling of network connections in general. */ var network: Network; - /** Settings that determine what information Chrome makes available to websites. */ + /** Settings that determine what information Chrome makes available to websites. */ var websites: Websites; } @@ -4820,7 +4820,7 @@ declare namespace chrome.proxy { /** Optional. The proxy server to be used for HTTP requests. */ proxyForHttp?: ProxyServer; /** Optional. The proxy server to be used for everthing else or if any of the specific proxyFor... is not specified. */ - fallbackProxy?: ProxyServer; + fallbackProxy?: ProxyServer; /** Optional. The proxy server to be used for all per-URL requests (that is http, https, and ftp). */ singleProxy?: ProxyServer; /** Optional. The proxy server to be used for HTTPS requests. */ @@ -4868,22 +4868,22 @@ declare namespace chrome.runtime { } interface InstalledDetails { - /** - * The reason that this event is being dispatched. - * One of: "install", "update", "chrome_update", or "shared_module_update" - */ + /** + * The reason that this event is being dispatched. + * One of: "install", "update", "chrome_update", or "shared_module_update" + */ reason: string; - /** - * Optional. - * Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'. - */ + /** + * Optional. + * Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'. + */ previousVersion?: string; - /** - * Optional. - * Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'. - * @since Chrome 29. - */ - id?: string; + /** + * Optional. + * Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'. + * @since Chrome 29. + */ + id?: string; } interface MessageOptions { @@ -4959,7 +4959,7 @@ declare namespace chrome.runtime { } interface UpdateAvailableDetails { - /** The version number of the available update. */ + /** The version number of the available update. */ version: string; } @@ -4968,7 +4968,7 @@ declare namespace chrome.runtime { version: string; } - interface PortDisconnectEvent extends chrome.events.Event<(port: Port) => void> {} + interface PortDisconnectEvent extends chrome.events.Event<(port: Port) => void> {} interface PortMessageEvent extends chrome.events.Event<(message: Object, port: Port) => void> {} @@ -4978,225 +4978,225 @@ declare namespace chrome.runtime { interface RuntimeInstalledEvent extends chrome.events.Event<(details: InstalledDetails) => void> {} - interface RuntimeEvent extends chrome.events.Event<() => void> {} + interface RuntimeEvent extends chrome.events.Event<() => void> {} interface RuntimeRestartRequiredEvent extends chrome.events.Event<(reason: string) => void> {} interface RuntimeUpdateAvailableEvent extends chrome.events.Event<(details: UpdateAvailableDetails) => void> {} - interface ManifestIcons { - [size: number]: string; - } + interface ManifestIcons { + [size: number]: string; + } - interface ManifestAction { - default_icon?: ManifestIcons; - default_title?: string; - default_popup?: string; - } + interface ManifestAction { + default_icon?: ManifestIcons; + default_title?: string; + default_popup?: string; + } - interface SearchProvider { - name?: string; - keyword?: string; - favicon_url?: string; - search_url: string; - encoding?: string; - suggest_url?: string; - instant_url?: string; - image_url?: string; - search_url_post_params?: string; - suggest_url_post_params?: string; - instant_url_post_params?: string; - image_url_post_params?: string; - alternate_urls?: string[]; - prepopulated_id?: number; - is_default?: boolean; - } + interface SearchProvider { + name?: string; + keyword?: string; + favicon_url?: string; + search_url: string; + encoding?: string; + suggest_url?: string; + instant_url?: string; + image_url?: string; + search_url_post_params?: string; + suggest_url_post_params?: string; + instant_url_post_params?: string; + image_url_post_params?: string; + alternate_urls?: string[]; + prepopulated_id?: number; + is_default?: boolean; + } - interface Manifest { - // Required - manifest_version: number; - name: string; - version: string; + interface Manifest { + // Required + manifest_version: number; + name: string; + version: string; - // Recommended - default_locale?: string; - description?: string; - icons?: ManifestIcons; + // Recommended + default_locale?: string; + description?: string; + icons?: ManifestIcons; - // Pick one (or none) - browser_action?: ManifestAction; - page_action?: ManifestAction; + // Pick one (or none) + browser_action?: ManifestAction; + page_action?: ManifestAction; - // Optional - author?: any; - automation?: any; - background?: { - scripts?: string[]; - page?: string; - persistent?: boolean; - }; - background_page?: string; - chrome_settings_overrides?: { - homepage?: string; - search_provider?: SearchProvider; - startup_pages?: string[]; - }; - chrome_ui_overrides?: { - bookmarks_ui?: { - remove_bookmark_shortcut?: boolean; - remove_button?: boolean; - } - }; - chrome_url_overrides?: { - bookmarks?: string; - history?: string; - newtab?: string; - }; - commands?: { - [name: string]: { - suggested_key?: { + // Optional + author?: any; + automation?: any; + background?: { + scripts?: string[]; + page?: string; + persistent?: boolean; + }; + background_page?: string; + chrome_settings_overrides?: { + homepage?: string; + search_provider?: SearchProvider; + startup_pages?: string[]; + }; + chrome_ui_overrides?: { + bookmarks_ui?: { + remove_bookmark_shortcut?: boolean; + remove_button?: boolean; + } + }; + chrome_url_overrides?: { + bookmarks?: string; + history?: string; + newtab?: string; + }; + commands?: { + [name: string]: { + suggested_key?: { default?: string; - windows?: string; - mac?: string; - chromeos?: string; - linux?: string; - }; - description?: string; - global?: boolean - } - }; - content_capabilities?: { - matches?: string[]; - permissions?: string[]; - }; - content_scripts?: { - matches?: string[]; - exclude_matches?: string[]; - css?: string[]; - js?: string[]; - run_at?: string; - all_frames?: boolean; - include_globs?: string[]; - exclude_globs?: string[]; - }[]; - content_security_policy?: string; - converted_from_user_script?: boolean; - copresence?: any; - current_locale?: string; - devtools_page?: string; - event_rules?: { - event?: string; - actions?: { - type: string; - }[]; + windows?: string; + mac?: string; + chromeos?: string; + linux?: string; + }; + description?: string; + global?: boolean + } + }; + content_capabilities?: { + matches?: string[]; + permissions?: string[]; + }; + content_scripts?: { + matches?: string[]; + exclude_matches?: string[]; + css?: string[]; + js?: string[]; + run_at?: string; + all_frames?: boolean; + include_globs?: string[]; + exclude_globs?: string[]; + }[]; + content_security_policy?: string; + converted_from_user_script?: boolean; + copresence?: any; + current_locale?: string; + devtools_page?: string; + event_rules?: { + event?: string; + actions?: { + type: string; + }[]; conditions?: chrome.declarativeContent.PageStateMatcher[] - }[]; - externally_connectable?: { + }[]; + externally_connectable?: { ids?: string[]; - matches?: string[]; + matches?: string[]; accepts_tls_channel_id?: boolean; - }; - file_browser_handlers?: { - id?: string; - default_title?: string; - file_filters?: string[]; - }[]; - file_system_provider_capabilities?: { - configurable?: boolean; - watchable?: boolean; - multiple_mounts?: boolean; - source?: string; - }; - homepage_url?: string; - import?: { - id: string; - minimum_version?: string - }[]; - export?: { - whitelist?: string[] - }; - incognito?: string; - input_components?: { - name?: string; - type?: string; - id?: string; - description?: string; - language?: string; - layouts?: any[]; - }[]; - key?: string; - minimum_chrome_version?: string; - nacl_modules?: { - path: string; - mime_type: string; - }[]; - oauth2?: { - client_id: string; - scopes?: string[]; - }; - offline_enabled?: boolean; - omnibox?: { - keyword: string; - }; - optional_permissions?: string[]; - options_page?: string; - options_ui?: { - page?: string; - chrome_style?: boolean; - open_in_tab?: boolean; - }; - permissions?: string[]; - platforms?: { - nacl_arch?: string; - sub_package_path: string; - }[]; - plugins?: { - path: string; - }[]; - requirements?: { - '3D'?: { - features?: string[] - }; - plugins?: { - npapi?: boolean; - } - }; - sandbox?: { - pages: string[]; - content_security_policy?: string; - }; - short_name?: string; - signature?: any; - spellcheck?: { - dictionary_language?: string; - dictionary_locale?: string; - dictionary_format?: string; - dictionary_path?: string; - }; - storage?: { - managed_schema: string - }; - system_indicator?: any; - tts_engine?: { - voices: { - voice_name: string; - lang?: string; - gender?: string; - event_types?: string[]; - }[] - }; - update_url?: string; - version_name?: string; - web_accessible_resources?: string[]; - [key: string]: any; - } + }; + file_browser_handlers?: { + id?: string; + default_title?: string; + file_filters?: string[]; + }[]; + file_system_provider_capabilities?: { + configurable?: boolean; + watchable?: boolean; + multiple_mounts?: boolean; + source?: string; + }; + homepage_url?: string; + import?: { + id: string; + minimum_version?: string + }[]; + export?: { + whitelist?: string[] + }; + incognito?: string; + input_components?: { + name?: string; + type?: string; + id?: string; + description?: string; + language?: string; + layouts?: any[]; + }[]; + key?: string; + minimum_chrome_version?: string; + nacl_modules?: { + path: string; + mime_type: string; + }[]; + oauth2?: { + client_id: string; + scopes?: string[]; + }; + offline_enabled?: boolean; + omnibox?: { + keyword: string; + }; + optional_permissions?: string[]; + options_page?: string; + options_ui?: { + page?: string; + chrome_style?: boolean; + open_in_tab?: boolean; + }; + permissions?: string[]; + platforms?: { + nacl_arch?: string; + sub_package_path: string; + }[]; + plugins?: { + path: string; + }[]; + requirements?: { + '3D'?: { + features?: string[] + }; + plugins?: { + npapi?: boolean; + } + }; + sandbox?: { + pages: string[]; + content_security_policy?: string; + }; + short_name?: string; + signature?: any; + spellcheck?: { + dictionary_language?: string; + dictionary_locale?: string; + dictionary_format?: string; + dictionary_path?: string; + }; + storage?: { + managed_schema: string + }; + system_indicator?: any; + tts_engine?: { + voices: { + voice_name: string; + lang?: string; + gender?: string; + event_types?: string[]; + }[] + }; + update_url?: string; + version_name?: string; + web_accessible_resources?: string[]; + [key: string]: any; + } /** * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via tabs.connect. * @since Chrome 26. */ export function connect(connectInfo?: ConnectInfo): Port; - /** + /** * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via tabs.connect. * @since Chrome 26. * @param extensionId Optional. @@ -5220,7 +5220,7 @@ declare namespace chrome.runtime { * Returns a DirectoryEntry for the package directory. * @since Chrome 29. */ - export function getPackageDirectoryEntry(callback: (directoryEntry: DirectoryEntry) => void): void; + export function getPackageDirectoryEntry(callback: (directoryEntry: DirectoryEntry) => void): void; /** * Returns information about the current platform. * @since Chrome 29. @@ -5250,21 +5250,21 @@ declare namespace chrome.runtime { * @since Chrome 32. */ export function restart(): void; - /** + /** * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage. * @since Chrome 26. * @param responseCallback Optional * Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. */ export function sendMessage(message: any, responseCallback?: (response: any) => void): void; - /** + /** * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage. * @since Chrome 32. * @param responseCallback Optional * Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message. */ export function sendMessage(message: any, options: MessageOptions, responseCallback?: (response: any) => void): void; - /** + /** * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage. * @since Chrome 26. * @param extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging. @@ -5288,7 +5288,7 @@ declare namespace chrome.runtime { * @param responseCallback Optional. * Parameter response: The response message sent by the native messaging host. If an error occurs while connecting to the native messaging host, the callback will be called with no arguments and runtime.lastError will be set to the error message. */ - export function sendNativeMessage(application: string, message: Object, responseCallback?: (response: any) => void): void; + export function sendNativeMessage(application: string, message: Object, responseCallback?: (response: any) => void): void; /** * Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics, and implement surveys. Maximum 255 characters. * @since Chrome 41. @@ -5296,7 +5296,7 @@ declare namespace chrome.runtime { * URL to be opened after the extension is uninstalled. This URL must have an http: or https: scheme. Set an empty string to not open a new tab upon uninstallation. * @param callback Called when the uninstall URL is set. If the given URL is invalid, runtime.lastError will be set. */ - export function setUninstallURL(url: string, callback?: () => void): void; + export function setUninstallURL(url: string, callback?: () => void): void; /** * Open your Extension's options page, if possible. * The precise behavior may depend on your manifest's options_ui or options_page key, or what Chrome happens to support at the time. For example, the page may be opened in a new tab, within chrome://extensions, within an App, or it may just focus an open options page. It will never cause the caller page to reload. @@ -5305,52 +5305,52 @@ declare namespace chrome.runtime { */ export function openOptionsPage(callback?: () => void): void; - /** - * Fired when a connection is made from either an extension process or a content script. - * @since Chrome 26. - */ + /** + * Fired when a connection is made from either an extension process or a content script. + * @since Chrome 26. + */ var onConnect: ExtensionConnectEvent; - /** - * Fired when a connection is made from another extension. - * @since Chrome 26. - */ - var onConnectExternal: ExtensionConnectEvent; - /** Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded. */ - var onSuspend: RuntimeEvent; - /** - * Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode. - * @since Chrome 23. - */ - var onStartup: RuntimeEvent; - /** Fired when the extension is first installed, when the extension is updated to a new version, and when Chrome is updated to a new version. */ + /** + * Fired when a connection is made from another extension. + * @since Chrome 26. + */ + var onConnectExternal: ExtensionConnectEvent; + /** Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded. */ + var onSuspend: RuntimeEvent; + /** + * Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode. + * @since Chrome 23. + */ + var onStartup: RuntimeEvent; + /** Fired when the extension is first installed, when the extension is updated to a new version, and when Chrome is updated to a new version. */ var onInstalled: RuntimeInstalledEvent; - /** Sent after onSuspend to indicate that the app won't be unloaded after all. */ - var onSuspendCanceled: RuntimeEvent; - /** - * Fired when a message is sent from either an extension process or a content script. - * @since Chrome 26. - */ + /** Sent after onSuspend to indicate that the app won't be unloaded after all. */ + var onSuspendCanceled: RuntimeEvent; + /** + * Fired when a message is sent from either an extension process or a content script. + * @since Chrome 26. + */ var onMessage: ExtensionMessageEvent; - /** - * Fired when a message is sent from another extension/app. Cannot be used in a content script. - * @since Chrome 26. - */ - var onMessageExternal: ExtensionMessageEvent; - /** - * Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps. - * @since Chrome 29. - */ + /** + * Fired when a message is sent from another extension/app. Cannot be used in a content script. + * @since Chrome 26. + */ + var onMessageExternal: ExtensionMessageEvent; + /** + * Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps. + * @since Chrome 29. + */ var onRestartRequired: RuntimeRestartRequiredEvent; - /** - * Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call chrome.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call chrome.runtime.reload() manually in response to this event the update will not get installed until the next time chrome itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if chrome.runtime.reload() is called in response to this event. - * @since Chrome 25. - */ + /** + * Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call chrome.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call chrome.runtime.reload() manually in response to this event the update will not get installed until the next time chrome itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if chrome.runtime.reload() is called in response to this event. + * @since Chrome 25. + */ var onUpdateAvailable: RuntimeUpdateAvailableEvent; - /** - * @deprecated since Chrome 33. Please use chrome.runtime.onRestartRequired. - * Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required. - */ - var onBrowserUpdateAvailable: RuntimeEvent; + /** + * @deprecated since Chrome 33. Please use chrome.runtime.onRestartRequired. + * Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required. + */ + var onBrowserUpdateAvailable: RuntimeEvent; } //////////////////// @@ -5388,76 +5388,76 @@ declare namespace chrome.scriptBadge { * @since Chrome 37. */ declare namespace chrome.sessions { - interface Filter { - /** - * Optional. - * The maximum number of entries to be fetched in the requested list. Omit this parameter to fetch the maximum number of entries (sessions.MAX_SESSION_RESULTS). - */ - maxResults?: number; - } + interface Filter { + /** + * Optional. + * The maximum number of entries to be fetched in the requested list. Omit this parameter to fetch the maximum number of entries (sessions.MAX_SESSION_RESULTS). + */ + maxResults?: number; + } - interface Session { - /** The time when the window or tab was closed or modified, represented in milliseconds since the epoch. */ - lastModified: number; - /** - * Optional. - * The tabs.Tab, if this entry describes a tab. Either this or sessions.Session.window will be set. - */ - tab?: tabs.Tab; - /** - * Optional. - * The windows.Window, if this entry describes a window. Either this or sessions.Session.tab will be set. - */ - window?: windows.Window; - } + interface Session { + /** The time when the window or tab was closed or modified, represented in milliseconds since the epoch. */ + lastModified: number; + /** + * Optional. + * The tabs.Tab, if this entry describes a tab. Either this or sessions.Session.window will be set. + */ + tab?: tabs.Tab; + /** + * Optional. + * The windows.Window, if this entry describes a window. Either this or sessions.Session.tab will be set. + */ + window?: windows.Window; + } - interface Device { - /** The name of the foreign device. */ - deviceName: string; - /** A list of open window sessions for the foreign device, sorted from most recently to least recently modified session. */ - sessions: Session[]; - } + interface Device { + /** The name of the foreign device. */ + deviceName: string; + /** A list of open window sessions for the foreign device, sorted from most recently to least recently modified session. */ + sessions: Session[]; + } - interface SessionChangedEvent extends chrome.events.Event<() => void> {} + interface SessionChangedEvent extends chrome.events.Event<() => void> {} - /** The maximum number of sessions.Session that will be included in a requested list. */ - export var MAX_SESSION_RESULTS: number; + /** The maximum number of sessions.Session that will be included in a requested list. */ + export var MAX_SESSION_RESULTS: number; - /** - * Gets the list of recently closed tabs and/or windows. - * @param callback - * Parameter sessions: The list of closed entries in reverse order that they were closed (the most recently closed tab or window will be at index 0). The entries may contain either tabs or windows. - */ - export function getRecentlyClosed(filter: Filter, callback: (sessions: Session[]) => void): void; - /** - * Gets the list of recently closed tabs and/or windows. - * @param callback - * Parameter sessions: The list of closed entries in reverse order that they were closed (the most recently closed tab or window will be at index 0). The entries may contain either tabs or windows. - */ - export function getRecentlyClosed(callback: (sessions: Session[]) => void): void; - /** - * Retrieves all devices with synced sessions. - * @param callback - * Parameter devices: The list of sessions.Device objects for each synced session, sorted in order from device with most recently modified session to device with least recently modified session. tabs.Tab objects are sorted by recency in the windows.Window of the sessions.Session objects. - */ - export function getDevices(filter: Filter, callback: (devices: Device[]) => void): void; - /** - * Retrieves all devices with synced sessions. - * @param callback - * Parameter devices: The list of sessions.Device objects for each synced session, sorted in order from device with most recently modified session to device with least recently modified session. tabs.Tab objects are sorted by recency in the windows.Window of the sessions.Session objects. - */ - export function getDevices(callback: (devices: Device[]) => void): void; - /** - * Reopens a windows.Window or tabs.Tab, with an optional callback to run when the entry has been restored. - * @param sessionId Optional. - * The windows.Window.sessionId, or tabs.Tab.sessionId to restore. If this parameter is not specified, the most recently closed session is restored. - * @param callback Optional. - * Parameter restoredSession: A sessions.Session containing the restored windows.Window or tabs.Tab object. - */ - export function restore(sessionId?: string, callback?: (restoredSession: Session) => void): void; + /** + * Gets the list of recently closed tabs and/or windows. + * @param callback + * Parameter sessions: The list of closed entries in reverse order that they were closed (the most recently closed tab or window will be at index 0). The entries may contain either tabs or windows. + */ + export function getRecentlyClosed(filter: Filter, callback: (sessions: Session[]) => void): void; + /** + * Gets the list of recently closed tabs and/or windows. + * @param callback + * Parameter sessions: The list of closed entries in reverse order that they were closed (the most recently closed tab or window will be at index 0). The entries may contain either tabs or windows. + */ + export function getRecentlyClosed(callback: (sessions: Session[]) => void): void; + /** + * Retrieves all devices with synced sessions. + * @param callback + * Parameter devices: The list of sessions.Device objects for each synced session, sorted in order from device with most recently modified session to device with least recently modified session. tabs.Tab objects are sorted by recency in the windows.Window of the sessions.Session objects. + */ + export function getDevices(filter: Filter, callback: (devices: Device[]) => void): void; + /** + * Retrieves all devices with synced sessions. + * @param callback + * Parameter devices: The list of sessions.Device objects for each synced session, sorted in order from device with most recently modified session to device with least recently modified session. tabs.Tab objects are sorted by recency in the windows.Window of the sessions.Session objects. + */ + export function getDevices(callback: (devices: Device[]) => void): void; + /** + * Reopens a windows.Window or tabs.Tab, with an optional callback to run when the entry has been restored. + * @param sessionId Optional. + * The windows.Window.sessionId, or tabs.Tab.sessionId to restore. If this parameter is not specified, the most recently closed session is restored. + * @param callback Optional. + * Parameter restoredSession: A sessions.Session containing the restored windows.Window or tabs.Tab object. + */ + export function restore(sessionId?: string, callback?: (restoredSession: Session) => void): void; - /** Fired when recently closed tabs and/or windows are changed. This event does not monitor synced sessions changes. */ - export var onChanged: SessionChangedEvent; + /** Fired when recently closed tabs and/or windows are changed. This event does not monitor synced sessions changes. */ + export var onChanged: SessionChangedEvent; } //////////////////// @@ -5469,113 +5469,113 @@ declare namespace chrome.sessions { * @since Chrome 20. */ declare namespace chrome.storage { - interface StorageArea { - /** - * Gets the amount of space (in bytes) being used by one or more items. - * @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set). - * Parameter bytesInUse: Amount of space being used in storage, in bytes. - */ - getBytesInUse(callback: (bytesInUse: number) => void): void; - /** - * Gets the amount of space (in bytes) being used by one or more items. - * @param keys A single key or list of keys to get the total usage for. An empty list will return 0. Pass in null to get the total usage of all of storage. - * @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set). - * Parameter bytesInUse: Amount of space being used in storage, in bytes. - */ - getBytesInUse(keys: string | string[] | null, callback: (bytesInUse: number) => void): void; - /** - * Removes all items from storage. - * @param callback Optional. - * Callback on success, or on failure (in which case runtime.lastError will be set). - */ - clear(callback?: () => void): void; - /** - * Sets multiple items. - * @param items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected. - * Primitive values such as numbers will serialize as expected. Values with a typeof "object" and "function" will typically serialize to {}, with the exception of Array (serializes as expected), Date, and Regex (serialize using their String representation). - * @param callback Optional. - * Callback on success, or on failure (in which case runtime.lastError will be set). - */ - set(items: Object, callback?: () => void): void; - /** - * Removes one item from storage. - * @param key A single key for items to remove. - * @param callback Optional. - * Callback on success, or on failure (in which case runtime.lastError will be set). - */ - remove(key: string, callback?: () => void): void; - /** - * Removes items from storage. - * @param keys A list of keys for items to remove. - * @param callback Optional. - * Callback on success, or on failure (in which case runtime.lastError will be set). - */ - remove(keys: string[], callback?: () => void): void; - /** - * Gets one or more items from storage. - * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set). - * Parameter items: Object with items in their key-value mappings. - */ - get(callback: (items: { [key: string]: any }) => void): void; - /** - * Gets one or more items from storage. - * @param keys A single key to get, list of keys to get, or a dictionary specifying default values. - * An empty list or object will return an empty result object. Pass in null to get the entire contents of storage. - * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set). - * Parameter items: Object with items in their key-value mappings. - */ - get(keys: string | string[] | Object | null, callback: (items: { [key: string]: any }) => void): void; - } + interface StorageArea { + /** + * Gets the amount of space (in bytes) being used by one or more items. + * @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set). + * Parameter bytesInUse: Amount of space being used in storage, in bytes. + */ + getBytesInUse(callback: (bytesInUse: number) => void): void; + /** + * Gets the amount of space (in bytes) being used by one or more items. + * @param keys A single key or list of keys to get the total usage for. An empty list will return 0. Pass in null to get the total usage of all of storage. + * @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set). + * Parameter bytesInUse: Amount of space being used in storage, in bytes. + */ + getBytesInUse(keys: string | string[] | null, callback: (bytesInUse: number) => void): void; + /** + * Removes all items from storage. + * @param callback Optional. + * Callback on success, or on failure (in which case runtime.lastError will be set). + */ + clear(callback?: () => void): void; + /** + * Sets multiple items. + * @param items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected. + * Primitive values such as numbers will serialize as expected. Values with a typeof "object" and "function" will typically serialize to {}, with the exception of Array (serializes as expected), Date, and Regex (serialize using their String representation). + * @param callback Optional. + * Callback on success, or on failure (in which case runtime.lastError will be set). + */ + set(items: Object, callback?: () => void): void; + /** + * Removes one item from storage. + * @param key A single key for items to remove. + * @param callback Optional. + * Callback on success, or on failure (in which case runtime.lastError will be set). + */ + remove(key: string, callback?: () => void): void; + /** + * Removes items from storage. + * @param keys A list of keys for items to remove. + * @param callback Optional. + * Callback on success, or on failure (in which case runtime.lastError will be set). + */ + remove(keys: string[], callback?: () => void): void; + /** + * Gets one or more items from storage. + * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set). + * Parameter items: Object with items in their key-value mappings. + */ + get(callback: (items: { [key: string]: any }) => void): void; + /** + * Gets one or more items from storage. + * @param keys A single key to get, list of keys to get, or a dictionary specifying default values. + * An empty list or object will return an empty result object. Pass in null to get the entire contents of storage. + * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set). + * Parameter items: Object with items in their key-value mappings. + */ + get(keys: string | string[] | Object | null, callback: (items: { [key: string]: any }) => void): void; + } - interface StorageChange { - /** Optional. The new value of the item, if there is a new value. */ - newValue?: any; - /** Optional. The old value of the item, if there was an old value. */ - oldValue?: any; - } + interface StorageChange { + /** Optional. The new value of the item, if there is a new value. */ + newValue?: any; + /** Optional. The old value of the item, if there was an old value. */ + oldValue?: any; + } - interface LocalStorageArea extends StorageArea { - /** The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the unlimitedStorage permission. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. */ - QUOTA_BYTES: number; - } + interface LocalStorageArea extends StorageArea { + /** The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the unlimitedStorage permission. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. */ + QUOTA_BYTES: number; + } - interface SyncStorageArea extends StorageArea { - /** @deprecated since Chrome 40. The storage.sync API no longer has a sustained write operation quota. */ - MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; - /** The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. */ - QUOTA_BYTES: number; - /** The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError. */ - QUOTA_BYTES_PER_ITEM: number; - /** The maximum number of items that can be stored in sync storage. Updates that would cause this limit to be exceeded will fail immediately and set runtime.lastError. */ - MAX_ITEMS: number; - /** - * The maximum number of set, remove, or clear operations that can be performed each hour. This is 1 every 2 seconds, a lower ceiling than the short term higher writes-per-minute limit. - * Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. - */ - MAX_WRITE_OPERATIONS_PER_HOUR: number; - /** - * The maximum number of set, remove, or clear operations that can be performed each minute. This is 2 per second, providing higher throughput than writes-per-hour over a shorter period of time. - * Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. - * @since Chrome 40. - */ - MAX_WRITE_OPERATIONS_PER_MINUTE: number; - } + interface SyncStorageArea extends StorageArea { + /** @deprecated since Chrome 40. The storage.sync API no longer has a sustained write operation quota. */ + MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; + /** The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. */ + QUOTA_BYTES: number; + /** The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError. */ + QUOTA_BYTES_PER_ITEM: number; + /** The maximum number of items that can be stored in sync storage. Updates that would cause this limit to be exceeded will fail immediately and set runtime.lastError. */ + MAX_ITEMS: number; + /** + * The maximum number of set, remove, or clear operations that can be performed each hour. This is 1 every 2 seconds, a lower ceiling than the short term higher writes-per-minute limit. + * Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. + */ + MAX_WRITE_OPERATIONS_PER_HOUR: number; + /** + * The maximum number of set, remove, or clear operations that can be performed each minute. This is 2 per second, providing higher throughput than writes-per-hour over a shorter period of time. + * Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. + * @since Chrome 40. + */ + MAX_WRITE_OPERATIONS_PER_MINUTE: number; + } - interface StorageChangedEvent extends chrome.events.Event<(changes: { [key: string]: StorageChange }, areaName: string) => void> {} + interface StorageChangedEvent extends chrome.events.Event<(changes: { [key: string]: StorageChange }, areaName: string) => void> {} - /** Items in the local storage area are local to each machine. */ - var local: LocalStorageArea; - /** Items in the sync storage area are synced using Chrome Sync. */ - var sync: SyncStorageArea; + /** Items in the local storage area are local to each machine. */ + var local: LocalStorageArea; + /** Items in the sync storage area are synced using Chrome Sync. */ + var sync: SyncStorageArea; - /** - * Items in the managed storage area are set by the domain administrator, and are read-only for the extension; trying to modify this namespace results in an error. - * @since Chrome 33. - */ - var managed: StorageArea; + /** + * Items in the managed storage area are set by the domain administrator, and are read-only for the extension; trying to modify this namespace results in an error. + * @since Chrome 33. + */ + var managed: StorageArea; - /** Fired when one or more items change. */ - var onChanged: StorageChangedEvent; + /** Fired when one or more items change. */ + var onChanged: StorageChangedEvent; } //////////////////// @@ -5647,40 +5647,40 @@ declare namespace chrome.socket { * @since Chrome 32. */ declare namespace chrome.system.cpu { - interface ProcessorUsage { - /** The cumulative time used by userspace programs on this processor. */ - user: number; - /** The cumulative time used by kernel programs on this processor. */ - kernel: number; - /** The cumulative time spent idle by this processor. */ - idle: number; - /** The total cumulative time for this processor. This value is equal to user + kernel + idle. */ - total: number; - } + interface ProcessorUsage { + /** The cumulative time used by userspace programs on this processor. */ + user: number; + /** The cumulative time used by kernel programs on this processor. */ + kernel: number; + /** The cumulative time spent idle by this processor. */ + idle: number; + /** The total cumulative time for this processor. This value is equal to user + kernel + idle. */ + total: number; + } - interface ProcessorInfo { - /** Cumulative usage info for this logical processor. */ - usage: ProcessorUsage; - } + interface ProcessorInfo { + /** Cumulative usage info for this logical processor. */ + usage: ProcessorUsage; + } - interface CpuInfo { - /** The number of logical processors. */ - numOfProcessors: number; - /** The architecture name of the processors. */ - archName: string; - /** The model name of the processors. */ - modelName: string; - /** - * A set of feature codes indicating some of the processor's capabilities. - * The currently supported codes are "mmx", "sse", "sse2", "sse3", "ssse3", "sse4_1", "sse4_2", and "avx". - */ - features: string[]; - /** Information about each logical processor. */ - processors: ProcessorInfo[]; - } + interface CpuInfo { + /** The number of logical processors. */ + numOfProcessors: number; + /** The architecture name of the processors. */ + archName: string; + /** The model name of the processors. */ + modelName: string; + /** + * A set of feature codes indicating some of the processor's capabilities. + * The currently supported codes are "mmx", "sse", "sse2", "sse3", "ssse3", "sse4_1", "sse4_2", and "avx". + */ + features: string[]; + /** Information about each logical processor. */ + processors: ProcessorInfo[]; + } - /** Queries basic CPU information of the system. */ - export function getInfo(callback: (info: CpuInfo) => void): void; + /** Queries basic CPU information of the system. */ + export function getInfo(callback: (info: CpuInfo) => void): void; } //////////////////// @@ -5692,15 +5692,15 @@ declare namespace chrome.system.cpu { * @since Chrome 32. */ declare namespace chrome.system.memory { - interface MemoryInfo { - /** The total amount of physical memory capacity, in bytes. */ - capacity: number; - /** The amount of available capacity, in bytes. */ - availableCapacity: number; - } + interface MemoryInfo { + /** The total amount of physical memory capacity, in bytes. */ + capacity: number; + /** The amount of available capacity, in bytes. */ + availableCapacity: number; + } - /** Get physical memory information. */ - export function getInfo(callback: (info: MemoryInfo) => void): void; + /** Get physical memory information. */ + export function getInfo(callback: (info: MemoryInfo) => void): void; } //////////////////// @@ -5712,51 +5712,51 @@ declare namespace chrome.system.memory { * @since Chrome 30. */ declare namespace chrome.system.storage { - interface StorageUnitInfo { - /** The transient ID that uniquely identifies the storage device. This ID will be persistent within the same run of a single application. It will not be a persistent identifier between different runs of an application, or between different applications. */ - id: string; - /** The name of the storage unit. */ - name: string; - /** - * The media type of the storage unit. - * fixed: The storage has fixed media, e.g. hard disk or SSD. - * removable: The storage is removable, e.g. USB flash drive. - * unknown: The storage type is unknown. - */ - type: string; - /** The total amount of the storage space, in bytes. */ - capacity: number; - } + interface StorageUnitInfo { + /** The transient ID that uniquely identifies the storage device. This ID will be persistent within the same run of a single application. It will not be a persistent identifier between different runs of an application, or between different applications. */ + id: string; + /** The name of the storage unit. */ + name: string; + /** + * The media type of the storage unit. + * fixed: The storage has fixed media, e.g. hard disk or SSD. + * removable: The storage is removable, e.g. USB flash drive. + * unknown: The storage type is unknown. + */ + type: string; + /** The total amount of the storage space, in bytes. */ + capacity: number; + } - interface StorageCapacityInfo { - /** A copied |id| of getAvailableCapacity function parameter |id|. */ - id: string; - /** The available capacity of the storage device, in bytes. */ - availableCapacity: number; - } + interface StorageCapacityInfo { + /** A copied |id| of getAvailableCapacity function parameter |id|. */ + id: string; + /** The available capacity of the storage device, in bytes. */ + availableCapacity: number; + } - interface SystemStorageAttachedEvent extends chrome.events.Event<(info: StorageUnitInfo) => void> {} + interface SystemStorageAttachedEvent extends chrome.events.Event<(info: StorageUnitInfo) => void> {} - interface SystemStorageDetachedEvent extends chrome.events.Event<(id: string) => void> {} + interface SystemStorageDetachedEvent extends chrome.events.Event<(id: string) => void> {} - /** Get the storage information from the system. The argument passed to the callback is an array of StorageUnitInfo objects. */ - export function getInfo(callback: (info: StorageUnitInfo[]) => void): void; - /** - * Ejects a removable storage device. - * @param callback - * Parameter result: success: The ejection command is successful -- the application can prompt the user to remove the device; in_use: The device is in use by another application. The ejection did not succeed; the user should not remove the device until the other application is done with the device; no_such_device: There is no such device known. failure: The ejection command failed. - */ - export function ejectDevice(id: string, callback: (result: string) => void): void; - /** - * Get the available capacity of a specified |id| storage device. The |id| is the transient device ID from StorageUnitInfo. - * @since Dev channel only. - */ - export function getAvailableCapacity(id: string, callback: (info: StorageCapacityInfo) => void): void; + /** Get the storage information from the system. The argument passed to the callback is an array of StorageUnitInfo objects. */ + export function getInfo(callback: (info: StorageUnitInfo[]) => void): void; + /** + * Ejects a removable storage device. + * @param callback + * Parameter result: success: The ejection command is successful -- the application can prompt the user to remove the device; in_use: The device is in use by another application. The ejection did not succeed; the user should not remove the device until the other application is done with the device; no_such_device: There is no such device known. failure: The ejection command failed. + */ + export function ejectDevice(id: string, callback: (result: string) => void): void; + /** + * Get the available capacity of a specified |id| storage device. The |id| is the transient device ID from StorageUnitInfo. + * @since Dev channel only. + */ + export function getAvailableCapacity(id: string, callback: (info: StorageCapacityInfo) => void): void; - /** Fired when a new removable storage is attached to the system. */ - export var onAttached: SystemStorageAttachedEvent; - /** Fired when a removable storage is detached from the system. */ - export var onDetached: SystemStorageDetachedEvent; + /** Fired when a new removable storage is attached to the system. */ + export var onAttached: SystemStorageAttachedEvent; + /** Fired when a removable storage is detached from the system. */ + export var onDetached: SystemStorageDetachedEvent; } //////////////////// @@ -5769,44 +5769,44 @@ declare namespace chrome.system.storage { */ declare namespace chrome.tabCapture { interface CaptureInfo { - /** The id of the tab whose status changed. */ + /** The id of the tab whose status changed. */ tabId: number; - /** - * The new capture status of the tab. - * One of: "pending", "active", "stopped", or "error" - */ + /** + * The new capture status of the tab. + * One of: "pending", "active", "stopped", or "error" + */ status: string; - /** Whether an element in the tab being captured is in fullscreen mode. */ + /** Whether an element in the tab being captured is in fullscreen mode. */ fullscreen: boolean; } interface CaptureOptions { - /** Optional. */ + /** Optional. */ audio?: boolean; - /** Optional. */ + /** Optional. */ video?: boolean; - /** Optional. */ - audioConstraints?: MediaStreamConstraints; - /** Optional. */ - videoConstraints?: MediaStreamConstraints; - } + /** Optional. */ + audioConstraints?: MediaStreamConstraints; + /** Optional. */ + videoConstraints?: MediaStreamConstraints; + } - interface CaptureStatusChangedEvent extends chrome.events.Event<(info: CaptureInfo) => void> {} + interface CaptureStatusChangedEvent extends chrome.events.Event<(info: CaptureInfo) => void> {} - /** - * Captures the visible area of the currently active tab. Capture can only be started on the currently active tab after the extension has been invoked. Capture is maintained across page navigations within the tab, and stops when the tab is closed, or the media stream is closed by the extension. - * @param options Configures the returned media stream. - * @param callback Callback with either the tab capture stream or null. - */ + /** + * Captures the visible area of the currently active tab. Capture can only be started on the currently active tab after the extension has been invoked. Capture is maintained across page navigations within the tab, and stops when the tab is closed, or the media stream is closed by the extension. + * @param options Configures the returned media stream. + * @param callback Callback with either the tab capture stream or null. + */ export function capture(options: CaptureOptions, callback: (stream: MediaStream | null) => void): void; - /** - * Returns a list of tabs that have requested capture or are being captured, i.e. status != stopped and status != error. This allows extensions to inform the user that there is an existing tab capture that would prevent a new tab capture from succeeding (or to prevent redundant requests for the same tab). - * @param callback Callback invoked with CaptureInfo[] for captured tabs. - */ + /** + * Returns a list of tabs that have requested capture or are being captured, i.e. status != stopped and status != error. This allows extensions to inform the user that there is an existing tab capture that would prevent a new tab capture from succeeding (or to prevent redundant requests for the same tab). + * @param callback Callback invoked with CaptureInfo[] for captured tabs. + */ export function getCapturedTabs(callback: (result: CaptureInfo[]) => void): void; - /** Event fired when the capture status of a tab changes. This allows extension authors to keep track of the capture status of tabs to keep UI elements like page actions in sync. */ - var onStatusChanged: CaptureStatusChangedEvent; + /** Event fired when the capture status of a tab changes. This allows extension authors to keep track of the capture status of tabs to keep UI elements like page actions in sync. */ + var onStatusChanged: CaptureStatusChangedEvent; } //////////////////// @@ -5818,334 +5818,334 @@ declare namespace chrome.tabCapture { * @since Chrome 5. */ declare namespace chrome.tabs { - /** - * Tab muted state and the reason for the last state change. - * @since Chrome 46. Warning: this is the current Beta channel. - */ - interface MutedInfo { - /** Whether the tab is prevented from playing sound (but hasn't necessarily recently produced sound). Equivalent to whether the muted audio indicator is showing. */ - muted: boolean; - /** - * Optional. - * The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed. - * "user": A user input action has set/overridden the muted state. - * "capture": Tab capture started, forcing a muted state change. - * "extension": An extension, identified by the extensionId field, set the muted state. - */ - reason?: string; - /** - * Optional. - * The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed. - */ - extensionId?: string; - } - - interface Tab { - /** - * Optional. - * Either loading or complete. - */ - status?: string; - /** The zero-based index of the tab within its window. */ - index: number; - /** - * Optional. - * The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists. - * @since Chrome 18. - */ - openerTabId?: number; - /** - * Optional. - * The title of the tab. This property is only present if the extension's manifest includes the "tabs" permission. - */ - title?: string; - /** - * Optional. - * The URL the tab is displaying. This property is only present if the extension's manifest includes the "tabs" permission. - */ - url?: string; - /** - * Whether the tab is pinned. - * @since Chrome 9. - */ - pinned: boolean; - /** - * Whether the tab is highlighted. - * @since Chrome 16. - */ - highlighted: boolean; - /** The ID of the window the tab is contained within. */ - windowId: number; - /** - * Whether the tab is active in its window. (Does not necessarily mean the window is focused.) - * @since Chrome 16. - */ - active: boolean; - /** - * Optional. - * The URL of the tab's favicon. This property is only present if the extension's manifest includes the "tabs" permission. It may also be an empty string if the tab is loading. - */ - favIconUrl?: string; - /** - * Optional. - * The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a Tab may not be assigned an ID, for example when querying foreign tabs using the sessions API, in which case a session ID may be present. Tab ID can also be set to chrome.tabs.TAB_ID_NONE for apps and devtools windows. - */ - id?: number; - /** Whether the tab is in an incognito window. */ - incognito: boolean; - /** - * Whether the tab is selected. - * @deprecated since Chrome 33. Please use tabs.Tab.highlighted. - */ - selected: boolean; - /** - * Optional. - * Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted). Equivalent to whether the speaker audio indicator is showing. - * @since Chrome 45. - */ - audible?: boolean; - /** - * Optional. - * Current tab muted state and the reason for the last state change. - * @since Chrome 46. Warning: this is the current Beta channel. - */ - mutedInfo?: MutedInfo; - /** - * Optional. The width of the tab in pixels. - * @since Chrome 31. - */ - width?: number; - /** - * Optional. The height of the tab in pixels. - * @since Chrome 31. - */ - height?: number; - /** - * Optional. The session ID used to uniquely identify a Tab obtained from the sessions API. - * @since Chrome 31. - */ - sessionId?: string; + /** + * Tab muted state and the reason for the last state change. + * @since Chrome 46. Warning: this is the current Beta channel. + */ + interface MutedInfo { + /** Whether the tab is prevented from playing sound (but hasn't necessarily recently produced sound). Equivalent to whether the muted audio indicator is showing. */ + muted: boolean; + /** + * Optional. + * The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed. + * "user": A user input action has set/overridden the muted state. + * "capture": Tab capture started, forcing a muted state change. + * "extension": An extension, identified by the extensionId field, set the muted state. + */ + reason?: string; + /** + * Optional. + * The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed. + */ + extensionId?: string; } - /** - * Defines how zoom changes in a tab are handled and at what scope. - * @since Chrome 38. - */ - interface ZoomSettings { - /** - * Optional. - * Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to "automatic". - * "automatic": Zoom changes are handled automatically by the browser. - * "manual": Overrides the automatic handling of zoom changes. The onZoomChange event will still be dispatched, and it is the responsibility of the extension to listen for this event and manually scale the page. This mode does not support per-origin zooming, and will thus ignore the scope zoom setting and assume per-tab. - * "disabled": Disables all zooming in the tab. The tab will revert to the default zoom level, and all attempted zoom changes will be ignored. - */ - mode?: string; - /** - * Optional. - * Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise. - * "per-origin": Zoom changes will persist in the zoomed page's origin, i.e. all other tabs navigated to that same origin will be zoomed as well. Moreover, per-origin zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they will all be zoomed to the same zoom factor. The per-origin scope is only available in the automatic mode. - * "per-tab": Zoom changes only take effect in this tab, and zoom changes in other tabs will not affect the zooming of this tab. Also, per-tab zoom changes are reset on navigation; navigating a tab will always load pages with their per-origin zoom factors. - */ - scope?: string; - /** - * Optional. - * Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings. - * @since Chrome 43. - */ - defaultZoomFactor?: number; - } + interface Tab { + /** + * Optional. + * Either loading or complete. + */ + status?: string; + /** The zero-based index of the tab within its window. */ + index: number; + /** + * Optional. + * The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists. + * @since Chrome 18. + */ + openerTabId?: number; + /** + * Optional. + * The title of the tab. This property is only present if the extension's manifest includes the "tabs" permission. + */ + title?: string; + /** + * Optional. + * The URL the tab is displaying. This property is only present if the extension's manifest includes the "tabs" permission. + */ + url?: string; + /** + * Whether the tab is pinned. + * @since Chrome 9. + */ + pinned: boolean; + /** + * Whether the tab is highlighted. + * @since Chrome 16. + */ + highlighted: boolean; + /** The ID of the window the tab is contained within. */ + windowId: number; + /** + * Whether the tab is active in its window. (Does not necessarily mean the window is focused.) + * @since Chrome 16. + */ + active: boolean; + /** + * Optional. + * The URL of the tab's favicon. This property is only present if the extension's manifest includes the "tabs" permission. It may also be an empty string if the tab is loading. + */ + favIconUrl?: string; + /** + * Optional. + * The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a Tab may not be assigned an ID, for example when querying foreign tabs using the sessions API, in which case a session ID may be present. Tab ID can also be set to chrome.tabs.TAB_ID_NONE for apps and devtools windows. + */ + id?: number; + /** Whether the tab is in an incognito window. */ + incognito: boolean; + /** + * Whether the tab is selected. + * @deprecated since Chrome 33. Please use tabs.Tab.highlighted. + */ + selected: boolean; + /** + * Optional. + * Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted). Equivalent to whether the speaker audio indicator is showing. + * @since Chrome 45. + */ + audible?: boolean; + /** + * Optional. + * Current tab muted state and the reason for the last state change. + * @since Chrome 46. Warning: this is the current Beta channel. + */ + mutedInfo?: MutedInfo; + /** + * Optional. The width of the tab in pixels. + * @since Chrome 31. + */ + width?: number; + /** + * Optional. The height of the tab in pixels. + * @since Chrome 31. + */ + height?: number; + /** + * Optional. The session ID used to uniquely identify a Tab obtained from the sessions API. + * @since Chrome 31. + */ + sessionId?: string; + } + + /** + * Defines how zoom changes in a tab are handled and at what scope. + * @since Chrome 38. + */ + interface ZoomSettings { + /** + * Optional. + * Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to "automatic". + * "automatic": Zoom changes are handled automatically by the browser. + * "manual": Overrides the automatic handling of zoom changes. The onZoomChange event will still be dispatched, and it is the responsibility of the extension to listen for this event and manually scale the page. This mode does not support per-origin zooming, and will thus ignore the scope zoom setting and assume per-tab. + * "disabled": Disables all zooming in the tab. The tab will revert to the default zoom level, and all attempted zoom changes will be ignored. + */ + mode?: string; + /** + * Optional. + * Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise. + * "per-origin": Zoom changes will persist in the zoomed page's origin, i.e. all other tabs navigated to that same origin will be zoomed as well. Moreover, per-origin zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they will all be zoomed to the same zoom factor. The per-origin scope is only available in the automatic mode. + * "per-tab": Zoom changes only take effect in this tab, and zoom changes in other tabs will not affect the zooming of this tab. Also, per-tab zoom changes are reset on navigation; navigating a tab will always load pages with their per-origin zoom factors. + */ + scope?: string; + /** + * Optional. + * Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings. + * @since Chrome 43. + */ + defaultZoomFactor?: number; + } interface InjectDetails { - /** - * Optional. - * If allFrames is true, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's false and is only injected into the top frame. - */ + /** + * Optional. + * If allFrames is true, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's false and is only injected into the top frame. + */ allFrames?: boolean; - /** - * Optional. JavaScript or CSS code to inject. - * Warning: Be careful using the code parameter. Incorrect use of it may open your extension to cross site scripting attacks. - */ + /** + * Optional. JavaScript or CSS code to inject. + * Warning: Be careful using the code parameter. Incorrect use of it may open your extension to cross site scripting attacks. + */ code?: string; - /** - * Optional. The soonest that the JavaScript or CSS will be injected into the tab. - * One of: "document_start", "document_end", or "document_idle" - * @since Chrome 20. - */ + /** + * Optional. The soonest that the JavaScript or CSS will be injected into the tab. + * One of: "document_start", "document_end", or "document_idle" + * @since Chrome 20. + */ runAt?: string; - /** Optional. JavaScript or CSS file to inject. */ + /** Optional. JavaScript or CSS file to inject. */ file?: string; - /** - * Optional. - * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is false. - * @since Chrome 39. - */ - matchAboutBlank?: boolean; + /** + * Optional. + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is false. + * @since Chrome 39. + */ + matchAboutBlank?: boolean; } interface CreateProperties { - /** Optional. The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window. */ + /** Optional. The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window. */ index?: number; - /** - * Optional. - * The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab. - * @since Chrome 18. - */ + /** + * Optional. + * The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab. + * @since Chrome 18. + */ openerTabId?: number; - /** - * Optional. - * The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page. - */ + /** + * Optional. + * The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page. + */ url?: string; - /** - * Optional. Whether the tab should be pinned. Defaults to false - * @since Chrome 9. - */ + /** + * Optional. Whether the tab should be pinned. Defaults to false + * @since Chrome 9. + */ pinned?: boolean; - /** Optional. The window to create the new tab in. Defaults to the current window. */ + /** Optional. The window to create the new tab in. Defaults to the current window. */ windowId?: number; - /** - * Optional. - * Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see windows.update). Defaults to true. - * @since Chrome 16. - */ + /** + * Optional. + * Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see windows.update). Defaults to true. + * @since Chrome 16. + */ active?: boolean; - /** - * Optional. Whether the tab should become the selected tab in the window. Defaults to true - * @deprecated since Chrome 33. Please use active. - */ - selected?: boolean; + /** + * Optional. Whether the tab should become the selected tab in the window. Defaults to true + * @deprecated since Chrome 33. Please use active. + */ + selected?: boolean; } interface MoveProperties { - /** The position to move the window to. -1 will place the tab at the end of the window. */ + /** The position to move the window to. -1 will place the tab at the end of the window. */ index: number; - /** Optional. Defaults to the window the tab is currently in. */ + /** Optional. Defaults to the window the tab is currently in. */ windowId?: number; } interface UpdateProperties { - /** - * Optional. Whether the tab should be pinned. - * @since Chrome 9. - */ + /** + * Optional. Whether the tab should be pinned. + * @since Chrome 9. + */ pinned?: boolean; - /** - * Optional. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab. - * @since Chrome 18. - */ + /** + * Optional. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab. + * @since Chrome 18. + */ openerTabId?: number; - /** Optional. A URL to navigate the tab to. */ + /** Optional. A URL to navigate the tab to. */ url?: string; - /** - * Optional. Adds or removes the tab from the current selection. - * @since Chrome 16. - */ + /** + * Optional. Adds or removes the tab from the current selection. + * @since Chrome 16. + */ highlighted?: boolean; - /** - * Optional. Whether the tab should be active. Does not affect whether the window is focused (see windows.update). - * @since Chrome 16. - */ + /** + * Optional. Whether the tab should be active. Does not affect whether the window is focused (see windows.update). + * @since Chrome 16. + */ active?: boolean; - /** - * Optional. Whether the tab should be selected. - * @deprecated since Chrome 33. Please use highlighted. - */ - selected?: boolean; - /** - * Optional. Whether the tab should be muted. - * @since Chrome 45. - */ - muted?: boolean; + /** + * Optional. Whether the tab should be selected. + * @deprecated since Chrome 33. Please use highlighted. + */ + selected?: boolean; + /** + * Optional. Whether the tab should be muted. + * @since Chrome 45. + */ + muted?: boolean; } interface CaptureVisibleTabOptions { - /** - * Optional. - * When format is "jpeg", controls the quality of the resulting image. This value is ignored for PNG images. As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease. - */ + /** + * Optional. + * When format is "jpeg", controls the quality of the resulting image. This value is ignored for PNG images. As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease. + */ quality?: number; - /** - * Optional. The format of an image. - * One of: "jpeg", or "png" - */ + /** + * Optional. The format of an image. + * One of: "jpeg", or "png" + */ format?: string; } interface ReloadProperties { - /** Optional. Whether using any local cache. Default is false. */ + /** Optional. Whether using any local cache. Default is false. */ bypassCache?: boolean; } interface ConnectInfo { - /** Optional. Will be passed into onConnect for content scripts that are listening for the connection event. */ + /** Optional. Will be passed into onConnect for content scripts that are listening for the connection event. */ name?: string; - /** - * Open a port to a specific frame identified by frameId instead of all frames in the tab. - * @since Chrome 41. - */ - frameId?: number; + /** + * Open a port to a specific frame identified by frameId instead of all frames in the tab. + * @since Chrome 41. + */ + frameId?: number; } - interface MessageSendOptions { - /** Optional. Send a message to a specific frame identified by frameId instead of all frames in the tab. */ - frameId?: number; - } + interface MessageSendOptions { + /** Optional. Send a message to a specific frame identified by frameId instead of all frames in the tab. */ + frameId?: number; + } interface HighlightInfo { - /** One or more tab indices to highlight. */ - tabs: number | number[]; - /** Optional. The window that contains the tabs. */ + /** One or more tab indices to highlight. */ + tabs: number | number[]; + /** Optional. The window that contains the tabs. */ windowId?: number; } interface QueryInfo { - /** - * Optional. Whether the tabs have completed loading. - * One of: "loading", or "complete" - */ + /** + * Optional. Whether the tabs have completed loading. + * One of: "loading", or "complete" + */ status?: string; - /** - * Optional. Whether the tabs are in the last focused window. - * @since Chrome 19. - */ + /** + * Optional. Whether the tabs are in the last focused window. + * @since Chrome 19. + */ lastFocusedWindow?: boolean; - /** Optional. The ID of the parent window, or windows.WINDOW_ID_CURRENT for the current window. */ + /** Optional. The ID of the parent window, or windows.WINDOW_ID_CURRENT for the current window. */ windowId?: number; - /** - * Optional. The type of window the tabs are in. - * One of: "normal", "popup", "panel", "app", or "devtools" - */ + /** + * Optional. The type of window the tabs are in. + * One of: "normal", "popup", "panel", "app", or "devtools" + */ windowType?: string; - /** Optional. Whether the tabs are active in their windows. */ + /** Optional. Whether the tabs are active in their windows. */ active?: boolean; - /** - * Optional. The position of the tabs within their windows. - * @since Chrome 18. - */ + /** + * Optional. The position of the tabs within their windows. + * @since Chrome 18. + */ index?: number; - /** Optional. Match page titles against a pattern. */ + /** Optional. Match page titles against a pattern. */ title?: string; - /** Optional. Match tabs against one or more URL patterns. Note that fragment identifiers are not matched. */ + /** Optional. Match tabs against one or more URL patterns. Note that fragment identifiers are not matched. */ url?: string | string[]; - /** - * Optional. Whether the tabs are in the current window. - * @since Chrome 19. - */ + /** + * Optional. Whether the tabs are in the current window. + * @since Chrome 19. + */ currentWindow?: boolean; - /** Optional. Whether the tabs are highlighted. */ + /** Optional. Whether the tabs are highlighted. */ highlighted?: boolean; - /** Optional. Whether the tabs are pinned. */ + /** Optional. Whether the tabs are pinned. */ pinned?: boolean; - /** - * Optional. Whether the tabs are audible. - * @since Chrome 45. - */ - audible?: boolean; - /** - * Optional. Whether the tabs are muted. - * @since Chrome 45. - */ - muted?: boolean; + /** + * Optional. Whether the tabs are audible. + * @since Chrome 45. + */ + audible?: boolean; + /** + * Optional. Whether the tabs are muted. + * @since Chrome 45. + */ + muted?: boolean; } interface TabHighlightInfo { @@ -6154,12 +6154,12 @@ declare namespace chrome.tabs { } interface TabRemoveInfo { - /** - * The window whose tab is closed. - * @since Chrome 25. - */ + /** + * The window whose tab is closed. + * @since Chrome 25. + */ windowId: number; - /** True when the tab is being closed because its window is being closed. */ + /** True when the tab is being closed because its window is being closed. */ isWindowClosing: boolean; } @@ -6169,35 +6169,35 @@ declare namespace chrome.tabs { } interface TabChangeInfo { - /** Optional. The status of the tab. Can be either loading or complete. */ + /** Optional. The status of the tab. Can be either loading or complete. */ status?: string; - /** - * The tab's new pinned state. - * @since Chrome 9. - */ + /** + * The tab's new pinned state. + * @since Chrome 9. + */ pinned?: boolean; - /** Optional. The tab's URL if it has changed. */ + /** Optional. The tab's URL if it has changed. */ url?: string; - /** - * The tab's new audible state. - * @since Chrome 45. - */ - audible?: boolean; - /** - * The tab's new muted state and the reason for the change. - * @since Chrome 46. Warning: this is the current Beta channel. - */ - mutedInfo?: MutedInfo; - /** - * The tab's new favicon URL. - * @since Chrome 27. - */ - favIconUrl?: string; - /** - * The tab's new title. - * @since Chrome 48. - */ - title?: string; + /** + * The tab's new audible state. + * @since Chrome 45. + */ + audible?: boolean; + /** + * The tab's new muted state and the reason for the change. + * @since Chrome 46. Warning: this is the current Beta channel. + */ + mutedInfo?: MutedInfo; + /** + * The tab's new favicon URL. + * @since Chrome 27. + */ + favIconUrl?: string; + /** + * The tab's new title. + * @since Chrome 48. + */ + title?: string; } interface TabMoveInfo { @@ -6212,23 +6212,23 @@ declare namespace chrome.tabs { } interface TabActiveInfo { - /** The ID of the tab that has become active. */ + /** The ID of the tab that has become active. */ tabId: number; - /** The ID of the window the active tab changed inside of. */ + /** The ID of the window the active tab changed inside of. */ windowId: number; } - interface TabWindowInfo { - /** The ID of the window of where the tab is located. */ - windowId: number; - } + interface TabWindowInfo { + /** The ID of the window of where the tab is located. */ + windowId: number; + } - interface ZoomChangeInfo { - tabId: number; - oldZoomFactor: number; - newZoomFactor: number; - zoomSettings: ZoomSettings; - } + interface ZoomChangeInfo { + tabId: number; + oldZoomFactor: number; + newZoomFactor: number; + zoomSettings: ZoomSettings; + } interface TabHighlightedEvent extends chrome.events.Event<(highlightInfo: HighlightInfo) => void> {} @@ -6248,315 +6248,315 @@ declare namespace chrome.tabs { interface TabReplacedEvent extends chrome.events.Event<(addedTabId: number, removedTabId: number) => void> {} - interface TabSelectedEvent extends chrome.events.Event<(tabId: number, selectInfo: TabWindowInfo) => void> {} + interface TabSelectedEvent extends chrome.events.Event<(tabId: number, selectInfo: TabWindowInfo) => void> {} - interface TabZoomChangeEvent extends chrome.events.Event<(ZoomChangeInfo: ZoomChangeInfo) => void> {} + interface TabZoomChangeEvent extends chrome.events.Event<(ZoomChangeInfo: ZoomChangeInfo) => void> {} - /** - * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc. - * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. - * @param callback Optional. Called after all the JavaScript has been executed. - * Parameter result: The result of the script in every injected frame. - */ + /** + * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc. + * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. + * @param callback Optional. Called after all the JavaScript has been executed. + * Parameter result: The result of the script in every injected frame. + */ export function executeScript(details: InjectDetails, callback?: (result: any[]) => void): void; - /** - * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc. - * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window. - * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. - * @param callback Optional. Called after all the JavaScript has been executed. - * Parameter result: The result of the script in every injected frame. - */ + /** + * Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc. + * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window. + * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. + * @param callback Optional. Called after all the JavaScript has been executed. + * Parameter result: The result of the script in every injected frame. + */ export function executeScript(tabId: number, details: InjectDetails, callback?: (result: any[]) => void): void; - /** Retrieves details about the specified tab. */ + /** Retrieves details about the specified tab. */ export function get(tabId: number, callback: (tab: Tab) => void): void; - /** - * Gets details about all tabs in the specified window. - * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}. - */ - export function getAllInWindow(callback: (tab: Tab) => void): void; - /** - * Gets details about all tabs in the specified window. - * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}. - * @param windowId Optional. Defaults to the current window. - */ - export function getAllInWindow(windowId: number, callback: (tab: Tab) => void): void; - /** Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view). */ + /** + * Gets details about all tabs in the specified window. + * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}. + */ + export function getAllInWindow(callback: (tab: Tab) => void): void; + /** + * Gets details about all tabs in the specified window. + * @deprecated since Chrome 33. Please use tabs.query {windowId: windowId}. + * @param windowId Optional. Defaults to the current window. + */ + export function getAllInWindow(windowId: number, callback: (tab: Tab) => void): void; + /** Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view). */ export function getCurrent(callback: (tab?: Tab) => void): void; - /** - * Gets the tab that is selected in the specified window. - * @deprecated since Chrome 33. Please use tabs.query {active: true}. - */ - export function getSelected(callback: (tab: Tab) => void): void; - /** - * Gets the tab that is selected in the specified window. - * @deprecated since Chrome 33. Please use tabs.query {active: true}. - * @param windowId Optional. Defaults to the current window. - */ - export function getSelected(windowId: number, callback: (tab: Tab) => void): void; - /** - * Creates a new tab. - * @param callback Optional. - * Parameter tab: Details about the created tab. Will contain the ID of the new tab. - */ + /** + * Gets the tab that is selected in the specified window. + * @deprecated since Chrome 33. Please use tabs.query {active: true}. + */ + export function getSelected(callback: (tab: Tab) => void): void; + /** + * Gets the tab that is selected in the specified window. + * @deprecated since Chrome 33. Please use tabs.query {active: true}. + * @param windowId Optional. Defaults to the current window. + */ + export function getSelected(windowId: number, callback: (tab: Tab) => void): void; + /** + * Creates a new tab. + * @param callback Optional. + * Parameter tab: Details about the created tab. Will contain the ID of the new tab. + */ export function create(createProperties: CreateProperties, callback?: (tab: Tab) => void): void; - /** - * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows. - * @param tabId The tab to move. - * @param callback Optional. - * Parameter tab: Details about the moved tab. - */ + /** + * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows. + * @param tabId The tab to move. + * @param callback Optional. + * Parameter tab: Details about the moved tab. + */ export function move(tabId: number, moveProperties: MoveProperties, callback?: (tab: Tab) => void): void; - /** - * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows. - * @param tabIds The tabs to move. - * @param callback Optional. - * Parameter tabs: Details about the moved tabs. - */ + /** + * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows. + * @param tabIds The tabs to move. + * @param callback Optional. + * Parameter tabs: Details about the moved tabs. + */ export function move(tabIds: number[], moveProperties: MoveProperties, callback?: (tabs: Tab[]) => void): void; - /** - * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified. - * @param callback Optional. - * Optional parameter tab: Details about the updated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested. - */ + /** + * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified. + * @param callback Optional. + * Optional parameter tab: Details about the updated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested. + */ export function update(updateProperties: UpdateProperties, callback?: (tab?: Tab) => void): void; - /** - * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified. - * @param tabId Defaults to the selected tab of the current window. - * @param callback Optional. - * Optional parameter tab: Details about the updated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested. - */ + /** + * Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified. + * @param tabId Defaults to the selected tab of the current window. + * @param callback Optional. + * Optional parameter tab: Details about the updated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested. + */ export function update(tabId: number, updateProperties: UpdateProperties, callback?: (tab?: Tab) => void): void; - /** - * Closes a tab. - * @param tabId The tab to close. - */ + /** + * Closes a tab. + * @param tabId The tab to close. + */ export function remove(tabId: number, callback?: Function): void; - /** - * Closes several tabs. - * @param tabIds The list of tabs to close. - */ + /** + * Closes several tabs. + * @param tabIds The list of tabs to close. + */ export function remove(tabIds: number[], callback?: Function): void; - /** - * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. - * @param callback - * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. - */ + /** + * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. + * @param callback + * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. + */ export function captureVisibleTab(callback: (dataUrl: string) => void): void; - /** - * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. - * @param windowId Optional. The target window. Defaults to the current window. - * @param callback - * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. - */ + /** + * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. + * @param windowId Optional. The target window. Defaults to the current window. + * @param callback + * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. + */ export function captureVisibleTab(windowId: number, callback: (dataUrl: string) => void): void; - /** - * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. - * @param options Optional. Details about the format and quality of an image. - * @param callback - * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. - */ + /** + * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. + * @param options Optional. Details about the format and quality of an image. + * @param callback + * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. + */ export function captureVisibleTab(options: CaptureVisibleTabOptions, callback: (dataUrl: string) => void): void; - /** - * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. - * @param windowId Optional. The target window. Defaults to the current window. - * @param options Optional. Details about the format and quality of an image. - * @param callback - * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. - */ + /** + * Captures the visible area of the currently active tab in the specified window. You must have permission to use this method. + * @param windowId Optional. The target window. Defaults to the current window. + * @param options Optional. Details about the format and quality of an image. + * @param callback + * Parameter dataUrl: A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. + */ export function captureVisibleTab(windowId: number, options: CaptureVisibleTabOptions, callback: (dataUrl: string) => void): void; - /** - * Reload a tab. - * @since Chrome 16. - * @param tabId The ID of the tab to reload; defaults to the selected tab of the current window. - */ - export function reload(tabId: number, reloadProperties?: ReloadProperties, callback?: () => void): void; - /** - * Reload the selected tab of the current window. - * @since Chrome 16. - */ - export function reload(reloadProperties: ReloadProperties, callback?: () => void): void; - /** - * Reload the selected tab of the current window. - * @since Chrome 16. - */ - export function reload(callback?: () => void): void; - /** - * Duplicates a tab. - * @since Chrome 23. - * @param tabId The ID of the tab which is to be duplicated. - * @param callback Optional. - * Optional parameter tab: Details about the duplicated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested. - */ + /** + * Reload a tab. + * @since Chrome 16. + * @param tabId The ID of the tab to reload; defaults to the selected tab of the current window. + */ + export function reload(tabId: number, reloadProperties?: ReloadProperties, callback?: () => void): void; + /** + * Reload the selected tab of the current window. + * @since Chrome 16. + */ + export function reload(reloadProperties: ReloadProperties, callback?: () => void): void; + /** + * Reload the selected tab of the current window. + * @since Chrome 16. + */ + export function reload(callback?: () => void): void; + /** + * Duplicates a tab. + * @since Chrome 23. + * @param tabId The ID of the tab which is to be duplicated. + * @param callback Optional. + * Optional parameter tab: Details about the duplicated tab. The tabs.Tab object doesn't contain url, title and favIconUrl if the "tabs" permission has not been requested. + */ export function duplicate(tabId: number, callback?: (tab?: Tab) => void): void; - /** - * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension. - * @since Chrome 20. - */ + /** + * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension. + * @since Chrome 20. + */ export function sendMessage(tabId: number, message: any, responseCallback?: (response: any) => void): void; - /** - * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension. - * @since Chrome 41. - * @param responseCallback Optional. - * Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message. - */ - export function sendMessage(tabId: number, message: any, options: MessageSendOptions, responseCallback?: (response: any) => void): void; - /** - * Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest event is fired in each content script running in the specified tab for the current extension. - * @deprecated since Chrome 33. Please use runtime.sendMessage. - * @param responseCallback Optional. - * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message. - */ - export function sendRequest(tabId: number, request: any, responseCallback?: (response: any) => void): void; - /** Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. */ + /** + * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension. + * @since Chrome 41. + * @param responseCallback Optional. + * Parameter response: The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message. + */ + export function sendMessage(tabId: number, message: any, options: MessageSendOptions, responseCallback?: (response: any) => void): void; + /** + * Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest event is fired in each content script running in the specified tab for the current extension. + * @deprecated since Chrome 33. Please use runtime.sendMessage. + * @param responseCallback Optional. + * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message. + */ + export function sendRequest(tabId: number, request: any, responseCallback?: (response: any) => void): void; + /** Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. */ export function connect(tabId: number, connectInfo?: ConnectInfo): runtime.Port; - /** - * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc. - * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. - * @param callback Optional. Called when all the CSS has been inserted. - */ - export function insertCSS(details: InjectDetails, callback?: Function): void; - /** - * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc. - * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window. - * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. - * @param callback Optional. Called when all the CSS has been inserted. - */ + /** + * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc. + * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. + * @param callback Optional. Called when all the CSS has been inserted. + */ + export function insertCSS(details: InjectDetails, callback?: Function): void; + /** + * Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc. + * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window. + * @param details Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. + * @param callback Optional. Called when all the CSS has been inserted. + */ export function insertCSS(tabId: number, details: InjectDetails, callback?: Function): void; - /** - * Highlights the given tabs. - * @since Chrome 16. - * @param callback Optional. - * Parameter window: Contains details about the window whose tabs were highlighted. - */ + /** + * Highlights the given tabs. + * @since Chrome 16. + * @param callback Optional. + * Parameter window: Contains details about the window whose tabs were highlighted. + */ export function highlight(highlightInfo: HighlightInfo, callback: (window: chrome.windows.Window) => void): void; - /** - * Gets all tabs that have the specified properties, or all tabs if no properties are specified. - * @since Chrome 16. - */ + /** + * Gets all tabs that have the specified properties, or all tabs if no properties are specified. + * @since Chrome 16. + */ export function query(queryInfo: QueryInfo, callback: (result: Tab[]) => void): void; - /** - * Detects the primary language of the content in a tab. - * @param callback - * Parameter language: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned. - */ + /** + * Detects the primary language of the content in a tab. + * @param callback + * Parameter language: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned. + */ export function detectLanguage(callback: (language: string) => void): void; - /** - * Detects the primary language of the content in a tab. - * @param tabId Optional. Defaults to the active tab of the current window. - * @param callback - * Parameter language: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned. - */ + /** + * Detects the primary language of the content in a tab. + * @param tabId Optional. Defaults to the active tab of the current window. + * @param callback + * Parameter language: An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned. + */ export function detectLanguage(tabId: number, callback: (language: string) => void): void; - /** - * Zooms a specified tab. - * @since Chrome 42. - * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab. - * @param callback Optional. Called after the zoom factor has been changed. - */ - export function setZoom(zoomFactor: number, callback?: () => void): void; - /** - * Zooms a specified tab. - * @since Chrome 42. - * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window. - * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab. - * @param callback Optional. Called after the zoom factor has been changed. - */ - export function setZoom(tabId: number, zoomFactor: number, callback?: () => void): void; - /** - * Gets the current zoom factor of a specified tab. - * @since Chrome 42. - * @param callback Called with the tab's current zoom factor after it has been fetched. - * Parameter zoomFactor: The tab's current zoom factor. - */ - export function getZoom(callback: (zoomFactor: number) => void): void; - /** - * Gets the current zoom factor of a specified tab. - * @since Chrome 42. - * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window. - * @param callback Called with the tab's current zoom factor after it has been fetched. - * Parameter zoomFactor: The tab's current zoom factor. - */ - export function getZoom(tabId: number, callback: (zoomFactor: number) => void): void; - /** - * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab. - * @since Chrome 42. - * @param zoomSettings Defines how zoom changes are handled and at what scope. - * @param callback Optional. Called after the zoom settings have been changed. - */ - export function setZoomSettings(zoomSettings: ZoomSettings, callback?: () => void): void; - /** - * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab. - * @since Chrome 42. - * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current window. - * @param zoomSettings Defines how zoom changes are handled and at what scope. - * @param callback Optional. Called after the zoom settings have been changed. - */ - export function setZoomSettings(tabId: number, zoomSettings: ZoomSettings, callback?: () => void): void; - /** - * Gets the current zoom settings of a specified tab. - * @since Chrome 42. - * @param callback Called with the tab's current zoom settings. - * Paramater zoomSettings: The tab's current zoom settings. - */ - export function getZoomSettings(callback: (zoomSettings: ZoomSettings) => void): void; - /** - * Gets the current zoom settings of a specified tab. - * @since Chrome 42. - * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window. - * @param callback Called with the tab's current zoom settings. - * Paramater zoomSettings: The tab's current zoom settings. - */ - export function getZoomSettings(tabId: number, callback: (zoomSettings: ZoomSettings) => void): void; + /** + * Zooms a specified tab. + * @since Chrome 42. + * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab. + * @param callback Optional. Called after the zoom factor has been changed. + */ + export function setZoom(zoomFactor: number, callback?: () => void): void; + /** + * Zooms a specified tab. + * @since Chrome 42. + * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window. + * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor. Values greater than zero specify a (possibly non-default) zoom factor for the tab. + * @param callback Optional. Called after the zoom factor has been changed. + */ + export function setZoom(tabId: number, zoomFactor: number, callback?: () => void): void; + /** + * Gets the current zoom factor of a specified tab. + * @since Chrome 42. + * @param callback Called with the tab's current zoom factor after it has been fetched. + * Parameter zoomFactor: The tab's current zoom factor. + */ + export function getZoom(callback: (zoomFactor: number) => void): void; + /** + * Gets the current zoom factor of a specified tab. + * @since Chrome 42. + * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window. + * @param callback Called with the tab's current zoom factor after it has been fetched. + * Parameter zoomFactor: The tab's current zoom factor. + */ + export function getZoom(tabId: number, callback: (zoomFactor: number) => void): void; + /** + * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab. + * @since Chrome 42. + * @param zoomSettings Defines how zoom changes are handled and at what scope. + * @param callback Optional. Called after the zoom settings have been changed. + */ + export function setZoomSettings(zoomSettings: ZoomSettings, callback?: () => void): void; + /** + * Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab. + * @since Chrome 42. + * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current window. + * @param zoomSettings Defines how zoom changes are handled and at what scope. + * @param callback Optional. Called after the zoom settings have been changed. + */ + export function setZoomSettings(tabId: number, zoomSettings: ZoomSettings, callback?: () => void): void; + /** + * Gets the current zoom settings of a specified tab. + * @since Chrome 42. + * @param callback Called with the tab's current zoom settings. + * Paramater zoomSettings: The tab's current zoom settings. + */ + export function getZoomSettings(callback: (zoomSettings: ZoomSettings) => void): void; + /** + * Gets the current zoom settings of a specified tab. + * @since Chrome 42. + * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window. + * @param callback Called with the tab's current zoom settings. + * Paramater zoomSettings: The tab's current zoom settings. + */ + export function getZoomSettings(tabId: number, callback: (zoomSettings: ZoomSettings) => void): void; - /** - * Fired when the highlighted or selected tabs in a window changes. - * @since Chrome 18. - */ + /** + * Fired when the highlighted or selected tabs in a window changes. + * @since Chrome 18. + */ var onHighlighted: TabHighlightedEvent; - /** Fired when a tab is closed. */ + /** Fired when a tab is closed. */ var onRemoved: TabRemovedEvent; - /** Fired when a tab is updated. */ + /** Fired when a tab is updated. */ var onUpdated: TabUpdatedEvent; - /** Fired when a tab is attached to a window, for example because it was moved between windows. */ + /** Fired when a tab is attached to a window, for example because it was moved between windows. */ var onAttached: TabAttachedEvent; - /** - * Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see tabs.onDetached. - */ + /** + * Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see tabs.onDetached. + */ var onMoved: TabMovedEvent; - /** Fired when a tab is detached from a window, for example because it is being moved between windows. */ + /** Fired when a tab is detached from a window, for example because it is being moved between windows. */ var onDetached: TabDetachedEvent; - /** Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set. */ + /** Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set. */ var onCreated: TabCreatedEvent; - /** - * Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set. - * @since Chrome 18. - */ + /** + * Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set. + * @since Chrome 18. + */ var onActivated: TabActivatedEvent; - /** - * Fired when a tab is replaced with another tab due to prerendering or instant. - * @since Chrome 26. - */ + /** + * Fired when a tab is replaced with another tab due to prerendering or instant. + * @since Chrome 26. + */ var onReplaced: TabReplacedEvent; - /** - * @deprecated since Chrome 33. Please use tabs.onActivated. - * Fires when the selected tab in a window changes. - */ - var onSelectionChanged: TabSelectedEvent; - /** - * @deprecated since Chrome 33. Please use tabs.onActivated. - * Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to tabs.onUpdated events to be notified when a URL is set. - */ - var onActiveChanged: TabSelectedEvent; - /** - * @deprecated since Chrome 33. Please use tabs.onHighlighted. - * Fired when the highlighted or selected tabs in a window changes. - */ - var onHighlightChanged: TabHighlightedEvent; - /** - * Fired when a tab is zoomed. - * @since Chrome 38. - */ - var onZoomChange: TabZoomChangeEvent; + /** + * @deprecated since Chrome 33. Please use tabs.onActivated. + * Fires when the selected tab in a window changes. + */ + var onSelectionChanged: TabSelectedEvent; + /** + * @deprecated since Chrome 33. Please use tabs.onActivated. + * Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to tabs.onUpdated events to be notified when a URL is set. + */ + var onActiveChanged: TabSelectedEvent; + /** + * @deprecated since Chrome 33. Please use tabs.onHighlighted. + * Fired when the highlighted or selected tabs in a window changes. + */ + var onHighlightChanged: TabHighlightedEvent; + /** + * Fired when a tab is zoomed. + * @since Chrome 38. + */ + var onZoomChange: TabZoomChangeEvent; } //////////////////// @@ -6568,16 +6568,16 @@ declare namespace chrome.tabs { * @since Chrome 19. */ declare namespace chrome.topSites { - /** An object encapsulating a most visited URL, such as the URLs on the new tab page. */ + /** An object encapsulating a most visited URL, such as the URLs on the new tab page. */ interface MostVisitedURL { - /** The most visited URL. */ + /** The most visited URL. */ url: string; - /** The title of the page */ + /** The title of the page */ title: string; } - /** Gets a list of top sites. */ - export function get(callback: (data: MostVisitedURL[]) => void): void; + /** Gets a list of top sites. */ + export function get(callback: (data: MostVisitedURL[]) => void): void; } //////////////////// @@ -6589,110 +6589,110 @@ declare namespace chrome.topSites { * @since Chrome 14. */ declare namespace chrome.tts { - /** An event from the TTS engine to communicate the status of an utterance. */ + /** An event from the TTS engine to communicate the status of an utterance. */ interface TtsEvent { - /** Optional. The index of the current character in the utterance. */ + /** Optional. The index of the current character in the utterance. */ charIndex?: number; - /** Optional. The error description, if the event type is 'error'. */ + /** Optional. The error description, if the event type is 'error'. */ errorMessage?: string; - /** - * The type can be 'start' as soon as speech has started, 'word' when a word boundary is reached, 'sentence' when a sentence boundary is reached, 'marker' when an SSML mark element is reached, 'end' when the end of the utterance is reached, 'interrupted' when the utterance is stopped or interrupted before reaching the end, 'cancelled' when it's removed from the queue before ever being synthesized, or 'error' when any other error occurs. When pausing speech, a 'pause' event is fired if a particular utterance is paused in the middle, and 'resume' if an utterance resumes speech. Note that pause and resume events may not fire if speech is paused in-between utterances. - * One of: "start", "end", "word", "sentence", "marker", "interrupted", "cancelled", "error", "pause", or "resume" - */ + /** + * The type can be 'start' as soon as speech has started, 'word' when a word boundary is reached, 'sentence' when a sentence boundary is reached, 'marker' when an SSML mark element is reached, 'end' when the end of the utterance is reached, 'interrupted' when the utterance is stopped or interrupted before reaching the end, 'cancelled' when it's removed from the queue before ever being synthesized, or 'error' when any other error occurs. When pausing speech, a 'pause' event is fired if a particular utterance is paused in the middle, and 'resume' if an utterance resumes speech. Note that pause and resume events may not fire if speech is paused in-between utterances. + * One of: "start", "end", "word", "sentence", "marker", "interrupted", "cancelled", "error", "pause", or "resume" + */ type: string; } - /** A description of a voice available for speech synthesis. */ + /** A description of a voice available for speech synthesis. */ interface TtsVoice { - /** Optional. The language that this voice supports, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */ + /** Optional. The language that this voice supports, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */ lang?: string; - /** - * Optional. This voice's gender. - * One of: "male", or "female" - */ + /** + * Optional. This voice's gender. + * One of: "male", or "female" + */ gender?: string; - /** Optional. The name of the voice. */ + /** Optional. The name of the voice. */ voiceName?: string; - /** The ID of the extension providing this voice. */ + /** The ID of the extension providing this voice. */ extensionsId?: string; - /** All of the callback event types that this voice is capable of sending. */ + /** All of the callback event types that this voice is capable of sending. */ eventTypes?: string[]; - /** - * If true, the synthesis engine is a remote network resource. It may be higher latency and may incur bandwidth costs. - * @since Chrome 33. - */ - remote?: boolean; + /** + * If true, the synthesis engine is a remote network resource. It may be higher latency and may incur bandwidth costs. + * @since Chrome 33. + */ + remote?: boolean; } interface SpeakOptions { - /** Optional. Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0. */ + /** Optional. Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0. */ volume?: number; - /** - * Optional. - * If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance. - */ + /** + * Optional. + * If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance. + */ enqueue?: boolean; - /** - * Optional. - * Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further—for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0. - */ + /** + * Optional. + * Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further—for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0. + */ rate?: number; - /** - * Optional. This function is called with events that occur in the process of speaking the utterance. - * @param event The update event from the text-to-speech engine indicating the status of this utterance. - */ + /** + * Optional. This function is called with events that occur in the process of speaking the utterance. + * @param event The update event from the text-to-speech engine indicating the status of this utterance. + */ onEvent?: (event: TtsEvent) => void; - /** - * Optional. - * Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch. - */ + /** + * Optional. + * Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch. + */ pitch?: number; - /** Optional. The language to be used for synthesis, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */ + /** Optional. The language to be used for synthesis, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */ lang?: string; - /** Optional. The name of the voice to use for synthesis. If empty, uses any available voice. */ + /** Optional. The name of the voice to use for synthesis. If empty, uses any available voice. */ voiceName?: string; - /** Optional. The extension ID of the speech engine to use, if known. */ + /** Optional. The extension ID of the speech engine to use, if known. */ extensionId?: string; - /** - * Optional. Gender of voice for synthesized speech. - * One of: "male", or "female" - */ + /** + * Optional. Gender of voice for synthesized speech. + * One of: "male", or "female" + */ gender?: string; - /** Optional. The TTS event types the voice must support. */ + /** Optional. The TTS event types the voice must support. */ requiredEventTypes?: string[]; - /** Optional. The TTS event types that you are interested in listening to. If missing, all event types may be sent. */ + /** Optional. The TTS event types that you are interested in listening to. If missing, all event types may be sent. */ desiredEventTypes?: string[]; } - /** Checks whether the engine is currently speaking. On Mac OS X, the result is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome. */ + /** Checks whether the engine is currently speaking. On Mac OS X, the result is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome. */ export function isSpeaking(callback?: (speaking: boolean) => void): void; - /** Stops any current speech and flushes the queue of any pending utterances. In addition, if speech was paused, it will now be un-paused for the next call to speak. */ + /** Stops any current speech and flushes the queue of any pending utterances. In addition, if speech was paused, it will now be un-paused for the next call to speak. */ export function stop(): void; - /** Gets an array of all available voices. */ + /** Gets an array of all available voices. */ export function getVoices(callback?: (voices: TtsVoice[]) => void): void; - /** - * Speaks text using a text-to-speech engine. - * @param utterance The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters. - * @param callback Optional. Called right away, before speech finishes. Check chrome.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback. - */ - export function speak(utterance: string, callback?: Function): void; - /** - * Speaks text using a text-to-speech engine. - * @param utterance The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters. - * @param options Optional. The speech options. - * @param callback Optional. Called right away, before speech finishes. Check chrome.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback. - */ - export function speak(utterance: string, options: SpeakOptions, callback?: Function): void; - /** - * Pauses speech synthesis, potentially in the middle of an utterance. A call to resume or stop will un-pause speech. - * @since Chrome 29. - */ - export function pause(): void; - /** - * If speech was paused, resumes speaking where it left off. - * @since Chrome 29. - */ - export function resume(): void; + /** + * Speaks text using a text-to-speech engine. + * @param utterance The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters. + * @param callback Optional. Called right away, before speech finishes. Check chrome.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback. + */ + export function speak(utterance: string, callback?: Function): void; + /** + * Speaks text using a text-to-speech engine. + * @param utterance The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters. + * @param options Optional. The speech options. + * @param callback Optional. Called right away, before speech finishes. Check chrome.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback. + */ + export function speak(utterance: string, options: SpeakOptions, callback?: Function): void; + /** + * Pauses speech synthesis, potentially in the middle of an utterance. A call to resume or stop will un-pause speech. + * @since Chrome 29. + */ + export function pause(): void; + /** + * If speech was paused, resumes speaking where it left off. + * @since Chrome 29. + */ + export function resume(): void; } //////////////////// @@ -6705,42 +6705,42 @@ declare namespace chrome.tts { */ declare namespace chrome.ttsEngine { interface SpeakOptions { - /** Optional. The language to be used for synthesis, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */ + /** Optional. The language to be used for synthesis, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */ lang?: string; - /** Optional. The name of the voice to use for synthesis. */ + /** Optional. The name of the voice to use for synthesis. */ voiceName?: string; - /** - * Optional. Gender of voice for synthesized speech. - * One of: "male", or "female" - */ + /** + * Optional. Gender of voice for synthesized speech. + * One of: "male", or "female" + */ gender?: string; - /** Optional. Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0. */ + /** Optional. Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0. */ volume?: number; - /** - * Optional. - * Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. This value is guaranteed to be between 0.1 and 10.0, inclusive. When a voice does not support this full range of rates, don't return an error. Instead, clip the rate to the range the voice supports. - */ + /** + * Optional. + * Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. This value is guaranteed to be between 0.1 and 10.0, inclusive. When a voice does not support this full range of rates, don't return an error. Instead, clip the rate to the range the voice supports. + */ rate?: number; - /** Optional. Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to this voice's default pitch. */ + /** Optional. Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to this voice's default pitch. */ pitch?: number; } interface TtsEngineSpeakEvent extends chrome.events.Event<(utterance: string, options: SpeakOptions, sendTtsEvent: (event: chrome.tts.TtsEvent) => void) => void> {} - /** Called when the user makes a call to tts.speak() and one of the voices from this extension's manifest is the first to match the options object. */ + /** Called when the user makes a call to tts.speak() and one of the voices from this extension's manifest is the first to match the options object. */ var onSpeak: TtsEngineSpeakEvent; - /** Fired when a call is made to tts.stop and this extension may be in the middle of speaking. If an extension receives a call to onStop and speech is already stopped, it should do nothing (not raise an error). If speech is in the paused state, this should cancel the paused state. */ - var onStop: chrome.events.Event<() => void>; - /** - * Optional: if an engine supports the pause event, it should pause the current utterance being spoken, if any, until it receives a resume event or stop event. Note that a stop event should also clear the paused state. - * @since Chrome 29. - */ - var onPause: chrome.events.Event<() => void>; - /** - * Optional: if an engine supports the pause event, it should also support the resume event, to continue speaking the current utterance, if any. Note that a stop event should also clear the paused state. - * @since Chrome 29. - */ - var onResume: chrome.events.Event<() => void>; + /** Fired when a call is made to tts.stop and this extension may be in the middle of speaking. If an extension receives a call to onStop and speech is already stopped, it should do nothing (not raise an error). If speech is in the paused state, this should cancel the paused state. */ + var onStop: chrome.events.Event<() => void>; + /** + * Optional: if an engine supports the pause event, it should pause the current utterance being spoken, if any, until it receives a resume event or stop event. Note that a stop event should also clear the paused state. + * @since Chrome 29. + */ + var onPause: chrome.events.Event<() => void>; + /** + * Optional: if an engine supports the pause event, it should also support the resume event, to continue speaking the current utterance, if any. Note that a stop event should also clear the paused state. + * @since Chrome 29. + */ + var onResume: chrome.events.Event<() => void>; } //////////////////// @@ -6752,85 +6752,85 @@ declare namespace chrome.ttsEngine { */ declare namespace chrome.types { interface ChromeSettingClearDetails { - /** - * Optional. - * The scope of the ChromeSetting. One of - * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), - * • regular_only: setting for the regular profile only (not inherited by the incognito profile), - * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), - * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). - */ + /** + * Optional. + * The scope of the ChromeSetting. One of + * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), + * • regular_only: setting for the regular profile only (not inherited by the incognito profile), + * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), + * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). + */ scope?: string; } interface ChromeSettingSetDetails extends ChromeSettingClearDetails { - /** - * The value of the setting. - * Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type. - */ + /** + * The value of the setting. + * Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type. + */ value: any; - /** - * Optional. - * The scope of the ChromeSetting. One of - * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), - * • regular_only: setting for the regular profile only (not inherited by the incognito profile), - * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), - * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). - */ - scope?: string; + /** + * Optional. + * The scope of the ChromeSetting. One of + * • regular: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), + * • regular_only: setting for the regular profile only (not inherited by the incognito profile), + * • incognito_persistent: setting for the incognito profile that survives browser restarts (overrides regular preferences), + * • incognito_session_only: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). + */ + scope?: string; } interface ChromeSettingGetDetails { - /** Optional. Whether to return the value that applies to the incognito session (default false). */ + /** Optional. Whether to return the value that applies to the incognito session (default false). */ incognito?: boolean; } - /** - * @param details Details of the currently effective value. - */ + /** + * @param details Details of the currently effective value. + */ type DetailsCallback = (details: ChromeSettingGetResultDetails) => void; interface ChromeSettingGetResultDetails { - /** - * One of - * • not_controllable: cannot be controlled by any extension - * • controlled_by_other_extensions: controlled by extensions with higher precedence - * • controllable_by_this_extension: can be controlled by this extension - * • controlled_by_this_extension: controlled by this extension - */ + /** + * One of + * • not_controllable: cannot be controlled by any extension + * • controlled_by_other_extensions: controlled by extensions with higher precedence + * • controllable_by_this_extension: can be controlled by this extension + * • controlled_by_this_extension: controlled by this extension + */ levelOfControl: string; - /** The value of the setting. */ + /** The value of the setting. */ value: any; - /** - * Optional. - * Whether the effective value is specific to the incognito session. - * This property will only be present if the incognito property in the details parameter of get() was true. - */ + /** + * Optional. + * Whether the effective value is specific to the incognito session. + * This property will only be present if the incognito property in the details parameter of get() was true. + */ incognitoSpecific?: boolean; } interface ChromeSettingChangedEvent extends chrome.events.Event {} - /** An interface that allows access to a Chrome browser setting. See accessibilityFeatures for an example. */ + /** An interface that allows access to a Chrome browser setting. See accessibilityFeatures for an example. */ interface ChromeSetting { - /** - * Sets the value of a setting. - * @param details Which setting to change. - * @param callback Optional. Called at the completion of the set operation. - */ + /** + * Sets the value of a setting. + * @param details Which setting to change. + * @param callback Optional. Called at the completion of the set operation. + */ set(details: ChromeSettingSetDetails, callback?: Function): void; - /** - * Gets the value of a setting. - * @param details Which setting to consider. - */ + /** + * Gets the value of a setting. + * @param details Which setting to consider. + */ get(details: ChromeSettingGetDetails, callback?: DetailsCallback): void; - /** - * Clears the setting, restoring any default value. - * @param details Which setting to clear. - * @param callback Optional. Called at the completion of the clear operation. - */ + /** + * Clears the setting, restoring any default value. + * @param details Which setting to clear. + * @param callback Optional. Called at the completion of the clear operation. + */ clear(details: ChromeSettingClearDetails, callback?: Function): void; - /** Fired after the setting changes. */ + /** Fired after the setting changes. */ onChange: ChromeSettingChangedEvent; } } @@ -6845,81 +6845,81 @@ declare namespace chrome.types { * @since Chrome 43. */ declare namespace chrome.vpnProvider { - interface VpnSessionParameters { - /** IP address for the VPN interface in CIDR notation. IPv4 is currently the only supported mode. */ - address: string; - /** Optional. Broadcast address for the VPN interface. (default: deduced from IP address and mask) */ - broadcastAddress?: string; - /** Optional. MTU setting for the VPN interface. (default: 1500 bytes) */ - mtu?: string; - /** - * Exclude network traffic to the list of IP blocks in CIDR notation from the tunnel. This can be used to bypass traffic to and from the VPN server. When many rules match a destination, the rule with the longest matching prefix wins. Entries that correspond to the same CIDR block are treated as duplicates. Such duplicates in the collated (exclusionList + inclusionList) list are eliminated and the exact duplicate entry that will be eliminated is undefined. - */ - exclusionList: string[]; - /** - * Include network traffic to the list of IP blocks in CIDR notation to the tunnel. This parameter can be used to set up a split tunnel. By default no traffic is directed to the tunnel. Adding the entry "0.0.0.0/0" to this list gets all the user traffic redirected to the tunnel. When many rules match a destination, the rule with the longest matching prefix wins. Entries that correspond to the same CIDR block are treated as duplicates. Such duplicates in the collated (exclusionList + inclusionList) list are eliminated and the exact duplicate entry that will be eliminated is undefined. - */ - inclusionList: string[]; - /** Optional. A list of search domains. (default: no search domain) */ - domainSearch?: string[]; - /** A list of IPs for the DNS servers. */ - dnsServer: string[]; - } + interface VpnSessionParameters { + /** IP address for the VPN interface in CIDR notation. IPv4 is currently the only supported mode. */ + address: string; + /** Optional. Broadcast address for the VPN interface. (default: deduced from IP address and mask) */ + broadcastAddress?: string; + /** Optional. MTU setting for the VPN interface. (default: 1500 bytes) */ + mtu?: string; + /** + * Exclude network traffic to the list of IP blocks in CIDR notation from the tunnel. This can be used to bypass traffic to and from the VPN server. When many rules match a destination, the rule with the longest matching prefix wins. Entries that correspond to the same CIDR block are treated as duplicates. Such duplicates in the collated (exclusionList + inclusionList) list are eliminated and the exact duplicate entry that will be eliminated is undefined. + */ + exclusionList: string[]; + /** + * Include network traffic to the list of IP blocks in CIDR notation to the tunnel. This parameter can be used to set up a split tunnel. By default no traffic is directed to the tunnel. Adding the entry "0.0.0.0/0" to this list gets all the user traffic redirected to the tunnel. When many rules match a destination, the rule with the longest matching prefix wins. Entries that correspond to the same CIDR block are treated as duplicates. Such duplicates in the collated (exclusionList + inclusionList) list are eliminated and the exact duplicate entry that will be eliminated is undefined. + */ + inclusionList: string[]; + /** Optional. A list of search domains. (default: no search domain) */ + domainSearch?: string[]; + /** A list of IPs for the DNS servers. */ + dnsServer: string[]; + } - interface VpnPlatformMessageEvent extends chrome.events.Event<(id: string, message: string, error: string) => void> {} + interface VpnPlatformMessageEvent extends chrome.events.Event<(id: string, message: string, error: string) => void> {} - interface VpnPacketReceptionEvent extends chrome.events.Event<(data: ArrayBuffer) => void> {} + interface VpnPacketReceptionEvent extends chrome.events.Event<(data: ArrayBuffer) => void> {} - interface VpnConfigRemovalEvent extends chrome.events.Event<(id: string) => void> {} + interface VpnConfigRemovalEvent extends chrome.events.Event<(id: string) => void> {} - interface VpnConfigCreationEvent extends chrome.events.Event<(id: string, name: string, data: Object) => void> {} + interface VpnConfigCreationEvent extends chrome.events.Event<(id: string, name: string, data: Object) => void> {} - interface VpnUiEvent extends chrome.events.Event<(event: string, id?: string) => void> {} + interface VpnUiEvent extends chrome.events.Event<(event: string, id?: string) => void> {} - /** - * Creates a new VPN configuration that persists across multiple login sessions of the user. - * @param name The name of the VPN configuration. - * @param callback Called when the configuration is created or if there is an error. - * Parameter id: A unique ID for the created configuration, empty string on failure. - */ - export function createConfig(name: string, callback: (id: string) => void): void; - /** - * Destroys a VPN configuration created by the extension. - * @param id ID of the VPN configuration to destroy. - * @param callback Optional. Called when the configuration is destroyed or if there is an error. - */ - export function destroyConfig(id: string, callback?: Function): void; - /** - * Sets the parameters for the VPN session. This should be called immediately after "connected" is received from the platform. This will succeed only when the VPN session is owned by the extension. - * @param parameters The parameters for the VPN session. - * @param callback Called when the parameters are set or if there is an error. - */ - export function setParameters(parameters: VpnSessionParameters, callback: Function): void; - /** - * Sends an IP packet through the tunnel created for the VPN session. This will succeed only when the VPN session is owned by the extension. - * @param data The IP packet to be sent to the platform. - * @param callback Optional. Called when the packet is sent or if there is an error. - */ - export function sendPacket(data: ArrayBuffer, callback?: Function): void; - /** - * Notifies the VPN session state to the platform. This will succeed only when the VPN session is owned by the extension. - * @param state The VPN session state of the VPN client. - * connected: VPN connection was successful. - * failure: VPN connection failed. - * @param callback Optional. Called when the notification is complete or if there is an error. - */ - export function notifyConnectionStateChanged(state: string, callback?: Function): void; + /** + * Creates a new VPN configuration that persists across multiple login sessions of the user. + * @param name The name of the VPN configuration. + * @param callback Called when the configuration is created or if there is an error. + * Parameter id: A unique ID for the created configuration, empty string on failure. + */ + export function createConfig(name: string, callback: (id: string) => void): void; + /** + * Destroys a VPN configuration created by the extension. + * @param id ID of the VPN configuration to destroy. + * @param callback Optional. Called when the configuration is destroyed or if there is an error. + */ + export function destroyConfig(id: string, callback?: Function): void; + /** + * Sets the parameters for the VPN session. This should be called immediately after "connected" is received from the platform. This will succeed only when the VPN session is owned by the extension. + * @param parameters The parameters for the VPN session. + * @param callback Called when the parameters are set or if there is an error. + */ + export function setParameters(parameters: VpnSessionParameters, callback: Function): void; + /** + * Sends an IP packet through the tunnel created for the VPN session. This will succeed only when the VPN session is owned by the extension. + * @param data The IP packet to be sent to the platform. + * @param callback Optional. Called when the packet is sent or if there is an error. + */ + export function sendPacket(data: ArrayBuffer, callback?: Function): void; + /** + * Notifies the VPN session state to the platform. This will succeed only when the VPN session is owned by the extension. + * @param state The VPN session state of the VPN client. + * connected: VPN connection was successful. + * failure: VPN connection failed. + * @param callback Optional. Called when the notification is complete or if there is an error. + */ + export function notifyConnectionStateChanged(state: string, callback?: Function): void; - /** Triggered when a message is received from the platform for a VPN configuration owned by the extension. */ - var onPlatformMessage: VpnPlatformMessageEvent; - /** Triggered when an IP packet is received via the tunnel for the VPN session owned by the extension. */ - var onPacketReceived: VpnPacketReceptionEvent; - /** Triggered when a configuration created by the extension is removed by the platform. */ - var onConfigRemoved: VpnConfigRemovalEvent; - /** Triggered when a configuration is created by the platform for the extension. */ - var onConfigCreated: VpnConfigCreationEvent; - /** Triggered when there is a UI event for the extension. UI events are signals from the platform that indicate to the app that a UI dialog needs to be shown to the user. */ - var onUIEvent: VpnUiEvent; + /** Triggered when a message is received from the platform for a VPN configuration owned by the extension. */ + var onPlatformMessage: VpnPlatformMessageEvent; + /** Triggered when an IP packet is received via the tunnel for the VPN session owned by the extension. */ + var onPacketReceived: VpnPacketReceptionEvent; + /** Triggered when a configuration created by the extension is removed by the platform. */ + var onConfigRemoved: VpnConfigRemovalEvent; + /** Triggered when a configuration is created by the platform for the extension. */ + var onConfigCreated: VpnConfigCreationEvent; + /** Triggered when there is a UI event for the extension. UI events are signals from the platform that indicate to the app that a UI dialog needs to be shown to the user. */ + var onUIEvent: VpnUiEvent; } //////////////////// @@ -6932,28 +6932,28 @@ declare namespace chrome.vpnProvider { * @since Chrome 43. */ declare namespace chrome.wallpaper { - interface WallpaperDetails { - /** Optional. The jpeg or png encoded wallpaper image. */ - data?: any; - /** Optional. The URL of the wallpaper to be set. */ - url?: string; - /** - * The supported wallpaper layouts. - * One of: "STRETCH", "CENTER", or "CENTER_CROPPED" - */ - layout: string; - /** The file name of the saved wallpaper. */ - filename: string; - /** Optional. True if a 128x60 thumbnail should be generated. */ - thumbnail?: boolean; - } + interface WallpaperDetails { + /** Optional. The jpeg or png encoded wallpaper image. */ + data?: any; + /** Optional. The URL of the wallpaper to be set. */ + url?: string; + /** + * The supported wallpaper layouts. + * One of: "STRETCH", "CENTER", or "CENTER_CROPPED" + */ + layout: string; + /** The file name of the saved wallpaper. */ + filename: string; + /** Optional. True if a 128x60 thumbnail should be generated. */ + thumbnail?: boolean; + } - /** - * Sets wallpaper to the image at url or wallpaperData with the specified layout - * @param callback - * Optional parameter thumbnail: The jpeg encoded wallpaper thumbnail. It is generated by resizing the wallpaper to 128x60. - */ - export function setWallpaper(details: WallpaperDetails, callback: (thumbnail: any) => void): void; + /** + * Sets wallpaper to the image at url or wallpaperData with the specified layout + * @param callback + * Optional parameter thumbnail: The jpeg encoded wallpaper thumbnail. It is generated by resizing the wallpaper to 128x60. + */ + export function setWallpaper(details: WallpaperDetails, callback: (thumbnail: any) => void): void; } //////////////////// @@ -6966,162 +6966,162 @@ declare namespace chrome.wallpaper { */ declare namespace chrome.webNavigation { interface GetFrameDetails { - /** - * The ID of the process runs the renderer for this tab. - * @since Chrome 22. - */ + /** + * The ID of the process runs the renderer for this tab. + * @since Chrome 22. + */ processId: number; - /** The ID of the tab in which the frame is. */ + /** The ID of the tab in which the frame is. */ tabId: number; - /** The ID of the frame in the given tab. */ + /** The ID of the frame in the given tab. */ frameId: number; } interface GetFrameResultDetails { - /** The URL currently associated with this frame, if the frame identified by the frameId existed at one point in the given tab. The fact that an URL is associated with a given frameId does not imply that the corresponding frame still exists. */ + /** The URL currently associated with this frame, if the frame identified by the frameId existed at one point in the given tab. The fact that an URL is associated with a given frameId does not imply that the corresponding frame still exists. */ url: string; - /** True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired. */ + /** True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired. */ errorOccurred: boolean; - /** ID of frame that wraps the frame. Set to -1 of no parent frame exists. */ + /** ID of frame that wraps the frame. Set to -1 of no parent frame exists. */ parentFrameId: number; } interface GetAllFrameDetails { - /** The ID of the tab. */ + /** The ID of the tab. */ tabId: number; } interface GetAllFrameResultDetails extends GetFrameResultDetails { - /** The ID of the process runs the renderer for this tab. */ + /** The ID of the process runs the renderer for this tab. */ processId: number; - /** The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe. */ + /** The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe. */ frameId: number; } - interface WebNavigationCallbackDetails { - /** The ID of the tab in which the navigation is about to occur. */ + interface WebNavigationCallbackDetails { + /** The ID of the tab in which the navigation is about to occur. */ tabId: number; - /** The time when the browser was about to start the navigation, in milliseconds since the epoch. */ + /** The time when the browser was about to start the navigation, in milliseconds since the epoch. */ timeStamp: number; } - interface WebNavigationUrlCallbackDetails extends WebNavigationCallbackDetails { + interface WebNavigationUrlCallbackDetails extends WebNavigationCallbackDetails { url: string; } - interface WebNavigationReplacementCallbackDetails extends WebNavigationCallbackDetails { - /** The ID of the tab that was replaced. */ - replacedTabId: number; + interface WebNavigationReplacementCallbackDetails extends WebNavigationCallbackDetails { + /** The ID of the tab that was replaced. */ + replacedTabId: number; } - interface WebNavigationFramedCallbackDetails extends WebNavigationUrlCallbackDetails { - /** 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique for a given tab and process. */ - frameId: number; - /** - * The ID of the process runs the renderer for this tab. - * @since Chrome 22. - */ - processId: number; + interface WebNavigationFramedCallbackDetails extends WebNavigationUrlCallbackDetails { + /** 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique for a given tab and process. */ + frameId: number; + /** + * The ID of the process runs the renderer for this tab. + * @since Chrome 22. + */ + processId: number; } - interface WebNavigationFramedErrorCallbackDetails extends WebNavigationFramedCallbackDetails { - /** The error description. */ - error: string; + interface WebNavigationFramedErrorCallbackDetails extends WebNavigationFramedCallbackDetails { + /** The error description. */ + error: string; } - interface WebNavigationSourceCallbackDetails extends WebNavigationUrlCallbackDetails { - /** The ID of the tab in which the navigation is triggered. */ + interface WebNavigationSourceCallbackDetails extends WebNavigationUrlCallbackDetails { + /** The ID of the tab in which the navigation is triggered. */ sourceTabId: number; - /** - * The ID of the process runs the renderer for the source tab. - * @since Chrome 22. - */ + /** + * The ID of the process runs the renderer for the source tab. + * @since Chrome 22. + */ sourceProcessId: number; - /** The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame. */ + /** The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame. */ sourceFrameId: number; } - interface WebNavigationParentedCallbackDetails extends WebNavigationFramedCallbackDetails { - /** - * ID of frame that wraps the frame. Set to -1 of no parent frame exists. - * @since Chrome 24. - */ + interface WebNavigationParentedCallbackDetails extends WebNavigationFramedCallbackDetails { + /** + * ID of frame that wraps the frame. Set to -1 of no parent frame exists. + * @since Chrome 24. + */ parentFrameId: number; } - interface WebNavigationTransitionCallbackDetails extends WebNavigationFramedCallbackDetails { - /** - * Cause of the navigation. - * One of: "link", "typed", "auto_bookmark", "auto_subframe", "manual_subframe", "generated", "start_page", "form_submit", "reload", "keyword", or "keyword_generated" - */ - transitionType: string; - /** - * A list of transition qualifiers. - * Each element one of: "client_redirect", "server_redirect", "forward_back", or "from_address_bar" - */ - transitionQualifiers: string[]; + interface WebNavigationTransitionCallbackDetails extends WebNavigationFramedCallbackDetails { + /** + * Cause of the navigation. + * One of: "link", "typed", "auto_bookmark", "auto_subframe", "manual_subframe", "generated", "start_page", "form_submit", "reload", "keyword", or "keyword_generated" + */ + transitionType: string; + /** + * A list of transition qualifiers. + * Each element one of: "client_redirect", "server_redirect", "forward_back", or "from_address_bar" + */ + transitionQualifiers: string[]; } - interface WebNavigationEventFilter { - /** Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event. */ + interface WebNavigationEventFilter { + /** Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event. */ url: chrome.events.UrlFilter[]; } - interface WebNavigationEvent extends chrome.events.Event<(details: T) => void> { - addListener(callback: (details: T) => void, filters?: WebNavigationEventFilter): void; + interface WebNavigationEvent extends chrome.events.Event<(details: T) => void> { + addListener(callback: (details: T) => void, filters?: WebNavigationEventFilter): void; } interface WebNavigationFramedEvent extends WebNavigationEvent {} - interface WebNavigationFramedErrorEvent extends WebNavigationEvent {} + interface WebNavigationFramedErrorEvent extends WebNavigationEvent {} - interface WebNavigationSourceEvent extends WebNavigationEvent {} + interface WebNavigationSourceEvent extends WebNavigationEvent {} - interface WebNavigationParentedEvent extends WebNavigationEvent {} + interface WebNavigationParentedEvent extends WebNavigationEvent {} - interface WebNavigationTransitionalEvent extends WebNavigationEvent {} + interface WebNavigationTransitionalEvent extends WebNavigationEvent {} - interface WebNavigationReplacementEvent extends WebNavigationEvent {} + interface WebNavigationReplacementEvent extends WebNavigationEvent {} - /** - * Retrieves information about the given frame. A frame refers to an