mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge branch 'master' of https://github.com/understandr/DefinitelyTyped
This commit is contained in:
+302
-129
File diff suppressed because it is too large
Load Diff
@@ -169,8 +169,14 @@ If a package was never on DefinitelyTyped, it does not need to be added to `notN
|
||||
|
||||
#### Lint
|
||||
|
||||
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "dtslint/dt.json" }`. All new packages must be linted.
|
||||
If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
|
||||
All new packages must be linted. To lint a package, add a `tslint.json` to that package containing
|
||||
```js
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
```
|
||||
|
||||
This should be the only content in a finished project's `tslint.json` file. If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
|
||||
|
||||
```js
|
||||
{
|
||||
|
||||
@@ -642,6 +642,12 @@
|
||||
"sourceRepoURL": "https://github.com/jdalrymple/node-gitlab",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Google Cloud Storage",
|
||||
"typingsPackageName": "google-cloud__storage",
|
||||
"sourceRepoURL": "https://github.com/googleapis/nodejs-storage",
|
||||
"asOfVersion": "2.3.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "graphene-pk11",
|
||||
"typingsPackageName": "graphene-pk11",
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"dtslint": "github:Microsoft/dtslint#production",
|
||||
"types-publisher": "Microsoft/types-publisher#production"
|
||||
"types-publisher": "github:Microsoft/types-publisher#production"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as accept from 'accept';
|
||||
|
||||
accept.charsets("iso-8859-5, unicode-1-1;q=0.8"); // charset === "iso-8859-5"
|
||||
accept.charset("iso-8859-5, unicode-1-1;q=0.8", ["unicode-1-1"]); // charset === "unicode-1-1"
|
||||
|
||||
accept.encoding("gzip, deflate, sdch"); // encoding === "gzip"
|
||||
accept.encoding("gzip, deflate, sdch", ["deflate", "identity"]);
|
||||
|
||||
const encodings = accept.encodings("compress;q=0.5, gzip;q=1.0"); // encodings === ["gzip", "compress", "identity"]
|
||||
encodings.lastIndexOf('');
|
||||
|
||||
accept.language("en;q=0.7, en-GB;q=0.8");
|
||||
accept.language("en;q=0.7, en-GB;q=0.8", ["en-gb"]); // language === "en-GB"
|
||||
const languages = accept.languages("da, en;q=0.7, en-GB;q=0.8"); // languages === ["da", "en-GB", "en"]
|
||||
languages.lastIndexOf('');
|
||||
|
||||
const mediaTypes = accept.mediaTypes("text/plain, application/json;q=0.5, text/html, */*;q=0.1");
|
||||
// mediaTypes === ["text/plain", "text/html", "application/json", "*/*"]
|
||||
mediaTypes.lastIndexOf('');
|
||||
const headers = {
|
||||
accept: 'text/plain, application/json;q=0.5, text/html, */*;q=0.1',
|
||||
'accept-language': 'da, en;q=0.7, en-GB;q=0.8'
|
||||
};
|
||||
|
||||
const all = accept.parseAll(headers);
|
||||
all.charsets.length;
|
||||
all.encodings.length;
|
||||
all.languages.length;
|
||||
all.mediaTypes.length;
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for accept 3.1
|
||||
// Project: https://github.com/hapijs/accept#readme
|
||||
// Definitions by: feinoujc <https://github.com/feinoujc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export function charset(charsetHeader?: string, preferences?: string[]): string;
|
||||
export function charsets(charsetHeader?: string): string[];
|
||||
export function encoding(encodingHeader?: string, preferences?: string[]): string;
|
||||
export function encodings(encodingHeader?: string): string[];
|
||||
export function language(languageHeader?: string, preferences?: string[]): string;
|
||||
export function languages(languageHeader?: string): string[];
|
||||
export function mediaTypes(mediaTypeHeader?: string): string[];
|
||||
export function parseAll(
|
||||
headers: Record<string, string | string[] | undefined>
|
||||
): {
|
||||
charsets: string[];
|
||||
encodings: string[];
|
||||
languages: string[];
|
||||
mediaTypes: string[];
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"accept-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -1223,7 +1223,7 @@ declare namespace AceAjax {
|
||||
/**
|
||||
* Returns `true` if the current `textInput` is in focus.
|
||||
**/
|
||||
isFocused(): void;
|
||||
isFocused(): boolean;
|
||||
|
||||
/**
|
||||
* Blurs the current `textInput`.
|
||||
|
||||
Vendored
+1
-1
@@ -54,7 +54,7 @@ declare namespace AltJS {
|
||||
export type Source = {[name:string]: () => SourceModel<any>};
|
||||
|
||||
export interface SourceModel<S> {
|
||||
local(state:any, ...args: any[]):any;
|
||||
local?(state:any, ...args: any[]):any;
|
||||
remote(state:any, ...args: any[]):Promise<S>;
|
||||
shouldFetch?(fetchFn:(...args:Array<any>) => boolean):void;
|
||||
loading?:(args:any) => void;
|
||||
|
||||
+10
-1
@@ -136,7 +136,16 @@ export interface ChannelWrapper extends EventEmitter {
|
||||
* Setup functions should, ideally, not throw errors, but if they do then the ChannelWrapper will emit an 'error' event.
|
||||
* @param func
|
||||
*/
|
||||
addSetup(func: SetupFunc): Promise<void>;
|
||||
addSetup(func: SetupFunc): Promise<void>;
|
||||
|
||||
/**
|
||||
* Remove a setup function added with `addSetup`. If there is currently a
|
||||
* connection, `teardown(channel, [cb])` will be run immediately, and the
|
||||
* returned Promise will not resolve until it completes.
|
||||
* @param func
|
||||
* @param [tearDown]
|
||||
*/
|
||||
removeSetup(func: SetupFunc, tearDown?: SetupFunc): Promise<void>;
|
||||
|
||||
/**
|
||||
* @see amqplib
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"whitespace": false,
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"whitespace": false,
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -153,6 +153,10 @@ declare module 'angular' {
|
||||
defaultFontSet(name: string): IIconProvider;
|
||||
}
|
||||
|
||||
interface IInkRippleProvider {
|
||||
disableInkRipple(): void;
|
||||
}
|
||||
|
||||
type IMedia = (media: string) => boolean;
|
||||
|
||||
interface ISidenavObject {
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"whitespace": false,
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"whitespace": false,
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +94,6 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function bind() {
|
||||
interface I1 { kind: 'I1'; }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').bind('myEvent', 'myData', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -104,14 +102,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').bind('myEvent', 'myData', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').bind('myEvent', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -120,14 +110,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').bind('myEvent', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').bind('myEvent', false);
|
||||
|
||||
@@ -139,12 +121,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -164,27 +140,15 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function off() {
|
||||
function defaultContext_defaultData(this: HTMLElement, event: JQueryEventObject) { }
|
||||
function defaultData(this: HTMLElement, event: JQueryEventObject) { }
|
||||
|
||||
function defaultContext_customData(this: HTMLElement, event: JQueryEventObject) { }
|
||||
|
||||
function customContext_defaultData(this: I1, event: JQueryEventObject) { }
|
||||
|
||||
function customContext_customData(this: I1, event: JQueryEventObject) { }
|
||||
|
||||
interface I1 { kind: 'I1'; }
|
||||
function customData(this: HTMLElement, event: JQueryEventObject) { }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', defaultContext_defaultData);
|
||||
$('table').off('myEvent', 'td', defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', defaultContext_customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', customContext_defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', customContext_customData);
|
||||
$('table').off('myEvent', 'td', customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', false);
|
||||
@@ -193,16 +157,10 @@ function JQuery() {
|
||||
$('table').off('myEvent', 'td');
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', defaultContext_defaultData);
|
||||
$('table').off('myEvent', defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', defaultContext_customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', customContext_defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', customContext_customData);
|
||||
$('table').off('myEvent', customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', false);
|
||||
@@ -213,19 +171,15 @@ function JQuery() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off({
|
||||
myEvent1: false,
|
||||
defaultContext_defaultData,
|
||||
defaultContext_customData,
|
||||
customContext_defaultData,
|
||||
customContext_customData
|
||||
defaultData,
|
||||
customData
|
||||
}, 'td');
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off({
|
||||
myEvent1: false,
|
||||
defaultContext_defaultData,
|
||||
defaultContext_customData,
|
||||
customContext_defaultData,
|
||||
customContext_customData
|
||||
defaultData,
|
||||
customData
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
@@ -236,8 +190,6 @@ function JQuery() {
|
||||
}
|
||||
|
||||
function on() {
|
||||
interface I1 { kind: 'I1'; }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', 'td', 'myData', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -246,14 +198,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', 'td', 'myData', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', null, 'myData', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -262,14 +206,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', null, 'myData', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', 'td', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -278,14 +214,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', 'td', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', 'td', false);
|
||||
|
||||
@@ -297,14 +225,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', 3, function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, number>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -313,14 +233,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').on('myEvent', false);
|
||||
|
||||
@@ -332,12 +244,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
}
|
||||
}, 'td', 'myData');
|
||||
|
||||
@@ -349,12 +255,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
}
|
||||
}, null, 'myData');
|
||||
|
||||
@@ -366,12 +266,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
}
|
||||
}, 'td');
|
||||
|
||||
@@ -383,12 +277,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, number>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, number>
|
||||
event;
|
||||
}
|
||||
}, 3);
|
||||
|
||||
@@ -400,19 +288,11 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function one() {
|
||||
interface I1 { kind: 'I1'; }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', 'td', 'myData', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -421,14 +301,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', 'td', 'myData', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', null, 'myData', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -437,14 +309,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', null, 'myData', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', 'td', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -453,14 +317,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', 'td', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', 'td', false);
|
||||
|
||||
@@ -472,14 +328,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', 3, function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, number>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', function(event) {
|
||||
// TODO: $ExpectType HTMLElement
|
||||
@@ -488,14 +336,6 @@ function JQuery() {
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', function(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').one('myEvent', false);
|
||||
|
||||
@@ -507,12 +347,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
}
|
||||
}, 'td', 'myData');
|
||||
|
||||
@@ -524,12 +358,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, string>
|
||||
event;
|
||||
}
|
||||
}, null, 'myData');
|
||||
|
||||
@@ -541,12 +369,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
}
|
||||
}, 'td');
|
||||
|
||||
@@ -558,12 +380,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, number>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, number>
|
||||
event;
|
||||
}
|
||||
}, 3);
|
||||
|
||||
@@ -575,12 +391,6 @@ function JQuery() {
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
},
|
||||
myEvent3(this: I1, event) {
|
||||
// $ExpectType I1
|
||||
this;
|
||||
// TODO: $ExpectType Event<HTMLElement, null>
|
||||
event;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"whitespace": false,
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+41
-4
@@ -1,8 +1,45 @@
|
||||
// Type definitions for ansicolors
|
||||
// Project: https://github.com/thlorenz/ansicolors
|
||||
// Definitions by: rogierschouten <https://github.com/rogierschouten>
|
||||
// Definitions by: Benjamin Arthur Lupton <https://github.com/balupton>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare var colors: { [index: string]: (s: string) => string; };
|
||||
export = colors;
|
||||
interface Colors extends String {
|
||||
(value: string): string
|
||||
white: this
|
||||
black: this
|
||||
blue: this
|
||||
cyan: this
|
||||
green: this
|
||||
magenta: this
|
||||
red: this
|
||||
yellow: this
|
||||
brightBlack: this
|
||||
brightRed: this
|
||||
brightGreen: this
|
||||
brightYellow: this
|
||||
brightBlue: this
|
||||
brightMagenta: this
|
||||
brightCyan: this
|
||||
brightWhite: this
|
||||
bgBlack: this
|
||||
bgRed: this
|
||||
bgGreen: this
|
||||
bgYellow: this
|
||||
bgBlue: this
|
||||
bgMagenta: this
|
||||
bgCyan: this
|
||||
bgWhite: this
|
||||
bgBrightBlack: this
|
||||
bgBrightRed: this
|
||||
bgBrightGreen: this
|
||||
bgBrightYellow: this
|
||||
bgBrightBlue: this
|
||||
bgBrightMagenta: this
|
||||
bgBrightCyan: this
|
||||
bgBrightWhite: this
|
||||
open: this
|
||||
close: this
|
||||
colors: this
|
||||
}
|
||||
declare const colors: Colors
|
||||
export default colors
|
||||
|
||||
+10
-8
@@ -670,14 +670,16 @@ declare module Microsoft.ApplicationInsights {
|
||||
context: ITelemetryContext;
|
||||
queue: Array<() => void>;
|
||||
/**
|
||||
* Starts timing how long the user views a page or other item. Call this when the page opens.
|
||||
* This method doesn't send any telemetry. Call {@link stopTrackTelemetry} to log the page when it closes.
|
||||
* Starts the timer for tracking a page load time. Use this instead of `trackPageView` if you want to control when the page view timer starts and stops,
|
||||
* but don't want to calculate the duration yourself. This method doesn't send any telemetry. Call `stopTrackPage` to log the end of the page view
|
||||
* and send the event.
|
||||
* @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
|
||||
*/
|
||||
startTrackPage(name?: string): any;
|
||||
/**
|
||||
* Logs how long a page or other item was visible, after {@link startTrackPage}. Call this when the page closes.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
* Stops the timer that was started by calling `startTrackPage` and sends the pageview load time telemetry with the specified properties and measurements.
|
||||
* The duration of the page view will be the time between calling `startTrackPage` and `stopTrackPage`.
|
||||
* @param name The string you used as the name in `startTrackPage`. Defaults to the document title.
|
||||
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
|
||||
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
@@ -689,7 +691,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
measurements?: { [name: string]: number }): any;
|
||||
/**
|
||||
* Logs that a page or other item was viewed.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
* @param name The string you used as the name in `startTrackPage`. Defaults to the document title.
|
||||
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
|
||||
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
@@ -701,13 +703,13 @@ declare module Microsoft.ApplicationInsights {
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number }, duration?: number): any;
|
||||
/**
|
||||
* Start timing an extended event. Call {@link stopTrackEvent} to log the event when it ends.
|
||||
* Start timing an extended event. Call `stopTrackEvent` to log the event when it ends.
|
||||
* @param name A string that identifies this event uniquely within the document.
|
||||
*/
|
||||
startTrackEvent(name: string): any;
|
||||
/**
|
||||
* Log an extended event that you started timing with {@link startTrackEvent}.
|
||||
* @param name The string you used to identify this event in startTrackEvent.
|
||||
* Log an extended event that you started timing with `startTrackEvent`.
|
||||
* @param name The string you used to identify this event in `startTrackEvent`.
|
||||
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ assert(true, "it's working");
|
||||
assert.ok(true, "inner functions work as well");
|
||||
|
||||
assert.throws(() => {});
|
||||
assert.throws(() => {}, /Regex test/);
|
||||
assert.throws(() => {}, () => {}, "works wonderfully");
|
||||
|
||||
assert['fail'](true, true, "works like a charm");
|
||||
|
||||
Vendored
+3
-2
@@ -1,6 +1,7 @@
|
||||
// Type definitions for commonjs-assert 1.4
|
||||
// Project: https://github.com/browserify/commonjs-assert
|
||||
// Definitions by: Nico Gallinal <https://github.com/nicoabie>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function assert(value: any, message?: string): void;
|
||||
@@ -23,10 +24,10 @@ declare namespace assert {
|
||||
function notStrictEqual(actual: any, expected: any, message?: string): void;
|
||||
|
||||
function throws(block: () => void, message?: string): void;
|
||||
function throws(block: () => void, error: () => void | ((err: any) => boolean) | RegExp, message?: string): void;
|
||||
function throws(block: () => void, error: (() => void) | ((err: any) => boolean) | RegExp, message?: string): void;
|
||||
|
||||
function doesNotThrow(block: () => void, message?: string): void;
|
||||
function doesNotThrow(block: () => void, error: () => void | ((err: any) => boolean) | RegExp, message?: string): void;
|
||||
function doesNotThrow(block: () => void, error: (() => void) | ((err: any) => boolean) | RegExp, message?: string): void;
|
||||
|
||||
function ifError(value: any): void;
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import Tree from "@atlaskit/tree";
|
||||
|
||||
import * as React from "react";
|
||||
import { render } from "react-dom";
|
||||
|
||||
declare const container: Element;
|
||||
|
||||
render(
|
||||
<Tree
|
||||
tree={{
|
||||
rootId: 1,
|
||||
items: {
|
||||
1: {
|
||||
id: 1,
|
||||
children: []
|
||||
},
|
||||
"string-id": {
|
||||
id: "string-id",
|
||||
children: [1, "another"],
|
||||
hasChildren: true,
|
||||
isExpanded: false,
|
||||
isChildrenLoading: false,
|
||||
data: {
|
||||
myVar: "this can be anything"
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
renderItem={() => <div />}
|
||||
onExpand={() => {}}
|
||||
onCollapse={() => {}}
|
||||
onDragStart={() => {}}
|
||||
onDragEnd={() => {}}
|
||||
offsetPerLevel={20}
|
||||
isDragEnabled
|
||||
isNestingEnabled
|
||||
/>,
|
||||
container
|
||||
);
|
||||
|
||||
// Check that default props work too.
|
||||
render(<Tree renderItem={() => <div />} />, container);
|
||||
Vendored
+153
@@ -0,0 +1,153 @@
|
||||
// Type definitions for @atlaskit/tree 4.1
|
||||
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/
|
||||
// Definitions by: Ben James <https://github.com/benhjames>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import { Component, ReactNode } from "react";
|
||||
|
||||
import {
|
||||
DraggingStyle,
|
||||
DraggableProvidedDragHandleProps,
|
||||
DraggableStateSnapshot,
|
||||
NotDraggingStyle
|
||||
} from "react-beautiful-dnd";
|
||||
|
||||
export type ItemId = any;
|
||||
|
||||
export type Path = number[];
|
||||
|
||||
export interface TreeData {
|
||||
rootId: ItemId;
|
||||
items: { [key: string]: TreeItem; [key: number]: TreeItem };
|
||||
}
|
||||
|
||||
export type TreeItemData = any;
|
||||
|
||||
export interface TreeItem {
|
||||
id: ItemId;
|
||||
children: ItemId[];
|
||||
hasChildren?: boolean;
|
||||
isExpanded?: boolean;
|
||||
isChildrenLoading?: boolean;
|
||||
data?: TreeItemData;
|
||||
}
|
||||
|
||||
export interface TreeSourcePosition {
|
||||
parentId: ItemId;
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface TreeDestinationPosition {
|
||||
parentId: ItemId;
|
||||
index?: number;
|
||||
}
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
interface TreeDraggingStyle extends Omit<DraggingStyle, "transition"> {
|
||||
paddingLeft: number;
|
||||
transition: "none" | string;
|
||||
}
|
||||
|
||||
type TreeDraggableStyle = NotDraggingStyle | TreeDraggingStyle;
|
||||
|
||||
interface TreeDraggableProps {
|
||||
// Props that can be spread onto the element directly
|
||||
// inline style
|
||||
style?: TreeDraggableStyle;
|
||||
// used for shared global styles
|
||||
"data-react-beautiful-dnd-draggable": string;
|
||||
}
|
||||
|
||||
interface TreeDraggableProvided {
|
||||
draggableProps: TreeDraggableProps;
|
||||
// will be null if the draggable is disabled
|
||||
dragHandleProps?: DraggableProvidedDragHandleProps;
|
||||
// The following props will be removed once we move to react 16
|
||||
innerRef: (element?: HTMLElement) => void;
|
||||
}
|
||||
|
||||
export interface RenderItemParams {
|
||||
item: TreeItem;
|
||||
depth: number;
|
||||
onExpand: (itemId: ItemId) => void;
|
||||
onCollapse: (itemId: ItemId) => void;
|
||||
provided: TreeDraggableProvided;
|
||||
snapshot: DraggableStateSnapshot;
|
||||
}
|
||||
|
||||
interface TreeItemMutation {
|
||||
id?: ItemId;
|
||||
children?: ItemId[];
|
||||
hasChildren?: boolean;
|
||||
isExpanded?: boolean;
|
||||
isChildrenLoading?: boolean;
|
||||
data?: TreeItemData;
|
||||
}
|
||||
|
||||
export function mutateTree(
|
||||
tree: TreeData,
|
||||
itemId: ItemId,
|
||||
mutation: TreeItemMutation
|
||||
): TreeData;
|
||||
|
||||
export function moveItemOnTree(
|
||||
tree: TreeData,
|
||||
from: TreeSourcePosition,
|
||||
to: TreeDestinationPosition
|
||||
): TreeData;
|
||||
|
||||
interface TreeProps {
|
||||
/** The tree data structure. */
|
||||
tree: TreeData;
|
||||
/** Function that will be called when a parent item needs to be expanded. */
|
||||
onExpand: (itemId: ItemId, path: Path) => void;
|
||||
/** Function that will be called when a parent item needs to be collapsed. */
|
||||
onCollapse: (itemId: ItemId, path: Path) => void;
|
||||
/** Function that will be called when the user starts dragging. */
|
||||
onDragStart: (itemId: ItemId) => void;
|
||||
/** Function that will be called when the user finishes dragging. */
|
||||
onDragEnd: (
|
||||
sourcePosition: TreeSourcePosition,
|
||||
destinationPosition: TreeDestinationPosition | undefined
|
||||
) => void;
|
||||
/** Function that will be called to render a single item. */
|
||||
renderItem: (itemProps: RenderItemParams) => ReactNode;
|
||||
/** Number of pixel is used to scaffold the tree by the consumer. */
|
||||
offsetPerLevel: number;
|
||||
/** Boolean to turn on drag&drop re-ordering on the tree */
|
||||
isDragEnabled: boolean;
|
||||
/** Boolean to turn on hovering while dragging */
|
||||
isNestingEnabled: boolean;
|
||||
}
|
||||
|
||||
interface FlattenedItem {
|
||||
item: TreeItem;
|
||||
path: Path;
|
||||
}
|
||||
|
||||
type FlattenedTree = FlattenedItem[];
|
||||
|
||||
interface TreeState {
|
||||
/** The flattened tree data structure transformed from props.tree */
|
||||
flattenedTree: FlattenedTree;
|
||||
// Id of the currently dragged item
|
||||
draggedItemId: ItemId;
|
||||
}
|
||||
|
||||
declare class Tree extends Component<TreeProps, TreeState> {
|
||||
static defaultProps: {
|
||||
tree: { children: [] };
|
||||
onExpand: () => void;
|
||||
onCollapse: () => void;
|
||||
onDragStart: () => void;
|
||||
onDragEnd: () => void;
|
||||
renderItem: () => void;
|
||||
offsetPerLevel: 35;
|
||||
isDragEnabled: false;
|
||||
isNestingEnabled: false;
|
||||
};
|
||||
}
|
||||
|
||||
export default Tree;
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react",
|
||||
"paths": {
|
||||
"@atlaskit/tree": ["atlaskit__tree"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "atlaskit__tree-tests.tsx"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -92,7 +92,7 @@ declare namespace Backbone {
|
||||
}
|
||||
|
||||
interface EventsHash {
|
||||
[selector: string]: string | {(eventObject: JQueryEventObject): void};
|
||||
[selector: string]: string | {(eventObject: JQuery.TriggeredEvent): void};
|
||||
}
|
||||
|
||||
export const Events: Events;
|
||||
|
||||
@@ -6,7 +6,6 @@ const result: Database.RunResult = { changes: 1, lastInsertRowid: 1 };
|
||||
const options: Database.Options = { fileMustExist: true, memory: true, readonly: true };
|
||||
const registrationOptions: Database.RegistrationOptions = {
|
||||
deterministic: true,
|
||||
name: '',
|
||||
safeIntegers: true,
|
||||
varargs: true
|
||||
};
|
||||
@@ -15,26 +14,49 @@ let db = Database('.');
|
||||
db = new Database('.', { memory: true });
|
||||
db.exec('CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL);');
|
||||
db.exec('INSERT INTO test(name) VALUES("name");');
|
||||
db.pragma('data_version', true);
|
||||
db.pragma('data_version', { simple: true });
|
||||
db.checkpoint();
|
||||
db.checkpoint('main');
|
||||
db.register(() => { });
|
||||
db.register({ name: 'noop', deterministic: true, varargs: true }, () => { });
|
||||
db.function('noop', () => { });
|
||||
db.function('noop', { deterministic: true, varargs: true }, () => { });
|
||||
db.aggregate('add', {
|
||||
start: 0,
|
||||
step: (t, n) => t + n,
|
||||
deterministic: true,
|
||||
varargs: true
|
||||
});
|
||||
db.aggregate('getAverage', {
|
||||
start: () => [],
|
||||
step: (array, nextValue) => {
|
||||
array.push(nextValue);
|
||||
},
|
||||
result: array => array.reduce((t: any, v: any) => t + v) / array.length,
|
||||
});
|
||||
db.aggregate('addAll', {
|
||||
start: 0,
|
||||
step: (total, nextValue) => total + nextValue,
|
||||
inverse: (total, droppedValue) => total - droppedValue,
|
||||
result: total => Math.round(total),
|
||||
});
|
||||
db.defaultSafeIntegers();
|
||||
db.defaultSafeIntegers(true);
|
||||
|
||||
const stmt = db.prepare('SELECT * FROM test WHERE name == ?;');
|
||||
stmt.get(['name']);
|
||||
stmt.all({ name: 'name' });
|
||||
stmt.each('name', (row: { name: string }) => { });
|
||||
stmt.each((row: { name: string }) => { });
|
||||
for (const row of stmt.iterate('name')) {
|
||||
}
|
||||
stmt.pluck();
|
||||
stmt.pluck(true);
|
||||
stmt.expand();
|
||||
stmt.expand(true);
|
||||
stmt.bind('name');
|
||||
stmt.safeIntegers();
|
||||
stmt.safeIntegers(true);
|
||||
|
||||
const trans = db.transaction(['INSERT INTO test(name) VALUES(?);']);
|
||||
trans.run('name');
|
||||
trans.bind('name');
|
||||
trans.run();
|
||||
const trans = db.transaction((param) => stmt.all(param));
|
||||
trans('name');
|
||||
trans.default('name');
|
||||
trans.deferred('name');
|
||||
trans.immediate('name');
|
||||
trans.exclusive('name');
|
||||
|
||||
Vendored
+29
-22
@@ -3,35 +3,32 @@
|
||||
// Definitions by: Ben Davies <https://github.com/Morfent>
|
||||
// Mathew Rumsey <https://github.com/matrumz>
|
||||
// Santiago Aguilar <https://github.com/sant123>
|
||||
// Alessandro Vergani <https://github.com/loghorn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import Integer = require("integer");
|
||||
|
||||
declare class Statement {
|
||||
interface Statement {
|
||||
database: Database;
|
||||
source: string;
|
||||
returnsData: boolean;
|
||||
constructor(db: Database, sources: string[]);
|
||||
reader: boolean;
|
||||
|
||||
run(...params: any[]): Database.RunResult;
|
||||
get(...params: any[]): any;
|
||||
all(...params: any[]): any[];
|
||||
each(params: any, cb: (row: any) => void): void;
|
||||
each(cb: (row: any) => void): void;
|
||||
each(...params: any[]): void;
|
||||
iterate(...params: any[]): IterableIterator<any>;
|
||||
pluck(toggleState?: boolean): this;
|
||||
expand(toggleState?: boolean): this;
|
||||
bind(...params: any[]): this;
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
declare class Transaction {
|
||||
database: Database;
|
||||
source: string;
|
||||
constructor(db: Database, sources: string[]);
|
||||
|
||||
run(...params: any[]): Database.RunResult;
|
||||
bind(...params: any[]): this;
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
interface Transaction {
|
||||
(...params: any[]): any;
|
||||
default(...params: any[]): any;
|
||||
deferred(...params: any[]): any;
|
||||
immediate(...params: any[]): any;
|
||||
exclusive(...params: any[]): any;
|
||||
}
|
||||
|
||||
interface Database {
|
||||
@@ -42,15 +39,14 @@ interface Database {
|
||||
inTransaction: boolean;
|
||||
|
||||
prepare(source: string): Statement;
|
||||
transaction(sources: string[]): Transaction;
|
||||
transaction(fn: (...params: any[]) => any): Transaction;
|
||||
exec(source: string): this;
|
||||
pragma(source: string, simplify?: boolean): any;
|
||||
pragma(source: string, options?: Database.PragmaOptions): any;
|
||||
checkpoint(databaseName?: string): this;
|
||||
register(cb: (...params: any[]) => any): this;
|
||||
register(
|
||||
options: Database.RegistrationOptions,
|
||||
cb: (...params: any[]) => any
|
||||
): this;
|
||||
function(name: string, cb: (...params: any[]) => any): this;
|
||||
function(name: string, options: Database.RegistrationOptions, cb: (...params: any[]) => any): this;
|
||||
aggregate(name: string, options: Database.AggregateOptions): this;
|
||||
loadExtension(path: string): this;
|
||||
close(): this;
|
||||
defaultSafeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
@@ -81,14 +77,25 @@ declare namespace Database {
|
||||
memory?: boolean;
|
||||
readonly?: boolean;
|
||||
fileMustExist?: boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
interface PragmaOptions {
|
||||
simple?: boolean;
|
||||
}
|
||||
|
||||
interface RegistrationOptions {
|
||||
name?: string;
|
||||
varargs?: boolean;
|
||||
deterministic?: boolean;
|
||||
safeIntegers?: boolean;
|
||||
}
|
||||
|
||||
interface AggregateOptions extends RegistrationOptions {
|
||||
start?: any;
|
||||
step: (total: any, next: any) => any;
|
||||
inverse?: (total: any, dropped: any) => any;
|
||||
result?: (total: any) => any;
|
||||
}
|
||||
}
|
||||
|
||||
declare const Database: DatabaseConstructor;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
@@ -20,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"better-sqlite3-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import binVersion = require('bin-version');
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
binVersion('curl');
|
||||
// $ExpectType Promise<string>
|
||||
binVersion('openssl', { args: ['version'] });
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for bin-version 3.0
|
||||
// Project: https://github.com/sindresorhus/bin-version#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = binVersion;
|
||||
|
||||
declare function binVersion(binary: string, options?: binVersion.Options): Promise<string>;
|
||||
|
||||
declare namespace binVersion {
|
||||
interface Options {
|
||||
args?: string[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bin-version-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -93,3 +93,28 @@ const parser5 = new Parser()
|
||||
length: '4',
|
||||
formatter: (arr) => { }
|
||||
});
|
||||
|
||||
const parser6 = new Parser()
|
||||
.nest("nested", {
|
||||
type: new Parser()
|
||||
.array("points", {
|
||||
type: new Parser()
|
||||
.uint8("x")
|
||||
.uint8("y"),
|
||||
length: 2
|
||||
})
|
||||
})
|
||||
.choice("optional", {
|
||||
tag: "nested.points[0].x",
|
||||
choices: {
|
||||
1: new Parser()
|
||||
.uint8("number")
|
||||
}
|
||||
});
|
||||
|
||||
const result = parser6.parse(Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]));
|
||||
|
||||
// See the inferred static types on the IntelliSense.
|
||||
result.nested.points[0].x;
|
||||
result.nested.points[1].y;
|
||||
result.optional.number;
|
||||
|
||||
Vendored
+108
-79
@@ -1,88 +1,117 @@
|
||||
// Type definitions for binary-parser 1.3
|
||||
// Project: https://github.com/keichi/binary-parser
|
||||
// Definitions by: Benjamin Riggs <https://github.com/riggs>, Dolan Miu <https://github.com/dolanmiu>
|
||||
// Definitions by: Benjamin Riggs <https://github.com/riggs>,
|
||||
// Dolan Miu <https://github.com/dolanmiu>,
|
||||
// Yu Shimura <https://github.com/yuhr>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Parser {
|
||||
parse(buffer: Buffer, callback?: (err?: Error, result?: any) => void): Parser.Parsed;
|
||||
export interface Parser<O extends object | undefined = undefined> {
|
||||
parse(buffer: Buffer, callback?: (err?: Error, result?: any) => void): Parser.Parsed<O>;
|
||||
|
||||
create(constructorFunction: ObjectConstructor): Parser;
|
||||
|
||||
int8(name: string, options?: Parser.Options): Parser;
|
||||
uint8(name: string, options?: Parser.Options): Parser;
|
||||
int8<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint8<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
|
||||
int16(name: string, options?: Parser.Options): Parser;
|
||||
uint16(name: string, options?: Parser.Options): Parser;
|
||||
int16le(name: string, options?: Parser.Options): Parser;
|
||||
int16be(name: string, options?: Parser.Options): Parser;
|
||||
uint16le(name: string, options?: Parser.Options): Parser;
|
||||
uint16be(name: string, options?: Parser.Options): Parser;
|
||||
int16<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint16<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
int16le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
int16be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint16le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint16be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
|
||||
int32(name: string, options?: Parser.Options): Parser;
|
||||
uint32(name: string, options?: Parser.Options): Parser;
|
||||
int32le(name: string, options?: Parser.Options): Parser;
|
||||
int32be(name: string, options?: Parser.Options): Parser;
|
||||
uint32le(name: string, options?: Parser.Options): Parser;
|
||||
uint32be(name: string, options?: Parser.Options): Parser;
|
||||
int32<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint32<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
int32le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
int32be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint32le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
uint32be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
|
||||
bit1(name: string, options?: Parser.Options): Parser;
|
||||
bit2(name: string, options?: Parser.Options): Parser;
|
||||
bit3(name: string, options?: Parser.Options): Parser;
|
||||
bit4(name: string, options?: Parser.Options): Parser;
|
||||
bit5(name: string, options?: Parser.Options): Parser;
|
||||
bit6(name: string, options?: Parser.Options): Parser;
|
||||
bit7(name: string, options?: Parser.Options): Parser;
|
||||
bit8(name: string, options?: Parser.Options): Parser;
|
||||
bit9(name: string, options?: Parser.Options): Parser;
|
||||
bit10(name: string, options?: Parser.Options): Parser;
|
||||
bit11(name: string, options?: Parser.Options): Parser;
|
||||
bit12(name: string, options?: Parser.Options): Parser;
|
||||
bit13(name: string, options?: Parser.Options): Parser;
|
||||
bit14(name: string, options?: Parser.Options): Parser;
|
||||
bit15(name: string, options?: Parser.Options): Parser;
|
||||
bit16(name: string, options?: Parser.Options): Parser;
|
||||
bit17(name: string, options?: Parser.Options): Parser;
|
||||
bit18(name: string, options?: Parser.Options): Parser;
|
||||
bit19(name: string, options?: Parser.Options): Parser;
|
||||
bit20(name: string, options?: Parser.Options): Parser;
|
||||
bit21(name: string, options?: Parser.Options): Parser;
|
||||
bit22(name: string, options?: Parser.Options): Parser;
|
||||
bit23(name: string, options?: Parser.Options): Parser;
|
||||
bit24(name: string, options?: Parser.Options): Parser;
|
||||
bit25(name: string, options?: Parser.Options): Parser;
|
||||
bit26(name: string, options?: Parser.Options): Parser;
|
||||
bit27(name: string, options?: Parser.Options): Parser;
|
||||
bit28(name: string, options?: Parser.Options): Parser;
|
||||
bit29(name: string, options?: Parser.Options): Parser;
|
||||
bit30(name: string, options?: Parser.Options): Parser;
|
||||
bit31(name: string, options?: Parser.Options): Parser;
|
||||
bit32(name: string, options?: Parser.Options): Parser;
|
||||
bit1<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit2<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit3<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit4<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit5<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit6<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit7<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit8<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit9<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit10<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit11<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit12<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit13<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit14<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit15<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit16<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit17<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit18<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit19<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit20<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit21<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit22<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit23<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit24<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit25<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit26<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit27<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit28<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit29<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit30<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit31<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
bit32<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
|
||||
float(name: string, options?: Parser.Options): Parser;
|
||||
floatle(name: string, options?: Parser.Options): Parser;
|
||||
floatbe(name: string, options?: Parser.Options): Parser;
|
||||
float<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
floatle<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
floatbe<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
|
||||
double(name: string, options?: Parser.Options): Parser;
|
||||
doublele(name: string, options?: Parser.Options): Parser;
|
||||
doublebe(name: string, options?: Parser.Options): Parser;
|
||||
double<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
doublele<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
doublebe<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
|
||||
|
||||
string(name: string, options?: Parser.StringOptions): Parser;
|
||||
string<N extends string>(name: N, options?: Parser.StringOptions): Parser.Next<O, N, string>;
|
||||
|
||||
buffer(name: string, options: Parser.BufferOptions): Parser;
|
||||
buffer<N extends string>(name: N, options: Parser.BufferOptions): Parser.Next<O, N, Buffer>;
|
||||
|
||||
array(name: string, options: Parser.ArrayOptions): Parser;
|
||||
array<N extends string, Q extends Parser.ArrayOptions>(name: N, options: Q): Parser.Next<O, N,
|
||||
Q extends { type: infer T }
|
||||
? T extends Parser<infer O>
|
||||
? O extends undefined ? Array<{}> : O[]
|
||||
: T extends string
|
||||
? number[]
|
||||
: never
|
||||
: never
|
||||
>;
|
||||
|
||||
choice(name: string, options: Parser.ChoiceOptions): Parser;
|
||||
choice<N extends string, Q extends Parser.ChoiceOptions>(name: N, options: Q): Parser.Next<O, N,
|
||||
Q extends {
|
||||
choices: infer C
|
||||
}
|
||||
? C extends {
|
||||
[key in keyof C]: infer T
|
||||
}
|
||||
? T extends Parser<infer O>
|
||||
? O extends undefined ? {} : O
|
||||
: T extends string ? any : never
|
||||
: never
|
||||
: never
|
||||
>;
|
||||
|
||||
nest(name: string, options: Parser.NestOptions): Parser;
|
||||
nest<N extends string, Q extends Parser.NestOptions>(name: N, options: Q): Parser.Next<O, N,
|
||||
Q extends { type: infer T }
|
||||
? T extends Parser<infer O>
|
||||
? O extends undefined ? {} : O
|
||||
: never
|
||||
: never
|
||||
>;
|
||||
|
||||
skip(length: number): Parser;
|
||||
skip(length: number): Parser<O>;
|
||||
|
||||
endianess(endianess: Parser.Endianness): Parser; /* [sic] */
|
||||
endianess(endianess: Parser.Endianness): Parser<O>; /* [sic] */
|
||||
|
||||
namely(alias: string): Parser;
|
||||
namely(alias: string): Parser<O>;
|
||||
|
||||
compile(): void;
|
||||
|
||||
@@ -96,10 +125,8 @@ export interface ParserConstructor {
|
||||
export const Parser: ParserConstructor;
|
||||
|
||||
export namespace Parser {
|
||||
type Data = number | string | Array<number | Parsed> | Parsed | Buffer;
|
||||
interface Parsed {
|
||||
[name: string]: Data;
|
||||
}
|
||||
type Data = number | string | Array<number | Parser<any>> | Parser<any> | Buffer;
|
||||
type Parsed<O extends object | undefined> = O extends undefined ? {} : O;
|
||||
|
||||
interface Options {
|
||||
formatter?: ((value: Data) => any);
|
||||
@@ -108,7 +135,7 @@ export namespace Parser {
|
||||
|
||||
interface StringOptions extends Options {
|
||||
encoding?: string;
|
||||
length?: number | string | ((this: Parsed) => number);
|
||||
length?: number | string | ((this: Parser<any>) => number);
|
||||
zeroTerminated?: boolean;
|
||||
greedy?: boolean;
|
||||
stripNull?: boolean;
|
||||
@@ -116,32 +143,34 @@ export namespace Parser {
|
||||
|
||||
interface BufferOptions extends Options {
|
||||
clone?: boolean;
|
||||
length?: number | string | ((this: Parsed) => number);
|
||||
length?: number | string | ((this: Parser<any>) => number);
|
||||
readUntil?: string | ((item: number, buffer: Buffer) => boolean);
|
||||
}
|
||||
|
||||
interface ArrayOptions extends Options {
|
||||
type: string | Parser;
|
||||
length?: number | string | ((this: Parsed) => number);
|
||||
lengthInBytes?: number | string | ((this: Parsed) => number);
|
||||
type: string | Parser<any>;
|
||||
length?: number | string | ((this: Parser<any>) => number);
|
||||
lengthInBytes?: number | string | ((this: Parser<any>) => number);
|
||||
readUntil?: string | ((item: number, buffer: Buffer) => boolean);
|
||||
}
|
||||
|
||||
interface ChoiceOptions extends Options {
|
||||
tag: string | ((this: Parsed) => number);
|
||||
choices: { [item: number]: Parser | string };
|
||||
defaultChoice?: Parser | string;
|
||||
tag: string | ((this: Parser<any>) => number);
|
||||
choices: { [item: number]: Parser<any> | string };
|
||||
defaultChoice?: Parser<any> | string;
|
||||
}
|
||||
|
||||
interface NestOptions extends Options {
|
||||
type: Parser | string;
|
||||
type: Parser<any>;
|
||||
}
|
||||
|
||||
type Endianness =
|
||||
'little' |
|
||||
'big';
|
||||
|
||||
interface Context {
|
||||
[name: string]: Parsed;
|
||||
}
|
||||
type Valid<O extends object | undefined, P extends object> =
|
||||
O extends undefined ? P : O & P;
|
||||
|
||||
type Next<O extends object | undefined, N extends string, T extends any> =
|
||||
Parser<Valid<O, { [name in N]: T }>>;
|
||||
}
|
||||
|
||||
Vendored
+190
-91
@@ -35,7 +35,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
type CatchFilter<E> = (new (...args: any[]) => E) | ((error: E) => boolean) | (object & E);
|
||||
type Constructor<E> = new (...args: any[]) => E;
|
||||
type CatchFilter<E> = ((error: E) => boolean) | (object & E);
|
||||
type IterableItem<R> = R extends Iterable<infer U> ? U : never;
|
||||
type IterableOrNever<R> = Extract<R, Iterable<any>>;
|
||||
type Resolvable<R> = R | PromiseLike<R>;
|
||||
@@ -85,69 +86,74 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<E1, E2, E3, E4, E5>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter4: CatchFilter<E4>,
|
||||
filter5: CatchFilter<E5>,
|
||||
onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<R>,
|
||||
): Bluebird<R>;
|
||||
catch<U, E1, E2, E3, E4, E5>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter4: CatchFilter<E4>,
|
||||
filter5: CatchFilter<E5>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
filter3: Constructor<E3>,
|
||||
filter4: Constructor<E4>,
|
||||
filter5: Constructor<E5>,
|
||||
onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<E1, E2, E3, E4>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter4: CatchFilter<E4>,
|
||||
onReject: (error: E1 | E2 | E3 | E4) => Resolvable<R>,
|
||||
): Bluebird<R>;
|
||||
catch<U, E1, E2, E3, E4, E5>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
filter3: Constructor<E3> | CatchFilter<E3>,
|
||||
filter4: Constructor<E4> | CatchFilter<E4>,
|
||||
filter5: Constructor<E5> | CatchFilter<E5>,
|
||||
onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<U, E1, E2, E3, E4>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter4: CatchFilter<E4>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
filter3: Constructor<E3>,
|
||||
filter4: Constructor<E4>,
|
||||
onReject: (error: E1 | E2 | E3 | E4) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<U, E1, E2, E3, E4>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
filter3: Constructor<E3> | CatchFilter<E3>,
|
||||
filter4: Constructor<E4> | CatchFilter<E4>,
|
||||
onReject: (error: E1 | E2 | E3 | E4) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<E1, E2, E3>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
onReject: (error: E1 | E2 | E3) => Resolvable<R>,
|
||||
): Bluebird<R>;
|
||||
catch<U, E1, E2, E3>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
filter3: Constructor<E3>,
|
||||
onReject: (error: E1 | E2 | E3) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<U, E1, E2, E3>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
filter3: Constructor<E3> | CatchFilter<E3>,
|
||||
onReject: (error: E1 | E2 | E3) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<E1, E2>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
onReject: (error: E1 | E2) => Resolvable<R>,
|
||||
): Bluebird<R>;
|
||||
catch<U, E1, E2>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
onReject: (error: E1 | E2) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<U, E1, E2>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
onReject: (error: E1 | E2) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<E1>(
|
||||
filter1: CatchFilter<E1>,
|
||||
onReject: (error: E1) => Resolvable<R>,
|
||||
): Bluebird<R>;
|
||||
catch<U, E1>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter1: Constructor<E1>,
|
||||
onReject: (error: E1) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
catch<U, E1>(
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
onReject: (error: E1) => Resolvable<U>,
|
||||
): Bluebird<U | R>;
|
||||
|
||||
@@ -201,33 +207,64 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
|
||||
tapCatch(onReject: (error?: any) => Resolvable<any>): Bluebird<R>;
|
||||
|
||||
tapCatch<E1, E2, E3, E4, E5>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter4: CatchFilter<E4>,
|
||||
filter5: CatchFilter<E5>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
filter3: Constructor<E3>,
|
||||
filter4: Constructor<E4>,
|
||||
filter5: Constructor<E5>,
|
||||
onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2, E3, E4, E5>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
filter3: Constructor<E3> | CatchFilter<E3>,
|
||||
filter4: Constructor<E4> | CatchFilter<E4>,
|
||||
filter5: Constructor<E5> | CatchFilter<E5>,
|
||||
onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2, E3, E4>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter4: CatchFilter<E4>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
filter3: Constructor<E3>,
|
||||
filter4: Constructor<E4>,
|
||||
onReject: (error: E1 | E2 | E3 | E4) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2, E3, E4>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
filter3: Constructor<E3> | CatchFilter<E3>,
|
||||
filter4: Constructor<E4> | CatchFilter<E4>,
|
||||
onReject: (error: E1 | E2 | E3 | E4) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2, E3>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter3: CatchFilter<E3>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
filter3: Constructor<E3>,
|
||||
onReject: (error: E1 | E2 | E3) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2, E3>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
filter3: Constructor<E3> | CatchFilter<E3>,
|
||||
onReject: (error: E1 | E2 | E3) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter2: CatchFilter<E2>,
|
||||
filter1: Constructor<E1>,
|
||||
filter2: Constructor<E2>,
|
||||
onReject: (error: E1 | E2) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1, E2>(
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
filter2: Constructor<E2> | CatchFilter<E2>,
|
||||
onReject: (error: E1 | E2) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1>(
|
||||
filter1: CatchFilter<E1>,
|
||||
filter1: Constructor<E1>,
|
||||
onReject: (error: E1) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
tapCatch<E1>(
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
filter1: Constructor<E1> | CatchFilter<E1>,
|
||||
onReject: (error: E1) => Resolvable<any>,
|
||||
): Bluebird<R>;
|
||||
|
||||
@@ -376,33 +413,64 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
|
||||
|
||||
// No need to be specific about Error types in these overrides, since there's no handler function
|
||||
catchReturn<U>(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter3: CatchFilter<Error>,
|
||||
filter4: CatchFilter<Error>,
|
||||
filter5: CatchFilter<Error>,
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
filter3: Constructor<Error>,
|
||||
filter4: Constructor<Error>,
|
||||
filter5: Constructor<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter3: CatchFilter<Error>,
|
||||
filter4: CatchFilter<Error>,
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
filter3: Constructor<Error> | CatchFilter<Error>,
|
||||
filter4: Constructor<Error> | CatchFilter<Error>,
|
||||
filter5: Constructor<Error> | CatchFilter<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter3: CatchFilter<Error>,
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
filter3: Constructor<Error>,
|
||||
filter4: Constructor<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
filter3: Constructor<Error> | CatchFilter<Error>,
|
||||
filter4: Constructor<Error> | CatchFilter<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
filter3: Constructor<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
filter3: Constructor<Error> | CatchFilter<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
filter1: Constructor<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
catchReturn<U>(
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
value: U,
|
||||
): Bluebird<R | U>;
|
||||
|
||||
@@ -420,33 +488,64 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
|
||||
|
||||
// No need to be specific about Error types in these overrides, since there's no handler function
|
||||
catchThrow(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter3: CatchFilter<Error>,
|
||||
filter4: CatchFilter<Error>,
|
||||
filter5: CatchFilter<Error>,
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
filter3: Constructor<Error>,
|
||||
filter4: Constructor<Error>,
|
||||
filter5: Constructor<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter3: CatchFilter<Error>,
|
||||
filter4: CatchFilter<Error>,
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
filter3: Constructor<Error> | CatchFilter<Error>,
|
||||
filter4: Constructor<Error> | CatchFilter<Error>,
|
||||
filter5: Constructor<Error> | CatchFilter<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter3: CatchFilter<Error>,
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
filter3: Constructor<Error>,
|
||||
filter4: Constructor<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter2: CatchFilter<Error>,
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
filter3: Constructor<Error> | CatchFilter<Error>,
|
||||
filter4: Constructor<Error> | CatchFilter<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: CatchFilter<Error>,
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
filter3: Constructor<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
filter3: Constructor<Error> | CatchFilter<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: Constructor<Error>,
|
||||
filter2: Constructor<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
filter2: Constructor<Error> | CatchFilter<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
filter1: Constructor<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
catchThrow(
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
filter1: Constructor<Error> | CatchFilter<Error>,
|
||||
reason: Error,
|
||||
): Bluebird<R>;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ $(() => {
|
||||
|
||||
$('#ex7').slider();
|
||||
|
||||
$('#ex7-enabled').click(function(this: HTMLInputElement) {
|
||||
$<HTMLInputElement>('#ex7-enabled').click(function() {
|
||||
if (this.checked) {
|
||||
// With JQuery
|
||||
$('#ex7').slider('enable');
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+7
-2
@@ -322,7 +322,7 @@ export interface TooltipOption {
|
||||
// Events
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
export interface CarouselEventHandler<TElement> extends JQuery.Event<TElement, undefined> {
|
||||
export interface CarouselEventHandler<TElement> extends JQuery.TriggeredEvent<TElement, undefined> {
|
||||
/**
|
||||
* The direction in which the carousel is sliding.
|
||||
*/
|
||||
@@ -339,6 +339,10 @@ export interface CarouselEventHandler<TElement> extends JQuery.Event<TElement, u
|
||||
to: number;
|
||||
}
|
||||
|
||||
export interface TapEventHandler<TElement> extends JQuery.TriggeredEvent<TElement, undefined> {
|
||||
relatedTarget: HTMLElement;
|
||||
}
|
||||
|
||||
export type AlertEvent = "close.bs.alert" | "closed.bs.alert";
|
||||
export type CarouselEvent = "slide.bs.carousel" | "slid.bs.carousel";
|
||||
export type CollapseEvent = "show.bs.collapse" | "shown.bs.collapse" | "hide.bs.collapse" | "hidden.bs.collapse";
|
||||
@@ -383,9 +387,10 @@ declare global {
|
||||
tooltip(options?: TooltipOption): this;
|
||||
|
||||
on(events: CarouselEvent, handler: JQuery.EventHandlerBase<TElement, CarouselEventHandler<TElement>>): this;
|
||||
on(events: TapEvent, handler: JQuery.EventHandlerBase<TElement, TapEventHandler<TElement>>): this;
|
||||
on(events:
|
||||
AlertEvent | CollapseEvent | DropdownEvent | ModalEvent |
|
||||
PopoverEvent | ScrollspyEvent | TapEvent | TooltipEvent,
|
||||
PopoverEvent | ScrollspyEvent | TooltipEvent,
|
||||
handler: JQuery.EventHandler<TElement>): this;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bull 3.4
|
||||
// Type definitions for bull 3.5
|
||||
// Project: https://github.com/OptimalBits/bull
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
||||
// Cameron Crothers <https://github.com/JProgrammer>
|
||||
@@ -17,7 +17,6 @@
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as Redis from "ioredis";
|
||||
import * as Promise from "bluebird";
|
||||
|
||||
/**
|
||||
* This is the Queue constructor.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import cachedPathRelative = require("cached-path-relative");
|
||||
|
||||
function browserifyTest() {
|
||||
const file = "file.txt";
|
||||
const m1: string = cachedPathRelative("./", file).replace(/\\/g, '/');
|
||||
return m1;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for cached-path-relative 1.0
|
||||
// Project: https://github.com/ashaffer/cached-path-relative
|
||||
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Memoize the results of the path.relative function. path.relative can be an expensive operation
|
||||
* if it happens a lot, and its results shouldn't change for the same arguments.
|
||||
* Use it just like your normal path.relative, but it's memoized.
|
||||
*/
|
||||
declare function cachedPathRelative(from: string, to: string): string;
|
||||
|
||||
export = cachedPathRelative;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cached-path-relative-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
agents, features, feature, Agent, Feature, PackedFeature, StatsByAgentID, SupportStatusByVersion, SupportStatus
|
||||
} from "caniuse-lite";
|
||||
|
||||
const chrome: Agent | undefined = agents.chrome;
|
||||
if (chrome !== undefined) {
|
||||
const browser: string = chrome.browser;
|
||||
const prefix: string = chrome.prefix;
|
||||
const prefixExceptions: any = chrome.prefix_exceptions;
|
||||
const usageGlobal: { [version: string]: number | undefined } = chrome.usage_global;
|
||||
const releaseDate: { [version: string]: number | undefined } = chrome.release_date;
|
||||
const versions: Array<string | null> = chrome.versions;
|
||||
consume(browser, prefix, prefixExceptions, usageGlobal, releaseDate, versions);
|
||||
}
|
||||
|
||||
const unpackedFeatures = Object.keys(features).map((id: string) => {
|
||||
const packed: PackedFeature = features[id];
|
||||
const unpacked: Feature = feature(packed);
|
||||
|
||||
const status: string = unpacked.status;
|
||||
const title: string = unpacked.title;
|
||||
const stats: StatsByAgentID = unpacked.stats;
|
||||
Object.keys(stats).forEach((agentID: string) => {
|
||||
const byVersion: SupportStatusByVersion = stats[agentID];
|
||||
Object.keys(byVersion).forEach(version => {
|
||||
const supportStatus: SupportStatus = byVersion[version];
|
||||
consume(supportStatus);
|
||||
});
|
||||
|
||||
const supportStatusByVersion: SupportStatusByVersion = stats[agentID];
|
||||
const agent: Agent = agents[agentID]!;
|
||||
return {
|
||||
feature: unpacked,
|
||||
agent,
|
||||
versions: Object.keys(supportStatusByVersion).map(version => {
|
||||
return {
|
||||
version,
|
||||
releaseDate: agent.release_date[version],
|
||||
[`feature_${id}`]: supportStatusByVersion[version]
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
function consume(...anything: any[]): void {
|
||||
// ...
|
||||
}
|
||||
Vendored
+159
@@ -0,0 +1,159 @@
|
||||
// Type definitions for caniuse-lite 1.0
|
||||
// Project: https://github.com/ben-eb/caniuse-lite#readme
|
||||
// Definitions by: Michael Utech <https://github.com/mutech>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/**
|
||||
* Information about user agents (browsers, platforms) indexed by their ID.
|
||||
*/
|
||||
export const agents: AgentsByID;
|
||||
|
||||
/**
|
||||
* Features index by their ID. The feature ID is a human readable identifier. The
|
||||
* associated value is a packed version of information about the feature that
|
||||
* can be unpacked using the function `feature(packed)`
|
||||
*/
|
||||
export const features: { [featureID: string]: PackedFeature; };
|
||||
|
||||
/**
|
||||
* @param packedFeature a packed feature obtained from `features[key]` for some valid key.
|
||||
* @return the unpacked information as `Feature`.
|
||||
*/
|
||||
export function feature(packedFeature: PackedFeature): Feature;
|
||||
|
||||
/**
|
||||
* @param packedRegion a packed version of regional usage data by agent OD.
|
||||
* @return the unpacked usage data indexed by agent ID and then version.
|
||||
*/
|
||||
export function region(packedRegion: PackedRegion): { [agentID: string]: UsageByVersion };
|
||||
|
||||
/**
|
||||
* Agents indexed by their ID. .
|
||||
*/
|
||||
export type AgentsByID = Readonly<{ [id: string]: Readonly<Agent> | undefined }>;
|
||||
|
||||
/**
|
||||
* Feature support status by version indexed by agent ID.
|
||||
*/
|
||||
export type StatsByAgentID = Readonly<{ [agentID: string]: SupportStatusByVersion }>;
|
||||
|
||||
/**
|
||||
* Feature support status indexed by an agent's versions.
|
||||
*/
|
||||
export type SupportStatusByVersion = Readonly<{ [version: string]: SupportStatus }>;
|
||||
|
||||
/**
|
||||
* Usage (percentage/market share) indexed by an agent's versions.
|
||||
*/
|
||||
export type UsageByVersion = Readonly<{ [version: string]: number | undefined }>;
|
||||
|
||||
/**
|
||||
* The standardization status of a feature:
|
||||
* * ls - WHATWG living standard
|
||||
* * rec - W3C recommendation
|
||||
* * pr - W3C proposed recommendation
|
||||
* * cr - W3C candidate recommendation
|
||||
* * wd - W3C working draft
|
||||
* * other - Non-W3C, but reputable
|
||||
* * unoff - Unofficial
|
||||
*/
|
||||
export type FeatureStatus = "ls" | "rec" | "pr" | "cr" | "wd" | "other" | "unoff" | string;
|
||||
|
||||
/**
|
||||
* Encoded support status:
|
||||
* * `n` - not supported
|
||||
* * `p` - not supported, polyfill available
|
||||
* * `u` - unknown
|
||||
* * `a x` - partially supported, vendor prefix
|
||||
* * `a` - partially supported
|
||||
* * `y x` - fully supported, vendor prefix
|
||||
* * `y` - fully supported
|
||||
*
|
||||
* The support status can additionally have one or more footnote references as `#<n>`, f.e.
|
||||
* `a x #1 #3`.
|
||||
*/
|
||||
export type SupportStatus = 'n' | 'p' | 'u' | "a x" | 'a' | "y x" | 'y' | string;
|
||||
|
||||
/**
|
||||
* Provides information about the Agent.
|
||||
*/
|
||||
export interface Agent {
|
||||
/**
|
||||
* Global agent usage by version
|
||||
*/
|
||||
usage_global: UsageByVersion;
|
||||
|
||||
/**
|
||||
* The agents vendor prefix
|
||||
*/
|
||||
prefix: string;
|
||||
|
||||
/**
|
||||
* Version matrix. See [caniuse](https://caniuse.com)
|
||||
*/
|
||||
versions: [ // Tuple of 70 version slots:
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null,
|
||||
string|null, string|null, string|null, string|null, string|null ];
|
||||
|
||||
/**
|
||||
* The agent's name
|
||||
*/
|
||||
browser: string;
|
||||
|
||||
/**
|
||||
* Release dates as seconds since epoch by version.
|
||||
*/
|
||||
release_date: { [version: string]: number | undefined };
|
||||
|
||||
/**
|
||||
* Exceptions to vendor prefix use.
|
||||
*/
|
||||
prefix_exceptions?: { [version: string]: string | undefined };
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies a feature and its support status in all known agent versions.
|
||||
*/
|
||||
export interface Feature {
|
||||
/**
|
||||
* Specification status of the feature.
|
||||
*/
|
||||
status: FeatureStatus;
|
||||
|
||||
/**
|
||||
* Descriptive title of the feature.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Agent support matrix for this feature.
|
||||
*/
|
||||
stats: StatsByAgentID;
|
||||
}
|
||||
|
||||
/**
|
||||
* A space optimized version of Feature that can be unpacked using `feature(PackedFeature)`.
|
||||
*/
|
||||
export interface PackedFeature {
|
||||
[encodedKey: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* A space optimized version of Region that can be unpacked using `region(PackedFeature)`.
|
||||
*/
|
||||
export interface PackedRegion {
|
||||
[encodedKey: string]: any;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"caniuse-lite-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as cfn from "cfn-response";
|
||||
import { CloudFormationCustomResourceEvent, Context } from "aws-lambda";
|
||||
|
||||
declare const event: CloudFormationCustomResourceEvent;
|
||||
declare const context: Context;
|
||||
|
||||
// $ExpectType void
|
||||
cfn.send(event, context, cfn.SUCCESS, { sample: 123 }, "abc");
|
||||
// $ExpectType void
|
||||
cfn.send(event, context, "SUCCESS");
|
||||
// $ExpectError
|
||||
cfn.send(event, context, "", {});
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for cfn-response 1.0
|
||||
// Project: https://github.com/LukeMizuhashi/cfn-response
|
||||
// Definitions by: Ivo Murrell <https://github.com/ivoisbelongtous>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { CloudFormationCustomResourceEvent, Context } from "aws-lambda";
|
||||
|
||||
export type ResponseStatus = "SUCCESS" | "FAILED";
|
||||
export const SUCCESS: ResponseStatus;
|
||||
export const FAILED: ResponseStatus;
|
||||
|
||||
export function send(
|
||||
event: CloudFormationCustomResourceEvent,
|
||||
context: Context,
|
||||
responseStatus: ResponseStatus,
|
||||
responseData?: object,
|
||||
physicalResourceId?: string
|
||||
): void;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cfn-response-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -9,7 +9,9 @@ const plugin = {
|
||||
}
|
||||
};
|
||||
|
||||
const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
|
||||
const ctx = new CanvasRenderingContext2D();
|
||||
|
||||
const chart: Chart = new Chart(ctx, {
|
||||
type: "bar",
|
||||
plugins: [plugin, plugin],
|
||||
data: {
|
||||
@@ -17,6 +19,8 @@ const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: "#000000",
|
||||
hoverBackgroundColor: ctx.createLinearGradient(0, 0, 0, 100),
|
||||
hoverBorderColor: ctx.createLinearGradient(0, 0, 0, 100),
|
||||
borderWidth: 1,
|
||||
label: "test",
|
||||
data: [1, null, 3]
|
||||
|
||||
Vendored
+2
-2
@@ -554,8 +554,8 @@ declare namespace Chart {
|
||||
borderSkipped?: PositionType;
|
||||
data?: Array<number | null | undefined> | ChartPoint[];
|
||||
fill?: boolean | number | string;
|
||||
hoverBackgroundColor?: string | string[];
|
||||
hoverBorderColor?: string | string[];
|
||||
hoverBackgroundColor?: ChartColor | ChartColor[];
|
||||
hoverBorderColor?: ChartColor | ChartColor[];
|
||||
hoverBorderWidth?: number | number[];
|
||||
label?: string;
|
||||
lineTension?: number;
|
||||
|
||||
+72
-75
@@ -1,92 +1,89 @@
|
||||
import { Break, BreakClip } from "./cast.framework.messages";
|
||||
|
||||
export = cast.framework.breaks;
|
||||
export as namespace breaks
|
||||
export class BreakSeekData {
|
||||
constructor(seekFrom: number, seekTo: number, breaks: Break[]);
|
||||
|
||||
declare namespace cast.framework.breaks {
|
||||
class BreakSeekData {
|
||||
constructor(seekFrom: number, seekTo: number, breaks: Break[]);
|
||||
/**
|
||||
* List of breaks
|
||||
*/
|
||||
breaks: Break[];
|
||||
|
||||
/**
|
||||
* List of breaks
|
||||
*/
|
||||
breaks: Break[];
|
||||
/**
|
||||
* Current playback time
|
||||
*/
|
||||
seekFrom: number;
|
||||
|
||||
/**
|
||||
* Current playback time
|
||||
*/
|
||||
seekFrom: number;
|
||||
/**
|
||||
* The time to seek to
|
||||
*/
|
||||
seekTo: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The time to seek to
|
||||
*/
|
||||
seekTo: number;
|
||||
}
|
||||
/** Provide context information for break clip load interceptor. */
|
||||
export class BreakClipLoadInterceptorContext {
|
||||
constructor(brk: Break);
|
||||
|
||||
/** Provide context information for break clip load interceptor. */
|
||||
class BreakClipLoadInterceptorContext {
|
||||
constructor(brk: Break);
|
||||
/**
|
||||
* The container break for the break clip
|
||||
*/
|
||||
break: Break;
|
||||
}
|
||||
|
||||
/**
|
||||
* The container break for the break clip
|
||||
*/
|
||||
break: Break;
|
||||
}
|
||||
/** Interface to manage breaks */
|
||||
export interface BreakManager {
|
||||
/**
|
||||
* Get current media break by id.
|
||||
*/
|
||||
getBreakById(id: string): Break;
|
||||
|
||||
/** Interface to manage breaks */
|
||||
interface BreakManager {
|
||||
/**
|
||||
* Get current media break by id.
|
||||
*/
|
||||
getBreakById(id: string): Break;
|
||||
/**
|
||||
* Get current media break clip by id
|
||||
*/
|
||||
getBreakClipById(id: string): BreakClip;
|
||||
|
||||
/**
|
||||
* Get current media break clip by id
|
||||
*/
|
||||
getBreakClipById(id: string): BreakClip;
|
||||
/** Get current media break clips. */
|
||||
getBreakClips(): BreakClip[];
|
||||
|
||||
/** Get current media break clips. */
|
||||
getBreakClips(): BreakClip[];
|
||||
/** Get current media breaks. */
|
||||
getBreaks(): Break[];
|
||||
|
||||
/** Get current media breaks. */
|
||||
getBreaks(): Break[];
|
||||
/** Returns true if watched breaks should be played. */
|
||||
getPlayWatchedBreak(): boolean;
|
||||
|
||||
/** Returns true if watched breaks should be played. */
|
||||
getPlayWatchedBreak(): boolean;
|
||||
/**
|
||||
* Provide an interceptor to allow developer to insert more break clips or modify current break clip before a break is started.
|
||||
* If interceptor is null it will reset the interceptor to default one.
|
||||
* By default VAST fetching and parsing logic in default interceptor.
|
||||
* So if customized interceptor is set by developer;
|
||||
* the VAST logic will be overridden and developers should implement their own VAST fetching and parsing logic in the provided interceptor.
|
||||
*/
|
||||
setBreakClipLoadInterceptor(
|
||||
interceptor: (
|
||||
breakClip: BreakClip,
|
||||
breakClipLoaderContext?: BreakClipLoadInterceptorContext
|
||||
) => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Provide an interceptor to allow developer to insert more break clips or modify current break clip before a break is started.
|
||||
* If interceptor is null it will reset the interceptor to default one.
|
||||
* By default VAST fetching and parsing logic in default interceptor.
|
||||
* So if customized interceptor is set by developer;
|
||||
* the VAST logic will be overridden and developers should implement their own VAST fetching and parsing logic in the provided interceptor.
|
||||
*/
|
||||
setBreakClipLoadInterceptor(
|
||||
interceptor: (
|
||||
breakClip: BreakClip,
|
||||
breakClipLoaderContext?: BreakClipLoadInterceptorContext
|
||||
) => void
|
||||
): void;
|
||||
/**
|
||||
* Provide an interceptor for developer to specify what breaks they want to play after seek.
|
||||
*/
|
||||
setBreakSeekInterceptor(
|
||||
seekInterceptor: (breakSeekData: BreakSeekData) => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Provide an interceptor for developer to specify what breaks they want to play after seek.
|
||||
*/
|
||||
setBreakSeekInterceptor(
|
||||
seekInterceptor: (breakSeekData: BreakSeekData) => void
|
||||
): void;
|
||||
/**
|
||||
* Set a flag to control if the watched client stitching break should be played.
|
||||
*/
|
||||
setPlayWatchedBreak(playWatchedBreak: boolean): void;
|
||||
|
||||
/**
|
||||
* Set a flag to control if the watched client stitching break should be played.
|
||||
*/
|
||||
setPlayWatchedBreak(playWatchedBreak: boolean): void;
|
||||
|
||||
/**
|
||||
* Provide an interceptor to modify VAST tracking URL before it is being sent to server.
|
||||
* The input of the interceptor is a string of the tracking URL.
|
||||
* The interceptor can either return a modified string of URL or a Promise of modified string of URL.
|
||||
* The interceptor can also return null if you want to send the tracking URL by your own code instead of by CAF.
|
||||
*/
|
||||
setVastTrackingInterceptor(
|
||||
interceptor?: (trackingUrl: string) => void
|
||||
): void;
|
||||
}
|
||||
/**
|
||||
* Provide an interceptor to modify VAST tracking URL before it is being sent to server.
|
||||
* The input of the interceptor is a string of the tracking URL.
|
||||
* The interceptor can either return a modified string of URL or a Promise of modified string of URL.
|
||||
* The interceptor can also return null if you want to send the tracking URL by your own code instead of by CAF.
|
||||
*/
|
||||
setVastTrackingInterceptor(
|
||||
interceptor?: (trackingUrl: string) => void
|
||||
): void;
|
||||
}
|
||||
|
||||
+738
-757
File diff suppressed because it is too large
Load Diff
+390
-392
@@ -4,423 +4,421 @@ import {
|
||||
Track,
|
||||
MediaStatus
|
||||
} from "./cast.framework.messages";
|
||||
export = cast.framework.events;
|
||||
|
||||
declare namespace cast.framework.events {
|
||||
type EventType =
|
||||
| "ALL"
|
||||
| "ABORT"
|
||||
| "CAN_PLAY"
|
||||
| "CAN_PLAY_THROUGH"
|
||||
| "DURATION_CHANGE"
|
||||
| "EMPTIED"
|
||||
| "ENDED"
|
||||
| "LOADED_DATA"
|
||||
| "LOADED_METADATA"
|
||||
| "LOAD_START"
|
||||
| "PAUSE"
|
||||
| "PLAY"
|
||||
| "PLAYING"
|
||||
| "PROGRESS"
|
||||
| "RATE_CHANGE"
|
||||
| "SEEKED"
|
||||
| "SEEKING"
|
||||
| "STALLED"
|
||||
| "TIME_UPDATE"
|
||||
| "SUSPEND"
|
||||
| "WAITING"
|
||||
| "BITRATE_CHANGED"
|
||||
| "BREAK_STARTED"
|
||||
| "BREAK_ENDED"
|
||||
| "BREAK_CLIP_LOADING"
|
||||
| "BREAK_CLIP_STARTED"
|
||||
| "BREAK_CLIP_ENDED"
|
||||
| "BUFFERING"
|
||||
| "CACHE_LOADED"
|
||||
| "CACHE_HIT"
|
||||
| "CACHE_INSERTED"
|
||||
| "CLIP_STARTED"
|
||||
| "CLIP_ENDED"
|
||||
| "EMSG"
|
||||
| "ERROR"
|
||||
| "ID3"
|
||||
| "MEDIA_STATUS"
|
||||
| "MEDIA_FINISHED"
|
||||
| "PLAYER_PRELOADING"
|
||||
| "PLAYER_PRELOADING_CANCELLED"
|
||||
| "PLAYER_LOAD_COMPLETE"
|
||||
| "PLAYER_LOADING"
|
||||
| "SEGMENT_DOWNLOADED"
|
||||
| "REQUEST_SEEK"
|
||||
| "REQUEST_LOAD"
|
||||
| "REQUEST_STOP"
|
||||
| "REQUEST_PAUSE"
|
||||
| "REQUEST_PLAY"
|
||||
| "REQUEST_PLAY_AGAIN"
|
||||
| "REQUEST_PLAYBACK_RATE_CHANGE"
|
||||
| "REQUEST_SKIP_AD"
|
||||
| "REQUEST_VOLUME_CHANGE"
|
||||
| "REQUEST_EDIT_TRACKS_INFO"
|
||||
| "REQUEST_EDIT_AUDIO_TRACKS"
|
||||
| "REQUEST_SET_CREDENTIALS"
|
||||
| "REQUEST_LOAD_BY_ENTITY"
|
||||
| "REQUEST_USER_ACTION"
|
||||
| "REQUEST_DISPLAY_STATUS"
|
||||
| "REQUEST_CUSTOM_COMMAND"
|
||||
| "REQUEST_FOCUS_STATE"
|
||||
| "REQUEST_QUEUE_LOAD"
|
||||
| "REQUEST_QUEUE_INSERT"
|
||||
| "REQUEST_QUEUE_UPDATE"
|
||||
| "REQUEST_QUEUE_REMOVE"
|
||||
| "REQUEST_QUEUE_REORDER"
|
||||
| "REQUEST_QUEUE_GET_ITEM_RANGE"
|
||||
| "REQUEST_QUEUE_GET_ITEMS"
|
||||
| "REQUEST_QUEUE_GET_ITEM_IDS"
|
||||
| "REQUEST_PRECACHE";
|
||||
export as namespace events
|
||||
export type EventType =
|
||||
| "ALL"
|
||||
| "ABORT"
|
||||
| "CAN_PLAY"
|
||||
| "CAN_PLAY_THROUGH"
|
||||
| "DURATION_CHANGE"
|
||||
| "EMPTIED"
|
||||
| "ENDED"
|
||||
| "LOADED_DATA"
|
||||
| "LOADED_METADATA"
|
||||
| "LOAD_START"
|
||||
| "PAUSE"
|
||||
| "PLAY"
|
||||
| "PLAYING"
|
||||
| "PROGRESS"
|
||||
| "RATE_CHANGE"
|
||||
| "SEEKED"
|
||||
| "SEEKING"
|
||||
| "STALLED"
|
||||
| "TIME_UPDATE"
|
||||
| "SUSPEND"
|
||||
| "WAITING"
|
||||
| "BITRATE_CHANGED"
|
||||
| "BREAK_STARTED"
|
||||
| "BREAK_ENDED"
|
||||
| "BREAK_CLIP_LOADING"
|
||||
| "BREAK_CLIP_STARTED"
|
||||
| "BREAK_CLIP_ENDED"
|
||||
| "BUFFERING"
|
||||
| "CACHE_LOADED"
|
||||
| "CACHE_HIT"
|
||||
| "CACHE_INSERTED"
|
||||
| "CLIP_STARTED"
|
||||
| "CLIP_ENDED"
|
||||
| "EMSG"
|
||||
| "ERROR"
|
||||
| "ID3"
|
||||
| "MEDIA_STATUS"
|
||||
| "MEDIA_FINISHED"
|
||||
| "PLAYER_PRELOADING"
|
||||
| "PLAYER_PRELOADING_CANCELLED"
|
||||
| "PLAYER_LOAD_COMPLETE"
|
||||
| "PLAYER_LOADING"
|
||||
| "SEGMENT_DOWNLOADED"
|
||||
| "REQUEST_SEEK"
|
||||
| "REQUEST_LOAD"
|
||||
| "REQUEST_STOP"
|
||||
| "REQUEST_PAUSE"
|
||||
| "REQUEST_PLAY"
|
||||
| "REQUEST_PLAY_AGAIN"
|
||||
| "REQUEST_PLAYBACK_RATE_CHANGE"
|
||||
| "REQUEST_SKIP_AD"
|
||||
| "REQUEST_VOLUME_CHANGE"
|
||||
| "REQUEST_EDIT_TRACKS_INFO"
|
||||
| "REQUEST_EDIT_AUDIO_TRACKS"
|
||||
| "REQUEST_SET_CREDENTIALS"
|
||||
| "REQUEST_LOAD_BY_ENTITY"
|
||||
| "REQUEST_USER_ACTION"
|
||||
| "REQUEST_DISPLAY_STATUS"
|
||||
| "REQUEST_CUSTOM_COMMAND"
|
||||
| "REQUEST_FOCUS_STATE"
|
||||
| "REQUEST_QUEUE_LOAD"
|
||||
| "REQUEST_QUEUE_INSERT"
|
||||
| "REQUEST_QUEUE_UPDATE"
|
||||
| "REQUEST_QUEUE_REMOVE"
|
||||
| "REQUEST_QUEUE_REORDER"
|
||||
| "REQUEST_QUEUE_GET_ITEM_RANGE"
|
||||
| "REQUEST_QUEUE_GET_ITEMS"
|
||||
| "REQUEST_QUEUE_GET_ITEM_IDS"
|
||||
| "REQUEST_PRECACHE";
|
||||
|
||||
type DetailedErrorCode =
|
||||
| "MEDIA_UNKNOWN"
|
||||
| "MEDIA_ABORTED"
|
||||
| "MEDIA_DECODE"
|
||||
| "MEDIA_NETWORK"
|
||||
| "MEDIA_SRC_NOT_SUPPORTED"
|
||||
| "SOURCE_BUFFER_FAILURE"
|
||||
| "MEDIAKEYS_UNKNOWN"
|
||||
| "MEDIAKEYS_NETWORK"
|
||||
| "MEDIAKEYS_UNSUPPORTED"
|
||||
| "MEDIAKEYS_WEBCRYPTO"
|
||||
| "NETWORK_UNKNOWN"
|
||||
| "SEGMENT_NETWORK"
|
||||
| "HLS_NETWORK_MASTER_PLAYLIST"
|
||||
| "HLS_NETWORK_PLAYLIST"
|
||||
| "HLS_NETWORK_NO_KEY_RESPONSE"
|
||||
| "HLS_NETWORK_KEY_LOAD"
|
||||
| "HLS_NETWORK_INVALID_SEGMENT"
|
||||
| "HLS_SEGMENT_PARSING"
|
||||
| "DASH_NETWORK"
|
||||
| "DASH_NO_INIT"
|
||||
| "SMOOTH_NETWORK"
|
||||
| "SMOOTH_NO_MEDIA_DATA"
|
||||
| "MANIFEST_UNKNOWN"
|
||||
| "HLS_MANIFEST_MASTER"
|
||||
| "HLS_MANIFEST_PLAYLIST"
|
||||
| "DASH_MANIFEST_UNKNOWN"
|
||||
| "DASH_MANIFEST_NO_PERIODS"
|
||||
| "DASH_MANIFEST_NO_MIMETYPE"
|
||||
| "DASH_INVALID_SEGMENT_INFO"
|
||||
| "SMOOTH_MANIFEST"
|
||||
| "SEGMENT_UNKNOWN"
|
||||
| "TEXT_UNKNOWN"
|
||||
| "APP"
|
||||
| "BREAK_CLIP_LOADING_ERROR"
|
||||
| "BREAK_SEEK_INTERCEPTOR_ERROR"
|
||||
| "IMAGE_ERROR"
|
||||
| "LOAD_INTERRUPTED"
|
||||
| "GENERIC";
|
||||
export type DetailedErrorCode =
|
||||
| "MEDIA_UNKNOWN"
|
||||
| "MEDIA_ABORTED"
|
||||
| "MEDIA_DECODE"
|
||||
| "MEDIA_NETWORK"
|
||||
| "MEDIA_SRC_NOT_SUPPORTED"
|
||||
| "SOURCE_BUFFER_FAILURE"
|
||||
| "MEDIAKEYS_UNKNOWN"
|
||||
| "MEDIAKEYS_NETWORK"
|
||||
| "MEDIAKEYS_UNSUPPORTED"
|
||||
| "MEDIAKEYS_WEBCRYPTO"
|
||||
| "NETWORK_UNKNOWN"
|
||||
| "SEGMENT_NETWORK"
|
||||
| "HLS_NETWORK_MASTER_PLAYLIST"
|
||||
| "HLS_NETWORK_PLAYLIST"
|
||||
| "HLS_NETWORK_NO_KEY_RESPONSE"
|
||||
| "HLS_NETWORK_KEY_LOAD"
|
||||
| "HLS_NETWORK_INVALID_SEGMENT"
|
||||
| "HLS_SEGMENT_PARSING"
|
||||
| "DASH_NETWORK"
|
||||
| "DASH_NO_INIT"
|
||||
| "SMOOTH_NETWORK"
|
||||
| "SMOOTH_NO_MEDIA_DATA"
|
||||
| "MANIFEST_UNKNOWN"
|
||||
| "HLS_MANIFEST_MASTER"
|
||||
| "HLS_MANIFEST_PLAYLIST"
|
||||
| "DASH_MANIFEST_UNKNOWN"
|
||||
| "DASH_MANIFEST_NO_PERIODS"
|
||||
| "DASH_MANIFEST_NO_MIMETYPE"
|
||||
| "DASH_INVALID_SEGMENT_INFO"
|
||||
| "SMOOTH_MANIFEST"
|
||||
| "SEGMENT_UNKNOWN"
|
||||
| "TEXT_UNKNOWN"
|
||||
| "APP"
|
||||
| "BREAK_CLIP_LOADING_ERROR"
|
||||
| "BREAK_SEEK_INTERCEPTOR_ERROR"
|
||||
| "IMAGE_ERROR"
|
||||
| "LOAD_INTERRUPTED"
|
||||
| "GENERIC";
|
||||
|
||||
type EndedReason =
|
||||
| "END_OF_STREAM"
|
||||
| "ERROR"
|
||||
| "STOPPED"
|
||||
| "INTERRUPTED"
|
||||
| "SKIPPED"
|
||||
| "BREAK_SWITCH";
|
||||
export type EndedReason =
|
||||
| "END_OF_STREAM"
|
||||
| "ERROR"
|
||||
| "STOPPED"
|
||||
| "INTERRUPTED"
|
||||
| "SKIPPED"
|
||||
| "BREAK_SWITCH";
|
||||
|
||||
/**
|
||||
* Event data for @see{@link EventType.SEGMENT_DOWNLOADED} event.
|
||||
*/
|
||||
export class SegmentDownloadedEvent extends Event {
|
||||
constructor(downloadTime?: number, size?: number);
|
||||
|
||||
/**
|
||||
* Event data for @see{@link EventType.SEGMENT_DOWNLOADED} event.
|
||||
* The time it took to download the segment; in milliseconds.
|
||||
*/
|
||||
class SegmentDownloadedEvent extends Event {
|
||||
constructor(downloadTime?: number, size?: number);
|
||||
|
||||
/**
|
||||
* The time it took to download the segment; in milliseconds.
|
||||
*/
|
||||
downloadTime?: number;
|
||||
|
||||
/**
|
||||
* The number of bytes in the segment.
|
||||
*/
|
||||
size?: number;
|
||||
}
|
||||
downloadTime?: number;
|
||||
|
||||
/**
|
||||
* Event data for all events that represent requests made to the receiver.
|
||||
* The number of bytes in the segment.
|
||||
*/
|
||||
class RequestEvent extends Event {
|
||||
constructor(
|
||||
type: EventType,
|
||||
requestData?: RequestData,
|
||||
senderId?: string
|
||||
);
|
||||
size?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event data for all events that represent requests made to the receiver.
|
||||
*/
|
||||
export class RequestEvent extends Event {
|
||||
constructor(
|
||||
type: EventType,
|
||||
requestData?: RequestData,
|
||||
senderId?: string
|
||||
);
|
||||
|
||||
/**
|
||||
* The data that was sent with the request.
|
||||
*/
|
||||
requestData?: RequestData;
|
||||
/**
|
||||
* The data that was sent with the request.
|
||||
*/
|
||||
requestData?: RequestData;
|
||||
|
||||
/**
|
||||
* The sender id the request came from.
|
||||
*/
|
||||
senderId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event data superexport class for all events dispatched by @see{@link PlayerManager}
|
||||
*/
|
||||
export class Event {
|
||||
constructor(type: EventType);
|
||||
|
||||
/**
|
||||
* Type of the event.
|
||||
*/
|
||||
type: EventType;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.MEDIA_STATUS} event.
|
||||
*/
|
||||
export class MediaStatusEvent extends Event {
|
||||
constructor(type: EventType, mediaStatus?: MediaStatus);
|
||||
|
||||
/**
|
||||
* The media status that was sent.
|
||||
*/
|
||||
mediaStatus?: MediaStatus;
|
||||
}
|
||||
/**
|
||||
* Event data for pause events forwarded from the MediaElement.
|
||||
*/
|
||||
export class MediaPauseEvent extends Event {
|
||||
constructor(currentMediaTime?: number, ended?: boolean);
|
||||
|
||||
/**
|
||||
* Indicate if the media ended (indicates the pause was fired due to stream reached the end).
|
||||
*/
|
||||
ended?: boolean;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.MEDIA_FINISHED} event.
|
||||
*/
|
||||
export class MediaFinishedEvent extends Event {
|
||||
constructor(currentMediaTime?: number, endedReason?: EndedReason);
|
||||
|
||||
/**
|
||||
* The time when the media finished (in seconds). For an item in a queue; this value represents the time in the currently playing queue item ( where 0 means the queue item has just started).
|
||||
*/
|
||||
currentTime?: number;
|
||||
|
||||
/**
|
||||
* The reason the media finished.
|
||||
*/
|
||||
endedReason?: EndedReason;
|
||||
}
|
||||
/**
|
||||
* Event data for all events forwarded from the MediaElement.
|
||||
*/
|
||||
export class MediaElementEvent extends Event {
|
||||
constructor(type: EventType, currentMediaTime?: number);
|
||||
|
||||
/**
|
||||
* The time in the currently playing clip when the event was fired (in seconds). Undefined if playback has not started yet.
|
||||
*/
|
||||
currentMediaTime?: number;
|
||||
}
|
||||
/**
|
||||
* Event data for all events pertaining to processing a load / preload request. made to the player.
|
||||
*/
|
||||
export class LoadEvent extends Event {
|
||||
constructor(type: EventType, media?: MediaInformation);
|
||||
|
||||
/**
|
||||
* Information about the media being loaded.
|
||||
*/
|
||||
media: MediaInformation;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.INBAND_TRACK_ADDED} event.
|
||||
*/
|
||||
export class InbandTrackAddedEvent {
|
||||
constructor(track: Track);
|
||||
|
||||
/**
|
||||
* Added track.
|
||||
*/
|
||||
track: Track;
|
||||
}
|
||||
|
||||
/** Event data for @see{@link EventType.ID3} event. */
|
||||
export class Id3Event extends Event {
|
||||
constructor(segmentData: Uint8Array);
|
||||
|
||||
/**
|
||||
* The segment data.
|
||||
*/
|
||||
segmentData: Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.EMSG} event.
|
||||
*/
|
||||
export class EmsgEvent extends Event {
|
||||
constructor(emsgData: any);
|
||||
|
||||
/**
|
||||
* The time that the event ends (in presentation time). Undefined if using legacy Dash support.
|
||||
*/
|
||||
endTime: any;
|
||||
|
||||
/**
|
||||
* The duration of the event (in units of timescale). Undefined if using legacy Dash support.
|
||||
*/
|
||||
eventDuration: any;
|
||||
|
||||
/**
|
||||
* A field identifying this instance of the message. Undefined if using legacy Dash support.
|
||||
*/
|
||||
id: any;
|
||||
|
||||
/**
|
||||
* Body of the message. Undefined if using legacy Dash support.
|
||||
*/
|
||||
messageData: any;
|
||||
|
||||
/**
|
||||
* The offset that the event starts; relative to the start of the segment this is contained in (in units of timescale). Undefined if using legacy Dash support.
|
||||
*/
|
||||
presentationTimeDelta: any;
|
||||
|
||||
/**
|
||||
* The sender id the request came from.
|
||||
*/
|
||||
senderId?: string;
|
||||
}
|
||||
/**
|
||||
* Identifies the message scheme. Undefined if using legacy Dash support.
|
||||
*/
|
||||
schemeIdUri: any;
|
||||
|
||||
/**
|
||||
* Event data superclass for all events dispatched by @see{@link PlayerManager}
|
||||
* The segment data. This is only defined if using legacy Dash support.
|
||||
*/
|
||||
class Event {
|
||||
constructor(type: EventType);
|
||||
segmentData: any;
|
||||
|
||||
/**
|
||||
* Type of the event.
|
||||
*/
|
||||
type: EventType;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.MEDIA_STATUS} event.
|
||||
* The time that the event starts (in presentation time). Undefined if using legacy Dash support.
|
||||
*/
|
||||
class MediaStatusEvent extends Event {
|
||||
constructor(type: EventType, mediaStatus?: MediaStatus);
|
||||
startTime: any;
|
||||
|
||||
/**
|
||||
* The media status that was sent.
|
||||
*/
|
||||
mediaStatus?: MediaStatus;
|
||||
}
|
||||
/**
|
||||
* Event data for pause events forwarded from the MediaElement.
|
||||
* Provides the timescale; in ticks per second. Undefined if using legacy Dash support.
|
||||
*/
|
||||
class MediaPauseEvent extends Event {
|
||||
constructor(currentMediaTime?: number, ended?: boolean);
|
||||
timescale: any;
|
||||
|
||||
/**
|
||||
* Indicate if the media ended (indicates the pause was fired due to stream reached the end).
|
||||
*/
|
||||
ended?: boolean;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.MEDIA_FINISHED} event.
|
||||
*/
|
||||
class MediaFinishedEvent extends Event {
|
||||
constructor(currentMediaTime?: number, endedReason?: EndedReason);
|
||||
|
||||
/**
|
||||
* The time when the media finished (in seconds). For an item in a queue; this value represents the time in the currently playing queue item ( where 0 means the queue item has just started).
|
||||
*/
|
||||
currentTime?: number;
|
||||
|
||||
/**
|
||||
* The reason the media finished.
|
||||
*/
|
||||
endedReason?: EndedReason;
|
||||
}
|
||||
/**
|
||||
* Event data for all events forwarded from the MediaElement.
|
||||
*/
|
||||
class MediaElementEvent extends Event {
|
||||
constructor(type: EventType, currentMediaTime?: number);
|
||||
|
||||
/**
|
||||
* The time in the currently playing clip when the event was fired (in seconds). Undefined if playback has not started yet.
|
||||
*/
|
||||
currentMediaTime?: number;
|
||||
}
|
||||
/**
|
||||
* Event data for all events pertaining to processing a load / preload request. made to the player.
|
||||
*/
|
||||
class LoadEvent extends Event {
|
||||
constructor(type: EventType, media?: MediaInformation);
|
||||
|
||||
/**
|
||||
* Information about the media being loaded.
|
||||
*/
|
||||
media: MediaInformation;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.INBAND_TRACK_ADDED} event.
|
||||
*/
|
||||
class InbandTrackAddedEvent {
|
||||
constructor(track: Track);
|
||||
* Specifies the value for the event. Undefined if using legacy Dash support.
|
||||
*/
|
||||
value: any;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.CLIP_ENDED} event.
|
||||
*/
|
||||
export class ClipEndedEvent extends Event {
|
||||
constructor(currentMediaTime: number, endedReason?: EndedReason);
|
||||
|
||||
/**
|
||||
* Added track.
|
||||
*/
|
||||
track: Track;
|
||||
}
|
||||
|
||||
/** Event data for @see{@link EventType.ID3} event. */
|
||||
class Id3Event extends Event {
|
||||
constructor(segmentData: Uint8Array);
|
||||
/**
|
||||
* The time in media (in seconds) when clip ended.
|
||||
*/
|
||||
currentMediaTime: number;
|
||||
|
||||
/**
|
||||
* The segment data.
|
||||
*/
|
||||
segmentData: Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.EMSG} event.
|
||||
* The reason the clip ended.
|
||||
*/
|
||||
class EmsgEvent extends Event {
|
||||
constructor(emsgData: any);
|
||||
endedReason?: EndedReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event data for @see{@link EventType.CACHE_LOADED} event.
|
||||
*/
|
||||
export class CacheLoadedEvent extends Event {
|
||||
constructor(media?: MediaInformation);
|
||||
|
||||
/**
|
||||
* Information about the media being cached.
|
||||
*/
|
||||
media: MediaInformation;
|
||||
}
|
||||
|
||||
export class CacheItemEvent extends Event {
|
||||
constructor(type: EventType, url: string);
|
||||
|
||||
/**
|
||||
* The URL of data fetched from cache
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
|
||||
export class BufferingEvent extends Event {
|
||||
constructor(isBuffering: boolean);
|
||||
|
||||
/**
|
||||
* True if the player is entering a buffering state.
|
||||
*/
|
||||
isBuffering: boolean;
|
||||
}
|
||||
|
||||
export class BreaksEvent extends Event {
|
||||
constructor(
|
||||
type: EventType,
|
||||
currentMediaTime?: number,
|
||||
index?: number,
|
||||
total?: number,
|
||||
whenSkippable?: number,
|
||||
endedReason?: EndedReason,
|
||||
breakClipId?: string,
|
||||
breakId?: string
|
||||
);
|
||||
|
||||
/**
|
||||
* The break's id. Refer to Break.id
|
||||
*/
|
||||
breakId?: string;
|
||||
|
||||
/**
|
||||
* The break clip's id. Refer to BreakClip.id
|
||||
*/
|
||||
breakClipId?: string;
|
||||
|
||||
/**
|
||||
* The time in the currently playing media when the break event occurred.
|
||||
*/
|
||||
currentMediaTime?: number;
|
||||
|
||||
/**
|
||||
* The reason the break clip ended.
|
||||
*/
|
||||
endedReason?: EndedReason;
|
||||
|
||||
/**
|
||||
* Index of break clip; which starts from 1.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Total number of break clips.
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* When to skip current break clip in sec; after break clip begins to play.
|
||||
*/
|
||||
whenSkippable?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event data for @see {@link EventType.BITRATE_CHANGED} event.
|
||||
*/
|
||||
export class BitrateChangedEvent {
|
||||
constructor(totalBitrate?: number);
|
||||
|
||||
/** The bitrate of the media (audio and video) in bits per second. */
|
||||
totalBitrate: number;
|
||||
}
|
||||
|
||||
export class ErrorEvent extends Event {
|
||||
constructor(detailedErrorCode: DetailedErrorCode, error?: any);
|
||||
|
||||
/**
|
||||
* The time that the event ends (in presentation time). Undefined if using legacy Dash support.
|
||||
*/
|
||||
endTime: any;
|
||||
|
||||
/**
|
||||
* The duration of the event (in units of timescale). Undefined if using legacy Dash support.
|
||||
*/
|
||||
eventDuration: any;
|
||||
|
||||
/**
|
||||
* A field identifying this instance of the message. Undefined if using legacy Dash support.
|
||||
*/
|
||||
id: any;
|
||||
|
||||
/**
|
||||
* Body of the message. Undefined if using legacy Dash support.
|
||||
*/
|
||||
messageData: any;
|
||||
|
||||
/**
|
||||
* The offset that the event starts; relative to the start of the segment this is contained in (in units of timescale). Undefined if using legacy Dash support.
|
||||
*/
|
||||
presentationTimeDelta: any;
|
||||
|
||||
/**
|
||||
* Identifies the message scheme. Undefined if using legacy Dash support.
|
||||
*/
|
||||
schemeIdUri: any;
|
||||
|
||||
/**
|
||||
* The segment data. This is only defined if using legacy Dash support.
|
||||
*/
|
||||
segmentData: any;
|
||||
|
||||
/**
|
||||
* The time that the event starts (in presentation time). Undefined if using legacy Dash support.
|
||||
*/
|
||||
startTime: any;
|
||||
|
||||
/**
|
||||
* Provides the timescale; in ticks per second. Undefined if using legacy Dash support.
|
||||
*/
|
||||
timescale: any;
|
||||
|
||||
/**
|
||||
* Specifies the value for the event. Undefined if using legacy Dash support.
|
||||
*/
|
||||
value: any;
|
||||
}
|
||||
/**
|
||||
* Event data for @see{@link EventType.CLIP_ENDED} event.
|
||||
*/
|
||||
class ClipEndedEvent extends Event {
|
||||
constructor(currentMediaTime: number, endedReason?: EndedReason);
|
||||
|
||||
/**
|
||||
* The time in media (in seconds) when clip ended.
|
||||
*/
|
||||
currentMediaTime: number;
|
||||
|
||||
/**
|
||||
* The reason the clip ended.
|
||||
*/
|
||||
endedReason?: EndedReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event data for @see{@link EventType.CACHE_LOADED} event.
|
||||
*/
|
||||
class CacheLoadedEvent extends Event {
|
||||
constructor(media?: MediaInformation);
|
||||
|
||||
/**
|
||||
* Information about the media being cached.
|
||||
*/
|
||||
media: MediaInformation;
|
||||
}
|
||||
|
||||
class CacheItemEvent extends Event {
|
||||
constructor(type: EventType, url: string);
|
||||
|
||||
/**
|
||||
* The URL of data fetched from cache
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
|
||||
class BufferingEvent extends Event {
|
||||
constructor(isBuffering: boolean);
|
||||
|
||||
/**
|
||||
* True if the player is entering a buffering state.
|
||||
*/
|
||||
isBuffering: boolean;
|
||||
}
|
||||
|
||||
class BreaksEvent extends Event {
|
||||
constructor(
|
||||
type: EventType,
|
||||
currentMediaTime?: number,
|
||||
index?: number,
|
||||
total?: number,
|
||||
whenSkippable?: number,
|
||||
endedReason?: EndedReason,
|
||||
breakClipId?: string,
|
||||
breakId?: string
|
||||
);
|
||||
|
||||
/**
|
||||
* The break's id. Refer to Break.id
|
||||
*/
|
||||
breakId?: string;
|
||||
|
||||
/**
|
||||
* The break clip's id. Refer to BreakClip.id
|
||||
*/
|
||||
breakClipId?: string;
|
||||
|
||||
/**
|
||||
* The time in the currently playing media when the break event occurred.
|
||||
*/
|
||||
currentMediaTime?: number;
|
||||
|
||||
/**
|
||||
* The reason the break clip ended.
|
||||
*/
|
||||
endedReason?: EndedReason;
|
||||
|
||||
/**
|
||||
* Index of break clip; which starts from 1.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* Total number of break clips.
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* When to skip current break clip in sec; after break clip begins to play.
|
||||
*/
|
||||
whenSkippable?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event data for @see {@link EventType.BITRATE_CHANGED} event.
|
||||
*/
|
||||
class BitrateChangedEvent {
|
||||
constructor(totalBitrate?: number);
|
||||
|
||||
/** The bitrate of the media (audio and video) in bits per second. */
|
||||
totalBitrate: number;
|
||||
}
|
||||
|
||||
class ErrorEvent extends Event {
|
||||
constructor(detailedErrorCode: DetailedErrorCode, error?: any);
|
||||
|
||||
detailedErrorCode: DetailedErrorCode;
|
||||
error?: any;
|
||||
}
|
||||
detailedErrorCode: DetailedErrorCode;
|
||||
error?: any;
|
||||
}
|
||||
|
||||
+1895
-1897
File diff suppressed because it is too large
Load Diff
+160
-162
@@ -1,198 +1,196 @@
|
||||
import { EventType } from "./cast.framework.events";
|
||||
export = cast.framework.system;
|
||||
|
||||
declare namespace cast.framework.system {
|
||||
type EventType =
|
||||
// Fired when the system is ready.
|
||||
| "READY"
|
||||
// Fired when the application is terminated
|
||||
| "SHUTDOWN"
|
||||
// Fired when a new sender has connected.
|
||||
| "SENDER_CONNECTED"
|
||||
// Fired when a sender has disconnected.
|
||||
| "SENDER_DISCONNECTED"
|
||||
// Fired when there is a system error.
|
||||
| "ERROR"
|
||||
// Fired when the system volume has changed.
|
||||
| "SYSTEM_VOLUME_CHANGED"
|
||||
// Fired when the visibility of the application has changed
|
||||
// (for example after a HDMI Input change or when the TV is turned
|
||||
// off/on and the cast device is externally powered).
|
||||
// Note that this API has the same effect as the webkitvisibilitychange event raised
|
||||
// by your document, we provided it as CastReceiverManager API for convenience and
|
||||
// to avoid a dependency on a webkit-prefixed event.
|
||||
| "VISIBILITY_CHANGED"
|
||||
// Fired when the standby state of the TV has changed.
|
||||
// This event is related to the visibility chnaged event, as if the TV is in standby
|
||||
// the visibility will be false, the visibility is more granular
|
||||
// (as it also detects that the TV has selected a different channel)
|
||||
// but it is not reliably detected in all TVs,
|
||||
// standby can be used in those cases as most TVs implement it.
|
||||
| "STANDBY_CHANGED"
|
||||
| "MAX_VIDEO_RESOLUTION_CHANGED"
|
||||
| "FEEDBACK_STARTED";
|
||||
export as namespace system
|
||||
export type EventType =
|
||||
// Fired when the system is ready.
|
||||
| "READY"
|
||||
// Fired when the application is terminated
|
||||
| "SHUTDOWN"
|
||||
// Fired when a new sender has connected.
|
||||
| "SENDER_CONNECTED"
|
||||
// Fired when a sender has disconnected.
|
||||
| "SENDER_DISCONNECTED"
|
||||
// Fired when there is a system error.
|
||||
| "ERROR"
|
||||
// Fired when the system volume has changed.
|
||||
| "SYSTEM_VOLUME_CHANGED"
|
||||
// Fired when the visibility of the application has changed
|
||||
// (for example after a HDMI Input change or when the TV is turned
|
||||
// off/on and the cast device is externally powered).
|
||||
// Note that this API has the same effect as the webkitvisibilitychange event raised
|
||||
// by your document, we provided it as CastReceiverManager API for convenience and
|
||||
// to avoid a dependency on a webkit-prefixed event.
|
||||
| "VISIBILITY_CHANGED"
|
||||
// Fired when the standby state of the TV has changed.
|
||||
// This event is related to the visibility chnaged event, as if the TV is in standby
|
||||
// the visibility will be false, the visibility is more granular
|
||||
// (as it also detects that the TV has selected a different channel)
|
||||
// but it is not reliably detected in all TVs,
|
||||
// standby can be used in those cases as most TVs implement it.
|
||||
| "STANDBY_CHANGED"
|
||||
| "MAX_VIDEO_RESOLUTION_CHANGED"
|
||||
| "FEEDBACK_STARTED";
|
||||
|
||||
type SystemState =
|
||||
| "NOT_STARTED"
|
||||
| "STARTING_IN_BACKGROUND"
|
||||
| "STARTING"
|
||||
| "READY"
|
||||
| "STOPPING_IN_BACKGROUND"
|
||||
| "STOPPING";
|
||||
export type SystemState =
|
||||
| "NOT_STARTED"
|
||||
| "STARTING_IN_BACKGROUND"
|
||||
| "STARTING"
|
||||
| "READY"
|
||||
| "STOPPING_IN_BACKGROUND"
|
||||
| "STOPPING";
|
||||
|
||||
type StandbyState = "STANDBY" | "NOT_STANDBY" | "UNKNOWN";
|
||||
export type StandbyState = "STANDBY" | "NOT_STANDBY" | "UNKNOWN";
|
||||
|
||||
type DisconnectReason = "REQUESTED_BY_SENDER" | "ERROR" | "UNKNOWN";
|
||||
export type DisconnectReason = "REQUESTED_BY_SENDER" | "ERROR" | "UNKNOWN";
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change; TV is turned off).
|
||||
*/
|
||||
export class VisibilityChangedEvent {
|
||||
constructor(isVisible: boolean);
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change; TV is turned off).
|
||||
* Whether the Cast device is the active input or not.
|
||||
*/
|
||||
class VisibilityChangedEvent {
|
||||
constructor(isVisible: boolean);
|
||||
isVisible: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the Cast device is the active input or not.
|
||||
*/
|
||||
isVisible: boolean;
|
||||
}
|
||||
/**
|
||||
* Represents the system volume data.
|
||||
*/
|
||||
export interface SystemVolumeData {
|
||||
/**
|
||||
* The level (from 0.0 to 1.0) of the system volume
|
||||
*/
|
||||
level: number;
|
||||
|
||||
/**
|
||||
* Whether the system volume is muted or not.
|
||||
*/
|
||||
muted: boolean;
|
||||
}
|
||||
/**
|
||||
* Event dispatched by @see{CastReceiverManager} when the system volume changes.
|
||||
*/
|
||||
export class SystemVolumeChangedEvent extends Event {
|
||||
constructor(volume: SystemVolumeData);
|
||||
|
||||
/**
|
||||
* The system volume data
|
||||
*/
|
||||
data: SystemVolumeData;
|
||||
}
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when the TV enters/leaves the standby state.
|
||||
*/
|
||||
export class StandbyChangedEvent {
|
||||
constructor(isStandby: boolean);
|
||||
|
||||
isStandby: boolean;
|
||||
}
|
||||
/**
|
||||
* Whether the TV is in standby or not.
|
||||
*/
|
||||
export interface ShutdownEvent extends Event {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when a sender is disconnected.
|
||||
*/
|
||||
export class SenderDisconnectedEvent extends Event {
|
||||
constructor(senderId: string, userAgent: string);
|
||||
/**
|
||||
* The ID of the sender connected.
|
||||
*/
|
||||
senderId: string;
|
||||
|
||||
/**
|
||||
* Represents the system volume data.
|
||||
* The user agent of the sender.
|
||||
*/
|
||||
interface SystemVolumeData {
|
||||
/**
|
||||
* The level (from 0.0 to 1.0) of the system volume
|
||||
*/
|
||||
level: number;
|
||||
|
||||
/**
|
||||
* Whether the system volume is muted or not.
|
||||
*/
|
||||
muted: boolean;
|
||||
}
|
||||
userAgent: string;
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{CastReceiverManager} when the system volume changes.
|
||||
* The reason the sender was disconnected.
|
||||
*/
|
||||
class SystemVolumeChangedEvent extends Event {
|
||||
constructor(volume: SystemVolumeData);
|
||||
|
||||
/**
|
||||
* The system volume data
|
||||
*/
|
||||
data: SystemVolumeData;
|
||||
}
|
||||
reason?: DisconnectReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when a sender is connected.
|
||||
*/
|
||||
export class SenderConnectedEvent extends Event {
|
||||
constructor(senderId: string, userAgent: string);
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when the TV enters/leaves the standby state.
|
||||
* The ID of the sender connected.
|
||||
*/
|
||||
class StandbyChangedEvent {
|
||||
constructor(isStandby: boolean);
|
||||
senderId: string;
|
||||
|
||||
isStandby: boolean;
|
||||
}
|
||||
/**
|
||||
* Whether the TV is in standby or not.
|
||||
* The user agent of the sender.
|
||||
*/
|
||||
interface ShutdownEvent extends Event {
|
||||
[key: string]: any;
|
||||
}
|
||||
userAgent: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the data of a connected sender device.
|
||||
*/
|
||||
export interface Sender {
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when a sender is disconnected.
|
||||
* The sender Id.
|
||||
*/
|
||||
class SenderDisconnectedEvent extends Event {
|
||||
constructor(senderId: string, userAgent: string);
|
||||
/**
|
||||
* The ID of the sender connected.
|
||||
*/
|
||||
senderId: string;
|
||||
|
||||
/**
|
||||
* The user agent of the sender.
|
||||
*/
|
||||
userAgent: string;
|
||||
|
||||
/**
|
||||
* The reason the sender was disconnected.
|
||||
*/
|
||||
reason?: DisconnectReason;
|
||||
}
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when a sender is connected.
|
||||
* Indicate the sender supports large messages (>64KB)
|
||||
*/
|
||||
class SenderConnectedEvent extends Event {
|
||||
constructor(senderId: string, userAgent: string);
|
||||
/**
|
||||
* The ID of the sender connected.
|
||||
*/
|
||||
senderId: string;
|
||||
|
||||
/**
|
||||
* The user agent of the sender.
|
||||
*/
|
||||
userAgent: string;
|
||||
}
|
||||
largeMessageSupported?: boolean;
|
||||
|
||||
/**
|
||||
* Represents the data of a connected sender device.
|
||||
* The userAgent of the sender.
|
||||
*/
|
||||
interface Sender {
|
||||
/**
|
||||
* The sender Id.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Indicate the sender supports large messages (>64KB)
|
||||
*/
|
||||
largeMessageSupported?: boolean;
|
||||
|
||||
/**
|
||||
* The userAgent of the sender.
|
||||
*/
|
||||
userAgent?: string;
|
||||
}
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event dispatched by CastReceiverManager when the system is ready.
|
||||
*/
|
||||
export class ReadyEvent {
|
||||
constructor(applicationData: ApplicationData);
|
||||
|
||||
/**
|
||||
* Event dispatched by CastReceiverManager when the system is ready.
|
||||
* The application data
|
||||
*/
|
||||
class ReadyEvent {
|
||||
constructor(applicationData: ApplicationData);
|
||||
data: ApplicationData;
|
||||
}
|
||||
|
||||
/**
|
||||
* The application data
|
||||
*/
|
||||
data: ApplicationData;
|
||||
}
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when the system needs to update the restriction on maximum video resolution.
|
||||
*/
|
||||
export class MaxVideoResolutionChangedEvent extends Event {
|
||||
constructor(height: number);
|
||||
|
||||
/**
|
||||
* Event dispatched by @see{@link CastReceiverManager} when the system needs to update the restriction on maximum video resolution.
|
||||
* Maximum video resolution requested by the system. The value of 0 means there is no restriction.
|
||||
*/
|
||||
class MaxVideoResolutionChangedEvent extends Event {
|
||||
constructor(height: number);
|
||||
|
||||
/**
|
||||
* Maximum video resolution requested by the system. The value of 0 means there is no restriction.
|
||||
*/
|
||||
height: number;
|
||||
}
|
||||
/** Event dispatched by @see{@link CastReceiverManager} when the systems starts to create feedback report. */
|
||||
interface FeedbackStartedEvent extends Event {
|
||||
[key: string]: any;
|
||||
}
|
||||
/** Event dispatched by @see{@link CastReceiverContext} which contains system information. */
|
||||
class Event {
|
||||
constructor(type: EventType, data?: any);
|
||||
type: EventType;
|
||||
data?: any;
|
||||
}
|
||||
|
||||
/** Represents the data of the launched application. */
|
||||
interface ApplicationData {
|
||||
id(): string;
|
||||
launchingSenderId(): string;
|
||||
name(): string;
|
||||
namespaces(): string[];
|
||||
sessionId(): number;
|
||||
}
|
||||
height: number;
|
||||
}
|
||||
/** Event dispatched by @see{@link CastReceiverManager} when the systems starts to create feedback report. */
|
||||
export interface FeedbackStartedEvent extends Event {
|
||||
[key: string]: any;
|
||||
}
|
||||
/** Event dispatched by @see{@link CastReceiverContext} which contains system information. */
|
||||
export class Event {
|
||||
constructor(type: EventType, data?: any);
|
||||
type: EventType;
|
||||
data?: any;
|
||||
}
|
||||
|
||||
/** Represents the data of the launched application. */
|
||||
export interface ApplicationData {
|
||||
id(): string;
|
||||
launchingSenderId(): string;
|
||||
name(): string;
|
||||
namespaces(): string[];
|
||||
sessionId(): number;
|
||||
}
|
||||
|
||||
+179
-183
@@ -1,197 +1,193 @@
|
||||
import { PlayerDataEventType } from "./cast.framework.ui";
|
||||
import { MediaMetadata } from "./cast.framework.messages";
|
||||
import { PlayerDataChangedEventHandler } from "./index";
|
||||
|
||||
export = cast.framework.ui;
|
||||
export as namespace ui
|
||||
export type ContentType = "video" | "audio" | "image";
|
||||
|
||||
declare namespace cast.framework.ui {
|
||||
type ContentType = "video" | "audio" | "image";
|
||||
export type State =
|
||||
| "launching"
|
||||
| "idle"
|
||||
| "loading"
|
||||
| "buffering"
|
||||
| "paused"
|
||||
| "playing";
|
||||
|
||||
type State =
|
||||
| "launching"
|
||||
| "idle"
|
||||
| "loading"
|
||||
| "buffering"
|
||||
| "paused"
|
||||
| "playing";
|
||||
export type PlayerDataEventType =
|
||||
| "ANY_CHANGE"
|
||||
| "STATE_CHANGED"
|
||||
| "IS_SEEKING_CHANGED"
|
||||
| "DURATION_CHANGED"
|
||||
| "CURRENT_TIME_CHANGED"
|
||||
| "METADATA_CHANGED"
|
||||
| "TITLE_CHANGED"
|
||||
| "SUBTITLE_CHANGED"
|
||||
| "THUMBNAIL_URL_CHANGED"
|
||||
| "NEXT_TITLE_CHANGED"
|
||||
| "NEXT_SUBTITLE_CHANGED"
|
||||
| "NEXT_THUMBNAIL_URL_CHANGED"
|
||||
| "PRELOADING_NEXT_CHANGED"
|
||||
| "CONTENT_TYPE_CHANGED"
|
||||
| "IS_LIVE_CHANGED"
|
||||
| "BREAK_PERCENTAGE_POSITIONS_CHANGED"
|
||||
| "IS_PLAYING_BREAK_CHANGED"
|
||||
| "IS_BREAK_SKIPPABLE_CHANGED"
|
||||
| "WHEN_SKIPPABLE_CHANGED"
|
||||
| "NUMBER_BREAK_CLIPS_CHANGED"
|
||||
| "CURRENT_BREAK_CLIP_NUMBER_CHANGED"
|
||||
| "DISPLAY_STATUS_CHANGED";
|
||||
|
||||
type PlayerDataEventType =
|
||||
| "ANY_CHANGE"
|
||||
| "STATE_CHANGED"
|
||||
| "IS_SEEKING_CHANGED"
|
||||
| "DURATION_CHANGED"
|
||||
| "CURRENT_TIME_CHANGED"
|
||||
| "METADATA_CHANGED"
|
||||
| "TITLE_CHANGED"
|
||||
| "SUBTITLE_CHANGED"
|
||||
| "THUMBNAIL_URL_CHANGED"
|
||||
| "NEXT_TITLE_CHANGED"
|
||||
| "NEXT_SUBTITLE_CHANGED"
|
||||
| "NEXT_THUMBNAIL_URL_CHANGED"
|
||||
| "PRELOADING_NEXT_CHANGED"
|
||||
| "CONTENT_TYPE_CHANGED"
|
||||
| "IS_LIVE_CHANGED"
|
||||
| "BREAK_PERCENTAGE_POSITIONS_CHANGED"
|
||||
| "IS_PLAYING_BREAK_CHANGED"
|
||||
| "IS_BREAK_SKIPPABLE_CHANGED"
|
||||
| "WHEN_SKIPPABLE_CHANGED"
|
||||
| "NUMBER_BREAK_CLIPS_CHANGED"
|
||||
| "CURRENT_BREAK_CLIP_NUMBER_CHANGED"
|
||||
| "DISPLAY_STATUS_CHANGED";
|
||||
/**
|
||||
* Player data changed event. Provides the changed field (type); and new value.
|
||||
*/
|
||||
export class PlayerDataChangedEvent {
|
||||
constructor(type: PlayerDataEventType, field: string, value: any);
|
||||
|
||||
/**
|
||||
* Player data changed event. Provides the changed field (type); and new value.
|
||||
* The field name that was changed.
|
||||
*/
|
||||
class PlayerDataChangedEvent {
|
||||
constructor(type: PlayerDataEventType, field: string, value: any);
|
||||
field: string;
|
||||
|
||||
/**
|
||||
* The field name that was changed.
|
||||
*/
|
||||
field: string;
|
||||
type: PlayerDataEventType;
|
||||
|
||||
type: PlayerDataEventType;
|
||||
|
||||
/**
|
||||
* The new field value.
|
||||
*/
|
||||
value: any;
|
||||
}
|
||||
/**
|
||||
* Player data binder. Bind a player data object to the player state.
|
||||
* The player data will be updated to reflect correctly the current player state without firing any change event.
|
||||
* The new field value.
|
||||
*/
|
||||
class PlayerDataBinder {
|
||||
constructor(playerData: PlayerData);
|
||||
|
||||
/**
|
||||
* Add listener to player data changes.
|
||||
*/
|
||||
addEventListener: (
|
||||
type: PlayerDataEventType,
|
||||
listener: PlayerDataChangedEventHandler
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Remove listener to player data changes.
|
||||
*/
|
||||
removeEventListener: (
|
||||
type: PlayerDataEventType,
|
||||
listener: PlayerDataChangedEventHandler
|
||||
) => void;
|
||||
}
|
||||
/**
|
||||
* Player data. Provide the player media and break state.
|
||||
*/
|
||||
interface PlayerData {
|
||||
/**
|
||||
* Array of breaks positions in percentage.
|
||||
*/
|
||||
breakPercentagePositions: number[];
|
||||
|
||||
/**
|
||||
* Content Type.
|
||||
*/
|
||||
contentType: ContentType;
|
||||
|
||||
/**
|
||||
* The number of the current playing break clip in the break.
|
||||
*/
|
||||
currentBreakClipNumber: number;
|
||||
|
||||
/**
|
||||
* Media current position in seconds; or break current position if playing break.
|
||||
*/
|
||||
currentTime: number;
|
||||
|
||||
/**
|
||||
* Whether the player metadata (ie: title; currentTime) should be displayed.
|
||||
* This will be true if at least one field in the metadata should be displayed.
|
||||
* In some cases; displayStatus will be true; but parts of the metadata should be hidden
|
||||
* (ie: the media title while media is seeking).
|
||||
* In these cases; additional css can be applied to hide those elements.
|
||||
* For cases where the media is audio-only; this will almost always be true.
|
||||
* In cases where the media is video; this will be true when:
|
||||
* (1) the video is loading; buffering; or seeking
|
||||
* (2) a play request was made in the last five seconds while media is already playing;
|
||||
* (3) there is a request made to show the status in the last five seconds; or
|
||||
* (4) the media was paused in the last five seconds.
|
||||
*/
|
||||
displayStatus: boolean;
|
||||
|
||||
/**
|
||||
* Media duration in seconds; Or break duration if playing break.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* Indicate break clip can be skipped.
|
||||
*/
|
||||
isBreakSkippable: boolean;
|
||||
|
||||
/**
|
||||
* Indicate if the content is a live stream.
|
||||
*/
|
||||
isLive: boolean;
|
||||
|
||||
/**
|
||||
* Indicate that the receiver is playing a break.
|
||||
*/
|
||||
isPlayingBreak: boolean;
|
||||
|
||||
/**
|
||||
* Indicate the player is seeking (can be either during playing or pausing).
|
||||
*/
|
||||
isSeeking: boolean;
|
||||
|
||||
/**
|
||||
* Media metadata.
|
||||
*/
|
||||
metadata: MediaMetadata;
|
||||
|
||||
/**
|
||||
* Next Item subtitle.
|
||||
*/
|
||||
nextSubtitle: string;
|
||||
|
||||
/**
|
||||
* Next Item thumbnail url.
|
||||
*/
|
||||
nextThumbnailUrl: string;
|
||||
|
||||
/**
|
||||
* Next Item title.
|
||||
*/
|
||||
nextTitle: string;
|
||||
|
||||
/**
|
||||
* Number of break clips in current break.
|
||||
*/
|
||||
numberBreakClips: number;
|
||||
|
||||
/**
|
||||
* Flag to show/hide next item metadata.
|
||||
*/
|
||||
preloadingNext: boolean;
|
||||
|
||||
/**
|
||||
* Current player state.
|
||||
*/
|
||||
state: State;
|
||||
|
||||
/**
|
||||
* Content thumbnail url.
|
||||
*/
|
||||
thumbnailUrl: string;
|
||||
|
||||
/**
|
||||
* Content title.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Provide the time a break is skipable - relative to current playback time. Undefined if not skippable.
|
||||
*/
|
||||
whenSkippable?: number;
|
||||
}
|
||||
value: any;
|
||||
}
|
||||
/**
|
||||
* Player data binder. Bind a player data object to the player state.
|
||||
* The player data will be updated to reflect correctly the current player state without firing any change event.
|
||||
*/
|
||||
export class PlayerDataBinder {
|
||||
constructor(playerData: PlayerData);
|
||||
|
||||
/**
|
||||
* Add listener to player data changes.
|
||||
*/
|
||||
addEventListener: (
|
||||
type: PlayerDataEventType,
|
||||
listener: PlayerDataChangedEventHandler
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Remove listener to player data changes.
|
||||
*/
|
||||
removeEventListener: (
|
||||
type: PlayerDataEventType,
|
||||
listener: PlayerDataChangedEventHandler
|
||||
) => void;
|
||||
}
|
||||
/**
|
||||
* Player data. Provide the player media and break state.
|
||||
*/
|
||||
export interface PlayerData {
|
||||
/**
|
||||
* Array of breaks positions in percentage.
|
||||
*/
|
||||
breakPercentagePositions: number[];
|
||||
|
||||
/**
|
||||
* Content Type.
|
||||
*/
|
||||
contentType: ContentType;
|
||||
|
||||
/**
|
||||
* The number of the current playing break clip in the break.
|
||||
*/
|
||||
currentBreakClipNumber: number;
|
||||
|
||||
/**
|
||||
* Media current position in seconds; or break current position if playing break.
|
||||
*/
|
||||
currentTime: number;
|
||||
|
||||
/**
|
||||
* Whether the player metadata (ie: title; currentTime) should be displayed.
|
||||
* This will be true if at least one field in the metadata should be displayed.
|
||||
* In some cases; displayStatus will be true; but parts of the metadata should be hidden
|
||||
* (ie: the media title while media is seeking).
|
||||
* In these cases; additional css can be applied to hide those elements.
|
||||
* For cases where the media is audio-only; this will almost always be true.
|
||||
* In cases where the media is video; this will be true when:
|
||||
* (1) the video is loading; buffering; or seeking
|
||||
* (2) a play request was made in the last five seconds while media is already playing;
|
||||
* (3) there is a request made to show the status in the last five seconds; or
|
||||
* (4) the media was paused in the last five seconds.
|
||||
*/
|
||||
displayStatus: boolean;
|
||||
|
||||
/**
|
||||
* Media duration in seconds; Or break duration if playing break.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* Indicate break clip can be skipped.
|
||||
*/
|
||||
isBreakSkippable: boolean;
|
||||
|
||||
/**
|
||||
* Indicate if the content is a live stream.
|
||||
*/
|
||||
isLive: boolean;
|
||||
|
||||
/**
|
||||
* Indicate that the receiver is playing a break.
|
||||
*/
|
||||
isPlayingBreak: boolean;
|
||||
|
||||
/**
|
||||
* Indicate the player is seeking (can be either during playing or pausing).
|
||||
*/
|
||||
isSeeking: boolean;
|
||||
|
||||
/**
|
||||
* Media metadata.
|
||||
*/
|
||||
metadata: MediaMetadata;
|
||||
|
||||
/**
|
||||
* Next Item subtitle.
|
||||
*/
|
||||
nextSubtitle: string;
|
||||
|
||||
/**
|
||||
* Next Item thumbnail url.
|
||||
*/
|
||||
nextThumbnailUrl: string;
|
||||
|
||||
/**
|
||||
* Next Item title.
|
||||
*/
|
||||
nextTitle: string;
|
||||
|
||||
/**
|
||||
* Number of break clips in current break.
|
||||
*/
|
||||
numberBreakClips: number;
|
||||
|
||||
/**
|
||||
* Flag to show/hide next item metadata.
|
||||
*/
|
||||
preloadingNext: boolean;
|
||||
|
||||
/**
|
||||
* Current player state.
|
||||
*/
|
||||
state: State;
|
||||
|
||||
/**
|
||||
* Content thumbnail url.
|
||||
*/
|
||||
thumbnailUrl: string;
|
||||
|
||||
/**
|
||||
* Content title.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Provide the time a break is skipable - relative to current playback time. Undefined if not skippable.
|
||||
*/
|
||||
whenSkippable?: number;
|
||||
}
|
||||
|
||||
@@ -1,64 +1,60 @@
|
||||
import {
|
||||
PlayerData,
|
||||
PlayerDataBinder
|
||||
} from "chromecast-caf-receiver/cast.framework.ui";
|
||||
import {
|
||||
ReadyEvent,
|
||||
ApplicationData
|
||||
} from "chromecast-caf-receiver/cast.framework.system";
|
||||
import {
|
||||
RequestEvent,
|
||||
Event,
|
||||
BreaksEvent
|
||||
} from "chromecast-caf-receiver/cast.framework.events";
|
||||
import {
|
||||
QueueBase,
|
||||
TextTracksManager,
|
||||
QueueManager,
|
||||
PlayerManager
|
||||
} from "chromecast-caf-receiver/cast.framework";
|
||||
import {
|
||||
BreakSeekData,
|
||||
BreakClipLoadInterceptorContext,
|
||||
BreakManager
|
||||
} from "chromecast-caf-receiver/cast.framework.breaks";
|
||||
import {
|
||||
Break,
|
||||
BreakClip,
|
||||
LoadRequestData,
|
||||
Track,
|
||||
MediaMetadata
|
||||
} from "chromecast-caf-receiver/cast.framework.messages";
|
||||
import { MediaMetadata } from "chromecast-caf-receiver/cast.framework.messages";
|
||||
|
||||
const breaksEvent = new BreaksEvent('BREAK_STARTED');
|
||||
breaksEvent.breakId = 'some-break-id';
|
||||
breaksEvent.breakClipId = 'some-break-clip-id';
|
||||
// The following test showcases how you can import individual types directly from the namespace:
|
||||
|
||||
const track = new Track(1, "TEXT");
|
||||
const breakClip = new BreakClip("id");
|
||||
const adBreak = new Break("id", ["id"], 1);
|
||||
const rEvent = new RequestEvent("BITRATE_CHANGED", { requestId: 2 });
|
||||
const pManager = new PlayerManager();
|
||||
pManager.addEventListener("STALLED", () => { });
|
||||
const ttManager = new TextTracksManager();
|
||||
const qManager = new QueueManager();
|
||||
const qBase = new QueueBase();
|
||||
const mediaMetadata = new MediaMetadata("GENERIC");
|
||||
mediaMetadata.metadataType = "TV_SHOW";
|
||||
|
||||
// The following tests showcase how you can globally access 'cast' types using
|
||||
// the nested namespace style. This is the preferred method as it
|
||||
// conforms exactly to the CAF documentation.
|
||||
|
||||
// tslint:disable-next-line
|
||||
const breaksEvent = new cast.framework.events.BreaksEvent("BREAK_STARTED");
|
||||
breaksEvent.breakId = "some-break-id";
|
||||
breaksEvent.breakClipId = "some-break-clip-id";
|
||||
|
||||
// tslint:disable-next-line
|
||||
const track = new cast.framework.messages.Track(1, "TEXT");
|
||||
// tslint:disable-next-line
|
||||
const breakClip = new cast.framework.messages.BreakClip("id");
|
||||
// tslint:disable-next-line
|
||||
const adBreak = new cast.framework.messages.Break("id", ["id"], 1);
|
||||
// tslint:disable-next-line
|
||||
const rEvent = new cast.framework.events.RequestEvent("BITRATE_CHANGED", {
|
||||
requestId: 2
|
||||
});
|
||||
// tslint:disable-next-line
|
||||
const pManager = new cast.framework.PlayerManager();
|
||||
pManager.addEventListener("STALLED", () => {});
|
||||
// tslint:disable-next-line
|
||||
const ttManager = new cast.framework.TextTracksManager();
|
||||
// tslint:disable-next-line
|
||||
const qManager = new cast.framework.QueueManager();
|
||||
// tslint:disable-next-line
|
||||
const qBase = new cast.framework.QueueBase();
|
||||
const items = qBase.fetchItems(1, 3, 4);
|
||||
const breakSeekData = new BreakSeekData(0, 100, []);
|
||||
const breakClipLoadContext = new BreakClipLoadInterceptorContext(adBreak);
|
||||
const breakManager: BreakManager = {
|
||||
// tslint:disable-next-line
|
||||
const breakSeekData = new cast.framework.breaks.BreakSeekData(0, 100, []);
|
||||
// tslint:disable-next-line
|
||||
const breakClipLoadContext = new cast.framework.breaks.BreakClipLoadInterceptorContext(
|
||||
adBreak
|
||||
);
|
||||
// tslint:disable-next-line
|
||||
const breakManager: cast.framework.breaks.BreakManager = {
|
||||
getBreakById: () => adBreak,
|
||||
getBreakClipById: () => breakClip,
|
||||
getBreakClips: () => [breakClip],
|
||||
getBreaks: () => [adBreak],
|
||||
getPlayWatchedBreak: () => true,
|
||||
setBreakClipLoadInterceptor: () => { },
|
||||
setBreakSeekInterceptor: () => { },
|
||||
setPlayWatchedBreak: () => { },
|
||||
setVastTrackingInterceptor: () => { }
|
||||
setBreakClipLoadInterceptor: () => {},
|
||||
setBreakSeekInterceptor: () => {},
|
||||
setPlayWatchedBreak: () => {},
|
||||
setVastTrackingInterceptor: () => {}
|
||||
};
|
||||
|
||||
const lrd: LoadRequestData = {
|
||||
// tslint:disable-next-line
|
||||
const lrd: cast.framework.messages.LoadRequestData = {
|
||||
requestId: 1,
|
||||
activeTrackIds: [1, 2],
|
||||
media: {
|
||||
@@ -75,7 +71,8 @@ const lrd: LoadRequestData = {
|
||||
queueData: {}
|
||||
};
|
||||
|
||||
const appData: ApplicationData = {
|
||||
// tslint:disable-next-line
|
||||
const appData: cast.framework.system.ApplicationData = {
|
||||
id: () => "id",
|
||||
launchingSenderId: () => "launch-id",
|
||||
name: () => "name",
|
||||
@@ -83,9 +80,11 @@ const appData: ApplicationData = {
|
||||
sessionId: () => 1
|
||||
};
|
||||
|
||||
const readyEvent = new ReadyEvent(appData);
|
||||
// tslint:disable-next-line
|
||||
const readyEvent = new cast.framework.system.ReadyEvent(appData);
|
||||
const data = readyEvent.data;
|
||||
const pData: PlayerData = {
|
||||
// tslint:disable-next-line
|
||||
const pData: cast.framework.ui.PlayerData = {
|
||||
breakPercentagePositions: [1],
|
||||
contentType: "video",
|
||||
currentBreakClipNumber: 2,
|
||||
@@ -96,7 +95,8 @@ const pData: PlayerData = {
|
||||
isLive: true,
|
||||
isPlayingBreak: false,
|
||||
isSeeking: true,
|
||||
metadata: new MediaMetadata("GENERIC"),
|
||||
// tslint:disable-next-line
|
||||
metadata: new cast.framework.messages.MediaMetadata("GENERIC"),
|
||||
nextSubtitle: "sub",
|
||||
nextThumbnailUrl: "url",
|
||||
nextTitle: "title",
|
||||
@@ -107,5 +107,6 @@ const pData: PlayerData = {
|
||||
title: "title",
|
||||
whenSkippable: 321
|
||||
};
|
||||
const binder = new PlayerDataBinder(pData);
|
||||
binder.addEventListener("ANY_CHANGE", e => { });
|
||||
// tslint:disable-next-line
|
||||
const binder = new cast.framework.ui.PlayerDataBinder(pData);
|
||||
binder.addEventListener("ANY_CHANGE", e => {});
|
||||
|
||||
+11
-7
@@ -11,14 +11,18 @@
|
||||
/// <reference path="./cast.framework.system.d.ts" />
|
||||
/// <reference path="./cast.framework.ui.d.ts" />
|
||||
|
||||
import * as framework from "./cast.framework";
|
||||
import { PlayerDataChangedEvent } from './cast.framework.ui';
|
||||
import { NetworkRequestInfo } from './cast.framework';
|
||||
import { Event } from './cast.framework.events';
|
||||
|
||||
export as namespace cast;
|
||||
export type EventHandler = (event: Event) => void;
|
||||
export type PlayerDataChangedEventHandler = (
|
||||
event: PlayerDataChangedEvent
|
||||
) => void;
|
||||
export type RequestHandler = (request: NetworkRequestInfo) => void;
|
||||
export type BinaryHandler = (data: Uint8Array) => Uint8Array;
|
||||
export { framework };
|
||||
|
||||
declare global {
|
||||
type EventHandler = (event: Event) => void;
|
||||
type PlayerDataChangedEventHandler = (
|
||||
event: PlayerDataChangedEvent
|
||||
) => void;
|
||||
type RequestHandler = (request: framework.NetworkRequestInfo) => void;
|
||||
type BinaryHandler = (data: Uint8Array) => Uint8Array;
|
||||
}
|
||||
|
||||
@@ -369,6 +369,7 @@ function test_dom_walker() {
|
||||
node = walker.lastForward();
|
||||
node = walker.next();
|
||||
node = walker.previous();
|
||||
isSomething = walker.guard(node, true);
|
||||
walker.reset();
|
||||
|
||||
isSomething = CKEDITOR.dom.walker.blockBoundary({ div: 1 })(node);
|
||||
@@ -485,7 +486,7 @@ function test_dialog() {
|
||||
{
|
||||
id: 'tab-basic',
|
||||
label: 'Basic Settings',
|
||||
elements: <any[]> []
|
||||
elements: [] as any []
|
||||
},
|
||||
{
|
||||
id: 'tab-adv',
|
||||
|
||||
Vendored
+1
-1
@@ -498,7 +498,7 @@ declare namespace CKEDITOR {
|
||||
|
||||
class walker {
|
||||
evaluator: (node: node) => boolean;
|
||||
guard: (node: node) => boolean;
|
||||
guard: (node: node, movingOut?: boolean) => boolean;
|
||||
|
||||
static validEmptyBlockContainers: { [key: string]: any };
|
||||
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
import * as utils from "ckeditor__ckeditor5-utils";
|
||||
import * as core from "ckeditor__ckeditor5-core";
|
||||
import * as engine from "ckeditor__ckeditor5-engine";
|
||||
|
||||
declare let bool: boolean;
|
||||
declare let command: core.Command;
|
||||
declare let commandCollection: core.CommandCollection;
|
||||
declare let commands: core.Command[];
|
||||
declare let componentFactory: core.ComponentFactory;
|
||||
declare let config: utils.Config;
|
||||
declare let conversion: engine.conversion.Conversion;
|
||||
declare let dataController: engine.controller.DataController;
|
||||
declare let editingController: engine.controller.EditingController;
|
||||
declare let editingKeystrokeHandler: core.EditingKeystrokeHandler;
|
||||
declare let editor: core.editor.Editor;
|
||||
declare let focusTracker: utils.FocusTracker;
|
||||
declare let htmlElement: HTMLElement;
|
||||
declare let keystrokes: core.EditingKeystrokeHandler;
|
||||
declare let locale: utils.Locale;
|
||||
declare let model: engine.model.Model;
|
||||
declare let num: number;
|
||||
declare let pendingActions: core.PendingActions;
|
||||
declare let plugin: core.Plugin;
|
||||
declare let pluginCollection: core.PluginCollection<any>;
|
||||
declare let pluginCollectionStr: core.PluginCollection<core.Plugin<string>>;
|
||||
declare let pluginStr: core.Plugin<string>;
|
||||
declare let myPlugin: MyPlugin;
|
||||
declare let myPluginMaybe: MyPlugin | undefined;
|
||||
declare let myPlugins: MyPlugin[];
|
||||
declare let str: string;
|
||||
declare let strOrUndef: string | undefined;
|
||||
declare let strs: string[];
|
||||
declare let ui: core.editor.EditorUI;
|
||||
declare let undef: undefined;
|
||||
declare let view: core.EditorUIView;
|
||||
|
||||
class MyPlugin extends core.Plugin {
|
||||
constructor(editor: core.editor.Editor) {
|
||||
super(editor);
|
||||
}
|
||||
|
||||
static get pluginName() {
|
||||
return "A";
|
||||
}
|
||||
|
||||
myMethod() {
|
||||
return "this is MyPlugin method";
|
||||
}
|
||||
}
|
||||
|
||||
class SomeCommand extends core.Command {
|
||||
execute() {}
|
||||
}
|
||||
|
||||
// core/editor/utils/dataapimixin =============================================
|
||||
|
||||
class DataApiEditor extends core.editor.Editor implements core.editor.utils.DataApi {
|
||||
// mixin by DataApiMixin
|
||||
getData: () => string;
|
||||
setData: (data: string) => void;
|
||||
}
|
||||
utils.mix(DataApiEditor, core.editor.utils.DataApiMixin);
|
||||
const dataApiEditor = new DataApiEditor();
|
||||
|
||||
dataApiEditor.setData("foo");
|
||||
str = dataApiEditor.getData();
|
||||
|
||||
// core/editor/utils/elementapimixin ==========================================
|
||||
|
||||
class ElementApiEditor extends core.editor.Editor implements core.editor.utils.ElementApi {
|
||||
// mixin by ElementApiMixin
|
||||
readonly sourceElement: HTMLElement;
|
||||
updateSourceElement: () => void;
|
||||
}
|
||||
utils.mix(ElementApiEditor, core.editor.utils.ElementApiMixin);
|
||||
const elementApiEditor = new ElementApiEditor();
|
||||
|
||||
htmlElement = elementApiEditor.sourceElement;
|
||||
elementApiEditor.updateSourceElement();
|
||||
|
||||
// core/editor/utils/attachtoform =============================================
|
||||
|
||||
// $ExpectError
|
||||
core.editor.utils.attachToForm(editor);
|
||||
core.editor.utils.attachToForm(elementApiEditor);
|
||||
|
||||
// core/editor/editor =========================================================
|
||||
|
||||
commandCollection = editor.commands;
|
||||
config = editor.config;
|
||||
editingController = editor.editing;
|
||||
conversion = editor.conversion;
|
||||
dataController = editor.data;
|
||||
editor.isReadOnly = bool;
|
||||
editingKeystrokeHandler = editor.keystrokes;
|
||||
locale = editor.locale;
|
||||
model = editor.model;
|
||||
pluginCollection = editor.plugins;
|
||||
|
||||
if (editor.state === "initializing") {
|
||||
console.log("new Editor()");
|
||||
} else if (editor.state === "ready") {
|
||||
console.log("Editor.create()");
|
||||
} else if (editor.state === "destroyed") {
|
||||
console.log("editor.destroy");
|
||||
} else {
|
||||
const n: never = editor.state;
|
||||
}
|
||||
|
||||
editor.state = "ready";
|
||||
|
||||
core.editor.Editor.builtinPlugins = [plugin, pluginStr, plugin];
|
||||
const plugins: Array<core.Plugin<any>> = core.editor.Editor.builtinPlugins;
|
||||
|
||||
core.editor.Editor.defaultConfig = {
|
||||
foo: {
|
||||
a: 1,
|
||||
b: 2
|
||||
}
|
||||
};
|
||||
|
||||
editor = new core.editor.Editor();
|
||||
editor = new core.editor.Editor({language: "pl"});
|
||||
|
||||
editor.destroy();
|
||||
editor.destroy().then(() => {
|
||||
console.log(`${editor.state} == destroyed`);
|
||||
});
|
||||
|
||||
editor.execute("someCommand");
|
||||
editor.execute("someCommand2", "arg1", 2);
|
||||
|
||||
editor.initPlugins();
|
||||
editor.initPlugins().then(() => {
|
||||
console.log(`init ${Array.from(editor.plugins).length} plugins`);
|
||||
});
|
||||
|
||||
locale.t = editor.t;
|
||||
str = editor.t("Label");
|
||||
str = editor.t('Created file "%0" in %1ms.', ["fileName", "100"]);
|
||||
|
||||
// core/editor/editorui =======================================================
|
||||
|
||||
componentFactory = ui.componentFactory;
|
||||
editor = ui.editor;
|
||||
focusTracker = ui.focusTracker;
|
||||
view = ui.view;
|
||||
|
||||
ui = new core.editor.EditorUI(editor, view);
|
||||
ui.destroy();
|
||||
ui.update();
|
||||
|
||||
// core/editor/editorwithui ===================================================
|
||||
|
||||
declare let ewui: core.editor.EditorWithUI;
|
||||
htmlElement = ewui.element!;
|
||||
ui = ewui.ui;
|
||||
|
||||
// core/command ===============================================================
|
||||
|
||||
editor = command.editor;
|
||||
|
||||
bool = command.isEnabled;
|
||||
|
||||
undef = command.value;
|
||||
strOrUndef = new core.Command<string>(editor).value;
|
||||
|
||||
command = new core.Command(editor);
|
||||
|
||||
command.destroy();
|
||||
|
||||
command.execute();
|
||||
|
||||
command.refresh();
|
||||
|
||||
// core/commandcollection =====================================================
|
||||
|
||||
commandCollection = new core.CommandCollection();
|
||||
|
||||
const collectionsPairs = Array.from(commandCollection);
|
||||
const collectionsPair = collectionsPairs[0];
|
||||
str = collectionsPair[0];
|
||||
command = collectionsPair[1];
|
||||
|
||||
commandCollection.add("foo", new SomeCommand(editor));
|
||||
|
||||
command = commandCollection.commands().next().value;
|
||||
commands = Array.from(commandCollection.commands());
|
||||
|
||||
commandCollection.destroy();
|
||||
|
||||
commandCollection.execute("foo");
|
||||
commandCollection.execute("bar", 1, "param");
|
||||
|
||||
command = commandCollection.get("foo");
|
||||
|
||||
str = commandCollection.names().next().value;
|
||||
strs = Array.from(commandCollection.names());
|
||||
|
||||
// core/editingkeystrokehandler ===============================================
|
||||
|
||||
keystrokes = new core.EditingKeystrokeHandler(editor);
|
||||
|
||||
editor = keystrokes.editor;
|
||||
|
||||
keystrokes.press({keyCode: 123});
|
||||
|
||||
keystrokes.set("Ctrl+A", "foo");
|
||||
keystrokes.set(["shift", "33"], "foo");
|
||||
keystrokes.set(["ctrl", "A"], "foo", {priority: 10});
|
||||
keystrokes.set(["ctrl", "A"], "foo", {priority: "high"});
|
||||
keystrokes.set(["ctrl", "A"], () => console.log("key"));
|
||||
keystrokes.set(["ctrl", "A"], (keyEvtData, cancel) => {
|
||||
console.log(keyEvtData.keyCode);
|
||||
cancel();
|
||||
});
|
||||
|
||||
// core/pendingactions ========================================================
|
||||
|
||||
pendingActions = new core.PendingActions(editor);
|
||||
|
||||
str = core.PendingActions.pluginName;
|
||||
|
||||
const firstAction = pendingActions.first;
|
||||
|
||||
bool = pendingActions.hasAny;
|
||||
|
||||
strs = Array.from(pendingActions, action => action.message);
|
||||
|
||||
const action1 = pendingActions.add("Action 1");
|
||||
|
||||
pendingActions.remove(action1);
|
||||
|
||||
firstAction!.fire("I'm an Observable with a message");
|
||||
str = firstAction!.message;
|
||||
str = action1.message;
|
||||
|
||||
// core/plugin ================================================================
|
||||
|
||||
class MyPluginMini extends core.Plugin {
|
||||
constructor(editor: core.editor.Editor) {
|
||||
super(editor);
|
||||
}
|
||||
}
|
||||
|
||||
class MyPluginAll extends core.Plugin<string> {
|
||||
constructor(editor: core.editor.Editor) {
|
||||
super(editor);
|
||||
}
|
||||
|
||||
static get pluginName() {
|
||||
return "All";
|
||||
}
|
||||
|
||||
static get requires() {
|
||||
return [MyPlugin, MyPluginMini];
|
||||
}
|
||||
|
||||
afterInit() {return Math.random() ? null : Promise.resolve("resolved"); }
|
||||
destroy() {return Math.random() ? null : Promise.resolve("destroy"); }
|
||||
init() {return Math.random() ? null : Promise.resolve("init"); }
|
||||
}
|
||||
|
||||
plugin = new MyPlugin(editor);
|
||||
plugin = new MyPluginMini(editor);
|
||||
pluginStr = new MyPluginAll(editor);
|
||||
|
||||
const Plugin: MyPlugin = new MyPlugin(editor);
|
||||
const pluginMini: MyPluginMini = new MyPluginMini(editor);
|
||||
const pluginAll: MyPluginAll = new MyPluginAll(editor);
|
||||
|
||||
editor = myPlugin.editor;
|
||||
|
||||
str = MyPluginAll.pluginName;
|
||||
strOrUndef = MyPluginMini.pluginName; // Todo: should be undefined.
|
||||
|
||||
plugin = new MyPluginAll.requires[0](editor);
|
||||
|
||||
const fs: Function[] = MyPluginAll.requires;
|
||||
const fsOrUndef = MyPluginMini.requires; // Todo: should be undefined.
|
||||
|
||||
// $ExpectError
|
||||
pluginMini.afterInit();
|
||||
pluginAll.afterInit();
|
||||
|
||||
// $ExpectError
|
||||
pluginMini.destroy();
|
||||
pluginAll.destroy();
|
||||
|
||||
// $ExpectError
|
||||
pluginMini.init();
|
||||
pluginAll.init();
|
||||
|
||||
// core/plugincollection ======================================================
|
||||
|
||||
pluginCollectionStr = new core.PluginCollection(editor, [MyPluginAll]);
|
||||
// $ExpectError
|
||||
pluginCollectionStr = new core.PluginCollection(editor, [MyPlugin]);
|
||||
|
||||
const aColl = new core.PluginCollection<MyPluginAll | MyPluginMini>(editor, [MyPluginAll, MyPluginMini]);
|
||||
|
||||
const myColl = new core.PluginCollection(editor, [MyPlugin]);
|
||||
|
||||
const myCollArray = Array.from(myColl);
|
||||
myPlugins = myCollArray.map(entry => entry[1]);
|
||||
myPlugin = new (myCollArray[0][0])(editor);
|
||||
|
||||
myColl.destroy()
|
||||
.then(destroyedPlugins => {
|
||||
num = destroyedPlugins.length;
|
||||
const plugin = destroyedPlugins[0];
|
||||
editor = plugin.editor;
|
||||
plugin.init!();
|
||||
plugin.destroy();
|
||||
str = plugin.myMethod();
|
||||
});
|
||||
|
||||
myPluginMaybe = myColl.get("A");
|
||||
myPluginMaybe = myColl.get(MyPlugin);
|
||||
|
||||
myColl.load([MyPlugin, "A"])
|
||||
.then((loadedPlugins) => {
|
||||
const plugin = loadedPlugins[0];
|
||||
editor = plugin.editor;
|
||||
str = plugin.myMethod();
|
||||
});
|
||||
|
||||
myColl.load([MyPlugin, "A"], [MyPlugin, "A"]);
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
// Type definitions for @ckeditor/ckeditor5-core 11.0
|
||||
// Project: https://github.com/ckeditor/ckeditor5-core
|
||||
// Definitions by: denisname <https://github.com/denisname>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as engine from "ckeditor__ckeditor5-engine";
|
||||
import * as ckutils from "ckeditor__ckeditor5-utils";
|
||||
|
||||
// TODO: depends on other libraries
|
||||
export interface AlignmentConfig {}
|
||||
export interface AutosaveConfig {}
|
||||
export interface CKFinderAdapterConfig {}
|
||||
export interface CloudServicesConfig {}
|
||||
export interface FontFamilyConfig {}
|
||||
export interface FontSizeConfig {}
|
||||
export interface HeadingConfig {}
|
||||
export interface HighlightConfig {}
|
||||
export interface ImageConfig {}
|
||||
export interface MediaEmbedConfig {}
|
||||
export interface TypingConfig {}
|
||||
export interface ComponentFactory {} // CKEditor 5 UI
|
||||
export interface EditorUIView {} // CKEditor 5 UI
|
||||
|
||||
export namespace editor {
|
||||
namespace utils {
|
||||
// core/editor/utils/attachtoform
|
||||
|
||||
function attachToForm(editor: Editor & ElementApi): void;
|
||||
|
||||
// core/editor/utils/dataapimixin
|
||||
|
||||
const DataApiMixin: DataApi;
|
||||
|
||||
interface DataApi {
|
||||
getData(): string;
|
||||
setData(data: string): void;
|
||||
}
|
||||
|
||||
// core/editor/utils/elementapimixin
|
||||
|
||||
const ElementApiMixin: ElementApi;
|
||||
|
||||
interface ElementApi {
|
||||
readonly sourceElement: HTMLElement;
|
||||
updateSourceElement(): void;
|
||||
}
|
||||
}
|
||||
|
||||
// core/editor/editor
|
||||
|
||||
class Editor implements ckutils.Emitter, ckutils.Observable {
|
||||
readonly commands: CommandCollection;
|
||||
readonly config: ckutils.Config;
|
||||
readonly conversion: engine.conversion.Conversion;
|
||||
readonly data: engine.controller.DataController;
|
||||
readonly editing: engine.controller.EditingController;
|
||||
isReadOnly: boolean;
|
||||
readonly keystrokes: EditingKeystrokeHandler;
|
||||
readonly locale: ckutils.Locale;
|
||||
readonly model: engine.model.Model;
|
||||
readonly plugins: PluginCollection<Plugin<any>>;
|
||||
state: "initializing" | "ready" | "destroyed";
|
||||
|
||||
static builtinPlugins: Array<Plugin<any>>;
|
||||
static defaultConfig: object;
|
||||
|
||||
constructor(config?: object);
|
||||
destroy(): Promise<void>;
|
||||
execute(commandName: string, ...commandParams: any[]): void;
|
||||
initPlugins(): Promise<void>;
|
||||
t(str: string, values?: string[]): string;
|
||||
|
||||
static create(config: object): Promise<any>;
|
||||
|
||||
// Emitter
|
||||
delegate(...events: string[]): ckutils.EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | ckutils.EventInfo<ckutils.Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: ckutils.Emitter, event: string, callback: Function, options?: {priority?: ckutils.PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: ckutils.Emitter): void;
|
||||
stopListening(emitter?: ckutils.Emitter, event?: string, callback?: Function): void;
|
||||
|
||||
// Observable
|
||||
bind(...bindProperties: string[]): ckutils.BindChain;
|
||||
decorate(methodName: string): void;
|
||||
set(name: object): void;
|
||||
set(name: string, value: any): void;
|
||||
unbind(...unbindProperties: string[]): void;
|
||||
}
|
||||
|
||||
// core/editor/editorconfig
|
||||
|
||||
interface EditorConfig {
|
||||
alignment: AlignmentConfig;
|
||||
autosave: AutosaveConfig;
|
||||
balloonToolbar: string[];
|
||||
blockToolbar: string[];
|
||||
ckfinder: CKFinderAdapterConfig;
|
||||
cloudServices: CloudServicesConfig;
|
||||
fontFamily: FontFamilyConfig;
|
||||
fontSize: FontSizeConfig;
|
||||
heading: HeadingConfig;
|
||||
highlight: HighlightConfig;
|
||||
image: ImageConfig;
|
||||
language: string;
|
||||
mediaEmbed: MediaEmbedConfig;
|
||||
plugins: Array<string | Plugin>;
|
||||
removePlugins: string[];
|
||||
toolbar: string[] | {items: string[]; viewportTopOffset: number; };
|
||||
typing: TypingConfig;
|
||||
}
|
||||
|
||||
// core/editor/editorui
|
||||
|
||||
class EditorUI implements ckutils.Emitter {
|
||||
readonly componentFactory: ComponentFactory;
|
||||
readonly editor: Editor;
|
||||
readonly focusTracker: ckutils.FocusTracker;
|
||||
readonly view: EditorUIView;
|
||||
|
||||
constructor(editor: Editor, view: EditorUIView);
|
||||
destroy(): void;
|
||||
update(): void;
|
||||
|
||||
// Emitter
|
||||
delegate(...events: string[]): ckutils.EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | ckutils.EventInfo<ckutils.Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: ckutils.Emitter, event: string, callback: Function, options?: {priority?: ckutils.PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: ckutils.Emitter): void;
|
||||
stopListening(emitter?: ckutils.Emitter, event?: string, callback?: Function): void;
|
||||
}
|
||||
|
||||
// core/editor/editorwithui
|
||||
|
||||
interface EditorWithUI {
|
||||
readonly element: HTMLElement | null;
|
||||
readonly ui: EditorUI;
|
||||
}
|
||||
}
|
||||
|
||||
// core/command
|
||||
|
||||
export class Command<T = undefined> implements ckutils.Emitter, ckutils.Observable {
|
||||
readonly editor: editor.Editor;
|
||||
readonly isEnabled: boolean;
|
||||
readonly value: T | undefined;
|
||||
|
||||
constructor(editor: editor.Editor);
|
||||
destroy(): void;
|
||||
execute(): void;
|
||||
refresh(): void;
|
||||
|
||||
// Emitter
|
||||
delegate(...events: string[]): ckutils.EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | ckutils.EventInfo<ckutils.Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: ckutils.Emitter, event: string, callback: Function, options?: {priority?: ckutils.PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: ckutils.Emitter): void;
|
||||
stopListening(emitter?: ckutils.Emitter, event?: string, callback?: Function): void;
|
||||
|
||||
// Observable
|
||||
bind(...bindProperties: string[]): ckutils.BindChain;
|
||||
decorate(methodName: string): void;
|
||||
set(name: object): void;
|
||||
set(name: string, value: any): void;
|
||||
unbind(...unbindProperties: string[]): void;
|
||||
}
|
||||
|
||||
// core/commandcollection
|
||||
|
||||
export class CommandCollection {
|
||||
constructor();
|
||||
[Symbol.iterator](): Iterator<[string, Command]>;
|
||||
add(commandName: string, command: Command): void;
|
||||
commands(): IterableIterator<Command>;
|
||||
destroy(): void;
|
||||
execute(commandName: string, ...commandParams: any[]): void;
|
||||
get(commandName: string): Command;
|
||||
names(): IterableIterator<string>;
|
||||
}
|
||||
|
||||
// core/editingkeystrokehandler
|
||||
|
||||
export class EditingKeystrokeHandler extends ckutils.KeystrokeHandler {
|
||||
readonly editor: editor.Editor;
|
||||
|
||||
constructor(editor: editor.Editor);
|
||||
set(
|
||||
keystroke: string | Array<string | number>,
|
||||
callback: string | ((keyEvtData: engine.view.observer.KeyEventData, cancel: () => void) => void),
|
||||
options?: {priority: ckutils.PriorityString | number}
|
||||
): void;
|
||||
}
|
||||
|
||||
// core/pendingactions
|
||||
|
||||
export class PendingActions extends Plugin {
|
||||
static readonly pluginName: "PendingActions";
|
||||
|
||||
first: null | ckutils.Observable & {message: string};
|
||||
readonly hasAny: boolean;
|
||||
|
||||
[Symbol.iterator](): Iterator<ckutils.Observable & {message: string}>;
|
||||
add(message: string): ckutils.Observable & {message: string};
|
||||
remove(action: ckutils.Observable & {message: string}): void;
|
||||
}
|
||||
|
||||
// core/plugin
|
||||
|
||||
export abstract class Plugin<T = void> implements ckutils.Emitter, ckutils.Observable {
|
||||
readonly editor: editor.Editor;
|
||||
|
||||
static readonly pluginName?: string;
|
||||
static readonly requires?: Array<new(editor: editor.Editor) => Plugin>;
|
||||
|
||||
constructor(editor: editor.Editor);
|
||||
afterInit?(): null | Promise<T>;
|
||||
destroy?(): null | Promise<T>;
|
||||
init?(): null | Promise<T>;
|
||||
|
||||
// Emitter
|
||||
delegate(...events: string[]): ckutils.EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | ckutils.EventInfo<ckutils.Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: ckutils.Emitter, event: string, callback: Function, options?: {priority?: ckutils.PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: ckutils.PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: ckutils.Emitter): void;
|
||||
stopListening(emitter?: ckutils.Emitter, event?: string, callback?: Function): void;
|
||||
|
||||
// Observable
|
||||
bind(...bindProperties: string[]): ckutils.BindChain;
|
||||
decorate(methodName: string): void;
|
||||
set(name: object): void;
|
||||
set(name: string, value: any): void;
|
||||
unbind(...unbindProperties: string[]): void;
|
||||
}
|
||||
|
||||
// PluginInterface, see Plugin
|
||||
|
||||
// core/plugincollection
|
||||
|
||||
export class PluginCollection<P extends Plugin<any>> {
|
||||
constructor(
|
||||
editor: editor.Editor,
|
||||
availablePlugins?: Array<new(editor: editor.Editor) => P>
|
||||
);
|
||||
|
||||
[Symbol.iterator](): Iterator<[new(editor: editor.Editor) => P, P]>;
|
||||
|
||||
destroy(): Promise<Array<P & {destroy(): void | null | Promise<any>}>>;
|
||||
|
||||
get(
|
||||
key: string | (new(editor: editor.Editor) => P)
|
||||
): P | undefined;
|
||||
|
||||
load(
|
||||
plugins: Array<string | (new(editor: editor.Editor) => P)>,
|
||||
removePlugins?: Array<string | (new(editor: editor.Editor) => P)>
|
||||
): Promise<P[]>;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom",
|
||||
"es2015.promise"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ckeditor__ckeditor5-core-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": {
|
||||
"options": [
|
||||
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
|
||||
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
|
||||
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
|
||||
["String", "Avoid using the `String` type. Did you mean `string`?"],
|
||||
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"]
|
||||
]
|
||||
},
|
||||
"no-empty-interface": false,
|
||||
"prefer-switch": false,
|
||||
"quotemark": [
|
||||
true,
|
||||
"double",
|
||||
"avoid-escape",
|
||||
"avoid-template"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import * as engine from "ckeditor__ckeditor5-engine";
|
||||
|
||||
declare let pattern: engine.view.MatcherPattern;
|
||||
|
||||
pattern = {name: /^p/};
|
||||
|
||||
pattern = {
|
||||
attributes: {
|
||||
title: "foobar",
|
||||
foo: /^\w+/,
|
||||
bar: true,
|
||||
}
|
||||
};
|
||||
|
||||
pattern = {
|
||||
classes: "foobar"
|
||||
};
|
||||
|
||||
pattern = {
|
||||
classes: /foo.../
|
||||
};
|
||||
|
||||
pattern = {
|
||||
classes: ["baz", "bar", /foo.../]
|
||||
};
|
||||
|
||||
pattern = {
|
||||
styles: {
|
||||
position: "absolute",
|
||||
color: /^\w*blue$/
|
||||
}
|
||||
};
|
||||
|
||||
pattern = {
|
||||
name: "span",
|
||||
styles: {
|
||||
"font-weight": "bold"
|
||||
},
|
||||
classes: "highlighted"
|
||||
};
|
||||
|
||||
pattern = (element: engine.view.Element) => {
|
||||
if (element.name === "div" && element.childCount > 0) {
|
||||
return {name: true};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
pattern = (element: engine.view.Element) => {
|
||||
if (element.name === "p") {
|
||||
const fontSize = element.getStyle("font-size")!;
|
||||
const size = fontSize.match(/(\d+)/px);
|
||||
|
||||
if (size && Number(size[1]) > 26) {
|
||||
return {name: true, attribute: ["font-size"]};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
declare let viewDefinition: engine.view.ElementDefinition;
|
||||
|
||||
viewDefinition = "p";
|
||||
|
||||
viewDefinition = {
|
||||
name: "h1",
|
||||
classes: ["foo", "bar"],
|
||||
};
|
||||
|
||||
viewDefinition = {
|
||||
name: "span",
|
||||
styles: {
|
||||
"font-size": "12px",
|
||||
"font-weight": "bold",
|
||||
},
|
||||
attributes: {
|
||||
"data-id": "123",
|
||||
}
|
||||
};
|
||||
+1368
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ckeditor__ckeditor5-engine-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": {
|
||||
"options": [
|
||||
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
|
||||
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
|
||||
["String", "Avoid using the `String` type. Did you mean `string`?"],
|
||||
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"]
|
||||
]
|
||||
},
|
||||
"no-empty-interface": false,
|
||||
"quotemark": [
|
||||
true,
|
||||
"double",
|
||||
"avoid-escape",
|
||||
"avoid-template"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -489,24 +489,30 @@ utils.mapsEqual(map, map);
|
||||
|
||||
// utils/mix ==================================================================
|
||||
|
||||
class Editor {
|
||||
b: () => number;
|
||||
}
|
||||
|
||||
interface SomeMixin {
|
||||
a: () => string;
|
||||
}
|
||||
|
||||
class Editor implements SomeMixin {
|
||||
a: () => string;
|
||||
b() { return 3; }
|
||||
}
|
||||
|
||||
const SomeMixin = {
|
||||
a() {
|
||||
return "a";
|
||||
}
|
||||
a() { return "a"; }
|
||||
};
|
||||
|
||||
const SomeMixinNum = {
|
||||
a() { return 3; }
|
||||
};
|
||||
|
||||
utils.mix(Editor, SomeMixin);
|
||||
const mixEditor = new Editor() as Editor & SomeMixin;
|
||||
mixEditor.a();
|
||||
mixEditor.b();
|
||||
// $ExpectError
|
||||
utils.mix(Editor, SomeMixinNum);
|
||||
|
||||
const editor = new Editor();
|
||||
str = editor.a();
|
||||
num = editor.b();
|
||||
|
||||
// utils/nth ==================================================================
|
||||
|
||||
|
||||
+6
-2
@@ -367,7 +367,11 @@ export class KeystrokeHandler {
|
||||
destroy(): void;
|
||||
listenTo(emitter: Emitter): void;
|
||||
press(keyEvtData: KeystrokeInfo): boolean;
|
||||
set(keystroke: string | Array<string | number>, callback: Function, options?: {priority?: PriorityString | number}): void;
|
||||
set(
|
||||
keystroke: string | Array<string | number>,
|
||||
callback: (keyEvtData: KeystrokeInfo, cancel: () => void) => void,
|
||||
options?: {priority?: PriorityString | number}
|
||||
): void;
|
||||
}
|
||||
|
||||
// utils/locale
|
||||
@@ -392,7 +396,7 @@ export function mapsEqual<K, V>(mapsA: Map<K, V>, mapsB: Map<K, V>): boolean;
|
||||
|
||||
// utils/mix
|
||||
|
||||
export function mix(baseClass: {new(): any}, ...mixins: any[]): void;
|
||||
export function mix<T>(baseClass: {new(...p: any[]): T}, ...mixins: Array<Partial<T>>): void;
|
||||
|
||||
// utils/nth
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import Box = require('cli-box');
|
||||
|
||||
// Create a simple box
|
||||
const b1: Box = Box("20x10");
|
||||
// console.log(b1.toString());
|
||||
|
||||
// Set custom marks
|
||||
const b2: Box = new Box({
|
||||
w: 10
|
||||
, h: 10
|
||||
, stringify: false
|
||||
, marks: {
|
||||
nw: "╔"
|
||||
, n: "══"
|
||||
, ne: "╗"
|
||||
, e: "║"
|
||||
, se: "╝"
|
||||
, s: "══"
|
||||
, sw: "╚"
|
||||
, w: "║"
|
||||
, b: "░░"
|
||||
}
|
||||
});
|
||||
// console.log(b2.stringify());
|
||||
|
||||
// Box with text and use the stringify
|
||||
const b3: Box = Box("20x10", "I will be \u001b[31mdis\u001b[0mplayed inside! \n A\u001b[34mnd I'm in a\u001b[0m new line!");
|
||||
// console.log(b3);
|
||||
|
||||
// Box with aligned text to top-right
|
||||
const b4: Box = Box("30x20", {
|
||||
text: "Box content"
|
||||
, stretch: true
|
||||
, autoEOL: true
|
||||
, vAlign: "top"
|
||||
, hAlign: "right"
|
||||
});
|
||||
// console.log(b4);
|
||||
|
||||
// Full screen box
|
||||
const b5: Box = Box({fullscreen: true, marks: {}}, "Hello World!");
|
||||
// console.log(b5.toString());
|
||||
|
||||
const b5s: string = Box({stringify: true, fullscreen: true, marks: {}}, "Hello World!");
|
||||
const b5ns: Box = Box({stringify: false, fullscreen: true, marks: {}}, "Hello World!");
|
||||
|
||||
const defaults = Box.defaults;
|
||||
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
// Type definitions for cli-box 6.0
|
||||
// Project: https://github.com/IonicaBizau/node-cli-box
|
||||
// Definitions by: Kent Wong <https://github.com/athasach>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/*~ Note that ES6 modules cannot directly export callable functions.
|
||||
*~ This file should be imported using the CommonJS-style:
|
||||
*~ import x = require('someLibrary');
|
||||
*~
|
||||
*~ Refer to the documentation to understand common
|
||||
*~ workarounds for this limitation of ES6 modules.
|
||||
*/
|
||||
|
||||
/*~ This declaration specifies that the function
|
||||
*~ is the exported object from the file
|
||||
*/
|
||||
export = Box;
|
||||
|
||||
type MarksKeys = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'b';
|
||||
type Marks = Record<MarksKeys, string>;
|
||||
|
||||
interface Options {
|
||||
w?: number;
|
||||
width?: number;
|
||||
h?: number;
|
||||
height?: number;
|
||||
fullscreen?: boolean;
|
||||
stringify?: boolean;
|
||||
marks?: Partial<Marks>;
|
||||
}
|
||||
|
||||
interface Text {
|
||||
text?: string;
|
||||
stretch?: boolean;
|
||||
autoEOL?: boolean;
|
||||
hAlign?: 'left' | 'middle' | 'right';
|
||||
vAlign?: 'top' | 'center' | 'bottom';
|
||||
}
|
||||
|
||||
interface Box {
|
||||
stringify(): string;
|
||||
settings: {
|
||||
width: number;
|
||||
height: number;
|
||||
marks: Marks;
|
||||
lines: Array<{
|
||||
text: string;
|
||||
offset: {
|
||||
y: number;
|
||||
}
|
||||
}>
|
||||
};
|
||||
options: {
|
||||
width: number;
|
||||
height: number;
|
||||
marks: Marks;
|
||||
fullscreen: boolean;
|
||||
stringify: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface BoxConstructor {
|
||||
new(options: Options | string, text?: Text | string): Box;
|
||||
(options: (Exclude<Options, 'stringify'> & { stringify: true }), text?: Text | string): string;
|
||||
(options: Options | string, text?: Text | string): Box;
|
||||
defaults: { marks: Marks };
|
||||
}
|
||||
|
||||
declare const Box: BoxConstructor;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cli-box-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,14 @@
|
||||
import commandExists = require('command-exists');
|
||||
|
||||
commandExists('ls', (err, commandExists) => {
|
||||
// $ExpectType boolean
|
||||
commandExists;
|
||||
});
|
||||
|
||||
commandExists('ls').then(command => {
|
||||
// $ExpectType string
|
||||
command;
|
||||
});
|
||||
|
||||
// $ExpectType boolean
|
||||
commandExists.sync('ls');
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for command-exists 1.2
|
||||
// Project: https://github.com/mathisonian/command-exists
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = commandExists;
|
||||
|
||||
declare function commandExists(commandName: string): Promise<string>;
|
||||
declare function commandExists(
|
||||
commandName: string,
|
||||
cb: (error: null, exists: boolean) => void
|
||||
): void;
|
||||
|
||||
declare namespace commandExists {
|
||||
function sync(commandName: string): boolean;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"command-exists-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,167 +1,242 @@
|
||||
import * as commonTags from 'common-tags';
|
||||
import {
|
||||
html,
|
||||
safeHtml,
|
||||
oneLine,
|
||||
oneLineTrim,
|
||||
stripIndent,
|
||||
stripIndents,
|
||||
inlineLists,
|
||||
oneLineInlineLists,
|
||||
commaLists,
|
||||
commaListsOr,
|
||||
commaListsAnd,
|
||||
oneLineCommaLists,
|
||||
oneLineCommaListsOr,
|
||||
oneLineCommaListsAnd,
|
||||
id,
|
||||
TemplateTag,
|
||||
trimResultTransformer,
|
||||
stripIndentTransformer,
|
||||
replaceResultTransformer,
|
||||
replaceSubstitutionTransformer,
|
||||
inlineArrayTransformer,
|
||||
splitStringTransformer,
|
||||
createTag,
|
||||
TemplateTransformer,
|
||||
replaceStringTransformer,
|
||||
} from 'common-tags';
|
||||
|
||||
/* Test Built-in Tags */
|
||||
|
||||
commonTags.commaLists `
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
const userMessages = ['hi', 'what are you up to?', '<script>alert("something evil")</script>'];
|
||||
html`
|
||||
<div class="chat-list">
|
||||
<ul>
|
||||
${userMessages.map(message => safeHtml`<li>${message}</li>`)}
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
commonTags.commaListsAnd`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commonTags.commaListsOr`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
let fruits = ['apple', 'orange', 'watermelon'];
|
||||
|
||||
commonTags.html`
|
||||
<div class="list">
|
||||
<ul>
|
||||
${fruits.map(fruit => `<li>${fruit}</li>`)}
|
||||
${'<li>kiwi</li>\n<li>guava</li>'}
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
commonTags.codeBlock`
|
||||
<div class="list">
|
||||
<ul>
|
||||
${fruits.map(fruit => `<li>${fruit}</li>`)}
|
||||
${'<li>kiwi</li>\n<li>guava</li>'}
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
commonTags.source`
|
||||
<div class="list">
|
||||
<ul>
|
||||
${fruits.map(fruit => `<li>${fruit}</li>`)}
|
||||
${'<li>kiwi</li>\n<li>guava</li>'}
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
||||
let userMessages = ['hi', 'what are you up to?', '<script>alert("something evil")</script>']
|
||||
commonTags.html`
|
||||
<div class="chat-list">
|
||||
<ul>
|
||||
${userMessages.map(message => commonTags.safeHtml`<li>${message}</li>`)}
|
||||
</ul>
|
||||
</div>
|
||||
`
|
||||
|
||||
commonTags.oneLine`
|
||||
oneLine`
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
`;
|
||||
|
||||
commonTags.oneLineTrim`
|
||||
oneLineTrim`
|
||||
https://news.com/article
|
||||
?utm_source=designernews.co
|
||||
`;
|
||||
|
||||
commonTags.oneLineCommaLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commonTags.oneLineCommaListsOr`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commonTags.oneLineCommaListsAnd`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commonTags.inlineLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commonTags.oneLineInlineLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
let verb = 'notice';
|
||||
|
||||
commonTags.stripIndent`
|
||||
const verb = 'notice';
|
||||
stripIndent`
|
||||
This is a multi-line string.
|
||||
You'll ${verb} that it is indented.
|
||||
We don't want to output this indentation.
|
||||
But we do want to keep this line indented.
|
||||
`;
|
||||
|
||||
commonTags.stripIndents`
|
||||
stripIndents`
|
||||
This is a multi-line string.
|
||||
You'll ${verb} that it is indented.
|
||||
We don't want to output this indentation.
|
||||
We don't want to keep this line indented either.
|
||||
`;
|
||||
|
||||
/* Test Tag Constructor */
|
||||
inlineLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
new commonTags.TemplateTag();
|
||||
oneLineInlineLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
const substitutionReplacer = (oldValue : string, newValue : string) => ({
|
||||
onSubstitution(substitution : string, resultSoFar : string) {
|
||||
commaLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commaListsOr`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
commaListsAnd`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
oneLineCommaLists`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
oneLineCommaListsOr`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
oneLineCommaListsAnd`
|
||||
I like ${['apples', 'bananas', 'watermelons']}
|
||||
They're good!
|
||||
`;
|
||||
|
||||
id`hello ${'world'}`;
|
||||
|
||||
oneLine(String.raw)`
|
||||
foo
|
||||
bar\nbaz
|
||||
`;
|
||||
|
||||
stripIndent(' foo\n bar');
|
||||
|
||||
const doNothing = createTag();
|
||||
doNothing`foo bar`;
|
||||
|
||||
const substitutionReplacer = (oldValue: string, newValue: string): TemplateTransformer => ({
|
||||
onSubstitution(substitution, resultSoFar) {
|
||||
if (substitution === oldValue) {
|
||||
return newValue;
|
||||
}
|
||||
return substitution;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
new commonTags.TemplateTag(substitutionReplacer('fizz', 'buzz'));
|
||||
const replaceFizzWithBuzz = createTag(substitutionReplacer('fizz', 'buzz'));
|
||||
replaceFizzWithBuzz`foo bar ${'fizz'}`;
|
||||
|
||||
new commonTags.TemplateTag(
|
||||
substitutionReplacer('fizz', 'buzz'),
|
||||
substitutionReplacer('foo', 'bar')
|
||||
createTag();
|
||||
createTag(substitutionReplacer('fizz', 'buzz'));
|
||||
createTag(substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar'));
|
||||
createTag([substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar')]);
|
||||
new TemplateTag();
|
||||
new TemplateTag(substitutionReplacer('fizz', 'buzz'));
|
||||
new TemplateTag(substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar'));
|
||||
new TemplateTag([substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar')]);
|
||||
|
||||
const tt: TemplateTransformer<{ foo: string }> = {
|
||||
getInitialContext() {
|
||||
return { foo: 'bar' };
|
||||
},
|
||||
onString(str, context) {
|
||||
// $ExpectType string
|
||||
str;
|
||||
// $ExpectType { foo: string; }
|
||||
context;
|
||||
return '';
|
||||
},
|
||||
onSubstitution(substitution, resultSoFar, context) {
|
||||
// $ExpectType string
|
||||
substitution;
|
||||
// $ExpectType string
|
||||
resultSoFar;
|
||||
// $ExpectType { foo: string; }
|
||||
context;
|
||||
return '';
|
||||
},
|
||||
onEndResult(endResult, context) {
|
||||
// $ExpectType string
|
||||
endResult;
|
||||
// $ExpectType { foo: string; }
|
||||
context;
|
||||
return '';
|
||||
},
|
||||
};
|
||||
|
||||
createTag({});
|
||||
createTag(tt);
|
||||
createTag({
|
||||
onString: str => `${str}!`,
|
||||
});
|
||||
createTag({
|
||||
onSubstitution: substitution => `${substitution}!`,
|
||||
});
|
||||
createTag({
|
||||
onEndResult: endResult => `${endResult}!`,
|
||||
});
|
||||
new TemplateTag({});
|
||||
new TemplateTag(tt);
|
||||
new TemplateTag({
|
||||
onString: str => `${str}!`,
|
||||
});
|
||||
new TemplateTag({
|
||||
onSubstitution: substitution => `${substitution}!`,
|
||||
});
|
||||
new TemplateTag({
|
||||
onEndResult: endResult => `${endResult}!`,
|
||||
});
|
||||
|
||||
createTag(trimResultTransformer());
|
||||
createTag(trimResultTransformer(''));
|
||||
createTag(trimResultTransformer('start'));
|
||||
createTag(trimResultTransformer('end'));
|
||||
createTag(trimResultTransformer('left'));
|
||||
createTag(trimResultTransformer('right'));
|
||||
|
||||
createTag(stripIndentTransformer());
|
||||
createTag(stripIndentTransformer('initial'));
|
||||
createTag(stripIndentTransformer('all'));
|
||||
|
||||
createTag(replaceResultTransformer('foo', 'bar'));
|
||||
createTag(replaceResultTransformer(/baz/g, 'bar'));
|
||||
createTag(
|
||||
replaceResultTransformer(/baz/g, (substring, ...matches) => {
|
||||
// $ExpectType string
|
||||
substring;
|
||||
// $ExpectType any[]
|
||||
matches;
|
||||
return '';
|
||||
})
|
||||
);
|
||||
|
||||
new commonTags.TemplateTag([
|
||||
substitutionReplacer('fizz', 'buzz'),
|
||||
substitutionReplacer('foo', 'bar')
|
||||
]);
|
||||
createTag(replaceSubstitutionTransformer('foo', 'bar'));
|
||||
createTag(replaceSubstitutionTransformer(/baz/g, 'bar'));
|
||||
createTag(
|
||||
replaceSubstitutionTransformer(/baz/g, (substring, ...matches) => {
|
||||
// $ExpectType string
|
||||
substring;
|
||||
// $ExpectType any[]
|
||||
matches;
|
||||
return '';
|
||||
})
|
||||
);
|
||||
|
||||
new commonTags.TemplateTag({});
|
||||
createTag(replaceStringTransformer('foo', 'bar'));
|
||||
createTag(replaceStringTransformer(/baz/g, 'bar'));
|
||||
createTag(
|
||||
replaceStringTransformer(/baz/g, (substring, ...matches) => {
|
||||
// $ExpectType string
|
||||
substring;
|
||||
// $ExpectType any[]
|
||||
matches;
|
||||
return '';
|
||||
})
|
||||
);
|
||||
|
||||
new commonTags.TemplateTag({
|
||||
onEndResult: endResult => `${endResult}!`
|
||||
});
|
||||
createTag(inlineArrayTransformer());
|
||||
createTag(inlineArrayTransformer({}));
|
||||
createTag(inlineArrayTransformer({ separator: 'foo' }));
|
||||
createTag(inlineArrayTransformer({ conjunction: 'bar' }));
|
||||
createTag(inlineArrayTransformer({ serial: true }));
|
||||
|
||||
new commonTags.TemplateTag({
|
||||
onSubstitution: substitution => `${substitution}!`,
|
||||
onEndResult: endResult => `${endResult}!`
|
||||
});
|
||||
|
||||
/* Tests Built-in Transformers */
|
||||
|
||||
new commonTags.TemplateTag(commonTags.trimResultTransformer());
|
||||
new commonTags.TemplateTag(commonTags.trimResultTransformer('left'));
|
||||
new commonTags.TemplateTag(commonTags.trimResultTransformer('right'));
|
||||
|
||||
new commonTags.TemplateTag(commonTags.stripIndentTransformer());
|
||||
new commonTags.TemplateTag(commonTags.stripIndentTransformer('initial'));
|
||||
new commonTags.TemplateTag(commonTags.stripIndentTransformer('all'));
|
||||
|
||||
new commonTags.TemplateTag(commonTags.replaceResultTransformer('foo', 'bar'));
|
||||
new commonTags.TemplateTag(commonTags.replaceSubstitutionTransformer(/baz/g, 'bar'));
|
||||
|
||||
new commonTags.TemplateTag(commonTags.replaceSubstitutionTransformer('foo', 'bar'));
|
||||
new commonTags.TemplateTag(commonTags.replaceSubstitutionTransformer(/baz/g, 'bar'));
|
||||
|
||||
new commonTags.TemplateTag(commonTags.inlineArrayTransformer());
|
||||
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({}));
|
||||
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({separator: 'foo'}));
|
||||
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({conjunction: 'bar'}));
|
||||
|
||||
new commonTags.TemplateTag(commonTags.splitStringTransformer('foo'));
|
||||
createTag(splitStringTransformer('foo'));
|
||||
|
||||
Vendored
+212
-59
@@ -1,67 +1,220 @@
|
||||
// Type definitions for common-tags v1.4.0
|
||||
// Type definitions for common-tags 1.8
|
||||
// Project: https://github.com/declandewet/common-tags
|
||||
// Definitions by: Viktor Zozuliak <https://github.com/zuzusik>
|
||||
// Paul Wang <https://github.com/tzupengwang>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare module 'common-tags' {
|
||||
type TemplateTag = (literals: TemplateStringsArray, ...placeholders: any[]) => string;
|
||||
export as namespace commonTags;
|
||||
|
||||
type TemplateTransformer = {
|
||||
onSubstitution?: (substitution: string, resultSoFar: string) => string;
|
||||
onEndResult?: (endResult : string) => string;
|
||||
}
|
||||
export type JSTag = (literals: TemplateStringsArray, ...placeholders: any[]) => string;
|
||||
|
||||
/* Built-in Tags */
|
||||
export var commaLists: TemplateTag;
|
||||
|
||||
export var commaListsAnd: TemplateTag;
|
||||
|
||||
export var commaListsOr: TemplateTag;
|
||||
|
||||
export var html: TemplateTag;
|
||||
|
||||
export var codeBlock: TemplateTag;
|
||||
|
||||
export var source: TemplateTag;
|
||||
|
||||
export var safeHtml: TemplateTag;
|
||||
|
||||
export var oneLine: TemplateTag;
|
||||
|
||||
export var oneLineTrim: TemplateTag;
|
||||
|
||||
export var oneLineCommaLists: TemplateTag;
|
||||
|
||||
export var oneLineCommaListsOr: TemplateTag;
|
||||
|
||||
export var oneLineCommaListsAnd: TemplateTag;
|
||||
|
||||
export var inlineLists: TemplateTag;
|
||||
|
||||
export var oneLineInlineLists: TemplateTag;
|
||||
|
||||
export var stripIndent: TemplateTag;
|
||||
|
||||
export var stripIndents: TemplateTag;
|
||||
|
||||
/* New Tag Constructor */
|
||||
export var TemplateTag: {
|
||||
new(): TemplateTag;
|
||||
new(...transformers: TemplateTransformer[]): TemplateTag;
|
||||
new(transformers: TemplateTransformer[]): TemplateTag;
|
||||
};
|
||||
|
||||
/* Built-in Transformers */
|
||||
export var trimResultTransformer: (side?: 'left'|'right') => TemplateTransformer;
|
||||
|
||||
export var stripIndentTransformer: (type?: 'initial'|'all') => TemplateTransformer;
|
||||
|
||||
export var replaceResultTransformer: (replaceWhat: string|RegExp, replaceWith: string) => TemplateTransformer;
|
||||
|
||||
export var replaceSubstitutionTransformer: (replaceWhat: string|RegExp, replaceWith: string) => TemplateTransformer;
|
||||
|
||||
export var inlineArrayTransformer: (opts?: {separator?: string, conjunction?: string}) => TemplateTransformer;
|
||||
|
||||
export var splitStringTransformer: (splitBy: string) => TemplateTransformer;
|
||||
export interface TemplateTag {
|
||||
(str: string): string;
|
||||
(tag: JSTag): TemplateTag;
|
||||
(literals: TemplateStringsArray, ...placeholders: any[]): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* You'll often find that you might want to include an array in a template.
|
||||
* Typically, doing something like `${array.join(', ')}` would work - but what if you're printing a list of items
|
||||
* in an HTML template and want to maintain the indentation? You'd have to count the spaces manually and include
|
||||
* them in the `.join()` call - which is a bit ugly for my taste.
|
||||
* This tag properly indents arrays, as well as newline characters in string substitutions,
|
||||
* by converting them to an array split by newline and re-using the same array inclusion logic.
|
||||
*/
|
||||
export const html: TemplateTag;
|
||||
|
||||
/**
|
||||
* alias for `html`
|
||||
*/
|
||||
export const codeBlock: TemplateTag;
|
||||
|
||||
/**
|
||||
* alias for `html`
|
||||
*/
|
||||
export const source: TemplateTag;
|
||||
|
||||
/**
|
||||
* A tag very similar to `html` but it does safe HTML escaping for strings coming from substitutions.
|
||||
* When combined with regular `html` tag, you can do basic HTML templating that is safe from
|
||||
* XSS (Cross-Site Scripting) attacks.
|
||||
*/
|
||||
export const safeHtml: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to keep your single-line strings under 80 characters without resorting to crazy string concatenation.
|
||||
*/
|
||||
export const oneLine: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to keep your single-line strings under 80 characters while trimming the new lines.
|
||||
*/
|
||||
export const oneLineTrim: TemplateTag;
|
||||
|
||||
/**
|
||||
* If you want to strip the initial indentation from the beginning of each line in a multiline string.
|
||||
* Important note: this tag will not indent multiline strings coming from the substitutions.
|
||||
* If you want that behavior, use the `html` tag (aliases: `source`, `codeBlock`).
|
||||
*/
|
||||
export const stripIndent: TemplateTag;
|
||||
|
||||
/**
|
||||
* If you want to strip *all* of the indentation from the beginning of each line in a multiline string.
|
||||
*/
|
||||
export const stripIndents: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a list.
|
||||
*/
|
||||
export const inlineLists: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a list, rendered out on a single line.
|
||||
*/
|
||||
export const oneLineInlineLists: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a comma-separated list.
|
||||
*/
|
||||
export const commaLists: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or".
|
||||
*/
|
||||
export const commaListsOr: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and".
|
||||
*/
|
||||
export const commaListsAnd: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a comma-separated list, and is rendered out on to a single line.
|
||||
*/
|
||||
export const oneLineCommaLists: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or", and is rendered out on to a single line.
|
||||
*/
|
||||
export const oneLineCommaListsOr: TemplateTag;
|
||||
|
||||
/**
|
||||
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and", and is rendered out on to a single line.
|
||||
*/
|
||||
export const oneLineCommaListsAnd: TemplateTag;
|
||||
|
||||
/**
|
||||
* A no-op tag that might come in useful in some scenarios, e.g. mocking.
|
||||
*/
|
||||
export const id: TemplateTag;
|
||||
|
||||
export interface TemplateTransformer<TCtx = { [key: string]: any }> {
|
||||
/**
|
||||
* Called before everything else.
|
||||
* The result of this hook will be passed to other hooks as `context`.
|
||||
* If omitted, `context` will be an empty object.
|
||||
*/
|
||||
getInitialContext?: () => TCtx;
|
||||
/**
|
||||
* Called when the tag encounters a string.
|
||||
* (a string is whatever's not inside "${}" in your template literal)
|
||||
* `str` is the value of the current string
|
||||
*/
|
||||
onString?: (str: string, context: TCtx) => string;
|
||||
/**
|
||||
* Called when the tag encounters a substitution.
|
||||
* (a substitution is whatever's inside "${}" in your template literal)
|
||||
* `substitution` is the value of the current substitution
|
||||
* `resultSoFar` is the end result up to the point of this substitution
|
||||
*/
|
||||
onSubstitution?: (substitution: string, resultSoFar: string, context: TCtx) => string;
|
||||
/**
|
||||
* Called when all substitutions have been parsed
|
||||
* `endResult` is the final value.
|
||||
*/
|
||||
onEndResult?: (endResult: string, context: TCtx) => string;
|
||||
}
|
||||
|
||||
export type PluginFunction = (oldValue: string, newValue: string) => TemplateTransformer<any>;
|
||||
|
||||
/**
|
||||
* New Tag factory
|
||||
*/
|
||||
export function createTag(transformers?: Array<TemplateTransformer<any>>): TemplateTag;
|
||||
export function createTag(...transformers: Array<TemplateTransformer<any>>): TemplateTag;
|
||||
export function createTag(...pluginFunctions: PluginFunction[]): TemplateTag;
|
||||
|
||||
export const TemplateTag: {
|
||||
/**
|
||||
* New Tag Constructor
|
||||
* @deprecated
|
||||
*/
|
||||
new (transformers?: Array<TemplateTransformer<any>>): TemplateTag;
|
||||
new (...transformers: Array<TemplateTransformer<any>>): TemplateTag;
|
||||
new (...pluginFunctions: PluginFunction[]): TemplateTag;
|
||||
};
|
||||
|
||||
/**
|
||||
* TemplateTag transformer that trims whitespace on the end result of a tagged template
|
||||
* @param [side=''] The side of the string to trim. Can be 'start' or 'end' (alternatively 'left' or 'right')
|
||||
* @return a TemplateTag transformer
|
||||
*/
|
||||
export function trimResultTransformer(
|
||||
side?: 'start' | 'end' | 'left' | 'right' | ''
|
||||
): TemplateTransformer;
|
||||
|
||||
/**
|
||||
* strips indentation from a template literal
|
||||
* @param [type='initial'] whether to remove all indentation or just leading indentation. can be 'all' or 'initial'
|
||||
* @return a TemplateTag transformer
|
||||
*/
|
||||
export function stripIndentTransformer(type?: 'initial' | 'all'): TemplateTransformer;
|
||||
|
||||
/**
|
||||
* Replaces a value or pattern in the end result with a new value.
|
||||
* @param replaceWhat the value or pattern that should be replaced
|
||||
* @param replaceWith the replacement value
|
||||
* @return a TemplateTag transformer
|
||||
*/
|
||||
export function replaceResultTransformer(
|
||||
replaceWhat: string | RegExp,
|
||||
replaceWith: string | ((substring: string, ...args: any[]) => string)
|
||||
): TemplateTransformer;
|
||||
|
||||
/**
|
||||
* Replaces the result of all substitutions (results of calling ${ ... }) with a new value.
|
||||
* Same as for `replaceResultTransformer`, replaceWhat can be a string or regular expression and replaceWith is the new value.
|
||||
*/
|
||||
export function replaceSubstitutionTransformer(
|
||||
replaceWhat: string | RegExp,
|
||||
replaceWith: string | ((substring: string, ...args: any[]) => string)
|
||||
): TemplateTransformer;
|
||||
|
||||
/**
|
||||
* Replaces the result of all strings (what's not in ${ ... }) with a new value.
|
||||
* Same as for `replaceResultTransformer`, replaceWhat can be a string or regular expression and replaceWith is the new value.
|
||||
*/
|
||||
export function replaceStringTransformer(
|
||||
replaceWhat: string | RegExp,
|
||||
replaceWith: string | ((substring: string, ...args: any[]) => string)
|
||||
): TemplateTransformer;
|
||||
|
||||
/**
|
||||
* Converts an array substitution to a string containing a list
|
||||
* @param [opts.separator=''] what to separate each item with (always followed by a space)
|
||||
* @param [opts.conjunction=''] replace the last separator with this value
|
||||
* @param [opts.serial=false] should the separator be included before the conjunction? As in the case of serial/oxford commas
|
||||
* @return a TemplateTag transformer
|
||||
*/
|
||||
export function inlineArrayTransformer(opts?: {
|
||||
separator?: string;
|
||||
conjunction?: string;
|
||||
serial?: boolean;
|
||||
}): TemplateTransformer;
|
||||
|
||||
/**
|
||||
* Splits a string substitution into an array by the provided splitBy substring, only if the string contains the splitBy substring.
|
||||
*/
|
||||
export function splitStringTransformer(splitBy: string): TemplateTransformer;
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -1,15 +1,76 @@
|
||||
import { Configuration } from 'webpack';
|
||||
import CompressionPlugin = require('compression-webpack-plugin');
|
||||
|
||||
const c: Configuration = {
|
||||
new CompressionPlugin();
|
||||
|
||||
new CompressionPlugin({
|
||||
include: ["a"] as ReadonlyArray<string>,
|
||||
exclude: [/a/g] as ReadonlyArray<RegExp>,
|
||||
test: "a",
|
||||
});
|
||||
|
||||
const config: Configuration = {
|
||||
plugins: [
|
||||
new CompressionPlugin({
|
||||
asset: "[path].gz[query]",
|
||||
algorithm: "gzip",
|
||||
cache: true,
|
||||
filename: "[path].gz[query]",
|
||||
minRatio: 0.8,
|
||||
test: /\.js$|\.html$/,
|
||||
threshold: 10240,
|
||||
minRatio: 0.8
|
||||
deleteOriginalAssets: true
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const configDefaultAlgo = new CompressionPlugin({
|
||||
compressionOptions: { level: 7 }
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
new CompressionPlugin({ asset: "[path].gz[query]" });
|
||||
|
||||
const zlib: Configuration = {
|
||||
plugins: [
|
||||
new CompressionPlugin({
|
||||
algorithm: "deflate",
|
||||
compressionOptions: {
|
||||
flush: 5,
|
||||
windowBits: 20,
|
||||
level: 7
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const badZlib: Configuration = {
|
||||
plugins: [
|
||||
// $ExpectError
|
||||
new CompressionPlugin({
|
||||
algorithm: "deflate",
|
||||
compressionOptions: 5
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
function customAlgorithm(input: string, options: number, callback: (err: Error, result: Buffer) => void) {
|
||||
}
|
||||
|
||||
const custom: Configuration = {
|
||||
plugins: [
|
||||
new CompressionPlugin({
|
||||
algorithm: customAlgorithm,
|
||||
compressionOptions: 5
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const badCustom: Configuration = {
|
||||
plugins: [
|
||||
// $ExpectError
|
||||
new CompressionPlugin({
|
||||
algorithm: customAlgorithm,
|
||||
compressionOptions: { flush: 5 }
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
+32
-27
@@ -1,42 +1,47 @@
|
||||
// Type definitions for compression-webpack-plugin 0.4
|
||||
// Type definitions for compression-webpack-plugin 2.0
|
||||
// Project: https://github.com/webpack-contrib/compression-webpack-plugin
|
||||
// Definitions by: Anton Kandybo <https://github.com/dublicator>
|
||||
// Rhys van der Waerden <https://github.com/rhys-vdw>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Plugin } from 'webpack';
|
||||
import { ZlibOptions as ZlibCompressionOptions } from 'zlib';
|
||||
|
||||
export = CompressionPlugin;
|
||||
|
||||
declare class CompressionPlugin extends Plugin {
|
||||
constructor(options?: CompressionPlugin.Options);
|
||||
declare class CompressionPlugin<O = any> extends Plugin {
|
||||
constructor(options?: CompressionPlugin.Options<O>);
|
||||
}
|
||||
|
||||
declare namespace CompressionPlugin {
|
||||
interface Options {
|
||||
asset?: string;
|
||||
algorithm?: string;
|
||||
type AlgorithmCallback = (error: Error | null, result: Buffer) => void;
|
||||
type Algorithm<O> = (source: string, options: O, callback: AlgorithmCallback) => void;
|
||||
|
||||
// NOTE: These are the async compression algorithms on the zlib object.
|
||||
type ZlibAlgorithm = 'deflate' | 'deflateRaw' | 'gzip';
|
||||
type Pattern = string | RegExp | ReadonlyArray<RegExp> | ReadonlyArray<string>;
|
||||
|
||||
interface BaseOptions {
|
||||
cache?: boolean | string;
|
||||
test?: RegExp | RegExp[];
|
||||
regExp?: RegExp | RegExp[];
|
||||
threshold?: number;
|
||||
deleteOriginalAssets?: boolean;
|
||||
exclude?: Pattern;
|
||||
filename?: string;
|
||||
include?: Pattern;
|
||||
minRatio?: number;
|
||||
|
||||
// zopfli options
|
||||
verbose?: boolean;
|
||||
verbose_more?: boolean;
|
||||
numiterations?: number;
|
||||
blocksplitting?: boolean;
|
||||
blocksplittinglast?: boolean;
|
||||
blocksplittingmax?: number;
|
||||
|
||||
// zlib options
|
||||
level?: number;
|
||||
flush?: number;
|
||||
chunkSize?: number;
|
||||
windowBits?: number;
|
||||
memLevel?: number;
|
||||
strategy?: number;
|
||||
dictionary?: any;
|
||||
test?: Pattern;
|
||||
threshold?: number;
|
||||
}
|
||||
|
||||
interface ZlibOptions extends BaseOptions {
|
||||
algorithm?: ZlibAlgorithm;
|
||||
compressionOptions?: ZlibCompressionOptions;
|
||||
}
|
||||
|
||||
interface CustomOptions<O> extends BaseOptions {
|
||||
algorithm: Algorithm<O>;
|
||||
compressionOptions?: O;
|
||||
}
|
||||
|
||||
type Options<O> = ZlibOptions | CustomOptions<O>;
|
||||
}
|
||||
|
||||
@@ -4,18 +4,24 @@ const conf = new Conf<string | number | boolean>();
|
||||
new Conf<string>({
|
||||
defaults: {
|
||||
foo: 'bar',
|
||||
unicorn: 'rainbow'
|
||||
unicorn: 'rainbow',
|
||||
},
|
||||
configName: '',
|
||||
projectName: 'foo',
|
||||
cwd: ''
|
||||
});
|
||||
new Conf<string>({ configName: '' });
|
||||
new Conf<string>({ projectName: 'foo' });
|
||||
new Conf<string>({ cwd: '' });
|
||||
new Conf<string>({ encryptionKey: '' });
|
||||
new Conf<string>({ encryptionKey: new Buffer('') });
|
||||
new Conf<string>({ encryptionKey: new Uint8Array([1]) });
|
||||
new Conf<string>({ encryptionKey: new DataView(new ArrayBuffer(2)) });
|
||||
new Conf<string>({ fileExtension: '.foo' });
|
||||
|
||||
// $ExpectError
|
||||
new Conf<string>({
|
||||
defaults: {
|
||||
foo: 'bar',
|
||||
unicorn: ['rainbow']
|
||||
}
|
||||
unicorn: ['rainbow'],
|
||||
},
|
||||
});
|
||||
conf.set('foo', 'bar');
|
||||
conf.set('hello', 1);
|
||||
@@ -28,10 +34,17 @@ conf.get('foo', null); // $ExpectError
|
||||
conf.delete('foo');
|
||||
conf.has('foo'); // $ExpectType boolean
|
||||
conf.clear();
|
||||
conf.onDidChange('foo', (oldVal, newVal) => {
|
||||
// $ExpectType string | number | boolean | undefined
|
||||
oldVal;
|
||||
// $ExpectType string | number | boolean | undefined
|
||||
newVal;
|
||||
});
|
||||
|
||||
conf.size; // $ExpectType number
|
||||
conf.store = {
|
||||
foo: 'bar',
|
||||
unicorn: 'rainbow'
|
||||
unicorn: 'rainbow',
|
||||
};
|
||||
conf.path; // $ExpectType string
|
||||
|
||||
|
||||
Vendored
+24
-18
@@ -1,31 +1,37 @@
|
||||
// Type definitions for conf 1.4
|
||||
// Type definitions for conf 2.1
|
||||
// Project: https://github.com/sindresorhus/conf
|
||||
// Definitions by: Sam Verschueren <https://github.com/SamVerschueren>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface Options<T> {
|
||||
defaults?: {[key: string]: T};
|
||||
configName?: string;
|
||||
projectName?: string;
|
||||
cwd?: string;
|
||||
}
|
||||
/// <reference types="node" />
|
||||
|
||||
declare class Conf<T = any> implements Iterable<[string, T]> {
|
||||
store: {[key: string]: T};
|
||||
store: { [key: string]: T };
|
||||
readonly path: string;
|
||||
readonly size: number;
|
||||
readonly size: number;
|
||||
|
||||
constructor(options?: Options<T>);
|
||||
get(key: string, defaultValue?: T): T;
|
||||
set(key: string, val: T): void;
|
||||
set(object: {[key: string]: T}): void;
|
||||
has(key: string): boolean;
|
||||
delete(key: string): void;
|
||||
clear(): void;
|
||||
onDidChange(key: string, callback: (oldVal: any, newVal: any) => void): void;
|
||||
[Symbol.iterator](): Iterator<[string, T]>;
|
||||
constructor(options?: Conf.Options<T>);
|
||||
get(key: string, defaultValue?: T): T;
|
||||
set(key: string, val: T): void;
|
||||
set(object: { [key: string]: T }): void;
|
||||
has(key: string): boolean;
|
||||
delete(key: string): void;
|
||||
clear(): void;
|
||||
onDidChange(key: string, callback: (oldVal: T | undefined, newVal: T | undefined) => void): void;
|
||||
[Symbol.iterator](): Iterator<[string, T]>;
|
||||
}
|
||||
|
||||
declare namespace Conf {
|
||||
interface Options<T> {
|
||||
defaults?: { [key: string]: T };
|
||||
configName?: string;
|
||||
projectName?: string;
|
||||
cwd?: string;
|
||||
encryptionKey?: string | Buffer | NodeJS.TypedArray | DataView;
|
||||
fileExtension?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export = Conf;
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"conf-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import Conf = require('conf');
|
||||
|
||||
const conf = new Conf<string | number | boolean>();
|
||||
new Conf<string>({
|
||||
defaults: {
|
||||
foo: 'bar',
|
||||
unicorn: 'rainbow',
|
||||
},
|
||||
configName: '',
|
||||
projectName: 'foo',
|
||||
cwd: '',
|
||||
});
|
||||
// $ExpectError
|
||||
new Conf<string>({
|
||||
defaults: {
|
||||
foo: 'bar',
|
||||
unicorn: ['rainbow'],
|
||||
},
|
||||
});
|
||||
conf.set('foo', 'bar');
|
||||
conf.set('hello', 1);
|
||||
conf.set('unicorn', false);
|
||||
conf.set('null', null); // $ExpectError
|
||||
|
||||
conf.get('foo'); // $ExpectType string | number | boolean
|
||||
conf.get('foo', 'bar'); // $ExpectType string | number | boolean
|
||||
conf.get('foo', null); // $ExpectError
|
||||
conf.delete('foo');
|
||||
conf.has('foo'); // $ExpectType boolean
|
||||
conf.clear();
|
||||
|
||||
conf.store = {
|
||||
foo: 'bar',
|
||||
unicorn: 'rainbow',
|
||||
};
|
||||
conf.path; // $ExpectType string
|
||||
|
||||
for (const [key, value] of conf) {
|
||||
key; // $ExpectType string
|
||||
value; // $ExpectType string | number | boolean
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Type definitions for conf 1.4
|
||||
// Project: https://github.com/sindresorhus/conf
|
||||
// Definitions by: Sam Verschueren <https://github.com/SamVerschueren>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface Options<T> {
|
||||
defaults?: { [key: string]: T };
|
||||
configName?: string;
|
||||
projectName?: string;
|
||||
cwd?: string;
|
||||
}
|
||||
|
||||
declare class Conf<T = any> implements Iterable<[string, T]> {
|
||||
store: { [key: string]: T };
|
||||
readonly path: string;
|
||||
readonly size: number;
|
||||
|
||||
constructor(options?: Options<T>);
|
||||
get(key: string, defaultValue?: T): T;
|
||||
set(key: string, val: T): void;
|
||||
set(object: { [key: string]: T }): void;
|
||||
has(key: string): boolean;
|
||||
delete(key: string): void;
|
||||
clear(): void;
|
||||
onDidChange(key: string, callback: (oldVal: any, newVal: any) => void): void;
|
||||
[Symbol.iterator](): Iterator<[string, T]>;
|
||||
}
|
||||
|
||||
export = Conf;
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"conf": [
|
||||
"conf/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"conf-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -5,6 +5,7 @@ let value: any;
|
||||
let key: string;
|
||||
let num: number;
|
||||
let object: any;
|
||||
let path: string;
|
||||
|
||||
cs.set(key, value);
|
||||
value = cs.get(key);
|
||||
@@ -13,4 +14,12 @@ cs.delete(key);
|
||||
object = cs.all;
|
||||
cs.all = object;
|
||||
num = cs.size;
|
||||
key = cs.path;
|
||||
path = cs.path;
|
||||
|
||||
const csWithPathOption = new Configstore('foo', null, { configPath: path });
|
||||
|
||||
csWithPathOption.set(key, value);
|
||||
value = csWithPathOption.get(key);
|
||||
csWithPathOption.delete(key);
|
||||
|
||||
key = csWithPathOption.path;
|
||||
|
||||
Vendored
+2
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for configstore 2.1
|
||||
// Type definitions for configstore 4.0
|
||||
// Project: https://github.com/yeoman/configstore
|
||||
// Definitions by: ArcticLight <https://github.com/ArcticLight>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -67,5 +67,6 @@ declare class Configstore {
|
||||
declare namespace Configstore {
|
||||
interface ConfigstoreOptions {
|
||||
globalConfigPath?: boolean;
|
||||
configPath?: string;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -110,6 +110,7 @@ declare namespace connectMongo {
|
||||
length: (callback: (err: any, length: number) => void) => void;
|
||||
clear: (callback?: (err?: any) => void) => void;
|
||||
touch: (sid: string, session: Express.SessionData, callback?: (err: any) => void) => void;
|
||||
close: () => void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+19
-1
@@ -37,6 +37,24 @@ declare namespace convict {
|
||||
parse: (content: string) => any;
|
||||
}
|
||||
|
||||
type PredefinedFormat =
|
||||
| '*'
|
||||
| 'int'
|
||||
| 'port'
|
||||
| 'windows_named_pipe'
|
||||
| 'port_or_windows_named_pipe'
|
||||
| 'url'
|
||||
| 'email'
|
||||
| 'ipaddress'
|
||||
| 'duration'
|
||||
| 'timestamp'
|
||||
| 'nat'
|
||||
| String
|
||||
| Object
|
||||
| Number
|
||||
| RegExp
|
||||
| Boolean;
|
||||
|
||||
interface SchemaObj<T = any> {
|
||||
default: T;
|
||||
doc?: string;
|
||||
@@ -52,7 +70,7 @@ declare namespace convict {
|
||||
* If omitted, format will be set to the value of Object.prototype.toString.call
|
||||
* for the default value
|
||||
*/
|
||||
format?: string | any[] | ((val: any) => void);
|
||||
format?: PredefinedFormat | any[] | ((val: any) => void);
|
||||
env?: string;
|
||||
arg?: string;
|
||||
sensitive?: boolean;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import createHash = require('create-hash');
|
||||
|
||||
const hash = createHash('sha224');
|
||||
|
||||
hash.update('synchronous write');
|
||||
hash.digest();
|
||||
hash.write('write to it as a stream');
|
||||
hash.end();
|
||||
hash.read();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user