mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -3009,6 +3009,7 @@
|
||||
/types/proj4leaflet/ @BendingBender
|
||||
/types/project-oxford/ @scsouthw
|
||||
/types/promise-dag/ @OSjoerdWie
|
||||
/types/promise-map-limit/ @kohlmannj
|
||||
/types/promise-pg/ @coldacid
|
||||
/types/promise-polyfill/ @skysteve
|
||||
/types/promise-pool/ @vilic
|
||||
|
||||
@@ -87,6 +87,7 @@ Primero, haz un [fork](https://guides.github.com/activities/forking/) en este re
|
||||
|
||||
* `cd types/my-package-to-edit`
|
||||
* Haz cambios. Recuerda editar las pruebas.
|
||||
Si realiza cambios importantes, no olvide [actualizar una versión principal](#quiero-actualizar-un-paquete-a-una-nueva-versión-principal).
|
||||
* También puede que quieras añadirte la sección "Definitions by" en el encabezado del paquete.
|
||||
- Esto hará que seas notificado (a través de tu nombre de usuario en GitHub) cada vez que alguien haga un pull request o issue sobre el paquete.
|
||||
- Haz esto añadiendo tu nombre al final de la línea, así como en `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
|
||||
@@ -87,6 +87,7 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
|
||||
|
||||
* `cd types/my-package-to-edit`
|
||||
* Make changes. Remember to edit tests.
|
||||
If you make breaking changes, do not forget to [update a major version](#i-want-to-update-a-package-to-a-new-major-version).
|
||||
* You may also want to add yourself to "Definitions by" section of the package header.
|
||||
- This will cause you to be notified (via your GitHub username) whenever someone makes a pull request or issue about the package.
|
||||
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
|
||||
@@ -660,6 +660,12 @@
|
||||
"sourceRepoURL": "https://github.com/ashtuchkin/iconv-lite",
|
||||
"asOfVersion": "0.4.14"
|
||||
},
|
||||
{
|
||||
"libraryName": "ids",
|
||||
"typingsPackageName": "ids",
|
||||
"sourceRepoURL": "https://github.com/bpmn-io/ids",
|
||||
"asOfVersion": "0.2.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "immutability-helper",
|
||||
"typingsPackageName": "immutability-helper",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "definitely-typed",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Vendored
+31
@@ -3039,6 +3039,37 @@ declare namespace AceAjax {
|
||||
**/
|
||||
new(container: HTMLElement, theme?: string): VirtualRenderer;
|
||||
}
|
||||
|
||||
export interface Completer {
|
||||
/**
|
||||
* Provides possible completion results asynchronously using the given callback.
|
||||
* @param editor The editor to associate with
|
||||
* @param session The `EditSession` to refer to
|
||||
* @param pos An object containing the row and column
|
||||
* @param prefix The prefixing string before the current position
|
||||
* @param callback Function to provide the results or error
|
||||
*/
|
||||
getCompletions: (editor: Editor, session: IEditSession, pos: Position, prefix: string, callback: CompletionCallback) => void;
|
||||
|
||||
/**
|
||||
* Provides tooltip information about a completion result.
|
||||
* @param item The completion result
|
||||
*/
|
||||
getDocTooltip?: (item: Completion) => void;
|
||||
}
|
||||
|
||||
export interface Completion {
|
||||
value: string;
|
||||
meta: string;
|
||||
type?: string;
|
||||
caption?: string;
|
||||
snippet?: any;
|
||||
score?: number;
|
||||
exactMatch?: number;
|
||||
docHTML?: string;
|
||||
}
|
||||
|
||||
export type CompletionCallback = (error: Error, results: Completion[]) => void;
|
||||
}
|
||||
|
||||
declare var ace: AceAjax.Ace;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
declare namespace adone {
|
||||
namespace application {
|
||||
namespace app {
|
||||
namespace I {
|
||||
type ArgumentType = ((x: string, index: number) => any) | RegExp;
|
||||
|
||||
@@ -12,7 +12,7 @@ declare namespace adone {
|
||||
| "append"
|
||||
| "count"
|
||||
| "set";
|
||||
nargs?: number | "+" | "*" | "?"
|
||||
nargs?: number | "+" | "*" | "?";
|
||||
type?: ArgumentType | ArgumentType[];
|
||||
verify?: (args: any, opts: any) => boolean; // TODO
|
||||
required?: boolean;
|
||||
@@ -49,7 +49,7 @@ declare namespace adone {
|
||||
name?: string;
|
||||
description?: string;
|
||||
subsystems?: SubsystemInfo[];
|
||||
commandsGroups?: Group[]
|
||||
commandsGroups?: Group[];
|
||||
}
|
||||
|
||||
interface SubsystemInfo {
|
||||
@@ -71,24 +71,24 @@ declare namespace adone {
|
||||
|
||||
namespace I {
|
||||
interface LoadSubsystemOptions {
|
||||
name?: string,
|
||||
description?: string,
|
||||
group?: string,
|
||||
transpile?: boolean
|
||||
name?: string;
|
||||
description?: string;
|
||||
group?: string;
|
||||
transpile?: boolean;
|
||||
}
|
||||
|
||||
interface CommonAddSubsystemInfo {
|
||||
name?: string,
|
||||
useFilename?: boolean
|
||||
description?: string,
|
||||
group?: string,
|
||||
configureArgs?: any[]
|
||||
transpile?: boolean,
|
||||
bind?: boolean | string
|
||||
name?: string;
|
||||
useFilename?: boolean;
|
||||
description?: string;
|
||||
group?: string;
|
||||
configureArgs?: any[];
|
||||
transpile?: boolean;
|
||||
bind?: boolean | string;
|
||||
}
|
||||
|
||||
interface AddSubsystemInfo extends CommonAddSubsystemInfo {
|
||||
subsystem: Subsystem | string,
|
||||
subsystem: Subsystem | string;
|
||||
}
|
||||
|
||||
interface SysInfo {
|
||||
@@ -109,7 +109,7 @@ declare namespace adone {
|
||||
}
|
||||
|
||||
interface AddSubsystemsFromOptions extends CommonAddSubsystemInfo {
|
||||
filter?: string[] | ((file: string) => boolean | Promise<boolean>)
|
||||
filter?: string[] | ((file: string) => boolean | Promise<boolean>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,25 +211,22 @@ declare namespace adone {
|
||||
_rejectionHandled(p: Promise<any>): void;
|
||||
|
||||
_signalExit(sigName: string): void;
|
||||
|
||||
}
|
||||
|
||||
namespace I {
|
||||
interface Command {
|
||||
// ?
|
||||
names: string[];
|
||||
// TODO
|
||||
}
|
||||
|
||||
interface Argument {
|
||||
// ?
|
||||
names: string[];
|
||||
// TODO
|
||||
}
|
||||
|
||||
interface PositionalArgument extends Argument {
|
||||
// ?
|
||||
}
|
||||
type PositionalArgument = Argument; // TODO
|
||||
|
||||
interface OptionalArgument extends Argument {
|
||||
// ?
|
||||
}
|
||||
type OptionalArgument = Argument; // TODO
|
||||
|
||||
interface DefineCommandFromSubsystemOptions {
|
||||
name?: string;
|
||||
Vendored
+2
-2
@@ -320,12 +320,12 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is an adone subsystem
|
||||
*/
|
||||
export function subsystem(obj: any): obj is adone.application.Subsystem;
|
||||
export function subsystem(obj: any): obj is adone.app.Subsystem;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone application
|
||||
*/
|
||||
export function application(obj: any): obj is adone.application.Application;
|
||||
export function application(obj: any): obj is adone.app.Application;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone logger
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference path="./adone.d.ts" />
|
||||
/// <reference path="./glosses/application.d.ts" />
|
||||
/// <reference path="./glosses/app.d.ts" />
|
||||
/// <reference path="./glosses/archives.d.ts" />
|
||||
/// <reference path="./glosses/assertion.d.ts" />
|
||||
/// <reference path="./glosses/collections/index.d.ts" />
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace applicationTests {
|
||||
Subsystem,
|
||||
runCli,
|
||||
Application
|
||||
} = adone.application;
|
||||
} = adone.app;
|
||||
|
||||
namespace DApplicationTests {
|
||||
{
|
||||
@@ -24,6 +24,7 @@
|
||||
"adone.d.ts",
|
||||
"async.d.ts",
|
||||
"benchmark.d.ts",
|
||||
"glosses/app.d.ts",
|
||||
"glosses/archives.d.ts",
|
||||
"glosses/assertion.d.ts",
|
||||
"glosses/collections/array_set.d.ts",
|
||||
@@ -95,7 +96,7 @@
|
||||
"glosses/utils.d.ts",
|
||||
"glosses/vault.d.ts",
|
||||
"index.d.ts",
|
||||
"test/glosses/application.ts",
|
||||
"test/glosses/app.ts",
|
||||
"test/glosses/archives.ts",
|
||||
"test/glosses/assertion.ts",
|
||||
"test/glosses/collections/array_set.ts",
|
||||
|
||||
@@ -21,9 +21,9 @@ type MyEntity = AFrame.Entity<{
|
||||
material: THREE.Material;
|
||||
sound: { pause(): void };
|
||||
}>;
|
||||
const camera = document.querySelector<MyEntity>('a-entity[camera]').components.camera;
|
||||
const material = document.querySelector<MyEntity>('a-entity[material]').components.material;
|
||||
document.querySelector<MyEntity>('a-entity[sound]').components.sound.pause();
|
||||
const camera = (document.querySelector('a-entity[camera]') as MyEntity).components.camera;
|
||||
const material = (document.querySelector('a-entity[material]') as MyEntity).components.material;
|
||||
(document.querySelector('a-entity[sound]') as MyEntity).components.sound.pause();
|
||||
|
||||
entity.getDOMAttribute('geometry').primitive;
|
||||
|
||||
@@ -38,21 +38,82 @@ entity.addEventListener('child-detached', (event) => {
|
||||
});
|
||||
|
||||
// Components
|
||||
const Component = AFRAME.registerComponent('test', {});
|
||||
|
||||
interface TestComponent extends AFrame.Component {
|
||||
multiply: (f: number) => number;
|
||||
|
||||
data: {
|
||||
myProperty: any[],
|
||||
string: string,
|
||||
num: number
|
||||
};
|
||||
|
||||
system: TestSystem;
|
||||
}
|
||||
|
||||
const Component = AFRAME.registerComponent<TestComponent>('test-component', {
|
||||
schema: {
|
||||
myProperty: {
|
||||
default: [],
|
||||
parse() { return [true]; },
|
||||
},
|
||||
string: { type: 'string' },
|
||||
num: 0
|
||||
},
|
||||
init() {
|
||||
this.data.num = 0;
|
||||
},
|
||||
update() {},
|
||||
tick() {},
|
||||
remove() {},
|
||||
pause() {},
|
||||
play() {},
|
||||
|
||||
multiply(this: TestComponent, f: number) {
|
||||
// Reference to system because both were registered with the same name.
|
||||
return f * this.data.num * this.system.data.counter;
|
||||
}
|
||||
});
|
||||
|
||||
// Scene
|
||||
const scene = document.querySelector('a-scene');
|
||||
scene.hasLoaded;
|
||||
|
||||
// System
|
||||
const system = scene.systems['systemName'];
|
||||
|
||||
interface TestSystem extends AFrame.System {
|
||||
data: {
|
||||
counter: number;
|
||||
};
|
||||
}
|
||||
|
||||
const testSystem: AFrame.SystemDefinition<TestSystem> = {
|
||||
schema: {
|
||||
counter: 0
|
||||
},
|
||||
|
||||
init() {
|
||||
this.data.counter = 1;
|
||||
}
|
||||
};
|
||||
|
||||
AFRAME.registerSystem('test-component', testSystem);
|
||||
|
||||
// Register Custom Geometry
|
||||
AFRAME.registerGeometry('a-test-geometry', {
|
||||
|
||||
interface TestGeometry extends AFrame.Geometry {
|
||||
schema: AFrame.MultiPropertySchema<{
|
||||
groupIndex: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
AFRAME.registerGeometry<TestGeometry>('a-test-geometry', {
|
||||
schema: {
|
||||
groupIndex: { default: 0 }
|
||||
},
|
||||
init(data) {
|
||||
this.geometry = new THREE.Geometry();
|
||||
const temp = data.groupIndex;
|
||||
temp;
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+93
-78
@@ -2,6 +2,7 @@
|
||||
// Project: https://aframe.io/
|
||||
// Definitions by: Paul Shannon <https://github.com/devpaul>
|
||||
// Roberto Ritger <https://github.com/bertoritger>
|
||||
// Trygve Wastvedt <https://github.com/twastvedt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -19,7 +20,7 @@ declare var hasNativeWebVRImplementation: boolean;
|
||||
interface Document {
|
||||
createElement(tagName: string): AFrame.Entity;
|
||||
querySelector(selectors: 'a-scene'): AFrame.Scene;
|
||||
querySelector<T extends AFrame.Entity<any>>(selectors: string): T;
|
||||
querySelector(selectors: string): AFrame.Entity<any>;
|
||||
querySelectorAll(selectors: string): NodeListOf<AFrame.Entity<any> | Element>;
|
||||
}
|
||||
|
||||
@@ -36,15 +37,15 @@ declare namespace AFrame {
|
||||
components: { [ key: string ]: ComponentDescriptor };
|
||||
geometries: { [ key: string ]: GeometryDescriptor };
|
||||
primitives: { [ key: string ]: Entity };
|
||||
registerComponent(name: string, component: ComponentDefinition): ComponentConstructor;
|
||||
registerComponent<T extends Component>(name: string, component: ComponentDefinition<T>): ComponentConstructor<T>;
|
||||
registerElement(name: string, element: ANode): void;
|
||||
registerGeometry(name: string, geometry: GeometryDefinition): Geometry;
|
||||
registerGeometry<T extends Geometry>(name: string, geometry: GeometryDefinition<T>): GeometryConstructor<T>;
|
||||
registerPrimitive(name: string, primitive: PrimitiveDefinition): void;
|
||||
registerShader(name: string, shader: any): void;
|
||||
registerSystem(name: string, definition: SystemDefinition): void;
|
||||
registerShader<T extends Shader>(name: string, shader: T): ShaderConstructor<T>;
|
||||
registerSystem<T extends System>(name: string, definition: SystemDefinition<T>): SystemConstructor<T>;
|
||||
schema: SchemaUtils;
|
||||
shaders: { [ key: string ]: ShaderDescriptor };
|
||||
systems: { [key: string]: System };
|
||||
systems: { [key: string]: SystemConstructor };
|
||||
THREE: typeof THREE;
|
||||
TWEEN: typeof TWEEN;
|
||||
utils: Utils;
|
||||
@@ -89,54 +90,39 @@ declare namespace AFrame {
|
||||
tick(): void;
|
||||
}
|
||||
|
||||
interface Component {
|
||||
interface Component<T extends { [key: string]: any } = any, S extends System = System> {
|
||||
attrName?: string;
|
||||
data?: any;
|
||||
data: T;
|
||||
dependencies?: string[];
|
||||
el: Entity;
|
||||
id: string;
|
||||
multiple?: boolean;
|
||||
name: string;
|
||||
schema: Schema;
|
||||
schema: Schema<T>;
|
||||
system: S | undefined;
|
||||
|
||||
init(data?: any): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
remove(): void;
|
||||
tick?(time: number, timeDelta: number): void;
|
||||
update(oldData: any): void;
|
||||
updateSchema?(): void;
|
||||
init(this: this, data?: T): void;
|
||||
pause(this: this): void;
|
||||
play(this: this): void;
|
||||
remove(this: this): void;
|
||||
tick?(this: this, time: number, timeDelta: number): void;
|
||||
update(this: this, oldData: T): void;
|
||||
updateSchema?(this: this): void;
|
||||
|
||||
extendSchema(update: Schema): void;
|
||||
flushToDOM(): void;
|
||||
extendSchema(this: this, update: Schema): void;
|
||||
flushToDOM(this: this): void;
|
||||
}
|
||||
|
||||
interface ComponentConstructor {
|
||||
new (el: Entity, name: string, id: string): Component;
|
||||
interface ComponentConstructor<T extends Component> {
|
||||
new (el: Entity, attrValue: string, id: string): T;
|
||||
}
|
||||
|
||||
interface ComponentDefinition {
|
||||
dependencies?: string[];
|
||||
el?: Entity;
|
||||
id?: string;
|
||||
multiple?: boolean;
|
||||
schema?: Schema;
|
||||
type ComponentDefinition<T extends Component = Component> = Partial<T>;
|
||||
|
||||
init?(data?: any): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
remove?(): void;
|
||||
tick?(time: number, timeDelta: number): void;
|
||||
update?(oldData: any): void;
|
||||
updateSchema?(): void;
|
||||
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface ComponentDescriptor {
|
||||
Component: Component;
|
||||
dependencies: string[] | null;
|
||||
multiple: boolean | null;
|
||||
interface ComponentDescriptor<T extends Component = Component> {
|
||||
Component: ComponentConstructor<T>;
|
||||
dependencies: string[] | undefined;
|
||||
multiple: boolean | undefined;
|
||||
|
||||
// internal APIs2
|
||||
// parse
|
||||
@@ -144,7 +130,6 @@ declare namespace AFrame {
|
||||
// schema
|
||||
// stringify
|
||||
// type
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface Coordinate {
|
||||
@@ -153,8 +138,14 @@ declare namespace AFrame {
|
||||
z: number;
|
||||
}
|
||||
|
||||
interface DefaultComponents {
|
||||
position: Component<Coordinate>;
|
||||
rotation: Component<Coordinate>;
|
||||
scale: Component<Coordinate>;
|
||||
}
|
||||
|
||||
interface Entity<C = ObjectMap<Component>> extends ANode {
|
||||
components: C;
|
||||
components: C & DefaultComponents;
|
||||
isPlaying: boolean;
|
||||
object3D: THREE.Object3D;
|
||||
object3DMap: ObjectMap<THREE.Object3D>;
|
||||
@@ -165,8 +156,8 @@ declare namespace AFrame {
|
||||
/**
|
||||
* @deprecated since 0.4.0
|
||||
*/
|
||||
getComputedAttribute<T = Component>(attr: string): T;
|
||||
getDOMAttribute<T = any>(attr: string): T;
|
||||
getComputedAttribute(attr: string): Component;
|
||||
getDOMAttribute(attr: string): any;
|
||||
getObject3D(type: string): THREE.Object3D;
|
||||
getOrCreateObject3D(type: string, construct: any): THREE.Object3D;
|
||||
is(stateName: string): boolean;
|
||||
@@ -179,7 +170,6 @@ declare namespace AFrame {
|
||||
|
||||
// getAttribute specific usages
|
||||
getAttribute(type: string): any;
|
||||
getAttribute<T = Component>(attr: string): T;
|
||||
getAttribute(type: 'position' | 'rotation' | 'scale'): Coordinate;
|
||||
|
||||
// setAttribute specific usages
|
||||
@@ -192,12 +182,18 @@ declare namespace AFrame {
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
type DetailEvent<D> = Event & { detail: D };
|
||||
type DetailEvent<D> = Event & {
|
||||
detail: D;
|
||||
target: EventTarget & Entity;
|
||||
};
|
||||
|
||||
interface EntityEventMap {
|
||||
'child-attached': DetailEvent<{ el: Element | Entity }>;
|
||||
'child-detached': DetailEvent<{ el: Element | Entity }>;
|
||||
'componentchanged': DetailEvent<{ name: string }>;
|
||||
'componentchanged': DetailEvent<{
|
||||
name: string,
|
||||
id: string
|
||||
}>;
|
||||
'componentremoved': DetailEvent<{
|
||||
name: string,
|
||||
id: string,
|
||||
@@ -215,23 +211,28 @@ declare namespace AFrame {
|
||||
interface Geometry {
|
||||
name: string;
|
||||
geometry: THREE.Geometry;
|
||||
schema: Schema;
|
||||
update(data: object): void;
|
||||
[ key: string ]: any;
|
||||
schema: Schema<any>;
|
||||
|
||||
init(this: this, data: { [P in keyof this['schema']]: any }): void;
|
||||
// Would like the above to be:
|
||||
// init?(this: this, data?: { [P in keyof T['schema']]: T['schema'][P]['default'] } ): void;
|
||||
// I think this is prevented by the following issue: https://github.com/Microsoft/TypeScript/issues/21760.
|
||||
}
|
||||
|
||||
interface GeometryDefinition extends ComponentDefinition {
|
||||
geometry?: THREE.Geometry;
|
||||
interface GeometryConstructor<T extends Geometry> {
|
||||
new (): T;
|
||||
}
|
||||
|
||||
interface GeometryDescriptor {
|
||||
Geometry: Geometry;
|
||||
type GeometryDefinition<T extends Geometry = Geometry> = Partial<T>;
|
||||
|
||||
interface GeometryDescriptor<T extends Geometry = Geometry> {
|
||||
Geometry: GeometryConstructor<T>;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
interface MultiPropertySchema {
|
||||
[ key: string ]: SinglePropertySchema<any>;
|
||||
}
|
||||
type MultiPropertySchema<T extends { [key: string ]: any }> = {
|
||||
[P in keyof T]: SinglePropertySchema<T[P]> | T[P];
|
||||
};
|
||||
|
||||
interface PrimitiveDefinition {
|
||||
defaultComponents?: any; // TODO cleanup type
|
||||
@@ -240,8 +241,9 @@ declare namespace AFrame {
|
||||
transforms?: any; // TODO cleanup type
|
||||
}
|
||||
|
||||
type PropertyTypes = 'array' | 'boolean' | 'color' | 'int' | 'number' | 'selector' |
|
||||
'selectorAll' | 'src' | 'string' | 'vec2' | 'vec3' | 'vec4';
|
||||
type PropertyTypes = 'array' | 'asset' | 'audio' | 'boolean' | 'color' |
|
||||
'int' | 'map' | 'model' | 'number' | 'selector' | 'selectorAll' |
|
||||
'string' | 'vec2' | 'vec3' | 'vec4';
|
||||
|
||||
type SceneEvents = 'enter-vr' | 'exit-vr' | 'loaded' | 'renderstart';
|
||||
|
||||
@@ -265,7 +267,7 @@ declare namespace AFrame {
|
||||
addEventListener(type: SceneEvents, listener: EventListener, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
type Schema = SinglePropertySchema<any> | MultiPropertySchema;
|
||||
type Schema<T = { [key: string]: any }> = SinglePropertySchema<T> | MultiPropertySchema<T>;
|
||||
|
||||
interface SchemaUtils {
|
||||
isSingleProperty(schema: Schema): boolean;
|
||||
@@ -274,11 +276,25 @@ declare namespace AFrame {
|
||||
|
||||
interface Shader {
|
||||
name: string;
|
||||
schema: Schema;
|
||||
data: { [key: string]: any };
|
||||
schema: Schema<this['data']>;
|
||||
material: THREE.Material;
|
||||
vertexShader: string;
|
||||
fragmentShader: string;
|
||||
|
||||
init(this: this, data?: this['data']): void;
|
||||
tick?(this: this, time: number, timeDelta: number): void;
|
||||
update(this: this, oldData: this['data']): void;
|
||||
}
|
||||
|
||||
interface ShaderDescriptor {
|
||||
Shader: Shader;
|
||||
interface ShaderConstructor<T extends Shader> {
|
||||
new (): T;
|
||||
}
|
||||
|
||||
type ShaderDefinition<T extends Shader = Shader> = Partial<T>;
|
||||
|
||||
interface ShaderDescriptor<T extends Shader = Shader> {
|
||||
Shader: ShaderConstructor<T>;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
@@ -287,27 +303,23 @@ declare namespace AFrame {
|
||||
'default'?: T;
|
||||
parse?(value: string): T;
|
||||
stringify?(value: T): string;
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface System {
|
||||
data: any;
|
||||
schema: Schema;
|
||||
init(): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
tick?(): void;
|
||||
data: { [key: string]: any };
|
||||
schema: Schema<this['data']>;
|
||||
init(this: this): void;
|
||||
pause(this: this): void;
|
||||
play(this: this): void;
|
||||
tick?(this: this, t: number, dt: number): void;
|
||||
}
|
||||
|
||||
interface SystemDefinition {
|
||||
schema?: Schema;
|
||||
init?(): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
tick?(): void;
|
||||
[ key: string ]: any;
|
||||
interface SystemConstructor<T extends System = System> {
|
||||
new (scene: Scene): T;
|
||||
}
|
||||
|
||||
type SystemDefinition<T extends System = System> = Partial<T>;
|
||||
|
||||
interface Utils {
|
||||
coordinates: {
|
||||
isCoordinate(value: string): boolean;
|
||||
@@ -326,5 +338,8 @@ declare namespace AFrame {
|
||||
diff(a: object, b: object): object;
|
||||
extend(target: object, ... source: object[]): object;
|
||||
extendDeep(target: object, ... source: object[]): object;
|
||||
|
||||
throttle(tickFunction: () => void, minimumInterval: number, optionalContext?: {}): (t: number, dt: number) => void;
|
||||
throttleTick(tickFunction: (t: number, dt: number) => void, minimumInterval: number, optionalContext?: {}): (t: number, dt: number) => void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@ import * as algoliasearch from 'algoliasearch';
|
||||
import {
|
||||
ClientOptions,
|
||||
SynonymOption,
|
||||
AlgoliaApiKeyOptions,
|
||||
ApiKeyOptions,
|
||||
SearchSynonymOptions,
|
||||
AlgoliaResponse,
|
||||
AlgoliaSecuredApiOptions,
|
||||
AlgoliaIndexSettings,
|
||||
AlgoliaQueryParameters,
|
||||
AlgoliaIndex,
|
||||
SecuredApiOptions,
|
||||
Index,
|
||||
Response,
|
||||
IndexSettings,
|
||||
QueryParameters,
|
||||
} from 'algoliasearch';
|
||||
|
||||
let _algoliaResponse: AlgoliaResponse = {
|
||||
let _algoliaResponse: Response = {
|
||||
hits: [{}, {}],
|
||||
page: 0,
|
||||
nbHits: 12,
|
||||
@@ -33,7 +33,7 @@ let _synonymOption: SynonymOption = {
|
||||
replaceExistingSynonyms: false,
|
||||
};
|
||||
|
||||
let _algoliaApiKeyOptions: AlgoliaApiKeyOptions = {
|
||||
let _algoliaApiKeyOptions: ApiKeyOptions = {
|
||||
validity: 0,
|
||||
maxQueriesPerIPPerHour: 0,
|
||||
indexes: [''],
|
||||
@@ -48,14 +48,14 @@ let _searchSynonymOptions: SearchSynonymOptions = {
|
||||
hitsPerPage: 0,
|
||||
};
|
||||
|
||||
let _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
|
||||
let _algoliaSecuredApiOptions: SecuredApiOptions = {
|
||||
filters: '',
|
||||
validUntil: 0,
|
||||
restrictIndices: '',
|
||||
userToken: '',
|
||||
};
|
||||
|
||||
let _algoliaIndexSettings: AlgoliaIndexSettings = {
|
||||
let _algoliaIndexSettings: IndexSettings = {
|
||||
attributesToIndex: [''],
|
||||
attributesForFaceting: [''],
|
||||
unretrievableAttributes: [''],
|
||||
@@ -63,7 +63,7 @@ let _algoliaIndexSettings: AlgoliaIndexSettings = {
|
||||
ranking: [''],
|
||||
customRanking: [''],
|
||||
replicas: [''],
|
||||
maxValuesPerFacet: '',
|
||||
maxValuesPerFacet: 100,
|
||||
attributesToHighlight: [''],
|
||||
attributesToSnippet: [''],
|
||||
highlightPreTag: '',
|
||||
@@ -96,13 +96,13 @@ let _algoliaIndexSettings: AlgoliaIndexSettings = {
|
||||
placeholders: '',
|
||||
};
|
||||
|
||||
let _algoliaQueryParameters: AlgoliaQueryParameters = {
|
||||
let _algoliaQueryParameters: QueryParameters = {
|
||||
query: '',
|
||||
filters: '',
|
||||
attributesToRetrieve: [''],
|
||||
restrictSearchableAttributes: [''],
|
||||
facets: '',
|
||||
maxValuesPerFacet: '',
|
||||
maxValuesPerFacet: 2,
|
||||
attributesToHighlight: [''],
|
||||
attributesToSnippet: [''],
|
||||
highlightPreTag: '',
|
||||
@@ -147,7 +147,20 @@ let _algoliaQueryParameters: AlgoliaQueryParameters = {
|
||||
minProximity: 0,
|
||||
};
|
||||
|
||||
let index: AlgoliaIndex = algoliasearch('', '').initIndex('');
|
||||
let index: Index = algoliasearch('', '').initIndex('');
|
||||
|
||||
let search = index.search({ query: '' });
|
||||
|
||||
index.search({ query: '' }, (err, res) => {});
|
||||
|
||||
// partialUpdateObject
|
||||
index.partialUpdateObject({}, () => {});
|
||||
index.partialUpdateObject({}, false, () => {});
|
||||
index.partialUpdateObject({}).then(() => {});
|
||||
index.partialUpdateObject({}, false).then(() => {});
|
||||
|
||||
// partialUpdateObjects
|
||||
index.partialUpdateObjects([{}], () => {});
|
||||
index.partialUpdateObjects([{}], false, () => {});
|
||||
index.partialUpdateObjects([{}]).then(() => {});
|
||||
index.partialUpdateObjects([{}], false).then(() => {});
|
||||
|
||||
Vendored
+573
-703
File diff suppressed because it is too large
Load Diff
Vendored
+624
@@ -0,0 +1,624 @@
|
||||
// Type definitions for algoliasearch-client-js 3.27.0
|
||||
// Project: https://github.com/algolia/algoliasearch-client-js
|
||||
// Definitions by: Baptiste Coquelle <https://github.com/cbaptiste>
|
||||
// Haroen Viaene <https://github.com/haroenv>
|
||||
// Aurélien Hervé <https://github.com/aherve>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare namespace algoliasearch {
|
||||
/*
|
||||
Interface for the algolia client object
|
||||
*/
|
||||
interface Client {
|
||||
/**
|
||||
* Initialization of the index
|
||||
* https://github.com/algolia/algoliasearch-client-js#init-index---initindex
|
||||
*/
|
||||
initIndex(indexName: string): Index;
|
||||
/**
|
||||
* Query on multiple index
|
||||
* https://github.com/algolia/algoliasearch-client-js#multiple-queries---multiplequeries
|
||||
*/
|
||||
search(
|
||||
queries: {
|
||||
indexName: string;
|
||||
query: string;
|
||||
params: QueryParameters;
|
||||
}[],
|
||||
cb: (err: Error, res: MultiResponse) => void
|
||||
): void;
|
||||
/**
|
||||
* Query on multiple index
|
||||
* https://github.com/algolia/algoliasearch-client-js#multiple-queries---multiplequeries
|
||||
*/
|
||||
search(
|
||||
queries: {
|
||||
indexName: string;
|
||||
query: string;
|
||||
params: QueryParameters;
|
||||
}[]
|
||||
): Promise<MultiResponse>;
|
||||
/**
|
||||
* Query for facet values of a specific facet
|
||||
*/
|
||||
searchForFacetValues(
|
||||
queries: [{ indexName: string; params: SearchForFacetValues.Parameters }]
|
||||
): Promise<SearchForFacetValues.Response[]>;
|
||||
/**
|
||||
* clear browser cache
|
||||
* https://github.com/algolia/algoliasearch-client-js#cache
|
||||
*/
|
||||
clearCache(): void;
|
||||
/**
|
||||
* Add a header to be sent with all upcoming requests
|
||||
*/
|
||||
setExtraHeader(name: string, value: string): void;
|
||||
/**
|
||||
* Get the value of an extra header
|
||||
*/
|
||||
getExtraHeader(name: string): string;
|
||||
/**
|
||||
* remove an extra header for all upcoming requests
|
||||
*/
|
||||
unsetExtraHeader(name: string): void;
|
||||
}
|
||||
/**
|
||||
* Interface for the index algolia object
|
||||
*/
|
||||
interface Index {
|
||||
/**
|
||||
* Gets a specific object
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObject(objectID: string, cb: (err: Error, res: {}) => void): void;
|
||||
/**
|
||||
* Gets specific attributes from an object
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObject(
|
||||
objectID: string,
|
||||
attributes: string[],
|
||||
cb: (err: Error, res: {}) => void
|
||||
): void;
|
||||
/**
|
||||
* Gets a list of objects
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObjects(
|
||||
objectIDs: string[],
|
||||
cb: (err: Error, res: { results: {}[] }) => void
|
||||
): void;
|
||||
/**
|
||||
* Gets a list of objects
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObjects(objectIDs: string[]): Promise<{ results: {}[] }>;
|
||||
/**
|
||||
* Clear cache of an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#cache
|
||||
*/
|
||||
clearCache(): void;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-in-an-index---search
|
||||
*/
|
||||
search(
|
||||
params: QueryParameters,
|
||||
cb: (err: Error, res: Response) => void
|
||||
): void;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-in-an-index---search
|
||||
*/
|
||||
search(params: QueryParameters): Promise<Response>;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search-for-facet-values/
|
||||
*/
|
||||
searchForFacetValues(
|
||||
options: SearchForFacetValues.Parameters
|
||||
): Promise<SearchForFacetValues.Response>;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search-for-facet-values/
|
||||
*/
|
||||
searchForFacetValues(
|
||||
options: SearchForFacetValues.Parameters,
|
||||
cb: (err: Error, res: SearchForFacetValues.Response) => void
|
||||
): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string, cb: (err: Error, res: BrowseResponse) => void): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string): Promise<BrowseResponse>;
|
||||
/**
|
||||
* Browse an index from a cursor
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browseFrom(
|
||||
cursor: string,
|
||||
cb: (err: Error, res: BrowseResponse) => void
|
||||
): void;
|
||||
/**
|
||||
* Browse an index from a cursor
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browseFrom(cursor: string): Promise<BrowseResponse>;
|
||||
}
|
||||
/**
|
||||
* Interface describing available options when initializing a client
|
||||
*/
|
||||
interface ClientOptions {
|
||||
/**
|
||||
* Timeout for requests to our servers, in milliseconds
|
||||
* default: 15s (node), 2s (browser)
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Protocol to use when communicating with algolia
|
||||
* default: current protocol(browser), https(node)
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* (node only) httpAgent instance to use when communicating with servers.
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
httpAgent?: any;
|
||||
/**
|
||||
* read: array of read hosts to use to call servers, computed automatically
|
||||
* write: array of read hosts to use to call servers, computed automatically
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
hosts?: { read?: string[]; write?: string[] };
|
||||
}
|
||||
interface BrowseResponse {
|
||||
cursor?: string;
|
||||
hits: {}[];
|
||||
params: string;
|
||||
query: string;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
|
||||
interface QueryParameters {
|
||||
/**
|
||||
* Query string used to perform the search
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#query
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* Filter the query with numeric, facet or/and tag filters
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#filters
|
||||
*/
|
||||
filters?: string;
|
||||
/**
|
||||
* A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.
|
||||
* default: *
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestoretrieve
|
||||
*/
|
||||
attributesToRetrieve?: string[];
|
||||
/**
|
||||
* List of attributes you want to use for textual search
|
||||
* default: attributeToIndex
|
||||
* https://github.com/algolia/algoliasearch-client-js#restrictsearchableattributes
|
||||
*/
|
||||
restrictSearchableAttributes?: string[];
|
||||
/**
|
||||
* You can use facets to retrieve only a part of your attributes declared in attributesForFaceting attributes
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#facets
|
||||
*/
|
||||
facets?: string;
|
||||
/**
|
||||
* Limit the number of facet values returned for each facet.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#maxvaluesperfacet
|
||||
*/
|
||||
maxValuesPerFacet?: number;
|
||||
/**
|
||||
* Default list of attributes to highlight. If set to null, all indexed attributes are highlighted.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestohighlight
|
||||
*/
|
||||
attributesToHighlight?: string[];
|
||||
/**
|
||||
* Default list of attributes to snippet alongside the number of words to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestosnippet
|
||||
*/
|
||||
attributesToSnippet?: string[];
|
||||
/**
|
||||
* Specify the string that is inserted before the highlighted parts in the query result
|
||||
* default: <em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightpretag
|
||||
*/
|
||||
highlightPreTag?: string;
|
||||
/**
|
||||
* Specify the string that is inserted after the highlighted parts in the query result
|
||||
* default: </em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightposttag
|
||||
*/
|
||||
highlightPostTag?: string;
|
||||
/**
|
||||
* String used as an ellipsis indicator when a snippet is truncated.
|
||||
* default: …
|
||||
* https://github.com/algolia/algoliasearch-client-js#snippetellipsistext
|
||||
*/
|
||||
snippetEllipsisText?: string;
|
||||
/**
|
||||
* If set to true, restrict arrays in highlights and snippets to items that matched the query at least partially else return all array items in highlights and snippets
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#restricthighlightandsnippetarrays
|
||||
*/
|
||||
restrictHighlightAndSnippetArrays?: boolean;
|
||||
/**
|
||||
* Pagination parameter used to select the number of hits per page
|
||||
* default: 20
|
||||
* https://github.com/algolia/algoliasearch-client-js#hitsperpage
|
||||
*/
|
||||
hitsPerPage?: number;
|
||||
/**
|
||||
* Pagination parameter used to select the page to retrieve.
|
||||
* default: 0
|
||||
* https://github.com/algolia/algoliasearch-client-js#page
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* Offset of the first hit to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#offset
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Number of hits to return.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#length
|
||||
*/
|
||||
length?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept one typo.
|
||||
* default: 4
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor1typo
|
||||
*/
|
||||
minWordSizefor1Typo?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept two typo.
|
||||
* fault: 8
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
*/
|
||||
minWordSizefor2Typos?: number;
|
||||
/**
|
||||
* This option allows you to control the number of typos allowed in the result set:
|
||||
* default: true
|
||||
* 'true' The typo tolerance is enabled and all matching hits are retrieved
|
||||
* 'false' The typo tolerance is disabled. All results with typos will be hidden.
|
||||
* 'min' Only keep results with the minimum number of typos
|
||||
* 'strict' Hits matching with 2 typos are not retrieved if there are some matching without typos.
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
*/
|
||||
typoTolerance?: boolean;
|
||||
/**
|
||||
* If set to false, disables typo tolerance on numeric tokens (numbers).
|
||||
* default:
|
||||
* https://github.com/algolia/algoliasearch-client-js#allowtyposonnumerictokens
|
||||
*/
|
||||
allowTyposOnNumericTokens?: boolean;
|
||||
/**
|
||||
* If set to true, plural won't be considered as a typo
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#ignoreplurals
|
||||
*/
|
||||
ignorePlurals?: boolean;
|
||||
/**
|
||||
* List of attributes on which you want to disable typo tolerance
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#disabletypotoleranceonattributes
|
||||
*/
|
||||
disableTypoToleranceOnAttributes?: string;
|
||||
/**
|
||||
* Search for entries around a given location
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlng
|
||||
*/
|
||||
aroundLatLng?: string;
|
||||
/**
|
||||
* Search for entries around a given latitude/longitude automatically computed from user IP address.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlngviaip
|
||||
*/
|
||||
aroundLatLngViaIP?: string;
|
||||
/**
|
||||
* Control the radius associated with a geo search. Defined in meters.
|
||||
* default: null
|
||||
* You can specify aroundRadius=all if you want to compute the geo distance without filtering in a geo area
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundradius
|
||||
*/
|
||||
aroundRadius?: number | 'all';
|
||||
/**
|
||||
* Control the precision of a geo search
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundprecision
|
||||
*/
|
||||
aroundPrecision?: number;
|
||||
/**
|
||||
* Define the minimum radius used for a geo search when aroundRadius is not set.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#minimumaroundradius
|
||||
*/
|
||||
minimumAroundRadius?: number;
|
||||
/**
|
||||
* Search entries inside a given area defined by the two extreme points of a rectangle
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#insideboundingbox
|
||||
*/
|
||||
insideBoundingBox?: number[][];
|
||||
/**
|
||||
* Selects how the query words are interpreted
|
||||
* default: 'prefixLast'
|
||||
* 'prefixAll' All query words are interpreted as prefixes. This option is not recommended.
|
||||
* 'prefixLast' Only the last word is interpreted as a prefix (default behavior).
|
||||
* 'prefixNone' No query word is interpreted as a prefix. This option is not recommended.
|
||||
* https://github.com/algolia/algoliasearch-client-js#querytype
|
||||
*/
|
||||
queryType?: any;
|
||||
/**
|
||||
* Search entries inside a given area defined by a set of points
|
||||
* defauly: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#insidepolygon
|
||||
*/
|
||||
insidePolygon?: number[][];
|
||||
/**
|
||||
* This option is used to select a strategy in order to avoid having an empty result page
|
||||
* default: 'none'
|
||||
* 'lastWords' When a query does not return any results, the last word will be added as optional
|
||||
* 'firstWords' When a query does not return any results, the first word will be added as optional
|
||||
* 'allOptional' When a query does not return any results, a second trial will be made with all words as optional
|
||||
* 'none' No specific processing is done when a query does not return any results
|
||||
* https://github.com/algolia/algoliasearch-client-js#removewordsifnoresults
|
||||
*/
|
||||
removeWordsIfNoResults?: string;
|
||||
/**
|
||||
* Enables the advanced query syntax
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#advancedsyntax
|
||||
*/
|
||||
advancedSyntax?: boolean;
|
||||
/**
|
||||
* A string that contains the comma separated list of words that should be considered as optional when found in the query
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#optionalwords
|
||||
*/
|
||||
optionalWords?: string[];
|
||||
/**
|
||||
* Remove stop words from the query before executing it
|
||||
* default: false
|
||||
* true|false: enable or disable stop words for all 41 supported languages; or
|
||||
* a list of language ISO codes (as a comma-separated string) for which stop words should be enable
|
||||
* https://github.com/algolia/algoliasearch-client-js#removestopwords
|
||||
*/
|
||||
removeStopWords?: string[];
|
||||
/**
|
||||
* List of attributes on which you want to disable the computation of exact criteria
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#disableexactonattributes
|
||||
*/
|
||||
disableExactOnAttributes?: string[];
|
||||
/**
|
||||
* This parameter control how the exact ranking criterion is computed when the query contains one word
|
||||
* default: attribute
|
||||
* 'none': no exact on single word query
|
||||
* 'word': exact set to 1 if the query word is found in the record
|
||||
* 'attribute': exact set to 1 if there is an attribute containing a string equals to the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#exactonsinglewordquery
|
||||
*/
|
||||
exactOnSingleWordQuery?: string;
|
||||
/**
|
||||
* Specify the list of approximation that should be considered as an exact match in the ranking formula
|
||||
* default: ['ignorePlurals', 'singleWordSynonym']
|
||||
* 'ignorePlurals': alternative words added by the ignorePlurals feature
|
||||
* 'singleWordSynonym': single-word synonym (For example "NY" = "NYC")
|
||||
* 'multiWordsSynonym': multiple-words synonym
|
||||
* https://github.com/algolia/algoliasearch-client-js#alternativesasexact
|
||||
*/
|
||||
alternativesAsExact?: any;
|
||||
/**
|
||||
* If set to 1, enables the distinct feature, disabled by default, if the attributeForDistinct index setting is set.
|
||||
* https://github.com/algolia/algoliasearch-client-js#distinct
|
||||
*/
|
||||
distinct?: any;
|
||||
/**
|
||||
* If set to true, the result hits will contain ranking information in the _rankingInfo attribute.
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#getrankinginfo
|
||||
*/
|
||||
getRankingInfo?: boolean;
|
||||
/**
|
||||
* All numerical attributes are automatically indexed as numerical filters
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericattributestoindex
|
||||
*/
|
||||
numericAttributesToIndex?: string[];
|
||||
/**
|
||||
* @deprecated please use filters instead
|
||||
* A string that contains the comma separated list of numeric filters you want to apply.
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericfilters-deprecated
|
||||
*/
|
||||
numericFilters?: string[];
|
||||
/**
|
||||
* @deprecated
|
||||
* Filter the query by a set of tags.
|
||||
* https://github.com/algolia/algoliasearch-client-js#tagfilters-deprecated
|
||||
*/
|
||||
tagFilters?: string;
|
||||
/**
|
||||
* @deprecated
|
||||
* Filter the query by a set of facets.
|
||||
* https://github.com/algolia/algoliasearch-client-js#facetfilters-deprecated
|
||||
*/
|
||||
facetFilters?: string;
|
||||
/**
|
||||
* If set to false, this query will not be taken into account in the analytics feature.
|
||||
* default true
|
||||
* https://github.com/algolia/algoliasearch-client-js#analytics
|
||||
*/
|
||||
analytics?: boolean;
|
||||
/**
|
||||
* If set, tag your query with the specified identifiers
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#analyticstags
|
||||
*/
|
||||
analyticsTags?: string[];
|
||||
/**
|
||||
* If set to false, the search will not use the synonyms defined for the targeted index.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#synonyms
|
||||
*/
|
||||
synonyms?: boolean;
|
||||
/**
|
||||
* If set to false, words matched via synonym expansion will not be replaced by the matched synonym in the highlighted result.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#replacesynonymsinhighlight
|
||||
*/
|
||||
replaceSynonymsInHighlight?: boolean;
|
||||
/**
|
||||
* Configure the precision of the proximity ranking criterion
|
||||
* default: 1
|
||||
* https://github.com/algolia/algoliasearch-client-js#minproximity
|
||||
*/
|
||||
minProximity?: number;
|
||||
|
||||
nbShards?: number;
|
||||
userData?: string | object;
|
||||
}
|
||||
|
||||
interface AlgoliaResponse {
|
||||
/**
|
||||
* Contains all the hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* Current page
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* Number of total hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* Number of pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbPage: number;
|
||||
/**
|
||||
* Number of hits per pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* Engine processing time (excluding network transfer)
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* Query used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* GET parameters used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
params: string;
|
||||
facets: {
|
||||
[facetName: string]: { [facetValue: string]: number };
|
||||
};
|
||||
}
|
||||
|
||||
namespace SearchForFacetValues {
|
||||
interface Parameters extends QueryParameters {
|
||||
/**
|
||||
* The facet to search in
|
||||
*/
|
||||
facetName: string;
|
||||
/**
|
||||
* The query for the search in this facet
|
||||
*/
|
||||
facetQuery: string;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
facetHits: { value: string; highlighted: string; count: number }[];
|
||||
exhaustiveFacetsCount: boolean;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
}
|
||||
|
||||
interface Response {
|
||||
/**
|
||||
* Contains all the hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* Current page
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* Number of total hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* Number of pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbPages: number;
|
||||
/**
|
||||
* Number of hits per pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* Engine processing time (excluding network transfer)
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* Query used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* GET parameters used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
params: string;
|
||||
facets?: {
|
||||
[facetName: string]: { [facetValue: string]: number };
|
||||
};
|
||||
}
|
||||
|
||||
interface MultiResponse {
|
||||
results: Response[];
|
||||
}
|
||||
}
|
||||
|
||||
declare function algoliasearch(
|
||||
applicationId: string,
|
||||
apiKey: string,
|
||||
options?: algoliasearch.ClientOptions
|
||||
): algoliasearch.Client;
|
||||
export = algoliasearch;
|
||||
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lite/index.d.ts",
|
||||
"algoliasearch-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+577
@@ -0,0 +1,577 @@
|
||||
// Type definitions for amazon-cognito-auth-js 1.2
|
||||
// Project: https://github.com/aws/amazon-cognito-auth-js
|
||||
// Definitions by: Scott Escue <https://github.com/scottescue>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/*
|
||||
* Create global variable to provide access to types when used without module
|
||||
* loading.
|
||||
*/
|
||||
export as namespace AmazonCognitoIdentity;
|
||||
|
||||
// Stubs the XDomainRequest built-in from older IE browsers, does not follow the project's interface naming convention
|
||||
export interface XDomainRequest {
|
||||
readonly responseText: string;
|
||||
timeout: number;
|
||||
onprogress: () => void;
|
||||
ontimeout: () => void;
|
||||
onerror: () => void;
|
||||
onload: () => void;
|
||||
|
||||
open(method: string, url: string): void;
|
||||
send(data: string): void;
|
||||
abort(): void;
|
||||
}
|
||||
|
||||
export interface CognitoSessionData {
|
||||
/**
|
||||
* The session's Id token.
|
||||
*/
|
||||
IdToken?: CognitoIdToken;
|
||||
|
||||
/**
|
||||
* The session's refresh token.
|
||||
*/
|
||||
RefreshToken?: CognitoRefreshToken;
|
||||
|
||||
/**
|
||||
* The session's access token.
|
||||
*/
|
||||
AccessToken?: CognitoAccessToken;
|
||||
|
||||
/**
|
||||
* The session's token scopes.
|
||||
*/
|
||||
TokenScopes?: CognitoTokenScopes;
|
||||
|
||||
/**
|
||||
* The session's state.
|
||||
*/
|
||||
State?: string;
|
||||
}
|
||||
|
||||
export interface CognitoAuthOptions {
|
||||
/**
|
||||
* Required: User pool application client id.
|
||||
*/
|
||||
ClientId: string;
|
||||
|
||||
/**
|
||||
* Required: The application/user-pools Cognito web hostname,this is set at the Cognito console.
|
||||
*/
|
||||
AppWebDomain: string;
|
||||
|
||||
/**
|
||||
* Optional: The token scopes
|
||||
*/
|
||||
TokenScopesArray?: ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
* Required: Required: The redirect Uri, which will be launched after authentication as signed in.
|
||||
*/
|
||||
RedirectUriSignIn: string;
|
||||
|
||||
/**
|
||||
* Required: The redirect Uri, which will be launched when signed out.
|
||||
*/
|
||||
RedirectUriSignOut: string;
|
||||
|
||||
/**
|
||||
* Optional: Pre-selected identity provider (this allows to automatically trigger social provider authentication flow).
|
||||
*/
|
||||
IdentityProvider?: string;
|
||||
|
||||
/**
|
||||
* Optional: UserPoolId for the configured cognito userPool.
|
||||
*/
|
||||
UserPoolId?: string;
|
||||
|
||||
/**
|
||||
* Optional: boolean flag indicating if the data collection is enabled to support cognito advanced security features. By default, this flag is set to true.
|
||||
*/
|
||||
AdvancedSecurityDataCollectionFlag?: boolean;
|
||||
}
|
||||
|
||||
export interface CognitoAuthUserHandler {
|
||||
onSuccess: (authSession: CognitoAuthSession) => void;
|
||||
onFailure: (err: any) => void;
|
||||
}
|
||||
|
||||
export interface CognitoConstants {
|
||||
DOMAIN_SCHEME: string;
|
||||
DOMAIN_PATH_SIGNIN: string;
|
||||
DOMAIN_PATH_TOKEN: string;
|
||||
DOMAIN_PATH_SIGNOUT: string;
|
||||
DOMAIN_QUERY_PARAM_REDIRECT_URI: string;
|
||||
DOMAIN_QUERY_PARAM_SIGNOUT_URI: string;
|
||||
DOMAIN_QUERY_PARAM_RESPONSE_TYPE: string;
|
||||
DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER: string;
|
||||
DOMAIN_QUERY_PARAM_USERCONTEXTDATA: string;
|
||||
CLIENT_ID: string;
|
||||
STATE: string;
|
||||
SCOPE: string;
|
||||
TOKEN: string;
|
||||
CODE: string;
|
||||
POST: string;
|
||||
PARAMETERERROR: string;
|
||||
SCOPETYPEERROR: string;
|
||||
QUESTIONMARK: string;
|
||||
POUNDSIGN: string;
|
||||
COLONDOUBLESLASH: string;
|
||||
SLASH: string;
|
||||
AMPERSAND: string;
|
||||
EQUALSIGN: string;
|
||||
SPACE: string;
|
||||
CONTENTTYPE: string;
|
||||
CONTENTTYPEVALUE: string;
|
||||
AUTHORIZATIONCODE: string;
|
||||
IDTOKEN: string;
|
||||
ACCESSTOKEN: string;
|
||||
REFRESHTOKEN: string;
|
||||
ERROR: string;
|
||||
ERROR_DESCRIPTION: string;
|
||||
STRINGTYPE: string;
|
||||
STATELENGTH: number;
|
||||
STATEORIGINSTRING: string;
|
||||
WITHCREDENTIALS: string;
|
||||
UNDEFINED: string;
|
||||
SELF: string;
|
||||
HOSTNAMEREGEX: RegExp;
|
||||
QUERYPARAMETERREGEX1: RegExp;
|
||||
QUERYPARAMETERREGEX2: RegExp;
|
||||
HEADER: { 'Content-Type': string };
|
||||
}
|
||||
|
||||
export class CognitoIdToken {
|
||||
/**
|
||||
* Constructs a new CognitoIdToken object
|
||||
* @param IdToken The JWT Id token
|
||||
*/
|
||||
constructor(IdToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getJwtToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for id token.
|
||||
* @param idToken The JWT Id token
|
||||
*/
|
||||
setJwtToken(idToken: string): void;
|
||||
|
||||
/**
|
||||
* @returns the token's expiration (exp member).
|
||||
*/
|
||||
getExpiration(): number;
|
||||
|
||||
/**
|
||||
* @returns the token's payload.
|
||||
*/
|
||||
decodePayload(): object;
|
||||
}
|
||||
|
||||
export class CognitoRefreshToken {
|
||||
/**
|
||||
* Constructs a new CognitoRefreshToken object
|
||||
* @param RefreshToken The JWT refresh token.
|
||||
*/
|
||||
constructor(RefreshToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for refresh token.
|
||||
* @param refreshToken The JWT refresh token.
|
||||
*/
|
||||
setToken(refreshToken: string): void;
|
||||
}
|
||||
|
||||
export class CognitoAccessToken {
|
||||
/**
|
||||
* Constructs a new CognitoAccessToken object
|
||||
* @param AccessToken The JWT access token.
|
||||
*/
|
||||
constructor(AccessToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getJwtToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for access token.
|
||||
* @param accessToken The JWT access token.
|
||||
*/
|
||||
setJwtToken(accessToken: string): void;
|
||||
|
||||
/**
|
||||
* @returns the token's expiration (exp member).
|
||||
*/
|
||||
getExpiration(): number;
|
||||
|
||||
/**
|
||||
* @returns the username from payload.
|
||||
*/
|
||||
getUsername(): string;
|
||||
|
||||
/**
|
||||
* @returns the token's payload.
|
||||
*/
|
||||
decodePayload(): object;
|
||||
}
|
||||
|
||||
export class CognitoTokenScopes {
|
||||
/**
|
||||
* Constructs a new CognitoTokenScopes object
|
||||
* @param TokenScopesArray The token scopes
|
||||
*/
|
||||
constructor(TokenScopesArray: ReadonlyArray<string>);
|
||||
|
||||
/**
|
||||
* @returns the token scopes.
|
||||
*/
|
||||
getScopes(): string[];
|
||||
|
||||
/**
|
||||
* Sets new value for token scopes.
|
||||
* @param tokenScopes The token scopes
|
||||
*/
|
||||
setTokenScopes(tokenScopes: ReadonlyArray<string>): void;
|
||||
}
|
||||
|
||||
export class CognitoAuthSession {
|
||||
/**
|
||||
* Constructs a new CognitoUserSession object
|
||||
* @param sessionData The session's tokens, scopes, and state.
|
||||
*/
|
||||
constructor(sessionData: CognitoSessionData);
|
||||
|
||||
/**
|
||||
* @returns the session's Id token
|
||||
*/
|
||||
getIdToken(): CognitoIdToken;
|
||||
|
||||
/**
|
||||
* Set a new Id token
|
||||
* @param IdToken The session's Id token.
|
||||
*/
|
||||
setIdToken(IdToken: CognitoIdToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's refresh token
|
||||
*/
|
||||
getRefreshToken(): CognitoRefreshToken;
|
||||
|
||||
/**
|
||||
* Set a new Refresh token
|
||||
* @param RefreshToken The session's refresh token.
|
||||
*/
|
||||
setRefreshToken(RefreshToken: CognitoRefreshToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's access token
|
||||
*/
|
||||
getAccessToken(): CognitoAccessToken;
|
||||
|
||||
/**
|
||||
* Set a new Access token
|
||||
* @param AccessToken The session's access token.
|
||||
*/
|
||||
setAccessToken(AccessToken: CognitoAccessToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's token scopes
|
||||
*/
|
||||
getTokenScopes(): CognitoTokenScopes;
|
||||
|
||||
/**
|
||||
* Set new token scopes
|
||||
* @param tokenScopes The session's token scopes.
|
||||
*/
|
||||
setTokenScopes(tokenScopes: CognitoTokenScopes): void;
|
||||
|
||||
/**
|
||||
* @returns the session's state
|
||||
*/
|
||||
getState(): string;
|
||||
|
||||
/**
|
||||
* Set new state
|
||||
* @param state The session's state.
|
||||
*/
|
||||
setState(State: string): void;
|
||||
|
||||
/**
|
||||
* Checks to see if the session is still valid based on session expiry information found
|
||||
* in Access and Id Tokens and the current time
|
||||
* @returns if the session is still valid
|
||||
*/
|
||||
isValid(): boolean;
|
||||
}
|
||||
|
||||
export class CognitoAuth {
|
||||
/**
|
||||
* Called on success or error.
|
||||
*/
|
||||
userhandler: CognitoAuthUserHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new CognitoAuth object
|
||||
* @param options Creation options
|
||||
*/
|
||||
constructor(options: CognitoAuthOptions);
|
||||
|
||||
/**
|
||||
* @returns the constants
|
||||
*/
|
||||
getCognitoConstants(): CognitoConstants;
|
||||
|
||||
/**
|
||||
* @returns the client id
|
||||
*/
|
||||
getClientId(): string;
|
||||
|
||||
/**
|
||||
* @returns the app web domain
|
||||
*/
|
||||
getAppWebDomain(): string;
|
||||
|
||||
/**
|
||||
* method for getting the current user of the application from the local storage
|
||||
*
|
||||
* @returns the user retrieved from storage
|
||||
*/
|
||||
getCurrentUser(): string;
|
||||
|
||||
/**
|
||||
* method for setting the current user's name
|
||||
* @param Username the user's name
|
||||
*/
|
||||
setUser(Username: string): void;
|
||||
|
||||
/**
|
||||
* sets response type to 'code'
|
||||
*/
|
||||
useCodeGrantFlow(): void;
|
||||
|
||||
/**
|
||||
* sets response type to 'token'
|
||||
*/
|
||||
useImplicitFlow(): void;
|
||||
|
||||
/**
|
||||
* @returns the current session for this user
|
||||
*/
|
||||
getSignInUserSession(): CognitoAuthSession;
|
||||
|
||||
/**
|
||||
* @returns the user's username
|
||||
*/
|
||||
getUsername(): string;
|
||||
|
||||
/**
|
||||
* @param Username the user's username
|
||||
*/
|
||||
setUsername(Username: string): void;
|
||||
|
||||
/**
|
||||
* @returns the user's state
|
||||
*/
|
||||
getState(): string;
|
||||
|
||||
/**
|
||||
* @param State the user's state
|
||||
*/
|
||||
setState(State: string): void;
|
||||
|
||||
/**
|
||||
* This is used to get a session, either from the session object or from the local storage, or by using a refresh token
|
||||
* @param RedirectUriSignIn Required: The redirect Uri, which will be launched after authentication.
|
||||
* @param TokenScopesArray Required: The token scopes, it is an array of strings specifying all scopes for the tokens.
|
||||
*/
|
||||
getSession(): void;
|
||||
|
||||
/**
|
||||
* Parse the http request response and proceed according to different response types.
|
||||
* @param httpRequestResponse the http request response
|
||||
*/
|
||||
parseCognitoWebResponse(httpRequestResponse: string): void;
|
||||
|
||||
/**
|
||||
* Get the query parameter map and proceed according to code response type.
|
||||
* @param Query parameter map
|
||||
*/
|
||||
getCodeQueryParameter(map: ReadonlyMap<string, string>): void;
|
||||
|
||||
/**
|
||||
* Get the query parameter map and proceed according to token response type.
|
||||
* @param Query parameter map
|
||||
*/
|
||||
getTokenQueryParameter(map: ReadonlyMap<string, string>): void;
|
||||
|
||||
/**
|
||||
* Get cached tokens and scopes and return a new session using all the cached data.
|
||||
* @returns the auth session
|
||||
*/
|
||||
getCachedSession(): CognitoAuthSession;
|
||||
|
||||
/**
|
||||
* This is used to get last signed in user from local storage
|
||||
* @returns the last user name
|
||||
*/
|
||||
getLastUser(): string;
|
||||
|
||||
/**
|
||||
* This is used to save the session tokens and scopes to local storage.
|
||||
*/
|
||||
cacheTokensScopes(): void;
|
||||
|
||||
/**
|
||||
* Compare two sets if they are identical.
|
||||
* @param set1 one set
|
||||
* @param set2 the other set
|
||||
* @returns boolean value is true if two sets are identical
|
||||
*/
|
||||
compareSets(set1: ReadonlySet<any>, set2: ReadonlySet<any>): boolean;
|
||||
|
||||
/**
|
||||
* Get the hostname from url.
|
||||
* @param url the url string
|
||||
* @returns hostname string
|
||||
*/
|
||||
getHostName(url: string): string;
|
||||
|
||||
/**
|
||||
* Get http query parameters and return them as a map.
|
||||
* @param url the url string
|
||||
* @param splitMark query parameters split mark (prefix)
|
||||
* @returns map
|
||||
*/
|
||||
getQueryParameters(url: string, splitMark: string): Map<string, string>;
|
||||
|
||||
/**
|
||||
* helper function to generate a random string
|
||||
* @param length the length of string
|
||||
* @param chars a original string
|
||||
* @returns a random value.
|
||||
*/
|
||||
generateRandomString(length: number, chars: string): string;
|
||||
|
||||
/**
|
||||
* This is used to clear the session tokens and scopes from local storage
|
||||
*/
|
||||
clearCachedTokensScopes(): void;
|
||||
|
||||
/**
|
||||
* This is used to build a user session from tokens retrieved in the authentication result
|
||||
* @param refreshToken Successful auth response from server.
|
||||
*/
|
||||
refreshSession(refreshToken: string): void;
|
||||
|
||||
/**
|
||||
* Make the http POST request.
|
||||
* @param header header JSON object
|
||||
* @param body body JSON object
|
||||
* @param url string
|
||||
* @param onSuccess callback
|
||||
* @param onFailure callback
|
||||
*/
|
||||
makePOSTRequest(header: object, body: object, url: string,
|
||||
onSuccess: (responseText: string) => void,
|
||||
onFailure: (responseText: string) => void): void;
|
||||
|
||||
/**
|
||||
* Create the XHR object
|
||||
* @param method which method to call
|
||||
* @param url the url string
|
||||
* @returns xhr
|
||||
*/
|
||||
createCORSRequest(method: string, url: string): XMLHttpRequest | XDomainRequest;
|
||||
|
||||
/**
|
||||
* The http POST request onFailure callback.
|
||||
* @param err the error object
|
||||
*/
|
||||
onFailure(err: any): void;
|
||||
|
||||
/**
|
||||
* The http POST request onSuccess callback when refreshing tokens.
|
||||
* @param jsonData tokens
|
||||
*/
|
||||
onSuccessRefreshToken(jsonData: string): void;
|
||||
|
||||
/**
|
||||
* The http POST request onSuccess callback when exchanging code for tokens.
|
||||
* @param jsonData tokens
|
||||
*/
|
||||
onSuccessExchangeForToken(jsonData: string): void;
|
||||
|
||||
/**
|
||||
* Launch Cognito Auth UI page.
|
||||
* @param URL the url to launch
|
||||
*/
|
||||
launchUri(URL: string): void;
|
||||
|
||||
/**
|
||||
* @returns scopes string
|
||||
*/
|
||||
getSpaceSeperatedScopeString(): string;
|
||||
|
||||
/**
|
||||
* Create the FQDN(fully qualified domain name) for authorization endpoint.
|
||||
* @returns url
|
||||
*/
|
||||
getFQDNSignIn(): string;
|
||||
|
||||
/**
|
||||
* Sign out the user.
|
||||
*/
|
||||
signOut(): void;
|
||||
|
||||
/**
|
||||
* Create the FQDN(fully qualified domain name) for signout endpoint.
|
||||
* @returns url
|
||||
*/
|
||||
getFQDNSignOut(): string;
|
||||
|
||||
/**
|
||||
* This method returns the encoded data string used for cognito advanced security feature.
|
||||
* This would be generated only when developer has included the JS used for collecting the
|
||||
* data on their client. Please refer to documentation to know more about using AdvancedSecurity
|
||||
* features
|
||||
*/
|
||||
getUserContextData(): string;
|
||||
|
||||
/**
|
||||
* Helper method to let the user know if he has either a valid cached session
|
||||
* or a valid authenticated session from the app integration callback.
|
||||
* @returns userSignedIn
|
||||
*/
|
||||
isUserSignedIn(): boolean;
|
||||
}
|
||||
|
||||
export class DateHelper {
|
||||
/**
|
||||
* @returns The current time in "ddd MMM D HH:mm:ss UTC YYYY" format.
|
||||
*/
|
||||
getNowString(): string;
|
||||
}
|
||||
|
||||
export class StorageHelper {
|
||||
/**
|
||||
* This is used to get a storage object
|
||||
* @returns the storage
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* This is used to return the storage
|
||||
* @returns the storage
|
||||
*/
|
||||
getStorage(): Storage;
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
import * as lib from 'amazon-cognito-auth-js';
|
||||
|
||||
const idToken: lib.CognitoIdToken = new lib.CognitoIdToken('fak3T0ken1==');
|
||||
idToken.decodePayload(); // $ExpectType object
|
||||
idToken.setJwtToken('fak3T0ken2=='); // $ExpectType void
|
||||
idToken.getJwtToken(); // $ExpectType string
|
||||
idToken.getExpiration(); // $ExpectType number
|
||||
|
||||
const refreshToken: lib.CognitoRefreshToken = new lib.CognitoRefreshToken('refreshplease==');
|
||||
refreshToken.setToken('refreshagainplease=='); // $ExpectType void
|
||||
refreshToken.getToken(); // $ExpectType string
|
||||
|
||||
const accessToken: lib.CognitoAccessToken = new lib.CognitoAccessToken('fak3T0ken3==');
|
||||
accessToken.decodePayload(); // $ExpectType object
|
||||
accessToken.setJwtToken('fak3T0ken4=='); // $ExpectType void
|
||||
accessToken.getJwtToken(); // $ExpectType string
|
||||
accessToken.getExpiration(); // $ExpectType number
|
||||
accessToken.getUsername(); // $ExpectType string
|
||||
|
||||
const tokenScopes: lib.CognitoTokenScopes = new lib.CognitoTokenScopes(['email', 'custom1']);
|
||||
tokenScopes.setTokenScopes(['openid']); // $ExpectType void
|
||||
tokenScopes.getScopes(); // $ExpectType string[]
|
||||
|
||||
let sessionData: lib.CognitoSessionData = {};
|
||||
let authSession: lib.CognitoAuthSession = new lib.CognitoAuthSession(sessionData);
|
||||
|
||||
sessionData = {
|
||||
IdToken: idToken,
|
||||
RefreshToken: refreshToken,
|
||||
AccessToken: accessToken,
|
||||
TokenScopes: tokenScopes,
|
||||
State: '/myapp/home'
|
||||
};
|
||||
authSession = new lib.CognitoAuthSession(sessionData);
|
||||
|
||||
authSession.setIdToken(new lib.CognitoIdToken('fak3T0ken5==')); // $ExpectType void
|
||||
authSession.setRefreshToken(new lib.CognitoRefreshToken('refreshmeyetagain==')); // $ExpectType void
|
||||
authSession.setAccessToken(new lib.CognitoAccessToken('fak3T0ken6==')); // $ExpectType void
|
||||
authSession.setTokenScopes(new lib.CognitoTokenScopes(['email'])); // $ExpectType void
|
||||
authSession.setState('/myapp/login'); // $ExpectType void
|
||||
authSession.getIdToken(); // $ExpectType CognitoIdToken
|
||||
authSession.getRefreshToken(); // $ExpectType CognitoRefreshToken
|
||||
authSession.getAccessToken(); // $ExpectType CognitoAccessToken
|
||||
authSession.getTokenScopes(); // $ExpectType CognitoTokenScopes
|
||||
authSession.getState(); // $ExpectType string
|
||||
|
||||
let authOptions: lib.CognitoAuthOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout'
|
||||
};
|
||||
let auth: lib.CognitoAuth = new lib.CognitoAuth(authOptions);
|
||||
|
||||
authOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
TokenScopesArray: ['email', 'openid'],
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout',
|
||||
IdentityProvider: 'Facebook',
|
||||
UserPoolId: 'us-east-1_faKE4ReAl',
|
||||
AdvancedSecurityDataCollectionFlag: true
|
||||
};
|
||||
auth = new lib.CognitoAuth(authOptions);
|
||||
|
||||
auth.getClientId(); // $ExpectType string
|
||||
auth.getAppWebDomain(); // $ExpectType string
|
||||
auth.getCurrentUser(); // $ExpectType string
|
||||
auth.setUser('jane.doe'); // $ExpectType void
|
||||
auth.useCodeGrantFlow(); // $ExpectType void
|
||||
auth.useImplicitFlow(); // $ExpectType void
|
||||
auth.getSignInUserSession(); // $ExpectType CognitoAuthSession
|
||||
auth.getUsername(); // $ExpectType string
|
||||
auth.setUsername('john.doe'); // $ExpectType void
|
||||
auth.getState(); // $ExpectType string
|
||||
auth.setState('/myhost/default.htm'); // $ExpectType void
|
||||
auth.getSession(); // $ExpectType void
|
||||
auth.parseCognitoWebResponse('url&stuff=true'); // $ExpectType void
|
||||
auth.getCodeQueryParameter(new Map()); // $ExpectType void
|
||||
auth.getTokenQueryParameter(new Map()); // $ExpectType void
|
||||
auth.getCachedSession(); // $ExpectType CognitoAuthSession
|
||||
auth.getLastUser(); // $ExpectType string
|
||||
auth.cacheTokensScopes(); // $ExpectType void
|
||||
auth.compareSets(new Set(['1']), new Set(['1'])); // $ExpectType boolean
|
||||
auth.getHostName('https://site.com/page?size=10'); // $ExpectType string
|
||||
auth.getQueryParameters('http://site.com?1=1&2=2', '?'); // $ExpectType Map<string, string>
|
||||
auth.generateRandomString(5, '159erf'); // $ExpectType string
|
||||
auth.clearCachedTokensScopes(); // $ExpectType void
|
||||
auth.refreshSession('refreshToken=='); // $ExpectType void
|
||||
// $ExpectType void
|
||||
auth.makePOSTRequest({ 'Content-Type': 'application/json' }, { pool: '2' },
|
||||
'https://auth.com/signin',
|
||||
(data) => console.log(data),
|
||||
(error) => console.log(error));
|
||||
auth.createCORSRequest('POST', '/myapp/login'); // $ExpectType XMLHttpRequest | XDomainRequest
|
||||
auth.onFailure('request failed'); // $ExpectType void
|
||||
auth.onSuccessRefreshToken('{"name":"John", "age":31}'); // $ExpectType void
|
||||
auth.onSuccessExchangeForToken('{"name":"Jane", "age":30}'); // $ExpectType void
|
||||
auth.launchUri('https://auth.com/login'); // $ExpectType void
|
||||
auth.getSpaceSeperatedScopeString(); // $ExpectType string
|
||||
auth.getFQDNSignIn(); // $ExpectType string
|
||||
auth.signOut(); // $ExpectType void
|
||||
auth.getFQDNSignOut(); // $ExpectType string
|
||||
auth.getUserContextData(); // $ExpectType string
|
||||
auth.isUserSignedIn(); // $ExpectType boolean
|
||||
|
||||
const userHandler: lib.CognitoAuthUserHandler = {
|
||||
onSuccess: (authSession: lib.CognitoAuthSession) => console.log(authSession),
|
||||
onFailure: (error: any) => console.log(error)
|
||||
};
|
||||
auth.userhandler = userHandler;
|
||||
|
||||
const constants: lib.CognitoConstants = auth.getCognitoConstants();
|
||||
constants.DOMAIN_SCHEME; // $ExpectType string
|
||||
constants.DOMAIN_PATH_SIGNIN; // $ExpectType string
|
||||
constants.DOMAIN_PATH_TOKEN; // $ExpectType string
|
||||
constants.DOMAIN_PATH_SIGNOUT; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_REDIRECT_URI; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_SIGNOUT_URI; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_RESPONSE_TYPE; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_USERCONTEXTDATA; // $ExpectType string
|
||||
constants.CLIENT_ID; // $ExpectType string
|
||||
constants.STATE; // $ExpectType string
|
||||
constants.SCOPE; // $ExpectType string
|
||||
constants.TOKEN; // $ExpectType string
|
||||
constants.CODE; // $ExpectType string
|
||||
constants.POST; // $ExpectType string
|
||||
constants.PARAMETERERROR; // $ExpectType string
|
||||
constants.SCOPETYPEERROR; // $ExpectType string
|
||||
constants.QUESTIONMARK; // $ExpectType string
|
||||
constants.POUNDSIGN; // $ExpectType string
|
||||
constants.COLONDOUBLESLASH; // $ExpectType string
|
||||
constants.SLASH; // $ExpectType string
|
||||
constants.AMPERSAND; // $ExpectType string
|
||||
constants.EQUALSIGN; // $ExpectType string
|
||||
constants.SPACE; // $ExpectType string
|
||||
constants.CONTENTTYPE; // $ExpectType string
|
||||
constants.CONTENTTYPEVALUE; // $ExpectType string
|
||||
constants.AUTHORIZATIONCODE; // $ExpectType string
|
||||
constants.IDTOKEN; // $ExpectType string
|
||||
constants.ACCESSTOKEN; // $ExpectType string
|
||||
constants.REFRESHTOKEN; // $ExpectType string
|
||||
constants.ERROR; // $ExpectType string
|
||||
constants.ERROR_DESCRIPTION; // $ExpectType string
|
||||
constants.STRINGTYPE; // $ExpectType string
|
||||
constants.STATELENGTH; // $ExpectType number
|
||||
constants.STATEORIGINSTRING; // $ExpectType string
|
||||
constants.WITHCREDENTIALS; // $ExpectType string
|
||||
constants.UNDEFINED; // $ExpectType string
|
||||
constants.SELF; // $ExpectType string
|
||||
constants.HOSTNAMEREGEX; // $ExpectType RegExp
|
||||
constants.QUERYPARAMETERREGEX1; // $ExpectType RegExp
|
||||
constants.QUERYPARAMETERREGEX2; // $ExpectType RegExp
|
||||
constants.HEADER['Content-Type']; // $ExpectType string
|
||||
|
||||
const dateHelper: lib.DateHelper = new lib.DateHelper();
|
||||
dateHelper.getNowString(); // $ExpectType string
|
||||
|
||||
const storageHelper: lib.StorageHelper = new lib.StorageHelper();
|
||||
storageHelper.getStorage(); // $ExpectType Storage
|
||||
@@ -0,0 +1,22 @@
|
||||
AmazonCognitoIdentity.CognitoIdToken; // $ExpectType typeof CognitoIdToken
|
||||
AmazonCognitoIdentity.CognitoRefreshToken; // $ExpectType typeof CognitoRefreshToken
|
||||
AmazonCognitoIdentity.CognitoAccessToken; // $ExpectType typeof CognitoAccessToken
|
||||
AmazonCognitoIdentity.CognitoTokenScopes; // $ExpectType typeof CognitoTokenScopes
|
||||
AmazonCognitoIdentity.CognitoAuthSession; // $ExpectType typeof CognitoAuthSession
|
||||
AmazonCognitoIdentity.CognitoAuth; // $ExpectType typeof CognitoAuth
|
||||
AmazonCognitoIdentity.DateHelper; // $ExpectType typeof DateHelper
|
||||
AmazonCognitoIdentity.StorageHelper; // $ExpectType typeof StorageHelper
|
||||
|
||||
const sessionData: AmazonCognitoIdentity.CognitoSessionData = {};
|
||||
new AmazonCognitoIdentity.CognitoAuthSession(sessionData);
|
||||
|
||||
const authOptions: AmazonCognitoIdentity.CognitoAuthOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout'
|
||||
};
|
||||
const auth = new AmazonCognitoIdentity.CognitoAuth(authOptions);
|
||||
auth.userhandler; // $ExpectType CognitoAuthUserHandler
|
||||
auth.getCognitoConstants(); // $ExpectType CognitoConstants
|
||||
auth.createCORSRequest('', ''); // $ExpectType XMLHttpRequest | XDomainRequest
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/amazon-cognito-auth-js-tests.ts",
|
||||
"test/amazon-cognito-auth-js-umd-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+2
-4
@@ -1,11 +1,9 @@
|
||||
// Type definitions for Angular Translate (pascalprecht.translate module) 2.15
|
||||
// Project: https://github.com/PascalPrecht/angular-translate
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Gabriel Gil <https://github.com/GabrielGil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="angular" />
|
||||
|
||||
declare var _: string;
|
||||
export = _;
|
||||
|
||||
@@ -69,7 +67,7 @@ declare module 'angular' {
|
||||
versionInfo(): string;
|
||||
loaderCache(): any;
|
||||
isReady(): boolean;
|
||||
onReady(): angular.IPromise<void>;
|
||||
onReady(fn?: () => void): angular.IPromise<void>;
|
||||
resolveClientLocale(): string;
|
||||
getAvailableLanguageKeys(): string[];
|
||||
}
|
||||
|
||||
@@ -1138,7 +1138,8 @@ angular.module('multiSlotTranscludeExample', [])
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('componentExample', [])
|
||||
// $ExpectType IModule
|
||||
const componentModule = angular.module('componentExample', [])
|
||||
.component('counter', {
|
||||
require: {ctrl: '^ctrl'},
|
||||
bindings: {
|
||||
@@ -1160,6 +1161,16 @@ angular.module('componentExample', [])
|
||||
},
|
||||
template: '',
|
||||
transclude: true
|
||||
})
|
||||
.component({
|
||||
aThirdComponent: {
|
||||
controller: class AThirdComponentController {
|
||||
count: number;
|
||||
},
|
||||
bindings: {
|
||||
count: '='
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
interface ICopyExampleUser {
|
||||
|
||||
Vendored
+8
-1
@@ -196,6 +196,12 @@ declare namespace angular {
|
||||
* @param options A definition object passed into the component.
|
||||
*/
|
||||
component(name: string, options: IComponentOptions): IModule;
|
||||
/**
|
||||
* Use this method to register a component.
|
||||
*
|
||||
* @param object Object map of components where the keys are the names and the values are the component definition objects
|
||||
*/
|
||||
component(object: {[componentName: string]: IComponentOptions}): IModule;
|
||||
/**
|
||||
* Use this method to register work which needs to be performed on module loading.
|
||||
*
|
||||
@@ -1028,7 +1034,7 @@ declare namespace angular {
|
||||
all<T1, T2, T3, T4>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise <T4>]): IPromise<[T1, T2, T3, T4]>;
|
||||
all<T1, T2, T3>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>]): IPromise<[T1, T2, T3]>;
|
||||
all<T1, T2>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>]): IPromise<[T1, T2]>;
|
||||
all<TAll>(promises: Array<IPromise<TAll>>): IPromise<TAll[]>;
|
||||
all<TAll>(promises: Array<TAll | IPromise<TAll>>): IPromise<TAll[]>;
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
*
|
||||
@@ -1273,6 +1279,7 @@ declare namespace angular {
|
||||
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): ICompileProvider;
|
||||
|
||||
component(name: string, options: IComponentOptions): ICompileProvider;
|
||||
component(object: {[componentName: string]: IComponentOptions}): ICompileProvider;
|
||||
|
||||
aHrefSanitizationWhitelist(): RegExp;
|
||||
aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
|
||||
|
||||
@@ -1,53 +1,52 @@
|
||||
import { EscapeCode } from './escape-code';
|
||||
import AnsiStyles = require('ansi-styles');
|
||||
|
||||
import ansi = require('ansi-styles');
|
||||
let ansiStyles = AnsiStyles as any,
|
||||
nsNames = ['modifier', 'color', 'bgColor'],
|
||||
namespaces = {
|
||||
modifier: ['reset', 'bold', 'dim', 'italic', 'underline', 'inverse', 'hidden', 'strikethrough'],
|
||||
color: ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray',
|
||||
'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright'],
|
||||
bgColor: ['bgBlack', 'bgRed', 'bgGreen', 'bgYellow', 'bgBlue', 'bgMagenta', 'bgCyan',
|
||||
'bgBlackBright', 'bgRedBright', 'bgGreenBright', 'bgYellowBright', 'bgBlueBright', 'bgMagentaBright', 'bgCyanBright', 'bgWhiteBright'],
|
||||
} as any,
|
||||
styles = [...namespaces.modifier, ...namespaces.color, ...namespaces.bgColor],
|
||||
codePair = ['open', 'close'],
|
||||
codeTypes = ['ansi', 'ansi256', 'ansi16m'],
|
||||
colorFormats = ['ansi', 'rgb', 'hsl', 'hsv', 'hwb', 'cmyk', 'xyz', 'lab', 'lch', 'hex', 'keyword', 'ansi256', 'hcg', 'apple', 'gray'],
|
||||
codesMap = 'codes';
|
||||
|
||||
|
||||
var styles = [
|
||||
ansi.reset,
|
||||
checkStyle(ansiStyles, styles);
|
||||
nsNames.forEach(ns => checkStyle(ansiStyles[ns], namespaces[ns]));
|
||||
|
||||
ansi.bold,
|
||||
ansi.dim,
|
||||
ansi.italic,
|
||||
ansi.underline,
|
||||
ansi.inverse,
|
||||
ansi.hidden,
|
||||
ansi.strikethrough,
|
||||
checkIsMap(ansiStyles[codesMap], `ansiStyles.${codesMap} not a Map.`);
|
||||
nsNames.forEach(ns => checkExist(ansiStyles[ns], `ansiStyles.${ns} is not exist.`));
|
||||
|
||||
ansi.black,
|
||||
ansi.red,
|
||||
ansi.green,
|
||||
ansi.yellow,
|
||||
ansi.blue,
|
||||
ansi.magenta,
|
||||
ansi.cyan,
|
||||
ansi.white,
|
||||
ansi.gray,
|
||||
['color', 'bgColor'].forEach(ns => checkConverter(ns, ansiStyles[ns], colorFormats));
|
||||
|
||||
ansi.bgBlack,
|
||||
ansi.bgRed,
|
||||
ansi.bgGreen,
|
||||
ansi.bgYellow,
|
||||
ansi.bgBlue,
|
||||
ansi.bgMagenta,
|
||||
ansi.bgCyan,
|
||||
ansi.bgWhite
|
||||
]
|
||||
|
||||
for (var key in styles) {
|
||||
check(key, styles[key])
|
||||
function checkStyle(namespace: any, styles: string[]) {
|
||||
styles.forEach(s => checkCodePair(s, namespace[s]));
|
||||
}
|
||||
function checkCodePair(styleName: string, pair: any): void {
|
||||
codePair.forEach(p => checkIsString(pair[p], `${styleName}.${p} is not a string.`));
|
||||
}
|
||||
|
||||
function check(key:string, escapeCodes:ansi.EscapeCodePair): void {
|
||||
if (uninitialized(escapeCodes.open)) {
|
||||
throw new Error('key not found ~> ' + key + '.open')
|
||||
}
|
||||
if (uninitialized(escapeCodes.close)) {
|
||||
throw new Error('key not found ~> ' + key + '.close')
|
||||
}
|
||||
function checkConverter(nsName: string, namespace: any, formats: string[]) {
|
||||
formats.forEach(f => codeTypes.forEach(t => checkIsFunction(namespace[t][f], `ansiStyles.${nsName}.${t}.${f} is not a function.`)));
|
||||
checkIsString(namespace.close, `${namespace}.close is not a string.`);
|
||||
}
|
||||
|
||||
function uninitialized(val:any): boolean {
|
||||
return val === null || val === undefined
|
||||
function checkExist(val: any, failMsg: string): void {
|
||||
if (val == null) throw new Error(failMsg);
|
||||
}
|
||||
function checkIsString(val: any, failMsg: string): void {
|
||||
if(typeof val != 'string') throw new Error(failMsg);
|
||||
}
|
||||
function checkIsFunction(fn: any, failMsg: string): void {
|
||||
if (typeof fn != 'function') throw new Error(failMsg);
|
||||
}
|
||||
function checkIsMap(map: any, failMsg: string): void {
|
||||
if (!(map instanceof Map)) throw new Error(failMsg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
import * as cssKeywords from 'color-name';
|
||||
|
||||
|
||||
export namespace EscapeCode {
|
||||
export interface CodePair {
|
||||
open: string;
|
||||
close: string;
|
||||
}
|
||||
|
||||
interface Modifier {
|
||||
reset: CodePair;
|
||||
bold: CodePair;
|
||||
dim: CodePair;
|
||||
/**
|
||||
* Not widely supported
|
||||
*/
|
||||
italic: CodePair;
|
||||
underline: CodePair;
|
||||
inverse: CodePair;
|
||||
hidden: CodePair;
|
||||
/**
|
||||
* Not widely supported
|
||||
*/
|
||||
strikethrough: CodePair;
|
||||
}
|
||||
interface Color {
|
||||
black: CodePair;
|
||||
red: CodePair;
|
||||
green: CodePair;
|
||||
yellow: CodePair;
|
||||
blue: CodePair;
|
||||
magenta: CodePair;
|
||||
cyan: CodePair;
|
||||
white: CodePair;
|
||||
/**
|
||||
* bright black
|
||||
*/
|
||||
gray: CodePair;
|
||||
grey: CodePair;
|
||||
|
||||
redBright: CodePair;
|
||||
greenBright: CodePair;
|
||||
yellowBright: CodePair;
|
||||
blueBright: CodePair;
|
||||
magentaBright: CodePair;
|
||||
cyanBright: CodePair;
|
||||
whiteBright: CodePair;
|
||||
}
|
||||
interface BackgroundColor {
|
||||
bgBlack: CodePair;
|
||||
bgRed: CodePair;
|
||||
bgGreen: CodePair;
|
||||
bgYellow: CodePair;
|
||||
bgBlue: CodePair;
|
||||
bgMagenta: CodePair;
|
||||
bgCyan: CodePair;
|
||||
bgWhite: CodePair;
|
||||
|
||||
bgBlackBright: CodePair;
|
||||
bgRedBright: CodePair;
|
||||
bgGreenBright: CodePair;
|
||||
bgYellowBright: CodePair;
|
||||
bgBlueBright: CodePair;
|
||||
bgMagentaBright: CodePair;
|
||||
bgCyanBright: CodePair;
|
||||
bgWhiteBright: CodePair;
|
||||
}
|
||||
|
||||
interface Conversions {
|
||||
ansi: (ansi: number) => string
|
||||
rgb: (r: number, g: number, b: number) => string
|
||||
hsl: (h: number, s: number, l: number) => string
|
||||
hsv: (h: number, s: number, v: number) => string
|
||||
hwb: (h: number, w: number, b: number) => string
|
||||
cmyk: (c: number, m: number, y: number, k: number) => string
|
||||
xyz: (x: number, y: number, z: number) => string
|
||||
lab: (l: number, a: number, b: number) => string
|
||||
lch: (l: number, c: number, h: number) => string
|
||||
hex: (hex: string) => string
|
||||
/**
|
||||
* color keyword in css to ansi code
|
||||
*/
|
||||
keyword: (keyword: keyof typeof cssKeywords) => string
|
||||
ansi256: (ansi256: number) => string
|
||||
hcg: (h: number, c: number, g: number) => string
|
||||
/**
|
||||
* apple RGB to ansi code
|
||||
*/
|
||||
apple: (r: number, g: number, b: number) => string
|
||||
gray: (grayscale: number) => string
|
||||
}
|
||||
interface ColorType {
|
||||
/**
|
||||
* 16 color ansi code
|
||||
*/
|
||||
ansi: Conversions
|
||||
/**
|
||||
* 256 color ansi code
|
||||
*/
|
||||
ansi256: Conversions
|
||||
/**
|
||||
* truecolor(16 million color) ansi code
|
||||
*/
|
||||
ansi16m: Conversions
|
||||
}
|
||||
}
|
||||
Vendored
+64
-30
@@ -1,40 +1,74 @@
|
||||
// Type definitions for ansi-styles 2.0.1
|
||||
// Type definitions for ansi-styles 3.2.1
|
||||
// Project: https://github.com/sindresorhus/ansi-styles
|
||||
// Definitions by: bryn austin bellomy <https://github.com/brynbellomy>
|
||||
// plylrnsdy <https://github.com/plylrnsdy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
import { EscapeCode } from './escape-code';
|
||||
|
||||
export interface EscapeCodePair {
|
||||
open: string;
|
||||
close: string;
|
||||
}
|
||||
|
||||
export declare var reset: EscapeCodePair;
|
||||
export const reset: EscapeCode.CodePair;
|
||||
export const bold: EscapeCode.CodePair;
|
||||
export const dim: EscapeCode.CodePair;
|
||||
/**
|
||||
* Not widely supported
|
||||
*/
|
||||
export const italic: EscapeCode.CodePair;
|
||||
export const underline: EscapeCode.CodePair;
|
||||
export const inverse: EscapeCode.CodePair;
|
||||
export const hidden: EscapeCode.CodePair;
|
||||
/**
|
||||
* Not widely supported
|
||||
*/
|
||||
export const strikethrough: EscapeCode.CodePair;
|
||||
|
||||
export declare var bold: EscapeCodePair;
|
||||
export declare var dim: EscapeCodePair;
|
||||
export declare var italic: EscapeCodePair;
|
||||
export declare var underline: EscapeCodePair;
|
||||
export declare var inverse: EscapeCodePair;
|
||||
export declare var hidden: EscapeCodePair;
|
||||
export declare var strikethrough: EscapeCodePair;
|
||||
export const black: EscapeCode.CodePair;
|
||||
export const red: EscapeCode.CodePair;
|
||||
export const green: EscapeCode.CodePair;
|
||||
export const yellow: EscapeCode.CodePair;
|
||||
export const blue: EscapeCode.CodePair;
|
||||
export const magenta: EscapeCode.CodePair;
|
||||
export const cyan: EscapeCode.CodePair;
|
||||
export const white: EscapeCode.CodePair;
|
||||
/**
|
||||
* bright black
|
||||
*/
|
||||
export const gray: EscapeCode.CodePair;
|
||||
export const grey: EscapeCode.CodePair;
|
||||
|
||||
export declare var black: EscapeCodePair;
|
||||
export declare var red: EscapeCodePair;
|
||||
export declare var green: EscapeCodePair;
|
||||
export declare var yellow: EscapeCodePair;
|
||||
export declare var blue: EscapeCodePair;
|
||||
export declare var magenta: EscapeCodePair;
|
||||
export declare var cyan: EscapeCodePair;
|
||||
export declare var white: EscapeCodePair;
|
||||
export declare var gray: EscapeCodePair;
|
||||
export const redBright: EscapeCode.CodePair;
|
||||
export const greenBright: EscapeCode.CodePair;
|
||||
export const yellowBright: EscapeCode.CodePair;
|
||||
export const blueBright: EscapeCode.CodePair;
|
||||
export const magentaBright: EscapeCode.CodePair;
|
||||
export const cyanBright: EscapeCode.CodePair;
|
||||
export const whiteBright: EscapeCode.CodePair;
|
||||
|
||||
export declare var bgBlack: EscapeCodePair;
|
||||
export declare var bgRed: EscapeCodePair;
|
||||
export declare var bgGreen: EscapeCodePair;
|
||||
export declare var bgYellow: EscapeCodePair;
|
||||
export declare var bgBlue: EscapeCodePair;
|
||||
export declare var bgMagenta: EscapeCodePair;
|
||||
export declare var bgCyan: EscapeCodePair;
|
||||
export declare var bgWhite: EscapeCodePair;
|
||||
export const bgBlack: EscapeCode.CodePair;
|
||||
export const bgRed: EscapeCode.CodePair;
|
||||
export const bgGreen: EscapeCode.CodePair;
|
||||
export const bgYellow: EscapeCode.CodePair;
|
||||
export const bgBlue: EscapeCode.CodePair;
|
||||
export const bgMagenta: EscapeCode.CodePair;
|
||||
export const bgCyan: EscapeCode.CodePair;
|
||||
export const bgWhite: EscapeCode.CodePair;
|
||||
|
||||
export const bgBlackBright: EscapeCode.CodePair;
|
||||
export const bgRedBright: EscapeCode.CodePair;
|
||||
export const bgGreenBright: EscapeCode.CodePair;
|
||||
export const bgYellowBright: EscapeCode.CodePair;
|
||||
export const bgBlueBright: EscapeCode.CodePair;
|
||||
export const bgMagentaBright: EscapeCode.CodePair;
|
||||
export const bgCyanBright: EscapeCode.CodePair;
|
||||
export const bgWhiteBright: EscapeCode.CodePair;
|
||||
|
||||
/**
|
||||
* Raw escape codes (i.e. without the CSI escape prefix \u001B[ and render mode postfix m) are available.
|
||||
*
|
||||
* This is a Map with the open codes as keys and close codes as values.
|
||||
*/
|
||||
export const codes: Map<number, number>
|
||||
export const modifier: EscapeCode.Modifier
|
||||
export const color: EscapeCode.Color & EscapeCode.ColorType & { close: string }
|
||||
export const bgColor: EscapeCode.BackgroundColor & EscapeCode.ColorType & { close: string }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db, aql } from "@arangodb";
|
||||
import { aql, db, query } from "@arangodb";
|
||||
import { md5 } from "@arangodb/crypto";
|
||||
import { createRouter } from "@arangodb/foxx";
|
||||
import sessionsMiddleware = require("@arangodb/foxx/sessions");
|
||||
@@ -21,15 +21,40 @@ const admin = users.firstExample({ username: "admin" })!;
|
||||
users.update(admin, { password: md5("hunter2") });
|
||||
console.logLines("user", admin._key, admin.username);
|
||||
|
||||
const query = aql`
|
||||
db._query(aql`
|
||||
FOR u IN ${users}
|
||||
RETURN u
|
||||
`;
|
||||
`);
|
||||
|
||||
db._createDocumentCollection("bananas").ensureIndex({
|
||||
interface Banana {
|
||||
color: string;
|
||||
shape: {
|
||||
type: string;
|
||||
coords: string[];
|
||||
};
|
||||
}
|
||||
|
||||
const bananas = db._createDocumentCollection("bananas", {
|
||||
waitForSync: false,
|
||||
keyOptions: {
|
||||
type: "autoincrement",
|
||||
increment: 11,
|
||||
offset: 23
|
||||
}
|
||||
}) as ArangoDB.Collection<Banana>;
|
||||
bananas.ensureIndex({
|
||||
type: "hash",
|
||||
unique: true,
|
||||
fields: ["color", "shape"]
|
||||
fields: ["color", "shape.type"]
|
||||
});
|
||||
bananas.updateByExample(
|
||||
bananas.any(),
|
||||
{ shape: { type: "round" } },
|
||||
{ mergeObjects: true }
|
||||
);
|
||||
bananas.ensureIndex({
|
||||
type: "geo",
|
||||
fields: ["latLng"]
|
||||
});
|
||||
|
||||
const router = createRouter();
|
||||
@@ -61,3 +86,13 @@ router.use(
|
||||
transport: cookieTransport({ secret: "banana", algorithm: "sha256" })
|
||||
})
|
||||
);
|
||||
|
||||
console.log(
|
||||
query`
|
||||
FOR u IN users
|
||||
${aql.literal(
|
||||
Math.random() < 0.5 ? "FILTER u.admin" : "FILTER !u.admin"
|
||||
)}
|
||||
RETURN u
|
||||
`.toArray()
|
||||
);
|
||||
|
||||
Vendored
+121
-76
@@ -89,8 +89,9 @@ declare namespace ArangoDB {
|
||||
| "network authentication required";
|
||||
type EdgeDirection = "any" | "inbound" | "outbound";
|
||||
type EngineType = "mmfiles" | "rocksdb";
|
||||
type IndexType = "hash" | "skiplist" | "fulltext" | "geo1" | "geo2";
|
||||
type IndexType = "hash" | "skiplist" | "fulltext" | "geo";
|
||||
type ViewType = "arangosearch";
|
||||
type KeyGeneratorType = "traditional" | "autoincrement";
|
||||
type ErrorName =
|
||||
| "ERROR_NO_ERROR"
|
||||
| "ERROR_FAILED"
|
||||
@@ -463,12 +464,29 @@ declare namespace ArangoDB {
|
||||
replicationFactor?: number;
|
||||
}
|
||||
|
||||
interface CreateCollectionOptions {
|
||||
waitForSync?: boolean;
|
||||
journalSize?: number;
|
||||
isVolatile?: boolean;
|
||||
isSystem?: boolean;
|
||||
keyOptions?: {
|
||||
type?: KeyGeneratorType;
|
||||
allowUserKeys?: boolean;
|
||||
increment?: number;
|
||||
offset?: number;
|
||||
};
|
||||
numberOfShards?: number;
|
||||
shardKeys?: string[];
|
||||
replicationFactor?: number;
|
||||
}
|
||||
|
||||
interface CollectionProperties {
|
||||
waitForSync: boolean;
|
||||
journalSize: number;
|
||||
isSystem: boolean;
|
||||
isVolatile: boolean;
|
||||
keyOptions?: {
|
||||
type: string;
|
||||
type: KeyGeneratorType;
|
||||
allowUserKeys: boolean;
|
||||
increment?: number;
|
||||
offset?: number;
|
||||
@@ -488,7 +506,7 @@ declare namespace ArangoDB {
|
||||
|
||||
interface IndexDescription<T> {
|
||||
type: IndexType;
|
||||
fields: ReadonlyArray<keyof T>;
|
||||
fields: ReadonlyArray<keyof T | string>;
|
||||
sparse?: boolean;
|
||||
unique?: boolean;
|
||||
deduplicate?: boolean;
|
||||
@@ -497,7 +515,7 @@ declare namespace ArangoDB {
|
||||
interface Index<T extends object = any> {
|
||||
id: string;
|
||||
type: IndexType;
|
||||
fields: Array<keyof T>;
|
||||
fields: Array<keyof T | string>;
|
||||
sparse: boolean;
|
||||
unique: boolean;
|
||||
deduplicate: boolean;
|
||||
@@ -520,6 +538,8 @@ declare namespace ArangoDB {
|
||||
|
||||
type DocumentLike = ObjectWithId | ObjectWithKey;
|
||||
|
||||
type Patch<T> = { [K in keyof T]?: T[K] | Patch<T[K]> };
|
||||
|
||||
interface DocumentMetadata {
|
||||
_key: string;
|
||||
_id: string;
|
||||
@@ -572,6 +592,7 @@ declare namespace ArangoDB {
|
||||
keepNull?: boolean;
|
||||
waitForSync?: boolean;
|
||||
limit?: number;
|
||||
mergeObjects?: boolean;
|
||||
}
|
||||
|
||||
interface RemoveOptions {
|
||||
@@ -706,24 +727,24 @@ declare namespace ArangoDB {
|
||||
): InsertResult<T>;
|
||||
update(
|
||||
selector: string | DocumentLike,
|
||||
data: Partial<Document<T>>,
|
||||
data: Patch<Document<T>>,
|
||||
options?: UpdateOptions
|
||||
): UpdateResult<T>;
|
||||
update(
|
||||
selectors: ReadonlyArray<string | DocumentLike>,
|
||||
data: ReadonlyArray<Partial<Document<T>>>,
|
||||
data: ReadonlyArray<Patch<Document<T>>>,
|
||||
options?: UpdateOptions
|
||||
): Array<UpdateResult<T>>;
|
||||
updateByExample(
|
||||
example: Partial<Document<T>>,
|
||||
newValue: Partial<Document<T>>,
|
||||
newValue: Patch<Document<T>>,
|
||||
keepNull?: boolean,
|
||||
waitForSync?: boolean,
|
||||
limit?: number
|
||||
): number;
|
||||
updateByExample(
|
||||
example: Partial<Document<T>>,
|
||||
newValue: Partial<Document<T>>,
|
||||
newValue: Patch<Document<T>>,
|
||||
options?: UpdateByExampleOptions
|
||||
): number;
|
||||
}
|
||||
@@ -745,6 +766,10 @@ declare namespace ArangoDB {
|
||||
options?: QueryOptions;
|
||||
}
|
||||
|
||||
interface AqlLiteral {
|
||||
toAQL: () => string;
|
||||
}
|
||||
|
||||
interface Cursor<T = any> {
|
||||
toArray(): T[];
|
||||
hasNext(): boolean;
|
||||
@@ -862,14 +887,14 @@ declare namespace ArangoDB {
|
||||
// Collection
|
||||
_collection(name: string): Collection;
|
||||
_collections(): Collection[];
|
||||
_create(name: string, properties?: CollectionProperties): Collection;
|
||||
_create(name: string, properties?: CreateCollectionOptions): Collection;
|
||||
_createDocumentCollection(
|
||||
name: string,
|
||||
properties?: CollectionProperties
|
||||
properties?: CreateCollectionOptions
|
||||
): Collection;
|
||||
_createEdgeCollection(
|
||||
name: string,
|
||||
properties?: CollectionProperties
|
||||
properties?: CreateCollectionOptions
|
||||
): Collection;
|
||||
_drop(name: string): void;
|
||||
_truncate(name: string): void;
|
||||
@@ -930,8 +955,26 @@ declare namespace Foxx {
|
||||
set?: (res: Response, sid: string) => void;
|
||||
clear?: (res: Response) => void;
|
||||
}
|
||||
interface CollectionSessionStorage extends SessionStorage {
|
||||
new: () => Session;
|
||||
save: (session: Session) => Session;
|
||||
clear: (session: Session) => boolean;
|
||||
prune: () => string[];
|
||||
}
|
||||
interface SessionsMiddleware extends DelegateMiddleware {
|
||||
storage: SessionStorage;
|
||||
transport: SessionTransport[];
|
||||
}
|
||||
|
||||
type Middleware = (req: Request, res: Response, next: NextFunction) => void;
|
||||
type SimpleMiddleware = (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) => void;
|
||||
interface DelegateMiddleware {
|
||||
register: (endpoint: Endpoint) => SimpleMiddleware;
|
||||
}
|
||||
type Middleware = SimpleMiddleware | DelegateMiddleware;
|
||||
type Handler = ((req: Request, res: Response) => void);
|
||||
type NextFunction = () => void;
|
||||
|
||||
@@ -1214,97 +1257,97 @@ declare namespace Foxx {
|
||||
|
||||
function route(handler: Handler, name?: string): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
middleware4: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
middleware4: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
middleware4: Middleware,
|
||||
middleware5: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
middleware4: SimpleMiddleware,
|
||||
middleware5: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
middleware4: Middleware,
|
||||
middleware5: Middleware,
|
||||
middleware6: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
middleware4: SimpleMiddleware,
|
||||
middleware5: SimpleMiddleware,
|
||||
middleware6: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
middleware4: Middleware,
|
||||
middleware5: Middleware,
|
||||
middleware6: Middleware,
|
||||
middleware7: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
middleware4: SimpleMiddleware,
|
||||
middleware5: SimpleMiddleware,
|
||||
middleware6: SimpleMiddleware,
|
||||
middleware7: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
middleware4: Middleware,
|
||||
middleware5: Middleware,
|
||||
middleware6: Middleware,
|
||||
middleware7: Middleware,
|
||||
middleware8: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
middleware4: SimpleMiddleware,
|
||||
middleware5: SimpleMiddleware,
|
||||
middleware6: SimpleMiddleware,
|
||||
middleware7: SimpleMiddleware,
|
||||
middleware8: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
function route(
|
||||
pathOrMiddleware: string | Middleware,
|
||||
middleware1: Middleware,
|
||||
middleware2: Middleware,
|
||||
middleware3: Middleware,
|
||||
middleware4: Middleware,
|
||||
middleware5: Middleware,
|
||||
middleware6: Middleware,
|
||||
middleware7: Middleware,
|
||||
middleware8: Middleware,
|
||||
middleware9: Middleware,
|
||||
pathOrMiddleware: string | SimpleMiddleware,
|
||||
middleware1: SimpleMiddleware,
|
||||
middleware2: SimpleMiddleware,
|
||||
middleware3: SimpleMiddleware,
|
||||
middleware4: SimpleMiddleware,
|
||||
middleware5: SimpleMiddleware,
|
||||
middleware6: SimpleMiddleware,
|
||||
middleware7: SimpleMiddleware,
|
||||
middleware8: SimpleMiddleware,
|
||||
middleware9: SimpleMiddleware,
|
||||
handler: Handler,
|
||||
name?: string
|
||||
): Endpoint;
|
||||
@@ -1327,6 +1370,13 @@ declare namespace Foxx {
|
||||
|
||||
declare module "@arangodb" {
|
||||
function aql(strings: TemplateStringsArray, ...args: any[]): ArangoDB.Query;
|
||||
namespace aql {
|
||||
function literal(value: any): ArangoDB.AqlLiteral;
|
||||
}
|
||||
function query(
|
||||
strings: TemplateStringsArray,
|
||||
...args: any[]
|
||||
): ArangoDB.Cursor;
|
||||
function time(): number;
|
||||
const db: ArangoDB.Database & {
|
||||
[key: string]: ArangoDB.Collection | undefined;
|
||||
@@ -1362,10 +1412,6 @@ declare module "@arangodb/foxx/graphql" {
|
||||
}
|
||||
|
||||
declare module "@arangodb/foxx/sessions" {
|
||||
interface SessionsMiddleware extends Foxx.Middleware {
|
||||
storage: Foxx.SessionStorage;
|
||||
transport: Foxx.SessionTransport[];
|
||||
}
|
||||
interface SessionsOptions {
|
||||
storage: Foxx.SessionStorage | string | ArangoDB.Collection;
|
||||
transport:
|
||||
@@ -1375,7 +1421,9 @@ declare module "@arangodb/foxx/sessions" {
|
||||
| "header";
|
||||
autoCreate?: boolean;
|
||||
}
|
||||
function sessionsMiddleware(options: SessionsOptions): Foxx.Middleware;
|
||||
function sessionsMiddleware(
|
||||
options: SessionsOptions
|
||||
): Foxx.SessionsMiddleware;
|
||||
export = sessionsMiddleware;
|
||||
}
|
||||
|
||||
@@ -1386,14 +1434,11 @@ declare module "@arangodb/foxx/sessions/storages/collection" {
|
||||
pruneExpired?: boolean;
|
||||
autoUpdate?: boolean;
|
||||
}
|
||||
interface CollectionStorage extends Foxx.SessionStorage {
|
||||
prune: () => string[];
|
||||
}
|
||||
function collectionStorage(
|
||||
options:
|
||||
| CollectionStorageOptions
|
||||
| CollectionStorageOptions["collection"]
|
||||
): CollectionStorage;
|
||||
): Foxx.CollectionSessionStorage;
|
||||
export = collectionStorage;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as arrify from 'arrify';
|
||||
|
||||
/***************** arrify<T> *****************/
|
||||
arrify(null);
|
||||
arrify<number>(null);
|
||||
|
||||
@@ -12,3 +13,74 @@ arrify([2, 3]);
|
||||
function test(val?: string | string[]) {
|
||||
arrify(val);
|
||||
}
|
||||
/***************** arrify<T> *****************/
|
||||
|
||||
/***************** arrify<T1, T2> *****************/
|
||||
arrify<number, string>(undefined); // returns []
|
||||
|
||||
arrify<number, string>(null); // returns []
|
||||
|
||||
{
|
||||
const value: number | string[] = 2018;
|
||||
arrify<number, string>(value); // returns [2018]
|
||||
}
|
||||
|
||||
{
|
||||
const value: number[] | string | string[] = ['a', 'b'];
|
||||
arrify<number, string>(value); // returns ['a', 'b']
|
||||
}
|
||||
/***************** arrify<T1, T2> *****************/
|
||||
|
||||
/***************** arrify<T1, T2, T3> *****************/
|
||||
arrify<boolean, number, string>(undefined);
|
||||
|
||||
arrify<boolean, number, string>(null);
|
||||
|
||||
{
|
||||
const value: boolean | number[] | string[] = true;
|
||||
// returns [true]
|
||||
arrify<boolean, number, string>(value);
|
||||
}
|
||||
|
||||
{
|
||||
const value: boolean[] | number | string[] = ['a', 'b'];
|
||||
// returns ['a', 'b']
|
||||
arrify<boolean, number, string>(value);
|
||||
}
|
||||
/***************** arrify<T1, T2, T3> *****************/
|
||||
|
||||
/***************** arrify<T1, T2, T3, T4> *****************/
|
||||
arrify<boolean, Date, number, string>(undefined);
|
||||
|
||||
arrify<boolean, Date, number, string>(null);
|
||||
|
||||
{
|
||||
const value: boolean | Date | number[] | string[] = new Date(2018);
|
||||
// returns [ new Date(2018) ]
|
||||
arrify<boolean, Date, number, string>(value);
|
||||
}
|
||||
|
||||
{
|
||||
const value: boolean[] | Date[] | number | string = [true, false];
|
||||
// returns [true, false]
|
||||
arrify<boolean, Date, number, string>(value);
|
||||
}
|
||||
/***************** arrify<T1, T2, T3, T4> *****************/
|
||||
|
||||
/***************** arrify<T1, T2, T3, T4, T5> *****************/
|
||||
arrify<boolean, Date, number, RegExp, string>(undefined);
|
||||
|
||||
arrify<boolean, Date, number, RegExp, string>(null);
|
||||
|
||||
{
|
||||
const value: boolean | Date | number[] | RegExp | string[] = /test/;
|
||||
// returns [ /test/ ]
|
||||
arrify<boolean, Date, number, RegExp, string>(value);
|
||||
}
|
||||
|
||||
{
|
||||
const value: boolean[] | Date[] | number | RegExp[] | string = [/test1/, /test2/];
|
||||
// returns [/test1/, /test2/]
|
||||
arrify<boolean, Date, number, RegExp, string>(value);
|
||||
}
|
||||
/***************** arrify<T1, T2, T3, T4, T5> *****************/
|
||||
|
||||
Vendored
+73
@@ -14,5 +14,78 @@
|
||||
* arrify([2, 3]) // returns [2, 3]
|
||||
*/
|
||||
declare function arrify<T>(val: undefined | null | T | T[]): T[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<number, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<number, string>(null);
|
||||
* @example
|
||||
* let value: number | string[] = 2018;
|
||||
* // returns [2018]
|
||||
* arrify<number, string>(value);
|
||||
* @example
|
||||
* let value: number[] | string | string[] = ['a', 'b'];
|
||||
* // returns ['a', 'b']
|
||||
* arrify<number, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2>(val: undefined | null | T1 | T2 | T1[] | T2[]): T1[] | T2[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, number, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, number, string>(null);
|
||||
* @example
|
||||
* let value: boolean | number[] | string[] = true;
|
||||
* // returns [true]
|
||||
* arrify<boolean, number, string>(value);
|
||||
* @example
|
||||
* let value: boolean[] | number | string[] = ['a', 'b'];
|
||||
* // returns ['a', 'b']
|
||||
* arrify<boolean, number, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2, T3>(val: undefined | null | T1 | T2 | T3 | T1[] | T2[] | T3[]): T1[] | T2[] | T3[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, string>(null);
|
||||
* @example
|
||||
* let value: boolean | Date | number[] | string[] = new Date(2018);
|
||||
* // returns [ new Date(2018) ]
|
||||
* arrify<boolean, Date, number, string>(value);
|
||||
* @example
|
||||
* let value: boolean[] | Date[] | number | string = [true, false];
|
||||
* // returns [true, false]
|
||||
* arrify<boolean, Date, number, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2, T3, T4>(val: undefined | null | T1 | T2 | T3 | T4 | T1[] | T2[] | T3[] | T4[]): T1[] | T2[] | T3[] | T4[];
|
||||
|
||||
/**
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, RegExp, string>(undefined);
|
||||
* @example
|
||||
* // returns []
|
||||
* arrify<boolean, Date, number, RegExp, string>(null);
|
||||
* @example
|
||||
* let value: boolean | Date | number[] | RegExp | string[] = /test/;
|
||||
* // returns [ /test/ ]
|
||||
* arrify<boolean, Date, number, RegExp, string>(value);
|
||||
* @example
|
||||
* let value: boolean[] | Date[] | number | RegExp[] | string = [/test1/, /test2/];
|
||||
* // returns [/test1/, /test2/]
|
||||
* arrify<boolean, Date, number, RegExp, string>(value);
|
||||
*/
|
||||
declare function arrify<T1, T2, T3, T4, T5>(val: undefined | null | T1 | T2 | T3 | T4 | T5 | T1[] | T2[] | T3[] | T4[] | T5[]): T1[] | T2[] | T3[] | T4[] | T5[];
|
||||
|
||||
declare namespace arrify {}
|
||||
export = arrify;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import atob from 'atob';
|
||||
|
||||
atob('foo');
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for atob 2.1
|
||||
// Project: https://git.coolaj86.com/coolaj86/atob.js.git
|
||||
// Definitions by: John Wright <https://github.com/johngeorgewright>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export default function(str: string): string;
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"lib": ["es6"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"atob-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+130
-2
@@ -33,8 +33,13 @@ export interface RetryOptions {
|
||||
maxRetries?: number;
|
||||
}
|
||||
|
||||
export interface UserMetadata { }
|
||||
export interface AppMetadata { }
|
||||
export interface UserMetadata {
|
||||
[propName: string]: string
|
||||
}
|
||||
|
||||
export interface AppMetadata {
|
||||
[propName: string]: any
|
||||
}
|
||||
|
||||
export interface UserData {
|
||||
email?: string;
|
||||
@@ -513,9 +518,72 @@ export interface EmailVerificationTicketOptions {
|
||||
result_url: string;
|
||||
}
|
||||
|
||||
export interface BaseClientOptions {
|
||||
baseUrl: string;
|
||||
clientId?: string;
|
||||
}
|
||||
|
||||
export interface OAuthClientOptions extends BaseClientOptions {
|
||||
clientSecret?: string;
|
||||
}
|
||||
|
||||
export interface DatabaseClientOptions extends BaseClientOptions {
|
||||
}
|
||||
|
||||
export interface PasswordLessClientOptions extends BaseClientOptions {
|
||||
}
|
||||
|
||||
export interface TokenManagerOptions extends BaseClientOptions {
|
||||
headers?: any;
|
||||
}
|
||||
export interface UsersOptions extends BaseClientOptions {
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
export interface SignInOptions extends VerifyOptions {
|
||||
connection?: string;
|
||||
}
|
||||
|
||||
export interface SocialSignInOptions {
|
||||
access_token: string;
|
||||
connection: string;
|
||||
}
|
||||
|
||||
export interface SignInToken {
|
||||
access_token: string;
|
||||
id_token?: string;
|
||||
token_type?: string;
|
||||
expiry: number;
|
||||
}
|
||||
|
||||
export interface RequestSMSCodeOptions extends RequestSMSOptions {
|
||||
client_id: string;
|
||||
}
|
||||
|
||||
export type SendType = 'link' | 'code';
|
||||
export interface RequestEmailCodeOrLinkOptions {
|
||||
email: string;
|
||||
send: SendType
|
||||
}
|
||||
|
||||
export interface ImpersonateSettingOptions {
|
||||
impersonator_id: string;
|
||||
protocol: string;
|
||||
token: string;
|
||||
clientId?: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class AuthenticationClient {
|
||||
|
||||
// Members
|
||||
database?: DatabaseAuthenticator;
|
||||
oauth?: OAuthAuthenticator;
|
||||
passwordless?: PasswordlessAuthenticator;
|
||||
tokens?: TokenManager;
|
||||
users?: UsersManager;
|
||||
|
||||
constructor(options: AuthenticationClientOptions);
|
||||
getClientInfo(): ClientInfo;
|
||||
|
||||
@@ -755,3 +823,63 @@ export class ManagementClient {
|
||||
updateResourceServer(params: ObjectWithId, data: ResourceServer): Promise<ResourceServer>;
|
||||
updateResourceServer(params: ObjectWithId, data: ResourceServer, cb?: (err: Error, data: ResourceServer) => void): void;
|
||||
}
|
||||
|
||||
|
||||
export class DatabaseAuthenticator {
|
||||
constructor(options: DatabaseClientOptions, oauth: OAuthAuthenticator);
|
||||
|
||||
changePassword(data: ResetPasswordOptions): Promise<any>;
|
||||
changePassword(data: ResetPasswordOptions, cb: (err: Error, message: string) => void): void;
|
||||
|
||||
requestChangePasswordEmail(data: ResetPasswordEmailOptions): Promise<any>;
|
||||
requestChangePasswordEmail(data: ResetPasswordEmailOptions, cb: (err: Error, message: string) => void): void;
|
||||
|
||||
signIn(data: SignInOptions): Promise<SignInToken>;
|
||||
signIn(data: SignInOptions, cb: (err: Error, data: SignInToken) => void): void;
|
||||
|
||||
signUp(data: CreateUserData): Promise<User>;
|
||||
signIn(data: CreateUserData, cb: (err: Error, data: User) => void): void;
|
||||
|
||||
}
|
||||
|
||||
export class OAuthAuthenticator {
|
||||
constructor(options: OAuthClientOptions);
|
||||
|
||||
passwordGrant(options: PasswordGrantOptions): Promise<SignInToken>;
|
||||
passwordGrant(options: PasswordGrantOptions, cb: (err: Error, response: SignInToken) => void): void;
|
||||
|
||||
signIn(data: SignInOptions): Promise<SignInToken>;
|
||||
signIn(data: SignInOptions, cb: (err: Error, data: SignInToken) => void): void;
|
||||
|
||||
|
||||
socialSignIn(data: SocialSignInOptions): Promise<SignInToken>;
|
||||
socialSignIn(data: SocialSignInOptions, cb: (err: Error, data: SignInToken) => void): void;
|
||||
}
|
||||
|
||||
export class PasswordlessAuthenticator {
|
||||
constructor(options: PasswordLessClientOptions, oauth: OAuthAuthenticator);
|
||||
|
||||
signIn(data: SignInOptions): Promise<SignInToken>;
|
||||
signIn(data: SignInOptions, cb: (err: Error, data: SignInToken) => void): void;
|
||||
|
||||
sendEmail(data: RequestEmailCodeOrLinkOptions): Promise<any>;
|
||||
sendEmail(data: RequestEmailCodeOrLinkOptions, cb: (err: Error, message: string) => void): void;
|
||||
|
||||
sendSMS(data: RequestSMSCodeOptions): Promise<any>;
|
||||
sendSMS(data: RequestSMSCodeOptions, cb: (err: Error, message: string) => void): void;
|
||||
}
|
||||
|
||||
export class TokenManager {
|
||||
constructor(options: TokenManagerOptions);
|
||||
|
||||
}
|
||||
|
||||
export class UsersManager {
|
||||
constructor(options: UsersOptions);
|
||||
|
||||
getInfo(accessToken: string): Promise<User>;
|
||||
getInfo(accessToken: string, cb: (err: Error, user: User) => void): void;
|
||||
|
||||
impersonate(userId: string, settings: ImpersonateSettingOptions): Promise<any>;
|
||||
impersonate(userId: string, settings: ImpersonateSettingOptions, cb: (err: Error, data: any) => void): void;
|
||||
}
|
||||
Vendored
+2
-2
@@ -46,7 +46,7 @@ export interface Node {
|
||||
|
||||
export interface ArrayExpression extends Node {
|
||||
type: "ArrayExpression";
|
||||
elements: Array<Expression | SpreadElement>;
|
||||
elements: Array<null | Expression | SpreadElement>;
|
||||
}
|
||||
|
||||
export interface AssignmentExpression extends Node {
|
||||
@@ -1306,7 +1306,7 @@ export type TSEntityName = Identifier | TSQualifiedName;
|
||||
export type TSTypeElement = TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSIndexSignature
|
||||
| TSMethodSignature | TSPropertySignature;
|
||||
|
||||
export function arrayExpression(elements?: Array<Expression | SpreadElement>): ArrayExpression;
|
||||
export function arrayExpression(elements?: Array<null | Expression | SpreadElement>): ArrayExpression;
|
||||
export function assignmentExpression(operator?: string, left?: LVal, right?: Expression): AssignmentExpression;
|
||||
export function binaryExpression(
|
||||
operator?: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=",
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import '../behavior3';
|
||||
|
||||
// Test decode
|
||||
const blackboard = new b3.Blackboard();
|
||||
const behaviorTree = new b3.BehaviorTree();
|
||||
behaviorTree.load({
|
||||
version: "0.3.0",
|
||||
scope: "tree",
|
||||
id: "6bc03cd0-38ef-4a3e-8e08-54c412491525",
|
||||
title: "A behavior tree",
|
||||
description: "",
|
||||
root: "607d29f5-9dbc-4cc4-8ebb-e57c4908d87b",
|
||||
properties: {},
|
||||
nodes: {
|
||||
"607d29f5-9dbc-4cc4-8ebb-e57c4908d87b": {
|
||||
id: "607d29f5-9dbc-4cc4-8ebb-e57c4908d87b",
|
||||
name: "Sequence",
|
||||
title: "Sequence",
|
||||
description: "",
|
||||
properties: {},
|
||||
display: {
|
||||
x: -216,
|
||||
y: -36
|
||||
},
|
||||
children: [
|
||||
"09f04185-205b-40c0-8494-ffd53ffd0820",
|
||||
"df7366f8-999a-4971-872c-cef57607f99f"
|
||||
]
|
||||
},
|
||||
"df7366f8-999a-4971-872c-cef57607f99f": {
|
||||
id: "df7366f8-999a-4971-872c-cef57607f99f",
|
||||
name: "Runner",
|
||||
title: "Runner",
|
||||
description: "",
|
||||
properties: {},
|
||||
display: {
|
||||
x: -12,
|
||||
y: -36
|
||||
}
|
||||
},
|
||||
"e498e1a5-5295-43c3-8716-20dd6d3407f2": {
|
||||
id: "e498e1a5-5295-43c3-8716-20dd6d3407f2",
|
||||
name: "Succeeder",
|
||||
title: "Succeeder",
|
||||
description: "",
|
||||
properties: {},
|
||||
display: {
|
||||
x: 192,
|
||||
y: -96
|
||||
}
|
||||
},
|
||||
"09f04185-205b-40c0-8494-ffd53ffd0820": {
|
||||
id: "09f04185-205b-40c0-8494-ffd53ffd0820",
|
||||
name: "Inverter",
|
||||
title: "Inverter",
|
||||
description: "",
|
||||
properties: {},
|
||||
display: {
|
||||
x: -36,
|
||||
y: -108
|
||||
},
|
||||
child: "e498e1a5-5295-43c3-8716-20dd6d3407f2"
|
||||
}
|
||||
},
|
||||
display: {
|
||||
camera_x: 640,
|
||||
camera_y: 324,
|
||||
camera_z: 1,
|
||||
x: -324,
|
||||
y: -36
|
||||
}
|
||||
});
|
||||
behaviorTree.tick(null, blackboard);
|
||||
Vendored
+908
@@ -0,0 +1,908 @@
|
||||
// Type definitions for behavior3 0.2
|
||||
// Project: https://github.com/behavior3/behavior3js
|
||||
// Definitions by: carry.wu <https://github.com/carrrywu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Behavior3JS
|
||||
* ===========
|
||||
*
|
||||
* * * *
|
||||
*
|
||||
* **Behavior3JS** is a Behavior Tree library written in JavaScript. It
|
||||
* provides structures and algorithms that assist you in the task of creating
|
||||
* intelligent agents for your game or application. Check it out some features
|
||||
* of Behavior3JS:
|
||||
*
|
||||
* - Based on the work of (Marzinotto et al., 2014), in which they propose a
|
||||
* **formal**, **consistent** and **general** definition of Behavior Trees;
|
||||
* - **Optimized to control multiple agents**: you can use a single behavior
|
||||
* tree instance to handle hundreds of agents;
|
||||
* - It was **designed to load and save trees in a JSON format**, in order to
|
||||
* use, edit and test it in multiple environments, tools and languages;
|
||||
* - A **cool visual editor** which you can access online;
|
||||
* - Several **composite, decorator and action nodes** available within the
|
||||
* library. You still can define your own nodes, including composites and
|
||||
* decorators;
|
||||
* - **Completely free**, the core module and the visual editor are all
|
||||
* published under the MIT License, which means that you can use them for
|
||||
* your open source and commercial projects;
|
||||
* - **Lightweight**!
|
||||
*
|
||||
* Visit http://behavior3.com to know more!
|
||||
*
|
||||
*
|
||||
* ## Core Classes and Functions
|
||||
*
|
||||
* This library include the following core structures...
|
||||
*
|
||||
*
|
||||
* **Public:**
|
||||
*
|
||||
* - **BehaviorTree**: the structure that represents a Behavior Tree;
|
||||
* - **Blackboard**: represents a "memory" in an agent and is required to to
|
||||
* run a `BehaviorTree`;
|
||||
* - **Composite**: base class for all composite nodes;
|
||||
* - **Decorator**: base class for all decorator nodes;
|
||||
* - **Action**: base class for all action nodes;
|
||||
* - **Condition**: base class for all condition nodes;
|
||||
*
|
||||
*
|
||||
* **Internal:**
|
||||
*
|
||||
* - **Tick**: used as container and tracking object through the tree during
|
||||
* the tick signal;
|
||||
* - **BaseNode**: the base class that provide all common node features;
|
||||
*
|
||||
* *Some classes are used internally on Behavior3JS, but you may need to access
|
||||
* its functionalities eventually, specially the `Tick` object.*
|
||||
*
|
||||
*
|
||||
* **Nodes:**
|
||||
*
|
||||
* - **Composite Nodes**: Sequence, Priority, MemSequence, MemPriority.
|
||||
* - **Decorators**: Inverter, Limiter, MaxTime, Repeater,
|
||||
* RepeaterUntilFailure, RepeaterUntilSuccess.
|
||||
* - **Actions**: Succeeder, Failer, Error, Runner, Wait.
|
||||
*
|
||||
* ## The list of all constants in B3.
|
||||
*
|
||||
* NAME | VALUE
|
||||
* ------------------- | ----------------------
|
||||
* VERSION | depends on the version
|
||||
* |
|
||||
* **Node State** |
|
||||
* SUCCESS | 1
|
||||
* FAILURE | 2
|
||||
* RUNNING | 3
|
||||
* ERROR | 4
|
||||
* |
|
||||
* **Node categories** |
|
||||
* COMPOSITE | 'composite'
|
||||
* DECORATOR | 'decorator'
|
||||
* ACTION | 'action'
|
||||
* CONDITION | 'condition'
|
||||
*
|
||||
*/
|
||||
declare namespace b3 {
|
||||
/**
|
||||
* This function is used to create unique IDs for trees and nodes.
|
||||
*
|
||||
* (consult http://www.ietf.org/rfc/rfc4122.txt).
|
||||
*
|
||||
*/
|
||||
function createUUID(): string;
|
||||
|
||||
/**
|
||||
* The BaseNode class is used as super class to all nodes in BehaviorJS. It
|
||||
* comprises all common variables and methods that a node must have to
|
||||
* execute.
|
||||
*
|
||||
* **IMPORTANT:** Do not inherit from this class, use `Composite`,
|
||||
* `Decorator`, `Action` or `Condition`, instead.
|
||||
*
|
||||
* The attributes are specially designed to serialization of the node in a
|
||||
* JSON format. In special, the `parameters` attribute can be set into the
|
||||
* visual editor (thus, in the JSON file), and it will be used as parameter
|
||||
* on the node initialization at `BehaviorTree.load`.
|
||||
*
|
||||
* BaseNode also provide 5 callback methods, which the node implementations
|
||||
* can override. They are `enter`, `open`, `tick`, `close` and `exit`. See
|
||||
* their documentation to know more. These callbacks are called inside the
|
||||
* `_execute` method, which is called in the tree traversal.
|
||||
*
|
||||
*/
|
||||
class BaseNode {
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
constructor({category, name, title, description, properties}?: {category?: string, name?: string, title?: string, description?: string, properties?: any});
|
||||
|
||||
/**
|
||||
* This is the main method to propagate the tick signal to this node. This
|
||||
* method calls all callbacks: `enter`, `open`, `tick`, `close`, and
|
||||
* `exit`. It only opens a node if it is not already open. In the same
|
||||
* way, this method only close a node if the node returned a status
|
||||
* different of `RUNNING`.
|
||||
*
|
||||
*/
|
||||
_execute(tick: Tick): number;
|
||||
|
||||
/**
|
||||
* Wrapper for enter method.
|
||||
*/
|
||||
_enter(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Wrapper for open method.
|
||||
*/
|
||||
_open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Wrapper for tick method.
|
||||
*/
|
||||
_tick(tick: Tick): number;
|
||||
|
||||
/**
|
||||
* Wrapper for close method.
|
||||
*/
|
||||
_close(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Wrapper for exit method.
|
||||
*/
|
||||
_exit(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Enter method, override this to use. It is called every time a node is
|
||||
* asked to execute, before the tick itself.
|
||||
*/
|
||||
enter(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Open method, override this to use. It is called only before the tick
|
||||
* callback and only if the not isn't closed.
|
||||
*
|
||||
* Note: a node will be closed if it returned `RUNNING` in the tick.
|
||||
*
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method, override this to use. This method must contain the real
|
||||
* execution of node (perform a task, call children, etc.). It is called
|
||||
* every time a node is asked to execute.
|
||||
*
|
||||
*/
|
||||
tick(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Close method, override this to use. This method is called after the tick
|
||||
* callback, and only if the tick return a state different from
|
||||
* `RUNNING`.
|
||||
*
|
||||
*/
|
||||
close(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Exit method, override this to use. Called every time in the end of the
|
||||
* execution.
|
||||
*
|
||||
*/
|
||||
exit(tick: Tick): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action is the base class for all action nodes. Thus, if you want to create
|
||||
* new custom action nodes, you need to inherit from this class. For example,
|
||||
* take a look at the Runner action:
|
||||
*
|
||||
* class Runner extends b3.Action {
|
||||
* constructor(){
|
||||
* super({name: 'Runner'});
|
||||
* }
|
||||
* tick(tick) {
|
||||
* return b3.RUNNING;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
*/
|
||||
class Action extends BaseNode {
|
||||
/**
|
||||
* Creates an instance of Action.
|
||||
*/
|
||||
constructor({name, title, properties}?: {name?: string, title?: string, properties?: any});
|
||||
}
|
||||
|
||||
/**
|
||||
* The BehaviorTree class, as the name implies, represents the Behavior Tree
|
||||
* structure.
|
||||
*
|
||||
* There are two ways to construct a Behavior Tree: by manually setting the
|
||||
* root node, or by loading it from a data structure (which can be loaded
|
||||
* from a JSON). Both methods are shown in the examples below and better
|
||||
* explained in the user guide.
|
||||
*
|
||||
* The tick method must be called periodically, in order to send the tick
|
||||
* signal to all nodes in the tree, starting from the root. The method
|
||||
* `BehaviorTree.tick` receives a target object and a blackboard as
|
||||
* parameters. The target object can be anything: a game agent, a system, a
|
||||
* DOM object, etc. This target is not used by any piece of Behavior3JS,
|
||||
* i.e., the target object will only be used by custom nodes.
|
||||
*
|
||||
* The blackboard is obligatory and must be an instance of `Blackboard`. This
|
||||
* requirement is necessary due to the fact that neither `BehaviorTree` or
|
||||
* any node will store the execution variables in its own object (e.g., the
|
||||
* BT does not store the target, information about opened nodes or number of
|
||||
* times the tree was called). But because of this, you only need a single
|
||||
* tree instance to control multiple (maybe hundreds) objects.
|
||||
*
|
||||
* Manual construction of a Behavior Tree
|
||||
* --------------------------------------
|
||||
*
|
||||
* var tree = new b3.BehaviorTree();
|
||||
*
|
||||
* tree.root = new b3.Sequence({children:[
|
||||
* new b3.Priority({children:[
|
||||
* new MyCustomNode(),
|
||||
* new MyCustomNode()
|
||||
* ]}),
|
||||
* ...
|
||||
* ]});
|
||||
*
|
||||
*
|
||||
* Loading a Behavior Tree from data structure
|
||||
* -------------------------------------------
|
||||
*
|
||||
* var tree = new b3.BehaviorTree();
|
||||
*
|
||||
* tree.load({
|
||||
* 'title' : 'Behavior Tree title'
|
||||
* 'description' : 'My description'
|
||||
* 'root' : 'node-id-1'
|
||||
* 'nodes' : {
|
||||
* 'node-id-1' : {
|
||||
* 'name' : 'Priority', // this is the node type
|
||||
* 'title' : 'Root Node',
|
||||
* 'description' : 'Description',
|
||||
* 'children' : ['node-id-2', 'node-id-3'],
|
||||
* },
|
||||
* ...
|
||||
* }
|
||||
* })
|
||||
*
|
||||
*/
|
||||
class BehaviorTree {
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* This method loads a Behavior Tree from a data structure, populating this
|
||||
* object with the provided data. Notice that, the data structure must
|
||||
* follow the format specified by Behavior3JS. Consult the guide to know
|
||||
* more about this format.
|
||||
*
|
||||
* You probably want to use custom nodes in your BTs, thus, you need to
|
||||
* provide the `names` object, in which this method can find the nodes by
|
||||
* `names[NODE_NAME]`. This variable can be a namespace or a dictionary,
|
||||
* as long as this method can find the node by its name, for example:
|
||||
*
|
||||
* //json
|
||||
* ...
|
||||
* 'node1': {
|
||||
* 'name': MyCustomNode,
|
||||
* 'title': ...
|
||||
* }
|
||||
* ...
|
||||
*
|
||||
* //code
|
||||
* var bt = new b3.BehaviorTree();
|
||||
* bt.load(data, {'MyCustomNode':MyCustomNode})
|
||||
*
|
||||
*
|
||||
*/
|
||||
load(data: any, names?: any): void;
|
||||
|
||||
/**
|
||||
* This method dump the current BT into a data structure.
|
||||
*
|
||||
* Note: This method does not record the current node parameters. Thus,
|
||||
* it may not be compatible with load for now.
|
||||
*
|
||||
*/
|
||||
dump(): any;
|
||||
|
||||
/**
|
||||
* Propagates the tick signal through the tree, starting from the root.
|
||||
*
|
||||
* This method receives a target object of any type (Object, Array,
|
||||
* DOMElement, whatever) and a `Blackboard` instance. The target object has
|
||||
* no use at all for all Behavior3JS components, but surely is important
|
||||
* for custom nodes. The blackboard instance is used by the tree and nodes
|
||||
* to store execution variables (e.g., last node running) and is obligatory
|
||||
* to be a `Blackboard` instance (or an object with the same interface).
|
||||
*
|
||||
* Internally, this method creates a Tick object, which will store the
|
||||
* target and the blackboard objects.
|
||||
*
|
||||
* Note: BehaviorTree stores a list of open nodes from last tick, if these
|
||||
* nodes weren't called after the current tick, this method will close them
|
||||
* automatically.
|
||||
*
|
||||
*/
|
||||
tick(target: any, blackboard: Blackboard): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Blackboard is the memory structure required by `BehaviorTree` and its
|
||||
* nodes. It only have 2 public methods: `set` and `get`. These methods works
|
||||
* in 3 different contexts: global, per tree, and per node per tree.
|
||||
*
|
||||
* Suppose you have two different trees controlling a single object with a
|
||||
* single blackboard, then:
|
||||
*
|
||||
* - In the global context, all nodes will access the stored information.
|
||||
* - In per tree context, only nodes sharing the same tree share the stored
|
||||
* information.
|
||||
* - In per node per tree context, the information stored in the blackboard
|
||||
* can only be accessed by the same node that wrote the data.
|
||||
*
|
||||
* The context is selected indirectly by the parameters provided to these
|
||||
* methods, for example:
|
||||
*
|
||||
* // getting/setting variable in global context
|
||||
* blackboard.set('testKey', 'value');
|
||||
* var value = blackboard.get('testKey');
|
||||
*
|
||||
* // getting/setting variable in per tree context
|
||||
* blackboard.set('testKey', 'value', tree.id);
|
||||
* var value = blackboard.get('testKey', tree.id);
|
||||
*
|
||||
* // getting/setting variable in per node per tree context
|
||||
* blackboard.set('testKey', 'value', tree.id, node.id);
|
||||
* var value = blackboard.get('testKey', tree.id, node.id);
|
||||
*
|
||||
* Note: Internally, the blackboard store these memories in different
|
||||
* objects, being the global on `_baseMemory`, the per tree on `_treeMemory`
|
||||
* and the per node per tree dynamically create inside the per tree memory
|
||||
* (it is accessed via `_treeMemory[id].nodeMemory`). Avoid to use these
|
||||
* variables manually, use `get` and `set` instead.
|
||||
*
|
||||
*/
|
||||
class Blackboard {
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Internal method to retrieve the tree context memory. If the memory does
|
||||
* not exist, this method creates it.
|
||||
*
|
||||
*/
|
||||
_getTreeMemory(treeScope: string): any;
|
||||
|
||||
/**
|
||||
* Internal method to retrieve the node context memory, given the tree
|
||||
* memory. If the memory does not exist, this method creates is.
|
||||
*
|
||||
*/
|
||||
_getNodeMemory(treeMemory: string, nodeScope: string): any;
|
||||
|
||||
/**
|
||||
* Internal method to retrieve the context memory. If treeScope and
|
||||
* nodeScope are provided, this method returns the per node per tree
|
||||
* memory. If only the treeScope is provided, it returns the per tree
|
||||
* memory. If no parameter is provided, it returns the global memory.
|
||||
* Notice that, if only nodeScope is provided, this method will still
|
||||
* return the global memory.
|
||||
*
|
||||
*/
|
||||
_getMemory(treeScope: string, nodeScope: string): any;
|
||||
|
||||
/**
|
||||
* Stores a value in the blackboard. If treeScope and nodeScope are
|
||||
* provided, this method will save the value into the per node per tree
|
||||
* memory. If only the treeScope is provided, it will save the value into
|
||||
* the per tree memory. If no parameter is provided, this method will save
|
||||
* the value into the global memory. Notice that, if only nodeScope is
|
||||
* provided (but treeScope not), this method will still save the value into
|
||||
* the global memory.
|
||||
*
|
||||
*/
|
||||
set(key: string, value: string, treeScope: string, nodeScope: string): void;
|
||||
|
||||
/**
|
||||
* Retrieves a value in the blackboard. If treeScope and nodeScope are
|
||||
* provided, this method will retrieve the value from the per node per tree
|
||||
* memory. If only the treeScope is provided, it will retrieve the value
|
||||
* from the per tree memory. If no parameter is provided, this method will
|
||||
* retrieve from the global memory. If only nodeScope is provided (but
|
||||
* treeScope not), this method will still try to retrieve from the global
|
||||
* memory.
|
||||
*
|
||||
*/
|
||||
get(key: string, treeScope: string, nodeScope: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Composite is the base class for all composite nodes. Thus, if you want to
|
||||
* create new custom composite nodes, you need to inherit from this class.
|
||||
*
|
||||
* When creating composite nodes, you will need to propagate the tick signal
|
||||
* to the children nodes manually. To do that, override the `tick` method and
|
||||
* call the `_execute` method on all nodes. For instance, take a look at how
|
||||
* the Sequence node inherit this class and how it call its children:
|
||||
*
|
||||
* // Inherit from Composite, using the util function Class.
|
||||
* class Sequence extends Composite {
|
||||
*
|
||||
* constructor(){
|
||||
* // Remember to set the name of the node.
|
||||
* super({name: 'Sequence'});
|
||||
* }
|
||||
*
|
||||
* // Override the tick function
|
||||
* tick(tick) {
|
||||
*
|
||||
* // Iterates over the children
|
||||
* for (var i=0; i<this.children.length; i++) {
|
||||
*
|
||||
* // Propagate the tick
|
||||
* var status = this.children[i]._execute(tick);
|
||||
*
|
||||
* if (status !== SUCCESS) {
|
||||
* return status;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* return SUCCESS;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
*/
|
||||
class Composite extends BaseNode {
|
||||
/**
|
||||
* Creates an instance of Composite.
|
||||
*/
|
||||
constructor({children, name, title, properties}?: {children?: BaseNode[], name?: string, title?: string, properties?: any});
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition is the base class for all condition nodes. Thus, if you want to
|
||||
* create new custom condition nodes, you need to inherit from this class.
|
||||
*
|
||||
*/
|
||||
class Condition extends BaseNode {
|
||||
/**
|
||||
* Creates an instance of Condition.
|
||||
*/
|
||||
constructor({name, title, properties}?: {name?: string, title?: string, properties?: any});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorator is the base class for all decorator nodes. Thus, if you want to
|
||||
* create new custom decorator nodes, you need to inherit from this class.
|
||||
*
|
||||
* When creating decorator nodes, you will need to propagate the tick signal
|
||||
* to the child node manually, just like the composite nodes. To do that,
|
||||
* override the `tick` method and call the `_execute` method on the child
|
||||
* node. For instance, take a look at how the Inverter node inherit this
|
||||
* class and how it call its children:
|
||||
*
|
||||
* // Inherit from Decorator, using the util function Class.
|
||||
* class Inverter extends b3.Decorator {
|
||||
*
|
||||
* constructor(){
|
||||
* super({name: 'Invereter'});
|
||||
* }
|
||||
*
|
||||
* tick: function(tick) {
|
||||
* if (!this.child) {
|
||||
* return b3.ERROR;
|
||||
* }
|
||||
*
|
||||
* // Propagate the tick
|
||||
* var status = this.child._execute(tick);
|
||||
*
|
||||
* if (status === b3.SUCCESS) {
|
||||
* status = b3.FAILURE;
|
||||
* } else if (status === b3.FAILURE) {
|
||||
* status = b3.SUCCESS;
|
||||
* }
|
||||
*
|
||||
* return status;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*/
|
||||
class Decorator extends BaseNode {
|
||||
/**
|
||||
* Creates an instance of Decorator.
|
||||
*/
|
||||
constructor({child, name, title, properties}?: {child?: BaseNode, name?: string, title?: string, properties?: any});
|
||||
}
|
||||
|
||||
/**
|
||||
* A new Tick object is instantiated every tick by BehaviorTree. It is passed
|
||||
* as parameter to the nodes through the tree during the traversal.
|
||||
*
|
||||
* The role of the Tick class is to store the instances of tree, debug,
|
||||
* target and blackboard. So, all nodes can access these informations.
|
||||
*
|
||||
* For internal uses, the Tick also is useful to store the open node after
|
||||
* the tick signal, in order to let `BehaviorTree` to keep track and close
|
||||
* them when necessary.
|
||||
*
|
||||
* This class also makes a bridge between nodes and the debug, passing the
|
||||
* node state to the debug if the last is provided.
|
||||
*
|
||||
*/
|
||||
class Tick {
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Called when entering a node (called by BaseNode).
|
||||
*/
|
||||
_enterNode(node: any): void;
|
||||
|
||||
/**
|
||||
* Callback when opening a node (called by BaseNode).
|
||||
*/
|
||||
_openNode(node: any): void;
|
||||
|
||||
/**
|
||||
* Callback when ticking a node (called by BaseNode).
|
||||
*/
|
||||
_tickNode(node: any): void;
|
||||
|
||||
/**
|
||||
* Callback when closing a node (called by BaseNode).
|
||||
*/
|
||||
_closeNode(node: any): void;
|
||||
|
||||
/**
|
||||
* Callback when exiting a node (called by BaseNode).
|
||||
*/
|
||||
_exitNode(node: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* This action node returns `ERROR` always.
|
||||
*
|
||||
*/
|
||||
class Error extends Action {
|
||||
/**
|
||||
* Creates an instance of Error.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* This action node returns `FAILURE` always.
|
||||
*
|
||||
*/
|
||||
class Failer extends Action {
|
||||
/**
|
||||
* Creates an instance of Failer.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* This action node returns RUNNING always.
|
||||
*
|
||||
*/
|
||||
class Runner extends Action {
|
||||
/**
|
||||
* Creates an instance of Runner.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* This action node returns `SUCCESS` always.
|
||||
*
|
||||
*/
|
||||
class Succeeder extends Action {
|
||||
/**
|
||||
* Creates an instance of Succeeder.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait a few seconds.
|
||||
*
|
||||
*/
|
||||
class Wait extends Action {
|
||||
/**
|
||||
* Creates an instance of Wait.
|
||||
*/
|
||||
constructor({milliseconds}?: {milliseconds?: number});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* MemPriority is similar to Priority node, but when a child returns a
|
||||
* `RUNNING` state, its index is recorded and in the next tick the,
|
||||
* MemPriority calls the child recorded directly, without calling previous
|
||||
* children again.
|
||||
*
|
||||
*/
|
||||
class MemPriority extends Composite {
|
||||
/**
|
||||
* Creates an instance of MemPriority.
|
||||
*/
|
||||
constructor({children}?: {children?: BaseNode[]});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* MemSequence is similar to Sequence node, but when a child returns a
|
||||
* `RUNNING` state, its index is recorded and in the next tick the
|
||||
* MemPriority call the child recorded directly, without calling previous
|
||||
* children again.
|
||||
*
|
||||
*/
|
||||
class MemSequence extends Composite {
|
||||
/**
|
||||
* Creates an instance of MemSequence.
|
||||
*/
|
||||
constructor({children}?: {children?: BaseNode[]});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Priority ticks its children sequentially until one of them returns
|
||||
* `SUCCESS`, `RUNNING` or `ERROR`. If all children return the failure state,
|
||||
* the priority also returns `FAILURE`.
|
||||
*
|
||||
*/
|
||||
class Priority extends Composite {
|
||||
/**
|
||||
* Creates an instance of Priority.
|
||||
*/
|
||||
constructor({children}?: {children?: BaseNode[]});
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Sequence node ticks its children sequentially until one of them
|
||||
* returns `FAILURE`, `RUNNING` or `ERROR`. If all children return the
|
||||
* success state, the sequence also returns `SUCCESS`.
|
||||
*
|
||||
*/
|
||||
class Sequence extends Composite {
|
||||
/**
|
||||
* Creates an instance of Sequence.
|
||||
*/
|
||||
constructor({children}?: {children?: BaseNode[]});
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Inverter decorator inverts the result of the child, returning `SUCCESS`
|
||||
* for `FAILURE` and `FAILURE` for `SUCCESS`.
|
||||
*
|
||||
*/
|
||||
class Inverter extends Decorator {
|
||||
/**
|
||||
* Creates an instance of Inverter.
|
||||
*/
|
||||
constructor({child}?: {child?: BaseNode});
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* This decorator limit the number of times its child can be called. After a
|
||||
* certain number of times, the Limiter decorator returns `FAILURE` without
|
||||
* executing the child.
|
||||
*
|
||||
*/
|
||||
class Limiter extends Decorator {
|
||||
/**
|
||||
* Creates an instance of Limiter.
|
||||
*
|
||||
* Settings parameters:
|
||||
*
|
||||
* - **maxLoop** (*Integer*) Maximum number of repetitions.
|
||||
* - **child** (*BaseNode*) The child node.
|
||||
*
|
||||
*/
|
||||
constructor({child, maxLoop}?: {child?: BaseNode, maxLoop?: number});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The MaxTime decorator limits the maximum time the node child can execute.
|
||||
* Notice that it does not interrupt the execution itself (i.e., the child
|
||||
* must be non-preemptive), it only interrupts the node after a `RUNNING`
|
||||
* status.
|
||||
*
|
||||
*/
|
||||
class MaxTime extends Decorator {
|
||||
/**
|
||||
* Creates an instance of MaxTime.
|
||||
*
|
||||
* - **maxTime** (*Integer*) Maximum time a child can execute.
|
||||
* - **child** (*BaseNode*) The child node.
|
||||
*
|
||||
*/
|
||||
constructor({maxTime, child}?: {maxTime?: number, child?: BaseNode});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* RepeatUntilFailure is a decorator that repeats the tick signal until the
|
||||
* node child returns `FAILURE`, `RUNNING` or `ERROR`. Optionally, a maximum
|
||||
* number of repetitions can be defined.
|
||||
*
|
||||
*/
|
||||
class RepeatUntilFailure extends Decorator {
|
||||
/**
|
||||
* Creates an instance of RepeatUntilFailure.
|
||||
*
|
||||
* - **maxLoop** (*Integer*) Maximum number of repetitions. Default to -1 (infinite).
|
||||
* - **child** (*BaseNode*) The child node.
|
||||
*
|
||||
*/
|
||||
constructor({maxLoop, child}?: {maxLoop?: number, child?: BaseNode});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* RepeatUntilSuccess is a decorator that repeats the tick signal until the
|
||||
* node child returns `SUCCESS`, `RUNNING` or `ERROR`. Optionally, a maximum
|
||||
* number of repetitions can be defined.
|
||||
*
|
||||
*/
|
||||
class RepeatUntilSuccess extends Decorator {
|
||||
/**
|
||||
* Creates an instance of RepeatUntilSuccess.
|
||||
*
|
||||
* - **maxLoop** (*Integer*) Maximum number of repetitions. Default to -1 (infinite).
|
||||
* - **child** (*BaseNode*) The child node.
|
||||
*
|
||||
*/
|
||||
constructor({maxLoop, child}?: {maxLoop?: number, child?: BaseNode});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeater is a decorator that repeats the tick signal until the child node
|
||||
* return `RUNNING` or `ERROR`. Optionally, a maximum number of repetitions
|
||||
* can be defined.
|
||||
*
|
||||
*/
|
||||
class Repeater extends Decorator {
|
||||
/**
|
||||
* Creates an instance of MaxTime.
|
||||
*
|
||||
* - **maxLoop** (*Integer*) Maximum number of repetitions. Default to -1 (infinite).
|
||||
* - **child** (*BaseNode*) The child node.
|
||||
*
|
||||
*/
|
||||
constructor({maxLoop, child}?: {maxLoop?: number, child?: BaseNode});
|
||||
|
||||
/**
|
||||
* Open method.
|
||||
*/
|
||||
open(tick: Tick): void;
|
||||
|
||||
/**
|
||||
* Tick method.
|
||||
*/
|
||||
tick(tick: Tick): number;
|
||||
}
|
||||
|
||||
const VERSION: string;
|
||||
const SUCCESS: number;
|
||||
const FAILURE: number;
|
||||
const RUNNING: number;
|
||||
const ERROR: number;
|
||||
const COMPOSITE: string;
|
||||
const DECORATOR: string;
|
||||
const ACTION: string;
|
||||
const CONDITION: string;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"behavior3-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,19 @@
|
||||
import BiMap from "bidirectional-map";
|
||||
|
||||
const bidirectionalMap = new BiMap({
|
||||
one: 1
|
||||
});
|
||||
bidirectionalMap.size; // $ExpectType number
|
||||
bidirectionalMap.set("two", 2);
|
||||
bidirectionalMap.set("three", 3);
|
||||
bidirectionalMap.get("one"); // $ExpectType number
|
||||
bidirectionalMap.get(true); // $ExpectError
|
||||
bidirectionalMap.getKey(1); // $ExpectType string
|
||||
bidirectionalMap.getKey("one"); // $ExpectError
|
||||
bidirectionalMap.delete("two");
|
||||
bidirectionalMap.deleteValue(3);
|
||||
bidirectionalMap.entries(); // $ExpectType IterableIterator<[string, number]>
|
||||
bidirectionalMap.has("one"); // $ExpectType boolean
|
||||
bidirectionalMap.hasValue(2); // $ExpectType boolean
|
||||
bidirectionalMap.keys(); // $ExpectType IterableIterator<string>
|
||||
bidirectionalMap.values(); // $ExpectType IterableIterator<number>
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for bidirectional-map 1.0
|
||||
// Project: https://github.com/educastellano/bidirectional-map
|
||||
// Definitions by: Helen Anderson <https://github.com/helenanderson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export default class BiMap<TValue> {
|
||||
constructor(object?: { [i: string]: TValue });
|
||||
size: number;
|
||||
|
||||
set(key: string, value: TValue): void;
|
||||
get(key: string): TValue;
|
||||
getKey(value: TValue): string;
|
||||
clear(): void;
|
||||
delete(key: string): void;
|
||||
deleteValue(value: TValue): void;
|
||||
entries(): IterableIterator<[string, TValue]>;
|
||||
has(key: string): boolean;
|
||||
hasValue(value: TValue): boolean;
|
||||
keys(): IterableIterator<string>;
|
||||
values(): IterableIterator<TValue>;
|
||||
}
|
||||
@@ -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",
|
||||
"bidirectional-map-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as blocked from 'blocked';
|
||||
|
||||
blocked((ms: number) => {
|
||||
// todo: show warning
|
||||
}, {
|
||||
threshold: 10
|
||||
});
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for blocked 1.2
|
||||
// Project: https://github.com/visionmedia/node-blocked#readme
|
||||
// Definitions by: Jonas Lochmann <https://github.com/l-jonas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
/*~ 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.
|
||||
*/
|
||||
|
||||
export = Blocked;
|
||||
|
||||
declare function Blocked(callback: (ms: number) => void, options?: Blocked.Options): NodeJS.Timer;
|
||||
|
||||
declare namespace Blocked {
|
||||
interface Options {
|
||||
threshold: number; // in milliseconds
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"blocked-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -30,3 +30,10 @@ const options: retry.Options = {
|
||||
};
|
||||
|
||||
retry(logFail, options);
|
||||
|
||||
function stopErrorExample() {
|
||||
console.log('retrying\n');
|
||||
throw new retry.StopError('stop retrying');
|
||||
}
|
||||
|
||||
retry(stopErrorExample);
|
||||
|
||||
Vendored
+2
@@ -20,6 +20,8 @@ declare namespace retry {
|
||||
context?: any;
|
||||
args?: any;
|
||||
}
|
||||
|
||||
class StopError extends Error {}
|
||||
}
|
||||
|
||||
export = retry;
|
||||
|
||||
@@ -167,8 +167,8 @@ browserSync({
|
||||
browserSync({
|
||||
proxy: {
|
||||
target: "http://yourlocal.dev",
|
||||
proxyRes: function (proxyRes, req, res) {
|
||||
console.log(proxyRes);
|
||||
proxyRes: function (proxyResponse, req, res) {
|
||||
console.log(proxyResponse);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -177,8 +177,28 @@ browserSync({
|
||||
proxy: {
|
||||
target: "http://yourlocal.dev",
|
||||
proxyRes: [
|
||||
function (proxyRes, req, res) {
|
||||
console.log(proxyRes);
|
||||
function (proxyResponse, req, res) {
|
||||
console.log(proxyResponse);
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
browserSync({
|
||||
proxy: {
|
||||
target: "http://yourlocal.dev",
|
||||
proxyRes: function (res) {
|
||||
console.log(res);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
browserSync({
|
||||
proxy: {
|
||||
target: "http://yourlocal.dev",
|
||||
proxyRes: [
|
||||
function (res) {
|
||||
console.log(res);
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+39
-17
@@ -39,7 +39,7 @@ declare namespace browserSync {
|
||||
* Specify which file events to respond to.
|
||||
* Available events: `add`, `change`, `unlink`, `addDir`, `unlinkDir`
|
||||
*/
|
||||
watchEvents?: string[];
|
||||
watchEvents?: WatchEvents | string[];
|
||||
/**
|
||||
* Watch files automatically.
|
||||
*/
|
||||
@@ -72,7 +72,7 @@ declare namespace browserSync {
|
||||
* ws - Default: undefined
|
||||
* middleware - Default: undefined
|
||||
* reqHeaders - Default: undefined
|
||||
* proxyRes - Default: undefined
|
||||
* proxyRes - Default: undefined (http.ServerResponse if expecting single parameter)
|
||||
* proxyReq - Default: undefined
|
||||
*/
|
||||
proxy?: string | ProxyOptions;
|
||||
@@ -91,7 +91,7 @@ declare namespace browserSync {
|
||||
* Default: []
|
||||
* Note: Requires at least version 2.8.0.
|
||||
*/
|
||||
serveStatic?: (string | { route?: string | string[], dir?: string | string[]})[];
|
||||
serveStatic?: StaticOptions[] | string[];
|
||||
/**
|
||||
* Options that are passed to the serve-static middleware when you use the
|
||||
* string[] syntax: eg: `serveStatic: ['./app']`.
|
||||
@@ -120,7 +120,7 @@ declare namespace browserSync {
|
||||
* Can be either "info", "debug", "warn", or "silent"
|
||||
* Default: info
|
||||
*/
|
||||
logLevel?: string;
|
||||
logLevel?: LogLevel;
|
||||
/**
|
||||
* Change the console logging prefix. Useful if you're creating your own project based on Browsersync
|
||||
* Default: BS
|
||||
@@ -170,7 +170,7 @@ declare namespace browserSync {
|
||||
* Decide which URL to open automatically when Browsersync starts. Defaults to "local" if none set.
|
||||
* Can be true, local, external, ui, ui-external, tunnel or false
|
||||
*/
|
||||
open?: string | boolean;
|
||||
open?: OpenOptions | boolean;
|
||||
/**
|
||||
* The browser(s) to open
|
||||
* Default: default
|
||||
@@ -320,6 +320,12 @@ declare namespace browserSync {
|
||||
excludeFileTypes?: string[];
|
||||
}
|
||||
|
||||
type WatchEvents = "add" | "change" | "unlink" | "addDir" | "unlinkDir";
|
||||
|
||||
type LogLevel = "info" | "debug" | "warn" | "silent";
|
||||
|
||||
type OpenOptions = "local" | "external" | "ui" | "ui-external" | "tunnel";
|
||||
|
||||
interface Hash<T> {
|
||||
[path: string]: T;
|
||||
}
|
||||
@@ -353,16 +359,21 @@ declare namespace browserSync {
|
||||
routes?: Hash<string>;
|
||||
/** configure custom middleware */
|
||||
middleware?: (MiddlewareHandler | PerRouteMiddleware)[];
|
||||
serveStaticOptions?: ServeStaticOptions
|
||||
serveStaticOptions?: ServeStaticOptions;
|
||||
}
|
||||
|
||||
interface ProxyOptions {
|
||||
target?: string;
|
||||
middleware?: MiddlewareHandler;
|
||||
ws?: boolean;
|
||||
reqHeaders?: (config: any) => Hash<any>;
|
||||
proxyRes?: ((res: http.ServerResponse, req: http.IncomingMessage, next: Function) => any)[] | ((res: http.ServerResponse, req: http.IncomingMessage, next: Function) => any);
|
||||
proxyReq?: ((res: http.ServerRequest) => any)[] | ((res: http.ServerRequest) => any);
|
||||
reqHeaders?: (config: object) => Hash<object>;
|
||||
proxyRes?: ProxyResponseMiddleware | ProxyResponseMiddleware[];
|
||||
proxyReq?: ((res: http.ServerRequest) => void)[] | ((res: http.ServerRequest) => void);
|
||||
error?: (err: NodeJS.ErrnoException, req: http.IncomingMessage, res: http.ServerResponse) => void;
|
||||
}
|
||||
|
||||
interface ProxyResponseMiddleware {
|
||||
(proxyRes: http.ServerResponse | http.IncomingMessage, res: http.ServerResponse, req: http.IncomingMessage): void;
|
||||
}
|
||||
|
||||
interface HttpsOptions {
|
||||
@@ -370,11 +381,17 @@ declare namespace browserSync {
|
||||
cert?: string;
|
||||
}
|
||||
|
||||
interface StaticOptions {
|
||||
route: string | string[],
|
||||
dir: string | string[]
|
||||
}
|
||||
|
||||
interface MiddlewareHandler {
|
||||
(req: http.IncomingMessage, res: http.ServerResponse, next: Function): any;
|
||||
(req: http.IncomingMessage, res: http.ServerResponse, next: () => void): any;
|
||||
}
|
||||
|
||||
interface PerRouteMiddleware {
|
||||
id?: string;
|
||||
route: string;
|
||||
handle: MiddlewareHandler;
|
||||
}
|
||||
@@ -382,18 +399,23 @@ declare namespace browserSync {
|
||||
interface GhostOptions {
|
||||
clicks?: boolean;
|
||||
scroll?: boolean;
|
||||
forms?: boolean | {
|
||||
submit?: boolean;
|
||||
inputs?: boolean;
|
||||
toggles?: boolean;
|
||||
};
|
||||
forms?: FormsOptions | boolean;
|
||||
}
|
||||
|
||||
interface FormsOptions {
|
||||
inputs: boolean,
|
||||
submit: boolean,
|
||||
toggles: boolean
|
||||
}
|
||||
|
||||
interface SnippetOptions {
|
||||
async?: boolean,
|
||||
async?: boolean;
|
||||
whitelist?: string[],
|
||||
blacklist?: string[],
|
||||
rule?: { match?: RegExp; fn?: (snippet: string, match: string) => any };
|
||||
rule?: {
|
||||
match?: RegExp;
|
||||
fn?: (snippet: string, match: string) => any
|
||||
};
|
||||
}
|
||||
|
||||
interface SocketOptions {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import btoa from 'btoa';
|
||||
|
||||
btoa('foo');
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for btoa 1.2
|
||||
// Project: https://git.coolaj86.com/coolaj86/btoa.js
|
||||
// Definitions by: John Wright <https://github.com/johngeorgewright>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export default function(str: string): string;
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"lib": ["es6"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"btoa-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -88,6 +88,27 @@ spyStringArg('foo');
|
||||
expect(spyStringArg).to.have.been.called.always.with.exactly('foo');
|
||||
spyStringArg.should.have.been.called.always.with.exactly('foo');
|
||||
|
||||
// .first / .second / .third
|
||||
const spyStringIteratedArg = chai.spy((arg: string) => arg);
|
||||
spyStringIteratedArg('foo');
|
||||
spyStringIteratedArg('bar');
|
||||
spyStringIteratedArg('baz');
|
||||
expect(spyStringIteratedArg).to.have.been.first.called.with('foo');
|
||||
spyStringIteratedArg.should.have.been.first.called.with('foo');
|
||||
expect(spyStringIteratedArg).to.have.been.first.called.with('bar');
|
||||
spyStringIteratedArg.should.have.been.first.called.with('bar');
|
||||
expect(spyStringIteratedArg).to.have.been.first.called.with('baz');
|
||||
spyStringIteratedArg.should.have.been.first.called.with('baz');
|
||||
|
||||
// .nth
|
||||
const spyStringNthArg = chai.spy((arg: string) => arg);
|
||||
spyStringNthArg('foo');
|
||||
spyStringNthArg('bar');
|
||||
expect(spyStringNthArg).on.nth(1).be.called.with('foo');
|
||||
spyStringNthArg.should.on.nth(1).be.called.with('foo');
|
||||
expect(spyStringNthArg).on.nth(2).be.called.with('bar');
|
||||
spyStringNthArg.should.on.nth(2).be.called.with('bar');
|
||||
|
||||
// .once
|
||||
expect(spy).to.have.been.called.once;
|
||||
expect(spy).to.not.have.been.called.once;
|
||||
|
||||
Vendored
+67
@@ -10,6 +10,10 @@ declare namespace Chai {
|
||||
spy: ChaiSpies.Spy;
|
||||
}
|
||||
|
||||
interface LanguageChains {
|
||||
on: Assertion;
|
||||
}
|
||||
|
||||
interface Assertion {
|
||||
/**
|
||||
* ####.spy
|
||||
@@ -31,6 +35,28 @@ declare namespace Chai {
|
||||
* Note that ```called``` can be used as a chainable method.
|
||||
*/
|
||||
called: ChaiSpies.Called;
|
||||
|
||||
/**
|
||||
* * ####.been
|
||||
* * Assert that something has been spied on. Negation passes through.
|
||||
* * ```ts
|
||||
* * expect(spy).to.have.been.called();
|
||||
* * spy.should.have.been.called();
|
||||
* ```
|
||||
* Note that ```been``` can be used as a chainable method.
|
||||
*/
|
||||
been: ChaiSpies.Been;
|
||||
|
||||
/**
|
||||
* * ####.nth (function)
|
||||
* * Assert that something has been spied on on a certain index. Negation passes through.
|
||||
* * ```ts
|
||||
* * expect(spy).on.nth(5).be.called.with('foobar');
|
||||
* * spy.should.on.nth(5).be.called.with('foobar');
|
||||
* ```
|
||||
* Note that ```nth``` can be used as a chainable method.
|
||||
*/
|
||||
nth(index: number): Assertion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +250,47 @@ declare namespace ChaiSpies {
|
||||
lt(n: number): Chai.Assertion;
|
||||
}
|
||||
|
||||
interface Been extends Chai.Assertion {
|
||||
(): Chai.Assertion;
|
||||
called: Called;
|
||||
|
||||
/**
|
||||
* ####.first
|
||||
* Assert that a spy has been called first.
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.first;
|
||||
* expect(spy).to.not.have.been.called.first;
|
||||
* spy.should.have.been.called.first;
|
||||
* spy.should.not.have.been.called.first;
|
||||
* ```
|
||||
*/
|
||||
first: Chai.Assertion;
|
||||
|
||||
/**
|
||||
* ####.second
|
||||
* Assert that a spy has been called second.
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.second;
|
||||
* expect(spy).to.not.have.been.called.second;
|
||||
* spy.should.have.been.called.second;
|
||||
* spy.should.not.have.been.called.second;
|
||||
* ```
|
||||
*/
|
||||
second: Chai.Assertion;
|
||||
|
||||
/**
|
||||
* ####.third
|
||||
* Assert that a spy has been called third.
|
||||
* ```ts
|
||||
* expect(spy).to.have.been.called.third;
|
||||
* expect(spy).to.not.have.been.called.third;
|
||||
* spy.should.have.been.called.third;
|
||||
* spy.should.not.have.been.called.third;
|
||||
* ```
|
||||
*/
|
||||
third: Chai.Assertion;
|
||||
}
|
||||
|
||||
interface With {
|
||||
/**
|
||||
* ####.with
|
||||
|
||||
Vendored
+6
-1
@@ -10,6 +10,7 @@
|
||||
// Guillaume Rodriguez <https://github.com/guillaume-ro-fr>
|
||||
// Sergey Rubanov <https://github.com/chicoxyzzy>
|
||||
// Simon Archer <https://github.com/archy-bold>
|
||||
// Ken Elkabany <https://github.com/braincore>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -168,6 +169,7 @@ declare namespace Chart {
|
||||
x?: number | string | Date;
|
||||
y?: number | string | Date;
|
||||
r?: number;
|
||||
t?: number | string | Date;
|
||||
}
|
||||
|
||||
interface ChartConfiguration {
|
||||
@@ -219,7 +221,7 @@ declare namespace Chart {
|
||||
interface ChartTitleOptions {
|
||||
display?: boolean;
|
||||
position?: PositionType;
|
||||
fullWdith?: boolean;
|
||||
fullWidth?: boolean;
|
||||
fontSize?: number;
|
||||
fontFamily?: string;
|
||||
fontColor?: ChartColor;
|
||||
@@ -422,6 +424,7 @@ declare namespace Chart {
|
||||
padding?: number;
|
||||
reverse?: boolean;
|
||||
showLabelBackdrop?: boolean;
|
||||
source?: 'auto' | 'data' | 'labels';
|
||||
}
|
||||
|
||||
interface AngleLineOptions {
|
||||
@@ -510,6 +513,7 @@ declare namespace Chart {
|
||||
gridLines?: GridLineOptions;
|
||||
barThickness?: number;
|
||||
scaleLabel?: ScaleTitleOptions;
|
||||
offset?: boolean;
|
||||
beforeUpdate?(scale?: any): void;
|
||||
beforeSetDimension?(scale?: any): void;
|
||||
beforeDataLimits?(scale?: any): void;
|
||||
@@ -529,6 +533,7 @@ declare namespace Chart {
|
||||
interface ChartXAxe extends CommonAxe {
|
||||
categoryPercentage?: number;
|
||||
barPercentage?: number;
|
||||
distribution?: 'linear' | 'series';
|
||||
time?: TimeScale;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -263,6 +263,7 @@ declare namespace chrome.bookmarks {
|
||||
export interface BookmarkRemoveInfo {
|
||||
index: number;
|
||||
parentId: string;
|
||||
node: BookmarkTreeNode;
|
||||
}
|
||||
|
||||
export interface BookmarkMoveInfo {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import progress = require('cli-progress');
|
||||
|
||||
function test0() {
|
||||
// Usage
|
||||
// Multiple examples are available e.g.example.js - just try it $ node example.js
|
||||
|
||||
const _cliProgress = require('cli-progress');
|
||||
|
||||
// create a new progress bar instance and use shades_classic theme
|
||||
const bar1 = new _cliProgress.Bar({}, _cliProgress.Presets.shades_classic);
|
||||
|
||||
// start the progress bar with a total value of 200 and start value of 0
|
||||
bar1.start(200, 0);
|
||||
|
||||
// update the current value in your application..
|
||||
bar1.update(100);
|
||||
|
||||
// stop the progress bar
|
||||
bar1.stop();
|
||||
}
|
||||
|
||||
function test1() {
|
||||
// Examples
|
||||
// Example 1 - Set Options
|
||||
|
||||
// change the progress characters
|
||||
// set fps limit to 5
|
||||
// change the output stream and barsize
|
||||
const bar = new progress.Bar({
|
||||
barCompleteChar: '#',
|
||||
barIncompleteChar: '.',
|
||||
fps: 5,
|
||||
stream: process.stdout,
|
||||
barsize: 65
|
||||
});
|
||||
}
|
||||
|
||||
function test2() {
|
||||
// Example 2 - Change Styles defined by Preset
|
||||
// uee shades preset
|
||||
// change the barsize
|
||||
const bar = new progress.Bar({
|
||||
barsize: 65
|
||||
}, progress.Presets.shades_grey);
|
||||
}
|
||||
|
||||
function test3() {
|
||||
// Example 3 - Custom Payload
|
||||
// create new progress bar with custom token "speed"
|
||||
const bar = new progress.Bar({
|
||||
format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit'
|
||||
});
|
||||
|
||||
// initialize the bar - set payload token "speed" with the default value "N/A"
|
||||
bar.start(200, 0, {
|
||||
speed: "N/A"
|
||||
});
|
||||
|
||||
// some code/update loop
|
||||
// ...
|
||||
|
||||
// update bar value. set custom token "speed" to 125
|
||||
bar.update(5, {
|
||||
speed: '125'
|
||||
});
|
||||
|
||||
// process finished
|
||||
bar.stop();
|
||||
}
|
||||
|
||||
function test4() {
|
||||
// Example 4 - Custom Presets
|
||||
// File mypreset.js
|
||||
|
||||
const _colors = require('colors');
|
||||
|
||||
module.exports = {
|
||||
format: _colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591'
|
||||
};
|
||||
}
|
||||
|
||||
function test5() {
|
||||
// Application
|
||||
|
||||
const _mypreset = require('./mypreset.js');
|
||||
|
||||
const bar = new progress.Bar({
|
||||
barsize: 65
|
||||
}, _mypreset);
|
||||
}
|
||||
Vendored
+114
@@ -0,0 +1,114 @@
|
||||
// Type definitions for cli-progress 1.8
|
||||
// Project: https://github.com/AndiDittrich/Node.CLI-Progress
|
||||
// Definitions by: My Self <https://github.com/mhegazy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* progress bar output format.
|
||||
* The progressbar can be customized by using the following build-in placeholders. They can be combined in any order.
|
||||
* {bar} - the progress bar, customizable by the options barsize, barCompleteString and barIncompleteString
|
||||
* {percentage} - the current progress in percent (0-100)
|
||||
* {total} - the end value
|
||||
* {value} - the current value set by last update() call
|
||||
* {eta} - expected time of accomplishment in seconds
|
||||
* {duration} - elapsed time in seconds
|
||||
* {eta_formatted} - expected time of accomplishment formatted into appropriate units
|
||||
* {duration_formatted} - elapsed time formatted into appropriate units
|
||||
*
|
||||
* Example:
|
||||
* progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}
|
||||
* is rendered as
|
||||
* progress [========================================] 100% | ETA: 0s | 200/200
|
||||
*/
|
||||
format?: string;
|
||||
|
||||
/** the maximum update rate (default: 10) */
|
||||
fps?: number;
|
||||
|
||||
/** output stream to use (default: process.stderr) */
|
||||
stream?: NodeJS.WritableStream;
|
||||
|
||||
/** automatically call stop() when the value reaches the total (default: false) */
|
||||
stopOnComplete?: boolean;
|
||||
|
||||
/** clear the progress bar on complete / stop() call (default: false) */
|
||||
clearOnComplete?: boolean;
|
||||
|
||||
/** the length of the progress bar in chars (default: 40) */
|
||||
barsize?: number;
|
||||
|
||||
/** character to use as "complete" indicator in the bar (default: "=") */
|
||||
barCompleteString?: string;
|
||||
|
||||
/** character to use as "incomplete" indicator in the bar (default: "-") */
|
||||
barIncompleteString?: string;
|
||||
|
||||
/** character to use as "complete" indicator in the bar (default: "=") */
|
||||
barCompleteChar?: string;
|
||||
|
||||
/** character to use as "incomplete" indicator in the bar (default: "-") */
|
||||
barIncompleteChar?: string;
|
||||
|
||||
/** hide the cursor during progress operation; restored on complete (default: false) */
|
||||
hideCursor?: boolean;
|
||||
|
||||
/** number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10) */
|
||||
etaBuffer?: number;
|
||||
|
||||
/** disable line wrapping (default: false) - pass null to keep terminal settings; pass true to trim the output to terminal width */
|
||||
linewrap?: boolean | null;
|
||||
}
|
||||
|
||||
export interface Preset {
|
||||
barCompleteChar: string;
|
||||
barIncompleteChar: string;
|
||||
format: string;
|
||||
}
|
||||
|
||||
export class Bar {
|
||||
/** Initialize a new Progress bar. An instance can be used multiple times! it's not required to re-create it! */
|
||||
constructor(opt: Options, preset?: Preset);
|
||||
|
||||
calculateETA(): void;
|
||||
|
||||
formatTime(t: any, roundToMultipleOf: any): any;
|
||||
|
||||
getTotal(): any;
|
||||
|
||||
/** Increases the current progress value by a specified amount (default +1). Update payload optionally */
|
||||
increment(step: number, payload?: object): void;
|
||||
|
||||
render(): void;
|
||||
|
||||
/** Sets the total progress value while progressbar is active. Especially useful handling dynamic tasks. */
|
||||
setTotal(total: number): void;
|
||||
|
||||
/** Starts the progress bar and set the total and initial value */
|
||||
start(total: number, startValue: number, payload?: object): void;
|
||||
|
||||
/** Stops the progress bar and go to next line */
|
||||
stop(): void;
|
||||
|
||||
stopTimer(): void;
|
||||
|
||||
/** Sets the current progress value and optionally the payload with values of custom tokens as a second parameter */
|
||||
update(current: number, payload?: object): void;
|
||||
}
|
||||
|
||||
export const Presets: {
|
||||
/** Styles as of cli-progress v1.3.0 */
|
||||
legacy: Preset;
|
||||
|
||||
/** Unicode Rectangles */
|
||||
rect: Preset;
|
||||
|
||||
/** Unicode background shades are used for the bar */
|
||||
shades_classic: Preset;
|
||||
|
||||
/** Unicode background shades with grey bar */
|
||||
shades_grey: Preset;
|
||||
};
|
||||
@@ -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",
|
||||
"cli-progress-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,11 @@
|
||||
import { PassThrough } from 'stream';
|
||||
import cloneable = require('cloneable-readable');
|
||||
|
||||
const ps = new PassThrough(); // $ExpectType PassThrough
|
||||
const cl = cloneable(ps); // $ExpectType Cloneable<PassThrough>
|
||||
|
||||
process.stdin.pipe(cl.clone()).pipe(process.stderr);
|
||||
process.stdin.pipe(cl).pipe(process.stdout);
|
||||
|
||||
cloneable.isCloneable(ps); // $ExpectType boolean
|
||||
cloneable.isCloneable(cl); // $ExpectType boolean
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// Type definitions for cloneable-readable 1.1
|
||||
// Project: https://github.com/mcollina/cloneable-readable#readme
|
||||
// Definitions by: Nikita Volodin <https://github.com/qlonik>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
import { Readable } from 'stream';
|
||||
|
||||
type Cloneable<T> = T & { clone(): Cloneable<T> };
|
||||
interface CloneableFn {
|
||||
<T extends Readable>(x: T): Cloneable<T>;
|
||||
isCloneable(x: Readable): boolean;
|
||||
}
|
||||
declare const cloneable: CloneableFn;
|
||||
export = cloneable;
|
||||
@@ -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",
|
||||
"cloneable-readable-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,10 +1,24 @@
|
||||
import commandLineArgs = require('command-line-args');
|
||||
|
||||
const optionDefinitions = [
|
||||
{ name: 'verbose', alias: 'v', type: Boolean },
|
||||
{ name: 'src', type: String, multiple: true, defaultOption: true },
|
||||
{ name: 'timeout', alias: 't', type: Number }
|
||||
const optionDefinitions: commandLineArgs.OptionDefinition[] = [
|
||||
{
|
||||
name: 'something',
|
||||
alias: 's',
|
||||
type: String,
|
||||
defaultValue: '1',
|
||||
multiple: true,
|
||||
lazyMultiple: true,
|
||||
defaultOption: true,
|
||||
group: 'one'
|
||||
}
|
||||
];
|
||||
|
||||
const options = commandLineArgs(optionDefinitions);
|
||||
const options = commandLineArgs(optionDefinitions, {
|
||||
argv: [ '--one', '1' ],
|
||||
partial: true,
|
||||
stopAtFirstUnknown: true,
|
||||
camelCase: true
|
||||
});
|
||||
|
||||
const unknown = options._unknown;
|
||||
const something = options.something;
|
||||
|
||||
Vendored
+79
-76
@@ -1,87 +1,90 @@
|
||||
// Type definitions for command-line-args 4.0.7
|
||||
// Type definitions for command-line-args 5.0
|
||||
// Project: https://github.com/75lb/command-line-args
|
||||
// Definitions by: CzBuCHi <https://github.com/CzBuCHi>
|
||||
// Definitions by: Lloyd Brookes <https://github.com/75lb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/**
|
||||
* Returns an object containing all options set on the command line. By default it parses the global [`process.argv`](https://nodejs.org/api/process.html#process_process_argv) array.
|
||||
*
|
||||
* By default, an exception is thrown if the user sets an unknown option (one without a valid [definition](#exp_module_definition--OptionDefinition)). To enable __partial parsing__, invoke `commandLineArgs` with the `partial` option - all unknown arguments will be returned in the `_unknown` property.
|
||||
*
|
||||
*
|
||||
* @param {module:definition[]} - An array of [OptionDefinition](#exp_module_definition--OptionDefinition) objects
|
||||
* @param [options] {object} - Options.
|
||||
* @param [options.argv] {string[]} - An array of strings, which if passed will be parsed instead of `process.argv`.
|
||||
* @param [options.partial] {boolean} - If `true`, an array of unknown arguments is returned in the `_unknown` property of the output.
|
||||
* @returns {object}
|
||||
* @throws `UNKNOWN_OPTION` if `options.partial` is false and the user set an undefined option
|
||||
* @throws `NAME_MISSING` if an option definition is missing the required `name` property
|
||||
* @throws `INVALID_TYPE` if an option definition has a `type` value that's not a function
|
||||
* @throws `INVALID_ALIAS` if an alias is numeric, a hyphen or a length other than 1
|
||||
* @throws `DUPLICATE_NAME` if an option definition name was used more than once
|
||||
* @throws `DUPLICATE_ALIAS` if an option definition alias was used more than once
|
||||
* @throws `DUPLICATE_DEFAULT_OPTION` if more than one option definition has `defaultOption: true`
|
||||
* @alias module:command-line-args
|
||||
* Returns an object containing option values parsed from the command line. By default it parses the global `process.argv` array.
|
||||
* Parsing is strict by default. To be more permissive, enable `partial` or `stopAtFirstUnknown` modes.
|
||||
*/
|
||||
declare function commandLineArgs(optionDefinitions: commandLineArgs.OptionDefinition[], options?: commandLineArgs.Options): any;
|
||||
declare function commandLineArgs(optionDefinitions: commandLineArgs.OptionDefinition[], options?: commandLineArgs.ParseOptions): commandLineArgs.CommandLineOptions;
|
||||
|
||||
declare module commandLineArgs {
|
||||
declare namespace commandLineArgs {
|
||||
interface CommandLineOptions {
|
||||
/**
|
||||
* Command-line arguments not parsed by `commandLineArgs`.
|
||||
*/
|
||||
_unknown?: string[];
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
export interface OptionDefinition {
|
||||
/**
|
||||
* The only required definition property is name, the value of each option will be either a Boolean or string.
|
||||
*/
|
||||
name: string,
|
||||
/**
|
||||
* The type value is a setter function (you receive the output from this),
|
||||
* enabling you to be specific about the type and value received.
|
||||
*/
|
||||
type?: (arg: string) => any,
|
||||
/**
|
||||
* getopt-style short option names. Can be any single character (unicode included) except a digit or hypen.
|
||||
*/
|
||||
alias?: string,
|
||||
/**
|
||||
* Set this flag if the option takes a list of values. You will receive an array of values, each passed
|
||||
* through the type function (if specified).
|
||||
*/
|
||||
multiple?: boolean,
|
||||
/**
|
||||
* Any unclaimed command-line args will be set on this option. This flag is typically set on
|
||||
* the most commonly-used option to make for more concise usage
|
||||
* (i.e. $ myapp *.js instead of $ myapp --files *.js).
|
||||
*/
|
||||
defaultOption?: boolean,
|
||||
/**
|
||||
* An initial value for the option.
|
||||
*/
|
||||
defaultValue?: any,
|
||||
/**
|
||||
* When your app has a large amount of options it makes sense to organise them in groups.
|
||||
* There are two automatic groups: _all (contains all options) and _none (contains options
|
||||
* without a group specified in their definition).
|
||||
*/
|
||||
group?: string | string[],
|
||||
/**
|
||||
* Describes the option.
|
||||
*/
|
||||
description?: string,
|
||||
/**
|
||||
* A label for the type, e.g. <ms>.
|
||||
*/
|
||||
typeLabel?: string;
|
||||
}
|
||||
interface ParseOptions {
|
||||
/**
|
||||
* An array of strings which if present will be parsed instead of `process.argv`.
|
||||
*/
|
||||
argv?: string[];
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* An array of strings, which if passed will be parsed instead of `process.argv`.
|
||||
*/
|
||||
argv?: string[];
|
||||
/**
|
||||
* If `true`, an array of unknown arguments is returned in the `_unknown` property of the output.
|
||||
*/
|
||||
partial?: boolean;
|
||||
}
|
||||
/**
|
||||
* If `true`, `commandLineArgs` will not throw on unknown options or values, instead returning them in the `_unknown` property of the output.
|
||||
*/
|
||||
partial?: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, `commandLineArgs` will not throw on unknown options or values. Instead, parsing will stop at the first unknown argument
|
||||
* and the remaining arguments returned in the `_unknown` property of the output. If set, `partial: true` is implied.
|
||||
*/
|
||||
stopAtFirstUnknown?: boolean;
|
||||
|
||||
/**
|
||||
* If `true`, options with hypenated names (e.g. `move-to`) will be returned in camel-case (e.g. `moveTo`).
|
||||
*/
|
||||
camelCase?: boolean;
|
||||
}
|
||||
|
||||
interface OptionDefinition {
|
||||
/**
|
||||
* The long option name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
|
||||
* are `String` (the default), `Number` and `Boolean` but you can use a custom function. If no option value was set you will receive `null`.
|
||||
*/
|
||||
type?: (input: string) => any;
|
||||
|
||||
/**
|
||||
* A getopt-style short option name. Can be any single character except a digit or hyphen.
|
||||
*/
|
||||
alias?: string;
|
||||
|
||||
/**
|
||||
* Set this flag if the option accepts multiple values. In the output, you will receive an array of values each passed through the `type` function.
|
||||
*/
|
||||
multiple?: boolean;
|
||||
|
||||
/**
|
||||
* Identical to `multiple` but with greedy parsing disabled.
|
||||
*/
|
||||
lazyMultiple?: boolean;
|
||||
|
||||
/**
|
||||
* Any values unaccounted for by an option definition will be set on the `defaultOption`. This flag is typically set
|
||||
* on the most commonly-used option to enable more concise usage.
|
||||
*/
|
||||
defaultOption?: boolean;
|
||||
|
||||
/**
|
||||
* An initial value for the option.
|
||||
*/
|
||||
defaultValue?: any;
|
||||
|
||||
/**
|
||||
* One or more group names the option belongs to.
|
||||
*/
|
||||
group?: string | string[];
|
||||
}
|
||||
}
|
||||
|
||||
export = commandLineArgs;
|
||||
|
||||
@@ -1,79 +1,5 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import commandLineArgs = require('command-line-args');
|
||||
|
||||
const optionDefinitions: commandLineArgs.OptionDefinition[] = [
|
||||
{
|
||||
name: 'something',
|
||||
alias: 's',
|
||||
type: String,
|
||||
defaultValue: '1',
|
||||
multiple: true,
|
||||
defaultOption: true,
|
||||
group: 'one'
|
||||
}
|
||||
];
|
||||
|
||||
const options = commandLineArgs(optionDefinitions, {
|
||||
argv: [ '--one', '1' ],
|
||||
partial: true
|
||||
});
|
||||
|
||||
const unknown = options._unknown;
|
||||
const something = options.something;
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// Type definitions for command-line-args 4.0
|
||||
// Project: https://github.com/75lb/command-line-args
|
||||
// Definitions by: CzBuCHi <https://github.com/CzBuCHi>, Lloyd Brookes <https://github.com/75lb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/**
|
||||
* Returns an object containing option values parsed from the command line. By default it parses the global `process.argv` array.
|
||||
*/
|
||||
declare function commandLineArgs(optionDefinitions: commandLineArgs.OptionDefinition[], options?: commandLineArgs.ParseOptions): commandLineArgs.CommandLineOptions;
|
||||
|
||||
declare namespace commandLineArgs {
|
||||
interface CommandLineOptions {
|
||||
/**
|
||||
* Command-line arguments not parsed by `commandLineArgs`.
|
||||
*/
|
||||
_unknown?: string[];
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
interface ParseOptions {
|
||||
/**
|
||||
* An array of strings which if present will be parsed instead of `process.argv`.
|
||||
*/
|
||||
argv?: string[];
|
||||
|
||||
/**
|
||||
* If `true`, `commandLineArgs` will not throw on unknown options or values, instead returning them in the `_unknown` property of the output.
|
||||
*/
|
||||
partial?: boolean;
|
||||
}
|
||||
|
||||
interface OptionDefinition {
|
||||
/**
|
||||
* The long option name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
|
||||
* are `String` (the default), `Number` and `Boolean` but you can use a custom function. If no option value was set you will receive `null`.
|
||||
*/
|
||||
type?: (input: string) => any;
|
||||
|
||||
/**
|
||||
* A getopt-style short option name. Can be any single character except a digit or hyphen.
|
||||
*/
|
||||
alias?: string;
|
||||
|
||||
/**
|
||||
* Set this flag if the option accepts multiple values. In the output, you will receive an array of values each passed through the `type` function.
|
||||
*/
|
||||
multiple?: boolean;
|
||||
|
||||
/**
|
||||
* Any values unaccounted for by an option definition will be set on the `defaultOption`. This flag is typically set
|
||||
* on the most commonly-used option to enable more concise usage.
|
||||
*/
|
||||
defaultOption?: boolean;
|
||||
|
||||
/**
|
||||
* An initial value for the option.
|
||||
*/
|
||||
defaultValue?: any;
|
||||
|
||||
/**
|
||||
* One or more group names the option belongs to.
|
||||
*/
|
||||
group?: string | string[];
|
||||
}
|
||||
}
|
||||
|
||||
export = commandLineArgs;
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"command-line-args": [ "command-line-args/v4" ]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"command-line-args-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ log.disable();
|
||||
// Non-standard
|
||||
point = dictOfPoint[s];
|
||||
point = dictOfPoint[i];
|
||||
point = dictOfPoint[sym];
|
||||
// point = dictOfPoint[sym];
|
||||
dictOfPoint = new Dict(dictOfPoint);
|
||||
dictOfAny = new Dict(point);
|
||||
dictOfPoint = Dict(dictOfPoint);
|
||||
|
||||
@@ -6,19 +6,23 @@
|
||||
* are not intended as functional tests.
|
||||
*/
|
||||
|
||||
import { hsv, HSVColor } from 'd3-hsv';
|
||||
import { rgb, RGBColor } from 'd3-color';
|
||||
import { hsv, HSVColor, interpolateHsv, interpolateHsvLong } from 'd3-hsv';
|
||||
import { rgb, hcl, RGBColor } from 'd3-color';
|
||||
|
||||
let c: RGBColor;
|
||||
let cRGB: RGBColor;
|
||||
let cHSV: HSVColor;
|
||||
let displayable: boolean;
|
||||
let cString: string;
|
||||
let iString: (t: number) => string;
|
||||
let nil: null;
|
||||
|
||||
// Hsv signature
|
||||
|
||||
// hsv signature
|
||||
cHSV = hsv(120, 0.4, 0.5);
|
||||
cHSV = hsv(120, 0.4, 0.5, 0.5);
|
||||
|
||||
// specifier signature
|
||||
// Specifier signature
|
||||
|
||||
cHSV = hsv('rgb(255, 255, 255)');
|
||||
cHSV = hsv('rgb(10%, 20%, 30%)');
|
||||
cHSV = hsv('rgba(255, 255, 255, 0.4)');
|
||||
@@ -28,13 +32,16 @@ cHSV = hsv('hsla(120, 50%, 20%, 0.4)');
|
||||
cHSV = hsv('#ffeeaa');
|
||||
cHSV = hsv('#fea');
|
||||
cHSV = hsv('steelblue');
|
||||
cHSV = hsv('');
|
||||
|
||||
// color signature
|
||||
c = rgb('steelblue');
|
||||
cHSV = hsv(c);
|
||||
// Color signature
|
||||
|
||||
cRGB = rgb('steelblue');
|
||||
cHSV = hsv(cRGB);
|
||||
cHSV = hsv(cHSV);
|
||||
|
||||
// method signatures
|
||||
// Method signatures
|
||||
|
||||
cHSV = cHSV.brighter();
|
||||
cHSV = cHSV.brighter(0.2);
|
||||
cHSV = cHSV.darker();
|
||||
@@ -43,3 +50,25 @@ displayable = cHSV.displayable();
|
||||
cString = cHSV.toString();
|
||||
console.log('Channels = (h : %d, s: %d, v: %d)', cHSV.h, cHSV.s, cHSV.v);
|
||||
console.log('Opacity = %d', cHSV.opacity);
|
||||
|
||||
// Interpolater
|
||||
|
||||
iString = interpolateHsv('seagreen', 'steelblue');
|
||||
iString = interpolateHsv(rgb('seagreen'), hcl('steelblue'));
|
||||
iString = interpolateHsv(rgb('seagreen'), hsv('steelblue'));
|
||||
|
||||
iString = interpolateHsvLong('seagreen', 'steelblue');
|
||||
iString = interpolateHsvLong(rgb('seagreen'), hcl('steelblue'));
|
||||
iString = interpolateHsvLong(rgb('seagreen'), hsv('steelblue'));
|
||||
|
||||
// Prototype, instanceof and typeguard
|
||||
|
||||
declare let color: RGBColor | HSVColor | null;
|
||||
|
||||
if (color instanceof rgb) {
|
||||
cRGB = color;
|
||||
} else if (color instanceof hsv) {
|
||||
cHSV = color;
|
||||
} else {
|
||||
nil = color;
|
||||
}
|
||||
|
||||
Vendored
+64
-3
@@ -1,28 +1,89 @@
|
||||
// Type definitions for D3JS d3-hsv module 0.0
|
||||
// Type definitions for D3JS d3-hsv module 0.1
|
||||
// Project: https://github.com/d3/d3-hsv/
|
||||
// Definitions by: Yuri Feldman <https://github.com/arrayjam>
|
||||
// Definitions by: Yuri Feldman <https://github.com/arrayjam>, denisname <https://github.com/denisname>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Last module patch version validated against: 0.0.3
|
||||
// Last module patch version validated against: 0.1.0
|
||||
|
||||
import { Color, RGBColor, ColorSpaceObject, ColorCommonInstance } from 'd3-color';
|
||||
|
||||
export type ColorSpaceObjectWithHSV = ColorSpaceObject | HSVColor;
|
||||
|
||||
export interface HSVColorFactory extends Function {
|
||||
/**
|
||||
* Constructs a new HSV color.
|
||||
* @param h The hue of the returned color.
|
||||
* @param s The saturation of the returned color.
|
||||
* @param v The value of the returned color.
|
||||
* @param opacity The opacity of the returned color.
|
||||
*/
|
||||
(h: number, s: number, v: number, opacity?: number): HSVColor;
|
||||
/**
|
||||
* Constructs a new HSV color.
|
||||
* @param cssColorSpecifier A CSS Color Module Level 3 specifier string,
|
||||
* it is parsed and then converted to the HSV color space.
|
||||
*/
|
||||
(cssColorSpecifier: string): HSVColor;
|
||||
/**
|
||||
* Constructs a new HSV color.
|
||||
* @param color A color instance, it will be converted to the RGB color space
|
||||
* using `color.rgb` and then converted to HSV.
|
||||
*/
|
||||
(color: HSVColor | ColorSpaceObject | ColorCommonInstance): HSVColor;
|
||||
|
||||
readonly prototype: HSVColor;
|
||||
}
|
||||
|
||||
export interface HSVColor extends Color {
|
||||
/**
|
||||
* The color hue.
|
||||
*/
|
||||
h: number;
|
||||
/**
|
||||
* The color saturation.
|
||||
*/
|
||||
s: number;
|
||||
/**
|
||||
* The color value.
|
||||
*/
|
||||
v: number;
|
||||
/**
|
||||
* The color opacity.
|
||||
*/
|
||||
opacity: number;
|
||||
|
||||
/**
|
||||
* Returns a brighter copy of this color.
|
||||
* @param k Controls how much brighter the returned color should be (defaults to 1).
|
||||
*/
|
||||
brighter(k?: number): this;
|
||||
|
||||
/**
|
||||
* Returns a darker copy of this color.
|
||||
* @param k Controls how much darker the returned color should be (defaults to 1).
|
||||
*/
|
||||
darker(k?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the RGB equivalent of this color.
|
||||
*/
|
||||
rgb(): RGBColor;
|
||||
}
|
||||
|
||||
export const hsv: HSVColorFactory;
|
||||
|
||||
/**
|
||||
* Returns an HSV color space interpolator between the two colors a and b.
|
||||
* If either color’s hue or chroma is NaN, the opposing color’s channel value is used.
|
||||
* The shortest path between hues is used. The return value of the interpolator is an RGB string.
|
||||
* @param a The starting color; it will be converted to HSV using `d3.hsv`.
|
||||
* @param b The ending color; it will be converted to HSV using `d3.hsv`.
|
||||
*/
|
||||
export function interpolateHsv(a: string | ColorCommonInstance, b: string | ColorCommonInstance): (t: number) => string;
|
||||
|
||||
/**
|
||||
* Like `interpolateHsv`, but does not use the shortest path between hues.
|
||||
* @param a The starting color; it will be converted to HSV using `d3.hsv`.
|
||||
* @param b The ending color; it will be converted to HSV using `d3.hsv`.
|
||||
*/
|
||||
export function interpolateHsvLong(a: string | ColorCommonInstance, b: string | ColorCommonInstance): (t: number) => string;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
@@ -17,7 +17,7 @@ let containsFlag: boolean;
|
||||
let point: [number, number] = [15, 15];
|
||||
const polygon: Array<[number, number]> = [[10, 10], [20, 20], [10, 30]];
|
||||
const pointArray: Array<[number, number]> = [[10, 10], [20, 20], [10, 30], [15, 15]];
|
||||
let hull: Array<[number, number]>;
|
||||
let hullOrNothing: Array<[number, number]> | null;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Tests
|
||||
@@ -27,7 +27,7 @@ num = d3Polygon.polygonArea(polygon);
|
||||
|
||||
point = d3Polygon.polygonCentroid(polygon);
|
||||
|
||||
hull = d3Polygon.polygonHull(pointArray);
|
||||
hullOrNothing = d3Polygon.polygonHull(pointArray);
|
||||
|
||||
containsFlag = d3Polygon.polygonContains(polygon, point);
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -3,11 +3,11 @@
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Last module patch version validated against: 1.0.1
|
||||
// Last module patch version validated against: 1.0.3
|
||||
|
||||
/**
|
||||
* Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order (
|
||||
* assuming a coordinate system where the origin ⟨0,0⟩ is in the top-left corner), the returned area is positive;
|
||||
* Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order
|
||||
* (assuming a coordinate system where the origin <0,0> is in the top-left corner), the returned area is positive;
|
||||
* otherwise it is negative, or zero.
|
||||
*
|
||||
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
|
||||
@@ -34,7 +34,7 @@ export function polygonHull(points: Array<[number, number]>): Array<[number, num
|
||||
* Returns true if and only if the specified point is inside the specified polygon.
|
||||
*
|
||||
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
|
||||
* @param point Coordinates of point <x, y>
|
||||
* @param point Coordinates of point <x, y>.
|
||||
*/
|
||||
export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"unified-signatures": false,
|
||||
"callable-types": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -1,80 +1,116 @@
|
||||
import moment = require("moment")
|
||||
import daterangepicker = require("daterangepicker");
|
||||
import moment = require('moment');
|
||||
import daterangepicker = require('daterangepicker');
|
||||
|
||||
function tests_simple() {
|
||||
$('#daterange').daterangepicker();
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
timePicker: true,
|
||||
timePickerIncrement: 30,
|
||||
locale: {
|
||||
format: 'MM/DD/YYYY h:mm A'
|
||||
}
|
||||
});
|
||||
$('input[name="daterange"]')
|
||||
.daterangepicker({
|
||||
timePicker: true,
|
||||
timePickerIncrement: 30,
|
||||
locale: {
|
||||
format: 'MM/DD/YYYY h:mm A'
|
||||
},
|
||||
maxSpan: { days: 10 },
|
||||
applyButtonClasses: 'my-apply-class',
|
||||
cancelButtonClasses: 'my-cancel-class',
|
||||
showDropdowns: true,
|
||||
maxYear: 3000,
|
||||
minYear: 2000
|
||||
})
|
||||
.data('daterangepicker')
|
||||
.remove();
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
Today: [moment(), moment()],
|
||||
Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
'Last Month': [
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.startOf('month'),
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month')
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
$('input[name="datefilter"]').on('apply.daterangepicker', function (ev, picker) {
|
||||
$(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
|
||||
$('input[name="datefilter"]').on('apply.daterangepicker', function(ev, picker) {
|
||||
$(this).val(
|
||||
`${picker.startDate.format('MM/DD/YYYY')} - ${picker.endDate.format('MM/DD/YYYY')}`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$('input[name="datefilter"]').on('cancel.daterangepicker', function (ev, picker) {
|
||||
$('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) {
|
||||
$(this).val('');
|
||||
});
|
||||
|
||||
$('#demo').daterangepicker({
|
||||
"startDate": "05/06/2016",
|
||||
"endDate": "05/12/2016"
|
||||
}, function (start: moment.Moment, end: moment.Moment, label: string) {
|
||||
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
|
||||
});
|
||||
|
||||
$(function() {
|
||||
|
||||
function cb(start: moment.Moment, end: moment.Moment) {
|
||||
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
||||
}
|
||||
cb(moment().subtract(29, 'days'), moment());
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
}
|
||||
}, cb);
|
||||
|
||||
$('#reportrange').daterangepicker({
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()]
|
||||
$('#demo').daterangepicker(
|
||||
{
|
||||
startDate: '05/06/2016',
|
||||
endDate: '05/12/2016'
|
||||
},
|
||||
showCustomRangeLabel: false
|
||||
}, cb);
|
||||
(start: moment.Moment, end: moment.Moment, label: string) => {
|
||||
console.log(
|
||||
"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$('#endDate').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
startDate: moment()
|
||||
$(() => {
|
||||
function cb(start: moment.Moment, end: moment.Moment) {
|
||||
$('#reportrange span').html(
|
||||
`${start.format('MMMM D, YYYY')} - ${end.format('MMMM D, YYYY')}`
|
||||
);
|
||||
}
|
||||
cb(moment().subtract(29, 'days'), moment());
|
||||
|
||||
$('#reportrange').daterangepicker(
|
||||
{
|
||||
ranges: {
|
||||
Today: [moment(), moment()],
|
||||
Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.startOf('month'),
|
||||
moment()
|
||||
.subtract(1, 'month')
|
||||
.endOf('month')
|
||||
]
|
||||
}
|
||||
},
|
||||
cb
|
||||
);
|
||||
|
||||
$('#reportrange').daterangepicker(
|
||||
{
|
||||
ranges: {
|
||||
Today: [moment(), moment()],
|
||||
Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()]
|
||||
},
|
||||
showCustomRangeLabel: false
|
||||
},
|
||||
cb
|
||||
);
|
||||
|
||||
$('#endDate').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
startDate: moment()
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
declare const host: HTMLElement;
|
||||
function test_from_amd() {
|
||||
var picker = new daterangepicker(host);
|
||||
console.log(picker.startDate.format("YYYY-MM-DD"));
|
||||
const picker = new daterangepicker(host);
|
||||
console.log(picker.startDate.format('YYYY-MM-DD'));
|
||||
}
|
||||
|
||||
Vendored
+71
-47
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Date Range Picker v2.1.30
|
||||
// Type definitions for Date Range Picker 3.0
|
||||
// Project: http://www.daterangepicker.com/
|
||||
// Definitions by: SirMartin <https://github.com/SirMartin>
|
||||
// Steven Masala <https://github.com/smasala>
|
||||
@@ -7,62 +7,81 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="jquery"/>
|
||||
import moment = require("moment");
|
||||
import moment = require('moment');
|
||||
|
||||
declare global {
|
||||
interface JQuery {
|
||||
daterangepicker(settings?: daterangepicker.Settings): JQuery;
|
||||
daterangepicker(settings?: daterangepicker.Settings, callback?: daterangepicker.DataRangePickerCallback): JQuery;
|
||||
daterangepicker: ((
|
||||
options?: daterangepicker.Options,
|
||||
callback?: daterangepicker.DataRangePickerCallback
|
||||
) => JQuery) & { defaultOptions?: daterangepicker.Options };
|
||||
data(key: 'daterangepicker'): daterangepicker | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
declare const daterangepicker: daterangepicker.DateRangePicker;
|
||||
declare class daterangepicker {
|
||||
constructor(
|
||||
element: HTMLElement,
|
||||
options?: daterangepicker.Options,
|
||||
callback?: daterangepicker.DataRangePickerCallback
|
||||
);
|
||||
|
||||
startDate: moment.Moment;
|
||||
endDate: moment.Moment;
|
||||
container: JQuery;
|
||||
|
||||
setStartDate(date: daterangepicker.DateOrString): void;
|
||||
setEndDate(date: daterangepicker.DateOrString): void;
|
||||
remove(): void;
|
||||
}
|
||||
|
||||
declare namespace daterangepicker {
|
||||
type DataRangePickerCallback = (start: moment.Moment, end: moment.Moment, label: string | null) => any;
|
||||
type DataRangePickerCallback = (
|
||||
start: moment.Moment,
|
||||
end: moment.Moment,
|
||||
label: string | null
|
||||
) => void;
|
||||
|
||||
interface DateRangePicker {
|
||||
new (element: HTMLElement, settings?: daterangepicker.Settings, callback?: DataRangePickerCallback): DateRangePicker;
|
||||
|
||||
startDate: moment.Moment;
|
||||
endDate: moment.Moment;
|
||||
container: JQuery;
|
||||
|
||||
setStartDate(date: Date | moment.Moment | string): void;
|
||||
setEndDate(date: Date | moment.Moment | string): void;
|
||||
remove(): void;
|
||||
}
|
||||
type DateOrString = string | moment.Moment | Date;
|
||||
|
||||
interface DatepickerEventObject extends JQueryEventObject {
|
||||
date: Date;
|
||||
format(format?: string): string;
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
interface Options {
|
||||
/**
|
||||
* The start of the initially selected date range
|
||||
*/
|
||||
startDate?: string | moment.Moment | Date;
|
||||
startDate?: DateOrString;
|
||||
/**
|
||||
* The end of the initially selected date range
|
||||
*/
|
||||
endDate?: string | moment.Moment | Date;
|
||||
endDate?: DateOrString;
|
||||
/**
|
||||
* The earliest date a user may select
|
||||
* The earliest date a user may select
|
||||
*/
|
||||
minDate?: string | moment.Moment | Date;
|
||||
minDate?: DateOrString;
|
||||
/**
|
||||
* The latest date a user may select
|
||||
*/
|
||||
maxDate?: string | moment.Moment | Date;
|
||||
maxDate?: DateOrString;
|
||||
/**
|
||||
* The maximum span between the selected start and end dates. Can have any property you can add to a moment object (i.e. days, months)
|
||||
*/
|
||||
dateLimit?: any;
|
||||
maxSpan?: moment.MomentInput | moment.Duration;
|
||||
/**
|
||||
* Show year and month select boxes above calendars to jump to a specific month and year
|
||||
*/
|
||||
showDropdowns?: boolean;
|
||||
/**
|
||||
* The minimum year shown in the dropdowns when `showDropdowns` is set to true.
|
||||
*/
|
||||
minYear?: number;
|
||||
/**
|
||||
* The maximum year shown in the dropdowns when `showDropdowns` is set to true.
|
||||
*/
|
||||
maxYear?: number;
|
||||
/**
|
||||
* Show localized week numbers at the start of each week on the calendars
|
||||
*/
|
||||
@@ -90,15 +109,25 @@ declare namespace daterangepicker {
|
||||
/**
|
||||
* Set predefined date ranges the user can select from.Each key is the label for the range, and its value an array with two dates representing the bounds of the range.
|
||||
*/
|
||||
ranges?: any;
|
||||
ranges?: { [name: string]: [DateOrString, DateOrString] };
|
||||
/**
|
||||
* (string: 'left'/'right'/'center') Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to
|
||||
* Whether to show the 'Custom Range' label or just pre-defined ranges
|
||||
*/
|
||||
opens?: string;
|
||||
showCustomRangeLabel?: boolean;
|
||||
/**
|
||||
* (string: 'down' or 'up') Whether the picker appears below (default) or above the HTML element it's attached to
|
||||
* Normally, if you use the `ranges` option to specify pre-defined date ranges, calendars
|
||||
* for choosing a custom date range are not shown until the user clicks "Custom Range".
|
||||
* When this option is set to true, the calendars for choosing a custom date range are always shown instead.
|
||||
*/
|
||||
drops?: string;
|
||||
alwaysShowCalendars?: boolean;
|
||||
/**
|
||||
* Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to
|
||||
*/
|
||||
opens?: 'left' | 'right' | 'center';
|
||||
/**
|
||||
* Whether the picker appears below (default) or above the HTML element it's attached to
|
||||
*/
|
||||
drops?: 'down' | 'up';
|
||||
/**
|
||||
* CSS class names that will be added to all buttons in the picker
|
||||
*/
|
||||
@@ -106,11 +135,11 @@ declare namespace daterangepicker {
|
||||
/**
|
||||
* CSS class string that will be added to the apply button
|
||||
*/
|
||||
applyClass?: string;
|
||||
applyButtonClasses?: string;
|
||||
/**
|
||||
* CSS class string that will be added to the cancel button
|
||||
*/
|
||||
cancelClass?: string;
|
||||
* CSS class string that will be added to the cancel button
|
||||
*/
|
||||
cancelButtonClasses?: string;
|
||||
/**
|
||||
* Allows you to provide localized strings for buttons and labels, customize the date display format, and change the first day of week for the calendars.
|
||||
*/
|
||||
@@ -124,33 +153,28 @@ declare namespace daterangepicker {
|
||||
*/
|
||||
autoApply?: boolean;
|
||||
/**
|
||||
* When enabled, the two calendars displayed will always be for two sequential months (i.e.January and February), and both will be advanced when clicking the left or right arrows above the calendars.When disabled, the two calendars can be individually advanced and display any month/ year.
|
||||
* When enabled, the two calendars displayed will always be for two sequential months (i.e.
|
||||
* January and February), and both will be advanced when clicking the left or right arrows
|
||||
* above the calendars.When disabled, the two calendars can be individually advanced and
|
||||
* display any month/ year.
|
||||
*/
|
||||
linkedCalendars?: boolean;
|
||||
/**
|
||||
* jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
|
||||
*/
|
||||
parentEl?: string;
|
||||
/**
|
||||
* A function that is passed each date in the two calendars before they are displayed, and may return true or false to indicate whether that date should be available for selection or not.
|
||||
*/
|
||||
isInvalidDate?(startDate: string | moment.Moment | Date, endDate?: string | moment.Moment | Date): boolean;
|
||||
isInvalidDate?(startDate: DateOrString, endDate?: DateOrString): boolean;
|
||||
/**
|
||||
* A function that is passed each date in the two calendars before they are displayed, and may return a string or array of CSS class names to apply to that date's calendar cell.
|
||||
*/
|
||||
isCustomDate?(date: string | moment.Moment | Date): string | string[] | undefined;
|
||||
isCustomDate?(date: DateOrString): string | string[] | undefined;
|
||||
/**
|
||||
* Indicates whether the date range picker should automatically update the value of an < input > element it's attached to at initialization and when the selected dates change.
|
||||
*/
|
||||
autoUpdateInput?: boolean;
|
||||
/**
|
||||
* Normally, if you use the ranges option to specify pre- defined date ranges, calendars for choosing a custom date range are not shown until the user clicks "Custom Range".When this option is set to true, the calendars for choosing a custom date range are always shown instead.
|
||||
*/
|
||||
alwaysShowCalendars?: boolean;
|
||||
/**
|
||||
* Whether to show the 'Custom Range' label or just pre-defined ranges
|
||||
*/
|
||||
showCustomRangeLabel?: boolean;
|
||||
* jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
|
||||
*/
|
||||
parentEl?: string;
|
||||
}
|
||||
|
||||
interface Locale {
|
||||
|
||||
@@ -1,79 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as dl from "deline";
|
||||
|
||||
const moduleName = "deline";
|
||||
|
||||
dl.deline(`deline`); // $ExpectType string
|
||||
dl.deline(`module name: ${moduleName}`); // $ExpectType string
|
||||
dl.deline`deline`; // $ExpectType string
|
||||
dl.deline`tagged template: ${moduleName}`; // $ExpectType string
|
||||
dl.deline`
|
||||
tagged template:
|
||||
|
||||
${moduleName}
|
||||
`;
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// Type definitions for deline 1.0
|
||||
// Project: https://github.com/airbnb/deline#readme
|
||||
// Definitions by: Inaki Arroyo <https://github.com/iarroyo5>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function deline(strings: string | TemplateStringsArray, ...values: any[]): string;
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ids-tests.ts"
|
||||
"deline-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for dom-to-image 2.6
|
||||
// Project: https://github.com/tsayen/dom-to-image
|
||||
// Definitions by: Jip Sterk <https://github.com/JipSterk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface DomToImage {
|
||||
toSvg(node: Node, options?: Options): Promise<string>;
|
||||
toPng(node: Node, options?: Options): Promise<string>;
|
||||
toJpeg(node: Node, options?: Options): Promise<string>;
|
||||
toBlob(node: Node, options?: Options): Promise<Blob>;
|
||||
toPixelData(node: Node, options?: Options): Promise<string>;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
filter?: (node: Node) => boolean;
|
||||
bgcolor?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
style?: {};
|
||||
quality?: number;
|
||||
imagePlaceholder?: string;
|
||||
cachebust?: boolean;
|
||||
}
|
||||
|
||||
export const DomToImage: DomToImage;
|
||||
|
||||
type DomToImage_ = DomToImage;
|
||||
type Options_ = Options;
|
||||
|
||||
export default DomToImage;
|
||||
|
||||
declare global {
|
||||
namespace DomToImage {
|
||||
type Options = Options_;
|
||||
type DomToImage = DomToImage_;
|
||||
}
|
||||
|
||||
const DomToImage: DomToImage.DomToImage;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
const node = new Node();
|
||||
|
||||
const options: DomToImage.Options = {
|
||||
filter,
|
||||
bgcolor: '#24292e',
|
||||
style: {
|
||||
width: '100px'
|
||||
},
|
||||
width: 100,
|
||||
height: 100,
|
||||
quality: 0.1,
|
||||
imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP',
|
||||
cachebust: true
|
||||
};
|
||||
|
||||
function filter(node: Node): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function testToSvg() {
|
||||
const svg = await DomToImage.toSvg(node, { filter });
|
||||
}
|
||||
|
||||
async function testToPng() {
|
||||
const png = await DomToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } });
|
||||
}
|
||||
|
||||
async function testToJpeg() {
|
||||
const jpeg = await DomToImage.toJpeg(node, { width: 100, height: 100 });
|
||||
}
|
||||
|
||||
async function testToBlob() {
|
||||
const blob = await DomToImage.toBlob(node, { quality: 0.1, });
|
||||
}
|
||||
|
||||
async function testToPixelData() {
|
||||
const pixelData = await DomToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true });
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import domToImage, { Options } from 'dom-to-image';
|
||||
|
||||
const node = new Node();
|
||||
|
||||
const options: Options = {
|
||||
filter,
|
||||
bgcolor: '#24292e',
|
||||
style: {
|
||||
width: '100px'
|
||||
},
|
||||
width: 100,
|
||||
height: 100,
|
||||
quality: 0.1,
|
||||
imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP',
|
||||
cachebust: true
|
||||
};
|
||||
|
||||
function filter(node: Node): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function testToSvg() {
|
||||
const svg = await domToImage.toSvg(node, { filter });
|
||||
}
|
||||
|
||||
async function testToPng() {
|
||||
const png = await domToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } });
|
||||
}
|
||||
|
||||
async function testToJpeg() {
|
||||
const jpeg = await domToImage.toJpeg(node, { width: 100, height: 100 });
|
||||
}
|
||||
|
||||
async function testToBlob() {
|
||||
const blob = await domToImage.toBlob(node, { quality: 0.1, });
|
||||
}
|
||||
|
||||
async function testToPixelData() {
|
||||
const pixelData = await domToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true });
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Options, DomToImage } from 'dom-to-image';
|
||||
|
||||
const node = new Node();
|
||||
|
||||
const options: Options = {
|
||||
filter,
|
||||
bgcolor: '#24292e',
|
||||
style: {
|
||||
width: '100px'
|
||||
},
|
||||
width: 100,
|
||||
height: 100,
|
||||
quality: 0.1,
|
||||
imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP',
|
||||
cachebust: true
|
||||
};
|
||||
|
||||
function filter(node: Node): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function testToSvg() {
|
||||
const svg = await DomToImage.toSvg(node, { filter });
|
||||
}
|
||||
|
||||
async function testToPng() {
|
||||
const png = await DomToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } });
|
||||
}
|
||||
|
||||
async function testToJpeg() {
|
||||
const jpeg = await DomToImage.toJpeg(node, { width: 100, height: 100 });
|
||||
}
|
||||
|
||||
async function testToBlob() {
|
||||
const blob = await DomToImage.toBlob(node, { quality: 0.1, });
|
||||
}
|
||||
|
||||
async function testToPixelData() {
|
||||
const pixelData = await DomToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true });
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/dom-to-image-module-tests.ts",
|
||||
"test/dom-to-image-global-tests.ts",
|
||||
"test/dom-to-image-import-default-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+3
@@ -610,6 +610,7 @@ declare namespace Draft {
|
||||
import DraftBlockType = Draft.Model.Constants.DraftBlockType;
|
||||
import DraftEntityMutability = Draft.Model.Constants.DraftEntityMutability;
|
||||
import DraftEntityType = Draft.Model.Constants.DraftEntityType;
|
||||
import DraftEntityInstance = Draft.Model.Entity.DraftEntityInstance;
|
||||
|
||||
import DraftDecoratorType = Draft.Model.Decorators.DraftDecoratorType;
|
||||
|
||||
@@ -754,6 +755,8 @@ declare namespace Draft {
|
||||
getEntity(key: string): EntityInstance;
|
||||
getLastCreatedEntityKey(): string;
|
||||
mergeEntityData(key: string, toMerge: { [key: string]: any }): ContentState;
|
||||
replaceEntityData(key: string, toMerge: { [key: string]: any }): ContentState;
|
||||
addEntity(instance: DraftEntityInstance): ContentState;
|
||||
|
||||
|
||||
getBlockMap(): BlockMap;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user