mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 01:31:45 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -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();
|
||||
|
||||
+4
-1
@@ -734,8 +734,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.
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
@@ -109,3 +113,40 @@ const BindingKindTest: Visitor = {
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Vendored
+7
-7
@@ -143,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> {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+4758
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-console": false,
|
||||
"semicolon": true
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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'));
|
||||
|
||||
Vendored
+3
-4
@@ -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;
|
||||
|
||||
@@ -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,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"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import * as CSON from 'cson-parser';
|
||||
|
||||
CSON.parse('[ 1, 2, a: "str" ]');
|
||||
|
||||
CSON.stringify({ domain: 'typescript.org' }, null, 4);
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// Type definitions for cson-parser 4.0
|
||||
// Project: https://github.com/groupon/cson-parser
|
||||
// Definitions by: Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export type ReplacerFunction = (key: string, value: any) => any;
|
||||
|
||||
/**
|
||||
* Converts a CSON string into an object.
|
||||
* @param text A valid CSON string.
|
||||
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
export function parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a CSON string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results or an array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value CSON text to make it easier to read.
|
||||
*/
|
||||
export function stringify(value: any, replacer?: ReplacerFunction | Array<(number | string)> | null, space?: string | number): string;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cson-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,48 @@
|
||||
import * as dh from 'diffie-hellman';
|
||||
|
||||
const dh1 = dh.getDiffieHellman('modp1');
|
||||
// $ExpectType DiffieHellman
|
||||
dh1;
|
||||
// $ExpectType Buffer
|
||||
dh1.generateKeys();
|
||||
// $ExpectType string
|
||||
dh1.generateKeys('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getPrime();
|
||||
// $ExpectType string
|
||||
dh1.getPrime('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getGenerator();
|
||||
// $ExpectType string
|
||||
dh1.getGenerator('hex');
|
||||
const pk = dh1.getPublicKey();
|
||||
// $ExpectType Buffer
|
||||
pk;
|
||||
// $ExpectType string
|
||||
dh1.getPublicKey('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getPrivateKey();
|
||||
// $ExpectType string
|
||||
dh1.getPrivateKey('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.computeSecret(pk);
|
||||
// $ExpectType Buffer
|
||||
dh1.computeSecret(pk.toString('hex'), 'hex');
|
||||
// $ExpectType string
|
||||
dh1.computeSecret(pk.toString('hex'), 'hex', 'hex');
|
||||
|
||||
const dh2 = dh.createDiffieHellman(new Buffer([5]));
|
||||
// $ExpectType DiffieHellman
|
||||
dh2;
|
||||
dh.createDiffieHellman('prime', 'hex');
|
||||
dh.createDiffieHellman('prime', 'hex', new Buffer([5]));
|
||||
dh.createDiffieHellman('prime', 'hex', 5);
|
||||
dh.createDiffieHellman('prime', 'hex', 'generator', 'hex');
|
||||
dh.createDiffieHellman(1);
|
||||
dh.createDiffieHellman(1, 1);
|
||||
dh.createDiffieHellman(1, new Buffer([5]));
|
||||
|
||||
dh2.setPublicKey(pk);
|
||||
dh2.setPublicKey(pk.toString('hex'), 'hex');
|
||||
dh2.setPrivateKey(pk);
|
||||
dh2.setPrivateKey(pk.toString('hex'), 'hex');
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for diffie-hellman 5.0
|
||||
// Project: https://github.com/crypto-browserify/diffie-hellman
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export { createDiffieHellman, getDiffieHellman, DiffieHellman } from 'crypto';
|
||||
@@ -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",
|
||||
"diffie-hellman-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -29,6 +29,9 @@ result = ejs.render(template, data, options);
|
||||
result = ejs.renderFile(fileName, SimpleCallback);
|
||||
result = ejs.renderFile(fileName, data, SimpleCallback);
|
||||
result = ejs.renderFile(fileName, data, options, SimpleCallback);
|
||||
asyncResult = ejs.renderFile(fileName);
|
||||
asyncResult = ejs.renderFile(fileName, data);
|
||||
asyncResult = ejs.renderFile(fileName, data, options);
|
||||
|
||||
ejsFunction = ejs.compile('');
|
||||
ejsFunction = ejs.compile(read(fileName, "utf8"));
|
||||
|
||||
Vendored
+2
@@ -54,6 +54,8 @@ export type RenderFileCallback<T> = (err: Error, str?: string) => T;
|
||||
export function renderFile<T>(path: string, cb: RenderFileCallback<T>): T;
|
||||
export function renderFile<T>(path: string, data: Data, cb: RenderFileCallback<T>): T;
|
||||
export function renderFile<T>(path: string, data: Data, opts: Options, cb: RenderFileCallback<T>): T;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
export function renderFile<T>(path: string, data?: Data, opts?: Options): Promise<T>;
|
||||
|
||||
/**
|
||||
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for hard-source-webpack-plugin 0.9
|
||||
// Type definitions for hard-source-webpack-plugin 1.0
|
||||
// Project: https://github.com/mzgoddard/hard-source-webpack-plugin#readme
|
||||
// Definitions by: woitechen <https://github.com/woitechen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -15,7 +15,7 @@ declare namespace hard_source_webpack_plugin { }
|
||||
|
||||
interface Options {
|
||||
cacheDirectory?: string;
|
||||
configHash?: (webpackConfig?: webpack.Configuration) => string;
|
||||
configHash?: string | ((webpackConfig?: webpack.Configuration) => string);
|
||||
environmentHash?: {
|
||||
root: string;
|
||||
directories: string[];
|
||||
|
||||
Vendored
+213
@@ -0,0 +1,213 @@
|
||||
// Type definitions for jju 1.4
|
||||
// Project: https://github.com/rlidwka/jju
|
||||
// Definitions by: Elizabeth Craig <https://github.com/ecraig12345>
|
||||
// Alex Kocharin <https://github.com/rlidwka>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Disabling unified-signatures rule so different documentation can be provided for each signature.
|
||||
// tslint:disable:unified-signatures
|
||||
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
* What to do with reserved keys (default 'ignore').
|
||||
* - "ignore" - ignore reserved keys
|
||||
* - "throw" - throw SyntaxError in case of reserved keys
|
||||
* - "replace" - replace reserved keys, this is the default JSON.parse behaviour, unsafe
|
||||
*/
|
||||
reserved_keys?: 'ignore' | 'throw' | 'replace';
|
||||
|
||||
/**
|
||||
* Create object as `Object.create(null)` instead of `{}`.
|
||||
* - If reserved_keys != 'replace', default is false.
|
||||
* - If reserved_keys == 'replace', default is true.
|
||||
*
|
||||
* It is usually unsafe and not recommended to change this option to false in the last case.
|
||||
*/
|
||||
null_prototype?: boolean;
|
||||
|
||||
/**
|
||||
* Reviver function (follows the JSON spec). This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
reviver?: (key: any, value: any) => any;
|
||||
|
||||
/**
|
||||
* Operation mode (default 'json5'). Set to 'json' if you want to throw on non-strict json files.
|
||||
*/
|
||||
mode?: 'json5' | 'json' | 'cjson';
|
||||
}
|
||||
|
||||
export interface StringifyOptions {
|
||||
/**
|
||||
* Output ascii only (default false).
|
||||
* If this option is enabled, output will not have any characters except 0x20-0x7f.
|
||||
*/
|
||||
ascii?: boolean;
|
||||
|
||||
/**
|
||||
* This option follows JSON specification.
|
||||
* @default '\t'
|
||||
*/
|
||||
indent?: string | number | boolean;
|
||||
|
||||
/**
|
||||
* Enquoting char.
|
||||
* - If `mode` is 'json', default is "
|
||||
* - Otherwise, default is '
|
||||
*/
|
||||
quote?: '"' | "'";
|
||||
|
||||
/**
|
||||
* Whether keys quoting in objects is required or not.
|
||||
* If you want `{"q": 1}` instead of `{q: 1}`, set it to true.
|
||||
* - If `mode` is 'json', default is true
|
||||
* - Otherwise, default is false
|
||||
*/
|
||||
quote_keys?: boolean;
|
||||
|
||||
/**
|
||||
* Sort all keys while stringifying.
|
||||
* By default sort order will depend on implementation--with v8 it's insertion order.
|
||||
* If set to true, all keys (but not arrays) will be sorted alphabetically.
|
||||
* You can provide your own sorting function as well.
|
||||
* @default false
|
||||
*/
|
||||
sort_keys?: boolean | ((a: any, b: any) => number);
|
||||
|
||||
/**
|
||||
* Replacer function or array. This option follows JSON specification.
|
||||
* If a function, used to transform the results.
|
||||
* If an array, acts as a approved list for selecting the object properties that will be stringified.
|
||||
*/
|
||||
replacer?: ((key: string, value: any) => any) | Array<number | string>;
|
||||
|
||||
/**
|
||||
* Don't output trailing comma. If this option is set, arrays like `[1,2,3,]` will never be generated.
|
||||
* Otherwise they may be generated for pretty printing.
|
||||
* - If `mode` is JSON, default is true
|
||||
* - Otherwise, default is false
|
||||
*/
|
||||
no_trailing_comma?: boolean;
|
||||
|
||||
/**
|
||||
* Operation mode. Set it to 'json' if you want correct json in the output.
|
||||
* If it is 'json', following options are implied:
|
||||
* - options.quote = '"'
|
||||
* - options.no_trailing_comma = true
|
||||
* - options.quote_keys = true
|
||||
* - '\x' literals are not used
|
||||
*/
|
||||
mode?: 'json' | 'json5' | 'cjson';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a token in a JSON file.
|
||||
*/
|
||||
export interface Token {
|
||||
/** Raw text of this token. If you join all raws, you will get the original document. */
|
||||
raw: string;
|
||||
/** Type of the token. */
|
||||
type: 'whitespace' | 'comment' | 'key' | 'literal' | 'separator' | 'newline';
|
||||
/** Path to the current token in the syntax tree. */
|
||||
stack: string[];
|
||||
/** Value of the token if token is a key or literal. */
|
||||
value?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object defining a programming style in which the JSON document was written.
|
||||
*/
|
||||
export interface JsonStyle {
|
||||
/** Preferred indentation. */
|
||||
indent: string;
|
||||
/** Preferred newline. */
|
||||
newline: string;
|
||||
/** " or ' depending on which quote is preferred. */
|
||||
quote: string;
|
||||
/** True if unquoted keys were used at least once. */
|
||||
quote_keys: boolean;
|
||||
/** True if input has a whitespace token. */
|
||||
has_whitespace: boolean;
|
||||
/** True if input has a comment token. */
|
||||
has_comments: boolean;
|
||||
/** True if input has a newline token. */
|
||||
has_newlines: boolean;
|
||||
/** True if input has at least one trailing comma. */
|
||||
has_trailing_comma: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse json/json5 text and returns a javascript value it corresponds to.
|
||||
* @param text Text to parse
|
||||
* @param options Parser options
|
||||
*/
|
||||
export function parse(text: string, options?: ParseOptions): any;
|
||||
/**
|
||||
* Compatibility syntax (follows JSON specification).
|
||||
* Converts a JavaScript Object Notation (JSON) string into an object.
|
||||
* @param text A valid JSON string.
|
||||
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
export function parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
|
||||
/**
|
||||
* Convert javascript value to an appropriate json/json5 text.
|
||||
* @param value Value to serialize
|
||||
* @param options Serializer options
|
||||
*/
|
||||
export function stringify(value: any, options?: StringifyOptions): string;
|
||||
/**
|
||||
* Compatibility syntax (follows JSON specification).
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
export function stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Compatibility syntax (follows JSON specification).
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
export function stringify(value: any, replacer?: Array<number | string> | null, space?: string | number): string;
|
||||
|
||||
/**
|
||||
* Parse json/json5 text and return an array of tokens it consists of.
|
||||
* @param text Text to tokenize
|
||||
* @param options Parser options
|
||||
*/
|
||||
export function tokenize(text: string, options?: ParseOptions): Token[];
|
||||
|
||||
/**
|
||||
* Parse json/json5 text and try to guess indentation, quoting style, etc.
|
||||
* @param text Text to analyze
|
||||
* @param options Parser options
|
||||
*/
|
||||
export function analyze(text: string, options?: ParseOptions): JsonStyle;
|
||||
|
||||
/**
|
||||
* Change json/json5 text, preserving original formatting as much as possible.
|
||||
* @param text Original text
|
||||
* @param new_value New value you want to set
|
||||
* @param options Parser and stringifier options
|
||||
*
|
||||
* @example
|
||||
* // here is your original JSON document:
|
||||
* var input = '{"foo": "bar", "baz": 123}'
|
||||
*
|
||||
* // you need to parse it first:
|
||||
* var json = jju.parse(input, {mode: 'json'})
|
||||
* // json is { foo: 'bar', baz: 123 }
|
||||
*
|
||||
* // then you can change it as you like:
|
||||
* json.foo = 'quux'
|
||||
* json.hello = 'world'
|
||||
*
|
||||
* // then you run an update function to change the original json:
|
||||
* var output = jju.update(input, json, {mode: 'json'})
|
||||
* // output is '{"foo": "quux", "baz": 123, "hello": "world"}'
|
||||
*/
|
||||
export function update(text: string, new_value: any, options?: ParseOptions & StringifyOptions): string;
|
||||
@@ -0,0 +1,4 @@
|
||||
import * as jju from 'jju';
|
||||
|
||||
jju.parse('{}'); // $ExpectType any
|
||||
jju.stringify({}); // $ExpectType string
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jju-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+7
-16
@@ -1,27 +1,22 @@
|
||||
// Type definitions for karma-coverage v0.5.3
|
||||
// Type definitions for karma-coverage 1.1
|
||||
// Project: https://github.com/karma-runner/karma-coverage
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Yaroslav Admin <https://github.com/devoto13>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as karma from 'karma';
|
||||
import 'karma';
|
||||
import * as istanbul from 'istanbul';
|
||||
|
||||
declare namespace karmaCoverage {
|
||||
interface Karma extends karma.Karma { }
|
||||
|
||||
interface Config extends karma.Config {
|
||||
set: (config: ConfigOptions) => void;
|
||||
}
|
||||
|
||||
interface ConfigOptions extends karma.ConfigOptions {
|
||||
declare module 'karma' {
|
||||
interface ConfigOptions {
|
||||
/**
|
||||
* See https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md
|
||||
*/
|
||||
coverageReporter?: (Reporter | Reporter[]);
|
||||
coverageReporter?: KarmaCoverageReporter & { reporters?: KarmaCoverageReporter[] };
|
||||
}
|
||||
|
||||
interface Reporter {
|
||||
interface KarmaCoverageReporter {
|
||||
type?: string;
|
||||
dir?: string;
|
||||
subdir?: string | ((browser: string) => string);
|
||||
@@ -33,7 +28,3 @@ declare namespace karmaCoverage {
|
||||
[moreSettings: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare var karmaCoverage: karmaCoverage.Karma;
|
||||
|
||||
export = karmaCoverage;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as karma from 'karma-coverage';
|
||||
import * as karma from 'karma';
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#basic
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#basic
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
files: [
|
||||
@@ -20,13 +20,13 @@ module.exports = function(config: karma.Config) {
|
||||
|
||||
// optionally, configure the reporter
|
||||
coverageReporter: {
|
||||
type : 'html',
|
||||
dir : 'coverage/'
|
||||
type: 'html',
|
||||
dir: 'coverage/'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#advanced-multiple-reporters
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#advanced-multiple-reporters
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
files: [
|
||||
@@ -56,7 +56,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#dont-minify-instrumenter-output
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#dont-minify-instrumenter-output
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -67,7 +67,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#subdir
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#subdir
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -93,7 +93,7 @@ module.exports = function(config: karma.Config) {
|
||||
coverageReporter: {
|
||||
dir: 'coverage',
|
||||
subdir: function(browser) {
|
||||
// normalization process to keep a consistent browser name accross different
|
||||
// normalization process to keep a consistent browser name across different
|
||||
// OS
|
||||
return browser.toLowerCase().split(/[ /-]/)[0];
|
||||
}
|
||||
@@ -102,18 +102,18 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#file
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#file
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
type : 'text',
|
||||
dir : 'coverage/',
|
||||
file : 'coverage.txt'
|
||||
type: 'text',
|
||||
dir: 'coverage/',
|
||||
file: 'coverage.txt'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#check
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#check
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -146,7 +146,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#watermarks
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#watermarks
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -160,24 +160,36 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#sourcestore
|
||||
module.exports = function(config: karma.Config) {
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#includeallsources
|
||||
module.exports = function (config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
type : 'text',
|
||||
dir : 'coverage/',
|
||||
file : 'coverage.txt',
|
||||
sourceStore : require('istanbul').Store.create('fslookup')
|
||||
type: 'text',
|
||||
dir: 'coverage/',
|
||||
file: 'coverage.txt',
|
||||
includeAllSources: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#reporters
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#sourcestore
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
reporters:[
|
||||
{type: 'html', dir:'coverage/'},
|
||||
type: 'text',
|
||||
dir: 'coverage/',
|
||||
file: 'coverage.txt',
|
||||
sourceStore: require('istanbul').Store.create('fslookup')
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#reporters
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
reporters: [
|
||||
{type: 'html', dir: 'coverage/'},
|
||||
{type: 'teamcity'},
|
||||
{type: 'text-summary'}
|
||||
],
|
||||
@@ -185,7 +197,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#instrumenter
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#instrumenter
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
|
||||
Vendored
+441
-444
@@ -13,58 +13,55 @@ import Promise = require('bluebird');
|
||||
import https = require('https');
|
||||
import { Appender } from 'log4js';
|
||||
|
||||
declare namespace karma {
|
||||
interface Karma {
|
||||
/**
|
||||
* `start` method is deprecated since 0.13. It will be removed in 0.14.
|
||||
* Please use
|
||||
* <code>
|
||||
* server = new Server(config, [done])
|
||||
* server.start()
|
||||
* </code>
|
||||
* instead.
|
||||
*/
|
||||
server: DeprecatedServer;
|
||||
Server: Server;
|
||||
runner: Runner;
|
||||
stopper: Stopper;
|
||||
launcher: Launcher;
|
||||
VERSION: string;
|
||||
constants: Constants;
|
||||
}
|
||||
/**
|
||||
* `start` method is deprecated since 0.13. It will be removed in 0.14.
|
||||
* Please use
|
||||
* <code>
|
||||
* server = new Server(config, [done])
|
||||
* server.start()
|
||||
* </code>
|
||||
* instead.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
export const server: DeprecatedServer;
|
||||
|
||||
interface Constants {
|
||||
VERSION: string;
|
||||
DEFAULT_PORT: number;
|
||||
DEFAULT_HOSTNAME: string;
|
||||
DEFAULT_LISTEN_ADDR: string;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
LOG_LOG: string;
|
||||
LOG_PRIORITIES: string[];
|
||||
COLOR_PATTERN: string;
|
||||
NO_COLOR_PATTERN: string;
|
||||
CONSOLE_APPENDER: {
|
||||
export const runner: Runner;
|
||||
export const stopper: Stopper;
|
||||
|
||||
export const VERSION: string;
|
||||
export const constants: Constants;
|
||||
|
||||
export interface Constants {
|
||||
VERSION: string;
|
||||
DEFAULT_PORT: number;
|
||||
DEFAULT_HOSTNAME: string;
|
||||
DEFAULT_LISTEN_ADDR: string;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
LOG_LOG: string;
|
||||
LOG_PRIORITIES: string[];
|
||||
COLOR_PATTERN: string;
|
||||
NO_COLOR_PATTERN: string;
|
||||
CONSOLE_APPENDER: {
|
||||
type: string;
|
||||
layout: {
|
||||
type: string;
|
||||
layout: {
|
||||
type: string;
|
||||
pattern: string;
|
||||
};
|
||||
pattern: string;
|
||||
};
|
||||
EXIT_CODE: string;
|
||||
}
|
||||
};
|
||||
EXIT_CODE: string;
|
||||
}
|
||||
|
||||
interface LauncherStatic {
|
||||
generateId(): string;
|
||||
// TODO: injector should be of type `di.Injector`
|
||||
new (emitter: NodeJS.EventEmitter, injector: any): Launcher;
|
||||
}
|
||||
export namespace launcher {
|
||||
class Launcher {
|
||||
static generateId(): string;
|
||||
|
||||
constructor(emitter: NodeJS.EventEmitter, injector: any);
|
||||
|
||||
interface Launcher {
|
||||
Launcher: LauncherStatic;
|
||||
// TODO: Can this return value ever be typified?
|
||||
launch(names: string[], protocol: string, hostname: string, port: number, urlRoot: string): any[];
|
||||
kill(id: string, callback: () => void): boolean;
|
||||
@@ -73,403 +70,403 @@ declare namespace karma {
|
||||
areAllCaptured(): boolean;
|
||||
markCaptured(id: string): void;
|
||||
}
|
||||
|
||||
interface DeprecatedServer {
|
||||
start(options?: any, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
interface Runner {
|
||||
run(options?: ConfigOptions | ConfigFile, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
interface Stopper {
|
||||
/**
|
||||
* This function will signal a running server to stop. The equivalent of karma stop.
|
||||
*/
|
||||
stop(options?: ConfigOptions, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
interface TestResults {
|
||||
disconnected: boolean;
|
||||
error: boolean;
|
||||
exitCode: number;
|
||||
failed: number;
|
||||
success: number;
|
||||
}
|
||||
|
||||
interface Server extends NodeJS.EventEmitter {
|
||||
// TODO: Figure out how to convert Server to class and remove suppression
|
||||
// tslint:disable-next-line:no-misused-new
|
||||
new (options?: ConfigOptions | ConfigFile, callback?: ServerCallback): Server;
|
||||
/**
|
||||
* Start the server
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Get properties from the injector
|
||||
* @param token
|
||||
*/
|
||||
get(token: string): any;
|
||||
/**
|
||||
* Force a refresh of the file list
|
||||
*/
|
||||
refreshFiles(): Promise<any>;
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
|
||||
/**
|
||||
* Listen to the 'run_complete' event.
|
||||
*/
|
||||
on(event: 'run_complete', listener: (browsers: any, results: TestResults) => void): this;
|
||||
|
||||
/**
|
||||
* Backward-compatibility with karma-intellij bundled with WebStorm.
|
||||
* Deprecated since version 0.13, to be removed in 0.14
|
||||
*/
|
||||
// static start(): void;
|
||||
}
|
||||
|
||||
type ServerCallback = (exitCode: number) => void;
|
||||
|
||||
interface Config {
|
||||
set: (config: ConfigOptions) => void;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
}
|
||||
|
||||
interface ConfigFile {
|
||||
configFile: string;
|
||||
}
|
||||
|
||||
interface ConfigOptions {
|
||||
/**
|
||||
* @description Enable or disable watching files and executing the tests whenever one of these files changes.
|
||||
* @default true
|
||||
*/
|
||||
autoWatch?: boolean;
|
||||
/**
|
||||
* @description When Karma is watching the files for changes, it tries to batch multiple changes into a single run
|
||||
* so that the test runner doesn't try to start and restart running tests more than it should.
|
||||
* The configuration setting tells Karma how long to wait (in milliseconds) after any changes have occurred
|
||||
* before starting the test process again.
|
||||
* @default 250
|
||||
*/
|
||||
autoWatchBatchDelay?: number;
|
||||
/**
|
||||
* @default ''
|
||||
* @description The root path location that will be used to resolve all relative paths defined in <code>files</code> and <code>exclude</code>.
|
||||
* If the basePath configuration is a relative path then it will be resolved to
|
||||
* the <code>__dirname</code> of the configuration file.
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* @default 2000
|
||||
* @description How long does Karma wait for a browser to reconnect (in ms).
|
||||
* <p>
|
||||
* With a flaky connection it is pretty common that the browser disconnects,
|
||||
* but the actual test execution is still running without any problems. Karma does not treat a disconnection
|
||||
* as immediate failure and will wait <code>browserDisconnectTimeout</code> (ms).
|
||||
* If the browser reconnects during that time, everything is fine.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTimeout?: number;
|
||||
/**
|
||||
* @default 0
|
||||
* @description The number of disconnections tolerated.
|
||||
* <p>
|
||||
* The <code>disconnectTolerance</code> value represents the maximum number of tries a browser will attempt
|
||||
* in the case of a disconnection. Usually any disconnection is considered a failure,
|
||||
* but this option allows you to define a tolerance level when there is a flaky network link between
|
||||
* the Karma server and the browsers.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTolerance?: number;
|
||||
/**
|
||||
* @default 10000
|
||||
* @description How long will Karma wait for a message from a browser before disconnecting from it (in ms).
|
||||
* <p>
|
||||
* If, during test execution, Karma does not receive any message from a browser within
|
||||
* <code>browserNoActivityTimeout</code> (ms), it will disconnect from the browser
|
||||
* </p>
|
||||
*/
|
||||
browserNoActivityTimeout?: number;
|
||||
/**
|
||||
* @default []
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>Chrome (launcher comes installed with Karma)</li>
|
||||
* <li>ChromeCanary (launcher comes installed with Karma)</li>
|
||||
* <li>PhantomJS (launcher comes installed with Karma)</li>
|
||||
* <li>Firefox (launcher requires karma-firefox-launcher plugin)</li>
|
||||
* <li>Opera (launcher requires karma-opera-launcher plugin)</li>
|
||||
* <li>Internet Explorer (launcher requires karma-ie-launcher plugin)</li>
|
||||
* <li>Safari (launcher requires karma-safari-launcher plugin)</li>
|
||||
* </ul>
|
||||
* @description A list of browsers to launch and capture. When Karma starts up, it will also start up each browser
|
||||
* which is placed within this setting. Once Karma is shut down, it will shut down these browsers as well.
|
||||
* You can capture any browser manually by opening the browser and visiting the URL where
|
||||
* the Karma web server is listening (by default it is <code>http://localhost:9876/</code>).
|
||||
*/
|
||||
browsers?: string[];
|
||||
/**
|
||||
* @default 60000
|
||||
* @description Timeout for capturing a browser (in ms).
|
||||
* <p>
|
||||
* The <code>captureTimeout</code> value represents the maximum boot-up time allowed for a
|
||||
* browser to start and connect to Karma. If any browser does not get captured within the timeout, Karma
|
||||
* will kill it and try to launch it again and, after three attempts to capture it, Karma will give up.
|
||||
* </p>
|
||||
*/
|
||||
captureTimeout?: number;
|
||||
client?: ClientOptions;
|
||||
/**
|
||||
* @default true
|
||||
* @description Enable or disable colors in the output (reporters and logs).
|
||||
*/
|
||||
colors?: boolean;
|
||||
/**
|
||||
* @default 'Infinity'
|
||||
* @description How many browsers Karma launches in parallel.
|
||||
* Especially on services like SauceLabs and Browserstack, it makes sense only to launch a limited
|
||||
* amount of browsers at once, and only start more when those have finished. Using this configuration,
|
||||
* you can specify how many browsers should be running at once at any given point in time.
|
||||
*/
|
||||
concurrency?: number;
|
||||
customLaunchers?: { [key: string]: CustomLauncher };
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to exclude from loaded files.
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to load in the browser.
|
||||
*/
|
||||
files?: Array<FilePattern | string>;
|
||||
/**
|
||||
* @default []
|
||||
* @description List of test frameworks you want to use. Typically, you will set this to ['jasmine'], ['mocha'] or ['qunit']...
|
||||
* Please note just about all frameworks in Karma require an additional plugin/framework library to be installed (via NPM).
|
||||
*/
|
||||
frameworks?: string[];
|
||||
/**
|
||||
* @default 'localhost'
|
||||
* @description Hostname to be used when capturing browsers.
|
||||
*/
|
||||
hostname?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description Options object to be used by Node's https class.
|
||||
* Object description can be found in the
|
||||
* [NodeJS.org API docs](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
|
||||
*/
|
||||
httpsServerOptions?: https.ServerOptions;
|
||||
/**
|
||||
* @default config.LOG_INFO
|
||||
* Possible values:
|
||||
* <ul>
|
||||
* <li>config.LOG_DISABLE</li>
|
||||
* <li>config.LOG_ERROR</li>
|
||||
* <li>config.LOG_WARN</li>
|
||||
* <li>config.LOG_INFO</li>
|
||||
* <li>config.LOG_DEBUG</li>
|
||||
* </ul>
|
||||
* @description Level of logging.
|
||||
*/
|
||||
logLevel?: string;
|
||||
/**
|
||||
* @default [{type: 'console'}]
|
||||
* @description A list of log appenders to be used. See the documentation for [log4js] for more information.
|
||||
*/
|
||||
loggers?: { [name: string]: Appender } | Appender[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of names of additional middleware you want the
|
||||
* Karma server to use. Middleware will be used in the order listed.
|
||||
* You must have installed the middleware via a plugin/framework
|
||||
* (either inline or via NPM). Additional information can be found in
|
||||
* [plugins](http://karma-runner.github.io/2.0/config/plugins.html).
|
||||
* The plugin must provide an express/connect middleware function
|
||||
* (details about this can be found in the
|
||||
* [Express](http://expressjs.com/guide/using-middleware.html) docs).
|
||||
*/
|
||||
middleware?: string[];
|
||||
/**
|
||||
* @default {}
|
||||
* @description Redefine default mapping from file extensions to MIME-type.
|
||||
* Set property name to required MIME, provide Array of extensions (without dots) as it's value.
|
||||
*/
|
||||
mime?: {[type: string]: string[]};
|
||||
/**
|
||||
* @default ['karma-*']
|
||||
* @description List of plugins to load. A plugin can be a string (in which case it will be required
|
||||
* by Karma) or an inlined plugin - Object.
|
||||
* By default, Karma loads all sibling NPM modules which have a name starting with karma-*.
|
||||
* Note: Just about all plugins in Karma require an additional library to be installed (via NPM).
|
||||
*/
|
||||
plugins?: any[];
|
||||
/**
|
||||
* @default 9876
|
||||
* @description The port where the web server will be listening.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* @default {'**\/*.coffee': 'coffee'}
|
||||
* @description A map of preprocessors to use.
|
||||
*
|
||||
* Preprocessors can be loaded through [plugins].
|
||||
*
|
||||
* Note: Just about all preprocessors in Karma (other than CoffeeScript and some other defaults)
|
||||
* require an additional library to be installed (via NPM).
|
||||
*
|
||||
* Be aware that preprocessors may be transforming the files and file types that are available at run time. For instance,
|
||||
* if you are using the "coverage" preprocessor on your source files, if you then attempt to interactively debug
|
||||
* your tests, you'll discover that your expected source code is completely changed from what you expected. Because
|
||||
* of that, you'll want to engineer this so that your automated builds use the coverage entry in the "reporters" list,
|
||||
* but your interactive debugging does not.
|
||||
*
|
||||
*/
|
||||
preprocessors?: { [name: string]: string | string[] };
|
||||
/**
|
||||
* @default 'http:'
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>http:</li>
|
||||
* <li>https:</li>
|
||||
* </ul>
|
||||
* @description Protocol used for running the Karma webserver.
|
||||
* Determines the use of the Node http or https class.
|
||||
* Note: Using <code>'https:'</code> requires you to specify <code>httpsServerOptions</code>.
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description A map of path-proxy pairs.
|
||||
*/
|
||||
proxies?: { [path: string]: string };
|
||||
/**
|
||||
* @default true
|
||||
* @description Whether or not Karma or any browsers should raise an error when an inavlid SSL certificate is found.
|
||||
*/
|
||||
proxyValidateSSL?: boolean;
|
||||
/**
|
||||
* @default 0
|
||||
* @description Karma will report all the tests that are slower than given time limit (in ms).
|
||||
* This is disabled by default (since the default value is 0).
|
||||
*/
|
||||
reportSlowerThan?: number;
|
||||
/**
|
||||
* @default ['progress']
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>dots</li>
|
||||
* <li>progress</li>
|
||||
* </ul>
|
||||
* @description A list of reporters to use.
|
||||
* Additional reporters, such as growl, junit, teamcity or coverage can be loaded through plugins.
|
||||
* Note: Just about all additional reporters in Karma (other than progress) require an additional library to be installed (via NPM).
|
||||
*/
|
||||
reporters?: string[];
|
||||
/**
|
||||
* @default false
|
||||
* @description Continuous Integration mode.
|
||||
* If true, Karma will start and capture all configured browsers, run tests and then exit with an exit code of 0 or 1 depending
|
||||
* on whether all tests passed or any tests failed.
|
||||
*/
|
||||
singleRun?: boolean;
|
||||
/**
|
||||
* @default ['polling', 'websocket']
|
||||
* @description An array of allowed transport methods between the browser and testing server. This configuration setting
|
||||
* is handed off to [socket.io](http://socket.io/) (which manages the communication
|
||||
* between browsers and the testing server).
|
||||
*/
|
||||
transports?: string[];
|
||||
/**
|
||||
* @default '/'
|
||||
* @description The base url, where Karma runs.
|
||||
* All of Karma's urls get prefixed with the urlRoot. This is helpful when using proxies, as
|
||||
* sometimes you might want to proxy a url that is already taken by Karma.
|
||||
*/
|
||||
urlRoot?: string;
|
||||
}
|
||||
|
||||
interface ClientOptions {
|
||||
/**
|
||||
* @default undefined
|
||||
* @description When karma run is passed additional arguments on the command-line, they
|
||||
* are passed through to the test adapter as karma.config.args (an array of strings).
|
||||
* The client.args option allows you to set this value for actions other than run.
|
||||
* How this value is used is up to your test adapter - you should check your adapter's
|
||||
* documentation to see how (and if) it uses this value.
|
||||
*/
|
||||
args?: string[];
|
||||
/**
|
||||
* @default true
|
||||
* @description Run the tests inside an iFrame or a new window
|
||||
* If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an
|
||||
* iFrame and may need a new window to run.
|
||||
*/
|
||||
useIframe?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Capture all console output and pipe it to the terminal.
|
||||
*/
|
||||
captureConsole?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Run the tests on the same window as the client, without using iframe or a new window
|
||||
*/
|
||||
runInParent?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Clear the context window
|
||||
* If true, Karma clears the context window upon the completion of running the tests.
|
||||
* If false, Karma does not clear the context window upon the completion of running the tests.
|
||||
* Setting this to false is useful when embedding a Jasmine Spec Runner Template.
|
||||
*/
|
||||
clearContext?: boolean;
|
||||
}
|
||||
|
||||
interface FilePattern {
|
||||
/**
|
||||
* The pattern to use for matching. This property is mandatory.
|
||||
*/
|
||||
pattern: string;
|
||||
/**
|
||||
* @default true
|
||||
* @description If <code>autoWatch</code> is true all files that have set watched to true will be watched
|
||||
* for changes.
|
||||
*/
|
||||
watched?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be included in the browser using <script> tag? Use false if you want to
|
||||
* load them manually, eg. using Require.js.
|
||||
*/
|
||||
included?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be served by Karma's webserver?
|
||||
*/
|
||||
served?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Should the files be served from disk on each request by Karma's webserver?
|
||||
*/
|
||||
nocache?: boolean;
|
||||
}
|
||||
|
||||
interface CustomLauncher {
|
||||
base: string;
|
||||
browserName?: string;
|
||||
flags?: string[];
|
||||
platform?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare var karma: karma.Karma;
|
||||
/** @deprecated */
|
||||
export interface DeprecatedServer {
|
||||
/** @deprecated */
|
||||
start(options?: any, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
export = karma;
|
||||
export interface Runner {
|
||||
run(options?: ConfigOptions | ConfigFile, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
export interface Stopper {
|
||||
/**
|
||||
* This function will signal a running server to stop. The equivalent of karma stop.
|
||||
*/
|
||||
stop(options?: ConfigOptions, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
export interface TestResults {
|
||||
disconnected: boolean;
|
||||
error: boolean;
|
||||
exitCode: number;
|
||||
failed: number;
|
||||
success: number;
|
||||
}
|
||||
|
||||
export class Server extends NodeJS.EventEmitter {
|
||||
constructor(options?: ConfigOptions | ConfigFile, callback?: ServerCallback);
|
||||
/**
|
||||
* Start the server
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Get properties from the injector
|
||||
* @param token
|
||||
*/
|
||||
get(token: string): any;
|
||||
/**
|
||||
* Force a refresh of the file list
|
||||
*/
|
||||
refreshFiles(): Promise<any>;
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
|
||||
/**
|
||||
* Listen to the 'run_complete' event.
|
||||
*/
|
||||
on(event: 'run_complete', listener: (browsers: any, results: TestResults) => void): this;
|
||||
|
||||
/**
|
||||
* Backward-compatibility with karma-intellij bundled with WebStorm.
|
||||
* Deprecated since version 0.13, to be removed in 0.14
|
||||
*/
|
||||
// static start(): void;
|
||||
}
|
||||
|
||||
export type ServerCallback = (exitCode: number) => void;
|
||||
|
||||
export interface Config {
|
||||
set: (config: ConfigOptions) => void;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
}
|
||||
|
||||
export interface ConfigFile {
|
||||
configFile: string;
|
||||
}
|
||||
|
||||
export interface ConfigOptions {
|
||||
/**
|
||||
* @description Enable or disable watching files and executing the tests whenever one of these files changes.
|
||||
* @default true
|
||||
*/
|
||||
autoWatch?: boolean;
|
||||
/**
|
||||
* @description When Karma is watching the files for changes, it tries to batch multiple changes into a single run
|
||||
* so that the test runner doesn't try to start and restart running tests more than it should.
|
||||
* The configuration setting tells Karma how long to wait (in milliseconds) after any changes have occurred
|
||||
* before starting the test process again.
|
||||
* @default 250
|
||||
*/
|
||||
autoWatchBatchDelay?: number;
|
||||
/**
|
||||
* @default ''
|
||||
* @description The root path location that will be used to resolve all relative paths defined in <code>files</code> and <code>exclude</code>.
|
||||
* If the basePath configuration is a relative path then it will be resolved to
|
||||
* the <code>__dirname</code> of the configuration file.
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* @default 2000
|
||||
* @description How long does Karma wait for a browser to reconnect (in ms).
|
||||
* <p>
|
||||
* With a flaky connection it is pretty common that the browser disconnects,
|
||||
* but the actual test execution is still running without any problems. Karma does not treat a disconnection
|
||||
* as immediate failure and will wait <code>browserDisconnectTimeout</code> (ms).
|
||||
* If the browser reconnects during that time, everything is fine.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTimeout?: number;
|
||||
/**
|
||||
* @default 0
|
||||
* @description The number of disconnections tolerated.
|
||||
* <p>
|
||||
* The <code>disconnectTolerance</code> value represents the maximum number of tries a browser will attempt
|
||||
* in the case of a disconnection. Usually any disconnection is considered a failure,
|
||||
* but this option allows you to define a tolerance level when there is a flaky network link between
|
||||
* the Karma server and the browsers.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTolerance?: number;
|
||||
/**
|
||||
* @default 10000
|
||||
* @description How long will Karma wait for a message from a browser before disconnecting from it (in ms).
|
||||
* <p>
|
||||
* If, during test execution, Karma does not receive any message from a browser within
|
||||
* <code>browserNoActivityTimeout</code> (ms), it will disconnect from the browser
|
||||
* </p>
|
||||
*/
|
||||
browserNoActivityTimeout?: number;
|
||||
/**
|
||||
* @default []
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>Chrome (launcher comes installed with Karma)</li>
|
||||
* <li>ChromeCanary (launcher comes installed with Karma)</li>
|
||||
* <li>PhantomJS (launcher comes installed with Karma)</li>
|
||||
* <li>Firefox (launcher requires karma-firefox-launcher plugin)</li>
|
||||
* <li>Opera (launcher requires karma-opera-launcher plugin)</li>
|
||||
* <li>Internet Explorer (launcher requires karma-ie-launcher plugin)</li>
|
||||
* <li>Safari (launcher requires karma-safari-launcher plugin)</li>
|
||||
* </ul>
|
||||
* @description A list of browsers to launch and capture. When Karma starts up, it will also start up each browser
|
||||
* which is placed within this setting. Once Karma is shut down, it will shut down these browsers as well.
|
||||
* You can capture any browser manually by opening the browser and visiting the URL where
|
||||
* the Karma web server is listening (by default it is <code>http://localhost:9876/</code>).
|
||||
*/
|
||||
browsers?: string[];
|
||||
/**
|
||||
* @default 60000
|
||||
* @description Timeout for capturing a browser (in ms).
|
||||
* <p>
|
||||
* The <code>captureTimeout</code> value represents the maximum boot-up time allowed for a
|
||||
* browser to start and connect to Karma. If any browser does not get captured within the timeout, Karma
|
||||
* will kill it and try to launch it again and, after three attempts to capture it, Karma will give up.
|
||||
* </p>
|
||||
*/
|
||||
captureTimeout?: number;
|
||||
client?: ClientOptions;
|
||||
/**
|
||||
* @default true
|
||||
* @description Enable or disable colors in the output (reporters and logs).
|
||||
*/
|
||||
colors?: boolean;
|
||||
/**
|
||||
* @default 'Infinity'
|
||||
* @description How many browsers Karma launches in parallel.
|
||||
* Especially on services like SauceLabs and Browserstack, it makes sense only to launch a limited
|
||||
* amount of browsers at once, and only start more when those have finished. Using this configuration,
|
||||
* you can specify how many browsers should be running at once at any given point in time.
|
||||
*/
|
||||
concurrency?: number;
|
||||
customLaunchers?: { [key: string]: CustomLauncher };
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to exclude from loaded files.
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to load in the browser.
|
||||
*/
|
||||
files?: Array<FilePattern | string>;
|
||||
/**
|
||||
* @default []
|
||||
* @description List of test frameworks you want to use. Typically, you will set this to ['jasmine'], ['mocha'] or ['qunit']...
|
||||
* Please note just about all frameworks in Karma require an additional plugin/framework library to be installed (via NPM).
|
||||
*/
|
||||
frameworks?: string[];
|
||||
/**
|
||||
* @default 'localhost'
|
||||
* @description Hostname to be used when capturing browsers.
|
||||
*/
|
||||
hostname?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description Options object to be used by Node's https class.
|
||||
* Object description can be found in the
|
||||
* [NodeJS.org API docs](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
|
||||
*/
|
||||
httpsServerOptions?: https.ServerOptions;
|
||||
/**
|
||||
* @default config.LOG_INFO
|
||||
* Possible values:
|
||||
* <ul>
|
||||
* <li>config.LOG_DISABLE</li>
|
||||
* <li>config.LOG_ERROR</li>
|
||||
* <li>config.LOG_WARN</li>
|
||||
* <li>config.LOG_INFO</li>
|
||||
* <li>config.LOG_DEBUG</li>
|
||||
* </ul>
|
||||
* @description Level of logging.
|
||||
*/
|
||||
logLevel?: string;
|
||||
/**
|
||||
* @default [{type: 'console'}]
|
||||
* @description A list of log appenders to be used. See the documentation for [log4js] for more information.
|
||||
*/
|
||||
loggers?: { [name: string]: Appender } | Appender[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of names of additional middleware you want the
|
||||
* Karma server to use. Middleware will be used in the order listed.
|
||||
* You must have installed the middleware via a plugin/framework
|
||||
* (either inline or via NPM). Additional information can be found in
|
||||
* [plugins](http://karma-runner.github.io/2.0/config/plugins.html).
|
||||
* The plugin must provide an express/connect middleware function
|
||||
* (details about this can be found in the
|
||||
* [Express](http://expressjs.com/guide/using-middleware.html) docs).
|
||||
*/
|
||||
middleware?: string[];
|
||||
/**
|
||||
* @default {}
|
||||
* @description Redefine default mapping from file extensions to MIME-type.
|
||||
* Set property name to required MIME, provide Array of extensions (without dots) as it's value.
|
||||
*/
|
||||
mime?: {[type: string]: string[]};
|
||||
/**
|
||||
* @default ['karma-*']
|
||||
* @description List of plugins to load. A plugin can be a string (in which case it will be required
|
||||
* by Karma) or an inlined plugin - Object.
|
||||
* By default, Karma loads all sibling NPM modules which have a name starting with karma-*.
|
||||
* Note: Just about all plugins in Karma require an additional library to be installed (via NPM).
|
||||
*/
|
||||
plugins?: any[];
|
||||
/**
|
||||
* @default 9876
|
||||
* @description The port where the web server will be listening.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* @default {'**\/*.coffee': 'coffee'}
|
||||
* @description A map of preprocessors to use.
|
||||
*
|
||||
* Preprocessors can be loaded through [plugins].
|
||||
*
|
||||
* Note: Just about all preprocessors in Karma (other than CoffeeScript and some other defaults)
|
||||
* require an additional library to be installed (via NPM).
|
||||
*
|
||||
* Be aware that preprocessors may be transforming the files and file types that are available at run time. For instance,
|
||||
* if you are using the "coverage" preprocessor on your source files, if you then attempt to interactively debug
|
||||
* your tests, you'll discover that your expected source code is completely changed from what you expected. Because
|
||||
* of that, you'll want to engineer this so that your automated builds use the coverage entry in the "reporters" list,
|
||||
* but your interactive debugging does not.
|
||||
*
|
||||
*/
|
||||
preprocessors?: { [name: string]: string | string[] };
|
||||
/**
|
||||
* @default 'http:'
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>http:</li>
|
||||
* <li>https:</li>
|
||||
* </ul>
|
||||
* @description Protocol used for running the Karma webserver.
|
||||
* Determines the use of the Node http or https class.
|
||||
* Note: Using <code>'https:'</code> requires you to specify <code>httpsServerOptions</code>.
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description A map of path-proxy pairs.
|
||||
*/
|
||||
proxies?: { [path: string]: string };
|
||||
/**
|
||||
* @default true
|
||||
* @description Whether or not Karma or any browsers should raise an error when an inavlid SSL certificate is found.
|
||||
*/
|
||||
proxyValidateSSL?: boolean;
|
||||
/**
|
||||
* @default 0
|
||||
* @description Karma will report all the tests that are slower than given time limit (in ms).
|
||||
* This is disabled by default (since the default value is 0).
|
||||
*/
|
||||
reportSlowerThan?: number;
|
||||
/**
|
||||
* @default ['progress']
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>dots</li>
|
||||
* <li>progress</li>
|
||||
* </ul>
|
||||
* @description A list of reporters to use.
|
||||
* Additional reporters, such as growl, junit, teamcity or coverage can be loaded through plugins.
|
||||
* Note: Just about all additional reporters in Karma (other than progress) require an additional library to be installed (via NPM).
|
||||
*/
|
||||
reporters?: string[];
|
||||
/**
|
||||
* @default false
|
||||
* @description Continuous Integration mode.
|
||||
* If true, Karma will start and capture all configured browsers, run tests and then exit with an exit code of 0 or 1 depending
|
||||
* on whether all tests passed or any tests failed.
|
||||
*/
|
||||
singleRun?: boolean;
|
||||
/**
|
||||
* @default ['polling', 'websocket']
|
||||
* @description An array of allowed transport methods between the browser and testing server. This configuration setting
|
||||
* is handed off to [socket.io](http://socket.io/) (which manages the communication
|
||||
* between browsers and the testing server).
|
||||
*/
|
||||
transports?: string[];
|
||||
/**
|
||||
* @default '/'
|
||||
* @description The base url, where Karma runs.
|
||||
* All of Karma's urls get prefixed with the urlRoot. This is helpful when using proxies, as
|
||||
* sometimes you might want to proxy a url that is already taken by Karma.
|
||||
*/
|
||||
urlRoot?: string;
|
||||
}
|
||||
|
||||
export interface ClientOptions {
|
||||
/**
|
||||
* @default undefined
|
||||
* @description When karma run is passed additional arguments on the command-line, they
|
||||
* are passed through to the test adapter as karma.config.args (an array of strings).
|
||||
* The client.args option allows you to set this value for actions other than run.
|
||||
* How this value is used is up to your test adapter - you should check your adapter's
|
||||
* documentation to see how (and if) it uses this value.
|
||||
*/
|
||||
args?: string[];
|
||||
/**
|
||||
* @default true
|
||||
* @description Run the tests inside an iFrame or a new window
|
||||
* If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an
|
||||
* iFrame and may need a new window to run.
|
||||
*/
|
||||
useIframe?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Capture all console output and pipe it to the terminal.
|
||||
*/
|
||||
captureConsole?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Run the tests on the same window as the client, without using iframe or a new window
|
||||
*/
|
||||
runInParent?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Clear the context window
|
||||
* If true, Karma clears the context window upon the completion of running the tests.
|
||||
* If false, Karma does not clear the context window upon the completion of running the tests.
|
||||
* Setting this to false is useful when embedding a Jasmine Spec Runner Template.
|
||||
*/
|
||||
clearContext?: boolean;
|
||||
}
|
||||
|
||||
export interface FilePattern {
|
||||
/**
|
||||
* The pattern to use for matching. This property is mandatory.
|
||||
*/
|
||||
pattern: string;
|
||||
/**
|
||||
* @default true
|
||||
* @description If <code>autoWatch</code> is true all files that have set watched to true will be watched
|
||||
* for changes.
|
||||
*/
|
||||
watched?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be included in the browser using <script> tag? Use false if you want to
|
||||
* load them manually, eg. using Require.js.
|
||||
*/
|
||||
included?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be served by Karma's webserver?
|
||||
*/
|
||||
served?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Should the files be served from disk on each request by Karma's webserver?
|
||||
*/
|
||||
nocache?: boolean;
|
||||
}
|
||||
|
||||
export interface CustomLauncher {
|
||||
base: string;
|
||||
browserName?: string;
|
||||
flags?: string[];
|
||||
platform?: string;
|
||||
}
|
||||
|
||||
export namespace config {
|
||||
function parseConfig(configFilePath: string, cliOptions: ConfigOptions): Config;
|
||||
}
|
||||
|
||||
+10
-12
@@ -1,16 +1,6 @@
|
||||
import gulp = require('gulp');
|
||||
import karma = require('karma');
|
||||
|
||||
function runKarma(singleRun: boolean): void {
|
||||
// MEMO: `start` method is deprecated since 0.13. It will be removed in 0.14.
|
||||
karma.server.start({
|
||||
configFile: __dirname + '/karma.conf.js',
|
||||
singleRun
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('test:unit:karma', gulp.parallel('build:test:unit', () => runKarma(true)));
|
||||
|
||||
// karma.server is deprecated and will eventually be removed
|
||||
karma.server.start({port: 9876}, (exitCode: number) => {
|
||||
console.log('Karma has exited with ' + exitCode);
|
||||
process.exit(exitCode);
|
||||
@@ -54,7 +44,8 @@ karma.runner.run({port: 9876}, (exitCode: number) => {
|
||||
process.exit(exitCode);
|
||||
});
|
||||
|
||||
const captured: boolean = karma.launcher.areAllCaptured();
|
||||
const launcher: karma.launcher.Launcher = null;
|
||||
const captured: boolean = launcher.areAllCaptured();
|
||||
|
||||
// Example of configuration file karma.conf.ts, see http://karma-runner.github.io/latest/config/configuration-file.html
|
||||
module.exports = (config: karma.Config) => {
|
||||
@@ -123,3 +114,10 @@ const foo = (config: karma.Config) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
console.log(karma.constants.DEFAULT_HOSTNAME);
|
||||
console.log(karma.VERSION);
|
||||
|
||||
karma.config.parseConfig('karma.conf.js', {
|
||||
singleRun: true
|
||||
});
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import { LinkifyOptions } from "./index";
|
||||
|
||||
export function linkifyHtml(input: string, options?: LinkifyOptions): string;
|
||||
export default linkifyHtml;
|
||||
Vendored
+185
@@ -0,0 +1,185 @@
|
||||
// Type definitions for linkifyjs 2.1
|
||||
// Project: https://github.com/SoapBox/linkifyjs#readme
|
||||
// Definitions by: Sean Zhu <https://github.com/szhu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export type PossiblyFuncOfHrefAndType<T> =
|
||||
| T
|
||||
| ((href: string, type: string) => T);
|
||||
|
||||
// There's always a possibility that values at a string key can always be
|
||||
// undefined; i.e., if the key does not exist.
|
||||
export type PossiblyByType<T> = T | { [type: string]: T | undefined };
|
||||
|
||||
export type EventHandler = (e: HTMLElement) => void;
|
||||
|
||||
export interface LinkifyOptions {
|
||||
/**
|
||||
* attributes
|
||||
* - Type: Object | Function (String href, String type)
|
||||
* - Default: null
|
||||
*
|
||||
* Object of attributes to add to each new link. Note: the class and target
|
||||
* attributes have dedicated options.
|
||||
*
|
||||
* Also accepts a function that takes the unformatted href, the link type
|
||||
* (e.g., 'url', 'email', etc.) and returns the object.
|
||||
*/
|
||||
attributes?: PossiblyFuncOfHrefAndType<{
|
||||
[attrName: string]: string;
|
||||
}> | null;
|
||||
|
||||
/**
|
||||
* className
|
||||
* - Type: String | Function (String href, String type) | Object
|
||||
* - Default: 'linkified' (may be removed in future releases)
|
||||
*
|
||||
* class attribute to use for newly created links.
|
||||
*
|
||||
* Accepts a function that takes the unformatted href value and link type
|
||||
* (e.g., 'url', 'email', etc.) and returns the string.
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* string or function to use for that type.
|
||||
*/
|
||||
className?: PossiblyByType<PossiblyFuncOfHrefAndType<string | undefined>>;
|
||||
|
||||
/**
|
||||
* defaultProtocol
|
||||
* - Type: String
|
||||
* - Default: 'http'
|
||||
* - Values: 'http', 'https', 'ftp', 'ftps', etc.
|
||||
*
|
||||
* Protocol that should be used in href attributes for URLs without a
|
||||
* protocol (e.g., github.com).
|
||||
*/
|
||||
defaultProtocol?: string;
|
||||
|
||||
/**
|
||||
* events
|
||||
* - *element, jquery interfaces only*
|
||||
* - Type: Object | Function (String href, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* Add event listeners to newly created link elements. Takes a hash where
|
||||
* each key is an standard event name and the value is an event handler.
|
||||
*
|
||||
* Also accepts a function that takes the unformatted href and the link type
|
||||
* (e.g., 'url', 'email', etc.) and returns the hash.
|
||||
*
|
||||
* For React, specify events in the attributes option as standard React
|
||||
* events.
|
||||
*
|
||||
* See the React Event docs and the linkify-react event docs
|
||||
*/
|
||||
events?: PossiblyFuncOfHrefAndType<{
|
||||
[eventName: string]: EventHandler;
|
||||
}> | null;
|
||||
|
||||
/**
|
||||
* format
|
||||
* - Type: Function (String value, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* Format the text displayed by a linkified entity. e.g., truncate a long
|
||||
* URL.
|
||||
*
|
||||
* Accepts an object where each key is the link type (e.g., 'url', 'email',
|
||||
* etc.) and each value is the formatting function to use for that type.
|
||||
*
|
||||
* NOTE: According to the linkifyjs implementation, `format` can be just a
|
||||
* string, but this is not mentioned in the docs, so we exclude it.
|
||||
*/
|
||||
format?: PossiblyByType<(value: string, type: string) => string>;
|
||||
//
|
||||
|
||||
/**
|
||||
* formatHref
|
||||
* - Type: Function (String href, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* Similar to format, except the result of this function will be used as the
|
||||
* href attribute of the new link.
|
||||
*
|
||||
* This is useful when finding hashtags, where you don’t necessarily want
|
||||
* the default to be a link to a named anchor.
|
||||
*
|
||||
* Accepts an object where each key is the link type (e.g., 'url', 'email',
|
||||
* etc.) and each value is the formatting function to use for that type.
|
||||
*
|
||||
* NOTE: According to the linkifyjs implementation, `formatHref` can be just
|
||||
* a string, but this is not mentioned in the docs, so we exclude it.
|
||||
*/
|
||||
formatHref?: PossiblyByType<(href: string, type: string) => string>;
|
||||
|
||||
/**
|
||||
* ignoreTags
|
||||
* - *element, html, and jquery interfaces only*
|
||||
* - Type: Array
|
||||
* - Default: []
|
||||
*
|
||||
* Prevent linkify from trying to parse links in the specified tags. This is
|
||||
* useful when running linkify on arbitrary HTML.
|
||||
*/
|
||||
ignoreTags?: string[];
|
||||
|
||||
/**
|
||||
* nl2br
|
||||
* - Type: Boolean
|
||||
* - Default: false
|
||||
*
|
||||
* If true, \n line breaks will automatically be converted to <br> tags.
|
||||
*
|
||||
*/
|
||||
nl2br?: boolean;
|
||||
|
||||
/**
|
||||
* tagName
|
||||
* - Type: String | Function (String href, String type) | Object
|
||||
* - Default: a
|
||||
*
|
||||
* The tag name to use for each link. For cases where you can’t use anchor
|
||||
* tags.
|
||||
*
|
||||
* Accepts a function that takes the unformatted href, the link type (e.g.,
|
||||
* 'url', 'email', etc.) and returns the tag name.
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* tag name to use for that type.
|
||||
*/
|
||||
tagName?: PossiblyByType<PossiblyFuncOfHrefAndType<string>>;
|
||||
|
||||
/**
|
||||
* target
|
||||
* - Type: String | Function (String href, String type) | Object
|
||||
* - Default: '_blank' for URLs, null for everything else
|
||||
*
|
||||
* target attribute for generated link.
|
||||
*
|
||||
* Accepts a function that takes the unformatted href, the link type (e.g.,
|
||||
* 'url', 'email', etc.) and returns the target
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* target to use for that type.
|
||||
*/
|
||||
target?: PossiblyByType<
|
||||
PossiblyFuncOfHrefAndType<string | null | undefined>
|
||||
>;
|
||||
|
||||
/**
|
||||
* validate
|
||||
* - Type: Boolean | Function (String value, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* If option resolves to false, the given value will not show up as a link.
|
||||
*
|
||||
* Accepts a function that takes a discovered link and the link type (e.g.,
|
||||
* 'url', 'email', etc.) and returns true if the link should be converted
|
||||
* into an anchor tag, and false otherwise.
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* the validation option to use for that type
|
||||
*/
|
||||
validate?: PossiblyByType<PossiblyFuncOfHrefAndType<boolean>>;
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import linkifyHtml from "linkifyjs/html";
|
||||
|
||||
// From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html
|
||||
|
||||
/* attributes */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
attributes: {
|
||||
rel: "nofollow"
|
||||
}
|
||||
});
|
||||
|
||||
/* className */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
className: "new-link--url"
|
||||
});
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
className(href, type) {
|
||||
return "new-link--" + type;
|
||||
}
|
||||
});
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
className: {
|
||||
url: "new-link--url",
|
||||
email(href: string) {
|
||||
return "new-link--email";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* events */
|
||||
|
||||
linkifyHtml("", {
|
||||
events: {
|
||||
click(e) {
|
||||
alert("Link clicked!");
|
||||
},
|
||||
mouseover(e) {
|
||||
alert("Link hovered!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* defaultProtocol */
|
||||
|
||||
/* format */
|
||||
|
||||
linkifyHtml("", {
|
||||
format(value, type) {
|
||||
if (type === "url" && value.length > 50) {
|
||||
value = value.slice(0, 50) + "…";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
linkifyHtml("", {
|
||||
format: {
|
||||
url(value) {
|
||||
return value.length > 50 ? value.slice(0, 50) + "…" : value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* formatHref */
|
||||
|
||||
linkifyHtml("This site is #rad", {
|
||||
formatHref(href, type) {
|
||||
if (type === "hashtag") {
|
||||
href = "https://twitter.com/hashtag/" + href.substring(1);
|
||||
}
|
||||
return href;
|
||||
}
|
||||
});
|
||||
|
||||
linkifyHtml("Hey @dhh, check out issue #23", {
|
||||
formatHref: {
|
||||
mention(href) {
|
||||
return "https://github.com" + href;
|
||||
},
|
||||
ticket(href) {
|
||||
return (
|
||||
"https://github.com/SoapBox/linkifyjs/issues/" +
|
||||
href.substring(1)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* ignoreTags */
|
||||
|
||||
linkifyHtml(
|
||||
// tslint:disable-next-line:prefer-template
|
||||
'Please ignore <script>var a = {}; a.com = "Hi";</script> \n' +
|
||||
"but do <span>b.ca</span>",
|
||||
{
|
||||
ignoreTags: ["script", "style"]
|
||||
}
|
||||
);
|
||||
|
||||
/* nl2br */
|
||||
|
||||
/* tagName */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
tagName: "span"
|
||||
});
|
||||
|
||||
linkifyHtml("#swag", {
|
||||
tagName: {
|
||||
hashtag: "span"
|
||||
}
|
||||
});
|
||||
|
||||
/* target */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
target: "_parent"
|
||||
});
|
||||
|
||||
linkifyHtml("test-email@example.com", {
|
||||
target: {
|
||||
url: "_parent",
|
||||
email: null
|
||||
}
|
||||
});
|
||||
|
||||
/* validate */
|
||||
|
||||
// Don't linkify links that don't begin in a protocol
|
||||
// e.g., "http://google.com" will be linkified, but "google.com" will not.
|
||||
linkifyHtml("www.google.com", {
|
||||
validate: {
|
||||
url(value) {
|
||||
return /^(http|ftp)s?:\/\//.test(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"html.d.ts",
|
||||
"linkifyjs-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for mustache-express 1.2
|
||||
// Project: https://github.com/bryanburgers/node-mustache-express#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Cache } from 'lru-cache';
|
||||
|
||||
export = mustacheExpress;
|
||||
|
||||
declare function mustacheExpress(
|
||||
partialsPath?: string,
|
||||
partialsExt?: string
|
||||
): mustacheExpress.ExpessEngine;
|
||||
|
||||
declare namespace mustacheExpress {
|
||||
interface ExpessEngine {
|
||||
(path: string, options: any, cb: (...args: any[]) => any): any;
|
||||
cache: TemplateCache;
|
||||
}
|
||||
|
||||
type TemplateCache = Cache<string, { name: string; data: string; partials: string[] }>;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import express = require('express');
|
||||
import mustacheExpress = require('mustache-express');
|
||||
|
||||
const app = express();
|
||||
app.engine('mustache', mustacheExpress());
|
||||
app.engine('mustache', mustacheExpress('/partials'));
|
||||
app.engine('mustache', mustacheExpress('/partials', '.mst'));
|
||||
|
||||
// $ExpectType Cache<string, { name: string; data: string; partials: string[]; }>
|
||||
mustacheExpress().cache;
|
||||
@@ -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",
|
||||
"mustache-express-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -90,7 +90,7 @@ spawnBox = (function() {
|
||||
|
||||
var box_geometry = new THREE.BoxGeometry( 4, 4, 4 ),
|
||||
handleCollision = function( collided_with ) {
|
||||
var target = <any>this;
|
||||
var target = this as any;
|
||||
target.collisions = 0;
|
||||
switch (++target.collisions) {
|
||||
|
||||
@@ -168,4 +168,4 @@ render = function() {
|
||||
render_stats.update();
|
||||
};
|
||||
|
||||
window.onload = initScene;
|
||||
window.onload = initScene;
|
||||
|
||||
@@ -186,11 +186,11 @@ initScene = function() {
|
||||
);
|
||||
}
|
||||
|
||||
input = <any>{
|
||||
input = {
|
||||
power: null,
|
||||
direction: null,
|
||||
steering: 0
|
||||
};
|
||||
} as any;
|
||||
document.addEventListener('keydown', function( ev ) {
|
||||
switch ( ev.keyCode ) {
|
||||
case 37: // left
|
||||
|
||||
Vendored
+26
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for pigpio 0.4
|
||||
// Type definitions for pigpio 1.2
|
||||
// Project: https://github.com/fivdi/pigpio
|
||||
// Definitions by: ManerFan <https://github.com/manerfan>
|
||||
// Definitions by: ManerFan <https://github.com/manerfan>, erikma <https://github.com/erikma>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -424,3 +424,27 @@ export function configureClock(microseconds: number, peripheral: number): void;
|
||||
* @param port an unsigned integer specifying the pigpio socket port number
|
||||
*/
|
||||
export function configureSocketPort(port: number): void;
|
||||
|
||||
/**
|
||||
* Returns the Raspberry Pi hardware revision as an unsigned integer. Returns 0
|
||||
* if the hardware revision can not be determined.
|
||||
*/
|
||||
export function hardwareRevision(): number;
|
||||
|
||||
/**
|
||||
* Gets the current unsigned 32-bit integer value of the number of microseconds
|
||||
* since system boot. This value wraps around the 32-bit space in just over an hour.
|
||||
* Use tickDiff() to get the difference between two tick values, to
|
||||
* ensure the correct JavaScript operations are used to account for the possibility
|
||||
* of overflow.
|
||||
*/
|
||||
export function getTick(): number;
|
||||
|
||||
/**
|
||||
* Returns the difference in microseconds between the end and start tick counts.
|
||||
* The tick counts can be retrieved using getTick(), or may be passed
|
||||
* in a GPIO event callback.
|
||||
* @param startTick The start of the measured interval. An unsigned integer tick value.
|
||||
* @param endTick The end of the measured interval. An unsigned integer tick value.
|
||||
*/
|
||||
export function tickDiff(startTick: number, endTick: number): number;
|
||||
|
||||
@@ -880,6 +880,15 @@ import * as assert from 'assert';
|
||||
}, 2000);
|
||||
})();
|
||||
|
||||
(function tickAndTickDiff(): void {
|
||||
const startTick: number = pigpio.getTick();
|
||||
setTimeout(() => {
|
||||
const endTick: number = pigpio.getTick();
|
||||
const diff: number = pigpio.tickDiff(startTick, endTick);
|
||||
assert.ok(diff > 0, 'expected tick count to increase across a timer call');
|
||||
}, 50);
|
||||
})();
|
||||
|
||||
(function gpio_glitch_filter(): void {
|
||||
const Gpio = pigpio.Gpio;
|
||||
const input = new Gpio(7, {
|
||||
|
||||
Vendored
+148
@@ -0,0 +1,148 @@
|
||||
// Type definitions for postcss-url 8.0
|
||||
// Project: https://github.com/postcss/postcss-url
|
||||
// Definitions by: Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Plugin } from 'postcss';
|
||||
|
||||
declare namespace url {
|
||||
type CustomTransformFunction = (
|
||||
asset: {
|
||||
/**
|
||||
* Original URL.
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* URL pathname.
|
||||
*/
|
||||
pathname?: string;
|
||||
|
||||
/**
|
||||
* Absolute path to asset.
|
||||
*/
|
||||
absolutePath?: string;
|
||||
|
||||
/**
|
||||
* Current relative path to asset.
|
||||
*/
|
||||
relativePath?: string;
|
||||
|
||||
/**
|
||||
* Querystring from URL.
|
||||
*/
|
||||
search?: string;
|
||||
|
||||
/**
|
||||
* Hash from URL.
|
||||
*/
|
||||
hash?: string;
|
||||
},
|
||||
dir: {
|
||||
/**
|
||||
* PostCSS from option.
|
||||
*/
|
||||
from?: string;
|
||||
|
||||
/**
|
||||
* PostCSS to option.
|
||||
*/
|
||||
to?: string;
|
||||
|
||||
/**
|
||||
* File path.
|
||||
*/
|
||||
file?: string;
|
||||
},
|
||||
) => string;
|
||||
type CustomHashFunction = (file: Buffer) => string;
|
||||
type CustomFilterFunction = (file: string) => boolean;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* URL rewriting mechanism.
|
||||
*
|
||||
* @default 'rebase'
|
||||
*/
|
||||
url?: 'copy' | 'inline' | 'rebase' | CustomTransformFunction;
|
||||
|
||||
/**
|
||||
* Specify the maximum file size to inline (in kilobytes).
|
||||
*/
|
||||
maxSize?: number;
|
||||
|
||||
/**
|
||||
* Do not warn when an SVG URL with a fragment is inlined.
|
||||
* PostCSS-URL does not support partial inlining.
|
||||
* The entire SVG file will be inlined.
|
||||
* By default a warning will be issued when this occurs.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
ignoreFragmentWarning?: boolean;
|
||||
|
||||
/**
|
||||
* Determine wether a file should be inlined.
|
||||
*/
|
||||
filter?: RegExp | CustomFilterFunction | string;
|
||||
|
||||
/**
|
||||
* Specifies whether the URL's fragment identifer value, if present, will be added to the inlined data URI.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
includeUriFragment?: boolean;
|
||||
|
||||
/**
|
||||
* The fallback method to use if the maximum size is exceeded or the URL contains a hash.
|
||||
*/
|
||||
fallback?: CustomTransformFunction;
|
||||
|
||||
/**
|
||||
* Specify the base path or list of base paths where to search images from.
|
||||
*/
|
||||
basePath?: string | string[];
|
||||
|
||||
/**
|
||||
* The assets files will be copied in that destination.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
assetsPath?: boolean | string;
|
||||
|
||||
/**
|
||||
* Rename the path of the files by a hash name.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
useHash?: boolean;
|
||||
|
||||
/**
|
||||
* Hash options
|
||||
*/
|
||||
hashOptions?: {
|
||||
/**
|
||||
* Hashing method or custom function.
|
||||
*/
|
||||
method?: 'xxhash32' | 'xxhash64' | CustomHashFunction;
|
||||
|
||||
/**
|
||||
* Shrink hast to certain length.
|
||||
*/
|
||||
shrink?: number;
|
||||
|
||||
/**
|
||||
* Append the original filename in resulting filename.
|
||||
*/
|
||||
append?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
type Url = Plugin<Options | Options[]>;
|
||||
}
|
||||
|
||||
declare const url: url.Url;
|
||||
export = url;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"postcss": "7.x.x"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as postcss from 'postcss';
|
||||
import * as url from 'postcss-url';
|
||||
|
||||
const standard: postcss.Transformer = url();
|
||||
|
||||
const single: postcss.Transformer = url({ url: 'copy', assetsPath: 'img', useHash: true });
|
||||
|
||||
const multiple: postcss.Transformer = url([
|
||||
{ filter: '**/assets/copy/*.png', url: 'copy', assetsPath: 'img', useHash: true },
|
||||
{ filter: '**/assets/inline/*.svg', url: 'inline' },
|
||||
{ filter: '**/assets/**/*.gif', url: 'rebase' },
|
||||
{ filter: 'cdn/**/*', url: (asset) => `https://cdn.url/${asset.url}` },
|
||||
]);
|
||||
|
||||
postcss().use(standard);
|
||||
postcss().use(single);
|
||||
postcss().use(multiple);
|
||||
@@ -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",
|
||||
"postcss-url-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for random-obj-key 1.0
|
||||
// Project: https://github.com/sindresorhus/random-obj-key
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = randomObjKey;
|
||||
|
||||
declare function randomObjKey<TObj extends { [key: string]: any }>(input: TObj): keyof TObj;
|
||||
@@ -0,0 +1,4 @@
|
||||
import randomObjKey = require('random-obj-key');
|
||||
|
||||
// $ExpectType "foo" | "bar"
|
||||
randomObjKey({ foo: true, bar: true });
|
||||
@@ -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",
|
||||
"random-obj-key-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+5
-3
@@ -4,7 +4,7 @@
|
||||
// Nathan Holland <https://github.com/NathanNZ>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
Heads up, this will commit to master.
|
||||
// Required fields are made according to 'minimum REQUIRED setup' in https://github.com/airbnb/react-dates/blob/master/README.md
|
||||
|
||||
import * as React from 'react';
|
||||
@@ -69,7 +69,6 @@ declare namespace ReactDates {
|
||||
small?: boolean;
|
||||
regular?: boolean;
|
||||
keepFocusOnInput?: boolean;
|
||||
|
||||
// calendar presentation and interaction related props
|
||||
renderMonthText?: (day: momentPropTypes.momentObj) => string | JSX.Element;
|
||||
renderMonthElement?: (
|
||||
@@ -497,7 +496,10 @@ declare namespace ReactDates {
|
||||
var toISODateString: (date: moment.MomentInput, currentFormat: moment.MomentFormatSpecification) => string | null;
|
||||
// utils/toLocalizedDateString.js
|
||||
var toLocalizedDateString: (
|
||||
date: moment.MomentInput,
|
||||
dat<<<<<<< master
|
||||
56
|
||||
|
||||
e: moment.MomentInput,
|
||||
currentFormat: moment.MomentFormatSpecification
|
||||
) => string | null;
|
||||
// utils/toMomentObject.js
|
||||
|
||||
@@ -24,6 +24,36 @@ export declare class ResponsiveNavigation extends Component<ResponsiveNavigation
|
||||
*/
|
||||
toggle(): void;
|
||||
render(): JSX.Element;
|
||||
static propTypes: {
|
||||
breakpoint: PropTypes.Validator<any>;
|
||||
alignX: PropTypes.Requireable<any>;
|
||||
alignY: PropTypes.Requireable<any>;
|
||||
selfAlignX: PropTypes.Requireable<any>;
|
||||
selfAlignY: PropTypes.Requireable<any>;
|
||||
centerAlign: PropTypes.Requireable<any>;
|
||||
flexContainer: PropTypes.Requireable<any>;
|
||||
flexDirRow: PropTypes.Requireable<any>;
|
||||
flexDirRowRev: PropTypes.Requireable<any>;
|
||||
flexDirCol: PropTypes.Requireable<any>;
|
||||
flexDirColRev: PropTypes.Requireable<any>;
|
||||
flexChild: PropTypes.Requireable<any>;
|
||||
flexOrder: PropTypes.Requireable<any>;
|
||||
flexOrderSmall: PropTypes.Requireable<any>;
|
||||
flexOrderMedium: PropTypes.Requireable<any>;
|
||||
flexOrderLarge: PropTypes.Requireable<any>;
|
||||
showFor: PropTypes.Requireable<any>;
|
||||
showOnlyFor: PropTypes.Requireable<any>;
|
||||
hideFor: PropTypes.Requireable<any>;
|
||||
hideOnlyFor: PropTypes.Requireable<any>;
|
||||
isHidden: PropTypes.Requireable<any>;
|
||||
isInvisible: PropTypes.Requireable<any>;
|
||||
showForLandscape: PropTypes.Requireable<any>;
|
||||
showForPortrait: PropTypes.Requireable<any>;
|
||||
showForSr: PropTypes.Requireable<any>;
|
||||
showOnFocus: PropTypes.Requireable<any>;
|
||||
isClearfix: PropTypes.Requireable<any>;
|
||||
float: PropTypes.Requireable<any>;
|
||||
};
|
||||
static defaultProps: {
|
||||
breakpoint: number;
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -25,7 +25,7 @@ declare namespace Gravatar {
|
||||
type DefaultImage = "404" | "mm" | "identicon" | "monsterid" | "wavatar" | "retro" | "blank";
|
||||
type Rating = "g" | "pg" | "r" | "x";
|
||||
|
||||
interface Props {
|
||||
interface Props extends Partial<JSX.IntrinsicElements['img']> {
|
||||
/**
|
||||
* The email address used to look up the Gravatar image.
|
||||
* If you wish to avoid sending an email address to the client, you can compute the md5 hash on the server and
|
||||
|
||||
Vendored
+4
-1
@@ -9037,8 +9037,11 @@ export const PixelRatio: PixelRatioStatic;
|
||||
*
|
||||
* const View = requireNativeComponent('RCTView');
|
||||
*
|
||||
* The concrete return type of `requireNativeComponent` is a string, but the declared type is
|
||||
* `any` because TypeScript assumes anonymous JSX intrinsics (`string` instead of `"div", for
|
||||
* example) not to have any props.
|
||||
*/
|
||||
export function requireNativeComponent(viewName: string): React.ReactType;
|
||||
export function requireNativeComponent(viewName: string): any;
|
||||
|
||||
export function findNodeHandle(
|
||||
componentOrHandle: null | number | React.Component<any, any> | React.ComponentClass<any>
|
||||
|
||||
+6
@@ -67,6 +67,9 @@ export type MenuProps<OptionType> = CommonProps<OptionType> & {
|
||||
export function menuCSS(state: MenuState): React.CSSProperties;
|
||||
|
||||
export class Menu<OptionType> extends Component<MenuProps<OptionType>, MenuState> {
|
||||
static contextTypes: {
|
||||
getPortalPlacement: (state: MenuState) => void,
|
||||
};
|
||||
getPlacement: (ref: ElementRef<any>) => void;
|
||||
getState: () => MenuProps<OptionType> & MenuState;
|
||||
}
|
||||
@@ -143,6 +146,9 @@ interface PortalStyleArgs {
|
||||
export function menuPortalCSS(args: PortalStyleArgs): React.CSSProperties;
|
||||
|
||||
export class MenuPortal<OptionType> extends Component<MenuPortalProps<OptionType>, MenuPortalState> {
|
||||
static childContextTypes: {
|
||||
getPortalPlacement: (state: MenuState) => void,
|
||||
};
|
||||
getChildContext(): {
|
||||
getPortalPlacement: (state: MenuState) => void;
|
||||
};
|
||||
|
||||
@@ -18,12 +18,7 @@ const NoOptionsMessage = (props: any) => {
|
||||
export default class CustomNoOptionsMessage extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
// Without the type argument, `OptionType` is inferred as `never` from the
|
||||
// `options` attribute of type `never[]`, and `Select.defaultProps` (of
|
||||
// type `Props<any>`) fails to be assignable to the instantiated props
|
||||
// type, `Props<never>`. This issue shouldn't come up in real code where
|
||||
// the `options` attribute isn't a literal empty array.
|
||||
<Select<{ label: string; value: string }>
|
||||
<Select
|
||||
isClearable
|
||||
components={{ NoOptionsMessage }}
|
||||
styles={{ noOptionsMessage: (base: any) => ({ ...base, ...msgStyles }) }}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export type ListProps = GridCoreProps & {
|
||||
/** Height constraint for list (determines how many actual rows are rendered) */
|
||||
height: number;
|
||||
/** Optional renderer to be used in place of rows when rowCount is 0 */
|
||||
noRowsRenderer?: () => JSX.Element | null;
|
||||
noRowsRenderer?: () => JSX.Element;
|
||||
/**
|
||||
* Callback invoked with information about the slice of rows that were just rendered.
|
||||
* ({ startIndex, stopIndex }): void
|
||||
|
||||
+78
-1
@@ -152,6 +152,26 @@ export type ColumnProps = {
|
||||
width: number;
|
||||
};
|
||||
export class Column extends Component<ColumnProps> {
|
||||
static propTypes: {
|
||||
"aria-label": Requireable<string>;
|
||||
cellDataGetter: Requireable<TableCellDataGetter>;
|
||||
cellRenderer: Requireable<TableCellRenderer>;
|
||||
className: Requireable<string>;
|
||||
columnData: Requireable<object>;
|
||||
dataKey: Validator<string>;
|
||||
disableSort: Requireable<boolean>;
|
||||
flexGrow: Requireable<number>;
|
||||
flexShrink: Requireable<number>;
|
||||
headerClassName: Requireable<string>;
|
||||
headerRenderer: Validator<TableHeaderRowRenderer>;
|
||||
label: Requireable<string>;
|
||||
maxWidth: Requireable<number>;
|
||||
minWidth: Requireable<number>;
|
||||
style: Requireable<React.CSSProperties>;
|
||||
width: Validator<number>;
|
||||
id: Requireable<string>;
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
cellDataGetter: TableCellDataGetter;
|
||||
cellRenderer: TableCellRenderer;
|
||||
@@ -358,6 +378,63 @@ export const SortIndicator: React.StatelessComponent<{
|
||||
* This component expects explicit width, height, and padding parameters.
|
||||
*/
|
||||
export class Table extends PureComponent<TableProps> {
|
||||
static propTypes: {
|
||||
"aria-label": Requireable<string>;
|
||||
autoHeight: Requireable<boolean>;
|
||||
children: Validator<Column>;
|
||||
className: Requireable<string>;
|
||||
disableHeader: Requireable<boolean>;
|
||||
estimatedRowSize: Validator<number>;
|
||||
gridClassName: Requireable<string>;
|
||||
gridStyle: Requireable<React.CSSProperties>;
|
||||
headerClassName: Requireable<string>;
|
||||
headerHeight: Validator<number>;
|
||||
headerRowRenderer: Requireable<TableHeaderRowRenderer>;
|
||||
headerStyle: Requireable<React.CSSProperties>;
|
||||
height: Validator<number>;
|
||||
id: Requireable<string>;
|
||||
noRowsRenderer: Requireable<() => JSX.Element>;
|
||||
onHeaderClick: Requireable<
|
||||
(params: HeaderMouseEventHandlerParams) => void
|
||||
>;
|
||||
onRowClick: Requireable<(params: RowMouseEventHandlerParams) => void>;
|
||||
onRowDoubleClick: Requireable<
|
||||
(params: RowMouseEventHandlerParams) => void
|
||||
>;
|
||||
onRowMouseOut: Requireable<
|
||||
(params: RowMouseEventHandlerParams) => void
|
||||
>;
|
||||
onRowMouseOver: Requireable<
|
||||
(params: RowMouseEventHandlerParams) => void
|
||||
>;
|
||||
onRowsRendered: Requireable<
|
||||
(params: RowMouseEventHandlerParams) => void
|
||||
>;
|
||||
onScroll: Requireable<(params: ScrollEventData) => void>;
|
||||
overscanRowCount: Validator<number>;
|
||||
rowClassName: Requireable<string | ((params: Index) => string)>;
|
||||
rowGetter: Validator<(params: Index) => any>;
|
||||
rowHeight: Validator<number | ((params: Index) => number)>;
|
||||
rowCount: Validator<number>;
|
||||
rowRenderer: Requireable<(props: TableRowProps) => React.ReactNode>;
|
||||
rowStyle: Validator<
|
||||
React.CSSProperties | ((params: Index) => React.CSSProperties)
|
||||
>;
|
||||
scrollToAlignment: Validator<Alignment>;
|
||||
scrollToIndex: Validator<number>;
|
||||
scrollTop: Requireable<number>;
|
||||
sort: Requireable<
|
||||
(
|
||||
params: { sortBy: string; sortDirection: SortDirectionType }
|
||||
) => void
|
||||
>;
|
||||
sortBy: Requireable<string>;
|
||||
sortDirection: Validator<SortDirectionType>;
|
||||
style: Requireable<React.CSSProperties>;
|
||||
tabIndex: Requireable<number>;
|
||||
width: Validator<number>;
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
disableHeader: false;
|
||||
estimatedRowSize: 30;
|
||||
@@ -368,7 +445,7 @@ export class Table extends PureComponent<TableProps> {
|
||||
onScroll: () => null;
|
||||
overscanRowCount: 10;
|
||||
rowRenderer: TableRowRenderer;
|
||||
headerRowRenderer: TableHeaderRowRenderer;
|
||||
headerRowRenderer: TableHeaderRenderer;
|
||||
rowStyle: {};
|
||||
scrollToAlignment: "auto";
|
||||
scrollToIndex: -1;
|
||||
|
||||
Vendored
+26
-100
@@ -421,34 +421,6 @@ declare namespace React {
|
||||
refs: {
|
||||
[key: string]: ReactInstance
|
||||
};
|
||||
|
||||
// Static properties copied from ComponentClass interface.
|
||||
/**
|
||||
* The validity of the type of `propTypes` cannot be checked
|
||||
* automatically at the definition of a component class because the
|
||||
* required type depends on `P`. We recommend checking it using
|
||||
* `asPropTypes` from the `react-typescript-helpers` package. If you
|
||||
* don't do that, then the type will still be checked by
|
||||
* JSX.LibraryManagedAttributes every time the component is used,
|
||||
* assuming you use TypeScript 3.0 or newer.
|
||||
*/
|
||||
// Note: `propTypes` and `defaultProps` need to be `any` so that a
|
||||
// component class that does not redeclare them is assignable to
|
||||
// `ComponentClass<P>`.
|
||||
static propTypes?: any;
|
||||
static contextTypes?: ValidationMap<any>;
|
||||
static childContextTypes?: ValidationMap<any>;
|
||||
/**
|
||||
* The validity of the type of `defaultProps` cannot be checked
|
||||
* automatically at the definition of a component class because the
|
||||
* required type depends on `P`. We recommend checking it using
|
||||
* `asDefaultProps` from the `react-typescript-helpers` package. If you
|
||||
* don't do that, then the type will still be checked by
|
||||
* JSX.LibraryManagedAttributes every time the component is used,
|
||||
* assuming you use TypeScript 3.0 or newer.
|
||||
*/
|
||||
static defaultProps?: any;
|
||||
static displayName?: string;
|
||||
}
|
||||
|
||||
class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> { }
|
||||
@@ -2664,77 +2636,31 @@ declare namespace React {
|
||||
*/
|
||||
componentStack: string;
|
||||
}
|
||||
|
||||
const Invalid_propTypes: unique symbol;
|
||||
/**
|
||||
* Dummy interface that is intersected into the props type of a component on
|
||||
* use to generate an error if the component's `propTypes` static property
|
||||
* is invalid. In most cases, you can get more information about the
|
||||
* problem with the `propTypes` by trying to assign the component to a
|
||||
* variable of type `React.ComponentType<P>` where `P` is the appropriate
|
||||
* props type. You can bypass the type checking of `propTypes` by defining
|
||||
* a static property named `bypassPropTypesTypecheck`.
|
||||
*/
|
||||
interface Invalid_propTypes<P, T> {
|
||||
[Invalid_propTypes]: never;
|
||||
}
|
||||
|
||||
const Invalid_defaultProps: unique symbol;
|
||||
/**
|
||||
* Dummy interface that is intersected into the props type of a component on
|
||||
* use to generate an error if the component's `defaultProps` static
|
||||
* property is invalid. In most cases, you can get more information about
|
||||
* the problem with the `defaultProps` by trying to assign the component to
|
||||
* a variable of type `React.ComponentType<P>` where `P` is the appropriate
|
||||
* props type. You can bypass the type checking of `defaultProps` by
|
||||
* defining a static property named `bypassDefaultPropsTypecheck`.
|
||||
*/
|
||||
interface Invalid_defaultProps<P, D> {
|
||||
[Invalid_defaultProps]: never;
|
||||
}
|
||||
|
||||
// For a component class, the P passed to JSX.LibraryManagedAttributes is
|
||||
// based on the `props` property and includes `children` regardless of
|
||||
// whether the original props type (the `P` type argument to
|
||||
// React.Component) does. However, it's common for component classes not
|
||||
// to list `children` in the `propTypes` if the original props type did not
|
||||
// include `children`. We accommodate that here by making the validator for
|
||||
// `children` optional.
|
||||
type ValidationMapWithOptionalChildren<P> =
|
||||
ValidationMap<Pick<P, Exclude<keyof P, "children">>> &
|
||||
Partial<ValidationMap<Pick<P, Extract<keyof P, "children">>>>;
|
||||
|
||||
// Explicitly check for excess properties in CheckPropTypes and
|
||||
// CheckDefaultProps because by the time we get to
|
||||
// JSX.LibraryManagedAttributes, we have lost the opportunity to do an
|
||||
// excess properties check on the original object literal.
|
||||
|
||||
type CheckPropTypes<P, T> =
|
||||
// This condition attempts to single out `T = any`, which needs to bypass the rest of the check
|
||||
// because `keyof T` would come out as not extending `keyof P`.
|
||||
T extends typeof Invalid_propTypes ? {} :
|
||||
[keyof T, T] extends [keyof P, ValidationMapWithOptionalChildren<P>] ? {} : Invalid_propTypes<P, T>;
|
||||
|
||||
type CheckDefaultProps<P, D> =
|
||||
D extends typeof Invalid_defaultProps ? {} :
|
||||
[keyof D, D] extends [keyof P, Partial<P>] ? {} : Invalid_defaultProps<P, D>;
|
||||
|
||||
// Any prop that has a default prop becomes optional, but its type is unchanged
|
||||
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
||||
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
||||
type Defaultize<P, D> = P extends any
|
||||
? string extends keyof P ? P :
|
||||
& Pick<P, Exclude<keyof P, keyof D>>
|
||||
& Partial<Pick<P, Extract<keyof P, keyof D>>>
|
||||
: never;
|
||||
|
||||
type ReactManagedAttributes<C, P> =
|
||||
(C extends { propTypes: infer T; }
|
||||
? (C extends { bypassPropTypesTypecheck: {}; } ? {} : CheckPropTypes<P, T>) : {}) &
|
||||
(C extends { defaultProps: infer D; }
|
||||
? (C extends { bypassDefaultPropsTypecheck: {}; } ? {} : CheckDefaultProps<P, D>) & Defaultize<P, D> : P);
|
||||
}
|
||||
|
||||
// Declared props take priority over inferred props
|
||||
// If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
|
||||
type MergePropTypes<P, T> = P & Pick<T, Exclude<keyof T, keyof P>>;
|
||||
|
||||
// Any prop that has a default prop becomes optional, but its type is unchanged
|
||||
// Undeclared default props are augmented into the resulting allowable attributes
|
||||
// If declared props have indexed properties, ignore default props entirely as keyof gets widened
|
||||
// Wrap in an outer-level conditional type to allow distribution over props that are unions
|
||||
type Defaultize<P, D> = P extends any
|
||||
? string extends keyof P ? P :
|
||||
& Pick<P, Exclude<keyof P, keyof D>>
|
||||
& Partial<Pick<P, Extract<keyof P, keyof D>>>
|
||||
& Partial<Pick<D, Exclude<keyof D, keyof P>>>
|
||||
: never;
|
||||
|
||||
type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D; }
|
||||
? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
|
||||
: C extends { propTypes: infer T; }
|
||||
? MergePropTypes<P, PropTypes.InferProps<T>>
|
||||
: C extends { defaultProps: infer D; }
|
||||
? Defaultize<P, D>
|
||||
: P;
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
@@ -2749,9 +2675,9 @@ declare global {
|
||||
// let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
|
||||
type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
|
||||
? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
|
||||
? React.ReactManagedAttributes<U, P>
|
||||
: React.ReactManagedAttributes<T, P>
|
||||
: React.ReactManagedAttributes<C, P>;
|
||||
? ReactManagedAttributes<U, P>
|
||||
: ReactManagedAttributes<T, P>
|
||||
: ReactManagedAttributes<C, P>;
|
||||
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface IntrinsicAttributes extends React.Attributes { }
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
interface LeaveMeAloneDtslint { foo: string; }
|
||||
// Re-enable when we move @types/react to TS 3.0 (except for the tests marked as
|
||||
// requiring TS >= 3.2)
|
||||
//
|
||||
// In the meantime, these tests can be run manually by uncommenting the code
|
||||
// below and running `dtslint --onlyTestTsNext`.
|
||||
// // Re-enable when we move @types/react to TS 3.0
|
||||
|
||||
// import * as React from 'react';
|
||||
// import * as PropTypes from 'prop-types';
|
||||
|
||||
// interface Props {
|
||||
// bool?: boolean | null;
|
||||
// bool?: boolean;
|
||||
// fnc: () => any;
|
||||
// node?: React.ReactNode;
|
||||
// num?: number | null;
|
||||
// num?: number;
|
||||
// reqNode: NonNullable<React.ReactNode>;
|
||||
// str: string;
|
||||
// }
|
||||
@@ -22,12 +18,14 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
// fnc: PropTypes.func.isRequired,
|
||||
// node: PropTypes.node,
|
||||
// num: PropTypes.number,
|
||||
// reqNode: PropTypes.node.isRequired,
|
||||
// str: PropTypes.string.isRequired,
|
||||
// extraStr: PropTypes.string.isRequired,
|
||||
// extraNum: PropTypes.number
|
||||
// };
|
||||
|
||||
// const defaultProps = {
|
||||
// fnc: (() => 'abc') as () => any,
|
||||
// extraBool: false,
|
||||
// reqNode: 'text_node' as NonNullable<React.ReactNode>
|
||||
// };
|
||||
|
||||
@@ -38,12 +36,39 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
|
||||
// const annotatedPropTypesAndDefaultPropsTests = [
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypesAndDefaultProps />, // str is required
|
||||
// <AnnotatedPropTypesAndDefaultProps str='abc' />,
|
||||
// <AnnotatedPropTypesAndDefaultProps />, // str and extraStr are required
|
||||
// <AnnotatedPropTypesAndDefaultProps extraStr='abc' str='abc' />,
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypesAndDefaultProps num='abc' />, // num type mismatch
|
||||
// <AnnotatedPropTypesAndDefaultProps
|
||||
// bool={true}
|
||||
// extraBool={true}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<span />}
|
||||
// num={0}
|
||||
// reqNode={<span />}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class UnannotatedPropTypesAndDefaultProps extends React.Component {
|
||||
// static propTypes = propTypes;
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
|
||||
// const unannotatedPropTypesAndDefaultPropsTests = [
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypesAndDefaultProps />, // stra and extraStr are required
|
||||
// <UnannotatedPropTypesAndDefaultProps extraStr='abc' str='abc' />,
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypesAndDefaultProps extraBool={0} />, // extraBool type mismatch
|
||||
// <UnannotatedPropTypesAndDefaultProps
|
||||
// bool={true}
|
||||
// extraBool={true}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<span />}
|
||||
// num={0}
|
||||
@@ -58,14 +83,16 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
|
||||
// const annotatedPropTypesTests = [
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypes />, // str, reqNode and fnc are required
|
||||
// <AnnotatedPropTypes fnc={console.log} str='abc' reqNode={<span />} />,
|
||||
// <AnnotatedPropTypes />, // str, extraStr, reqNode and fnc are required
|
||||
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} />,
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypes fnc={console.log} str='abc' reqNode={<span />} extraBool={false} />, // extraBool doesn't exist
|
||||
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} extraBool={false} />, // extraBool doesn't exist
|
||||
// // $ExpectError
|
||||
// <AnnotatedPropTypes fnc={console.log} str='abc' reqNode={<span />} num='abc' />, // num type mismatch
|
||||
// <AnnotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} num='abc' />, // num type mismatch
|
||||
// <AnnotatedPropTypes
|
||||
// bool={false}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<React.Fragment />}
|
||||
// num={0}
|
||||
@@ -74,6 +101,29 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class UnannotatedPropTypes extends React.Component {
|
||||
// static propTypes = propTypes;
|
||||
// }
|
||||
|
||||
// const unannotatedPropTypesTests = [
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypes />, // str, extraStr and fnc are required
|
||||
// <UnannotatedPropTypes fnc={console.log} extraStr='abc' str='abc' />,
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} />, // reqNode doesn't exist
|
||||
// // $ExpectError
|
||||
// <UnannotatedPropTypes fnc={console.log} extraStr='abc' str='abc' reqNode={<span />} num='abc' />, // num type mismatch
|
||||
// <UnannotatedPropTypes
|
||||
// bool={false}
|
||||
// extraNum={0}
|
||||
// extraStr='abc'
|
||||
// fnc={console.log}
|
||||
// node={<React.Fragment />}
|
||||
// num={0}
|
||||
// str='abc'
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class AnnotatedDefaultProps extends React.Component<Props> {
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
@@ -87,6 +137,7 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
// <AnnotatedDefaultProps str={() => { }} />, // str type mismatch
|
||||
// <AnnotatedDefaultProps
|
||||
// bool={true}
|
||||
// extraBool={false}
|
||||
// fnc={console.log}
|
||||
// node={null}
|
||||
// num={0}
|
||||
@@ -95,15 +146,31 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class UnannotatedDefaultProps extends React.Component {
|
||||
// static defaultProps = defaultProps;
|
||||
// }
|
||||
|
||||
// const unannotatedDefaultPropsTests = [
|
||||
// <UnannotatedDefaultProps />,
|
||||
// <UnannotatedDefaultProps
|
||||
// extraBool={true}
|
||||
// fnc={console.log}
|
||||
// reqNode={<span />}
|
||||
// />
|
||||
// ];
|
||||
|
||||
// class ComponentWithNoDefaultProps extends React.Component<Props> {}
|
||||
|
||||
// function FunctionalComponent(props: Props) { return <>{props.reqNode}</>; }
|
||||
// function FunctionalComponent(props: Props) { return <>{props.reqNode}</> }
|
||||
// FunctionalComponent.defaultProps = defaultProps;
|
||||
|
||||
// const functionalComponentTests = [
|
||||
// // $ExpectError
|
||||
// <FunctionalComponent />,
|
||||
// // NOTE: This test requires TypeScript >= 3.2, which honors JSX.LibraryManagedAttributes for function components.
|
||||
// // This is possibly a bug/limitation of TS
|
||||
// // Even if JSX.LibraryManagedAttributes returns the correct type, it doesn't seem to work with non-classes
|
||||
// // This also doesn't work with things typed React.SFC<P> because defaultProps will always be Partial<P>
|
||||
// // $ExpectError
|
||||
// <FunctionalComponent str='' />
|
||||
// ];
|
||||
|
||||
@@ -115,28 +182,27 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
// const memoTests = [
|
||||
// // $ExpectError
|
||||
// <MemoFunctionalComponent />,
|
||||
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
|
||||
// // $ExpectError won't work as long as FunctionalComponent doesn't work either
|
||||
// <MemoFunctionalComponent str='abc' />,
|
||||
// // $ExpectError
|
||||
// <MemoAnnotatedDefaultProps />,
|
||||
// <AnnotatedDefaultProps str='abc' />,
|
||||
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
|
||||
// // $ExpectError this doesn't work despite JSX.LibraryManagedAttributes returning the correct type
|
||||
// <MemoAnnotatedDefaultProps str='abc' />,
|
||||
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
|
||||
// // $ExpectError won't work as long as FunctionalComponent doesn't work either
|
||||
// <LazyMemoFunctionalComponent str='abc' />,
|
||||
// // $ExpectError
|
||||
// <LazyMemoAnnotatedDefaultProps />,
|
||||
// // Requires TypeScript >= 3.2; see comment re FunctionalComponent above
|
||||
// // $ExpectError this doesn't work despite JSX.LibraryManagedAttributes returning the correct type
|
||||
// <LazyMemoAnnotatedDefaultProps str='abc' />
|
||||
// ];
|
||||
|
||||
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
|
||||
// type AnnotatedDefaultPropsLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof AnnotatedDefaultProps, Props>;
|
||||
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
|
||||
// // $ExpectType AnnotatedDefaultPropsLibraryManagedAttributes
|
||||
// type FunctionalComponentLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof FunctionalComponent, Props>;
|
||||
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
|
||||
// // $ExpectType FunctionalComponentLibraryManagedAttributes
|
||||
// type MemoFunctionalComponentLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof MemoFunctionalComponent, Props>;
|
||||
// // $ExpectType Pick<Props, "bool" | "node" | "num" | "str"> & Partial<Pick<Props, "fnc" | "reqNode">>
|
||||
// // $ExpectType FunctionalComponentLibraryManagedAttributes
|
||||
// type LazyMemoFunctionalComponentLibraryManagedAttributes = JSX.LibraryManagedAttributes<typeof LazyMemoFunctionalComponent, Props>;
|
||||
|
||||
// const ForwardRef = React.forwardRef((props: Props, ref: React.Ref<ComponentWithNoDefaultProps>) => (
|
||||
@@ -152,97 +218,7 @@ interface LeaveMeAloneDtslint { foo: string; }
|
||||
// reqNode={<span />}
|
||||
// str=''
|
||||
// />,
|
||||
// // the type of ForwardRef.defaultProps stays Partial<P> anyway even if assigned
|
||||
// // $ExpectError
|
||||
// // same bug as MemoFunctionalComponent and React.SFC-typed things
|
||||
// // $ExpectError the type of ForwardRef.defaultProps stays Partial<P> anyway even if assigned
|
||||
// <ForwardRef str='abc' />
|
||||
// ];
|
||||
|
||||
// const wrongDefaultProps = {
|
||||
// fnc: 42
|
||||
// };
|
||||
// class WrongDefaultPropsComponent extends React.Component<Props> {
|
||||
// static defaultProps = wrongDefaultProps;
|
||||
// }
|
||||
// const wrongDefaultPropsComponentTests = [
|
||||
// // $ExpectError
|
||||
// <WrongDefaultPropsComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
// // $ExpectError
|
||||
// const investigateWrongDefaultPropsComponent: React.ComponentType<Props> = WrongDefaultPropsComponent;
|
||||
|
||||
// const excessDefaultProps = {
|
||||
// another: 43
|
||||
// };
|
||||
// class ExcessDefaultPropsComponent extends React.Component<Props> {
|
||||
// static defaultProps = excessDefaultProps;
|
||||
// }
|
||||
// const excessDefaultPropsComponentTests = [
|
||||
// // $ExpectError
|
||||
// <ExcessDefaultPropsComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
// // $ExpectError
|
||||
// const investigateExcessDefaultPropsComponent: React.ComponentType<Props> = ExcessDefaultPropsComponent;
|
||||
|
||||
// const wrongPropTypes = {
|
||||
// bool: PropTypes.bool,
|
||||
// fnc: PropTypes.number.isRequired,
|
||||
// node: PropTypes.node,
|
||||
// num: PropTypes.number,
|
||||
// reqNode: PropTypes.node.isRequired,
|
||||
// str: PropTypes.string.isRequired,
|
||||
// };
|
||||
// class WrongPropTypesComponent extends React.Component<Props> {
|
||||
// static propTypes = wrongPropTypes;
|
||||
// }
|
||||
// const wrongPropTypesComponentTests = [
|
||||
// // $ExpectError
|
||||
// <WrongPropTypesComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
|
||||
// const incompletePropTypes = {
|
||||
// bool: PropTypes.bool,
|
||||
// node: PropTypes.node,
|
||||
// num: PropTypes.number,
|
||||
// reqNode: PropTypes.node.isRequired,
|
||||
// str: PropTypes.string.isRequired,
|
||||
// };
|
||||
// class IncompletePropTypesComponent extends React.Component<Props> {
|
||||
// static propTypes = incompletePropTypes;
|
||||
// }
|
||||
// const incompletePropTypesComponentTests = [
|
||||
// // $ExpectError
|
||||
// <IncompletePropTypesComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
|
||||
// const excessPropTypes = {
|
||||
// another: PropTypes.number.isRequired,
|
||||
// bool: PropTypes.bool,
|
||||
// fnc: PropTypes.func.isRequired,
|
||||
// node: PropTypes.node,
|
||||
// num: PropTypes.number,
|
||||
// reqNode: PropTypes.node.isRequired,
|
||||
// str: PropTypes.string.isRequired,
|
||||
// };
|
||||
// class ExcessPropTypesComponent extends React.Component<Props> {
|
||||
// static propTypes = excessPropTypes;
|
||||
// }
|
||||
// const ExcessPropTypesComponentTests = [
|
||||
// // $ExpectError
|
||||
// <ExcessPropTypesComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
|
||||
// class WrongDefaultPropsSuppressedComponent extends React.Component<Props> {
|
||||
// static defaultProps = wrongDefaultProps;
|
||||
// static bypassDefaultPropsTypecheck = true;
|
||||
// }
|
||||
// const wrongDefaultPropsSuppressedComponentTests = [
|
||||
// <WrongDefaultPropsSuppressedComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
|
||||
// class WrongPropTypesSuppressedComponent extends React.Component<Props> {
|
||||
// static propTypes = wrongPropTypes;
|
||||
// static bypassPropTypesTypecheck = true;
|
||||
// }
|
||||
// const wrongPropTypesSuppressedComponentTests = [
|
||||
// <WrongPropTypesSuppressedComponent fnc={() => undefined} reqNode="text" str="str" />
|
||||
// ];
|
||||
|
||||
Vendored
+4
@@ -34,6 +34,10 @@ export interface CommonProps {
|
||||
px?: ResponsiveProp;
|
||||
py?: ResponsiveProp;
|
||||
theme?: any;
|
||||
// this is actually more powerful than the plugin because of some limitations of the transform
|
||||
/**
|
||||
* This works even without babel-plugin-styled-components.
|
||||
*/
|
||||
css?: Interpolation<any>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import * as React from "react";
|
||||
import { Flex, Box } from "@rebass/grid";
|
||||
import { css } from "styled-components";
|
||||
|
||||
const Layout = () => (
|
||||
<Flex m={4}>
|
||||
<Box px={3} py={2} />
|
||||
</Flex>
|
||||
);
|
||||
|
||||
const cssTest = <Flex css='background: transparent;'><Box css={css`${{color: 'inherit'}}`}/></Flex>;
|
||||
|
||||
Vendored
+147
-179
@@ -1,185 +1,153 @@
|
||||
// Type definitions for SkyWay
|
||||
// Project: http://nttcom.github.io/skyway/
|
||||
// Type definitions for SkyWay@1.1.17
|
||||
// Project: https://github.com/skyway/skyway-js-sdk
|
||||
// Definitions by: Toshiya Nakakura <https://github.com/nakakura>
|
||||
// Atsushi Izumihara <https://github.com/izmhr>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
/// <reference types="webrtc" />
|
||||
|
||||
declare namespace PeerJs{
|
||||
interface PeerJSOption{
|
||||
key?: string;
|
||||
host?: string;
|
||||
port?: number;
|
||||
path?: string;
|
||||
secure?: boolean;
|
||||
turn?: boolean;
|
||||
config?: RTCPeerConnectionConfig;
|
||||
debug?: number;
|
||||
}
|
||||
|
||||
interface PeerConnectOption{
|
||||
label?: string;
|
||||
metadata?: any;
|
||||
serialization?: string;
|
||||
reliable?: boolean;
|
||||
}
|
||||
|
||||
interface DataConnection{
|
||||
send(data: any): void;
|
||||
close(): void;
|
||||
on(event: string, cb: ()=>void): void;
|
||||
on(event: 'data', cb: (data: any)=>void): void;
|
||||
on(event: 'open', cb: ()=>void): void;
|
||||
on(event: 'close', cb: ()=>void): void;
|
||||
on(event: 'error', cb: (err: any)=>void): void;
|
||||
off(event: string, fn: Function, once?: boolean): void;
|
||||
bufferSize: number;
|
||||
dataChannel: RTCDataChannel;
|
||||
label: string;
|
||||
metadata: any;
|
||||
open: boolean;
|
||||
peerConnection: any;
|
||||
peer: string;
|
||||
reliable: boolean;
|
||||
serialization: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface MediaConnection{
|
||||
answer(stream?: any): void;
|
||||
close(): void;
|
||||
on(event: string, cb: ()=>void): void;
|
||||
on(event: 'stream', cb: (stream: any)=>void): void;
|
||||
on(event: 'close', cb: ()=>void): void;
|
||||
on(event: 'error', cb: (err: any)=>void): void;
|
||||
off(event: string, fn: Function, once?: boolean): void;
|
||||
open: boolean;
|
||||
metadata: any;
|
||||
peer: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface utilSupportsObj {
|
||||
audioVideo: boolean;
|
||||
data: boolean;
|
||||
binary: boolean;
|
||||
reliable: boolean;
|
||||
}
|
||||
|
||||
interface util{
|
||||
browser: string;
|
||||
supports: utilSupportsObj;
|
||||
}
|
||||
|
||||
export interface Peer{
|
||||
/**
|
||||
*
|
||||
* @param id The brokering ID of the remote peer (their peer.id).
|
||||
* @param options for specifying details about Peer Connection
|
||||
*/
|
||||
connect(id: string, options?: PeerJs.PeerConnectOption): PeerJs.DataConnection;
|
||||
/**
|
||||
* Connects to the remote peer specified by id and returns a data connection.
|
||||
* @param id The brokering ID of the remote peer (their peer.id).
|
||||
* @param stream The caller's media stream
|
||||
*/
|
||||
call(id: string, stream: any): PeerJs.MediaConnection;
|
||||
/**
|
||||
* Calls the remote peer specified by id and returns a media connection.
|
||||
* @param event Event name
|
||||
* @param cb Callback Function
|
||||
*/
|
||||
on(event: string, cb: ()=>void): void;
|
||||
/**
|
||||
* Emitted when a connection to the PeerServer is established.
|
||||
* @param event Event name
|
||||
* @param cb id is the brokering ID of the peer
|
||||
*/
|
||||
on(event: 'open', cb: (id: string)=>void): void;
|
||||
/**
|
||||
* Emitted when a new data connection is established from a remote peer.
|
||||
* @param event Event name
|
||||
* @param cb Callback Function
|
||||
*/
|
||||
on(event: 'connection', cb: (dataConnection: PeerJs.DataConnection)=>void): void;
|
||||
/**
|
||||
* Emitted when a remote peer attempts to call you.
|
||||
* @param event Event name
|
||||
* @param cb Callback Function
|
||||
*/
|
||||
on(event: 'call', cb: (mediaConnection: PeerJs.MediaConnection)=>void): void;
|
||||
/**
|
||||
* Emitted when the peer is destroyed and can no longer accept or create any new connections.
|
||||
* @param event Event name
|
||||
* @param cb Callback Function
|
||||
*/
|
||||
on(event: 'close', cb: ()=>void): void;
|
||||
/**
|
||||
* Emitted when the peer is disconnected from the signalling server
|
||||
* @param event Event name
|
||||
* @param cb Callback Function
|
||||
*/
|
||||
on(event: 'disconnected', cb: ()=>void): void;
|
||||
/**
|
||||
* Errors on the peer are almost always fatal and will destroy the peer.
|
||||
* @param event Event name
|
||||
* @param cb Callback Function
|
||||
*/
|
||||
on(event: 'error', cb: (err: any)=>void): void;
|
||||
/**
|
||||
* Remove event listeners.(EventEmitter3)
|
||||
* @param {String} event The event we want to remove.
|
||||
* @param {Function} fn The listener that we need to find.
|
||||
* @param {Boolean} once Only remove once listeners.
|
||||
*/
|
||||
off(event: string, fn: Function, once?: boolean): void;
|
||||
/**
|
||||
* Close the connection to the server, leaving all existing data and media connections intact.
|
||||
*/
|
||||
disconnect(): void;
|
||||
/**
|
||||
* Close the connection to the server and terminate all existing connections.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Get a list of available peer IDs
|
||||
* @param callback
|
||||
*/
|
||||
listAllPeers(callback: (peerIds: Array<string>)=>void): void;
|
||||
|
||||
/**
|
||||
* The brokering ID of this peer
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* A hash of all connections associated with this peer, keyed by the remote peer's ID.
|
||||
*/
|
||||
connections: any;
|
||||
/**
|
||||
* false if there is an active connection to the PeerServer.
|
||||
*/
|
||||
disconnected: boolean;
|
||||
/**
|
||||
* true if this peer and all of its connections can no longer be used.
|
||||
*/
|
||||
destroyed: boolean;
|
||||
}
|
||||
interface Options {
|
||||
key: string;
|
||||
debug?: number;
|
||||
turn?: boolean;
|
||||
credential?: Credential;
|
||||
config?: RTCConfiguration;
|
||||
}
|
||||
|
||||
declare var Peer: {
|
||||
prototype: RTCIceServer;
|
||||
/**
|
||||
* A peer can connect to other peers and listen for connections.
|
||||
* @param id Other peers can connect to this peer using the provided ID.
|
||||
* If no ID is given, one will be generated by the brokering server.
|
||||
* @param options for specifying details about PeerServer
|
||||
*/
|
||||
new (id: string, options?: PeerJs.PeerJSOption): PeerJs.Peer;
|
||||
interface Credential {
|
||||
timestamp?: number;
|
||||
ttl?: number;
|
||||
authToken?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A peer can connect to other peers and listen for connections.
|
||||
* @param options for specifying details about PeerServer
|
||||
*/
|
||||
new (options: PeerJs.PeerJSOption): PeerJs.Peer;
|
||||
};
|
||||
interface CallOptions {
|
||||
metadata?: any;
|
||||
videoBandWidth?: number;
|
||||
audioBandwidth?: number;
|
||||
videoCodec?: string;
|
||||
audioCodec?: string;
|
||||
videoReceiveEnabled?: boolean;
|
||||
audioReceiveEnabled?: boolean;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
interface ConnectOptions {
|
||||
metadata?: any;
|
||||
serialization?: string;
|
||||
dcInit?: RTCDataChannelInit;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
interface RoomOptions {
|
||||
mode?: string;
|
||||
stream?: MediaStream;
|
||||
videoBandwidth?: number;
|
||||
audioBandwidth?: number;
|
||||
videoCodec?: string;
|
||||
audioCodec?: string;
|
||||
videoReceiveEnabled?: boolean;
|
||||
audioReceiveEnabled?: boolean;
|
||||
}
|
||||
|
||||
interface AnswerOptions {
|
||||
videoBandwidth?: number;
|
||||
audioBandwidth?: number;
|
||||
videoCodec?: string;
|
||||
audioCodec?: string;
|
||||
}
|
||||
|
||||
declare class Peer {
|
||||
constructor(id: string, options: Options);
|
||||
constructor(options: Options);
|
||||
|
||||
connections: any;
|
||||
id: string;
|
||||
open: boolean;
|
||||
rooms: any;
|
||||
|
||||
call(peerId: string, stream?: MediaStream, options?: CallOptions): MediaConnection | undefined;
|
||||
connect(peerId: string, options?: ConnectOptions): DataConnection | undefined;
|
||||
destroy(): undefined;
|
||||
disconnect(): undefined;
|
||||
joinRoom(roomName: string, roomOptions?: RoomOptions): SFURoom | MeshRoom | undefined | null;
|
||||
listAllPeers(cb: (peerIds: Array<string>) => void): void;
|
||||
updateCredential(newCredential: Credential): undefined;
|
||||
|
||||
on(event: string, cb: (ret: any) => void): void;
|
||||
on(event: 'open', cb: (id: string) => void): void;
|
||||
on(event: 'call', cb: (call: MediaConnection) => void): void;
|
||||
on(event: 'close', cb: () => void): void;
|
||||
on(event: 'connection', cb: (connection: DataConnection) => void): void;
|
||||
on(event: 'disconnected', cb: (id: string) => void): void;
|
||||
on(event: 'error', cb: (err: any) => void): void;
|
||||
}
|
||||
|
||||
declare class MediaConnection {
|
||||
metadata: any;
|
||||
open: boolean;
|
||||
remoteId: string;
|
||||
peer: string;
|
||||
|
||||
answer(stream: MediaStream, options?: AnswerOptions): undefined;
|
||||
close(): void | undefined;
|
||||
replaceStream(stream: MediaStream): undefined;
|
||||
|
||||
on(event: string, cb: () => void): void;
|
||||
on(event: 'stream', cb: (stream: MediaStream) => void): void;
|
||||
on(event: 'close', cb: () => void): void;
|
||||
on(event: 'removeStream', cb: (reamoteStream: MediaStream) => void): void;
|
||||
}
|
||||
|
||||
declare class DataConnection {
|
||||
metadata: any;
|
||||
open: boolean;
|
||||
remoteId: string;
|
||||
peer: string;
|
||||
|
||||
send(data: any): void;
|
||||
close(): void | undefined;
|
||||
|
||||
on(event: string, cb: () => void): void;
|
||||
on(event: 'data', cb: (data: any) => void): void;
|
||||
on(event: 'close', cb: () => void): void;
|
||||
}
|
||||
|
||||
interface DataObject {
|
||||
src: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
declare class MeshRoom {
|
||||
close(): undefined;
|
||||
getLog(): undefined;
|
||||
replaceStream(stream: MediaSource): undefined;
|
||||
send(data: any): undefined;
|
||||
|
||||
on(event: string, cb: () => void): void;
|
||||
on(event: 'open', cb: () => void): void;
|
||||
on(event: 'peerJoin', cb: (peerId: string) => void): void;
|
||||
on(event: 'peerLeave', cb: (peerId: string) => void): void;
|
||||
on(event: 'log', cb: (logs: Array<string>) => void): void;
|
||||
once(event: 'log', cb: (logs: Array<string>) => void): void;
|
||||
on(event: 'stream', cb: (stream: MediaStream) => void): void;
|
||||
on(event: 'data', cb: (object: DataObject) => void): void;
|
||||
on(event: 'close', cb: () => void): void;
|
||||
on(event: 'removeStream', cb: (stream: MediaStream) => void): void;
|
||||
}
|
||||
|
||||
declare class SFURoom {
|
||||
close(): undefined;
|
||||
getLog(): undefined;
|
||||
replaceStream(stream: MediaSource): undefined;
|
||||
send(data: any): undefined;
|
||||
|
||||
on(event: string, cb: () => void): void;
|
||||
on(event: 'open', cb: () => void): void;
|
||||
on(event: 'peerJoin', cb: (peerId: string) => void): void;
|
||||
on(event: 'peerLeave', cb: (peerId: string) => void): void;
|
||||
on(event: 'log', cb: (logs: Array<string>) => void): void;
|
||||
once(event: 'log', cb: (logs: Array<string>) => void): void;
|
||||
on(event: 'stream', cb: (stream: MediaStream) => void): void;
|
||||
on(event: 'data', cb: (object: DataObject) => void): void;
|
||||
on(event: 'close', cb: () => void): void;
|
||||
on(event: 'removeStream', cb: (stream: MediaStream) => void): void;
|
||||
}
|
||||
|
||||
@@ -1,44 +1,37 @@
|
||||
var peerByOption: PeerJs.Peer = new Peer({
|
||||
const peerByOption: Peer = new Peer({
|
||||
key: 'peerKey',
|
||||
debug: 3,
|
||||
debug: 3
|
||||
});
|
||||
|
||||
peerByOption.listAllPeers(function(items){
|
||||
for(var i in items){
|
||||
console.log(decodeURI(items[i]));
|
||||
peerByOption.listAllPeers((items) => {
|
||||
for (let item in items) {
|
||||
console.log(decodeURI(items[item]));
|
||||
}
|
||||
});
|
||||
|
||||
var peerById: PeerJs.Peer = new Peer("peerid");
|
||||
const peerByIdAndOption: Peer = new Peer('peerid', {
|
||||
key: 'peerKey',
|
||||
debug: 3
|
||||
});
|
||||
|
||||
var peerByIdAndOption: PeerJs.Peer = new Peer(
|
||||
"peerId",
|
||||
{
|
||||
key: 'peerKey',
|
||||
debug: 3,
|
||||
});
|
||||
|
||||
var id = peerByOption.id;
|
||||
var connections = peerByOption.connections;
|
||||
var flag = peerByOption.disconnected;
|
||||
flag = peerByOption.destroyed;
|
||||
let id = peerByOption.id;
|
||||
let connections = peerByOption.connections;
|
||||
|
||||
peerByOption.disconnect();
|
||||
peerByOption.destroy();
|
||||
|
||||
var connection = peerById.connect("id", {
|
||||
let connection = peerByOption.connect("id", {
|
||||
label: 'chat',
|
||||
serialization: 'none',
|
||||
metadata: {message: 'hi i want to chat with you!'}
|
||||
metadata: { message: 'hi i want to chat with you!' }
|
||||
});
|
||||
|
||||
var call = peerById.call('callto-id', (<any>window).localStream);
|
||||
let call = peerByOption.call('callto-id', (window as any).localStream);
|
||||
|
||||
var openHandler=()=> console.log("open");
|
||||
peerById.on("open", openHandler);
|
||||
peerById.on("connection", (c)=> console.log("connection"));
|
||||
peerById.on("call", (media)=> console.log("call"));
|
||||
peerById.on("close", ()=> console.log("close"));
|
||||
peerById.on("disconnected", ()=> console.log("disconnected"));
|
||||
peerById.on("error", (err)=> console.log(err));
|
||||
peerById.off("open", openHandler);
|
||||
let openHandler = () => console.log("open");
|
||||
peerByOption.on("open", openHandler);
|
||||
peerByOption.on("connection", (c) => console.log("connection"));
|
||||
peerByOption.on("call", (media) => console.log("call"));
|
||||
peerByOption.on("close", () => console.log("close"));
|
||||
peerByOption.on("disconnected", () => console.log("disconnected"));
|
||||
peerByOption.on("error", (err) => console.log(err));
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import {} from "react";
|
||||
import { CSSProp } from ".";
|
||||
|
||||
declare module "react" {
|
||||
interface Attributes {
|
||||
// NOTE: unlike the plain javascript version, it is not possible to get access
|
||||
// to the element's own attributes inside function interpolations.
|
||||
// Only theme will be accessible, and only with the DefaultTheme due to the global
|
||||
// nature of this declaration.
|
||||
// If you are writing this inline you already have access to all the attributes anyway,
|
||||
// no need for the extra indirection.
|
||||
/**
|
||||
* If present, this React element will be converted by
|
||||
* `babel-plugin-styled-components` into a styled component
|
||||
* with the given css as its styles.
|
||||
*/
|
||||
css?: CSSProp;
|
||||
}
|
||||
}
|
||||
Vendored
+31
@@ -440,4 +440,35 @@ export class StyleSheetManager extends React.Component<
|
||||
StyleSheetManagerProps
|
||||
> {}
|
||||
|
||||
/**
|
||||
* The CSS prop is not declared by default in the types as it would cause 'css' to be present
|
||||
* on the types of anything that uses styled-components indirectly, even if they do not use the
|
||||
* babel plugin.
|
||||
*
|
||||
* You can load a default declaration by using writing this special import from
|
||||
* a typescript file. This module does not exist in reality, which is why the {} is important:
|
||||
*
|
||||
* ```ts
|
||||
* import {} from 'styled-components/cssprop'
|
||||
* ```
|
||||
*
|
||||
* Or you can declare your own module augmentation, which allows you to specify the type of Theme:
|
||||
*
|
||||
* ```ts
|
||||
* import { CSSProp } from 'styled-components'
|
||||
*
|
||||
* interface MyTheme {}
|
||||
*
|
||||
* declare module 'react' {
|
||||
* interface Attributes {
|
||||
* css?: CSSProp<MyTheme>
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
// ONLY string literals and inline invocations of css`` are supported, anything else crashes the plugin
|
||||
export type CSSProp<T = AnyIfEmpty<DefaultTheme>> =
|
||||
string |
|
||||
FlattenInterpolation<ThemeProps<T>>;
|
||||
|
||||
export default styled;
|
||||
|
||||
Vendored
+5
@@ -1,2 +1,7 @@
|
||||
export { default } from '.';
|
||||
export * from '.';
|
||||
|
||||
/**
|
||||
* Recommended: also `import {} from 'styled-components/cssprop'`,
|
||||
* or augment react's `Attribute` interface with your own version.
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@ import styled, {
|
||||
StyledComponent,
|
||||
ThemedStyledComponentsModule
|
||||
} from "styled-components";
|
||||
import {} from "styled-components/cssprop";
|
||||
|
||||
/**
|
||||
* general usage
|
||||
@@ -187,7 +188,6 @@ const styledButton = styled.button`
|
||||
const name = "hey";
|
||||
|
||||
const ThemedMyButton = withTheme(MyButton);
|
||||
|
||||
<ThemedMyButton name={name} />;
|
||||
|
||||
/**
|
||||
@@ -305,7 +305,6 @@ const ObjectStylesBox = styled.div`
|
||||
fontSize: 2
|
||||
}};
|
||||
`;
|
||||
|
||||
<ObjectStylesBox size="big" />;
|
||||
|
||||
/**
|
||||
@@ -337,7 +336,6 @@ const AttrsWithOnlyNewProps = styled.h2.attrs({ as: "h1" })`
|
||||
`;
|
||||
|
||||
const AttrsInputExtra = styled(AttrsInput).attrs({ autoComplete: "off" })``;
|
||||
|
||||
<AttrsInputExtra />;
|
||||
|
||||
/**
|
||||
@@ -434,10 +432,8 @@ const Component = (props: WithThemeProps) => (
|
||||
);
|
||||
|
||||
const ComponentWithTheme = withTheme(Component);
|
||||
|
||||
<ComponentWithTheme text={"hi"} />; // ok
|
||||
<ComponentWithTheme text={"hi"} theme={{ color: "red" }} />; // ok
|
||||
|
||||
<ThemeConsumer>{theme => <Component text="hi" theme={theme} />}</ThemeConsumer>;
|
||||
|
||||
/**
|
||||
@@ -625,7 +621,6 @@ const divFnRef = (ref: HTMLDivElement | null) => {
|
||||
const divRef = React.createRef<HTMLDivElement>();
|
||||
|
||||
const StyledDiv = styled.div``;
|
||||
|
||||
<StyledDiv ref={divRef} />;
|
||||
<StyledDiv ref={divFnRef} />;
|
||||
<StyledDiv ref="string" />; // $ExpectError
|
||||
@@ -786,3 +781,89 @@ async function themeAugmentation() {
|
||||
</base.ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
// NOTE: this is needed for some tests inside cssProp,
|
||||
// but actually running this module augmentation will cause
|
||||
// tests elsewhere to break, and there is no way to contain it.
|
||||
// Uncomment out as needed to run tests.
|
||||
|
||||
// declare module "styled-components" {
|
||||
// interface DefaultTheme {
|
||||
// background: string;
|
||||
// }
|
||||
// }
|
||||
|
||||
function cssProp() {
|
||||
function Custom(props: React.ComponentPropsWithoutRef<"div">) {
|
||||
return <div {...props} />;
|
||||
}
|
||||
|
||||
const myCss = "background: blue;";
|
||||
|
||||
return (
|
||||
<>
|
||||
<div css="background: blue;" />
|
||||
{/*
|
||||
For some reason $ExpectError doesn't work on this expression.
|
||||
Only strings work, objects crash the plugin.
|
||||
<div css={{ background: "blue" }} />
|
||||
*/}
|
||||
<div
|
||||
// would be nice to be able to turn this into an error as it also crashes the plugin,
|
||||
// but this is how optional properties work in TypeScript...
|
||||
css={undefined}
|
||||
/>
|
||||
<div
|
||||
// css used as tagged function is fine and is correctly handled by the plugin
|
||||
css={css`
|
||||
background: blue;
|
||||
`}
|
||||
/>
|
||||
<div
|
||||
// but this crashes the plugin, even though it's valid type-wise and we can't forbid it
|
||||
css={css({ background: "blue" })}
|
||||
/>
|
||||
<div
|
||||
// this also crashes the plugin, only inline strings or css template tag work
|
||||
css={myCss}
|
||||
/>
|
||||
<div
|
||||
css={css`
|
||||
background: ${() => "blue"};
|
||||
`}
|
||||
/>
|
||||
<div
|
||||
css={css`
|
||||
background: ${props => {
|
||||
// This requires the DefaultTheme augmentation
|
||||
// // $ExpectType string
|
||||
// props.theme.background;
|
||||
return props.theme.background;
|
||||
}};
|
||||
`}
|
||||
/>
|
||||
<Custom css="background: blue;" />
|
||||
<Custom css={undefined} />
|
||||
<Custom
|
||||
css={css`
|
||||
background: blue;
|
||||
`}
|
||||
/>
|
||||
<Custom
|
||||
css={css`
|
||||
background: ${() => "blue"};
|
||||
`}
|
||||
/>
|
||||
<Custom
|
||||
css={css`
|
||||
background: ${props => {
|
||||
// This requires the DefaultTheme augmentation
|
||||
// // $ExpectType string
|
||||
// props.theme.background;
|
||||
return props.theme.background;
|
||||
}};
|
||||
`}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,20 +3,26 @@
|
||||
"baseUrl": "../",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react",
|
||||
"lib": ["es6", "dom"],
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"module": "commonjs",
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"typeRoots": ["../"],
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"macro.d.ts",
|
||||
"cssprop.d.ts",
|
||||
"test/index.tsx",
|
||||
"test/macro.tsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
Vendored
+103
-49
@@ -1,89 +1,143 @@
|
||||
// Type definitions for tabtab 0.0.4
|
||||
// Type definitions for tabtab 3.0.2
|
||||
// Project: https://github.com/mklabs/node-tabtab
|
||||
// Definitions by: Vojtěch Habarta <https://github.com/vojtechhabarta>
|
||||
// Kamontat Chantrachirathumrong <https://github.com/kamontat>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
// TypeScript Version: 2.0
|
||||
|
||||
/**
|
||||
* Main completion method, has support for installation and actual completion.
|
||||
* @param name Name of the command to complete.
|
||||
* @param cb Get called when a tab-completion command happens.
|
||||
* Install option
|
||||
*
|
||||
* @param name is a name of the cli command
|
||||
* @param completer Somethings, you want to complete another program that's where the `completer` option might come handy.
|
||||
*/
|
||||
export declare function complete(name: string, cb: CallBack): void;
|
||||
export type InstallOption = {
|
||||
name: string;
|
||||
completer: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Main completion method, has support for installation and actual completion.
|
||||
* @param name Name of the command to complete.
|
||||
* @param completer Name of the command to call on completion.
|
||||
* @param cb Get called when a tab-completion command happens.
|
||||
* Uninstall option
|
||||
*
|
||||
* @param name is a name of the cli command
|
||||
*/
|
||||
export declare function complete(name: string, completer: string, cb: CallBack): void;
|
||||
export type UninstallOption = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple helper function to know if the script is run in the context of a completion command.
|
||||
* This type represent object (Json object)
|
||||
*/
|
||||
export declare function isComplete(): boolean;
|
||||
export type Json = {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to return the list of short and long options, parsed from the usual --help output of a command (cake/rake -H, vagrant, commander -h, optimist.help(), ...).
|
||||
* Tabtab environment data that return from {@link parseEnv} method
|
||||
*
|
||||
* @param complete A Boolean indicating whether we act in "plumbing mode" or not
|
||||
* @param words The Number of words in the completed line
|
||||
* @param point A Number indicating cursor position
|
||||
* @param line The String input line
|
||||
* @param partial The String part of line preceding cursor position
|
||||
* @param last The last String word of the line
|
||||
* @param lastPartial The last word String of partial
|
||||
* @param prev The String word preceding last
|
||||
*/
|
||||
export declare function parseOut(str: string): { shorts: string[]; longs: string[] };
|
||||
|
||||
/**
|
||||
* Same purpose as parseOut, but for parsing tasks from an help command (cake/rake -T, vagrant, etc.).
|
||||
*/
|
||||
export declare function parseTasks(str: string, prefix: string, reg?: RegExp | string): string[];
|
||||
|
||||
/**
|
||||
* Helper to return completion output and log to standard output.
|
||||
* @param values Array of values to complete against.
|
||||
* @param data The data object returned by the complete callback, used mainly to filter results accordingly upon the text that is supplied by the user.
|
||||
* @param prefix A prefix to add to the completion results, useful for options to add dashes (eg. - or --).
|
||||
*/
|
||||
export declare function log(values: string[], data: Data, prefix?: string): void;
|
||||
|
||||
interface CallBack {
|
||||
(error?: Error, data?: Data, text?: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds interesting values to drive the output of the completion.
|
||||
*/
|
||||
interface Data {
|
||||
|
||||
export type TabtabEnv = {
|
||||
/**
|
||||
* full command being completed
|
||||
* A Boolean indicating whether we act in "plumbing mode" or not
|
||||
*/
|
||||
line: string;
|
||||
complete: boolean;
|
||||
|
||||
/**
|
||||
* number of words
|
||||
* The Number of words in the completed line
|
||||
*/
|
||||
words: number;
|
||||
|
||||
/**
|
||||
* cursor position
|
||||
* A Number indicating cursor position
|
||||
*/
|
||||
point: number;
|
||||
|
||||
/**
|
||||
* tabing in the middle of a word: foo bar baz bar foobarrrrrrr
|
||||
* The String input line
|
||||
*/
|
||||
line: string;
|
||||
|
||||
/**
|
||||
* The String part of line preceding cursor position
|
||||
*/
|
||||
partial: string;
|
||||
|
||||
/**
|
||||
* last word of the line
|
||||
* The last String word of the line
|
||||
*/
|
||||
last: string;
|
||||
|
||||
/**
|
||||
* last partial of the line
|
||||
* The last word String of partial
|
||||
*/
|
||||
lastPartial: string;
|
||||
|
||||
/**
|
||||
* the previous word
|
||||
* The String word preceding last
|
||||
*/
|
||||
prev: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* this is a item to show when completion enable,
|
||||
*
|
||||
* @param name usually is a subcommand name or option name
|
||||
* @param description this is a optional description of the completion
|
||||
*/
|
||||
export type CompleteItem = {
|
||||
name: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type CompleteItemOrString = string | CompleteItem;
|
||||
|
||||
/**
|
||||
* Install and enable completion on user system.
|
||||
*
|
||||
* @param option install option
|
||||
*
|
||||
*/
|
||||
export function install(option: InstallOption): Promise<void>;
|
||||
|
||||
/**
|
||||
* Uninstall and remove all completion on user system
|
||||
*
|
||||
* @param option uninstall option
|
||||
*/
|
||||
export function uninstall(option: UninstallOption): Promise<void>;
|
||||
|
||||
/**
|
||||
* Public: Main utility to extract information from command line arguments and
|
||||
* Environment variables, namely COMP args in "plumbing" mode.
|
||||
*
|
||||
* @param env environment (usually will be process.env)
|
||||
* @returns env is a object of completion environment
|
||||
*
|
||||
* @example
|
||||
* const env = tabtab.parseEnv(process.env);
|
||||
*/
|
||||
export function parseEnv(env: Json): TabtabEnv;
|
||||
|
||||
/**
|
||||
* Helper to normalize String and Objects when logging out.
|
||||
*/
|
||||
export function completionItem(item: CompleteItemOrString): CompleteItem;
|
||||
|
||||
/**
|
||||
* Main logging utility to pass completion items.
|
||||
* This is simply an helper to log to stdout with each item separated by a new
|
||||
* line.
|
||||
*
|
||||
* Bash needs in addition to filter out the args for the completion to work
|
||||
* (zsh, fish don't need this).
|
||||
*
|
||||
* @param args Strings or Objects with name and description property.
|
||||
*/
|
||||
export function log(args: string[] | CompleteItem[] | CompleteItemOrString[]): void;
|
||||
|
||||
@@ -1,30 +1,83 @@
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import tabtab = require('tabtab');
|
||||
import child_process = require('child_process');
|
||||
import string_decoder = require('string_decoder');
|
||||
import { install, log, TabtabEnv, uninstall, parseEnv } from "tabtab";
|
||||
|
||||
if (process.argv.slice(2)[0] === 'completion') {
|
||||
tabtab.complete('pkgname', function(err, data) {
|
||||
if (err || !data) return;
|
||||
if (/^--\w?/.test(data.last)) return tabtab.log(['help', 'version'], data, '--');
|
||||
if (/^-\w?/.test(data.last)) return tabtab.log(['n', 'o', 'd', 'e'], data, '-');
|
||||
tabtab.log(['list', 'of', 'commands'], data);
|
||||
const opts = require("minimist")(process.argv.slice(2), {
|
||||
string: ["foo", "bar"],
|
||||
boolean: ["help", "version", "loglevel"]
|
||||
});
|
||||
|
||||
child_process.exec('rake -H', {encoding: null}, function(err, stdout, stderr) {
|
||||
if (err) return;
|
||||
var decoder = new string_decoder.StringDecoder('utf8');
|
||||
var parsed = tabtab.parseOut(decoder.write(stdout));
|
||||
if (/^--\w?/.test(data.last)) return tabtab.log(parsed.longs, data, '--');
|
||||
if (/^-\w?/.test(data.last)) return tabtab.log(parsed.shorts, data, '-');
|
||||
const args = opts._;
|
||||
|
||||
const completion = (env: TabtabEnv) => {
|
||||
if (!env.complete) return;
|
||||
|
||||
// Write your completions there
|
||||
|
||||
if (env.prev === "foo") {
|
||||
return log(["is", "this", "the", "real", "life"]);
|
||||
}
|
||||
|
||||
if (env.prev === "bar") {
|
||||
return log(["is", "this", "just", "fantasy"]);
|
||||
}
|
||||
|
||||
if (env.prev === "--loglevel") {
|
||||
return log(["error", "warn", "info", "notice", "verbose"]);
|
||||
}
|
||||
|
||||
return log([
|
||||
"--help",
|
||||
"--version",
|
||||
"--loglevel",
|
||||
"foo",
|
||||
"bar",
|
||||
"install-completion",
|
||||
"completion",
|
||||
"someCommand:someCommand is some kind of command with a description",
|
||||
{
|
||||
name: "someOtherCommand:hey",
|
||||
description: 'You must add a description for items with ":" in them'
|
||||
},
|
||||
"anotherOne"
|
||||
]);
|
||||
};
|
||||
|
||||
const run = (): Promise<void> => {
|
||||
const cmd = args[0];
|
||||
|
||||
// Write your CLI there
|
||||
|
||||
// Here we install for the program `tabtab-test` (this file), with
|
||||
// completer being the same program. Sometimes, you want to complete
|
||||
// another program that's where the `completer` option might come handy.
|
||||
if (cmd === "install-completion") {
|
||||
return install({
|
||||
name: "tabtab-test",
|
||||
completer: "tabtab-test"
|
||||
});
|
||||
}
|
||||
|
||||
child_process.exec('cake', {encoding: null}, function(err, stdout, stderr) {
|
||||
if (err) return;
|
||||
var decoder = new string_decoder.StringDecoder('utf8');
|
||||
var tasks = tabtab.parseTasks(decoder.write(stdout), 'cake');
|
||||
tabtab.log(tasks, data);
|
||||
if (cmd === "uninstall-completion") {
|
||||
// Here we uninstall for the program `tabtab-test` (this file).
|
||||
return uninstall({
|
||||
name: "tabtab-test"
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// The completion command is added automatically by tabtab when the program
|
||||
// is completed.
|
||||
if (cmd === "completion") {
|
||||
return new Promise<void>(res => {
|
||||
const env = parseEnv(process.env);
|
||||
completion(env);
|
||||
res();
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise<void>((_, rej) => rej());
|
||||
};
|
||||
|
||||
run().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -40,7 +40,7 @@ export interface ThemeListener<C extends string> {
|
||||
callback: (theme: Theme) => void
|
||||
): SubscriptionId;
|
||||
unsubscribe(context: ContextWithTheme<C>, id: SubscriptionId): void;
|
||||
contextTypes: React.ValidationMap<ContextWithTheme<C>>;
|
||||
contextTypes: React.ValidationMap<C>;
|
||||
}
|
||||
/**
|
||||
* ThemeListener for the default channel
|
||||
|
||||
@@ -181,8 +181,8 @@
|
||||
//
|
||||
|
||||
var object = new THREE.Object3D();
|
||||
object.position.x = (<number>table[i + 3] * 140) - 1330;
|
||||
object.position.y = - (<number>table[i + 4] * 180) + 990;
|
||||
object.position.x = ((table[i + 3] as number) * 140) - 1330;
|
||||
object.position.y = - ((table[i + 4] as number) * 180) + 990;
|
||||
|
||||
targets.table.push(object);
|
||||
|
||||
@@ -354,4 +354,4 @@
|
||||
renderer.render(scene, camera);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// Type definitions for timing-safe-equal 1.0
|
||||
// Project: https://github.com/crypto-browserify/timing-safe-equal
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export = timingSafeEqual;
|
||||
|
||||
declare function timingSafeEqual(a: Buffer, b: Buffer): boolean;
|
||||
@@ -0,0 +1,5 @@
|
||||
import timingSafeEqual = require('timing-safe-equal');
|
||||
|
||||
const buffer: Buffer = new Buffer([1, 2, 3, 4, 5]);
|
||||
// $ExpectType boolean
|
||||
timingSafeEqual(buffer, buffer);
|
||||
@@ -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",
|
||||
"timing-safe-equal-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+2
@@ -11,6 +11,7 @@
|
||||
// Oleksii Kachura <https://github.com/alex-kachura>
|
||||
// dcop <https://github.com/dcop>
|
||||
// Avraham Essoudry <https://github.com/avrahamcool>
|
||||
// Dmitriy Trifonov <https://github.com/divideby>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { MomentInput, MomentFormatSpecification, Moment } from 'moment';
|
||||
@@ -244,6 +245,7 @@ export interface TimelineOptions {
|
||||
multiselectPerGroup?: boolean;
|
||||
onAdd?: TimelineOptionsItemCallbackFunction;
|
||||
onAddGroup?: TimelineOptionsGroupCallbackFunction;
|
||||
onInitialDrawComplete?: (() => void);
|
||||
onUpdate?: TimelineOptionsItemCallbackFunction;
|
||||
onMove?: TimelineOptionsItemCallbackFunction;
|
||||
onMoveGroup?: TimelineOptionsGroupCallbackFunction;
|
||||
|
||||
Vendored
+46
-38
@@ -1,55 +1,63 @@
|
||||
// Type definitions for @xmpp/jid 0.0
|
||||
// Type definitions for @xmpp/jid 0.6
|
||||
// Project: https://github.com/node-xmpp/node-xmpp/
|
||||
// Definitions by: PJakcson <https://github.com/PJakcson>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export function createJID(local: string, domain: string, resource: string): JID;
|
||||
export function equal(a: JID, b: JID): boolean;
|
||||
export function is(a: any): boolean;
|
||||
export = jid;
|
||||
|
||||
/**
|
||||
* Created by marcneumann on 17.02.17.
|
||||
*/
|
||||
export class JID {
|
||||
local: string;
|
||||
domain: string;
|
||||
resource: string;
|
||||
declare function jid(address: string): jid.JID;
|
||||
declare function jid(local: string | undefined, domain: string, resource?: string): jid.JID;
|
||||
|
||||
constructor(local: string, domain?: string, resource?: string);
|
||||
declare namespace jid {
|
||||
function jid(address: string): JID;
|
||||
function jid(local: string | undefined, domain: string, resource?: string): JID;
|
||||
|
||||
parseJID(jid: string): void;
|
||||
function createJID(local: string | undefined, domain: string, resource?: string): JID;
|
||||
function equal(a: JID, b: JID): boolean;
|
||||
function detectEscape(local?: string): boolean;
|
||||
function escapeLocal(local: string): string;
|
||||
function unescapeLocal(local: string): string;
|
||||
function parse(s: string): JID;
|
||||
|
||||
toString(unescape?: any): string;
|
||||
class JID {
|
||||
local: string;
|
||||
domain: string;
|
||||
resource: string;
|
||||
|
||||
/**
|
||||
* Convenience method to distinguish users
|
||||
*/
|
||||
bare(): JID;
|
||||
constructor(local: string | undefined, domain: string, resource?: string);
|
||||
|
||||
/**
|
||||
* Comparison function
|
||||
*/
|
||||
equals(other: JID): boolean;
|
||||
toString(unescape?: boolean): string;
|
||||
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-localpart
|
||||
*/
|
||||
setLocal(local: string, escape?: any): void;
|
||||
/**
|
||||
* Convenience method to distinguish users
|
||||
*/
|
||||
bare(): JID;
|
||||
|
||||
getLocal(unescape?: any): string;
|
||||
/**
|
||||
* Comparison function
|
||||
*/
|
||||
equals(other: JID): boolean;
|
||||
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-domain
|
||||
*/
|
||||
setDomain(value: string): void;
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-localpart
|
||||
*/
|
||||
setLocal(local: string, escape?: boolean): void;
|
||||
|
||||
getDomain(): string;
|
||||
getLocal(unescape?: boolean): string;
|
||||
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-resourcepart
|
||||
*/
|
||||
setResource(value: string): void;
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-domain
|
||||
*/
|
||||
setDomain(value: string): void;
|
||||
|
||||
getResource(): string;
|
||||
getDomain(): string;
|
||||
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-resourcepart
|
||||
*/
|
||||
setResource(value: string): void;
|
||||
|
||||
getResource(): string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,39 @@
|
||||
import { JID } from '@xmpp/jid';
|
||||
import jid = require('@xmpp/jid');
|
||||
|
||||
/*
|
||||
* All return an instance of JID.JID, the new operator is optional.
|
||||
*/
|
||||
let addr = new JID('alice@wonderland.net/rabbithole'); // OK
|
||||
addr = new JID('alice', 'wonderland.net', 'rabbithole'); // BEST; see section on escaping below
|
||||
let addr: jid.JID;
|
||||
let str: string;
|
||||
let bool: boolean;
|
||||
|
||||
addr = jid('alice@wonderland.net/rabbithole');
|
||||
addr = jid('alice', 'wonderland.net', 'rabbithole');
|
||||
|
||||
/*
|
||||
* local
|
||||
*/
|
||||
addr.local = 'alice';
|
||||
addr.local; // alice
|
||||
// same as
|
||||
str = addr.local;
|
||||
addr.setLocal('alice');
|
||||
addr.getLocal(); // alice
|
||||
addr.setLocal('alice', true);
|
||||
str = addr.getLocal();
|
||||
|
||||
/*
|
||||
* domain
|
||||
*/
|
||||
addr.domain = 'wonderland.net';
|
||||
addr.domain; // wonderland.net
|
||||
// same as
|
||||
str = addr.domain;
|
||||
addr.setDomain('wonderland.net');
|
||||
addr.getDomain(); // wonderland.net
|
||||
str = addr.getDomain();
|
||||
|
||||
/*
|
||||
* resource
|
||||
*/
|
||||
addr.resource = 'rabbithole';
|
||||
addr.resource; // rabbithole
|
||||
// same as
|
||||
str = addr.resource;
|
||||
addr.setResource('rabbithole');
|
||||
addr.getResource(); // rabbithole
|
||||
str = addr.getResource();
|
||||
|
||||
addr.toString(); // alice@wonderland.net/rabbithole
|
||||
addr.bare(); // returns a JID without resource
|
||||
str = addr.toString();
|
||||
str = addr.toString(true);
|
||||
addr = addr.bare();
|
||||
|
||||
const some_jid = new JID('is', 'a', 'test');
|
||||
addr.equals(some_jid); // returns true if the two JIDs are equal, false otherwise
|
||||
bool = addr.equals(addr);
|
||||
|
||||
bool = jid.equal(addr, addr);
|
||||
|
||||
addr = jid.createJID('my', 'homies');
|
||||
bool = jid.equal(addr, addr);
|
||||
bool = jid.detectEscape('homies');
|
||||
str = jid.escapeLocal('homies');
|
||||
str = jid.unescapeLocal('homies');
|
||||
addr = jid.parse('homies');
|
||||
|
||||
Reference in New Issue
Block a user