Merge branch 'master' into ts-3.2-dom-updates

This commit is contained in:
Nathan Shively-Sanders
2018-12-13 11:02:22 -08:00
1122 changed files with 50913 additions and 17030 deletions
+306 -133
View File
File diff suppressed because it is too large Load Diff
+11 -2
View File
@@ -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
{
@@ -336,3 +342,6 @@ This project is licensed under the MIT license.
Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file.
[![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon)
[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average?
[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours?
+12
View File
@@ -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",
@@ -1656,6 +1662,12 @@
"sourceRepoURL": "https://github.com/ansman/validate.js",
"asOfVersion": "0.11.0"
},
{
"libraryName": "vega",
"typingsPackageName": "vega",
"sourceRepoURL": "https://github.com/vega/vega",
"asOfVersion": "3.2.0"
},
{
"libraryName": "vso-node-api",
"typingsPackageName": "vso-node-api",
+1 -1
View File
@@ -22,6 +22,6 @@
},
"devDependencies": {
"dtslint": "github:Microsoft/dtslint#production",
"types-publisher": "Microsoft/types-publisher#production"
"types-publisher": "github:Microsoft/types-publisher#production"
}
}
+29
View File
@@ -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;
+21
View File
@@ -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[];
};
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
-63
View File
@@ -1,63 +0,0 @@
import {
ACLType,
CopyAndPutMetaResult,
CopyObjectOptions,
DeleteMultiOptions,
DeleteMultiResult,
GetObjectOptions,
GetObjectResult,
GetStreamOptions,
GetStreamResult,
HeadObjectOptions,
HeadObjectResult,
ListObjectResult,
ListObjectsQuery,
NormalSuccessResponse,
PutObjectOptions,
PutObjectResult,
PutStreamOptions,
RequestOptions,
SignatureUrlOptions,
UserMeta
} from "./index";
export interface ClusterType {
host: string;
accessKeyId: string;
accessKeySecret: string;
}
export interface ClusterOptions {
clusters: ClusterType[];
schedule?: string;
}
export class Cluster {
constructor(options: ClusterOptions)
list(query: ListObjectsQuery | null, options: RequestOptions): Promise<ListObjectResult>;
put(name: string, file: any, options?: PutObjectOptions): Promise<PutObjectResult>;
putStream(name: string, stream: any, options?: PutStreamOptions): Promise<{ name: string, res: NormalSuccessResponse }>;
head(name: string, options?: HeadObjectOptions): Promise<HeadObjectResult>;
get(name: string, file?: any, options?: GetObjectOptions): Promise<GetObjectResult>;
getStream(name?: string, options?: GetStreamOptions): Promise<GetStreamResult>;
delete(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
copy(name: string, sourceName: string, options?: CopyObjectOptions): Promise<CopyAndPutMetaResult>;
putMeta(name: string, meta: UserMeta, options: RequestOptions): Promise<CopyAndPutMetaResult>;
deleteMulti(names: string[], options?: DeleteMultiOptions): Promise<DeleteMultiResult>;
signatureUrl(name: string, options?: SignatureUrlOptions): string;
putACL(name: string, acl: ACLType, options?: RequestOptions): Promise<NormalSuccessResponse>;
restore(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
}
-71
View File
@@ -1,71 +0,0 @@
import { NormalSuccessResponse, RequestOptions } from "./index";
export interface ImageClientOptions {
imageHost: string; // your image service domain that binding to a OSS bucket
accessKeyId: string; // access key you create on aliyun console website
accessKeySecret: string; // access secret you create
bucket: string; // the default bucket you want to access If you don't have any bucket, please use putBucket() create one first.
region?: string; // the bucket data region location, please see Data Regions, default is oss-cn-hangzhou
internal?: boolean; // access OSS with aliyun internal network or not, default is false If your servers are running on aliyun too, you can set true to save lot of money.
timeout?: string | number; // instance level timeout for all operations, default is 60s
}
export interface ImageGetOptions {
timeout?: number;
headers?: object;
}
export interface StyleData {
Name: string; // style name
Content: string; // style content
CreateTime: string; // style create time
LastModifyTime: string; // style last modify time
}
export class ImageClient {
constructor(options: ImageClientOptions)
/**
* Get an image from the image channel.
*/
get(name: string, file?: any, options?: ImageGetOptions): Promise<{ content: any, res: NormalSuccessResponse }>;
/**
* Get an image read stream.
*/
getStream(name: string, options?: ImageGetOptions): Promise<{ stream: any, res: NormalSuccessResponse }>;
/**
* Get a image exif info by image object name from the image channel.
*/
getExif(name: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* Get a image info and exif info by image object name from the image channel.
*/
getInfo(name: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* todo
*/
putStyle(name: string, style: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* Get a style by name from the image channel.
*/
getStyle(name: string, options?: RequestOptions): Promise<{ data: StyleData, res: NormalSuccessResponse}>;
/**
* Get all styles from the image channel.
*/
listStyle(options?: RequestOptions): Promise<StyleData[]>;
/**
* todo
*/
deleteStyle(styleName: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
/**
* Create a signature url for directly download.
*/
signatureUrl(name: string, options?: { expires?: string, timeout?: string }): string;
}
+18 -27
View File
@@ -1,34 +1,25 @@
import OSS from "ali-oss";
import * as OSS from 'ali-oss';
const client = new OSS({
const ossOptions: OSS.Options = {
accessKeyId: 'your access key',
accessKeySecret: 'your access secret',
bucket: 'your bucket name',
region: 'oss-cn-hangzhou'
});
};
const ImageClient = OSS.ImageClient({
imageHost: 'host',
accessKeySecret: "secret",
accessKeyId: 'id',
bucket: "",
internal: false,
region: "",
timeout: 2000
});
const client = new OSS(ossOptions);
const cluster = OSS.Cluster({
clusters: [
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
],
schedule: 'masterSlave',
});
const clusterOptions: OSS.ClusterOptions = {
clusters: [],
};
const clusterClient = new OSS.Cluster(clusterOptions);
const imageOptions: OSS.ImageClientOptions = {
imageHost: 'xxxx',
accessKeyId: 'xxxx',
accessKeySecret: 'xxxx',
bucket: 'xxxx'
};
const imageClient = new OSS.ImageClient(imageOptions);
+576 -463
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -18,8 +18,6 @@
},
"files": [
"index.d.ts",
"ImageClient.d.ts",
"Cluster.d.ts",
"ali-oss-tests.ts"
]
}
+4 -1
View File
@@ -1,3 +1,6 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
"no-mergeable-namespace": false
}
}
+10 -1
View File
@@ -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
+12 -8
View File
@@ -22,8 +22,8 @@ declare namespace AnalyticsNode {
},
timestamp?: Date;
messageId?: string;
anonymousId: string | number;
userId: string | number;
anonymousId?: string | number;
userId?: string | number;
}
interface Data {
@@ -47,7 +47,8 @@ declare namespace AnalyticsNode {
/* The identify method lets you tie a user to their actions and record
traits about them. */
identify(message: {
userId: string | number;
userId?: string | number;
anonymousId?: string | number;
traits?: Object;
timestamp?: Date;
context?: Object;
@@ -56,7 +57,8 @@ declare namespace AnalyticsNode {
/* The track method lets you record the actions your users perform. */
track(message: {
userId: string | number;
userId?: string | number;
anonymousId?: string | number;
event: string;
properties?: Object;
timestamp?: Date;
@@ -67,7 +69,8 @@ declare namespace AnalyticsNode {
/* The page method lets you record page views on your website, along with
optional extra information about the page being viewed. */
page(message: {
userId: string | number;
userId?: string | number;
anonymousId?: string | number;
category?: string;
name?: string;
properties?: Object;
@@ -79,19 +82,20 @@ declare namespace AnalyticsNode {
/* alias is how you associate one identity with another. */
alias(message: {
previousId: string | number;
userId: string | number;
userId?: string | number;
anonymousId?: string | number;
integrations?: Integrations;
}, callback?: (err: Error, data: Data) => void): Analytics;
/* Group calls can be used to associate individual users with shared
accounts or companies. */
group(message: {
userId: string | number;
userId?: string | number;
anonymousId?: string | number;
groupId: string | number;
traits?: Object;
context?: Object;
timestamp?: Date;
anonymous_id?: string | number;
integrations?: Integrations;
}, callback?: (err: Error, data: Data) => void): Analytics;
+2 -1
View File
@@ -74,6 +74,7 @@
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"whitespace": false,
"no-angle-bracket-type-assertion": false
}
}
+2 -1
View File
@@ -74,6 +74,7 @@
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"whitespace": false,
"no-angle-bracket-type-assertion": false
}
}
+4
View File
@@ -153,6 +153,10 @@ declare module 'angular' {
defaultFontSet(name: string): IIconProvider;
}
interface IInkRippleProvider {
disableInkRipple(): void;
}
type IMedia = (media: string) => boolean;
interface ISidenavObject {
+2 -1
View File
@@ -74,6 +74,7 @@
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"whitespace": false,
"no-angle-bracket-type-assertion": false
}
}
+2 -1
View File
@@ -74,6 +74,7 @@
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"whitespace": false,
"no-angle-bracket-type-assertion": false
}
}
+10 -200
View File
@@ -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;
}
});
}
+2 -1
View File
@@ -74,6 +74,7 @@
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"whitespace": false,
"no-angle-bracket-type-assertion": false
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ Object.keys({
}).forEach((color) => {
const cname = color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`);
((<(...anything: any[]) => ansi.Cursor> cursor[color])()
((cursor[color] as (...anything: any[]) => ansi.Cursor)()
.bold()
.bg)[color === 'blue' || color === 'brightBlue' ? 'black' : 'blue']()
.write(
+41 -4
View File
@@ -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
@@ -47,7 +47,8 @@ appInsights = {
startTrackEvent(name: string) { return null; },
stopTrackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
trackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number) { return null; },
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean,
resultCode: number, properties?: { [name: string]: string }, measurements?: { [name: string]: number }) { return null; },
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null; },
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null; },
trackTrace(message: string, properties?: { [name: string]: string; }, severityLevel?: AI.SeverityLevel) { return null; },
@@ -86,7 +87,7 @@ appInsights.trackTrace("message", null);
appInsights.trackTrace("message", { a: '1', b: '2' }, AI.SeverityLevel.Error);
// trackDependency
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null);
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null, {prop1: 'abc'}, {meas1: 4.5});
// flush
appInsights.flush();
+14 -9
View File
@@ -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.
*/
@@ -734,8 +736,11 @@ declare module Microsoft.ApplicationInsights {
* @param totalTime total request time
* @param success indicates if the request was sessessful
* @param resultCode response code returned by the dependency request
* @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.
*/
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number): any;
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number,
properties?: { [name: string]: string }, measurements?: { [name: string]: number }): any;
/**
* Log an exception you have caught.
* @param exception An Error from a catch clause, or the string error message.
+3
View File
@@ -16,6 +16,9 @@ coll.save({ username: "user" });
const doc = coll.any();
console.log(doc.username);
const coll2 = db._collection(coll.name());
console.log(coll2 === coll);
const users = coll as ArangoDB.Collection<User>;
const admin = users.firstExample({ username: "admin" })!;
users.update(admin, { password: md5("hunter2") });
+2 -10
View File
@@ -619,6 +619,7 @@ declare namespace ArangoDB {
interface Collection<T extends object = any> {
// Collection
name(): string;
checksum(
withRevisions?: boolean,
withData?: boolean
@@ -1503,16 +1504,7 @@ declare module "@arangodb/foxx/queues" {
function deleteQueue(name: string): boolean;
function get(name: string): Queue;
export {
createQueue as create,
deleteQueue as delete,
get,
JobOptions,
Job,
Queue,
QueueItem,
Script,
};
export { createQueue as create, deleteQueue as delete, get, JobOptions, Job, Queue, QueueItem, Script, };
}
declare module "@arangodb/foxx/graphql" {
+1
View File
@@ -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");
+3 -2
View File
@@ -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;
+9 -9
View File
@@ -390,22 +390,22 @@ async.auto({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
} as any],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
email_link: ['write_file', function (callback: AsyncResultCallback<any>, results: any) { } as any]
});
async.auto({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
} as any],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
email_link: ['write_file', function (callback: AsyncResultCallback<any>, results: any) { } as any]
}, function (err, results) {
console.log('finished auto');
});
@@ -421,11 +421,11 @@ async.auto<A>({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
} as any],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
email_link: ['write_file', function (callback: AsyncResultCallback<any>, results: any) { } as any]
}, 1, function (err, results) {
console.log('finished auto');
});
@@ -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);
+153
View File
@@ -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;
+20
View File
@@ -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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+2 -2
View File
@@ -557,8 +557,8 @@ function testDesializerManager() {
}
function isStorableClass(o: object): o is StorableClass {
if (typeof o === "object" && (<StorableClass> o).name &&
(<StorableClass> o).name === "test") {
if (typeof o === "object" && (o as StorableClass).name &&
(o as StorableClass).name === "test") {
return true;
} else {
return false;
+10
View File
@@ -7,15 +7,18 @@ const options: babel.TransformOptions = {
babel.transform("code();", options, (err, result) => {
const { code, map, ast } = result!;
const { body } = ast!.program;
});
const transformSyncResult = babel.transformSync("code();", options);
if (transformSyncResult) {
const { code, map, ast } = transformSyncResult;
const { body } = ast!.program;
}
babel.transformFile("filename.js", options, (err, result) => {
const { code, map, ast } = result!;
const { body } = ast!.program;
});
babel.transformFileSync("filename.js", options)!.code;
@@ -25,7 +28,14 @@ const parsedAst = babel.parse(sourceCode, options);
babel.transformFromAst(parsedAst!, sourceCode, options, (err, result) => {
const { code, map, ast } = result!;
const { body } = ast!.program;
});
const transformFromAstSyncResult = babel.transformFromAstSync(parsedAst!, sourceCode, options);
const { code, map, ast } = transformFromAstSyncResult!;
const { body } = ast!.program;
babel.transformFromAstAsync(parsedAst!, sourceCode, options).then(transformFromAstAsyncResult => {
const { code, map, ast } = transformFromAstAsyncResult!;
const { body } = ast!.program;
});
+2 -2
View File
@@ -349,7 +349,7 @@ export function transformFromAstSync(ast: Node, code?: string, opts?: TransformO
/**
* Given an AST, transform it.
*/
export function transformFromAstSync(ast: Node, code?: string, opts?: TransformOptions): Promise<BabelFileResult | null>;
export function transformFromAstAsync(ast: Node, code?: string, opts?: TransformOptions): Promise<BabelFileResult | null>;
// A babel plugin is a simple function which must return an object matching
// the following interface. Babel will throw if it finds unknown properties.
@@ -365,7 +365,7 @@ export interface PluginObj<S = {}> {
}
export interface BabelFileResult {
ast?: Node | null;
ast?: t.File | null;
code?: string | null;
ignored?: boolean;
map?: {
+47 -5
View File
@@ -4,10 +4,14 @@ import * as t from "@babel/types";
// Examples from: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md
const MyVisitor: Visitor = {
Identifier: {
enter() {
enter(path) {
// $ExpectType NodePath<Identifier>
path;
console.log("Entered!");
},
exit() {
exit(path) {
// $ExpectType NodePath<Identifier>
path;
console.log("Exited!");
}
}
@@ -89,7 +93,8 @@ const v1: Visitor = {
const id = path.scope.generateUidIdentifierBasedOnNode(path.node.id!);
path.remove();
path.scope.parent.push({ id, init: path.node });
path.scope.parent.push({ id });
path.scope.parent.push({ id, init: t.stringLiteral('foo'), kind: "const" });
path.scope.rename("n", "x");
path.scope.rename("n");
@@ -104,7 +109,44 @@ const BindingKindTest: Visitor = {
kind === 'const';
kind === 'let';
kind === 'var';
// The following should fail when uncommented
// kind === 'anythingElse';
// $ExpectError
kind === 'anythingElse';
},
};
interface SomeVisitorState { someState: string; }
const VisitorStateTest: Visitor<SomeVisitorState> = {
enter(path, state) {
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
exit(path, state) {
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
Identifier(path, state) {
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
FunctionDeclaration: {
enter(path, state) {
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
},
exit(path, state) {
// $ExpectType SomeVisitorState
state;
// $ExpectType SomeVisitorState
this;
}
}
};
+14 -9
View File
@@ -90,11 +90,16 @@ export class Scope {
removeData(key: string): void;
push(opts: any): void;
push(opts: {
id: t.LVal,
init?: t.Expression,
unique?: boolean,
kind?: "var" | "let" | "const",
}): void;
getProgramParent(): Scope;
getFunctionParent(): Scope;
getFunctionParent(): Scope | null;
getBlockParent(): Scope;
@@ -138,17 +143,17 @@ export class Binding {
constantViolations: NodePath[];
}
export type Visitor<S = Node> = VisitNodeObject<Node> & {
[P in Node["type"]]?: VisitNode<S, Extract<Node, { type: P; }>>;
export type Visitor<S = {}> = VisitNodeObject<S, Node> & {
[Type in Node["type"]]?: VisitNode<S, Extract<Node, { type: Type; }>>;
};
export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<T>;
export type VisitNode<S, P> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>;
export type VisitNodeFunction<T, P> = (this: T, path: NodePath<P>, state: any) => void;
export type VisitNodeFunction<S, P> = (this: S, path: NodePath<P>, state: S) => void;
export interface VisitNodeObject<T> {
enter?(path: NodePath<T>, state: any): void;
exit?(path: NodePath<T>, state: any): void;
export interface VisitNodeObject<S, P> {
enter?: VisitNodeFunction<S, P>;
exit?: VisitNodeFunction<S, P>;
}
export class NodePath<T = Node> {
@@ -64,7 +64,7 @@ const modelOpts: Backbone.ModelFetchWithCacheOptions = {
context: {},
};
const hoge = <Backbone.ModelWithCache> new Backbone.Model;
const hoge = new Backbone.Model() as Backbone.ModelWithCache;
hoge.fetch(modelOpts);
const collectionOpts: Backbone.CollectionFetchWithCacheOptions = {
@@ -76,5 +76,5 @@ const collectionOpts: Backbone.CollectionFetchWithCacheOptions = {
prefillSuccess: (self: any) => { },
};
const fuga = <Backbone.CollectionWithCache> new Backbone.Collection;
const fuga = new Backbone.Collection() as Backbone.CollectionWithCache;
fuga.fetch(collectionOpts);
+13 -1
View File
@@ -122,7 +122,19 @@ declare module 'backbone' {
}
export class Store extends Events {
export class Store implements Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
initializeRelation(model, relation, options);
addModelScope(scope:any):void;
+13 -1
View File
@@ -407,9 +407,21 @@ export interface ObjectOptions extends RadioMixinOptions {
* A base class which other classes can extend from. Object incorporates many
* backbone conventions and utilities like initialize and Backbone.Events.
*/
export class Object extends Backbone.Events implements CommonMixin, RadioMixin {
export class Object implements CommonMixin, RadioMixin, Backbone.Events {
constructor(options?: ObjectOptions);
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
/**
* Receives a hash of event names and functions and/or function names,
* and returns the same hash with the function names replaced with the
@@ -70,8 +70,8 @@ namespace InitializingWithOptions {
});
var testCollection6 = new TestCollection([
<TestModel>{},
<TestModel>{},
{} as TestModel,
{} as TestModel,
]);
}
+12 -1
View File
@@ -71,7 +71,18 @@ declare module "backbone" {
stopReplying(commandName?: string, callback?: (...args: any[]) => any, context?: any): Requests;
}
class Channel extends Backbone.Events implements Commands, Requests {
class Channel implements Commands, Requests, Backbone.Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
channelName: string;
reset(): Channel;
+1 -1
View File
@@ -1,6 +1,6 @@
function test_events() {
var object = new Backbone.Events();
var object = Backbone.Events;
object.on("alert", (eventName: string) => alert("Triggered " + eventName));
object.trigger("alert", "an event");
+48 -16
View File
@@ -3,6 +3,7 @@
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Natan Vivo <https://github.com/nvivo>
// kenjiru <https://github.com/kenjiru>
// jjoekoullas <https://github.com/jjoekoullas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -91,24 +92,37 @@ declare namespace Backbone {
}
interface EventsHash {
[selector: string]: string | {(eventObject: JQueryEventObject): void};
[selector: string]: string | {(eventObject: JQuery.TriggeredEvent): void};
}
class Events {
export const Events: Events;
interface Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
}
class ModelBase implements Events {
on(eventName: string, callback?: Function, context?: any): any;
on(eventMap: EventsHash): any;
off(eventName?: string, callback?: Function, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: Function, context?: any): any;
unbind(eventName?: string, callback?: Function, context?: any): any;
on(eventName: any, callback?: any, context?: any): any
off(eventName?: string, callback?: Function, context?: any): any
trigger(eventName: string, ...args: any[]): any
bind(eventName: string, callback: Function, context?: any): any
unbind(eventName?: string, callback?: Function, context?: any): any
once(events: string, callback: Function, context?: any): any
listenTo(object: any, events: string, callback: Function):any
listenToOnce(object: any, events: string, callback: Function): any
stopListening(object?: any, events?: string, callback?: Function): any
once(events: string, callback: Function, context?: any): any;
listenTo(object: any, events: string, callback: Function): any;
listenToOnce(object: any, events: string, callback: Function): any;
stopListening(object?: any, events?: string, callback?: Function): any;
}
class ModelBase extends Events {
parse(response: any, options?: any): any;
toJSON(options?: any): any;
sync(...arg: any[]): JQueryXHR;
@@ -353,7 +367,7 @@ declare namespace Backbone {
without(...values: TModel[]): TModel[];
}
class Router extends Events {
class Router extends EventSignatures {
/**
* Do not use, prefer TypeScript's extend functionality.
@@ -382,7 +396,7 @@ declare namespace Backbone {
var history: History;
class History extends Events {
class History extends EventSignatures {
handlers: any[];
interval: number;
@@ -419,7 +433,7 @@ declare namespace Backbone {
attributes?: {[id: string]: any};
}
class View<TModel extends Model> extends Events {
class View<TModel extends Model> extends EventSignatures {
/**
* Do not use, prefer TypeScript's extend functionality.
@@ -471,3 +485,21 @@ declare namespace Backbone {
function noConflict(): typeof Backbone;
var $: JQueryStatic;
}
/**
* This is not for external use and is only here as a convenient way to
* specify signatures for internal implementers of Backbone.Events
*/
declare abstract class EventSignatures implements Backbone.Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: Backbone.EventsHash): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
}
+3 -3
View File
@@ -120,7 +120,7 @@ function CommonMethodsInEventStreamsAndProperties() {
Bacon.fromArray([1, 2, 3]).withStateMachine(0, (sum, event) => {
if (event.hasValue()) {
// had to cast to `number` because event:Bacon.Next<number>|Bacon.Error<{}>
return [sum + <number>event.value(), []];
return [sum + (event.value() as number), []];
}
else if (event.isEnd()) {
return [undefined, [new Bacon.Next(sum), event]];
@@ -140,8 +140,8 @@ function CommonMethodsInEventStreamsAndProperties() {
{
// This is handy for keeping track whether we are currently awaiting an AJAX response:
var ajaxRequest = <Bacon.Observable<Error, JQueryXHR>>{},
ajaxResponse = <Bacon.Observable<Error, JQueryXHR>>{},
var ajaxRequest = {} as Bacon.Observable<Error, JQueryXHR>,
ajaxResponse = {} as Bacon.Observable<Error, JQueryXHR>,
showAjaxIndicator = ajaxRequest.awaiting(ajaxResponse);
}
File diff suppressed because it is too large Load Diff
+4758
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"esnext"
],
"strictFunctionTypes": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"baidu-app-tests.ts"
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-console": false,
"semicolon": true
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ async function run() {
clientSecret: '',
scope(request) {
const scopes = ['public_profile', 'email'];
if ((<RequestQuery> request.query).wantsSharePermission) {
if ((request.query as RequestQuery).wantsSharePermission) {
scopes.push('publish_actions');
}
return scopes;
+14 -6
View File
@@ -2,24 +2,32 @@ import Database = require('better-sqlite3');
const integer = Database.Integer(1);
const err = new Database.SqliteError('ok', 'ok');
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
};
let db = Database('.');
db = new Database('.', {memory: true});
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.checkpoint();
db.checkpoint('main');
db.register(() => {});
db.register({name: 'noop', deterministic: true, varargs: true}, () => {});
db.register(() => { });
db.register({ name: 'noop', deterministic: true, varargs: true }, () => { });
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}) => {});
stmt.all({ name: 'name' });
stmt.each('name', (row: { name: string }) => { });
stmt.each((row: { name: string }) => { });
stmt.pluck();
stmt.pluck(true);
stmt.bind('name');
+68 -62
View File
@@ -1,88 +1,94 @@
// Type definitions for better-sqlite3 3.1
// Type definitions for better-sqlite3 5.0
// Project: http://github.com/JoshuaWise/better-sqlite3
// Definitions by: Ben Davies <https://github.com/Morfent>
// Mathew Rumsey <https://github.com/matrumz>
// Santiago Aguilar <https://github.com/sant123>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import Integer = require('integer');
interface RunResult {
changes: number;
lastInsertROWID: Integer.IntLike;
}
import Integer = require("integer");
declare class Statement {
database: Database;
source: string;
returnsData: boolean;
constructor(db: Database, sources: string[]);
database: Database;
source: string;
returnsData: boolean;
constructor(db: Database, sources: string[]);
run(...params: any[]): 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;
pluck(toggleState?: boolean): this;
bind(...params: any[]): this;
safeIntegers(toggleState?: boolean): this;
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;
pluck(toggleState?: boolean): this;
bind(...params: any[]): this;
safeIntegers(toggleState?: boolean): this;
}
declare class Transaction {
database: Database;
source: string;
constructor(db: Database, sources: string[]);
database: Database;
source: string;
constructor(db: Database, sources: string[]);
run(...params: any[]): RunResult;
bind(...params: any[]): this;
safeIntegers(toggleState?: boolean): this;
}
interface DatabaseOptions {
memory?: boolean;
readonly?: boolean;
fileMustExist?: boolean;
}
interface RegistrationOptions {
name?: string;
varargs?: boolean;
deterministic?: boolean;
safeIntegers?: boolean;
run(...params: any[]): Database.RunResult;
bind(...params: any[]): this;
safeIntegers(toggleState?: boolean): this;
}
interface Database {
memory: boolean;
readonly: boolean;
name: string;
open: boolean;
inTransaction: boolean;
memory: boolean;
readonly: boolean;
name: string;
open: boolean;
inTransaction: boolean;
prepare(source: string): Statement;
transaction(sources: string[]): Transaction;
exec(source: string): this;
pragma(source: string, simplify?: boolean): any;
checkpoint(databaseName?: string): this;
register(cb: (...params: any[]) => any): this;
register(options: RegistrationOptions, cb: (...params: any[]) => any): this;
close(): this;
defaultSafeIntegers(toggleState?: boolean): this;
prepare(source: string): Statement;
transaction(sources: string[]): Transaction;
exec(source: string): this;
pragma(source: string, simplify?: boolean): any;
checkpoint(databaseName?: string): this;
register(cb: (...params: any[]) => any): this;
register(
options: Database.RegistrationOptions,
cb: (...params: any[]) => any
): this;
close(): this;
defaultSafeIntegers(toggleState?: boolean): this;
}
declare class SqliteError implements Error {
name: string;
message: string;
code: string;
constructor(message: string, code: string);
name: string;
message: string;
code: string;
constructor(message: string, code: string);
}
interface DatabaseConstructor {
new(filename: string, options?: DatabaseOptions): Database;
(filename: string, options?: DatabaseOptions): Database;
prototype: Database;
new (filename: string, options?: Database.Options): Database;
(filename: string, options?: Database.Options): Database;
prototype: Database;
Integer: typeof Integer;
SqliteError: typeof SqliteError;
Integer: typeof Integer;
SqliteError: typeof SqliteError;
}
declare namespace Database {
interface RunResult {
changes: number;
lastInsertRowid: Integer.IntLike;
}
interface Options {
memory?: boolean;
readonly?: boolean;
fileMustExist?: boolean;
}
interface RegistrationOptions {
name?: string;
varargs?: boolean;
deterministic?: boolean;
safeIntegers?: boolean;
}
}
declare const Database: DatabaseConstructor;
+6
View File
@@ -0,0 +1,6 @@
import binVersion = require('bin-version');
// $ExpectType Promise<string>
binVersion('curl');
// $ExpectType Promise<string>
binVersion('openssl', { args: ['version'] });
+14
View File
@@ -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[];
}
}
+23
View File
@@ -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"
]
}
+1
View File
@@ -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;
+108 -79
View File
@@ -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 }>>;
}
+1 -1
View File
@@ -17,7 +17,7 @@ export const wordlists: {
spanish: string[];
};
export function entropyToMnemonic(entropyHex: string, wordlist?: string[]): string;
export function entropyToMnemonic(entropyHex: Buffer | string, wordlist?: string[]): string;
export function generateMnemonic(strength?: number, rng?: (size: number) => Buffer, wordlist?: string[]): string;
+5 -7
View File
@@ -1,10 +1,8 @@
'use strict';
import xor = require('bitwise-xor');
"use strict";
let b: Buffer;
import xor = require("bitwise-xor");
var b: Buffer;
b = xor("a", "b");
b = xor(new Buffer("a"), new Buffer("b"));
b = xor('a', 'b');
b = xor(new Buffer('a'), new Buffer('b'));
+3 -4
View File
@@ -1,15 +1,14 @@
// Type definitions for bitwise-xor 0.0.0
// Type definitions for bitwise-xor 0.0
// Project: https://github.com/czzarr/node-bitwise-xor
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/**
* Bitwise XOR between two Buffers or Strings, returns a Buffer
*/
declare function xor(b1: Buffer, b2: Buffer): Buffer;
declare function xor(s1: string, s2: string): Buffer;
declare function xor(a: Buffer | string, b: Buffer | string): Buffer;
export = xor;
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
@@ -20,4 +20,4 @@
"index.d.ts",
"bitwise-xor-tests.ts"
]
}
}
+1 -77
View File
@@ -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"
}
@@ -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');
+4 -1
View File
@@ -1,3 +1,6 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
"no-angle-bracket-type-assertion": false
}
}
+7 -2
View File
@@ -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;
}
}
+21 -15
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/braintree/braintree-web
// Definitions by: Guy Shahine <https://github.com/chlela>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/**
* @module braintree-web/american-express
@@ -359,7 +360,8 @@ declare namespace braintree {
* });
* @static
*/
create: (options: { authorization: string }, callback: callback) => void;
create(options: { authorization: string }): Promise<Client>;
create(options: { authorization: string }, callback: callback): void;
/**
* @description The current version of the SDK, i.e. `3.0.2`.
@@ -439,7 +441,8 @@ declare namespace braintree {
* @param {callback} callback The second argument, `data`, is the {@link DataCollector} instance.
* @returns {void}
*/
create: (options: { client: Client, kount: boolean, paypal: boolean }, callback: callback) => void;
create(options: { client: Client, kount: boolean, paypal: boolean }): Promise<DataCollector>;
create(options: { client: Client, kount: boolean, paypal: boolean }, callback: callback): void;
/**
* @description The current version of the SDK, i.e. `3.0.2`.
@@ -591,18 +594,15 @@ declare namespace braintree {
* @property {?HostedFields~hostedFieldsFieldData} fields.expirationYear {@link HostedFields~hostedFieldsFieldData|hostedFieldsFieldData} for the expiration year field, if it is present.
* @property {?HostedFields~hostedFieldsFieldData} fields.postalCode {@link HostedFields~hostedFieldsFieldData|hostedFieldsFieldData} for the postal code field, if it is present.
*/
interface HostedFieldsFieldDataFields {
number: HostedFieldsHostedFieldsFieldData;
cvv: HostedFieldsHostedFieldsFieldData;
expirationDate: HostedFieldsHostedFieldsFieldData;
expirationMonth: HostedFieldsHostedFieldsFieldData;
expirationYear: HostedFieldsHostedFieldsFieldData;
postalCode: HostedFieldsHostedFieldsFieldData;
}
type HostedFieldsHostedFieldsFieldName = 'number' | 'cvv' | 'expirationDate' | 'expirationMonth' | 'expirationYear' | 'postalCode';
type HostedFieldsFieldDataFields = {
[key in HostedFieldsHostedFieldsFieldName]: HostedFieldsHostedFieldsFieldData;
};
interface HostedFieldsStateObject {
cards: HostedFieldsHostedFieldsCard[];
emittedBy: string;
emittedBy: HostedFieldsHostedFieldsFieldName;
fields: HostedFieldsFieldDataFields;
}
@@ -666,7 +666,8 @@ declare namespace braintree {
* }
* }, callback);
*/
create: (options: { client: Client, fields: HostedFieldFieldOptions, styles: any }, callback: callback) => void;
create(options: { client: Client, fields: HostedFieldFieldOptions, styles: any }): Promise<HostedFields>;
create(options: { client: Client, fields: HostedFieldFieldOptions, styles: any }, callback: callback): void;
/**
@@ -726,7 +727,7 @@ declare namespace braintree {
* });
* @returns {void}
*/
on(event: string, handler: ((event: any) => any)): void;
on(event: string, handler: ((event: HostedFieldsStateObject) => void)): void;
/**
* Cleanly tear down anything set up by {@link module:braintree-web/hosted-fields.create|create}
@@ -785,7 +786,9 @@ declare namespace braintree {
* });
* @returns {void}
*/
tokenize(options?: { vault: boolean }, callback?: callback): void;
tokenize(options?: { vault?: boolean, cardholderName?: string, billingAddress?: any }): Promise<HostedFieldsTokenizePayload>;
tokenize(options: { vault?: boolean, cardholderName?: string, billingAddress?: any }, callback: callback): void;
tokenize(callback: callback): void;
/**
* Add a class to a {@link module:braintree-web/hosted-fields~field field}. Useful for updating field styles when events occur elsewhere in your checkout.
@@ -1138,7 +1141,8 @@ declare namespace braintree {
* client: client
* }, callback);
*/
create: (options: { client: Client }, callback: callback) => void;
create(options: { client: Client }): Promise<ThreeDSecure>;
create(options: { client: Client }, callback: callback): void;
/**
* @description The current version of the SDK, i.e. `3.0.2`.
@@ -1207,6 +1211,7 @@ declare namespace braintree {
* }
* });
*/
verifyCard(options: { nonce: string, amount: number, addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void, removeFrame?: () => void }): Promise<ThreeDSecureVerifyPayload>;
verifyCard(options: { nonce: string, amount: number, addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void, removeFrame: () => void }, callback: callback): void;
/**
@@ -1751,3 +1756,4 @@ declare namespace braintree {
export = braintree;
export as namespace braintree;
+3 -3
View File
@@ -6,7 +6,7 @@ let clientToken: string = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiO
braintree.client.create({
authorization: clientToken
}, function (error: braintree.BraintreeError, clientInstance: any) {
}, function (error: braintree.BraintreeError, clientInstance: braintree.Client) {
var form: HTMLFormElement = document.getElementById('my-form-id') as HTMLFormElement;
var data: { creditCard: braintree.CreditCardInfo } = {
@@ -396,7 +396,7 @@ let submitNonceToServer: (nonce: string) => void;
braintree.threeDSecure.verifyCard({
nonce: existingNonce,
amount: 123.45,
amount: 123.45, // $ExpectType number
addFrame: function (err, iframe) {
// Set up your UI and add the iframe.
let my3DSContainer = document.createElement('div');
@@ -437,4 +437,4 @@ braintree.threeDSecure.cancelVerifyCard(function (err: braintree.BraintreeError,
verifyPayload.nonce; // The nonce returned from the 3ds lookup call
verifyPayload.liabilityShifted; // boolean
verifyPayload.liabilityShiftPossible; // boolean
});
});
+8 -5
View File
@@ -1,10 +1,13 @@
import { ApplePay } from "..";
import * as braintree from "..";
let version: string = braintree.VERSION;
let clientToken: string = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiI0YjlhYzVmYmI4ZTNkYzQzMmFkZjJhNzBlNjZlMWNjY2M5ODRkYzE4ZTM4YmY4NjYzZTM5NjM3NWZjYmQzY2U5fGNyZWF0ZWRfYXQ9MjAxNi0wOS0wOFQwNTowMzo0MC4xNjk1NTUwMzUrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0=";
braintree.client.create({
authorization: clientToken
}, function (error: braintree.BraintreeError, clientInstance: any) {
}, function (error: braintree.BraintreeError, clientInstance: braintree.Client) {
var form: HTMLFormElement = document.getElementById('my-form-id') as HTMLFormElement;
var data: { creditCard: braintree.CreditCardInfo } = {
@@ -62,7 +65,7 @@ braintree.client.create({
select: true
}
}
}, function (hostedFieldsErr?: braintree.BraintreeError, hostedFieldsInstance?: any) {
}, function (hostedFieldsErr?: braintree.BraintreeError, hostedFieldsInstance?: braintree.HostedFields) {
if (hostedFieldsErr) {
// Handle error in Hosted Fields creation
@@ -178,7 +181,7 @@ braintree.client.create({
});
});
braintree.applePay.create({ client: clientInstance }, function (createErr?: braintree.BraintreeError, applePayInstance?: any) {
braintree.applePay.create({ client: clientInstance }, function (createErr?: braintree.BraintreeError, applePayInstance?: ApplePay) {
if (createErr) {
// Handle error in client creation
console.log(`Error Code: ${error.code}, Type: ${error.type}, Message: ${error.message}, Details: ${error.details}`);
@@ -194,7 +197,7 @@ braintree.client.create({
total: { label: 'Your Label', amount: '10.00' },
};
var paymentRequest = braintree.applePay.createPaymentRequest(request);
var paymentRequest = applePayInstance.createPaymentRequest(request);
console.log(paymentRequest);
// { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
@@ -394,7 +397,7 @@ let submitNonceToServer: (nonce: string) => void;
braintree.threeDSecure.verifyCard({
nonce: existingNonce,
amount: 123.45,
amount: 123.45, // $ExpectType number
addFrame: function (err, iframe) {
// Set up your UI and add the iframe.
let my3DSContainer = document.createElement('div');
+7 -1
View File
@@ -98,11 +98,17 @@ const pdfQueue = new Queue('pdf transcoding', {
//
//////////////////////////////////////////////////////////////////////////////////
pdfQueue.process((job) => {
pdfQueue.process((job: Queue.Job) => {
// Processors can also return promises instead of using the done callback
return Promise.resolve();
});
async function pfdPromise(job: Queue.Job) {
return Promise.resolve();
}
pdfQueue.process(1, pfdPromise);
videoQueue.add({ video: 'http://example.com/video1.mov' }, { jobId: 1 })
.then((video1Job) => {
// When job has successfully be placed in the queue the job is returned
+35 -91
View File
@@ -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>
@@ -12,11 +12,11 @@
// Alec Brunelle <https://github.com/aleccool213>
// Dan Manastireanu <https://github.com/danmana>
// Kjell-Morten Bratsberg Thorsen <https://github.com/kjellmorten>
// Christian D. <https://github.com/pc-jedi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as Redis from "ioredis";
import * as Promise from "bluebird";
/**
* This is the Queue constructor.
@@ -92,7 +92,7 @@ declare namespace Bull {
* Define a custom backoff strategy
*/
backoffStrategies?: {
[key: string]: (attemptsMade: number, err: typeof Error) => number;
[key: string]: (attemptsMade: number, err: Error) => number;
};
/**
@@ -342,50 +342,39 @@ declare namespace Bull {
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* If the callback signature contains the second optional done argument,
* the callback will be passed a done callback to be called after the job has been completed.
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event;
* results, as a second argument to the "completed" event.
*/
process(callback: (job: Job<T>, done: DoneCallback) => void): void;
/**
* Defines a processing function for the jobs placed into a given Queue.
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event; results, as a second argument to the "completed" event.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
* The callback can also be defined as the string path to a module
* exporting the callback function. Using a path has several advantages:
* - The process is sandboxed so if it crashes it does not affect the worker.
* - You can run blocking code without affecting the queue (jobs will not stall).
* - Much better utilization of multi-core CPUs.
* - Less connections to redis.
*
* A promise must be returned to signal job completion.
* If, however, the callback signature does not contain the done argument,
* a promise must be returned to signal job completion.
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
* If it is resolved, its value will be the "completed" event's second argument.
*/
process(callback: ((job: Job<T>) => void) | string): Promise<any>;
process(callback: ((job: Job<T>, done: DoneCallback) => void) | ((job: Job<T>) => Promise<any>) | string): void;
/**
* Defines a processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
* The callback can also be defined as the string path to a module
* exporting the callback function. Using a path has several advantages:
* - The process is sandboxed so if it crashes it does not affect the worker.
* - You can run blocking code without affecting the queue (jobs will not stall).
* - Much better utilization of multi-core CPUs.
* - Less connections to redis.
*
* A promise must be returned to signal job completion.
* If the callback signature contains the second optional done argument,
* the callback will be passed a done callback to be called after the job has been completed.
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event; results, as a second argument to the "completed" event.
*
* If, however, the callback signature does not contain the done argument,
* a promise must be returned to signal job completion.
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
* If it is resolved, its value will be the "completed" event's second argument.
*
* @param concurrency Bull will then call you handler in parallel respecting this max number.
* @param concurrency Bull will then call your handler in parallel respecting this maximum value.
*/
process(concurrency: number, callback: ((job: Job<T>) => void) | string): Promise<any>;
process(concurrency: number, callback: ((job: Job<T>, done: DoneCallback) => void) | ((job: Job<T>) => Promise<any>) | string): void;
/**
* Defines a processing function for the jobs placed into a given Queue.
@@ -393,35 +382,21 @@ declare namespace Bull {
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* If the callback signature contains the second optional done argument,
* the callback will be passed a done callback to be called after the job has been completed.
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event;
* results, as a second argument to the "completed" event.
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event; results, as a second argument to the "completed" event.
*
* @param concurrency Bull will then call you handler in parallel respecting this max number.
*/
process(concurrency: number, callback: (job: Job<T>, done: DoneCallback) => void): void;
/**
* Defines a named processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
* The callback can also be defined as the string path to a module
* exporting the callback function. Using a path has several advantages:
* - The process is sandboxed so if it crashes it does not affect the worker.
* - You can run blocking code without affecting the queue (jobs will not stall).
* - Much better utilization of multi-core CPUs.
* - Less connections to redis.
*
* A promise must be returned to signal job completion.
* If, however, the callback signature does not contain the done argument,
* a promise must be returned to signal job completion.
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
* If it is resolved, its value will be the "completed" event's second argument.
*
* @param name Bull will only call the handler if the job name matches
*/
// tslint:disable-next-line:unified-signatures
process(name: string, callback: ((job: Job<T>) => void) | string): Promise<any>;
process(name: string, callback: ((job: Job<T>, done: DoneCallback) => void) | ((job: Job<T>) => Promise<any>) | string): void;
/**
* Defines a processing function for the jobs placed into a given Queue.
@@ -429,52 +404,21 @@ declare namespace Bull {
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* If the callback signature contains the second optional done argument,
* the callback will be passed a done callback to be called after the job has been completed.
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event;
* results, as a second argument to the "completed" event.
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event; results, as a second argument to the "completed" event.
*
* @param name Bull will only call the handler if the job name matches
*/
// tslint:disable-next-line:unified-signatures
process(name: string, callback: (job: Job<T>, done: DoneCallback) => void): void;
/**
* Defines a named processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
* The callback can also be defined as the string path to a module
* exporting the callback function. Using a path has several advantages:
* - The process is sandboxed so if it crashes it does not affect the worker.
* - You can run blocking code without affecting the queue (jobs will not stall).
* - Much better utilization of multi-core CPUs.
* - Less connections to redis.
*
* A promise must be returned to signal job completion.
* If, however, the callback signature does not contain the done argument,
* a promise must be returned to signal job completion.
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
* If it is resolved, its value will be the "completed" event's second argument.
*
* @param name Bull will only call the handler if the job name matches
* @param concurrency Bull will then call you handler in parallel respecting this max number.
* @param concurrency Bull will then call your handler in parallel respecting this maximum value.
*/
process(name: string, concurrency: number, callback: ((job: Job<T>) => void) | string): Promise<any>;
/**
* Defines a processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event;
* results, as a second argument to the "completed" event.
*
* @param name Bull will only call the handler if the job name matches
* @param concurrency Bull will then call you handler in parallel respecting this max number.
*/
process(name: string, concurrency: number, callback: (job: Job<T>, done: DoneCallback) => void): void;
process(name: string, concurrency: number, callback: ((job: Job<T>, done: DoneCallback) => void) | ((job: Job<T>) => Promise<any>) | string): void;
/**
* Creates a new job and adds it to the queue.
@@ -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
View File
@@ -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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+48
View File
@@ -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 {
// ...
}
+159
View File
@@ -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;
}
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5 -3
View File
@@ -118,6 +118,8 @@ export interface ClientOptions {
export type PolicyOptionVariants<T> = PolicyOptions<T> | DecoratedPolicyOptions<T>;
export type Id = string | { id: string };
/**
* The Policy object provides a convenient cache interface by setting a
* global policy which is automatically applied to every storage action.
@@ -138,7 +140,7 @@ export class Policy<T, O extends PolicyOptionVariants<T>> {
* @param id the unique item identifier (within the policy segment).
* Can be a string or an object with the required 'id' key.
*/
get(id: string | { id: string }): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
get(id: Id): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
/**
* store an item in the cache where:
@@ -148,12 +150,12 @@ export class Policy<T, O extends PolicyOptionVariants<T>> {
* removed from the cache (or is marked invalid).
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
*/
set(id: string | { id: string }, value: T, ttl?: number): Promise<void>;
set(id: Id, value: T, ttl?: number): Promise<void>;
/**
* remove the item from cache where:
* @param id the unique item identifier (within the policy segment).
*/
drop(id: string | { id: string }): Promise<void>;
drop(id: Id): Promise<void>;
/**
* given a created timestamp in milliseconds, returns the time-to-live left
* based on the configured rules.
+12
View File
@@ -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, "", {});
+19
View File
@@ -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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5 -1
View File
@@ -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]
+2 -2
View File
@@ -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;
+3 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for Cheerio v0.22.0
// Project: https://github.com/cheeriojs/cheerio
// Definitions by: Bret Little <https://github.com/blittle>, VILIC VANE <http://vilic.info>, Wayne Maurer <https://github.com/wmaurer>, Umar Nizamani <https://github.com/umarniz>, LiJinyao <https://github.com/LiJinyao>, Chennakrishna <https://github.com/chennakrishna8>
// Definitions by: Bret Little <https://github.com/blittle>, VILIC VANE <http://vilic.info>, Wayne Maurer <https://github.com/wmaurer>, Umar Nizamani <https://github.com/umarniz>, LiJinyao <https://github.com/LiJinyao>, Chennakrishna <https://github.com/chennakrishna8>, AzSiAz <https://github.com/AzSiAz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Cheerio {
@@ -111,9 +111,8 @@ interface Cheerio {
eq(index: number): Cheerio;
get(): string[];
get(): CheerioElement[];
get(index: number): CheerioElement;
get(): any[];
get(index: number): any;
index(): number;
index(selector: string): number;
+72 -75
View File
@@ -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;
}
File diff suppressed because it is too large Load Diff
+390 -392
View File
@@ -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;
}
File diff suppressed because it is too large Load Diff
+160 -162
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
+2 -1
View File
@@ -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',

Some files were not shown because too many files have changed in this diff Show More