Merge remote-tracking branch 'upstream/master'

This commit is contained in:
卞中杰
2018-12-13 17:33:45 +08:00
370 changed files with 12957 additions and 3372 deletions
+302 -129
View File
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -169,8 +169,14 @@ If a package was never on DefinitelyTyped, it does not need to be added to `notN
#### Lint
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "dtslint/dt.json" }`. All new packages must be linted.
If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
All new packages must be linted. To lint a package, add a `tslint.json` to that package containing
```js
{
"extends": "dtslint/dt.json"
}
```
This should be the only content in a finished project's `tslint.json` file. If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
```js
{
+6
View File
@@ -642,6 +642,12 @@
"sourceRepoURL": "https://github.com/jdalrymple/node-gitlab",
"asOfVersion": "2.0.0"
},
{
"libraryName": "Google Cloud Storage",
"typingsPackageName": "google-cloud__storage",
"sourceRepoURL": "https://github.com/googleapis/nodejs-storage",
"asOfVersion": "2.3.0"
},
{
"libraryName": "graphene-pk11",
"typingsPackageName": "graphene-pk11",
+1 -1
View File
@@ -22,6 +22,6 @@
},
"devDependencies": {
"dtslint": "github:Microsoft/dtslint#production",
"types-publisher": "Microsoft/types-publisher#production"
"types-publisher": "github:Microsoft/types-publisher#production"
}
}
+10 -1
View File
@@ -136,7 +136,16 @@ export interface ChannelWrapper extends EventEmitter {
* Setup functions should, ideally, not throw errors, but if they do then the ChannelWrapper will emit an 'error' event.
* @param func
*/
addSetup(func: SetupFunc): Promise<void>;
addSetup(func: SetupFunc): Promise<void>;
/**
* Remove a setup function added with `addSetup`. If there is currently a
* connection, `teardown(channel, [cb])` will be run immediately, and the
* returned Promise will not resolve until it completes.
* @param func
* @param [tearDown]
*/
removeSetup(func: SetupFunc, tearDown?: SetupFunc): Promise<void>;
/**
* @see amqplib
+4
View File
@@ -153,6 +153,10 @@ declare module 'angular' {
defaultFontSet(name: string): IIconProvider;
}
interface IInkRippleProvider {
disableInkRipple(): void;
}
type IMedia = (media: string) => boolean;
interface ISidenavObject {
+1
View File
@@ -5,6 +5,7 @@ assert(true, "it's working");
assert.ok(true, "inner functions work as well");
assert.throws(() => {});
assert.throws(() => {}, /Regex test/);
assert.throws(() => {}, () => {}, "works wonderfully");
assert['fail'](true, true, "works like a charm");
+3 -2
View File
@@ -1,6 +1,7 @@
// Type definitions for commonjs-assert 1.4
// Project: https://github.com/browserify/commonjs-assert
// Definitions by: Nico Gallinal <https://github.com/nicoabie>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function assert(value: any, message?: string): void;
@@ -23,10 +24,10 @@ declare namespace assert {
function notStrictEqual(actual: any, expected: any, message?: string): void;
function throws(block: () => void, message?: string): void;
function throws(block: () => void, error: () => void | ((err: any) => boolean) | RegExp, message?: string): void;
function throws(block: () => void, error: (() => void) | ((err: any) => boolean) | RegExp, message?: string): void;
function doesNotThrow(block: () => void, message?: string): void;
function doesNotThrow(block: () => void, error: () => void | ((err: any) => boolean) | RegExp, message?: string): void;
function doesNotThrow(block: () => void, error: (() => void) | ((err: any) => boolean) | RegExp, message?: string): void;
function ifError(value: any): void;
@@ -0,0 +1,42 @@
import Tree from "@atlaskit/tree";
import * as React from "react";
import { render } from "react-dom";
declare const container: Element;
render(
<Tree
tree={{
rootId: 1,
items: {
1: {
id: 1,
children: []
},
"string-id": {
id: "string-id",
children: [1, "another"],
hasChildren: true,
isExpanded: false,
isChildrenLoading: false,
data: {
myVar: "this can be anything"
}
}
}
}}
renderItem={() => <div />}
onExpand={() => {}}
onCollapse={() => {}}
onDragStart={() => {}}
onDragEnd={() => {}}
offsetPerLevel={20}
isDragEnabled
isNestingEnabled
/>,
container
);
// Check that default props work too.
render(<Tree renderItem={() => <div />} />, container);
+153
View File
@@ -0,0 +1,153 @@
// Type definitions for @atlaskit/tree 4.1
// Project: https://bitbucket.org/atlassian/atlaskit-mk-2/
// Definitions by: Ben James <https://github.com/benhjames>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Component, ReactNode } from "react";
import {
DraggingStyle,
DraggableProvidedDragHandleProps,
DraggableStateSnapshot,
NotDraggingStyle
} from "react-beautiful-dnd";
export type ItemId = any;
export type Path = number[];
export interface TreeData {
rootId: ItemId;
items: { [key: string]: TreeItem; [key: number]: TreeItem };
}
export type TreeItemData = any;
export interface TreeItem {
id: ItemId;
children: ItemId[];
hasChildren?: boolean;
isExpanded?: boolean;
isChildrenLoading?: boolean;
data?: TreeItemData;
}
export interface TreeSourcePosition {
parentId: ItemId;
index: number;
}
export interface TreeDestinationPosition {
parentId: ItemId;
index?: number;
}
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
interface TreeDraggingStyle extends Omit<DraggingStyle, "transition"> {
paddingLeft: number;
transition: "none" | string;
}
type TreeDraggableStyle = NotDraggingStyle | TreeDraggingStyle;
interface TreeDraggableProps {
// Props that can be spread onto the element directly
// inline style
style?: TreeDraggableStyle;
// used for shared global styles
"data-react-beautiful-dnd-draggable": string;
}
interface TreeDraggableProvided {
draggableProps: TreeDraggableProps;
// will be null if the draggable is disabled
dragHandleProps?: DraggableProvidedDragHandleProps;
// The following props will be removed once we move to react 16
innerRef: (element?: HTMLElement) => void;
}
export interface RenderItemParams {
item: TreeItem;
depth: number;
onExpand: (itemId: ItemId) => void;
onCollapse: (itemId: ItemId) => void;
provided: TreeDraggableProvided;
snapshot: DraggableStateSnapshot;
}
interface TreeItemMutation {
id?: ItemId;
children?: ItemId[];
hasChildren?: boolean;
isExpanded?: boolean;
isChildrenLoading?: boolean;
data?: TreeItemData;
}
export function mutateTree(
tree: TreeData,
itemId: ItemId,
mutation: TreeItemMutation
): TreeData;
export function moveItemOnTree(
tree: TreeData,
from: TreeSourcePosition,
to: TreeDestinationPosition
): TreeData;
interface TreeProps {
/** The tree data structure. */
tree: TreeData;
/** Function that will be called when a parent item needs to be expanded. */
onExpand: (itemId: ItemId, path: Path) => void;
/** Function that will be called when a parent item needs to be collapsed. */
onCollapse: (itemId: ItemId, path: Path) => void;
/** Function that will be called when the user starts dragging. */
onDragStart: (itemId: ItemId) => void;
/** Function that will be called when the user finishes dragging. */
onDragEnd: (
sourcePosition: TreeSourcePosition,
destinationPosition: TreeDestinationPosition | undefined
) => void;
/** Function that will be called to render a single item. */
renderItem: (itemProps: RenderItemParams) => ReactNode;
/** Number of pixel is used to scaffold the tree by the consumer. */
offsetPerLevel: number;
/** Boolean to turn on drag&drop re-ordering on the tree */
isDragEnabled: boolean;
/** Boolean to turn on hovering while dragging */
isNestingEnabled: boolean;
}
interface FlattenedItem {
item: TreeItem;
path: Path;
}
type FlattenedTree = FlattenedItem[];
interface TreeState {
/** The flattened tree data structure transformed from props.tree */
flattenedTree: FlattenedTree;
// Id of the currently dragged item
draggedItemId: ItemId;
}
declare class Tree extends Component<TreeProps, TreeState> {
static defaultProps: {
tree: { children: [] };
onExpand: () => void;
onCollapse: () => void;
onDragStart: () => void;
onDragEnd: () => void;
renderItem: () => void;
offsetPerLevel: 35;
isDragEnabled: false;
isNestingEnabled: false;
};
}
export default Tree;
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"paths": {
"@atlaskit/tree": ["atlaskit__tree"]
}
},
"files": ["index.d.ts", "atlaskit__tree-tests.tsx"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+6
View File
@@ -0,0 +1,6 @@
import binVersion = require('bin-version');
// $ExpectType Promise<string>
binVersion('curl');
// $ExpectType Promise<string>
binVersion('openssl', { args: ['version'] });
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for bin-version 3.0
// Project: https://github.com/sindresorhus/bin-version#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = binVersion;
declare function binVersion(binary: string, options?: binVersion.Options): Promise<string>;
declare namespace binVersion {
interface Options {
args?: string[];
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bin-version-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -93,3 +93,28 @@ const parser5 = new Parser()
length: '4',
formatter: (arr) => { }
});
const parser6 = new Parser()
.nest("nested", {
type: new Parser()
.array("points", {
type: new Parser()
.uint8("x")
.uint8("y"),
length: 2
})
})
.choice("optional", {
tag: "nested.points[0].x",
choices: {
1: new Parser()
.uint8("number")
}
});
const result = parser6.parse(Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]));
// See the inferred static types on the IntelliSense.
result.nested.points[0].x;
result.nested.points[1].y;
result.optional.number;
+108 -79
View File
@@ -1,88 +1,117 @@
// Type definitions for binary-parser 1.3
// Project: https://github.com/keichi/binary-parser
// Definitions by: Benjamin Riggs <https://github.com/riggs>, Dolan Miu <https://github.com/dolanmiu>
// Definitions by: Benjamin Riggs <https://github.com/riggs>,
// Dolan Miu <https://github.com/dolanmiu>,
// Yu Shimura <https://github.com/yuhr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/// <reference types="node" />
export interface Parser {
parse(buffer: Buffer, callback?: (err?: Error, result?: any) => void): Parser.Parsed;
export interface Parser<O extends object | undefined = undefined> {
parse(buffer: Buffer, callback?: (err?: Error, result?: any) => void): Parser.Parsed<O>;
create(constructorFunction: ObjectConstructor): Parser;
int8(name: string, options?: Parser.Options): Parser;
uint8(name: string, options?: Parser.Options): Parser;
int8<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint8<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int16(name: string, options?: Parser.Options): Parser;
uint16(name: string, options?: Parser.Options): Parser;
int16le(name: string, options?: Parser.Options): Parser;
int16be(name: string, options?: Parser.Options): Parser;
uint16le(name: string, options?: Parser.Options): Parser;
uint16be(name: string, options?: Parser.Options): Parser;
int16<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint16<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int16le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int16be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint16le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint16be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int32(name: string, options?: Parser.Options): Parser;
uint32(name: string, options?: Parser.Options): Parser;
int32le(name: string, options?: Parser.Options): Parser;
int32be(name: string, options?: Parser.Options): Parser;
uint32le(name: string, options?: Parser.Options): Parser;
uint32be(name: string, options?: Parser.Options): Parser;
int32<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint32<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int32le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int32be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint32le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint32be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit1(name: string, options?: Parser.Options): Parser;
bit2(name: string, options?: Parser.Options): Parser;
bit3(name: string, options?: Parser.Options): Parser;
bit4(name: string, options?: Parser.Options): Parser;
bit5(name: string, options?: Parser.Options): Parser;
bit6(name: string, options?: Parser.Options): Parser;
bit7(name: string, options?: Parser.Options): Parser;
bit8(name: string, options?: Parser.Options): Parser;
bit9(name: string, options?: Parser.Options): Parser;
bit10(name: string, options?: Parser.Options): Parser;
bit11(name: string, options?: Parser.Options): Parser;
bit12(name: string, options?: Parser.Options): Parser;
bit13(name: string, options?: Parser.Options): Parser;
bit14(name: string, options?: Parser.Options): Parser;
bit15(name: string, options?: Parser.Options): Parser;
bit16(name: string, options?: Parser.Options): Parser;
bit17(name: string, options?: Parser.Options): Parser;
bit18(name: string, options?: Parser.Options): Parser;
bit19(name: string, options?: Parser.Options): Parser;
bit20(name: string, options?: Parser.Options): Parser;
bit21(name: string, options?: Parser.Options): Parser;
bit22(name: string, options?: Parser.Options): Parser;
bit23(name: string, options?: Parser.Options): Parser;
bit24(name: string, options?: Parser.Options): Parser;
bit25(name: string, options?: Parser.Options): Parser;
bit26(name: string, options?: Parser.Options): Parser;
bit27(name: string, options?: Parser.Options): Parser;
bit28(name: string, options?: Parser.Options): Parser;
bit29(name: string, options?: Parser.Options): Parser;
bit30(name: string, options?: Parser.Options): Parser;
bit31(name: string, options?: Parser.Options): Parser;
bit32(name: string, options?: Parser.Options): Parser;
bit1<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit2<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit3<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit4<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit5<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit6<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit7<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit8<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit9<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit10<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit11<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit12<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit13<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit14<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit15<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit16<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit17<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit18<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit19<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit20<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit21<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit22<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit23<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit24<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit25<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit26<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit27<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit28<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit29<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit30<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit31<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit32<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
float(name: string, options?: Parser.Options): Parser;
floatle(name: string, options?: Parser.Options): Parser;
floatbe(name: string, options?: Parser.Options): Parser;
float<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
floatle<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
floatbe<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
double(name: string, options?: Parser.Options): Parser;
doublele(name: string, options?: Parser.Options): Parser;
doublebe(name: string, options?: Parser.Options): Parser;
double<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
doublele<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
doublebe<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
string(name: string, options?: Parser.StringOptions): Parser;
string<N extends string>(name: N, options?: Parser.StringOptions): Parser.Next<O, N, string>;
buffer(name: string, options: Parser.BufferOptions): Parser;
buffer<N extends string>(name: N, options: Parser.BufferOptions): Parser.Next<O, N, Buffer>;
array(name: string, options: Parser.ArrayOptions): Parser;
array<N extends string, Q extends Parser.ArrayOptions>(name: N, options: Q): Parser.Next<O, N,
Q extends { type: infer T }
? T extends Parser<infer O>
? O extends undefined ? Array<{}> : O[]
: T extends string
? number[]
: never
: never
>;
choice(name: string, options: Parser.ChoiceOptions): Parser;
choice<N extends string, Q extends Parser.ChoiceOptions>(name: N, options: Q): Parser.Next<O, N,
Q extends {
choices: infer C
}
? C extends {
[key in keyof C]: infer T
}
? T extends Parser<infer O>
? O extends undefined ? {} : O
: T extends string ? any : never
: never
: never
>;
nest(name: string, options: Parser.NestOptions): Parser;
nest<N extends string, Q extends Parser.NestOptions>(name: N, options: Q): Parser.Next<O, N,
Q extends { type: infer T }
? T extends Parser<infer O>
? O extends undefined ? {} : O
: never
: never
>;
skip(length: number): Parser;
skip(length: number): Parser<O>;
endianess(endianess: Parser.Endianness): Parser; /* [sic] */
endianess(endianess: Parser.Endianness): Parser<O>; /* [sic] */
namely(alias: string): Parser;
namely(alias: string): Parser<O>;
compile(): void;
@@ -96,10 +125,8 @@ export interface ParserConstructor {
export const Parser: ParserConstructor;
export namespace Parser {
type Data = number | string | Array<number | Parsed> | Parsed | Buffer;
interface Parsed {
[name: string]: Data;
}
type Data = number | string | Array<number | Parser<any>> | Parser<any> | Buffer;
type Parsed<O extends object | undefined> = O extends undefined ? {} : O;
interface Options {
formatter?: ((value: Data) => any);
@@ -108,7 +135,7 @@ export namespace Parser {
interface StringOptions extends Options {
encoding?: string;
length?: number | string | ((this: Parsed) => number);
length?: number | string | ((this: Parser<any>) => number);
zeroTerminated?: boolean;
greedy?: boolean;
stripNull?: boolean;
@@ -116,32 +143,34 @@ export namespace Parser {
interface BufferOptions extends Options {
clone?: boolean;
length?: number | string | ((this: Parsed) => number);
length?: number | string | ((this: Parser<any>) => number);
readUntil?: string | ((item: number, buffer: Buffer) => boolean);
}
interface ArrayOptions extends Options {
type: string | Parser;
length?: number | string | ((this: Parsed) => number);
lengthInBytes?: number | string | ((this: Parsed) => number);
type: string | Parser<any>;
length?: number | string | ((this: Parser<any>) => number);
lengthInBytes?: number | string | ((this: Parser<any>) => number);
readUntil?: string | ((item: number, buffer: Buffer) => boolean);
}
interface ChoiceOptions extends Options {
tag: string | ((this: Parsed) => number);
choices: { [item: number]: Parser | string };
defaultChoice?: Parser | string;
tag: string | ((this: Parser<any>) => number);
choices: { [item: number]: Parser<any> | string };
defaultChoice?: Parser<any> | string;
}
interface NestOptions extends Options {
type: Parser | string;
type: Parser<any>;
}
type Endianness =
'little' |
'big';
interface Context {
[name: string]: Parsed;
}
type Valid<O extends object | undefined, P extends object> =
O extends undefined ? P : O & P;
type Next<O extends object | undefined, N extends string, T extends any> =
Parser<Valid<O, { [name in N]: T }>>;
}
+48
View File
@@ -0,0 +1,48 @@
import {
agents, features, feature, Agent, Feature, PackedFeature, StatsByAgentID, SupportStatusByVersion, SupportStatus
} from "caniuse-lite";
const chrome: Agent | undefined = agents.chrome;
if (chrome !== undefined) {
const browser: string = chrome.browser;
const prefix: string = chrome.prefix;
const prefixExceptions: any = chrome.prefix_exceptions;
const usageGlobal: { [version: string]: number | undefined } = chrome.usage_global;
const releaseDate: { [version: string]: number | undefined } = chrome.release_date;
const versions: Array<string | null> = chrome.versions;
consume(browser, prefix, prefixExceptions, usageGlobal, releaseDate, versions);
}
const unpackedFeatures = Object.keys(features).map((id: string) => {
const packed: PackedFeature = features[id];
const unpacked: Feature = feature(packed);
const status: string = unpacked.status;
const title: string = unpacked.title;
const stats: StatsByAgentID = unpacked.stats;
Object.keys(stats).forEach((agentID: string) => {
const byVersion: SupportStatusByVersion = stats[agentID];
Object.keys(byVersion).forEach(version => {
const supportStatus: SupportStatus = byVersion[version];
consume(supportStatus);
});
const supportStatusByVersion: SupportStatusByVersion = stats[agentID];
const agent: Agent = agents[agentID]!;
return {
feature: unpacked,
agent,
versions: Object.keys(supportStatusByVersion).map(version => {
return {
version,
releaseDate: agent.release_date[version],
[`feature_${id}`]: supportStatusByVersion[version]
};
})
};
});
});
function consume(...anything: any[]): void {
// ...
}
+159
View File
@@ -0,0 +1,159 @@
// Type definitions for caniuse-lite 1.0
// Project: https://github.com/ben-eb/caniuse-lite#readme
// Definitions by: Michael Utech <https://github.com/mutech>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/**
* Information about user agents (browsers, platforms) indexed by their ID.
*/
export const agents: AgentsByID;
/**
* Features index by their ID. The feature ID is a human readable identifier. The
* associated value is a packed version of information about the feature that
* can be unpacked using the function `feature(packed)`
*/
export const features: { [featureID: string]: PackedFeature; };
/**
* @param packedFeature a packed feature obtained from `features[key]` for some valid key.
* @return the unpacked information as `Feature`.
*/
export function feature(packedFeature: PackedFeature): Feature;
/**
* @param packedRegion a packed version of regional usage data by agent OD.
* @return the unpacked usage data indexed by agent ID and then version.
*/
export function region(packedRegion: PackedRegion): { [agentID: string]: UsageByVersion };
/**
* Agents indexed by their ID. .
*/
export type AgentsByID = Readonly<{ [id: string]: Readonly<Agent> | undefined }>;
/**
* Feature support status by version indexed by agent ID.
*/
export type StatsByAgentID = Readonly<{ [agentID: string]: SupportStatusByVersion }>;
/**
* Feature support status indexed by an agent's versions.
*/
export type SupportStatusByVersion = Readonly<{ [version: string]: SupportStatus }>;
/**
* Usage (percentage/market share) indexed by an agent's versions.
*/
export type UsageByVersion = Readonly<{ [version: string]: number | undefined }>;
/**
* The standardization status of a feature:
* * ls - WHATWG living standard
* * rec - W3C recommendation
* * pr - W3C proposed recommendation
* * cr - W3C candidate recommendation
* * wd - W3C working draft
* * other - Non-W3C, but reputable
* * unoff - Unofficial
*/
export type FeatureStatus = "ls" | "rec" | "pr" | "cr" | "wd" | "other" | "unoff" | string;
/**
* Encoded support status:
* * `n` - not supported
* * `p` - not supported, polyfill available
* * `u` - unknown
* * `a x` - partially supported, vendor prefix
* * `a` - partially supported
* * `y x` - fully supported, vendor prefix
* * `y` - fully supported
*
* The support status can additionally have one or more footnote references as `#<n>`, f.e.
* `a x #1 #3`.
*/
export type SupportStatus = 'n' | 'p' | 'u' | "a x" | 'a' | "y x" | 'y' | string;
/**
* Provides information about the Agent.
*/
export interface Agent {
/**
* Global agent usage by version
*/
usage_global: UsageByVersion;
/**
* The agents vendor prefix
*/
prefix: string;
/**
* Version matrix. See [caniuse](https://caniuse.com)
*/
versions: [ // Tuple of 70 version slots:
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null,
string|null, string|null, string|null, string|null, string|null ];
/**
* The agent's name
*/
browser: string;
/**
* Release dates as seconds since epoch by version.
*/
release_date: { [version: string]: number | undefined };
/**
* Exceptions to vendor prefix use.
*/
prefix_exceptions?: { [version: string]: string | undefined };
}
/**
* Specifies a feature and its support status in all known agent versions.
*/
export interface Feature {
/**
* Specification status of the feature.
*/
status: FeatureStatus;
/**
* Descriptive title of the feature.
*/
title: string;
/**
* Agent support matrix for this feature.
*/
stats: StatsByAgentID;
}
/**
* A space optimized version of Feature that can be unpacked using `feature(PackedFeature)`.
*/
export interface PackedFeature {
[encodedKey: string]: any;
}
/**
* A space optimized version of Region that can be unpacked using `region(PackedFeature)`.
*/
export interface PackedRegion {
[encodedKey: string]: any;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"caniuse-lite-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5 -1
View File
@@ -9,7 +9,9 @@ const plugin = {
}
};
const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
const ctx = new CanvasRenderingContext2D();
const chart: Chart = new Chart(ctx, {
type: "bar",
plugins: [plugin, plugin],
data: {
@@ -17,6 +19,8 @@ const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
datasets: [
{
backgroundColor: "#000000",
hoverBackgroundColor: ctx.createLinearGradient(0, 0, 0, 100),
hoverBorderColor: ctx.createLinearGradient(0, 0, 0, 100),
borderWidth: 1,
label: "test",
data: [1, null, 3]
+2 -2
View File
@@ -554,8 +554,8 @@ declare namespace Chart {
borderSkipped?: PositionType;
data?: Array<number | null | undefined> | ChartPoint[];
fill?: boolean | number | string;
hoverBackgroundColor?: string | string[];
hoverBorderColor?: string | string[];
hoverBackgroundColor?: ChartColor | ChartColor[];
hoverBorderColor?: ChartColor | ChartColor[];
hoverBorderWidth?: number | number[];
label?: string;
lineTension?: number;
+2 -1
View File
@@ -369,6 +369,7 @@ function test_dom_walker() {
node = walker.lastForward();
node = walker.next();
node = walker.previous();
isSomething = walker.guard(node, true);
walker.reset();
isSomething = CKEDITOR.dom.walker.blockBoundary({ div: 1 })(node);
@@ -485,7 +486,7 @@ function test_dialog() {
{
id: 'tab-basic',
label: 'Basic Settings',
elements: <any[]> []
elements: [] as any []
},
{
id: 'tab-adv',
+1 -1
View File
@@ -498,7 +498,7 @@ declare namespace CKEDITOR {
class walker {
evaluator: (node: node) => boolean;
guard: (node: node) => boolean;
guard: (node: node, movingOut?: boolean) => boolean;
static validEmptyBlockContainers: { [key: string]: any };
+47
View File
@@ -0,0 +1,47 @@
import Box = require('cli-box');
// Create a simple box
const b1: Box = Box("20x10");
// console.log(b1.toString());
// Set custom marks
const b2: Box = new Box({
w: 10
, h: 10
, stringify: false
, marks: {
nw: "╔"
, n: "══"
, ne: "╗"
, e: "║"
, se: "╝"
, s: "══"
, sw: "╚"
, w: "║"
, b: "░░"
}
});
// console.log(b2.stringify());
// Box with text and use the stringify
const b3: Box = Box("20x10", "I will be \u001b[31mdis\u001b[0mplayed inside! \n A\u001b[34mnd I'm in a\u001b[0m new line!");
// console.log(b3);
// Box with aligned text to top-right
const b4: Box = Box("30x20", {
text: "Box content"
, stretch: true
, autoEOL: true
, vAlign: "top"
, hAlign: "right"
});
// console.log(b4);
// Full screen box
const b5: Box = Box({fullscreen: true, marks: {}}, "Hello World!");
// console.log(b5.toString());
const b5s: string = Box({stringify: true, fullscreen: true, marks: {}}, "Hello World!");
const b5ns: Box = Box({stringify: false, fullscreen: true, marks: {}}, "Hello World!");
const defaults = Box.defaults;
+70
View File
@@ -0,0 +1,70 @@
// Type definitions for cli-box 6.0
// Project: https://github.com/IonicaBizau/node-cli-box
// Definitions by: Kent Wong <https://github.com/athasach>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/*~ Note that ES6 modules cannot directly export callable functions.
*~ This file should be imported using the CommonJS-style:
*~ import x = require('someLibrary');
*~
*~ Refer to the documentation to understand common
*~ workarounds for this limitation of ES6 modules.
*/
/*~ This declaration specifies that the function
*~ is the exported object from the file
*/
export = Box;
type MarksKeys = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'b';
type Marks = Record<MarksKeys, string>;
interface Options {
w?: number;
width?: number;
h?: number;
height?: number;
fullscreen?: boolean;
stringify?: boolean;
marks?: Partial<Marks>;
}
interface Text {
text?: string;
stretch?: boolean;
autoEOL?: boolean;
hAlign?: 'left' | 'middle' | 'right';
vAlign?: 'top' | 'center' | 'bottom';
}
interface Box {
stringify(): string;
settings: {
width: number;
height: number;
marks: Marks;
lines: Array<{
text: string;
offset: {
y: number;
}
}>
};
options: {
width: number;
height: number;
marks: Marks;
fullscreen: boolean;
stringify: boolean;
};
}
interface BoxConstructor {
new(options: Options | string, text?: Text | string): Box;
(options: (Exclude<Options, 'stringify'> & { stringify: true }), text?: Text | string): string;
(options: Options | string, text?: Text | string): Box;
defaults: { marks: Marks };
}
declare const Box: BoxConstructor;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cli-box-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,14 @@
import commandExists = require('command-exists');
commandExists('ls', (err, commandExists) => {
// $ExpectType boolean
commandExists;
});
commandExists('ls').then(command => {
// $ExpectType string
command;
});
// $ExpectType boolean
commandExists.sync('ls');
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for command-exists 1.2
// Project: https://github.com/mathisonian/command-exists
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = commandExists;
declare function commandExists(commandName: string): Promise<string>;
declare function commandExists(
commandName: string,
cb: (error: null, exists: boolean) => void
): void;
declare namespace commandExists {
function sync(commandName: string): boolean;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"command-exists-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+204 -129
View File
@@ -1,167 +1,242 @@
import * as commonTags from 'common-tags';
import {
html,
safeHtml,
oneLine,
oneLineTrim,
stripIndent,
stripIndents,
inlineLists,
oneLineInlineLists,
commaLists,
commaListsOr,
commaListsAnd,
oneLineCommaLists,
oneLineCommaListsOr,
oneLineCommaListsAnd,
id,
TemplateTag,
trimResultTransformer,
stripIndentTransformer,
replaceResultTransformer,
replaceSubstitutionTransformer,
inlineArrayTransformer,
splitStringTransformer,
createTag,
TemplateTransformer,
replaceStringTransformer,
} from 'common-tags';
/* Test Built-in Tags */
commonTags.commaLists `
I like ${['apples', 'bananas', 'watermelons']}
They're good!
const userMessages = ['hi', 'what are you up to?', '<script>alert("something evil")</script>'];
html`
<div class="chat-list">
<ul>
${userMessages.map(message => safeHtml`<li>${message}</li>`)}
</ul>
</div>
`;
commonTags.commaListsAnd`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commonTags.commaListsOr`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
let fruits = ['apple', 'orange', 'watermelon'];
commonTags.html`
<div class="list">
<ul>
${fruits.map(fruit => `<li>${fruit}</li>`)}
${'<li>kiwi</li>\n<li>guava</li>'}
</ul>
</div>
`;
commonTags.codeBlock`
<div class="list">
<ul>
${fruits.map(fruit => `<li>${fruit}</li>`)}
${'<li>kiwi</li>\n<li>guava</li>'}
</ul>
</div>
`;
commonTags.source`
<div class="list">
<ul>
${fruits.map(fruit => `<li>${fruit}</li>`)}
${'<li>kiwi</li>\n<li>guava</li>'}
</ul>
</div>
`;
let userMessages = ['hi', 'what are you up to?', '<script>alert("something evil")</script>']
commonTags.html`
<div class="chat-list">
<ul>
${userMessages.map(message => commonTags.safeHtml`<li>${message}</li>`)}
</ul>
</div>
`
commonTags.oneLine`
oneLine`
foo
bar
baz
`;
commonTags.oneLineTrim`
oneLineTrim`
https://news.com/article
?utm_source=designernews.co
`;
commonTags.oneLineCommaLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commonTags.oneLineCommaListsOr`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commonTags.oneLineCommaListsAnd`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commonTags.inlineLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commonTags.oneLineInlineLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
let verb = 'notice';
commonTags.stripIndent`
const verb = 'notice';
stripIndent`
This is a multi-line string.
You'll ${verb} that it is indented.
We don't want to output this indentation.
But we do want to keep this line indented.
`;
commonTags.stripIndents`
stripIndents`
This is a multi-line string.
You'll ${verb} that it is indented.
We don't want to output this indentation.
We don't want to keep this line indented either.
`;
/* Test Tag Constructor */
inlineLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
new commonTags.TemplateTag();
oneLineInlineLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
const substitutionReplacer = (oldValue : string, newValue : string) => ({
onSubstitution(substitution : string, resultSoFar : string) {
commaLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commaListsOr`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
commaListsAnd`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
oneLineCommaLists`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
oneLineCommaListsOr`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
oneLineCommaListsAnd`
I like ${['apples', 'bananas', 'watermelons']}
They're good!
`;
id`hello ${'world'}`;
oneLine(String.raw)`
foo
bar\nbaz
`;
stripIndent(' foo\n bar');
const doNothing = createTag();
doNothing`foo bar`;
const substitutionReplacer = (oldValue: string, newValue: string): TemplateTransformer => ({
onSubstitution(substitution, resultSoFar) {
if (substitution === oldValue) {
return newValue;
}
return substitution;
}
},
});
new commonTags.TemplateTag(substitutionReplacer('fizz', 'buzz'));
const replaceFizzWithBuzz = createTag(substitutionReplacer('fizz', 'buzz'));
replaceFizzWithBuzz`foo bar ${'fizz'}`;
new commonTags.TemplateTag(
substitutionReplacer('fizz', 'buzz'),
substitutionReplacer('foo', 'bar')
createTag();
createTag(substitutionReplacer('fizz', 'buzz'));
createTag(substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar'));
createTag([substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar')]);
new TemplateTag();
new TemplateTag(substitutionReplacer('fizz', 'buzz'));
new TemplateTag(substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar'));
new TemplateTag([substitutionReplacer('fizz', 'buzz'), substitutionReplacer('foo', 'bar')]);
const tt: TemplateTransformer<{ foo: string }> = {
getInitialContext() {
return { foo: 'bar' };
},
onString(str, context) {
// $ExpectType string
str;
// $ExpectType { foo: string; }
context;
return '';
},
onSubstitution(substitution, resultSoFar, context) {
// $ExpectType string
substitution;
// $ExpectType string
resultSoFar;
// $ExpectType { foo: string; }
context;
return '';
},
onEndResult(endResult, context) {
// $ExpectType string
endResult;
// $ExpectType { foo: string; }
context;
return '';
},
};
createTag({});
createTag(tt);
createTag({
onString: str => `${str}!`,
});
createTag({
onSubstitution: substitution => `${substitution}!`,
});
createTag({
onEndResult: endResult => `${endResult}!`,
});
new TemplateTag({});
new TemplateTag(tt);
new TemplateTag({
onString: str => `${str}!`,
});
new TemplateTag({
onSubstitution: substitution => `${substitution}!`,
});
new TemplateTag({
onEndResult: endResult => `${endResult}!`,
});
createTag(trimResultTransformer());
createTag(trimResultTransformer(''));
createTag(trimResultTransformer('start'));
createTag(trimResultTransformer('end'));
createTag(trimResultTransformer('left'));
createTag(trimResultTransformer('right'));
createTag(stripIndentTransformer());
createTag(stripIndentTransformer('initial'));
createTag(stripIndentTransformer('all'));
createTag(replaceResultTransformer('foo', 'bar'));
createTag(replaceResultTransformer(/baz/g, 'bar'));
createTag(
replaceResultTransformer(/baz/g, (substring, ...matches) => {
// $ExpectType string
substring;
// $ExpectType any[]
matches;
return '';
})
);
new commonTags.TemplateTag([
substitutionReplacer('fizz', 'buzz'),
substitutionReplacer('foo', 'bar')
]);
createTag(replaceSubstitutionTransformer('foo', 'bar'));
createTag(replaceSubstitutionTransformer(/baz/g, 'bar'));
createTag(
replaceSubstitutionTransformer(/baz/g, (substring, ...matches) => {
// $ExpectType string
substring;
// $ExpectType any[]
matches;
return '';
})
);
new commonTags.TemplateTag({});
createTag(replaceStringTransformer('foo', 'bar'));
createTag(replaceStringTransformer(/baz/g, 'bar'));
createTag(
replaceStringTransformer(/baz/g, (substring, ...matches) => {
// $ExpectType string
substring;
// $ExpectType any[]
matches;
return '';
})
);
new commonTags.TemplateTag({
onEndResult: endResult => `${endResult}!`
});
createTag(inlineArrayTransformer());
createTag(inlineArrayTransformer({}));
createTag(inlineArrayTransformer({ separator: 'foo' }));
createTag(inlineArrayTransformer({ conjunction: 'bar' }));
createTag(inlineArrayTransformer({ serial: true }));
new commonTags.TemplateTag({
onSubstitution: substitution => `${substitution}!`,
onEndResult: endResult => `${endResult}!`
});
/* Tests Built-in Transformers */
new commonTags.TemplateTag(commonTags.trimResultTransformer());
new commonTags.TemplateTag(commonTags.trimResultTransformer('left'));
new commonTags.TemplateTag(commonTags.trimResultTransformer('right'));
new commonTags.TemplateTag(commonTags.stripIndentTransformer());
new commonTags.TemplateTag(commonTags.stripIndentTransformer('initial'));
new commonTags.TemplateTag(commonTags.stripIndentTransformer('all'));
new commonTags.TemplateTag(commonTags.replaceResultTransformer('foo', 'bar'));
new commonTags.TemplateTag(commonTags.replaceSubstitutionTransformer(/baz/g, 'bar'));
new commonTags.TemplateTag(commonTags.replaceSubstitutionTransformer('foo', 'bar'));
new commonTags.TemplateTag(commonTags.replaceSubstitutionTransformer(/baz/g, 'bar'));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer());
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({}));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({separator: 'foo'}));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({conjunction: 'bar'}));
new commonTags.TemplateTag(commonTags.splitStringTransformer('foo'));
createTag(splitStringTransformer('foo'));
+212 -59
View File
@@ -1,67 +1,220 @@
// Type definitions for common-tags v1.4.0
// Type definitions for common-tags 1.8
// Project: https://github.com/declandewet/common-tags
// Definitions by: Viktor Zozuliak <https://github.com/zuzusik>
// Paul Wang <https://github.com/tzupengwang>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
declare module 'common-tags' {
type TemplateTag = (literals: TemplateStringsArray, ...placeholders: any[]) => string;
export as namespace commonTags;
type TemplateTransformer = {
onSubstitution?: (substitution: string, resultSoFar: string) => string;
onEndResult?: (endResult : string) => string;
}
export type JSTag = (literals: TemplateStringsArray, ...placeholders: any[]) => string;
/* Built-in Tags */
export var commaLists: TemplateTag;
export var commaListsAnd: TemplateTag;
export var commaListsOr: TemplateTag;
export var html: TemplateTag;
export var codeBlock: TemplateTag;
export var source: TemplateTag;
export var safeHtml: TemplateTag;
export var oneLine: TemplateTag;
export var oneLineTrim: TemplateTag;
export var oneLineCommaLists: TemplateTag;
export var oneLineCommaListsOr: TemplateTag;
export var oneLineCommaListsAnd: TemplateTag;
export var inlineLists: TemplateTag;
export var oneLineInlineLists: TemplateTag;
export var stripIndent: TemplateTag;
export var stripIndents: TemplateTag;
/* New Tag Constructor */
export var TemplateTag: {
new(): TemplateTag;
new(...transformers: TemplateTransformer[]): TemplateTag;
new(transformers: TemplateTransformer[]): TemplateTag;
};
/* Built-in Transformers */
export var trimResultTransformer: (side?: 'left'|'right') => TemplateTransformer;
export var stripIndentTransformer: (type?: 'initial'|'all') => TemplateTransformer;
export var replaceResultTransformer: (replaceWhat: string|RegExp, replaceWith: string) => TemplateTransformer;
export var replaceSubstitutionTransformer: (replaceWhat: string|RegExp, replaceWith: string) => TemplateTransformer;
export var inlineArrayTransformer: (opts?: {separator?: string, conjunction?: string}) => TemplateTransformer;
export var splitStringTransformer: (splitBy: string) => TemplateTransformer;
export interface TemplateTag {
(str: string): string;
(tag: JSTag): TemplateTag;
(literals: TemplateStringsArray, ...placeholders: any[]): string;
}
/**
* You'll often find that you might want to include an array in a template.
* Typically, doing something like `${array.join(', ')}` would work - but what if you're printing a list of items
* in an HTML template and want to maintain the indentation? You'd have to count the spaces manually and include
* them in the `.join()` call - which is a bit ugly for my taste.
* This tag properly indents arrays, as well as newline characters in string substitutions,
* by converting them to an array split by newline and re-using the same array inclusion logic.
*/
export const html: TemplateTag;
/**
* alias for `html`
*/
export const codeBlock: TemplateTag;
/**
* alias for `html`
*/
export const source: TemplateTag;
/**
* A tag very similar to `html` but it does safe HTML escaping for strings coming from substitutions.
* When combined with regular `html` tag, you can do basic HTML templating that is safe from
* XSS (Cross-Site Scripting) attacks.
*/
export const safeHtml: TemplateTag;
/**
* Allows you to keep your single-line strings under 80 characters without resorting to crazy string concatenation.
*/
export const oneLine: TemplateTag;
/**
* Allows you to keep your single-line strings under 80 characters while trimming the new lines.
*/
export const oneLineTrim: TemplateTag;
/**
* If you want to strip the initial indentation from the beginning of each line in a multiline string.
* Important note: this tag will not indent multiline strings coming from the substitutions.
* If you want that behavior, use the `html` tag (aliases: `source`, `codeBlock`).
*/
export const stripIndent: TemplateTag;
/**
* If you want to strip *all* of the indentation from the beginning of each line in a multiline string.
*/
export const stripIndents: TemplateTag;
/**
* Allows you to inline an array substitution as a list.
*/
export const inlineLists: TemplateTag;
/**
* Allows you to inline an array substitution as a list, rendered out on a single line.
*/
export const oneLineInlineLists: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list.
*/
export const commaLists: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or".
*/
export const commaListsOr: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and".
*/
export const commaListsAnd: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, and is rendered out on to a single line.
*/
export const oneLineCommaLists: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or", and is rendered out on to a single line.
*/
export const oneLineCommaListsOr: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and", and is rendered out on to a single line.
*/
export const oneLineCommaListsAnd: TemplateTag;
/**
* A no-op tag that might come in useful in some scenarios, e.g. mocking.
*/
export const id: TemplateTag;
export interface TemplateTransformer<TCtx = { [key: string]: any }> {
/**
* Called before everything else.
* The result of this hook will be passed to other hooks as `context`.
* If omitted, `context` will be an empty object.
*/
getInitialContext?: () => TCtx;
/**
* Called when the tag encounters a string.
* (a string is whatever's not inside "${}" in your template literal)
* `str` is the value of the current string
*/
onString?: (str: string, context: TCtx) => string;
/**
* Called when the tag encounters a substitution.
* (a substitution is whatever's inside "${}" in your template literal)
* `substitution` is the value of the current substitution
* `resultSoFar` is the end result up to the point of this substitution
*/
onSubstitution?: (substitution: string, resultSoFar: string, context: TCtx) => string;
/**
* Called when all substitutions have been parsed
* `endResult` is the final value.
*/
onEndResult?: (endResult: string, context: TCtx) => string;
}
export type PluginFunction = (oldValue: string, newValue: string) => TemplateTransformer<any>;
/**
* New Tag factory
*/
export function createTag(transformers?: Array<TemplateTransformer<any>>): TemplateTag;
export function createTag(...transformers: Array<TemplateTransformer<any>>): TemplateTag;
export function createTag(...pluginFunctions: PluginFunction[]): TemplateTag;
export const TemplateTag: {
/**
* New Tag Constructor
* @deprecated
*/
new (transformers?: Array<TemplateTransformer<any>>): TemplateTag;
new (...transformers: Array<TemplateTransformer<any>>): TemplateTag;
new (...pluginFunctions: PluginFunction[]): TemplateTag;
};
/**
* TemplateTag transformer that trims whitespace on the end result of a tagged template
* @param [side=''] The side of the string to trim. Can be 'start' or 'end' (alternatively 'left' or 'right')
* @return a TemplateTag transformer
*/
export function trimResultTransformer(
side?: 'start' | 'end' | 'left' | 'right' | ''
): TemplateTransformer;
/**
* strips indentation from a template literal
* @param [type='initial'] whether to remove all indentation or just leading indentation. can be 'all' or 'initial'
* @return a TemplateTag transformer
*/
export function stripIndentTransformer(type?: 'initial' | 'all'): TemplateTransformer;
/**
* Replaces a value or pattern in the end result with a new value.
* @param replaceWhat the value or pattern that should be replaced
* @param replaceWith the replacement value
* @return a TemplateTag transformer
*/
export function replaceResultTransformer(
replaceWhat: string | RegExp,
replaceWith: string | ((substring: string, ...args: any[]) => string)
): TemplateTransformer;
/**
* Replaces the result of all substitutions (results of calling ${ ... }) with a new value.
* Same as for `replaceResultTransformer`, replaceWhat can be a string or regular expression and replaceWith is the new value.
*/
export function replaceSubstitutionTransformer(
replaceWhat: string | RegExp,
replaceWith: string | ((substring: string, ...args: any[]) => string)
): TemplateTransformer;
/**
* Replaces the result of all strings (what's not in ${ ... }) with a new value.
* Same as for `replaceResultTransformer`, replaceWhat can be a string or regular expression and replaceWith is the new value.
*/
export function replaceStringTransformer(
replaceWhat: string | RegExp,
replaceWith: string | ((substring: string, ...args: any[]) => string)
): TemplateTransformer;
/**
* Converts an array substitution to a string containing a list
* @param [opts.separator=''] what to separate each item with (always followed by a space)
* @param [opts.conjunction=''] replace the last separator with this value
* @param [opts.serial=false] should the separator be included before the conjunction? As in the case of serial/oxford commas
* @return a TemplateTag transformer
*/
export function inlineArrayTransformer(opts?: {
separator?: string;
conjunction?: string;
serial?: boolean;
}): TemplateTransformer;
/**
* Splits a string substitution into an array by the provided splitBy substring, only if the string contains the splitBy substring.
*/
export function splitStringTransformer(splitBy: string): TemplateTransformer;
+1 -77
View File
@@ -1,79 +1,3 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
"extends": "dtslint/dt.json"
}
+1
View File
@@ -110,6 +110,7 @@ declare namespace connectMongo {
length: (callback: (err: any, length: number) => void) => void;
clear: (callback?: (err?: any) => void) => void;
touch: (sid: string, session: Express.SessionData, callback?: (err: any) => void) => void;
close: () => void;
}
}
+19 -1
View File
@@ -37,6 +37,24 @@ declare namespace convict {
parse: (content: string) => any;
}
type PredefinedFormat =
| '*'
| 'int'
| 'port'
| 'windows_named_pipe'
| 'port_or_windows_named_pipe'
| 'url'
| 'email'
| 'ipaddress'
| 'duration'
| 'timestamp'
| 'nat'
| String
| Object
| Number
| RegExp
| Boolean;
interface SchemaObj<T = any> {
default: T;
doc?: string;
@@ -52,7 +70,7 @@ declare namespace convict {
* If omitted, format will be set to the value of Object.prototype.toString.call
* for the default value
*/
format?: string | any[] | ((val: any) => void);
format?: PredefinedFormat | any[] | ((val: any) => void);
env?: string;
arg?: string;
sensitive?: boolean;
+29
View File
@@ -0,0 +1,29 @@
import { sha1, sha256, sha384, sha512 } from 'crypto-hash';
// $ExpectType Promise<string>
sha1('🦄');
// $ExpectType Promise<ArrayBuffer>
sha1('🦄', { outputFormat: 'buffer' });
// $ExpectType Promise<string>
sha1('🦄', { outputFormat: 'hex' });
// $ExpectType Promise<string>
sha256('🦄');
// $ExpectType Promise<ArrayBuffer>
sha256('🦄', { outputFormat: 'buffer' });
// $ExpectType Promise<string>
sha256('🦄', { outputFormat: 'hex' });
// $ExpectType Promise<string>
sha384('🦄');
// $ExpectType Promise<ArrayBuffer>
sha384('🦄', { outputFormat: 'buffer' });
// $ExpectType Promise<string>
sha384('🦄', { outputFormat: 'hex' });
// $ExpectType Promise<string>
sha512('🦄');
// $ExpectType Promise<ArrayBuffer>
sha512('🦄', { outputFormat: 'buffer' });
// $ExpectType Promise<string>
sha512('🦄', { outputFormat: 'hex' });
+48
View File
@@ -0,0 +1,48 @@
// Type definitions for crypto-hash 1.0
// Project: https://github.com/sindresorhus/crypto-hash#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function sha1(
buffer: string | ArrayBuffer | ArrayBufferView,
options?: OptionsHexOutput
): Promise<string>;
export function sha1(
buffer: string | ArrayBuffer | ArrayBufferView,
options: OptionBufferOutput
): Promise<ArrayBuffer>;
export function sha256(
buffer: string | ArrayBuffer | ArrayBufferView,
options?: OptionsHexOutput
): Promise<string>;
export function sha256(
buffer: string | ArrayBuffer | ArrayBufferView,
options: OptionBufferOutput
): Promise<ArrayBuffer>;
export function sha384(
buffer: string | ArrayBuffer | ArrayBufferView,
options?: OptionsHexOutput
): Promise<string>;
export function sha384(
buffer: string | ArrayBuffer | ArrayBufferView,
options: OptionBufferOutput
): Promise<ArrayBuffer>;
export function sha512(
buffer: string | ArrayBuffer | ArrayBufferView,
options?: OptionsHexOutput
): Promise<string>;
export function sha512(
buffer: string | ArrayBuffer | ArrayBufferView,
options: OptionBufferOutput
): Promise<ArrayBuffer>;
export interface OptionsHexOutput {
outputFormat?: 'hex';
}
export interface OptionBufferOutput {
outputFormat: 'buffer';
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"crypto-hash-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+10
View File
@@ -0,0 +1,10 @@
import Cryptr = require('cryptr');
// $ExpectType Cryptr
const cryptr = new Cryptr('myTotallySecretKey');
// $ExpectType string
const encrypted_string = cryptr.encrypt('bacon');
// $ExpectType string
cryptr.decrypt(encrypted_string);
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for cryptr 4.0
// Project: https://github.com/MauriceButler/cryptr
// Definitions by: Roman Rogowski <https://github.com/rrogowski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Cryptr {
/**
* Cryptr provides a mechanism for aes-256-ctr encryption/decryption.
* @param secret key used for encryption/decryption
*/
constructor(secret: string);
/** Encrypt a string. */
encrypt(value: string): string;
/** Decrypt a string. */
decrypt(value: string): string;
}
export = Cryptr;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"cryptr-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -48,7 +48,7 @@ brush = brush.extent(function(d, i, group) {
// chainable
brush = brush.filter(function(d, i, group) {
// Cast d3 event to D3ZoomEvent to be used in filter logic
const e = <d3Brush.D3BrushEvent<BrushDatum>> event;
const e = event as d3Brush.D3BrushEvent<BrushDatum>;
console.log('Owner SVG Element of svg group: ', this.ownerSVGElement); // this is of type SVGGElement
return e.sourceEvent.type !== 'zoom' || !d.filterZoomEvent; // datum type is BrushDatum (as propagated to SVGGElement with brush event attached)
+3 -3
View File
@@ -134,7 +134,7 @@ touchableFn = circleDrag.touchable();
circleCustomDrag.subject(function(d, i, g) {
// Cast event type for completeness, otherwise event is of type any.
const e = <d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CustomSubject | d3Drag.SubjectPosition>> event;
const e = event as d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CustomSubject | d3Drag.SubjectPosition>;
const that: SVGCircleElement = this;
const datum: CircleDatum = d;
const index: number = i;
@@ -163,14 +163,14 @@ subjectAccessor = circleCustomDrag.subject();
function dragstarted(this: SVGCircleElement, d: CircleDatum) {
// cast d3 event to drag event. Otherwise, d3 event is currently defined as type 'any'
const e = <d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CircleDatum | d3Drag.SubjectPosition>> event;
const e = event as d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CircleDatum | d3Drag.SubjectPosition>;
e.sourceEvent.stopPropagation();
select(this).classed('dragging', true);
}
function dragged(this: SVGCircleElement, d: CircleDatum) {
// cast d3 event to drag event. Otherwise, d3 event is currently defined as type 'any'
const e = <d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CircleDatum | d3Drag.SubjectPosition>> event;
const e = event as d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CircleDatum | d3Drag.SubjectPosition>;
select(this).attr('cx', d.x = e.x).attr('cy', d.y = e.y);
}
+1 -1
View File
@@ -1060,7 +1060,7 @@ interface SuccessEvent {
const successEvent = { type: 'wonEuro2016', team: 'Island' };
function customListener(this: HTMLBodyElement | null, finalOpponent: string): string {
const e = <SuccessEvent> d3Selection.event;
const e = d3Selection.event as SuccessEvent;
return `${e.team} defeated ${finalOpponent} in the EURO 2016 Cup. Who would have thought!!!`;
}
-1
View File
@@ -2,7 +2,6 @@
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-angle-bracket-type-assertion": false,
"no-this-assignment": false,
"unified-signatures": false,
"no-unnecessary-generics": false
+10 -7
View File
@@ -38,7 +38,7 @@ export interface CanvasPath_D3Shape {
// -----------------------------------------------------------------------------------
/**
* Interface corresponding to the minimum data type assumed by the accessor functions of the Arc generator
* Interface corresponding to the minimum data type assumed by the accessor functions of the Arc generator
*/
export interface DefaultArcObject {
/**
@@ -994,14 +994,17 @@ export function lineRadial(): LineRadial<[number, number]>;
*/
export function lineRadial<Datum>(): LineRadial<Datum>;
/**
* @deprecated Use LineRadial<Datum>
*/
export type RadialLine<Datum> = LineRadial<Datum>;
/**
* DEPRECATED: Use lineRadial()
* @deprecated Use lineRadial()
*/
export function radialLine(): RadialLine<[number, number]>;
/**
* DEPRECATED: Use lineRadial<Datum>()
* @deprecated Use lineRadial<Datum>()
*/
export function radialLine<Datum>(): RadialLine<Datum>;
@@ -1620,16 +1623,16 @@ export function areaRadial(): AreaRadial<[number, number]>;
export function areaRadial<Datum>(): AreaRadial<Datum>;
/**
* DEPRECATED: Use AreaRadial interface
* @deprecated Use AreaRadial interface
*/
export type RadialArea<Datum> = AreaRadial<Datum>;
/**
* DEPRECATED: Use areaRadial()
* @deprecated Use areaRadial()
*/
export function radialArea(): RadialArea<[number, number]>;
/**
* DEPRECATED: Use areaRadial<Datum>()
* @deprecated Use areaRadial<Datum>()
*/
export function radialArea<Datum>(): RadialArea<Datum>;
@@ -2239,7 +2242,7 @@ export interface LinkRadial<This, LinkDatum, NodeDatum> {
}
/**
* DEPRECATED: Use LinkRadial interface
* @deprecated Use LinkRadial interface
*/
export type RadialLink<This, LinkDatum, NodeDatum> = LinkRadial<This, LinkDatum, NodeDatum>;
+4 -4
View File
@@ -91,7 +91,7 @@ interface GroupDatum {
function zoomedCanvas(this: HTMLCanvasElement, d: CanvasDatum) {
// Cast d3 event to D3ZoomEvent to be used in zoom event handler
const e = <d3Zoom.D3ZoomEvent<HTMLCanvasElement, any>> event;
const e = event as d3Zoom.D3ZoomEvent<HTMLCanvasElement, any>;
if (context) {
context.save();
context.clearRect(0, 0, this.width, this.height); // this element
@@ -112,7 +112,7 @@ canvasZoom = d3Zoom.zoom<HTMLCanvasElement, CanvasDatum>()
function zoomedSVGOverlay(this: SVGRectElement) {
// Cast d3 event to D3ZoomEvent to be used in zoom event handler
const e = <d3Zoom.D3ZoomEvent<HTMLCanvasElement, any>> event;
const e = event as d3Zoom.D3ZoomEvent<HTMLCanvasElement, any>;
g.attr('transform', e.transform.toString());
}
@@ -146,7 +146,7 @@ constraintFn = svgZoom.constrain();
// chainable
svgZoom = svgZoom.filter(function(d, i, group) {
// Cast d3 event to D3ZoomEvent to be used in filter logic
const e = <d3Zoom.D3ZoomEvent<SVGRectElement, SVGDatum>> event;
const e = event as d3Zoom.D3ZoomEvent<SVGRectElement, SVGDatum>;
console.log('Overlay Rectangle width: ', this.width.baseVal.value); // this typing is SVGRectElement
return e.sourceEvent.type !== 'brush' || !d.filterBrushEvent; // datum type is SVGDatum (as propagated to SVGRectElement with zoom event attached)
@@ -178,7 +178,7 @@ touchableFn = svgZoom.touchable();
// chainable
svgZoom = svgZoom.wheelDelta(function(d, i, group) {
// Cast d3 event to D3ZoomEvent to be used in filter logic
const e = <WheelEvent> event;
const e = event as WheelEvent;
const that: SVGRectElement = this;
const datum: SVGDatum = d;
const index: number = i;
-1
View File
@@ -2,7 +2,6 @@
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-angle-bracket-type-assertion": false,
"no-this-assignment": false,
"unified-signatures": false,
"no-unnecessary-generics": false
+1
View File
@@ -2,6 +2,7 @@ import * as tracer from "dd-trace";
import SpanContext = require("dd-trace/src/opentracing/span_context");
tracer.init({
enabled: true,
service: "MyLovelyService",
hostname: "localhost",
port: 8126,
+11 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for dd-trace-js 0.6
// Type definitions for dd-trace-js 0.7
// Project: https://github.com/DataDog/dd-trace-js
// Definitions by: Colin Bradley <https://github.com/ColinBradley>
// Eloy Durán <https://github.com/alloy>
@@ -54,6 +54,12 @@ declare class TraceProxy extends Tracer {
}
interface TracerOptions {
/**
* Whether to enable the tracer.
* @default true
*/
enabled?: boolean;
/**
* Enable debug logging in the tracer.
* @default false
@@ -185,6 +191,7 @@ declare class Scope {
type Plugin =
| "amqp10"
| "amqplib"
| "bluebird"
| "elasticsearch"
| "express"
| "graphql"
@@ -197,8 +204,10 @@ type Plugin =
| "mysql"
| "mysql2"
| "pg"
| "q"
| "redis"
| "restify";
| "restify"
| "when";
interface BasePluginOptions {
/**
@@ -0,0 +1,25 @@
import debounce = require("debounce-promise");
import { DebounceOptions } from "debounce-promise";
const options: DebounceOptions = {};
const optionsA: DebounceOptions = { leading: true };
const f = async () => 2;
const f2 = (a: string) => 2;
debounce(f, 100);
debounce(f, 0, options);
debounce(f, 100, optionsA);
debounce(f, 10, { accumulate: true });
const foo = debounce(async () => f2, 10, {
leading: true,
accumulate: true
});
foo().then(f => f("2"));
const bar = debounce(async () => [1, 2, 3], 100);
bar().then(ar => ar.concat());
// Converts the return value from the producer function to a promise
const two = debounce((a: string, b: number, c: { d: boolean }) => [4], 10, {
leading: true,
accumulate: true
});
two("1", 2, { d: false }).then(ar => ar.pop(), () => 2);
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for debounce-promise 3.1
// Project: https://github.com/bjoerge/debounce-promise
// Definitions by: Wu Haotian <https://github.com/whtsky>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
declare namespace debounce {
interface DebounceOptions {
leading?: boolean;
accumulate?: boolean;
}
}
declare function debounce<T extends (...args: any[]) => any>(
func: T,
wait?: number,
options?: debounce.DebounceOptions
): (
...args: Parameters<T>
) => ReturnType<T> extends Promise<any>
? ReturnType<T>
: Promise<ReturnType<T>>;
export = debounce;
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "debounce-promise-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
-31
View File
@@ -1,31 +0,0 @@
declare var describe: (test: string, callback: () => void) => void;
declare var beforeAll: (callback: () => void) => void;
declare var afterAll: (callback: () => void) => void;
declare var test: (test: string, callback: () => void) => void;
describe('Test', () => {
beforeAll(async () => {
await device.reloadReactNative();
});
afterAll(async () => {
await element(by.id('element')).clearText();
});
test('Test', async () => {
await element(by.id('element')).replaceText('text');
await element(by.id('element')).tap();
await element(by.id('element')).scroll(50, 'down');
await element(by.id('scrollView')).scrollTo('bottom');
await expect(element(by.id('element')).atIndex(0)).toNotExist();
await element(by.id('scrollView')).swipe('down', 'fast');
await element(by.type('UIPickerView')).setColumnToValue(1, "6");
await expect(element(by.id('element').withAncestor(by.id('parent_element')))).toNotExist();
await expect(element(by.id('element').withDescendant(by.id('child_element')))).toNotExist();
await waitFor(element(by.id('element'))).toBeVisible().withTimeout(2000);
await device.pressBack();
await waitFor(element(by.text('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
});
});
+424 -417
View File
@@ -3,428 +3,435 @@
// Definitions by: Tareq El-Masri <https://github.com/TareqElMasri>, Steve Chun <https://github.com/stevechun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare const detox: Detox.Detox;
declare const device: Detox.Device;
declare const element: Detox.Element;
declare const waitFor: Detox.WaitFor;
declare const expect: Detox.Expect<Detox.Expect<any>>;
declare const by: Detox.Matchers;
declare global {
const detox: Detox.Detox;
const device: Detox.Device;
const element: Detox.Element;
const waitFor: Detox.WaitFor;
const expect: Detox.Expect<Detox.Expect<any>>;
const by: Detox.Matchers;
declare namespace Detox {
interface Detox {
/**
* The setup phase happens inside detox.init(). This is the phase where detox reads its configuration, starts a server, loads its expection library and starts a simulator
* @param config
* @param options
* @example const config = require('../package.json').detox;
*
* before(async () => {
* await detox.init(config);
* });
*/
init(config: any, options?: DetoxInitOptions): Promise<void>;
/**
* Artifacts currently include only logs from the app process before each task
* @param args
*/
beforeEach(...args: any[]): Promise<void>;
/**
* Artifacts currently include only logs from the app process after each task
* @param args
*/
afterEach(...args: any[]): Promise<void>;
/**
* The cleanup phase should happen after all the tests have finished. This is the phase where detox-server shuts down.
* @example after(async () => {
* await detox.cleanup();
* });
*/
cleanup(): Promise<void>;
}
interface Device {
/**
* Launch the app
* @param config
* @example // Terminate the app and launch it again. If set to false, the simulator will try to bring app from background,
* // if the app isn't running, it will launch a new instance. default is false
* await device.launchApp({newInstance: true});
* // Grant or deny runtime permissions for your application.
* await device.launchApp({permissions: {calendar: 'YES'}});
* // Mock opening the app from URL to test your app's deep link handling mechanism.
* await device.launchApp({url: url});
*/
launchApp(config: DeviceLanchAppConfig): Promise<void>;
/**
* By default, terminateApp() with no params will terminate the app
* To terminate another app, specify its bundle id
* @param bundle
* @example await device.terminateApp('other.bundle.id');
*/
terminateApp(bundle?: string): Promise<void>;
/**
* Send application to background by bringing com.apple.springboard to the foreground.
* Combining sendToHome() with launchApp({newInstance: false}) will simulate app coming back from background.
* @example await device.sendToHome();
* await device.launchApp({newInstance: false});
*/
sendToHome(): Promise<void>;
/**
* If this is a React Native app, reload the React Native JS bundle. This action is much faster than device.launchApp(), and can be used if you just need to reset your React Native logic.
* @example await device.reloadReactNative()
*/
reloadReactNative(): Promise<void>;
/**
* By default, installApp() with no params will install the app file defined in the current configuration.
* To install another app, specify its path
* @param path
* @example await device.installApp('path/to/other/app');
*/
installApp(path?: any): Promise<void>;
/**
* By default, uninstallApp() with no params will uninstall the app defined in the current configuration.
* To uninstall another app, specify its bundle id
* @param bundle
* @example await device.installApp('other.bundle.id');
*/
uninstallApp(bundle?: string): Promise<void>;
/**
* Mock opening the app from URL. sourceApp is an optional parameter to specify source application bundle id.
* @param url
*/
openURL(url: {url: string, sourceApp?: string}): Promise<void>;
/**
* Mock handling of received user notification when app is in foreground.
* @param params
*/
sendUserNotification(...params: any[]): Promise<void>;
/**
* Mock handling of received user activity when app is in foreground.
* @param params
*/
sendUserActivity(...params: any[]): Promise<void>;
/**
* Takes "portrait" or "landscape" and rotates the device to the given orientation. Currently only available in the iOS Simulator.
* @param orientation
*/
setOrientation(orientation: Orientation): Promise<void>;
/**
* Note: setLocation is dependent on fbsimctl. if fbsimctl is not installed, the command will fail, it must be installed. Sets the simulator location to the given latitude and longitude.
* @param lat
* @param lon
* @example await device.setLocation(32.0853, 34.7818);
*/
setLocation(lat: number, lon: number): Promise<void>;
/**
* Disable EarlGrey's network synchronization mechanism on preffered endpoints. Usful if you want to on skip over synchronizing on certain URLs.
* @param urls
* @example await device.setURLBlacklist(['.*127.0.0.1.*']);
*/
setURLBlacklist(urls: string[]): Promise<void>;
/**
* Enable EarlGrey's synchronization mechanism (enabled by default). This is being reset on every new instance of the app.
* @example await device.enableSynchronization();
*/
enableSynchronization(): Promise<void>;
/**
* Disable EarlGrey's synchronization mechanism (enabled by default) This is being reset on every new instance of the app.
* @example await device.disableSynchronization();
*/
disableSynchronization(): Promise<void>;
/**
* Resets the Simulator to clean state (like the Simulator > Reset Content and Settings... menu item), especially removing previously set permissions.
* @example await device.resetContentAndSettings();
*/
resetContentAndSettings(): Promise<void>;
/**
* Returns the current device, ios or android.
* @example if (device.getPlatform() === 'ios') {
* await expect(loopSwitch).toHaveValue('1');
* }
*/
getPlatform(): "ios" | "android";
/**
* Simulate press back button (Android Only)
*/
pressBack(): Promise<void>;
/**
* Simulate shake (iOS Only)
*/
shake(): Promise<void>;
}
namespace Detox {
interface Detox {
/**
* The setup phase happens inside detox.init(). This is the phase where detox reads its configuration, starts a server, loads its expection library and starts a simulator
* @param config
* @param options
* @example const config = require('../package.json').detox;
*
* before(async () => {
* await detox.init(config);
* });
*/
init(config: any, options?: DetoxInitOptions): Promise<void>;
/**
* Artifacts currently include only logs from the app process before each task
* @param args
*/
beforeEach(...args: any[]): Promise<void>;
/**
* Artifacts currently include only logs from the app process after each task
* @param args
*/
afterEach(...args: any[]): Promise<void>;
/**
* The cleanup phase should happen after all the tests have finished. This is the phase where detox-server shuts down.
* @example after(async () => {
* await detox.cleanup();
* });
*/
cleanup(): Promise<void>;
}
interface Device {
/**
* Launch the app
* @param config
* @example // Terminate the app and launch it again. If set to false, the simulator will try to bring app from background,
* // if the app isn't running, it will launch a new instance. default is false
* await device.launchApp({newInstance: true});
* // Grant or deny runtime permissions for your application.
* await device.launchApp({permissions: {calendar: 'YES'}});
* // Mock opening the app from URL to test your app's deep link handling mechanism.
* await device.launchApp({url: url});
*/
launchApp(config: DeviceLanchAppConfig): Promise<void>;
/**
* By default, terminateApp() with no params will terminate the app
* To terminate another app, specify its bundle id
* @param bundle
* @example await device.terminateApp('other.bundle.id');
*/
terminateApp(bundle?: string): Promise<void>;
/**
* Send application to background by bringing com.apple.springboard to the foreground.
* Combining sendToHome() with launchApp({newInstance: false}) will simulate app coming back from background.
* @example await device.sendToHome();
* await device.launchApp({newInstance: false});
*/
sendToHome(): Promise<void>;
/**
* If this is a React Native app, reload the React Native JS bundle. This action is much faster than device.launchApp(), and can be used if you just need to reset your React Native logic.
* @example await device.reloadReactNative()
*/
reloadReactNative(): Promise<void>;
/**
* By default, installApp() with no params will install the app file defined in the current configuration.
* To install another app, specify its path
* @param path
* @example await device.installApp('path/to/other/app');
*/
installApp(path?: any): Promise<void>;
/**
* By default, uninstallApp() with no params will uninstall the app defined in the current configuration.
* To uninstall another app, specify its bundle id
* @param bundle
* @example await device.installApp('other.bundle.id');
*/
uninstallApp(bundle?: string): Promise<void>;
/**
* Mock opening the app from URL. sourceApp is an optional parameter to specify source application bundle id.
* @param url
*/
openURL(url: { url: string; sourceApp?: string }): Promise<void>;
/**
* Mock handling of received user notification when app is in foreground.
* @param params
*/
sendUserNotification(...params: any[]): Promise<void>;
/**
* Mock handling of received user activity when app is in foreground.
* @param params
*/
sendUserActivity(...params: any[]): Promise<void>;
/**
* Takes "portrait" or "landscape" and rotates the device to the given orientation. Currently only available in the iOS Simulator.
* @param orientation
*/
setOrientation(orientation: Orientation): Promise<void>;
/**
* Note: setLocation is dependent on fbsimctl. if fbsimctl is not installed, the command will fail, it must be installed. Sets the simulator location to the given latitude and longitude.
* @param lat
* @param lon
* @example await device.setLocation(32.0853, 34.7818);
*/
setLocation(lat: number, lon: number): Promise<void>;
/**
* Disable EarlGrey's network synchronization mechanism on preffered endpoints. Usful if you want to on skip over synchronizing on certain URLs.
* @param urls
* @example await device.setURLBlacklist(['.*127.0.0.1.*']);
*/
setURLBlacklist(urls: string[]): Promise<void>;
/**
* Enable EarlGrey's synchronization mechanism (enabled by default). This is being reset on every new instance of the app.
* @example await device.enableSynchronization();
*/
enableSynchronization(): Promise<void>;
/**
* Disable EarlGrey's synchronization mechanism (enabled by default) This is being reset on every new instance of the app.
* @example await device.disableSynchronization();
*/
disableSynchronization(): Promise<void>;
/**
* Resets the Simulator to clean state (like the Simulator > Reset Content and Settings... menu item), especially removing previously set permissions.
* @example await device.resetContentAndSettings();
*/
resetContentAndSettings(): Promise<void>;
/**
* Returns the current device, ios or android.
* @example if (device.getPlatform() === 'ios') {
* await expect(loopSwitch).toHaveValue('1');
* }
*/
getPlatform(): "ios" | "android";
/**
* Simulate press back button (Android Only)
*/
pressBack(): Promise<void>;
/**
* Simulate shake (iOS Only)
*/
shake(): Promise<void>;
}
type DetoxAny = Element & Actions<any> & WaitFor;
type DetoxAny = Element & Actions<any> & WaitFor;
interface Element {
(by: Matchers): DetoxAny;
interface Element {
(by: Matchers): DetoxAny;
/**
* Choose from multiple elements matching the same matcher using index
* @param index
* @example await element(by.text('Product')).atIndex(2);
*/
atIndex(index: number): DetoxAny;
}
interface Matchers {
(by: Matchers): Matchers;
/**
* Choose from multiple elements matching the same matcher using index
* @param index
* @example await element(by.text('Product')).atIndex(2);
*/
atIndex(index: number): DetoxAny;
}
interface Matchers {
(by: Matchers): Matchers;
/**
* by.id will match an id that is given to the view via testID prop.
* @param id
* @example // In a React Native component add testID like so:
* <TouchableOpacity testID={'tap_me'}>
* // Then match with by.id:
* await element(by.id('tap_me'));
*/
id(id: string): Matchers;
/**
* Find an element by text, useful for text fields, buttons.
* @param text
* @example await element(by.text('Tap Me'));
*/
text(text: string): Matchers;
/**
* Find an element by accessibilityLabel on iOS, or by contentDescription on Android.
* @param label
* @example await element(by.label('Welcome'));
*/
label(label: string): Matchers;
/**
* Find an element by native view type.
* @param nativeViewType
* @example await element(by.type('RCTImageView'));
*/
type(nativeViewType: string): Matchers;
/**
* Find an element with an accessibility trait. (iOS only)
* @example await element(by.traits(['button']));
*/
traits(traits: string[]): Matchers;
/**
* Find an element by a matcher with a parent matcher
* @param parentBy
* @example await element(by.id('Grandson883').withAncestor(by.id('Son883')));
*/
withAncestor(parentBy: Matchers): Matchers;
/**
* Find an element by a matcher with a child matcher
* @param childBy
* @example await element(by.id('Son883').withDescendant(by.id('Grandson883')));
*/
withDescendant(childBy: Matchers): Matchers;
/**
* Find an element by multiple matchers
* @param by
* @example await element(by.text('Product').and(by.id('product_name'));
*/
and(by: Matchers): Matchers;
}
interface Expect<R> {
(element: Element): Expect<any>;
/**
* Expect the view to be at least 75% visible.
* @example await expect(element(by.id('UniqueId204'))).toBeVisible();
*/
toBeVisible(): R;
/**
* Expect the view to not be visible.
* @example await expect(element(by.id('UniqueId205'))).toBeNotVisible();
*/
toBeNotVisible(): R;
/**
* Expect the view to exist in the UI hierarchy.
* @example await expect(element(by.id('UniqueId205'))).toExist();
*/
toExist(): R;
/**
* Expect the view to not exist in the UI hierarchy.
* @example await expect(element(by.id('RandomJunk959'))).toNotExist();
*/
toNotExist(): R;
/**
* In React Native apps, expect UI component of type <Text> to have text.
* In native iOS apps, expect UI elements of type UIButton, UILabel, UITextField or UITextViewIn to have inputText with text.
* @param text
* @example await expect(element(by.id('UniqueId204'))).toHaveText('I contain some text');
*/
toHaveText(text: string): R;
/**
* It searches by accessibilityLabel on iOS, or by contentDescription on Android.
* In React Native it can be set for both platforms by defining an accessibilityLabel on the view.
* @param label
* @example await expect(element(by.id('UniqueId204'))).toHaveLabel('Done');
*/
toHaveLabel(label: string): R;
/**
* In React Native apps, expect UI component to have testID with that id.
* In native iOS apps, expect UI element to have accesibilityIdentifier with that id.
* @param id
* @example await expect(element(by.text('I contain some text'))).toHaveId('UniqueId204');
*/
toHaveId(id: string): R;
/**
* Expect components like a Switch to have a value ('0' for off, '1' for on).
* @param value
* @example await expect(element(by.id('UniqueId533'))).toHaveValue('0');
*/
toHaveValue(value: any): R;
}
interface WaitFor {
/**
* This API polls using the given expectation continuously until the expectation is met. Use manual synchronization with waitFor only as a last resort.
* NOTE: Every waitFor call must set a timeout using withTimeout(). Calling waitFor without setting a timeout will do nothing.
* @example await waitFor(element(by.id('UniqueId336'))).toExist().withTimeout(2000);
*/
(element: Element): Expect<WaitFor>;
/**
* Waits for the condition to be met until the specified time (millis) have elapsed.
* @param millis number
* @example await waitFor(element(by.id('UniqueId336'))).toExist().withTimeout(2000);
*/
withTimeout(millis: number): Promise<void>;
/**
* Performs the action repeatedly on the element until an expectation is met
* @param by
* @example await waitFor(element(by.text('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
*/
whileElement(by: Matchers): DetoxAny;
}
interface Actions<R> {
/**
* Simulate tap on an element
* @example await element(by.id('tappable')).tap();
*/
tap(): Promise<Actions<R>>;
/**
* Simulate long press on an element
* @example await element(by.id('tappable')).longPress();
*/
longPress(): Promise<Actions<R>>;
/**
* Simulate multiple taps on an element.
* @param times number
* @example await element(by.id('tappable')).multiTap(3);
*/
multiTap(times: number): Promise<Actions<R>>;
/**
* Simulate tap at a specific point on an element.
* Note: The point coordinates are relative to the matched element and the element size could changes on different devices or even when changing the device font size.
* @param point
* @example await element(by.id('tappable')).tapAtPoint({ x:5, y:10 });
*/
tapAtPoint(point: { x: number, y: number }): Promise<Actions<R>>;
/**
* Use the builtin keyboard to type text into a text field.
* @param text
* @example await element(by.id('textField')).typeText('passcode');
*/
typeText(text: string): Promise<Actions<R>>;
/**
* Paste text into a text field.
* @param text
* @example await element(by.id('textField')).replaceText('passcode again');
*/
replaceText(text: string): Promise<Actions<R>>;
/**
* Clear text from a text field.
* @example await element(by.id('textField')).clearText();
*/
clearText(): Promise<Actions<R>>;
/**
*
* @param pixels
* @param direction
* @example
* await element(by.id('scrollView')).scroll(100, 'down');
* await element(by.id('scrollView')).scroll(100, 'up');
*/
scroll(pixels: number, direction: Direction): Promise<Actions<R>>;
/**
* Scroll to edge.
* @param edge
* @example await element(by.id('scrollView')).scrollTo('bottom');
* await element(by.id('scrollView')).scrollTo('top');
*/
scrollTo(edge: Direction): Promise<Actions<R>>;
/**
*
* @param direction
* @param speed
* @param percentage
* @example await element(by.id('scrollView')).swipe('down');
* await element(by.id('scrollView')).swipe('down', 'fast');
* await element(by.id('scrollView')).swipe('down', 'fast', 0.5);
*/
swipe(direction: Direction, speed?: Speed, percentage?: number): Promise<Actions<R>>;
/**
* (iOS Only) column - number of datepicker column (starts from 0) value - string value in setted column (must be correct)
* @param column
* @param value
* @example await expect(element(by.type('UIPickerView'))).toBeVisible();
* await element(by.type('UIPickerView')).setColumnToValue(1,"6");
* await element(by.type('UIPickerView')).setColumnToValue(2,"34");
*/
setColumnToValue(column: number, value: string): Promise<Actions<R>>;
}
/**
* by.id will match an id that is given to the view via testID prop.
* @param id
* @example // In a React Native component add testID like so:
* <TouchableOpacity testID={'tap_me'}>
* // Then match with by.id:
* await element(by.id('tap_me'));
*/
id(id: string): Matchers;
/**
* Find an element by text, useful for text fields, buttons.
* @param text
* @example await element(by.text('Tap Me'));
*/
text(text: string): Matchers;
/**
* Find an element by accessibilityLabel on iOS, or by contentDescription on Android.
* @param label
* @example await element(by.label('Welcome'));
*/
label(label: string): Matchers;
/**
* Find an element by native view type.
* @param nativeViewType
* @example await element(by.type('RCTImageView'));
*/
type(nativeViewType: string): Matchers;
/**
* Find an element with an accessibility trait. (iOS only)
* @example await element(by.traits(['button']));
*/
traits(traits: string[]): Matchers;
/**
* Find an element by a matcher with a parent matcher
* @param parentBy
* @example await element(by.id('Grandson883').withAncestor(by.id('Son883')));
*/
withAncestor(parentBy: Matchers): Matchers;
/**
* Find an element by a matcher with a child matcher
* @param childBy
* @example await element(by.id('Son883').withDescendant(by.id('Grandson883')));
*/
withDescendant(childBy: Matchers): Matchers;
/**
* Find an element by multiple matchers
* @param by
* @example await element(by.text('Product').and(by.id('product_name'));
*/
and(by: Matchers): Matchers;
}
interface Expect<R> {
(element: Element): Expect<any>;
/**
* Expect the view to be at least 75% visible.
* @example await expect(element(by.id('UniqueId204'))).toBeVisible();
*/
toBeVisible(): R;
/**
* Expect the view to not be visible.
* @example await expect(element(by.id('UniqueId205'))).toBeNotVisible();
*/
toBeNotVisible(): R;
/**
* Expect the view to exist in the UI hierarchy.
* @example await expect(element(by.id('UniqueId205'))).toExist();
*/
toExist(): R;
/**
* Expect the view to not exist in the UI hierarchy.
* @example await expect(element(by.id('RandomJunk959'))).toNotExist();
*/
toNotExist(): R;
/**
* In React Native apps, expect UI component of type <Text> to have text.
* In native iOS apps, expect UI elements of type UIButton, UILabel, UITextField or UITextViewIn to have inputText with text.
* @param text
* @example await expect(element(by.id('UniqueId204'))).toHaveText('I contain some text');
*/
toHaveText(text: string): R;
/**
* It searches by accessibilityLabel on iOS, or by contentDescription on Android.
* In React Native it can be set for both platforms by defining an accessibilityLabel on the view.
* @param label
* @example await expect(element(by.id('UniqueId204'))).toHaveLabel('Done');
*/
toHaveLabel(label: string): R;
/**
* In React Native apps, expect UI component to have testID with that id.
* In native iOS apps, expect UI element to have accesibilityIdentifier with that id.
* @param id
* @example await expect(element(by.text('I contain some text'))).toHaveId('UniqueId204');
*/
toHaveId(id: string): R;
/**
* Expect components like a Switch to have a value ('0' for off, '1' for on).
* @param value
* @example await expect(element(by.id('UniqueId533'))).toHaveValue('0');
*/
toHaveValue(value: any): R;
}
interface WaitFor {
/**
* This API polls using the given expectation continuously until the expectation is met. Use manual synchronization with waitFor only as a last resort.
* NOTE: Every waitFor call must set a timeout using withTimeout(). Calling waitFor without setting a timeout will do nothing.
* @example await waitFor(element(by.id('UniqueId336'))).toExist().withTimeout(2000);
*/
(element: Element): Expect<WaitFor>;
/**
* Waits for the condition to be met until the specified time (millis) have elapsed.
* @param millis number
* @example await waitFor(element(by.id('UniqueId336'))).toExist().withTimeout(2000);
*/
withTimeout(millis: number): Promise<void>;
/**
* Performs the action repeatedly on the element until an expectation is met
* @param by
* @example await waitFor(element(by.text('Text5'))).toBeVisible().whileElement(by.id('ScrollView630')).scroll(50, 'down');
*/
whileElement(by: Matchers): DetoxAny;
}
interface Actions<R> {
/**
* Simulate tap on an element
* @example await element(by.id('tappable')).tap();
*/
tap(): Promise<Actions<R>>;
/**
* Simulate long press on an element
* @example await element(by.id('tappable')).longPress();
*/
longPress(): Promise<Actions<R>>;
/**
* Simulate multiple taps on an element.
* @param times number
* @example await element(by.id('tappable')).multiTap(3);
*/
multiTap(times: number): Promise<Actions<R>>;
/**
* Simulate tap at a specific point on an element.
* Note: The point coordinates are relative to the matched element and the element size could changes on different devices or even when changing the device font size.
* @param point
* @example await element(by.id('tappable')).tapAtPoint({ x:5, y:10 });
*/
tapAtPoint(point: { x: number; y: number }): Promise<Actions<R>>;
/**
* Use the builtin keyboard to type text into a text field.
* @param text
* @example await element(by.id('textField')).typeText('passcode');
*/
typeText(text: string): Promise<Actions<R>>;
/**
* Paste text into a text field.
* @param text
* @example await element(by.id('textField')).replaceText('passcode again');
*/
replaceText(text: string): Promise<Actions<R>>;
/**
* Clear text from a text field.
* @example await element(by.id('textField')).clearText();
*/
clearText(): Promise<Actions<R>>;
/**
*
* @param pixels
* @param direction
* @example
* await element(by.id('scrollView')).scroll(100, 'down');
* await element(by.id('scrollView')).scroll(100, 'up');
*/
scroll(pixels: number, direction: Direction): Promise<Actions<R>>;
/**
* Scroll to edge.
* @param edge
* @example await element(by.id('scrollView')).scrollTo('bottom');
* await element(by.id('scrollView')).scrollTo('top');
*/
scrollTo(edge: Direction): Promise<Actions<R>>;
/**
*
* @param direction
* @param speed
* @param percentage
* @example await element(by.id('scrollView')).swipe('down');
* await element(by.id('scrollView')).swipe('down', 'fast');
* await element(by.id('scrollView')).swipe('down', 'fast', 0.5);
*/
swipe(
direction: Direction,
speed?: Speed,
percentage?: number
): Promise<Actions<R>>;
/**
* (iOS Only) column - number of datepicker column (starts from 0) value - string value in setted column (must be correct)
* @param column
* @param value
* @example await expect(element(by.type('UIPickerView'))).toBeVisible();
* await element(by.type('UIPickerView')).setColumnToValue(1,"6");
* await element(by.type('UIPickerView')).setColumnToValue(2,"34");
*/
setColumnToValue(
column: number,
value: string
): Promise<Actions<R>>;
}
type Direction = "left" | "right" | "top" | "bottom" | "up" | "down";
type Orientation = "portrait" | "landscape";
type Speed = "fast" | "slow";
interface LanguageAndLocale {
language?: string;
locale?: string;
}
interface DetoxInitOptions {
/**
* Detox exports device, expect, element, by and waitFor as globals by default, if you want to control their initialization manually, set init detox with initGlobals set to false.
* This is useful when during E2E tests you also need to run regular expectations in node. jest Expect for instance, will not be overriden by Detox when this option is used.
*/
initGlobals?: boolean;
/**
* By default await detox.init(config); will launch the installed app. If you wish to control when your app is launched, add {launchApp: false} param to your init.
*/
launchApp?: boolean;
}
interface DeviceLanchAppConfig {
/**
* Restart the app
* Terminate the app and launch it again. If set to false, the simulator will try to bring app from background, if the app isn't running, it will launch a new instance. default is false
*/
newInstance?: boolean;
/**
* Set runtime permissions
* Grant or deny runtime permissions for your application.
*/
permissions?: any;
/**
* Launch from URL
* Mock opening the app from URL to test your app's deep link handling mechanism.
*/
url?: any;
/**
* Launch with user notifications
*/
userNotification?: any;
/**
* Launch with user activity
*/
userActivity?: any;
/**
* Launch into a fresh installation
* A flag that enables relaunching into a fresh installation of the app (it will uninstall and install the binary again), default is false.
*/
delete?: boolean;
/**
* Detox can start the app with additional launch arguments
* The added launchArgs will be passed through the launch command to the device and be accessible via [[NSProcessInfo processInfo] arguments]
*/
launchArgs?: any;
/**
* Launch config for specifying the native language and locale
*/
languageAndLocale?: LanguageAndLocale;
type Direction = "left" | "right" | "top" | "bottom" | "up" | "down";
type Orientation = "portrait" | "landscape";
type Speed = "fast" | "slow";
interface LanguageAndLocale {
language?: string;
locale?: string;
}
interface DetoxInitOptions {
/**
* Detox exports device, expect, element, by and waitFor as globals by default, if you want to control their initialization manually, set init detox with initGlobals set to false.
* This is useful when during E2E tests you also need to run regular expectations in node. jest Expect for instance, will not be overriden by Detox when this option is used.
*/
initGlobals?: boolean;
/**
* By default await detox.init(config); will launch the installed app. If you wish to control when your app is launched, add {launchApp: false} param to your init.
*/
launchApp?: boolean;
}
interface DeviceLanchAppConfig {
/**
* Restart the app
* Terminate the app and launch it again. If set to false, the simulator will try to bring app from background, if the app isn't running, it will launch a new instance. default is false
*/
newInstance?: boolean;
/**
* Set runtime permissions
* Grant or deny runtime permissions for your application.
*/
permissions?: any;
/**
* Launch from URL
* Mock opening the app from URL to test your app's deep link handling mechanism.
*/
url?: any;
/**
* Launch with user notifications
*/
userNotification?: any;
/**
* Launch with user activity
*/
userActivity?: any;
/**
* Launch into a fresh installation
* A flag that enables relaunching into a fresh installation of the app (it will uninstall and install the binary again), default is false.
*/
delete?: boolean;
/**
* Detox can start the app with additional launch arguments
* The added launchArgs will be passed through the launch command to the device and be accessible via [[NSProcessInfo processInfo] arguments]
*/
launchArgs?: any;
/**
* Launch config for specifying the native language and locale
*/
languageAndLocale?: LanguageAndLocale;
}
}
}
export { by, detox, device, element, expect, waitFor };
+9
View File
@@ -0,0 +1,9 @@
interface DetoxJestAdapter {
detox: Detox.Detox;
beforeEach: () => Promise<void>;
afterAll: () => Promise<void>;
}
declare const adapter: DetoxJestAdapter;
export default adapter;
+9
View File
@@ -0,0 +1,9 @@
interface DetoxMochaAdapter {
detox: Detox.Detox;
beforeEach: (context: any) => Promise<void>;
afterEach: (context: any) => Promise<void>;
}
declare const adapter: DetoxMochaAdapter;
export default adapter;
+40
View File
@@ -0,0 +1,40 @@
declare var describe: (test: string, callback: () => void) => void;
declare var beforeAll: (callback: () => void) => void;
declare var afterAll: (callback: () => void) => void;
declare var test: (test: string, callback: () => void) => void;
describe("Test", () => {
beforeAll(async () => {
await device.reloadReactNative();
});
afterAll(async () => {
await element(by.id("element")).clearText();
});
test("Test", async () => {
await element(by.id("element")).replaceText("text");
await element(by.id("element")).tap();
await element(by.id("element")).scroll(50, "down");
await element(by.id("scrollView")).scrollTo("bottom");
await expect(element(by.id("element")).atIndex(0)).toNotExist();
await element(by.id("scrollView")).swipe("down", "fast");
await element(by.type("UIPickerView")).setColumnToValue(1, "6");
await expect(
element(by.id("element").withAncestor(by.id("parent_element")))
).toNotExist();
await expect(
element(by.id("element").withDescendant(by.id("child_element")))
).toNotExist();
await waitFor(element(by.id("element")))
.toBeVisible()
.withTimeout(2000);
await device.pressBack();
await waitFor(element(by.text("Text5")))
.toBeVisible()
.whileElement(by.id("ScrollView630"))
.scroll(50, "down");
});
});
@@ -0,0 +1,28 @@
declare var beforeAll: (callback: () => void) => void;
declare var beforeEach: (callback: () => void) => void;
declare var afterAll: (callback: () => void) => void;
import adapter from "detox/runners/jest/adapters";
// Normally the Detox configuration from the project's package.json like so:
// const config = require("./package.json").detox;
declare const config: any;
beforeAll(async () => {
await detox.init(config);
const initOptions: Detox.DetoxInitOptions = {
initGlobals: false,
launchApp: false,
};
await detox.init(config, initOptions);
});
beforeEach(async () => {
await adapter.beforeEach();
});
afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});
@@ -0,0 +1,32 @@
// tslint:disable:only-arrow-functions
declare var before: (callback: () => void) => void;
declare var beforeEach: (callback: () => void) => void;
declare var after: (callback: () => void) => void;
declare var afterEach: (callback: () => void) => void;
import adapter from "detox/runners/mocha/adapters";
// Normally the Detox configuration from the project's package.json like so:
// const config = require("./package.json").detox;
declare const config: any;
// Normally, the beforeEach and afterEach function should take `this` as its argument,
// but `this` cannot be used since it doesn't have a type signature (and therefore always implicltly any)
declare const context: any;
before(async function() {
await detox.init(config);
});
beforeEach(async function() {
await adapter.beforeEach(context);
});
afterEach(async function() {
await adapter.afterEach(context);
});
after(async function() {
await detox.cleanup();
});
+42
View File
@@ -0,0 +1,42 @@
declare var describe: (test: string, callback: () => void) => void;
declare var beforeAll: (callback: () => void) => void;
declare var afterAll: (callback: () => void) => void;
declare var test: (test: string, callback: () => void) => void;
import { by, device, element, expect, waitFor } from "detox";
describe("Test", () => {
beforeAll(async () => {
await device.reloadReactNative();
});
afterAll(async () => {
await element(by.id("element")).clearText();
});
test("Test", async () => {
await element(by.id("element")).replaceText("text");
await element(by.id("element")).tap();
await element(by.id("element")).scroll(50, "down");
await element(by.id("scrollView")).scrollTo("bottom");
await expect(element(by.id("element")).atIndex(0)).toNotExist();
await element(by.id("scrollView")).swipe("down", "fast");
await element(by.type("UIPickerView")).setColumnToValue(1, "6");
await expect(
element(by.id("element").withAncestor(by.id("parent_element")))
).toNotExist();
await expect(
element(by.id("element").withDescendant(by.id("child_element")))
).toNotExist();
await waitFor(element(by.id("element")))
.toBeVisible()
.withTimeout(2000);
await device.pressBack();
await waitFor(element(by.text("Text5")))
.toBeVisible()
.whileElement(by.id("ScrollView630"))
.scroll(50, "down");
});
});
+8 -7
View File
@@ -1,24 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"lib": ["es6"],
"target": "ES2015",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detox-tests.ts"
"runners/jest/adapters/index.d.ts",
"runners/mocha/adapters/index.d.ts",
"test/detox-global-tests.ts",
"test/detox-module-tests.ts",
"test/detox-jest-setup-tests.ts",
"test/detox-mocha-setup-tests.ts"
]
}
+191 -55
View File
@@ -7,6 +7,7 @@
// Marius Meisenzahl <https://github.com/meisenzahl>
// Rob Moran <https://github.com/thegecko>
// Cameron Diver <https://github.com/CameronDiver>
// Pascal Sthamer <https://github.com/p4sca1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -15,8 +16,16 @@
import * as stream from 'stream';
import * as events from 'events';
// The modem parameter is an instance of docker-modem, which is missing type declarations.
// https://github.com/apocas/docker-modem
declare namespace Dockerode {
interface Container {
class Container {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(options: {}, callback: Callback<ContainerInspectInfo>): void;
inspect(callback: Callback<ContainerInspectInfo>): void;
inspect(options?: {}): Promise<ContainerInspectInfo>;
@@ -100,18 +109,20 @@ declare namespace Dockerode {
logs(callback: Callback<NodeJS.ReadableStream>): void;
logs(options?: ContainerLogsOptions): Promise<NodeJS.ReadableStream>;
stats(options: {}, callback: Callback<any>): void;
stats(callback: Callback<any>): void;
stats(options?: {}): Promise<any>;
stats(options: {}, callback: Callback<ContainerStats>): void;
stats(callback: Callback<ContainerStats>): void;
stats(options?: {}): Promise<ContainerStats>;
attach(options: {}, callback: Callback<NodeJS.ReadableStream>): void;
attach(options: {}): Promise<NodeJS.ReadableStream>;
modem: any;
id?: string;
attach(options: {}, callback: Callback<NodeJS.ReadWriteStream>): void;
attach(options: {}): Promise<NodeJS.ReadWriteStream>;
}
interface Image {
class Image {
constructor(modem: any, name: string);
modem: any;
id: string;
inspect(callback: Callback<ImageInspectInfo>): void;
inspect(): Promise<ImageInspectInfo>;
@@ -132,24 +143,28 @@ declare namespace Dockerode {
remove(options: {}, callback: Callback<ImageRemoveInfo>): void;
remove(callback: Callback<ImageRemoveInfo>): void;
remove(options?: {}): Promise<any>;
modem: any;
id?: string;
}
interface Volume {
class Volume {
constructor(modem: any, name: string);
modem: any;
name: string;
inspect(callback: Callback<any>): void;
inspect(): Promise<any>;
remove(options: {}, callback: Callback<any>): void;
remove(callback: Callback<any>): void;
remove(options?: {}): Promise<any>;
modem: any;
name?: string;
}
interface Service {
class Service {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(callback: Callback<any>): void;
inspect(): Promise<any>;
@@ -159,20 +174,24 @@ declare namespace Dockerode {
update(options: {}, callback: Callback<any>): void;
update(options: {}): Promise<any>;
modem: any;
id?: string;
}
interface Task {
class Task {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(callback: Callback<any>): void;
inspect(): Promise<any>;
modem: any;
id?: string;
}
interface Node {
class Node {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(callback: Callback<any>): void;
inspect(): Promise<any>;
@@ -183,12 +202,11 @@ declare namespace Dockerode {
remove(options: {}, callback: Callback<any>): void;
remove(callback: Callback<any>): void;
remove(options?: {}): Promise<any>;
modem: any;
id?: string;
}
interface Plugin {
class Plugin {
constructor(modem: any, name: string, remote?: any);
modem: any;
name: string;
remote: any;
@@ -227,7 +245,12 @@ declare namespace Dockerode {
upgrade(auth: any, options?: {}): Promise<any>;
}
interface Secret {
class Secret {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(callback: Callback<SecretInfo>): void;
inspect(): Promise<SecretInfo>;
@@ -238,12 +261,14 @@ declare namespace Dockerode {
remove(options: {}, callback: Callback<any>): void;
remove(callback: Callback<any>): void;
remove(options?: {}): Promise<any>;
modem: any;
id?: string;
}
interface Network {
class Network {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(callback: Callback<any>): void;
inspect(): Promise<any>;
@@ -258,12 +283,14 @@ declare namespace Dockerode {
disconnect(options: {}, callback: Callback<any>): void;
disconnect(callback: Callback<any>): void;
disconnect(options?: {}): Promise<any>;
modem: any;
id?: string;
}
interface Exec {
class Exec {
constructor(modem: any, id: string);
modem: any;
id: string;
inspect(callback: Callback<any>): void;
inspect(): Promise<any>;
@@ -272,9 +299,6 @@ declare namespace Dockerode {
resize(options: {}, callback: Callback<any>): void;
resize(options: {}): Promise<any>;
modem: any;
id?: string;
}
interface ImageInfo {
@@ -446,20 +470,99 @@ declare namespace Dockerode {
GlobalIPv6Address: string;
GlobalIPv6PrefixLen: number;
MacAddress: string;
}
};
};
Node?: {
ID: string;
IP: string;
Addr: string;
Name: string;
Cpus: number;
Memory: number;
Labels: any;
}
ID: string;
IP: string;
Addr: string;
Name: string;
Cpus: number;
Memory: number;
Labels: any;
};
};
}
interface NetworkStats {
[name: string]: {
rx_bytes: number;
rx_dropped: number;
rx_errors: number;
rx_packets: number;
tx_bytes: number;
tx_dropped: number;
tx_errors: number;
tx_packets: number;
};
}
interface CPUStats {
cpu_usage: {
percpu_usage: number[];
usage_in_usermode: number;
total_usage: number;
usage_in_kernelmode: number;
};
system_cpu_usage: number;
online_cpus: number;
throttling_data: {
periods: number;
throttled_periods: number;
throttled_time: number;
};
}
interface MemoryStats {
stats: {
total_pgmajfault: number;
cache: number;
mapped_file: number;
total_inactive_file: number;
pgpgout: number;
rss: number;
total_mapped_file: number;
writeback: number;
unevictable: number;
pgpgin: number;
total_unevictable: number;
pgmajfault: number;
total_rss: number;
total_rss_huge: number;
total_writeback: number;
total_inactive_anon: number;
rss_huge: number;
hierarchical_memory_limit: number;
total_pgfault: number;
total_active_file: number;
active_anon: number;
total_active_anon: number;
total_pgpgout: number;
total_cache: number;
inactive_anon: number;
active_file: number;
pgfault: number;
inactive_file: number;
total_pgpgin: number;
};
max_usage: number;
usage: number;
failcnt: number;
limit: number;
}
interface ContainerStats {
read: string;
pid_stats: {
current: number;
};
networks: NetworkStats;
memory_stats: MemoryStats;
blkio_stats: {};
cpu_stats: CPUStats;
precpu_stats: CPUStats;
}
interface HostConfig {
AutoRemove: boolean;
Binds: string[];
@@ -652,13 +755,45 @@ declare namespace Dockerode {
GlobalIPv6Address?: string;
GlobalIPV6PrefixLen?: number;
MacAddress?: string;
DriverOpts?: {[key: string]: string};
DriverOpts?: { [key: string]: string };
}
interface EndpointsConfig {
[key: string]: EndpointSettings;
}
type MountType =
| "bind"
| "volume"
| "tmpfs";
type MountConsistency =
| "default"
| "consistent"
| "cached"
| "delegated";
type MountPropagation =
| "private"
| "rprivate"
| "shared"
| "rshared"
| "slave"
| "rslave";
interface MountSettings {
Target: string;
Source: string;
Type: MountType;
ReadOnly ?: boolean;
Consistency ?: MountConsistency;
BindOptions ?: {
Propagation: MountPropagation;
};
}
type MountConfig = MountSettings[];
interface ContainerCreateOptions {
name?: string;
Hostname?: string;
@@ -715,6 +850,7 @@ declare namespace Dockerode {
DnsSearch?: string[];
ExtraHosts?: any;
VolumesFrom?: string[];
Mounts?: MountConfig;
CapAdd?: string[];
CapDrop?: string[];
GroupAdd?: string[];
@@ -894,8 +1030,8 @@ declare namespace Dockerode {
}
interface ImageBuildContext {
context: string;
src: string[];
context: string;
src: string[];
}
interface DockerVersion {
@@ -906,7 +1042,7 @@ declare namespace Dockerode {
Details: {
ApiVersion: string;
Arch: string;
BuilTime: Date;
BuildTime: Date;
Experimental: string;
GitCommit: string;
GoVersion: string;
+88
View File
@@ -0,0 +1,88 @@
function customActions() {
const actionId = dynaTrace.enterAction("my custom action", "click");
dynaTrace.leaveAction(actionId);
}
function customVisit() {
dynaTrace.tagVisit("My Custom Visit");
/** after some code execution we can end the visit early */
dynaTrace.endVisit();
}
function signal() {
dynaTrace.signalLoadStart();
dynaTrace.signalLoadEnd();
dynaTrace.signalOnLoadStart();
dynaTrace.signalOnLoadEnd();
dynaTrace.sendSignal(false, false, true);
}
function load() {
dynaTrace.setLoadEndManually();
dynaTrace.incrementOnLoadEndMarkers();
}
function automaticDetection() {
dynaTrace.setAutomaticActionDetection(false);
}
function reporting() {
dynaTrace.reportError(" Custom error");
const actionId = dynaTrace.enterAction("second action", "keypress");
dynaTrace.reportError("Second custom error", actionId);
dynaTrace.reportEvent("My Event");
dynaTrace.reportString("My Key", "Custom value");
dynaTrace.reportValue("Value Key", 2);
dynaTrace.reportWarning("Warning");
}
function thirdParty() {
const url = "http://somescript.com";
dynaTrace.startThirdParty("s", url);
dynaTrace.stopThirdParty(url, true, Date.now() - 1000, Date.now());
}
function listener() {
const clickListener = (key: string) => ({});
dynaTrace.addPageLeavingListener(clickListener);
}
function streaming() {
dynaTrace.addStreamingNode(
"http://youtube.com",
120,
true,
false,
120,
30,
10,
5,
"_info_"
);
}
function userInput() {
const userInput = dynaTrace.beginUserInput("", "click", "RETURN", 23);
dynaTrace.endUserInput(userInput);
}
function Xhr() {
const enterActionId = dynaTrace.enterXhrAction(
"Angular Http request",
0,
false
);
dynaTrace.enterXhrCallback(enterActionId);
dynaTrace.leaveXhrCallback(enterActionId);
dynaTrace.leaveXhrAction(enterActionId);
}
function appVersion() {
dynaTrace.setAppVersion("1.1.1");
}
function metadata() {
dynaTrace.setMetaData("some metadata", "value");
}
+234
View File
@@ -0,0 +1,234 @@
// Type definitions for dynatrace 1.0
// Project: https://www.dynatrace.com/
// Definitions by: Alvaro Cruz <https://github.com/alvaro450>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface dynaTrace {
/**
* @description disable automatic detection
* Use in conjuction with enterAction
* @example
* dynaTrace.setAutomaticActionDetection(false);
* dynaTrace.enterAction('action message', 'select', null, null);
*/
setAutomaticActionDetection(on: boolean): void;
/**
* @description capture load event manually.
* followed by a signalLoadEnd to complete the capture.
*/
setLoadEndManually(): void;
/**
* @description Signal load start. If load start can be determined more accurately
* than the automatic detection, this function can be used.
*/
signalLoadStart(): void;
/**
* @description Signals that the page has finished loading
*/
signalLoadEnd(): void;
/**
* @description Force signal sending to make certain that actions aren't lost.
* @param forceSync - Force synchronous sending of signal (if false, it'll be sent asynchronously)
* @param sendPreview - Force sending of preview signals which haven't been closed yet.
* @param killUnfinished - Kills unfinished actions and sends them immediately. Handle with care, actions might be inaccurate.
*/
sendSignal(
forceSync: boolean,
sendPreview: boolean,
killUnfinished: boolean
): void;
/**
* @description parentAction: optional id of parent action.
* - if parameter is not passed => appended to currently running action
* - if a number is passed => action is added as subaction to action with given id
* - if false => new root action is started.
* The function returns an internal tracking object that represents the action that was started.
* This tracking object must be passed to dynaTrace.leaveAction().
* @param name - name of the action
* @param type
* @param startTime - time in milliseconds. if null, current time is used.
* @param parentAction optional id of parent action. if parameter is not passed=> appended to
* currently running action, if false => root action, if a number is passed, action is added
* as subaction to action with given id.
* @returns id of created action
*/
enterAction(
name: string,
type: string,
time?: number,
parentAction?: number | boolean
): number;
/**
* @description stops the action that is represented by the given tracking object.
* @param actionId - id of action to leave. must be the value returned by enterAction
* @param time - end time in milliseconds
* @param startTime - optional start time in milliseconds (necessary if start time should be modified)
*/
leaveAction(actionId: number, time?: number, startTime?: number): void;
/**
* @description Reports an error message
* @param parentAction - parent action id. if not passed or null, error is added to current action
*/
reportError(error: string | Error, parentAction?: number): void;
/**
* @description Reports a warning message
* @param parentAction - parent action id. if not passed or null, error is added to current action
*/
reportWarning(warning: string, parentAction?: number): void;
/**
* @description Reports an event
* @param parentAction - parent action id. if not passed or null, error is added to current action
*/
reportEvent(msg: string, parentAction?: number): void;
/**
* @description Reports a key value pair to the server. The data can e.g. be used to create charts.
*/
reportValue(key: string, value: number): void;
/**
* @description Reports a key value pair to the server. The data can e.g. be used to create charts.
* The difference to the reportValue function is that here the value is a string.
*/
reportString(key: string, value: string): void;
/**
* @description The JavaScript ADK enables you to tag your visits with any value you want.
* Use tagVisit(visitName) to tag the current visit with the specified value
*/
tagVisit(visitName: string): void;
/**
* @description Indicates start of a third party resource
* @param type - i = image, s = script, c = custom
*/
startThirdParty(type: "i" | "s" | "c", url: string): void;
/**
* @description Indicates stop of a third party resource
* @param url - Complete URL of resource (must match URL provided in startThirdParty).
* @param success - True if the resource was loaded successfully, false if not.
* @param start - Absolute start time in milliseconds. When parameter is not passed or <= 0,
* time of startThirdParty call is used.
* @param stop - Absolute stop time in milliseconds. When parameter is not passed or <= 0,
* time of stopThirdParty call is used.
*/
stopThirdParty(
url: string,
success: boolean,
start?: number,
stop?: number
): void;
/**
* @description Adds a listener that is called when the user is leaving the page,
* but before the monitor signal is sent
* @param listener A function that will be called in case the user leaves the page.
*/
addPageLeavingListener(listener: (key: string) => {}): void;
/**
* @description Sends a Streaming Node to the Server
* @param source - URL of the streaming resource
* @param duration - duration of the streaming resource in seconds
* @param userTriggered - did the user trigger the playback or did it start automatically?
* @param watchedCompletely - did the streaming resource play to the end?
* @param maxPlayTime - maximum progress this streaming resource had in seconds
* @param playTime - the time this streaming resource was playing in seconds
* @param bufferingCount - amount of bufferings that occured during the playback
* @param bufferingTime - total time spent with buffering in seconds
* @param type - action type of the streaming node. Is used for classifying events
* on the serverside, e.g. _info_, _warn_, _error_
*/
addStreamingNode(
source: string,
duration: number,
userTriggered: boolean,
watchedCompletely: boolean,
maxPlayTime: number,
playTime: number,
bufferingCount: number,
bufferingTime: number,
type: "_info_" | "_warn_" | "_error_"
): void;
/**
* @description Indicates the start of a user input. User inputs must always
* be stopped by calling endUserInput. If an xhr call or a page load happens
* it is checked if a user input is active. If yes, the user input is set to
* have triggered the page action.
* @param domNode - Which triggered the action (button, etc) is used for determining its caption
* @param type - Type of the user input: 'click', 'keypress', 'scroll',...
* @param addInfo - Additional info for user input such as key, mouse button, etc ('F5', 'RETURN',...)
* @param validTime - How long should the user input be able to open actions? default is 30ms
*/
beginUserInput(
domNode: any,
type: string,
addInfo: string,
validTime: number
): any;
/**
* @description the user input object returned by beginUserInput
*/
endUserInput(userInputObject: any): void;
/**
* @description Initiate ajax action. Must be closed by leaveXhrAction afterwards.
* @param type Additional info about type of xhr (eg. framework name,etc)
* @param mode - The action mode: 0 .. just extend running ajax actions 1 .. extend any running action 2 ..
* extend any running action - visible subaction 3 .. start action if user input is present
* @param webSocket - Indicates if this action is a webSocket action or not
* @returns id of action
*/
enterXhrAction(type: string, mode: number, webSocket: boolean): number;
/**
* @description Indicates the end of an xhr action. Must be started by leaveXhrAction beforehand.
* @param id - id of action (must be the value returned by enterXhrAction)
*/
leaveXhrAction(id: number): void;
/**
* @description Indicates that an xhr callback is active (eg. XMLHttpRequest onreadystatechange).
* This is necessary to automatically add actions started during a callback as subactions.
* Xhr callback must be stopped by leaveXhrCallback.
* @param actionId - id of action where callback belongs to
*/
enterXhrCallback(actionId: number): void;
/**
* @description Indicates the end of an xhr callback. Must be called after enterXhrCallback.
* @param actionId - id of action where callback belongs to
*/
leaveXhrCallback(actionId: number): void;
/**
* @description Indicates the start of a load action. Frameworks often have their own load callback functions.
* This can be used when framework starts load before "DOMContentLoaded".
*/
signalOnLoadStart(): void;
/**
* @description Tells the JavaScript agent to wait for an additional call of signalOnLoadEnd.
* When the last call of signalOnLoadEnd is performed the "onload" action is closed.
* Note: if this function is called, signalOnLoadEnd MUST be called afterwards to indicated the end of one load.
* Otherwise there will be unexpected action behaviour.
*/
incrementOnLoadEndMarkers(): void;
/**
* @description Indicates the end of a load action. needs incrementOnLoadEndMarkers to be called before.
* As soon as the last signalOnLoadEnd is called, the "onload" action is closed.
*/
signalOnLoadEnd(): void;
/**
* @description By default a visit ends after a configurable inactivity time (default is 30 min.).
* Using the ADK, a visit can be ended forcibly, for example when a user logs out from an application.
* Simply call dynaTrace.endVisit() and the visit ends without waiting for the inactivity time.
* For correlation purposes the visit shows as active in the client for about three minutes,
* but actions sent after dynaTrace.endVisit() are added to a new visit.
* End the current UEM visit. This is useful for "logout" buttons, so that,
* when the user logs out, the user's visit can also be closed by calling this method.
*/
endVisit(): void;
/**
* @description Set the application version for this visit.
* This will be read on the server side and included as part of each visit for easy splitting.
* @param appVersion - The version string to be set.
*/
setAppVersion(appVersion: string): void;
/**
* @description Set meta-data for the page via a key/value pair.
* @param key - The readable key for the value
* @param value - The value to associate with the identifier
*/
setMetaData(key: string, value: string): void;
}
declare let dynaTrace: dynaTrace;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"dynatrace-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -13,25 +13,6 @@ function ignoreFunction(path: string) {
return true;
}
// this is the obsolete API and will be removed in a future version
packager({
dir: ".",
name: "myapplication",
platform: "win32",
arch: "all",
electronVersion: "0.34.0",
win32metadata: {
CompanyName: "Acme CO",
FileDescription: "My application",
OriginalFilename: "myapp.exe",
ProductName: "Application",
InternalName: "roadrunner",
"requested-execution-level": "highestAvailable",
"application-manifest": "manifest.xml"
}
}, callback);
function onCompleted(appPaths: string | string[]) {
}
@@ -102,7 +83,7 @@ packager({
afterExtract: [
completeFunction
],
afterPrune: [
afterPrune: [
completeFunction
],
appCopyright: "Copyright",
@@ -122,7 +103,6 @@ packager({
ignore: /ab+c/,
out: "out",
overwrite: true,
packageManager: false,
prune: true,
quiet: true,
tmpdir: "/tmp",
@@ -157,7 +137,6 @@ packager({
new RegExp('abc')
],
overwrite: false,
packageManager: "npm",
platform: "darwin",
prune: false,
quiet: false,
@@ -184,7 +163,14 @@ packager({
strictSSL: false
},
ignore: ignoreFunction,
packageManager: "cnpm",
platform: "linux"
}).then(onCompleted).catch(onError);
packager({
dir: ".",
arch: "mips64el",
electronVersion: "1.8.8",
prebuiltAsar: "prebuilt.asar",
platform: "linux"
}).then(onCompleted).catch(onError);
@@ -200,11 +186,14 @@ packager({
quiet: true,
strictSSL: false
},
packageManager: "yarn",
platform: "mas",
extendInfo: {
foo: "bar"
},
osxNotarize: {
appleId: "My ID",
appleIdPassword: "Bad Password"
},
osxSign: {
identity: "myidentity",
entitlements: "path/to/my.entitlements",
+20 -21
View File
@@ -1,9 +1,10 @@
// Type definitions for electron-packager 12.0
// Type definitions for electron-packager 13.0
// Project: https://github.com/electron-userland/electron-packager
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
// Juan Jimenez-Anca <https://github.com/cortopy>
// John Kleinschmidt <https://github.com/jkleinsc>
// Brendan Forster <https://github.com/shiftkey>
// Mark Lee <https://github.com/malept>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -23,20 +24,6 @@ export = electronPackager;
*/
declare function electronPackager(opts: electronPackager.Options): Promise<string|string[]>;
/**
* This will:
* - Find or download the correct release of Electron
* - Use that version of electron to create a app in <out>/<appname>-<platform>-<arch>
*
* You should be able to launch the app on the platform you built for. If not, check your settings and try again.
*
* @param opts - Options to configure packaging.
* @param callback - Callback which is called when packaging is done or an error occured.
*
* @deprecated since version 12.0
*/
declare function electronPackager(opts: electronPackager.Options, callback: electronPackager.finalCallback): void;
declare namespace electronPackager {
/**
* Callback which is called when electron-packager is done.
@@ -48,8 +35,7 @@ declare namespace electronPackager {
type ignoreFunction = (path: string) => boolean;
type onCompleteFn = (buildPath: string, electronVersion: string, platform: string, arch: string, callbackFn: () => void) => void;
type arch = "ia32" | "x64" | "armv7l" | "arm64" |"all";
type packageManager = "npm" | "cnpm" | "yarn" | false;
type arch = "ia32" | "x64" | "armv7l" | "arm64" | "mips64el" | "all";
type platform = "linux" | "win32" | "darwin" | "mas" | "all";
interface AsarOptions {
@@ -65,6 +51,11 @@ declare namespace electronPackager {
strictSSL?: boolean;
}
interface ElectronNotarizeOptions {
appleId: string;
appleIdPassword: string;
}
interface ElectronOsXSignOptions {
identity?: string;
entitlements?: string;
@@ -116,6 +107,10 @@ declare namespace electronPackager {
* Whether to package the application's source code into an archive, using Electron's archive format
*/
asar?: boolean | AsarOptions;
/**
* The path to a prebuilt ASAR file.
*/
prebuiltAsar?: string;
/**
* The build version of the application. Defaults to the value of appVersion.
* Maps to the FileVersion metadata property on Windows, and CFBundleVersion on OS X.
@@ -160,10 +155,6 @@ declare namespace electronPackager {
* Whether to replace an already existing output directory for a given platform (true) or skip recreating it (false).
*/
overwrite?: boolean;
/**
* The package manager used to prune devDependencies modules from the outputted Electron app
*/
packageManager?: packageManager;
/**
* The target platform(s) to build for. Not required if the all option is set.
*/
@@ -202,6 +193,14 @@ declare namespace electronPackager {
* The bundle identifier to use in the application helper's plist.
*/
helperBundleId?: string;
/**
* Forces support for Mojave (macOS 10.14) dark mode in the packaged app.
*/
darwinDarkModeSupport?: boolean;
/**
* If present, notarizes OS X target apps when the host platform is OS X and XCode is installed.
*/
osxNotarize?: ElectronNotarizeOptions;
/**
* If present, signs OS X target apps when the host platform is OS X and XCode is installed.
*/
+25
View File
@@ -0,0 +1,25 @@
import emptyDir = require('empty-dir');
emptyDir('./', (err, isEmpty) => {
// $ExpectType ErrnoException
err;
// $ExpectType boolean
isEmpty;
});
// $ExpectType boolean
emptyDir.sync('./test/empty');
function filter(filepath: string) {
return !/(Thumbs\.db|\.DS_Store)$/i.test(filepath);
}
emptyDir('./', filter, (err, isEmpty) => {
// $ExpectType ErrnoException
err;
// $ExpectType boolean
isEmpty;
});
// $ExpectType boolean
emptyDir.sync('./test/empty', filter);
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for empty-dir 1.0
// Project: https://github.com/js-cli/js-empty-dir
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export = emptyDir;
declare function emptyDir(
dir: string,
cb: (err: NodeJS.ErrnoException, isEmpty: boolean) => void
): void;
declare function emptyDir(
dir: string,
filter: (path: string) => boolean,
cb: (err: NodeJS.ErrnoException, isEmpty: boolean) => void
): void;
declare namespace emptyDir {
function sync(dir: string, filter?: (path: string) => boolean): boolean;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"empty-dir-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+14
View File
@@ -0,0 +1,14 @@
import * as escapeGoat from 'escape-goat';
// $ExpectType string
escapeGoat.escape('🦄 & 🐐');
// $ExpectType string
escapeGoat.unescape('🦄 &amp; 🐐');
// $ExpectType string
escapeGoat.escape('Hello <em>World</em>');
const url = 'https://sindresorhus.com?x="🦄"';
// $ExpectType string
escapeGoat.escapeTag`<a href="${url}">Unicorn</a>`;
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for escape-goat 1.3
// Project: https://github.com/sindresorhus/escape-goat#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function escape(input: string): string;
export function unescape(input: string): string;
export function escapeTag(template: TemplateStringsArray, ...substitutions: any[]): string;
export function unescapeTag(template: TemplateStringsArray, ...substitutions: any[]): string;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"escape-goat-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -19,3 +19,27 @@ const client = new Eureka({
port: 32768,
}
});
// example configuration against newer Eureka (https://www.npmjs.com/package/eureka-js-client#400-bad-request-errors-from-eureka-server)
const newerClient = new Eureka({
// application instance information
instance: {
app: 'jqservice',
hostName: 'localhost',
ipAddr: '127.0.0.1',
port: {
$: 443,
'@enabled': true
},
vipAddress: 'jq.test.something.com',
dataCenterInfo: {
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
name: 'MyOwn',
},
},
eureka: {
// eureka server host / port
host: '192.168.99.100',
port: 32768,
}
});
+8 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for eureka-js-client 4.3
// Type definitions for eureka-js-client 4.4
// Project: https://github.com/jquatier/eureka-js-client
// Definitions by: Ilko Hoffmann <https://github.com/Schnillz>
// Definitions by: Ilko Hoffmann <https://github.com/Schnillz>, Karl O. <https://github.com/karl-run>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export class Eureka {
@@ -26,7 +26,7 @@ export namespace EurekaClient {
ipAddr: string;
vipAddress: string;
dataCenterInfo: DataCenterInfo;
port?: number;
port?: number | LegacyPortWrapper;
instanceId?: string;
appGroupName?: string;
sid?: string;
@@ -61,6 +61,10 @@ export namespace EurekaClient {
useLocalMetadata?: boolean;
preferIpAddress?: boolean;
}
interface LegacyPortWrapper {
'$': number;
'@enabled': boolean;
}
interface PortWrapper {
enabled: boolean;
port: number;
@@ -71,5 +75,6 @@ export namespace EurekaClient {
}
interface DataCenterInfo {
name: DataCenterName;
'@class'?: string;
}
}
+1 -1
View File
@@ -4529,7 +4529,7 @@ interface IUtilMisc {
* @param [context] Context to invoke callback in
* @param [crossOrigin] crossOrigin value to set image element to
*/
loadImage(url: string, callback: (image: HTMLImageElement) => void, context?: any, crossOrigin?: boolean): void;
loadImage(url: string, callback: (image: HTMLImageElement) => void, context?: any, crossOrigin?: string): void;
/**
* Creates corresponding fabric instances from their object representations
+11 -3
View File
@@ -1,6 +1,6 @@
import favicons, { Configuration } from "favicons";
import * as favicons from "favicons";
let config: Partial<Configuration> = {
let config: Partial<favicons.Configuration> = {
path: "/foo/bar"
};
@@ -19,7 +19,15 @@ favicons("path/to/file.png", config, (err, res) => {
}
});
favicons("file.png", (err, res) => {
favicons("file.png", (err: any, res: any) => {
html = res.html.join("");
for (const { name, contents } of [...res.files, ...res.images]) {
html = name + contents.toString();
}
});
favicons("file.png").then((res) => {
html = res.html.join("");
for (const { name, contents } of [...res.files, ...res.images]) {
+82 -73
View File
@@ -1,79 +1,84 @@
// Type definitions for favicons 5.1
// Type definitions for favicons 5.3
// Project: https://github.com/evilebottnawi/favicons/blob/master/package.json
// Definitions by: Mohsen Azimi <https://github.com/mohsen1>
// Definitions by: Mohsen Azimi <https://github.com/mohsen1>, Nikk Radetskiy <https://github.com/metsawyr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
export interface Configuration {
/** Path for overriding default icons path @default "/" */
path: string;
/** Your application's name @default null */
appName: string | null;
/** Your application's description @default null */
appDescription: string | null;
/** Your (or your developer's) name @default null */
developerName: string | null;
/** Your (or your developer's) URL @default null */
developerURL: string | null;
/** Primary text direction for name, short_name, and description @default "auto" */
dir: string;
/** Primary language for name and short_name @default "en-US */
lang: string;
/** Background colour for flattened icons @default "#fff" */
background: string;
/** Theme color user for example in Android's task switcher @default "#fff" */
theme_color: string;
/** Preferred display mode: "fullscreen", "standalone", "minimal-ui" or "browser" @default "standalone" */
display: "fullscreen" | "standalone" | "minimal-ui" | "browser";
/** Default orientation: "any", "natural", "portrait" or "landscape" @default "any" */
orientation: "any" | "natural" | "portrait" | "landscape";
/** Start URL when launching the application from a device @default "/?homescreen=1" */
start_url: string;
/** Your application's version string @default "1.0" */
version: string;
/** Print logs to console? @default false */
logging: boolean;
/**
* Platform Options:
* - offset - offset in percentage
* - background:
* * false - use default
* * true - force use default, e.g. set background for Android icons
* * color - set background for the specified icons
*/
icons: Partial<{
/* Create Android homescreen icon. */
android: boolean | { offset: string; background: string };
/* Create Apple touch icons. */
appleIcon: boolean | { offset: string; background: string };
/* Create Apple startup images. */
appleStartup: boolean | { offset: string; background: string };
/* Create Opera Coast icon. */
coast: boolean | { offset: string; background: string };
/* Create regular favicons. */
favicons: boolean;
/* Create Firefox OS icons. */
firefox: boolean | { offset: string; background: string };
/* Create Windows 8 tile icons. */
windows: boolean | { background: string };
/* Create Yandex browser icon. */
yandex: boolean | { background: string };
}>;
import { Duplex } from "stream";
declare namespace favicons {
interface Configuration {
/** Path for overriding default icons path @default "/" */
path: string;
/** Your application's name @default null */
appName: string | null;
/** Your application's description @default null */
appDescription: string | null;
/** Your (or your developer's) name @default null */
developerName: string | null;
/** Your (or your developer's) URL @default null */
developerURL: string | null;
/** Primary text direction for name, short_name, and description @default "auto" */
dir: string;
/** Primary language for name and short_name @default "en-US */
lang: string;
/** Background colour for flattened icons @default "#fff" */
background: string;
/** Theme color user for example in Android's task switcher @default "#fff" */
theme_color: string;
/** Preferred display mode: "fullscreen", "standalone", "minimal-ui" or "browser" @default "standalone" */
display: "fullscreen" | "standalone" | "minimal-ui" | "browser";
/** Default orientation: "any", "natural", "portrait" or "landscape" @default "any" */
orientation: "any" | "natural" | "portrait" | "landscape";
/** Start URL when launching the application from a device @default "/?homescreen=1" */
start_url: string;
/** Your application's version string @default "1.0" */
version: string;
/** Print logs to console? @default false */
logging: boolean;
/**
* Platform Options:
* - offset - offset in percentage
* - background:
* * false - use default
* * true - force use default, e.g. set background for Android icons
* * color - set background for the specified icons
*/
icons: Partial<{
/* Create Android homescreen icon. */
android: boolean | { offset: string; background: string };
/* Create Apple touch icons. */
appleIcon: boolean | { offset: string; background: string };
/* Create Apple startup images. */
appleStartup: boolean | { offset: string; background: string };
/* Create Opera Coast icon. */
coast: boolean | { offset: string; background: string };
/* Create regular favicons. */
favicons: boolean;
/* Create Firefox OS icons. */
firefox: boolean | { offset: string; background: string };
/* Create Windows 8 tile icons. */
windows: boolean | { background: string };
/* Create Yandex browser icon. */
yandex: boolean | { background: string };
}>;
}
interface FavIconResponse {
images: Array<{ name: string; contents: Buffer }>;
files: Array<{ name: string; contents: Buffer }>;
html: string[];
}
type Callback = (error: Error | null, response: FavIconResponse) => void;
/** You can programmatically access Favicons configuration (icon filenames, HTML, manifest files, etc) with this export */
const config: Configuration;
function stream(configuration?: Configuration): Duplex;
}
export interface FavIconResponse {
images: Array<{ name: string; contents: Buffer }>;
files: Array<{ name: string; contents: Buffer }>;
html: string[];
}
export type Callback = (error: Error | null, response: FavIconResponse) => void;
/** You can programmatically access Favicons configuration (icon filenames, HTML, manifest files, etc) with this export */
export const config: Configuration;
/**
* Generate favicons
* @param source Source image(s)
@@ -82,12 +87,16 @@ export const config: Configuration;
*/
declare function favicons(
source: string | Buffer | string[],
callback?: Callback
configuration?: Partial<favicons.Configuration>,
): Promise<favicons.FavIconResponse>;
declare function favicons(
source: string | Buffer | string[],
callback?: favicons.Callback
): void;
declare function favicons(
source: string | Buffer | string[],
configuration?: Partial<Configuration>,
callback?: Callback
configuration?: Partial<favicons.Configuration>,
callback?: favicons.Callback
): void;
export default favicons;
export = favicons;
+1 -1
View File
@@ -11,7 +11,7 @@ declare namespace fined {
interface PathSpec {
path?: string;
name?: string;
extensions?: string | string[] | { [extension: string]: string };
extensions?: string | string[] | { [extension: string]: string | null };
cwd?: string;
findUp?: boolean;
}
+2 -1
View File
@@ -144,7 +144,8 @@ function handleSignoutClick(event: MouseEvent) {
// Load the API and make an API call. Display the results on the screen.
function makeApiCall() {
gapi.client.people.people.get({
resourceName: 'people/me'
resourceName: 'people/me',
personFields: 'names'
}).then((resp) => {
const p = document.createElement('p');
const name = resp.result.names[0].givenName;
+1
View File
@@ -64,6 +64,7 @@
var request = gapi.client.people.people.connections.list({
'resourceName': 'people/me',
'pageSize': 10,
'personFields': 'names'
});
request.execute(function(resp) {
+4 -7
View File
@@ -1,6 +1,7 @@
// Type definitions for Google People API 1.0
// Project: https://developers.google.com/people/
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Joshua O'Brien <https://github.com/joshuaobrien>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -13,7 +14,7 @@ declare namespace gapi.client.people {
resourceName: string;
// Query parameters
requestMask?: RequestMask;
personFields: string;
}
function get(parameters: GetParameters): HttpRequest<Person>;
@@ -21,7 +22,7 @@ declare namespace gapi.client.people {
interface GetBatchGetParameters {
// Query parameters
resourcesName?: string;
requestMask?: RequestMask;
personFields: string;
}
function getBatchGet(parameters: GetBatchGetParameters): HttpRequest<BatchGetResponse>;
@@ -49,7 +50,7 @@ declare namespace gapi.client.people {
pageSize?: number;
sortOrder?: SortOrder;
syncToken?: string;
requestMask?: RequestMask;
personFields: string;
}
interface Response {
@@ -60,10 +61,6 @@ declare namespace gapi.client.people {
}
}
interface RequestMask {
includeField: string;
}
type SourceType = 'SOURCE_TYPE_UNSPECIFIED' | 'ACCOUNT' | 'PROFILE' | 'DOMAIN_PROFILE' | 'CONTACT';
interface Source {
+2 -1
View File
@@ -20,7 +20,8 @@ https://developers.google.com/api-client-library/javascript/reference/referenced
}).then(function() {
// 3. Initialize and make the API request.
return gapi.client.people.people.get({
resourceName: 'people/me'
resourceName: 'people/me',
personFields: 'name'
});
}).then(function(response) {
console.log(response.result);
+78
View File
@@ -0,0 +1,78 @@
import * as gdal from 'gdal';
// gdal.checksumImage(srcRasterBand, 0, 0, 512, 512);
gdal.config.get('GDAL_DATA');
gdal.config.set('GDAL_DATA', 'C:\\warmerda\\bld\\data');
/*gdal.contourGenerate({
src: srcRasterBand,
dst: dstRasterBand
});*/
gdal.decToDMS(60, 'lat');
gdal.decToDMS(60, 'lat', 2);
/*gdal.fillNodata({
});*/
let creationOptionsArray: string[];
creationOptionsArray = ['VRT_CREATION_OPTION=...'];
let creationOptionsObject: object;
creationOptionsObject = {
VRT_CREATION_OPTION: '...'
};
gdal.open('C:\\datasets\\ogr.shp');
gdal.open('C:\\datasets\\ogr.shp', 'r');
gdal.open('C:\\datasets\\ogr.shp', 'r', 'ESRI Shapefile');
gdal.open('C:\\datasets\\ogr.shp', 'r', ['ESRI Shapefile']);
gdal.open('C:\\datasets\\ogr.shp', 'r+');
gdal.open('C:\\datasets\\ogr.shp', 'r+', 'ESRI Shapefile');
gdal.open('C:\\datasets\\ogr.shp', 'r+', ['ESRI Shapefile']);
gdal.open('C:\\datasets\\raster.vrt', 'w', 'VRT');
gdal.open('C:\\datasets\\raster.vrt', 'w', 'VRT', 512, 512, 3, 1, creationOptionsArray);
gdal.open('C:\\datasets\\raster.vrt', 'w', 'VRT', 512, 512, 3, 1, creationOptionsObject);
gdal.open('C:\\datasets\\raster.vrt', 'w', ['VRT']);
gdal.open('C:\\datasets\\raster.vrt', 'w', ['VRT'], 512, 512, 3, 1, creationOptionsArray);
gdal.open('C:\\datasets\\raster.vrt', 'w', ['VRT'], 512, 512, 3, 1, creationOptionsObject);
/*let polygonizeOptions: gdal.PolygonizeOptions;
polygonizeOptions = {
src: srcRasterBand,
dst: dstRasterBand,
connectedness: 1,
mask: maskRasterBand,
pixValField: 1,
useFloats: true
};
gdal.polygonize(polygonizeOptions);
gdal.polygonize({
src: srcRasterBand,
dst: dstRasterBand,
pixValField: 1
});*/
gdal.quiet();
/*let reprojectImageOptions: gdal.ReprojectImageOptions;
reprojectImageOptions = {
src: srcRasterBand,
dst: dstRasterBand,
s_srs: sourceSRS,
t_srs: targetSRS
};
gdal.reprojectImage(reprojectImageOptions);
gdal.reprojectImage({
});
gdal.sieveFilter({
});
gdal.suggestedWarpOutput({
});*/
gdal.verbose();
+707
View File
@@ -0,0 +1,707 @@
// Type definitions for gdal 0.9
// Project: https://github.com/naturalatlas/node-gdal#readme
// Definitions by: Andrei Digori <https://github.com/andreidigori>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
export as namespace gdal;
/* Internal interfaces */
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
export type Resampling = 'NEAREST' | 'GAUSS' | 'CUBIC' | 'AVERAGE' | 'MODE' | 'AVERAGE_MAGPHASE' | 'NONE';
export interface XY {
x: number;
y: number;
}
export interface XYZ extends XY {
z: number;
}
export interface EnvelopeBounds {
minX: number;
maxX: number;
minY: number;
maxY: number;
}
export interface Envelope3DBounds extends EnvelopeBounds {
minZ: number;
maxZ: number;
}
export interface RasterBandStatistics {
min: number;
max: number;
mean: number;
std_dev: number;
}
export interface RasterBandPixelsWriteOptions {
buffer_width?: number;
buffer_height?: number;
pixel_space?: number;
line_space?: number;
}
export interface RasterBandPixelsReadOptions {
buffer_width?: number;
buffer_height?: number;
pixel_space?: number;
line_space?: number;
data_type?: string;
}
export interface ContourGenerateOptions {
src: RasterBand;
dst: Layer;
offset?: number;
interval?: number;
fixedLevels?: number[];
nodata?: number;
idField?: number;
elevField?: number;
}
export interface FillNoDataOptions {
src: RasterBand;
mask?: RasterBand;
searchDist: number;
smoothingIterations?: number;
}
export interface PolygonizeOptions {
src: RasterBand;
dst: Layer;
mask?: RasterBand;
pixValField: number;
connectedness?: number;
useFloats?: boolean;
}
export interface ReprojectImageOptions {
src: Dataset;
dst: Dataset;
s_srs: SpatialReference;
t_srs: SpatialReference;
resampling?: string;
cutline?: Geometry;
srcBands?: number[];
dstBands?: number[];
srcAlphaBand?: number;
dstAlphaBand?: number;
srcNodata?: number;
dstNodata?: number;
memoryLimit?: number;
maxError?: number;
multi?: boolean;
options?: string[] | object;
}
export interface SieveFilterOptions {
src: RasterBand;
dst: RasterBand;
mask?: RasterBand;
threshold: number;
connectedness?: number;
}
export interface SuggestedWarpOutputOptions {
src: Dataset;
s_srs: SpatialReference;
t_srs: SpatialReference;
maxError?: number;
}
/* From API: https://naturalatlas.github.io/node-gdal/ */
/* Constants */
// CPL Error Codes
export const CPLE_AppDefined: number;
export const CPLE_AssertionFailed: number;
export const CPLE_FileIO: number;
export const CPLE_IllegalArg: number;
export const CPLE_None: number;
export const CPLE_NotSupported: number;
export const CPLE_NoWriteAccess: number;
export const CPLE_ObjectNull: number;
export const CPLE_OpenFailed: number;
export const CPLE_OutOfMemory: number;
export const CPLE_UserInterrupt: number;
// CPL Error Levels
export const CE_Debug: number;
export const CE_Failure: number;
export const CE_Fatal: number;
export const CE_None: number;
export const CE_Warning: number;
// DCAP
export const DCAP_CREATE: string;
export const DCAP_CREATECOPY: string;
export const DCAP_VIRTUALIO: string;
// DMD
export const DMD_CREATIONDATATYPES: string;
export const DMD_CREATIONOPTIONLIST: string;
export const DMD_EXTENSION: string;
export const DMD_HELPTOPIC: string;
export const DMD_LONGNAME: string;
export const DMD_MIMETYPE: string;
// GCI
export const GCI_AlphaBand: string;
export const GCI_BlackBand: string;
export const GCI_BlueBand: string;
export const GCI_CyanBand: string;
export const GCI_GrayIndex: string;
export const GCI_GreenBand: string;
export const GCI_HueBand: string;
export const GCI_LightnessBand: string;
export const GCI_MagentaBand: string;
export const GCI_PaletteIndex: string;
export const GCI_RedBand: string;
export const GCI_SaturationBand: string;
export const GCI_Undefined: string;
export const GCI_YCbCr_CbBand: string;
export const GCI_YCbCr_CrBand: string;
export const GCI_YCbCr_YBand: string;
export const GCI_YellowBand: string;
// GDT
export const GDT_Byte: string;
export const GDT_CFloat32: string;
export const GDT_CFloat64: string;
export const GDT_CInt16: string;
export const GDT_CInt32: string;
export const GDT_Float32: string;
export const GDT_Float64: string;
export const GDT_Int16: string;
export const GDT_Int32: string;
export const GDT_UInt16: string;
export const GDT_UInt32: string;
export const GDT_Unknown: string;
// GRA
export const GRA_Average: string;
export const GRA_Bilinear: string;
export const GRA_Cubic: string;
export const GRA_CubicSpline: string;
export const GRA_Lanczos: string;
export const GRA_Mode: string;
export const GRA_NearestNeighbor: string;
// ODsC
export const ODrCCreateDataSource: string;
export const ODrCDeleteDataSource: string;
export const ODsCCreateGeomFieldAfterCreateLayer: string;
export const ODsCCreateLayer: string;
export const ODsCDeleteLayer: string;
// OFT
export const OFTBinary: string;
export const OFTDate: string;
export const OFTDateTime: string;
export const OFTInteger: string;
export const OFTIntegerList: string;
export const OFTReal: string;
export const OFTRealList: string;
export const OFTString: string;
export const OFTStringList: string;
export const OFTTime: string;
export const OFTWideString: string;
export const OFTWideStringList: string;
// OJ
export const OJLeft: string;
export const OJRight: string;
export const OJUndefined: string;
// OLC
export const OLCAlterFieldDefn: string;
export const OLCCreateField: string;
export const OLCCreateGeomField: string;
export const OLCDeleteFeature: string;
export const OLCDeleteField: string;
export const OLCFastFeatureCount: string;
export const OLCFastGetExtent: string;
export const OLCFastSetNextByIndex: string;
export const OLCFastSpatialFilter: string;
export const OLCIgnoreFields: string;
export const OLCRandomRead: string;
export const OLCRandomWrite: string;
export const OLCReorderFields: string;
export const OLCSequentialWrite: string;
export const OLCStringsAsUTF8: string;
export const OLCTransactions: string;
// wkbByteOrder
export const wkbNDR: string;
export const wkbXDR: string;
// wkbGeometryType
export const wkb25DBit: number;
export const wkbGeometryCollection: number;
export const wkbGeometryCollection25D: number;
export const wkbLinearRing: string;
export const wkbLinearRing25D: number;
export const wkbLineString: number;
export const wkbLineString25D: number;
export const wkbMultiLineString: number;
export const wkbMultiLineString25D: number;
export const wkbMultiPoint: number;
export const wkbMultiPoint25D: number;
export const wkbMultiPolygon: number;
export const wkbMultiPolygon25D: number;
export const wkbNone: number;
export const wkbPoint: number;
export const wkbPoint25D: number;
export const wkbPolygon: number;
export const wkbPolygon25D: number;
export const wkbUnknown: number;
// wkbVariant
export const wkbVariantIso: string;
export const wkbVariantOgc: string;
export const wkbVariantOldOgc: string;
/* Classes and interfaces */
export class CoordinateTransformation {
constructor(source: SpatialReference, target: SpatialReference | Dataset);
transformPoint(x: number, y: number, z?: number): XYZ;
}
export interface Dataset {
buildOverviews(resampling: Resampling, overviews: number[], bands?: number[]): void;
close(): void;
executeSQL(statement: string, spatial_filter?: Geometry, dialect?: string): Layer;
flush(): void;
getFileList(): string[];
getGCPProjection(): string;
getGCPs(): object[];
getMetadata(domain?: string): object;
setGCPs(gcps: object[], projection: string): void;
testCapability(capability: string): boolean;
readonly bands: DatasetBands;
readonly description: string;
readonly driver: Driver;
geoTransform: number[];
readonly layers: DatasetLayers;
readonly rasterSize: XY;
srs: SpatialReference;
}
export interface DatasetBands {
count(): number;
create(dataType: number): RasterBand;
forEach(callback: (band: RasterBand, i: number) => void): void;
get(id: number): RasterBand;
map<T>(callback: (band: RasterBand, i: number) => T): T[];
readonly ds: Dataset;
}
export interface DatasetLayers {
copy(src_lyr_name: string, dst_lyr_name: string, options?: object | string[]): Layer;
count(): number;
create(name: string, srs: SpatialReference, geomType: number | Geometry, creation_options: string[] | object): Layer;
forEach(callback: (layer: Layer, i: number) => void): void;
get(key: string | number): Layer;
map<T>(callback: (layer: Layer, i: number) => T): T[];
remove(index: number): void;
readonly ds: Dataset;
}
export interface Driver {
copyFiles(name_old: string, name_new: string): void;
create(filename: string, x_size?: number, y_size?: number, band_count?: number, data_type?: number, creation_options?: string[] | object): Dataset;
createCopy(filename: string, src: Dataset, strict?: boolean, options?: string[] | object): Dataset;
deleteDataset(filename: string): void;
getMetadata(domain?: string): object;
open(path: string, mode?: 'r' | 'r+'): Dataset;
rename(new_name: string, old_name: string): void;
readonly description: string;
}
export class Envelope {
constructor(bounds: EnvelopeBounds);
contains(envelope: Envelope): boolean;
intersect(envelope: Envelope): void;
intersects(envelope: Envelope): boolean;
isEmpty(): boolean;
merge(envelope: Envelope): void;
toPolygon(): Polygon;
}
export class Envelope3D extends Envelope {
constructor(bounds: Envelope3DBounds);
}
export class Feature {
constructor(definition: Layer | FeatureDefn);
clone(): Feature;
destroy(): void;
equals(feature: Feature): boolean;
getFieldDefn(index: number): FieldDefn;
getGeometry(): Geometry;
setFrom(feature: Feature, index_map?: number[], forgiving?: boolean): void;
setGeometry(geometry: Geometry): void;
readonly defn: FeatureDefn;
fid: number;
readonly fields: FeatureFields;
}
export class FeatureDefn {
constructor();
clone(): FeatureDefn;
readonly fields: FeatureDefnFields;
geomIgnored: boolean;
geomType: number;
readonly name: string;
styleIgnored: boolean;
}
export interface FeatureDefnFields {
add(field: FieldDefn | FieldDefn[]): void;
count(): number;
forEach(callback: (field: FieldDefn, i: number) => void): void;
get(key: string | number): FieldDefn;
getNames(): string[];
indexOf(name: string): number;
map<T>(callback: (field: FieldDefn, i: number) => T): T[];
remove(key: string | number): void;
reorder(map: number[]): void;
readonly featureDefn: FeatureDefn;
}
export interface FeatureFields {
count(): number;
forEach(callback: (value: any, key: string) => void): void;
get(key: string | number): any;
getNames(): string[];
indexOf(name: string): number;
map<T>(callback: (value: any, key: string) => T): T[];
reset(values: object, value: any): void;
set(key: string | number, value: any): void;
toArray(): any[];
toJSON(): string;
toObject(): object;
readonly feature: Feature;
}
export class FieldDefn {
constructor(name: string, type: string);
ignored: boolean;
justification: string;
name: string;
precision: number;
type: string;
width: number;
}
export interface GDALDrivers {
count(): number;
forEach(callback: (driver: Driver, i: number) => void): void;
get(index: number | string): Driver;
getNames(): string[];
map<T>(callback: (driver: Driver, i: number) => T): T[];
}
export abstract class Geometry {
static create(type: number): Geometry;
static fromWKB(wkb: number, srs?: SpatialReference): Geometry;
static fromWKT(wkt: string, srs?: SpatialReference): Geometry;
static getConstructor(type: number): Geometry;
static getName(type: number): string;
boundary(): Geometry;
buffer(distance: number, segments: number): Geometry;
centroid(): Point;
clone(): Geometry;
closeRings(): void;
contains(geometry: Geometry): boolean;
convexHull(): Geometry;
crosses(geometry: Geometry): boolean;
difference(geometry: Geometry): Geometry;
disjoint(geometry: Geometry): boolean;
distance(geometry: Geometry): number;
empty(): void;
equals(geometry: Geometry): boolean;
getEnvelope(): Envelope;
getEnvelope3D(): Envelope3D;
intersection(geometry: Geometry): Geometry;
intersects(geometry: Geometry): boolean;
isEmpty(): boolean;
isRing(): boolean;
isSimple(): boolean;
isValid(): boolean;
overlaps(geometry: Geometry): boolean;
segmentize(segment_length: number): number;
simplify(tolerance: number): Geometry;
simplifyPreserveTopology(tolerance: number): Geometry;
swapXY(): void;
symDifference(geometry: Geometry): Geometry;
toGML(): Geometry;
toJSON(): Geometry;
toKML(): Geometry;
toObject(): object;
touches(geometry: Geometry): boolean;
toWKB(byte_order?: string, variant?: string): Geometry;
toWKT(): Geometry;
transform(transformation: CoordinateTransformation): void;
transformTo(srs: SpatialReference): void;
union(geometry: Geometry): Geometry;
within(geometry: Geometry): boolean;
readonly coordinateDimension: number;
readonly dimension: number;
readonly name: string;
srs: SpatialReference;
readonly wkbSize: number;
readonly wkbType: number;
}
export class GeometryCollection extends Geometry {
getArea(): number;
getLength(): number;
children: GeometryCollectionChildren;
}
export interface GeometryCollectionChildren {
add(geometry: Geometry | Geometry[]): void;
count(): number;
forEach(callback: (geometry: Geometry, i: number) => void): void;
get(index: number): Geometry;
map<T>(callback: (geometry: Geometry, i: number) => T): T[];
remove(index: number): void;
toArray(): Geometry[];
readonly layer: Layer;
}
export interface Layer {
flush(): void;
getExtent(force?: boolean): Envelope;
getSpatialFilter(): Geometry;
setAttributeFilter(filter: string): void;
setSpatialFilter(filter: Geometry): void;
setSpatialFilter(minX: number, maxX: number, minY: number, maxY: number): void;
testCapability(capability: string): boolean;
readonly ds: Dataset;
readonly features: LayerFeatures;
readonly fidColumn: string;
readonly fields: LayerFields;
readonly geomColumn: string;
readonly geomType: number;
readonly name: string;
readonly srs: SpatialReference;
}
export interface LayerFeatures {
add(feature: Feature): void;
count(force?: boolean): number;
first(): Feature;
forEach(callback: (feature: Feature, i: number) => void): void;
get(id: number): Feature;
map<T>(callback: (feature: Feature, i: number) => T): T[];
next(): Feature;
remove(id: number): void;
set(id: number, feature: Feature): void;
readonly layer: Layer;
}
export interface LayerFields {
add(def: FieldDefn | FieldDefn[], approx?: boolean): void;
count(): number;
forEach(callback: (field: FieldDefn, i: number) => void): void;
fromJSON(object: object, approx_ok?: boolean): LayerFields;
get(field: string | number): FieldDefn;
getNames(): string[];
indexOf(field: string): number;
map<T>(callback: (field: FieldDefn, i: number) => T): T[];
remove(field: string | number): void;
reorder(map: number[]): void;
readonly layer: Layer;
}
export class LinearRing extends LineString {
getArea(): number;
}
export class LineString extends Geometry {
addSubLineString(line: LineString, start?: number, end?: number): void;
getLength(): number;
value(distance: number): Point;
readonly points: LineStringPoints;
}
export interface LineStringPoints {
add(point: Point | Point[]): void;
count(): number;
forEach(callback: (point: Point, i: number) => void): void;
get(index: number): Point;
map<T>(callback: (point: Point, i: number) => T): T[];
remove(index: number): void;
resize(count: number): void;
reverse(): void;
set(index: number, point: Point): void;
toArray(): Point[];
}
export class MultiLineString extends GeometryCollection {
polygonize(): Polygon;
}
export class MultiPoint extends GeometryCollection {}
export class MultiPolygon extends GeometryCollection {
getArea(): number;
unionCascaded(): Geometry;
}
export class Point extends Geometry {
constructor(x: number, y: number, z?: number);
x: number;
y: number;
z: number;
}
export class Polygon extends Geometry {
getArea(): number;
rings: PolygonRings;
}
export interface PolygonRings {
add(ring: LinearRing | LinearRing[]): void;
count(): number;
forEach(callback: (ring: LinearRing, i: number) => void): void;
get(index: number): LinearRing;
map<T>(callback: (ring: LinearRing, i: number) => T): T[];
remove(index: number): void;
toArray(): LinearRing[];
readonly layer: Layer;
}
export interface RasterBand {
computeStatistics(allow_approximation: boolean): RasterBandStatistics;
createMaskBand(flags: number): void;
fill(real_value: number, imaginary_value?: number): void;
flush(): void;
getMaskBand(): RasterBand;
getMaskFlags(): number;
getMetadata(domain?: string): object;
getStatistics(allow_approximation: boolean, force: boolean): RasterBandStatistics;
setStatistics(min: number, max: number, mean: number, std_dev: number): void;
readonly blockSize: XY;
categoryNames: string[];
colorInterpretation: string;
readonly dataType: string;
readonly description: string;
readonly ds: Dataset;
readonly hasArbitraryOverviews: boolean;
readonly id: number;
readonly maximum: number;
readonly minimum: number;
noDataValue: number;
offset: number;
readonly overviews: RasterBandOverviews;
readonly pixels: RasterBandPixels;
readonly readOnly: boolean;
scale: number;
readonly size: XY;
unitType: string;
}
export interface RasterBandOverviews {
count(): number;
forEach(callback: (overviewBand: RasterBand, i: number) => void): void;
get(index: number): RasterBand;
getBySampleCount(samples: number): RasterBand;
map<T>(callback: (overviewBand: RasterBand, i: number) => T): T[];
}
export interface RasterBandPixels {
get(x: number, y: number): number;
read(x: number, y: number, width: number, height: number, data?: TypedArray, options?: RasterBandPixelsReadOptions): TypedArray;
readBlock(x: number, y: number, data?: TypedArray): TypedArray;
set(x: number, y: number, value: number): void;
write(x: number, y: number, width: number, height: number, data: TypedArray, options?: RasterBandPixelsWriteOptions): void;
writeBlock(x: number, y: number, data: TypedArray): void;
}
export class SpatialReference {
constructor(wkt?: string);
autoIdentifyEPSG(): void;
clone(): SpatialReference;
cloneGeogCS(): SpatialReference;
EPSGTreatsAsLatLong(): boolean;
EPSGTreatsAsNorthingEasting(): boolean;
getAngularUnits(): { value: any, unit: any };
getAttrValue(node_name: string, attr_index?: number): string;
getAuthorityCode(target_key: string): string;
getAuthorityName(target_key: string): string;
getLinearUnits(): { value: any, unit: any };
isCompound(): boolean;
isGeocentric(): boolean;
isGeographic(): boolean;
isLocal(): boolean;
isProjected(): boolean;
isSame(srs: SpatialReference): boolean;
isSameGeogCS(srs: SpatialReference): boolean;
isSameVertCS(srs: SpatialReference): boolean;
isVertical(): boolean;
morphFromESRI(): void;
morphToESRI(): void;
setWellKnownGeogCS(name: string): void;
toPrettyWKT(simplify?: boolean): string;
toProj4(): string;
toWKT(): string;
toXML(): string;
validate(): string;
static fromCRSURL(input: string): SpatialReference;
static fromEPSG(input: string): SpatialReference;
static fromEPSGA(input: number): SpatialReference;
static fromESRI(input: string[]): SpatialReference;
static fromMICoordSys(input: string): SpatialReference;
static fromProj4(input: string): SpatialReference;
static fromURL(url: string): SpatialReference;
static fromURN(input: string): SpatialReference;
static fromUserInput(input: string): SpatialReference;
static fromWKT(wkt: string): SpatialReference;
static fromWMSAUTO(input: string): SpatialReference;
static fromXML(input: string): SpatialReference;
}
export namespace config {
function get(key: string): string;
function set(key: string, value: string): void;
}
export const drivers: GDALDrivers;
export const lastError: { number: any, message: any, type: any };
export const version: string;
export function checksumImage(src: RasterBand, x?: number, y?: number, w?: number, h?: number): number;
export function contourGenerate(options: ContourGenerateOptions): void;
export function decToDMS(angle: number, axis: 'lat' | 'long', precision?: number): string;
export function fillNodata(options: FillNoDataOptions): void;
export function open(path: string, mode?: 'r' | 'r+' | 'w', drivers?: string | string[]): Dataset;
export function open(path: string, mode?: 'w', drivers?: string | string[], x_size?: number, y_size?: number, band_count?: number, data_type?: number, creation_options?: string[] | object): Dataset;
export function polygonize(options: PolygonizeOptions): void;
export function quiet(): void;
export function reprojectImage(options: ReprojectImageOptions): void;
export function sieveFilter(options: SieveFilterOptions): void;
export function suggestedWarpOutput(options: SuggestedWarpOutputOptions): { rasterSize: any, geoTransform: any };
export function verbose(): void;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gdal-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+29
View File
@@ -0,0 +1,29 @@
/// <reference types="node" />
import ghauth = require("ghauth");
import { AuthOptions, TokenData } from "ghauth";
// Full
const authOptions1: AuthOptions = {
configName: "awesome",
noSave: true,
authUrl: "https://api.github.com/authorizations",
promptName: "GitHub",
scopes: ["user"],
note: "This token is for my awesome app",
userAgent: "My Awesome App",
};
ghauth(authOptions1, (err: Error, authData: TokenData) => {
authData.user;
authData.token;
});
// Required
const authOptions2: AuthOptions = {
configName: "awesome",
};
ghauth(authOptions2, (err: Error, authData: TokenData) => {
authData.user;
authData.token;
});
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for ghauth 3.2
// Project: https://github.com/rvagg/ghauth
// Definitions by: Leko <https://github.com/Leko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function ghauth(authOptions: ghauth.AuthOptions, callback: (err: Error, tokenData: ghauth.TokenData) => void): void;
declare namespace ghauth {
interface AuthOptions {
configName: string;
/**
* @default false
*/
noSave?: boolean;
/**
* @default "https://api.github.com/authorizations"
*/
authUrl?: string;
/**
* @default "GitHub"
*/
promptName?: string;
/**
* @default []
*/
scopes?: ReadonlyArray<string>;
/**
* @default "Node.js command-line app with ghauth"
*/
note?: string;
/**
* @default "Magic Node.js application that does magic things with ghauth"
*/
userAgent?: string;
}
interface TokenData {
user: string;
token: string;
}
}
export = ghauth;

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