This commit is contained in:
PopGoesTheWza
2019-01-23 12:17:00 +01:00
751 changed files with 36182 additions and 6477 deletions
+1 -1
View File
@@ -5,5 +5,5 @@ indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
[{*.json,*.yml,*.ts}]
[{*.json,*.yml,*.ts,*.tsx,*.md}]
indent_style = space
+14 -6
View File
@@ -1,6 +1,4 @@
# DefinitelyTyped [![Build Status](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped.svg?branch=master)](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
[![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# DefinitelyTyped
> The repository for *high quality* TypeScript type definitions.
@@ -8,6 +6,19 @@ Also see the [definitelytyped.org](http://definitelytyped.org) website, although
*You can also read this README in [Spanish](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md), [Korean](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md), and [Russian](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ru.md)!*
## Current status
This section tracks the health of the repository and publishing process.
It may be helpful for contributors experiencing any issues with their PRs and packages.
* All packages are type-checking/linting cleanly: [![Build Status](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped.svg?branch=master)](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
* All packages are being published to npm in under 10,000 seconds: [![Publish Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13)
* [typescript-bot](https://github.com/typescript-bot) has been active on DefinitelyTyped [![Activity Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14)
If anything here seems wrong, or any of the above are failing, please raise an issue in [the DefinitelyTyped Gitter channel](https://gitter.im/DefinitelyTyped/DefinitelyTyped).
[![Join the chat at https://gitter.im/DefinitelyTyped/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/DefinitelyTyped/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## What are declaration files?
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
@@ -342,6 +353,3 @@ This project is licensed under the MIT license.
Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file.
[![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon)
[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.types-publisher-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average?
[![Build Status](https://typescript.visualstudio.com/TypeScript/_apis/build/status/sandersn.typescript-bot-watchdog)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours?
+5 -5
View File
@@ -8,7 +8,7 @@
Также посетите веб-сайт [definitelytyped.org](http://definitelytyped.org), хотя информация в этом README более свежая.
*Вы также можете прочитать этот README на [английском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md), [испанском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md) and [корейском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md).*
*Вы также можете прочитать этот README на [английском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md), [испанском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.es.md) и [корейском](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.ko.md).*
## Что такое файлы декларации (файлы описания/объявления типов)?
@@ -101,9 +101,9 @@ DefinitelyTyped работает только благодаря вкладу т
// John <https://github.com/john>
```
* Если есть `tslint.json`, запустите `npm run lint package-name`. В противном случае запустите `tsc` in в директории пакета.
* Если есть `tslint.json`, запустите `npm run lint package-name`. В противном случае запустите `tsc` в директории пакета.
Когда вы создаете PR для редактирования существующего пакета, `dt-bot` должен @-уведомить previous authors.
Когда вы создаете PR для редактирования существующего пакета, `dt-bot` должен @-уведомить
предыдущих авторов. Если этого не произойдет, вы можете сделать это самостоятельно в комментарии, связанном с PR.
@@ -124,7 +124,7 @@ DefinitelyTyped работает только благодаря вкладу т
| tsconfig.json | Позволяет вам запускать `tsc` внутри пакета. |
| tslint.json | Включает linting. |
Создайте их, запустив `npx dts-gen --dt --name my-package-name --template module` если у вас ≥ 5.2.0, `npm install -g dts-gen` и `dts-gen --dt --name my-package-name --template module` в противном случае.
Создайте их, запустив `npx dts-gen --dt --name my-package-name --template module` если у вас npm ≥ 5.2.0, `npm install -g dts-gen` и `dts-gen --dt --name my-package-name --template module` в противном случае.
Посмотреть все варианты на [dts-gen](https://github.com/Microsoft/dts-gen).
Вы можете отредактировать `tsconfig.json` чтобы добавить новые файлы, добавить `"target": "es6"` (необходимо для асинхронных функций), добавить в `"lib"`, или добавить опцию компилятора `"jsx"`.
@@ -283,7 +283,7 @@ f("one");
"typeRoots": ["../../"],
"paths": {
"history": [ "history/v2" ]
},
}
},
"files": [
"index.d.ts",
+6
View File
@@ -1068,6 +1068,12 @@
"sourceRepoURL": "https://github.com/paularmstrong/normalizr",
"asOfVersion": "2.0.18"
},
{
"libraryName": "Nuka Carousel",
"typingsPackageName": "nuka-carousel",
"sourceRepoURL": "https://github.com/FormidableLabs/nuka-carousel/",
"asOfVersion": "4.4.6"
},
{
"libraryName": "Numbro",
"typingsPackageName": "numbro",
+2
View File
@@ -14,6 +14,8 @@ accept.language("en;q=0.7, en-GB;q=0.8", ["en-gb"]); // language === "en-GB"
const languages = accept.languages("da, en;q=0.7, en-GB;q=0.8"); // languages === ["da", "en-GB", "en"]
languages.lastIndexOf('');
accept.mediaType("text/plain, application/json;q=0.5, text/html, */*;q=0.1");
accept.mediaType("text/plain, application/json;q=0.5, text/html, */*;q=0.1", ["application/json", "text/html"]);
const mediaTypes = accept.mediaTypes("text/plain, application/json;q=0.5, text/html, */*;q=0.1");
// mediaTypes === ["text/plain", "text/html", "application/json", "*/*"]
mediaTypes.lastIndexOf('');
+1
View File
@@ -10,6 +10,7 @@ export function encoding(encodingHeader?: string, preferences?: string[]): strin
export function encodings(encodingHeader?: string): string[];
export function language(languageHeader?: string, preferences?: string[]): string;
export function languages(languageHeader?: string): string[];
export function mediaType(mediaTypeHeader?: string, preferences?: string[]): string;
export function mediaTypes(mediaTypeHeader?: string): string[];
export function parseAll(
headers: Record<string, string | string[] | undefined>
@@ -0,0 +1,28 @@
import * as ActiveStorage from 'activestorage';
ActiveStorage.start();
const delegate: ActiveStorage.DirectUploadDelegate = {
directUploadWillCreateBlobWithXHR(xhr) {
console.log(xhr.status);
},
directUploadWillStoreFileWithXHR(xhr) {
console.log(xhr.status);
},
};
const d = new ActiveStorage.DirectUpload(
new File([], 'blank.txt'),
'/rails/active_storage/direct_uploads',
delegate
);
d.create((error, blob) => {
if (error) {
console.log(error.message);
} else {
const { byte_size, checksum, content_type, filename, signed_id } = blob;
console.log({ byte_size, checksum, content_type, filename, signed_id });
}
});
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for ActiveStorage 5.2
// Project: https://github.com/rails/rails/tree/master/activestorage/app/javascipt
// Definitions by: Cameron Bothner <https://github.com/cbothner>
// Definitions: https://github.com/cbothner/DefinitelyTyped
// TypeScript Version: 2.1
export as namespace ActiveStorage
export function start(): void;
export class DirectUpload {
id: number;
file: File;
url: string;
constructor(file: File, url: string, delegate: DirectUploadDelegate)
create(callback: (error: Error, blob: Blob) => void): void;
}
export interface DirectUploadDelegate {
directUploadWillCreateBlobWithXHR?: (xhr: XMLHttpRequest) => void;
directUploadWillStoreFileWithXHR?: (xhr: XMLHttpRequest) => void;
}
export interface Blob {
byte_size: number;
checksum: string;
content_type: string;
filename: string;
signed_id: string;
}
+16
View File
@@ -0,0 +1,16 @@
{
"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", "activestorage-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+40
View File
@@ -0,0 +1,40 @@
/*
| Copyright 2018 Esri
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
*/
import * as adlib from "adlib";
const transform1: adlib.TransformFunction =
(key: string, value: any, settings: any, param?: any): any => {
return null;
};
const transformsList: adlib.TransformsList = {
firstXform: transform1
};
const template = {
value: '{{ instance.color }}'
};
const settings = {
instance: {
color: 'red'
}
};
const interpolated = adlib.adlib(template, settings, transformsList);
const list: string[] = adlib.listDependencies(template);
+75
View File
@@ -0,0 +1,75 @@
// Type definitions for adlib 3.0
// Project: https://github.com/Esri/adlib
// Definitions by: Esri <https://github.com/Esri>
// Mike Tschudi <https://github.com/MikeTschudi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/*
| Copyright 2018 Esri
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
*/
/**
* Transform function to apply to interpolated value.
*
* @param key Path within a handlebar-style expression to attempt to replace; e.g., `s.animal.type` in
* https://github.com/Esri/adlib#transforms
* @param value Value to replace expression with
* @param settings Hash providing values to insert into template; see https://github.com/Esri/adlib#general-pattern
* @param param Parameter for transform function; e.g., the `optional` transform accepts a count of levels
* to delete if the value is not found (default is 0--just the current level);
* see https://github.com/Esri/adlib#optional-transform
*/
export interface TransformFunction {
(
key: string,
value: any,
settings: any,
param?: any
): any;
}
/**
* Set of transformation functions keyed by the transform function's name.
*/
export interface TransformsList {
[ transformFnName: string ]: TransformFunction;
}
/**
* A JavaScript library for interpolating property values in JSON Objects.
*
* @param template A template that possibly containing handlebar-style property values to replace;
* see https://github.com/Esri/adlib#general-pattern
* @param settings Hash providing values to insert into template; see https://github.com/Esri/adlib#general-pattern
* @param transforms Set of transformation functions
* @return Copy of template with replacements performed
*/
export function adlib(
template: any,
settings: any,
transforms?: TransformsList
): any;
/**
* Reads a template and spits out unique handlebar-style property values.
*
* @param template A template that possibly containing handlebar-style property values to replace;
* see https://github.com/Esri/adlib#general-pattern
* @return List of unique property values in template
*/
export function listDependencies(
template: any
): string [];
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"adlib-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+10
View File
@@ -0,0 +1,10 @@
import * as aesjs from 'aes-js';
const key = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
const data: Uint8Array = aesjs.utils.utf8.toBytes('hello world');
const ecb = new aesjs.ModeOfOperation.ecb(key);
ecb.decrypt(ecb.encrypt(data));
const hex: string = aesjs.utils.hex.fromBytes(data);
+134
View File
@@ -0,0 +1,134 @@
// Type definitions for aes-js 3.1
// Project: https://github.com/ricmoo/aes-js
// Definitions by: Federico Bond <https://github.com/federicobond>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type ByteSource = ArrayBuffer | Uint8Array | number[];
export class AES {
/**
* Create a new AES block cipher.
* @param key The cipher key.
*/
constructor(key: ByteSource)
encrypt(v: ByteSource): ByteSource;
}
/**
* Create a new Counter state for CTR cipher mode.
* @param initialValue The Counter initial value.
*/
export class Counter {
constructor(initialValue: number)
setValue(value: number): void;
setBytes(bytes: ByteSource): void;
increment(): void;
}
export namespace ModeOfOperation {
class ModeOfOperationECB {
/**
* Create a new ECB stream cipher.
* @param key The cipher key.
*/
constructor(key: ByteSource)
encrypt(v: ByteSource): Uint8Array;
decrypt(v: ByteSource): Uint8Array;
}
class ModeOfOperationCBC {
/**
* Create a new CBC stream cipher.
* @param key The cipher key.
* @param iv The cipher initialization vector.
*/
constructor(key: ByteSource, iv: ByteSource);
encrypt(v: ByteSource): Uint8Array;
decrypt(v: ByteSource): Uint8Array;
}
class ModeOfOperationCFB {
/**
* Create a new CFB stream cipher.
* @param key The cipher key.
* @param iv The cipher initialization vector.
* @param segmentSize The cipher segment size.
*/
constructor(key: ByteSource, iv: ByteSource, segmentSize: number);
encrypt(v: ByteSource): Uint8Array;
decrypt(v: ByteSource): Uint8Array;
}
class ModeOfOperationOFB {
/**
* Create a new OFB stream cipher.
* @param key The cipher key.
* @param iv The cipher initialization vector.
*/
constructor(key: ByteSource, iv: ByteSource);
encrypt(v: ByteSource): Uint8Array;
decrypt(v: ByteSource): Uint8Array;
}
class ModeOfOperationCTR {
/**
* Create a new CTR stream cipher.
* @param key The cipher key.
* @param counter The cipher counter state.
*/
constructor(key: ByteSource, counter?: Counter)
encrypt(v: ByteSource): Uint8Array;
decrypt(v: ByteSource): Uint8Array;
}
const ecb: typeof ModeOfOperationECB;
const cbc: typeof ModeOfOperationCBC;
const cfb: typeof ModeOfOperationCFB;
const ofb: typeof ModeOfOperationOFB;
const ctr: typeof ModeOfOperationCTR;
}
export namespace utils {
namespace utf8 {
/**
* Convert a UTF8 encoded string to a Uint8Array.
* @param data The input string.
*/
function toBytes(data: string): Uint8Array;
/**
* Convert an array-like object containing UTF8 data to a string.
* @param data The input data.
*/
function fromBytes(data: ByteSource): string;
}
namespace hex {
/**
* Convert a hexadecimal string to a Uint8Array.
* @param data The input string.
*/
function toBytes(data: string): Uint8Array;
/**
* Convert an array-like object to a hexadecimal string.
* @param data The input data.
*/
function fromBytes(data: ByteSource): string;
}
}
export namespace padding {
namespace pkcs7 {
/**
* Add standard PKCS7 padding to an array.
* @param data The input data.
*/
function pad(data: ByteSource): Uint8Array;
/**
* Remove standard PKCS7 padding from an array.
* @param data The input data.
*/
function strip(data: ByteSource): Uint8Array;
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"aes-js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -358,7 +358,7 @@ export interface Utils {
// Definitions
// used as mixins to register functions to create classes (newable functions) in A-Frame
export type ComponentDefinition<T extends object = object> = T & Partial<Component>;
export type ComponentDefinition<T extends object = object> = T & Partial<Component> & ThisType<T & Component>;
export type GeometryDefinition<T extends object = object, U = any> = T & Partial<Geometry<U>>;
export type NodeDefinition<T extends object = object> = T & Partial<ANode>;
export interface PrimitiveDefinition {
+19 -19
View File
@@ -30,7 +30,7 @@ AFRAME.registerComponent('set-image', {
init: function() {
var data = this.data;
var el = this.el!;
var el = this.el;
this.setupFadeAnimation();
@@ -133,14 +133,14 @@ AFRAME.registerComponent('arrow-key-rotation', {
if (!this.data.enabled) {
return;
}
var rotation = this.el!.getAttribute('rotation');
var rotation = this.el.getAttribute('rotation');
if (!rotation) {
return;
}
if (this.directionX || this.directionY) {
rotation.x += this.data.dx * this.directionY;
rotation.y += this.data.dy * this.directionX;
this.el!.setAttribute('rotation', rotation);
this.el.setAttribute('rotation', rotation);
}
}
});
@@ -164,10 +164,10 @@ AFRAME.registerComponent('hide-once-playing', {
}
},
onPlaying: function() {
this.el!.setAttribute('visible', false);
this.el.setAttribute('visible', false);
},
onPause: function() {
this.el!.setAttribute('visible', true);
this.el.setAttribute('visible', true);
}
});
@@ -178,10 +178,10 @@ AFRAME.registerComponent('play-on-vrdisplayactivate-or-enter-vr', {
},
play: function() {
window.addEventListener('vrdisplayactivate', this.playVideo);
this.el!.sceneEl!.addEventListener('enter-vr', this.playVideoNextTick);
this.el.sceneEl!.addEventListener('enter-vr', this.playVideoNextTick);
},
pause: function() {
this.el!.sceneEl!.removeEventListener('enter-vr', this.playVideoNextTick);
this.el.sceneEl!.removeEventListener('enter-vr', this.playVideoNextTick);
window.removeEventListener('vrdisplayactivate', this.playVideo);
},
playVideoNextTick: function() {
@@ -189,7 +189,7 @@ AFRAME.registerComponent('play-on-vrdisplayactivate-or-enter-vr', {
},
playVideo: function() {
// TODO improve type
var video = (this.el! as Entity<any>).components.material.material.map.image;
var video = (this.el as Entity<any>).components.material.material.map.image;
if (!video) {
return;
}
@@ -208,7 +208,7 @@ AFRAME.registerComponent('play-on-window-click', {
window.removeEventListener('click', this.onClick);
},
onClick: function() {
var video = (this.el! as Entity<any>).components.material.material.map.image;
var video = (this.el as Entity<any>).components.material.material.map.image;
if (!video) {
return;
}
@@ -227,7 +227,7 @@ AFRAME.registerComponent('toggle-play-on-window-click', {
window.removeEventListener('click', this.onClick);
},
onClick: function() {
var video = (this.el! as Entity<any>).components.material.material.map.image;
var video = (this.el as Entity<any>).components.material.material.map.image;
if (!video) {
return;
}
@@ -359,7 +359,7 @@ AFRAME.registerComponent('audioanalyser-levels-scale', {
return;
}
children = this.el!.children;
children = this.el.children;
for (var i = 0; i < children.length; i++) {
(children[i] as ANode).setAttribute('scale', {
x: 1,
@@ -382,7 +382,7 @@ AFRAME.registerComponent('audioanalyser-volume-bind', {
tick: function() {
var analyserComponent;
var data = this.data;
var el = this.el!;
var el = this.el;
var value;
analyserComponent = data.analyserEl.components.audioanalyser;
@@ -404,7 +404,7 @@ AFRAME.registerComponent('audioanalyser-volume-scale', {
tick: function() {
var analyserEl = this.data.analyserEl || this.el;
var analyserComponent;
var el = this.el!;
var el = this.el;
var volume;
analyserComponent = analyserEl.components.audioanalyser;
@@ -542,7 +542,7 @@ AFRAME.registerComponent('audioanalyser-waveform', {
},
remove: function() {
this.el!.removeObject3D('waveformContainer');
this.el.removeObject3D('waveformContainer');
}
});
@@ -874,7 +874,7 @@ AFRAME.registerComponent('color-on-beat', {
init: function() {
var analyserEl = this.data.analyserEl || this.el;
var el = this.el!;
var el = this.el;
analyserEl.addEventListener('audioanalyser-beat', function() {
el.setAttribute(
@@ -909,12 +909,12 @@ AFRAME.registerComponent('remove-on-event', {
removeEventListener: function() {
var data = this.data;
var el = this.el!;
var el = this.el;
el.removeEventListener(data.event, this._removeEntity);
},
_removeEntity: function() {
var el = this.el!;
var el = this.el;
if ((el as any).parentEl) {
(el as any).parentEl.removeChild(el);
}
@@ -1016,7 +1016,7 @@ function rgbToHex(r: number, g: number, b: number) {
AFRAME.registerComponent('random-material', {
init: function() {
this.el!.setAttribute('material', {
this.el.setAttribute('material', {
color: this.getRandomColor(),
metalness: Math.random(),
roughness: Math.random()
@@ -1034,7 +1034,7 @@ AFRAME.registerComponent('random-material', {
AFRAME.registerComponent('random-torus-knot', {
init: function() {
this.el!.setAttribute('geometry', {
this.el.setAttribute('geometry', {
primitive: 'torusKnot',
radius: Math.random() * 10,
radiusTubular: Math.random() * 0.75,
+1
View File
@@ -75,6 +75,7 @@ const Component = registerComponent('test-component', {
},
init() {
this.data.num = 0;
this.el.setAttribute('custom-attribute', 'custom-value');
},
update() {},
tick() {},
@@ -0,0 +1,206 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import * as AirbnbPropTypes from 'airbnb-prop-types';
class ClassComp extends React.Component {
render() {
return null;
}
}
function FuncComp() {
return null;
}
// $ExpectType Requireable<number | null>
AirbnbPropTypes.and([PropTypes.number]);
// $ExpectType Requireable<number | null>
AirbnbPropTypes.and([PropTypes.number, AirbnbPropTypes.nonNegativeInteger]);
// $ExpectType Validator<number>
AirbnbPropTypes.and([PropTypes.number, AirbnbPropTypes.integer()], 'foo').isRequired;
// $ExpectType Requireable<number>
AirbnbPropTypes.between({ lt: 1 });
// $ExpectType Requireable<number>
AirbnbPropTypes.between({ lte: 2 });
// $ExpectType Requireable<number>
AirbnbPropTypes.between({ gt: 3 });
// $ExpectType Requireable<number>
AirbnbPropTypes.between({ gte: 4 });
// $ExpectType Requireable<number>
AirbnbPropTypes.between({ lt: 1, gt: 0 });
// $ExpectType Requireable<boolean>
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenHavePropXorChildren('foo');
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenOf(PropTypes.string);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.componentWithName(/Foo/);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.componentWithName('Foo', { stripHOCs: ['connect'] });
// $ExpectType Requireable<number>
AirbnbPropTypes.disallowedIf(PropTypes.number, 'foo', PropTypes.string);
// $ExpectType Requireable<ReactElementLike>
AirbnbPropTypes.elementType(ClassComp);
// $ExpectType Requireable<ReactElementLike>
AirbnbPropTypes.elementType(FuncComp);
// $ExpectType Requireable<ReactElementLike>
AirbnbPropTypes.elementType('div');
// $ExpectType Requireable<ReactElementLike>
AirbnbPropTypes.elementType('*');
// $ExpectError
AirbnbPropTypes.elementType(ClassComp, FuncComp, 'div');
// $ExpectType Requireable<null | undefined>
AirbnbPropTypes.explicitNull();
// $ExpectType Validator<never>
AirbnbPropTypes.explicitNull().isRequired;
interface ForbidShape {
foo: string;
bar: number;
baz?: boolean | null;
}
// $ExpectType ValidationMap<{ foo: string | null; bar: number; baz: boolean | null; }>
AirbnbPropTypes.forbidExtraProps({
foo: PropTypes.string,
bar: PropTypes.number.isRequired,
baz: PropTypes.bool,
});
// $ExpectType ValidationMap<ForbidShape>
AirbnbPropTypes.forbidExtraProps<ForbidShape>({
foo: PropTypes.string.isRequired,
bar: PropTypes.number.isRequired,
baz: PropTypes.bool,
});
// $ExpectType Requireable<number>
AirbnbPropTypes.integer();
// $ExpectType Requireable<{}>
AirbnbPropTypes.keysOf(PropTypes.number);
// $ExpectType Requireable<{}>
AirbnbPropTypes.keysOf(PropTypes.number, 'foo');
// $ExpectType Requireable<{}>
AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar']));
// $ExpectType Requireable<number>
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.number);
// $ExpectType Requireable<number>
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.number, 'foo');
// $ExpectType Requireable<string>
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.string, 'foo', 'bar');
// $ExpectType Requireable<boolean>
AirbnbPropTypes.mutuallyExclusiveTrueProps('foo');
// $ExpectType Requireable<boolean>
AirbnbPropTypes.mutuallyExclusiveTrueProps('foo', 'bar');
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.nChildren(1, PropTypes.number);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.nChildren(1, AirbnbPropTypes.childrenOfType('span'));
// $ExpectType Requireable<number>
AirbnbPropTypes.nonNegativeInteger;
// $ExpectType Requireable<number>
AirbnbPropTypes.nonNegativeNumber();
// $ExpectType Requireable<string>
AirbnbPropTypes.numericString();
// $ExpectType Requireable<{}>
AirbnbPropTypes.object();
// $ExpectType Requireable<{ foo: string; }>
AirbnbPropTypes.object<{ foo: string }>();
AirbnbPropTypes.or([PropTypes.bool.isRequired, AirbnbPropTypes.explicitNull().isRequired]);
AirbnbPropTypes.or([PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.string)]);
AirbnbPropTypes.or([PropTypes.number, PropTypes.string, PropTypes.bool], 'foo');
// $ExpectType Requireable<number>
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);
// $ExpectType Requireable<string | null>
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator<number>
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;
// $ExpectType Requireable<{}>
AirbnbPropTypes.restrictedProp();
// $ExpectType Requireable<{}>
AirbnbPropTypes.restrictedProp(() => 'Error');
// $ExpectType Requireable<{}>
AirbnbPropTypes.restrictedProp(() => new Error('Error'));
// $ExpectType Requireable<{}>
AirbnbPropTypes.sequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable<{}>
AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string });
// $ExpectType Requireable<{}>
AirbnbPropTypes.sequenceOf(
{ validator: PropTypes.number, min: 0, max: 10 },
{ validator: PropTypes.string },
{ validator: PropTypes.bool },
);
interface ShapeShape {
foo: string;
bar?: number | null;
}
// $ExpectType Requireable<{ foo: string | null; }>
AirbnbPropTypes.shape({
foo: PropTypes.string,
});
// $ExpectType Requireable<{ foo: string | null; bar: number | null; }>
AirbnbPropTypes.shape({
foo: PropTypes.string,
bar: PropTypes.number,
});
// $ExpectType Requireable<ShapeShape>
AirbnbPropTypes.shape<ShapeShape>({
foo: PropTypes.string.isRequired,
bar: PropTypes.number,
});
// $ExpectType Requireable<string>
AirbnbPropTypes.stringStartsWith('foo');
// $ExpectType Requireable<any[]>
AirbnbPropTypes.uniqueArray();
// $ExpectType Requireable<string[]>
AirbnbPropTypes.uniqueArray<string>();
// $ExpectType Requireable<{ [key: string]: number | null; }>
AirbnbPropTypes.valuesOf(PropTypes.number);
+198
View File
@@ -0,0 +1,198 @@
// Type definitions for airbnb-prop-types 2.11
// Project: https://github.com/airbnb/prop-types
// Definitions by: Miles Johnson <https://github.com/milesj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import * as PropTypes from 'prop-types';
export interface ReactComponentLike {
setState(...args: any[]): any;
forceUpdate(...args: any[]): any;
render(): PropTypes.ReactNodeLike;
props: any;
state: any;
context: any;
refs: any;
}
export interface ReactClassComponentLike {
new (...args: any[]): ReactComponentLike;
}
export type ReactFunctionComponentLike = (...args: any[]) => PropTypes.ReactNodeLike;
export type ReactTypeLike = string | ReactClassComponentLike | ReactFunctionComponentLike;
export interface Specifier<T = any> {
max?: number;
min?: number;
validator: PropTypes.Validator<T>;
}
export function and<A>(
propTypes: [PropTypes.Validator<A>],
name?: string,
): PropTypes.Requireable<A>;
export function and<A, B>(
propTypes: [PropTypes.Validator<A>, PropTypes.Validator<B>],
name?: string,
): PropTypes.Requireable<A & B>;
export function and<A, B, C>(
propTypes: [PropTypes.Validator<A>, PropTypes.Validator<B>, PropTypes.Validator<C>],
name?: string,
): PropTypes.Requireable<A & B & C>;
export function and<T>(
propTypes: Array<PropTypes.Validator<any>>,
name?: string,
): PropTypes.Requireable<T>;
export function between(options: {
lt?: number;
lte?: number;
gt?: number;
gte?: number;
}): PropTypes.Requireable<number>;
export function booleanSome(...props: string[]): PropTypes.Requireable<boolean>;
export function childrenHavePropXorChildren<T = PropTypes.ReactNodeLike>(
prop: string | symbol,
): PropTypes.Requireable<T>;
export function childrenOf<T = PropTypes.ReactNodeLike, P = any>(
propType: PropTypes.Validator<P>,
): PropTypes.Requireable<T>;
export function childrenOfType<T = PropTypes.ReactNodeLike>(
...types: ReactTypeLike[]
): PropTypes.Requireable<T>;
export function childrenSequenceOf<T = PropTypes.ReactNodeLike>(
...specifiers: Specifier[]
): PropTypes.Requireable<T>;
export function componentWithName<T = PropTypes.ReactNodeLike>(
name: string | RegExp,
options?: { stripHOCs: ReadonlyArray<string> },
): PropTypes.Requireable<T>;
export function disallowedIf<T>(
propType: PropTypes.Requireable<T>,
otherPropName: string,
otherPropType: PropTypes.Validator<any>,
): PropTypes.Requireable<T>;
export function elementType<T = PropTypes.ReactElementLike>(
type: ReactTypeLike,
): PropTypes.Requireable<T>;
export function explicitNull(): PropTypes.Requireable<null | undefined>;
export function forbidExtraProps<T extends object>(
propTypes: PropTypes.ValidationMap<T>,
): PropTypes.ValidationMap<T>;
export function integer(): PropTypes.Requireable<number>;
export function keysOf<T, P>(
propType: PropTypes.Validator<P>,
name?: string,
): PropTypes.Requireable<T>;
export function mutuallyExclusiveProps<T>(
propType: PropTypes.Requireable<T>,
...propNames: string[]
): PropTypes.Requireable<T>;
export function mutuallyExclusiveProps<T>(
// tslint:disable-next-line:unified-signatures
propType: PropTypes.Validator<T>,
...propNames: string[]
): PropTypes.Requireable<T>;
export function mutuallyExclusiveTrueProps(...propNames: string[]): PropTypes.Requireable<boolean>;
export function nChildren<T = PropTypes.ReactNodeLike, P = any>(
n: number,
propType?: PropTypes.Validator<P>,
): PropTypes.Requireable<T>;
export const nonNegativeInteger: PropTypes.Requireable<number>;
export function nonNegativeNumber(): PropTypes.Requireable<number>;
export function numericString(): PropTypes.Requireable<string>;
export function object<T extends object>(): PropTypes.Requireable<T>;
export function or<A>(propTypes: [PropTypes.Validator<A>], name?: string): PropTypes.Requireable<A>;
export function or<A, B>(
propTypes: [PropTypes.Validator<A>, PropTypes.Validator<B>],
name?: string,
): PropTypes.Requireable<A | B>;
export function or<A, B, C>(
propTypes: [PropTypes.Validator<A>, PropTypes.Validator<B>, PropTypes.Validator<C>],
name?: string,
): PropTypes.Requireable<A | B | C>;
export function or<T>(
propTypes: Array<PropTypes.Validator<T>>,
name?: string,
): PropTypes.Requireable<T>;
export function or<T = any>(
// tslint:disable-next-line:unified-signatures
propTypes: Array<PropTypes.Validator<any>>,
name?: string,
): PropTypes.Requireable<T>;
export function range<T extends number>(min?: number, max?: number): PropTypes.Requireable<T>;
export function range(min?: number, max?: number): PropTypes.Requireable<number>;
export function requiredBy<P>(
requiredByPropName: string,
propType: PropTypes.Validator<P>,
defaultValue?: any,
): PropTypes.Requireable<P>;
export function restrictedProp<T>(
messageFunction?: (
props: object,
propName: string,
componentName: string,
location: string,
propFullName: string,
) => string | Error | undefined,
): PropTypes.Requireable<T>;
export function sequenceOf<T>(...specifiers: Specifier[]): PropTypes.Requireable<T>;
export function shape<T extends object>(
propTypes: PropTypes.ValidationMap<T>,
): PropTypes.Requireable<T>;
export function stringStartsWith(string: string): PropTypes.Requireable<string>;
export function uniqueArray<T = any>(): PropTypes.Requireable<T[]>;
export function uniqueArrayOf<T, P>(
propType: PropTypes.Validator<P>,
mapperOrName: ((value: any) => any) | string,
name?: string,
): PropTypes.Requireable<T[]>;
export function valuesOf<T>(
propType: PropTypes.Validator<T>,
): PropTypes.Requireable<{ [key: string]: T }>;
export function withShape<T extends object, P, S>(
propType: PropTypes.Validator<P>,
propTypes: PropTypes.ValidationMap<S>,
): PropTypes.Requireable<T>;
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "airbnb-prop-types-tests.ts"]
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-unnecessary-generics": false
}
}
+5
View File
@@ -0,0 +1,5 @@
import allKeys = require('all-keys');
allKeys(Symbol.prototype); // $ExpectType Set<string>
allKeys(Symbol.prototype, { includeObjectPrototype: false }); // $ExpectType Set<string>
allKeys(Symbol.prototype, { includeSymbols: false }); // $ExpectType Set<string>
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for all-keys 2.0
// Project: https://github.com/sindresorhus/all-keys#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export = allKeys;
/**
* Get all property keys of an object including non-enumerable and inherited ones.
* Like [Reflect.ownKeys()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
* but traverses up the prototype-chain.
*/
declare function allKeys(obj: object, options?: allKeys.Options): Set<string>;
declare namespace allKeys {
interface Options {
/**
* Include `Object.prototype` properties like `isPrototypeOf`.
* @default true
*/
includeObjectPrototype?: boolean;
/**
* Include [Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) keys.
* @default true
*/
includeSymbols?: boolean;
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"all-keys-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+22
View File
@@ -0,0 +1,22 @@
const aMap = new AMap.Map('id', {
resizeEnable: true,
animateEnable: true
});
aMap.setCenter(new AMap.LngLat(0, 0));
AMap.plugin(['someplugin'], () => {
console.log('plugin loaded');
});
AMap.convertFrom([116.3, 39.9], 'gps', (status, result) => {
if (result.info === 'ok') {
const _ = result.locations;
}
});
new AMap.Marker({
map: aMap,
title: '',
position: new AMap.LngLat(0, 0),
});
+1392
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"amap-js-sdk-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+30 -22
View File
@@ -1,10 +1,10 @@
import Analytics = require("analytics-node");
var analytics: Analytics;
let analytics: Analytics;
function testConfig(): void {
analytics = new Analytics('YOUR_WRITE_KEY', {
flushAt: 20,
flushAfter: 10000,
flushInterval: 10000,
host: "http://example.com",
enable: true
});
@@ -33,7 +33,7 @@ function testIdentify(): void {
if (err) {
console.error(err);
} else {
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`))
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`));
}
});
}
@@ -59,7 +59,7 @@ function testTrack(): void {
if (err) {
console.error(err);
} else {
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`))
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`));
}
});
}
@@ -91,20 +91,20 @@ function testPage(): void {
if (err) {
console.error(err);
} else {
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`))
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`));
}
});
}
function testAlias(): void {
// the anonymous user does actions ...
analytics.track({ userId: 'anonymous_user', event: 'Anonymous Event' })
analytics.track({ userId: 'anonymous_user', event: 'Anonymous Event' });
// the anonymous user signs up and is aliased
analytics.alias({ previousId: 'anonymous_user', userId: 'identified@gmail.com' })
analytics.alias({ previousId: 'anonymous_user', userId: 'identified@gmail.com' });
// the identified user is identified
analytics.identify({ userId: 'identified@gmail.com', traits: { plan: 'Free' } })
analytics.identify({ userId: 'identified@gmail.com', traits: { plan: 'Free' } });
// the identified user does actions ...
analytics.track({ userId: 'identified@gmail.com', event: 'Identified Action' })
analytics.track({ userId: 'identified@gmail.com', event: 'Identified Action' });
}
function testGroup(): void {
@@ -128,35 +128,41 @@ function testGroup(): void {
if (err) {
console.error(err);
} else {
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`))
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`));
}
});
}
function testIntegrations(): void {
analytics.track({
event: 'Upgraded Membershipt',
event: 'Upgraded Membership',
userId: '97234974',
integrations: {
'All': false,
'Vero': true,
'Google Analytics': false
All: false,
Vero: true,
'Google Analytics': false,
AppsFlyer: {
appsflyer_id: 'example-id'
}
}
});
analytics.track({
event: 'Upgraded Membershipt',
event: 'Upgraded Membership',
userId: '97234974',
integrations: {
'All': false,
'Vero': true,
'Google Analytics': false
All: false,
Vero: true,
'Google Analytics': false,
AppsFlyer: {
appsflyer_id: 'example-id'
}
}
}, (err, data) => {
if (err) {
console.error(err);
} else {
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`))
data.batch.forEach((message) => console.log(`${data.sentAt} : ${message}`));
}
});
}
@@ -164,8 +170,10 @@ function testIntegrations(): void {
function testFlush(): void {
analytics.flush();
analytics.flush((err, batch) => {
if (err) { alert("Oh nos!"); }
else { console.log(batch.batch[0].type); }
if (err) {
alert("Oh nos!");
} else {
console.log(batch.batch[0].type);
}
});
}
+16 -14
View File
@@ -1,4 +1,4 @@
// Type definitions for Segment's analytics.js for Node.js
// Type definitions for analytics-node 3.1
// Project: https://segment.com/docs/libraries/node/
// Definitions by: Andrew Fong <https://github.com/fongandrew>
// Thomas Thiebaud <https://github.com/thomasthiebaud>
@@ -19,7 +19,7 @@ declare namespace AnalyticsNode {
_metadata: {
nodeVersion: string;
[key: string]: any;
},
};
timestamp?: Date;
messageId?: string;
anonymousId?: string | number;
@@ -27,19 +27,21 @@ declare namespace AnalyticsNode {
}
interface Data {
batch: Message[],
batch: Message[];
timestamp: Date;
sentAt: Date;
}
interface Integrations {
[index: string]: boolean;
[integration_name: string]: IntegrationValue;
}
export class Analytics {
type IntegrationValue = boolean | { [integration_key: string]: any };
class Analytics {
constructor(writeKey: string, opts?: {
flushAt?: number,
flushAfter?: number,
flushInterval?: number,
host?: string,
enable?: boolean
});
@@ -49,9 +51,9 @@ declare namespace AnalyticsNode {
identify(message: {
userId?: string | number;
anonymousId?: string | number;
traits?: Object;
traits?: any;
timestamp?: Date;
context?: Object;
context?: any;
integrations?: Integrations;
}, callback?: (err: Error, data: Data) => void): Analytics;
@@ -60,9 +62,9 @@ declare namespace AnalyticsNode {
userId?: string | number;
anonymousId?: string | number;
event: string;
properties?: Object;
properties?: any;
timestamp?: Date;
context?: Object;
context?: any;
integrations?: Integrations;
}, callback?: (err: Error, data: Data) => void): Analytics;
@@ -73,9 +75,9 @@ declare namespace AnalyticsNode {
anonymousId?: string | number;
category?: string;
name?: string;
properties?: Object;
properties?: any;
timestamp?: Date;
context?: Object;
context?: any;
integrations?: Integrations;
}, callback?: (err: Error, data: Data) => void): Analytics;
@@ -93,8 +95,8 @@ declare namespace AnalyticsNode {
userId?: string | number;
anonymousId?: string | number;
groupId: string | number;
traits?: Object;
context?: Object;
traits?: any;
context?: any;
timestamp?: Date;
integrations?: Integrations;
}, callback?: (err: Error, data: Data) => void): Analytics;
+1 -79
View File
@@ -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" }
+1
View File
@@ -344,6 +344,7 @@ declare module 'angular' {
}
interface IMenuService {
close(): void;
hide(response?: any, options?: any): IPromise<any>;
open(event?: MouseEvent): void;
}
@@ -90,6 +90,7 @@ angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactorySe
responseError() {}
};
actionDescriptor.cancellable = true;
actionDescriptor.hasBody = true;
});
///////////////////////////////////////
+1
View File
@@ -88,6 +88,7 @@ declare module 'angular' {
withCredentials?: boolean;
responseType?: string;
interceptor?: IResourceInterceptor;
hasBody?: boolean;
}
// Allow specify more resource methods
+8
View File
@@ -0,0 +1,8 @@
import arrayMove = require('array-move');
const input = ['a', 'b', 'c'];
const input2 = [1, 2, 3];
arrayMove(input, 1, 2); // $ExpectType string[]
arrayMove(input2, 1, 2); // $ExpectType number[]
arrayMove.mut(input, 1, 2); // $ExpectType void
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for array-move 1.0
// Project: https://github.com/sindresorhus/array-move
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = arrayMove;
/**
* Move an array item to a different position.
*
* @param from Index of item to move. If negative, it will begin that many elements from the end.
* @param to Index of where to move the item. If negative, it will begin that many elements from the end.
* @returns A new array with the item moved to the new position.
*/
declare function arrayMove<T extends any[]>(input: T, from: number, to: number): T;
declare namespace arrayMove {
/**
* Moves the item to the new position in the input array.
*
* Useful for huge arrays where absolute performance is needed.
*
* @param from Index of item to move. If negative, it will begin that many elements from the end.
* @param to Index of where to move the item. If negative, it will begin that many elements from the end.
*/
function mut(input: any[], from: number, to: number): void;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"array-move-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+69 -34
View File
@@ -1,13 +1,18 @@
// Type definitions for Async 2.0.1
// Type definitions for Async 2.4
// Project: https://github.com/caolan/async
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn>, Angus Fenying <https://github.com/fenying>, Pascal Martin <https://github.com/pascalmartin>
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Arseniy Maximov <https://github.com/kern0>
// Joe Herman <https://github.com/Penryn>
// Angus Fenying <https://github.com/fenying>
// Pascal Martin <https://github.com/pascalmartin>
// Dmitri Trofimov <https://github.com/Dmitri1337>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export as namespace async;
export interface Dictionary<T> { [key: string]: T; }
export type IterableCollection<T> = T[] | IterableIterator<T> | Dictionary<T>
export type IterableCollection<T> = T[] | IterableIterator<T> | Dictionary<T>;
export interface ErrorCallback<E = Error> { (err?: E | null): void; }
export interface AsyncBooleanResultCallback<E = Error> { (err?: E | null, truthValue?: boolean): void; }
@@ -26,30 +31,40 @@ export interface AsyncBooleanIterator<T, E = Error> { (item: T, callback: AsyncB
export interface AsyncWorker<T, E = Error> { (task: T, callback: ErrorCallback<E>): void; }
export interface AsyncVoidFunction<E = Error> { (callback: ErrorCallback<E>): void; }
export type AsyncAutoTasks<R extends Dictionary<any>, E> = { [K in keyof R]: AsyncAutoTask<R[K], R, E> }
export type AsyncAutoTask<R1, R extends Dictionary<any>, E> = AsyncAutoTaskFunctionWithoutDependencies<R1, E> | (keyof R | AsyncAutoTaskFunction<R1, R, E>)[];
export type AsyncAutoTasks<R extends Dictionary<any>, E> = { [K in keyof R]: AsyncAutoTask<R[K], R, E> };
export type AsyncAutoTask<R1, R extends Dictionary<any>, E> = AsyncAutoTaskFunctionWithoutDependencies<R1, E> | Array<keyof R | AsyncAutoTaskFunction<R1, R, E>>;
export interface AsyncAutoTaskFunctionWithoutDependencies<R1, E = Error> { (cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E = Error> { (results: R, cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
export interface DataContainer<T> {
data: T;
}
export interface CallbackContainer {
callback: Function;
}
export interface PriorityContainer {
priority: number;
}
export interface AsyncQueue<T> {
length(): number;
started: boolean;
running(): number;
idle(): boolean;
concurrency: number;
push<R,E = Error>(task: T | T[], callback?: AsyncResultCallback<R, E>): void;
push<R, E = Error>(task: T | T[], callback?: AsyncResultCallback<R, E>): void;
unshift<E = Error>(task: T | T[], callback?: ErrorCallback<E>): void;
remove(filter: (node: DataContainer<T>) => boolean): void;
saturated: () => any;
empty: () => any;
drain: () => any;
paused: boolean;
pause(): void
pause(): void;
resume(): void;
kill(): void;
workersList(): {
data: T,
callback: Function
}[];
workersList<TWorker extends DataContainer<T>, CallbackContainer>(): TWorker[];
error(error: Error, data: any): void;
unsaturated(): void;
buffer: number;
@@ -60,7 +75,7 @@ export interface AsyncPriorityQueue<T> {
concurrency: number;
started: boolean;
paused: boolean;
push<R,E = Error>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
push<R, E = Error>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
saturated: () => any;
empty: () => any;
drain: () => any;
@@ -69,11 +84,7 @@ export interface AsyncPriorityQueue<T> {
pause(): void;
resume(): void;
kill(): void;
workersList(): {
data: T,
priority: number,
callback: Function
}[];
workersList<TWorker extends DataContainer<T>, CallbackContainer, PriorityContainer>(): TWorker[];
error(error: Error, data: any): void;
unsaturated(): void;
buffer: number;
@@ -82,7 +93,7 @@ export interface AsyncPriorityQueue<T> {
export interface AsyncCargo {
length(): number;
payload?: number;
push(task: any, callback? : Function): void;
push(task: any, callback?: Function): void;
saturated(): void;
empty(): void;
drain(): void;
@@ -105,11 +116,17 @@ export function forEachOfLimit<T, E = Error>(obj: IterableCollection<T>, limit:
export const eachOf: typeof forEachOf;
export const eachOfSeries: typeof forEachOf;
export const eachOfLimit: typeof forEachOfLimit;
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E = Error>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T> | Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export const mapSeries: typeof map;
export function mapLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function mapValuesLimit<T, R, E = Error>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export function mapValuesLimit<T, R, E = Error>(
obj: Dictionary<T>,
limit: number,
iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void,
callback: AsyncResultObjectCallback<R, E>
): void;
export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export const mapValuesSeries: typeof mapValues;
export function filter<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
@@ -151,7 +168,7 @@ export function concatLimit<T, R, E = Error>(arr: IterableCollection<T>, limit:
export const concatSeries: typeof concat;
// Control Flow
export function series<T, E = Error>(tasks: AsyncFunction<T, E>[], callback?: AsyncResultArrayCallback<T, E>): void;
export function series<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
export function series<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
export function parallel<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
export function parallel<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
@@ -161,9 +178,9 @@ export function whilst<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>,
export function doWhilst<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function until<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doUntil<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function during<E = Error>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function during<E = Error>(test: (testCallback: AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doDuring<E = Error>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
export function forever<E = Error>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
export function forever<E = Error>(next: (next: ErrorCallback<E>) => void, errBack: ErrorCallback<E>): void;
export function waterfall<T, E = Error>(tasks: Function[], callback?: AsyncResultCallback<T, E>): void;
export function compose(...fns: Function[]): Function;
export function seq(...fns: Function[]): Function;
@@ -172,34 +189,52 @@ export function applyEachSeries(fns: Function[], ...argsAndCallback: any[]): voi
export function queue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncQueue<T>;
export function queue<T, R, E = Error>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): AsyncQueue<T>;
export function priorityQueue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency: number): AsyncPriorityQueue<T>;
export function cargo<E = Error>(worker : (tasks: any[], callback : ErrorCallback<E>) => void, payload? : number) : AsyncCargo;
export function cargo<E = Error>(worker: (tasks: any[], callback: ErrorCallback<E>) => void, payload?: number): AsyncCargo;
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency?: number, callback?: AsyncResultCallback<R, E>): void;
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, callback?: AsyncResultCallback<R, E>): void;
export function autoInject<E = Error>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
export function retry<T, E = Error>(opts: number, task: (callback : AsyncResultCallback<T, E>, results: any) => void, callback: AsyncResultCallback<any, E>): void;
export function retry<T, E = Error>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T, E>, results : any) => void, callback: AsyncResultCallback<any, E>): void;
export function retry<T, E = Error>(
opts: number | {
times: number,
interval: number | ((retryCount: number) => number)
},
task: (callback: AsyncResultCallback<T, E>, results: any) => void,
callback: AsyncResultCallback<any, E>
): void;
export function retryable<T, E = Error>(opts: number | {times: number, interval: number}, task: AsyncFunction<T, E>): AsyncFunction<T, E>;
export function apply<E = Error>(fn: Function, ...args: any[]): AsyncFunction<any,E>;
export function apply<E = Error>(fn: Function, ...args: any[]): AsyncFunction<any, E>;
export function nextTick(callback: Function, ...args: any[]): void;
export const setImmediate: typeof nextTick;
export function reflect<T, E = Error>(fn: AsyncFunction<T, E>) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
export function reflectAll<T, E = Error>(tasks: AsyncFunction<T, E>[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[];
export function reflect<T, E = Error>(fn: AsyncFunction<T, E>): (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
export function reflectAll<T, E = Error>(tasks: Array<AsyncFunction<T, E>>): Array<(callback: (err: null, result: {error?: E, value?: T}) => void) => void>;
export function timeout<T, E = Error>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E>;
export function timeout<T, R, E = Error>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E>;
export function times<T, E> (n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function times<T, E>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function timesSeries<T, E = Error>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function timesLimit<T, E = Error>(n: number, limit: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
export function transform<T, R, E = Error>(
arr: {[key: string]: T},
iteratee: (acc: {[key: string]: R}, item: T, key: string, callback: (error?: E) => void) => void,
callback?: AsyncResultObjectCallback<T, E>
): void;
export function race<T, E = Error>(tasks: (AsyncFunction<T, E>)[], callback: AsyncResultCallback<T, E>) : void;
export function transform<T, R, E = Error>(
arr: {[key: string]: T},
acc: {[key: string]: R},
iteratee: (acc: {[key: string]: R}, item: T, key: string, callback: (error?: E) => void) => void,
callback?: AsyncResultObjectCallback<T, E>
): void;
export function race<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback: AsyncResultCallback<T, E>): void;
// Utils
export function memoize(fn: Function, hasher?: Function): Function;
+35 -35
View File
@@ -10,45 +10,45 @@ function eachOfIterator<T, K, E>(item: T, key: K, callback: (err: Error) => void
function concatIterator<T, R, E>(item: T, callback: (err: E, res: R[]) => void) { }
async.map(collectionGenerator(), funcMapIterator, funcMapComplete)
async.mapSeries(collectionGenerator(), funcMapIterator, funcMapComplete)
async.mapLimit(collectionGenerator(), 2, funcMapIterator, funcMapComplete)
async.map(collectionGenerator(), funcMapIterator, funcMapComplete);
async.mapSeries(collectionGenerator(), funcMapIterator, funcMapComplete);
async.mapLimit(collectionGenerator(), 2, funcMapIterator, funcMapComplete);
async.filter(collectionGenerator(), booleanIterator, function (err: Error, results: any[]) { })
async.filterSeries(collectionGenerator(), booleanIterator, function (err: Error, results: any[]) { })
async.filterLimit(collectionGenerator(), 2, booleanIterator, function (err: Error, results: any[]) { })
async.select(collectionGenerator(), booleanIterator, function (err: Error, results: any[]) { })
async.selectSeries(collectionGenerator(), booleanIterator, function (err: Error, results: any[]) { })
async.selectLimit(collectionGenerator(), 2, booleanIterator, function (err: Error, results: any[]) { })
async.filter(collectionGenerator(), booleanIterator, (err: Error, results: any[]) => { });
async.filterSeries(collectionGenerator(), booleanIterator, (err: Error, results: any[]) => { });
async.filterLimit(collectionGenerator(), 2, booleanIterator, (err: Error, results: any[]) => { });
async.select(collectionGenerator(), booleanIterator, (err: Error, results: any[]) => { });
async.selectSeries(collectionGenerator(), booleanIterator, (err: Error, results: any[]) => { });
async.selectLimit(collectionGenerator(), 2, booleanIterator, (err: Error, results: any[]) => { });
async.reject(collectionGenerator(), booleanIterator, function (err: Error, results: any[]) { })
async.rejectSeries(collectionGenerator(), booleanIterator, function (err: Error, results: any[]) { })
async.rejectLimit(collectionGenerator(), 2, booleanIterator, function (err: Error, results: any[]) { })
async.reject(collectionGenerator(), booleanIterator, (err: Error, results: any[]) => { });
async.rejectSeries(collectionGenerator(), booleanIterator, (err: Error, results: any[]) => { });
async.rejectLimit(collectionGenerator(), 2, booleanIterator, (err: Error, results: any[]) => { });
async.each(collectionGenerator(), eachIterator, function (err: Error) { })
async.eachLimit(collectionGenerator(), 2, eachIterator, function (err: Error) { })
async.eachSeries(collectionGenerator(), eachIterator, function (err: Error) { })
async.eachOf(collectionGenerator(), eachOfIterator, function (err: Error) { })
async.eachOfLimit(collectionGenerator(), 2, eachOfIterator, function (err: Error) { })
async.eachOfSeries(collectionGenerator(), eachOfIterator, function (err: Error) { })
async.forEach(collectionGenerator(), eachIterator, function (err: Error) { })
async.forEachLimit(collectionGenerator(), 2, eachIterator, function (err: Error) { })
async.forEachSeries(collectionGenerator(), eachIterator, function (err: Error) { })
async.forEachOf(collectionGenerator(), eachOfIterator, function (err: Error) { })
async.forEachOfLimit(collectionGenerator(), 2, eachOfIterator, function (err: Error) { })
async.forEachOfSeries(collectionGenerator(), eachOfIterator, function (err: Error) { })
async.each(collectionGenerator(), eachIterator, (err: Error) => { });
async.eachLimit(collectionGenerator(), 2, eachIterator, (err: Error) => { });
async.eachSeries(collectionGenerator(), eachIterator, (err: Error) => { });
async.eachOf(collectionGenerator(), eachOfIterator, (err: Error) => { });
async.eachOfLimit(collectionGenerator(), 2, eachOfIterator, (err: Error) => { });
async.eachOfSeries(collectionGenerator(), eachOfIterator, (err: Error) => { });
async.forEach(collectionGenerator(), eachIterator, (err: Error) => { });
async.forEachLimit(collectionGenerator(), 2, eachIterator, (err: Error) => { });
async.forEachSeries(collectionGenerator(), eachIterator, (err: Error) => { });
async.forEachOf(collectionGenerator(), eachOfIterator, (err: Error) => { });
async.forEachOfLimit(collectionGenerator(), 2, eachOfIterator, (err: Error) => { });
async.forEachOfSeries(collectionGenerator(), eachOfIterator, (err: Error) => { });
async.every(collectionGenerator(), booleanIterator, function (err: Error, res: boolean) { })
async.everyLimit(collectionGenerator(), 2, booleanIterator, function (err: Error, res: boolean) { })
async.everySeries(collectionGenerator(), booleanIterator, function (err: Error, res: boolean) { })
async.every(collectionGenerator(), booleanIterator, (err: Error, res: boolean) => { });
async.everyLimit(collectionGenerator(), 2, booleanIterator, (err: Error, res: boolean) => { });
async.everySeries(collectionGenerator(), booleanIterator, (err: Error, res: boolean) => { });
async.some(collectionGenerator(), booleanIterator, function (err: Error, res: boolean) { })
async.someLimit(collectionGenerator(), 2, booleanIterator, function (err: Error, res: boolean) { })
async.someSeries(collectionGenerator(), booleanIterator, function (err: Error, res: boolean) { })
async.some(collectionGenerator(), booleanIterator, (err: Error, res: boolean) => { });
async.someLimit(collectionGenerator(), 2, booleanIterator, (err: Error, res: boolean) => { });
async.someSeries(collectionGenerator(), booleanIterator, (err: Error, res: boolean) => { });
async.detect(collectionGenerator(), booleanIterator, function (err: Error, res: boolean) { })
async.detectLimit(collectionGenerator(), 2, booleanIterator, function (err: Error, res: boolean) { })
async.detectSeries(collectionGenerator(), booleanIterator, function (err: Error, res: boolean) { })
async.detect(collectionGenerator(), booleanIterator, (err: Error, res: boolean) => { });
async.detectLimit(collectionGenerator(), 2, booleanIterator, (err: Error, res: boolean) => { });
async.detectSeries(collectionGenerator(), booleanIterator, (err: Error, res: boolean) => { });
async.concat(collectionGenerator(), concatIterator, (err: Error, res: any[]) => { })
async.concatSeries(collectionGenerator(), concatIterator, (err: Error, res: any[]) => { })
async.concat(collectionGenerator(), concatIterator, (err: Error, res: any[]) => { });
async.concatSeries(collectionGenerator(), concatIterator, (err: Error, res: any[]) => { });
+39 -55
View File
@@ -1,74 +1,58 @@
interface StringCallback { (err?: Error, result?: string): void; }
interface AsyncStringGetter { (callback: StringCallback): void; }
var taskArray: AsyncStringGetter[] = [
function (callback) {
setTimeout(function () {
callback(undefined, 'one');
}, 200);
},
function (callback) {
setTimeout(function () {
callback(undefined, 'two');
}, 100);
},
const taskArray: AsyncStringGetter[] = [
callback => { setTimeout(() => { callback(undefined, 'one'); }, 200); },
callback => { setTimeout(() => { callback(undefined, 'two'); }, 100); }
];
async.series(taskArray, function (err, results) {
async.series(taskArray, (err, results) => {
if (results) {
let first = results[0];
const first = results[0];
if (first) {
console.log(first.match(/o/))
}
}
});
async.parallel(taskArray, function (err, results) {
if (results) {
let first = results[0];
if (first) {
console.log(first.match(/o/))
}
}
});
async.parallelLimit(taskArray, 3, function (err, results) {
if (results) {
let first = results[0];
if (first) {
console.log(first.match(/o/))
console.log(first.match(/o/));
}
}
});
async.parallel(taskArray, (err, results) => {
if (results) {
const first = results[0];
if (first) {
console.log(first.match(/o/));
}
}
});
async.parallelLimit(taskArray, 3, (err, results) => {
if (results) {
const first = results[0];
if (first) {
console.log(first.match(/o/));
}
}
});
interface Lookup<T> { [key: string]: T; }
interface NumberCallback { (err?: Error, result?: number): void; }
interface AsyncNumberGetter { (callback: NumberCallback): void; }
var taskDict: Lookup<AsyncNumberGetter> = {
one: function(callback) {
setTimeout(function() {
callback(undefined, 1);
}, 200);
},
two: function(callback) {
setTimeout(function() {
callback(undefined, 2);
}, 100);
}
}
const taskDict: Lookup<AsyncNumberGetter> = {
one: callback => { setTimeout(() => { callback(undefined, 1); }, 200); },
two: callback => { setTimeout(() => { callback(undefined, 2); }, 100); }
};
async.series(taskDict, function(err, results) {
let one = results['one'];
console.log(one && one.toFixed(1))
});
async.parallel(taskDict, function(err, results) {
let one = results['one'];
console.log(one && one.toFixed(1))
});
async.parallelLimit(taskDict, 3, function(err, results) {
let one = results['one'];
console.log(one && one.toFixed(1))
async.series(taskDict, (err, results) => {
const one = results['one'];
console.log(one && one.toFixed(1));
});
async.parallel(taskDict, (err, results) => {
const one = results['one'];
console.log(one && one.toFixed(1));
});
async.parallelLimit(taskDict, 3, (err, results) => {
const one = results['one'];
console.log(one && one.toFixed(1));
});
+392 -677
View File
File diff suppressed because it is too large Load Diff
+3 -29
View File
@@ -1,34 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODOs
"arrow-return-shorthand": false,
"array-type": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"max-line-length": false,
"no-consecutive-blank-lines": false,
"no-padding": false,
"no-unnecessary-generics": false,
"no-var-keyword": false,
"no-void-expression": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-const": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"trim-file": false,
"typedef-whitespace": false,
"unified-signatures": false,
"whitespace": false
"ban-types": true, // PRODUCES ERRORS WHEN REMOVED
"callable-types": false, // HAS ISSUES
"no-unnecessary-generics": false // HAS ISSUES
}
}
+2 -1
View File
@@ -130,7 +130,8 @@ const otherOptions : Auth0LockConstructorOptions = {
hashCleanup: false,
leeway: 30,
_enableImpersonation: true,
_enableIdPInitiatedLogin: false
_enableIdPInitiatedLogin: false,
defaultADUsernameFromEmailPrefix: false
};
new Auth0Lock(CLIENT_ID, DOMAIN, otherOptions);
+1 -1
View File
@@ -130,7 +130,7 @@ interface Auth0LockConstructorOptions {
closable?: boolean;
configurationBaseUrl?: string;
container?: string;
defaultADUsernameFromEmailPrefix?: string;
defaultADUsernameFromEmailPrefix?: boolean;
defaultDatabaseConnection?: string;
defaultEnterpriseConnection?: string;
flashMessage?: Auth0LockFlashMessageOptions;
+11 -1
View File
@@ -147,11 +147,21 @@ management
management
.updateUser({id: "user_id"}, {"email": "hi@me.co"}, (err: Error, users: auth0.User) => {});
// Update user metadata
management
.updateUserMetadata({id: "user_id"}, {"key": "value"});
// Update user metadata with JSON object
management
.updateUserMetadata({id: "user_id"}, {
key: "value",
numKey: 123,
objKey: {
foo: "bar",
another: "value"
}
});
// Update user metadata using callback
management
.updateUserMetadata({id: "user_id"}, {"key": "value"}, (err: Error, users: auth0.User) => {});
+6 -3
View File
@@ -1,6 +1,7 @@
// Type definitions for auth0 2.9.2
// Type definitions for auth0 2.9.3
// Project: https://github.com/auth0/node-auth0
// Definitions by: Seth Westphal <https://github.com/westy92>
// Ian Howe <https://github.com/ianhowe76>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -32,7 +33,7 @@ export interface RetryOptions {
}
export interface UserMetadata {
[propName: string]: string
[propName: string]: any
}
export interface AppMetadata {
@@ -46,7 +47,9 @@ export interface UserData {
verify_email?: boolean;
password?: string;
phone_number?: string;
phone_verified?: boolean,
phone_verified?: boolean;
given_name?: string;
family_name?: string;
user_metadata?: UserMetadata;
app_metadata?: AppMetadata;
}
@@ -74,6 +74,7 @@ paul.get('livesIn'); // === ourHouse
// You can control which relations get serialized to JSON, using the 'includeInJSON'
// property on a Relation. Also, each object will only get serialized once to prevent loops.
alert(JSON.stringify(paul.get('user').toJSON(), null, '\t'));
alert(JSON.stringify(paul.get('user').toJSON({ option1: 'value1' }), null, '\t'));
// Load occupants 'person-2' and 'person-5', which don't exist yet, from the server
ourHouse.fetchRelated('occupants');
+1 -1
View File
@@ -34,7 +34,7 @@ declare module 'backbone' {
fetchRelated(key:string, options?:any, update?:boolean):any;
toJSON():any;
toJSON(options?: any):any;
static setup();
+24
View File
@@ -0,0 +1,24 @@
import badgen from 'badgen';
// $ExpectType string
badgen({
subject: 'SUBJECT',
status: 'STATUS'
});
// $ExpectType string
badgen({
subject: 'SUBJECT',
status: 'STATUS',
color: 'green'
});
// $ExpectType string
badgen({
subject: 'SUBJECT',
status: 'STATUS',
color: '#FF0000',
style: 'flat',
icon: 'data:image/svg+xml;base64,...',
iconWidth: 20
});
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for badgen 2.6
// Project: https://github.com/amio/badgen
// Definitions by: m5d215 <https://github.com/m5d215>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
type ColorPresets =
| 'green'
| 'blue'
| 'red'
| 'yellow'
| 'orange'
| 'purple'
| 'pink'
| 'grey'
| 'gray'
| 'cyan'
| 'black';
interface BadgeCreationParams {
/**
* Text representing the subject.
*/
subject: string;
/**
* Text representing the status.
*/
status: string;
/**
* Color RGB or Color Name, optional.
*/
color?: ColorPresets | string;
/**
* 'flat' or undefined, optional.
*/
style?: 'flat';
/**
* Use icon, optional.
*/
icon?: string;
/**
* Use this if icon is not square.
* @default 13
*/
iconWidth?: number;
}
declare function badgen(params: BadgeCreationParams): string;
export = badgen;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"badgen-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
@@ -0,0 +1,6 @@
import { BdApi } from 'bandagedbd__bdapi';
BdApi.React; // $ExpectType typeof React
BdApi.ReactDOM.render; // $ExpectType Renderer
BdApi.alert('foo', 'bar'); // $ExpectType void
BdApi.showToast('hello', { timeout: 2000 }); // $ExpectType void
+176
View File
@@ -0,0 +1,176 @@
// Type definitions for bdapi 0.2
// Project: https://github.com/rauenzi/BetterDiscordApp
// Definitions by: Ari Seyhun <https://github.com/Acidic9>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// Documentation: https://github.com/rauenzi/BetterDiscordApp/wiki/Creating-Plugins#bdapi
import * as ReactInstance from 'react';
import * as ReactDOMInstance from 'react-dom';
export const BdApi: typeof BdApiModule;
/**
* Function with no arguments and no return value that may be called to revert changes made by monkeyPatch method,
* restoring (unpatching) original method.
*/
export type CancelPatch = () => void;
/**
* A callback that modifies method logic.
* This callback is called on each call of the original method and is provided all data about original call.
* Any of the data can be modified if necessary, but do so wisely.
*/
export type PatchFunction = (data: PatchData) => any;
/**
* A callback that modifies method logic.
* This callback is called on each call of the original method and is provided all data about original call.
* Any of the data can be modified if necessary, but do so wisely.
*/
export interface PatchData {
thisObject: object;
methodArguments: any[];
CancelPatch: CancelPatch;
originalMethod: () => void;
callOriginalMethod: () => void;
returnValue: any;
}
export interface MonkeyPatchOptions {
once?: boolean;
silent?: boolean;
displayName?: string;
before?: PatchFunction;
after?: PatchFunction;
instead?: PatchFunction;
}
export interface ToastOptions {
type?: string;
icon?: boolean;
timeout?: number;
}
export namespace BdApiModule {
/**
* The React module being used inside Discord.
*/
const React: typeof ReactInstance;
/**
* The ReactDOM module being used inside Discord.
*/
const ReactDOM: typeof ReactDOMInstance;
/**
* Creates an shows an alert modal to the user. A preview of how it may look can be found [here](https://i.zackrauen.com/7qnnNC.png).
*/
function alert(title: string, content: string): void;
/**
* Removes a style added with [`injectCSS`](#injectcssid-css) below.
*/
function clearCSS(id: string): void;
/**
* Deletes some saved data for plugin `pluginName` with key `key`.
*/
function deleteData(pluginName: string, key: string): void;
/**
* Searches for an internal Discord webpack module based on `filter`.
*/
function findModule(filter: () => void): any;
/**
* Searches for multiple internal Discord webpack module based on `filter`. It's the same as [`findModule`](#findmodulefilter) but will return all matches
*/
function findAllModules(filter: () => void): any[];
/**
* Searches for an internal Discord webpack module that has every property passed.
*/
function findModuleByProps(...props: string[]): any;
/**
* Returns BandagedBD's instance of the core module. Only use this if you know what you are doing.
*/
function getCore(): any; // TODO: This should not return 'any' but instead 'Core'
/**
* Alias for [loadData(pluginName, key)](#loaddatapluginname-key)
*/
function getData(pluginName: string, key: string): any;
/**
* Gets the internal react instance for a particular node.
*/
function getInternalInstance(node: HTMLElement): object|undefined;
/**
* Gets the instance of another plugin with the name `name`.
*/
function getPlugin(name: string): object|null;
/**
* Adds a block of css to the current document's `head`.
*/
function injectCSS(id: string, css: string): object|null;
/**
* Links some remote JavaScript to be added to the page. Useful for libraries like `Sortable.js`.
*/
function linkJS(id: string, url: string): void;
/**
* Gets some saved data for plugin `pluginName` with key `key`. Data can be saved with [`saveData`](#savedatapluginname-key-data).
*/
function loadData(pluginName: string, key: string): any;
/**
* This function monkey-patches a method on an object. The patching callback may be run before, after or instead of target method.
* - Be careful when monkey-patching. Think not only about original functionality of target method and your changes,
* but also about developers of other plugins, who may also patch this method before or after you.
* Try to change target method behaviour as little as possible, and avoid changing method signatures.
* - Display name of patched method is changed, so you can see if a function has been patched (and how many times) while debugging or in the stack trace.
* Also, patched methods have property `__monkeyPatched` set to `true`, in case you want to check something programmatically.
*/
function monkeyPatch(module: object, methodName: string, options: MonkeyPatchOptions): CancelPatch;
/**
* Adds a listener for when the node is removed from the document body.
*/
function onRemoved(node: HTMLElement, callback: () => void): void;
/**
* Saved some `data` for plugin `pluginName` under `key` key. Gets saved in the plugins folder under `pluginName.config.json`. Data can be saved with [`loadData`](#loaddatapluginname-key).
*/
function saveData(pluginName: string, key: string, data: any): void;
/**
* Alias for [saveData(pluginName, key, data)](#savedatapluginname-key-data)
*
*/
function setData(pluginName: string, key: string, data: any): void;
/**
* Shows a simple toast message similar to on Android. An example of the `success` toast can be seen [here](https://i.zackrauen.com/zIagVa.png).
*/
function showToast(content: string, options?: ToastOptions): void;
/**
* Wraps a function in a try catch block.
*/
function suppressErrors(method: () => void, message?: string): () => void;
/**
* Determines if the input is valid and parseable JSON.
*/
function testJSON(data: string): boolean;
/**
* Removes some previously linked JS by [`linkJS`](#linkjsid-url).
*/
function unlinkJS(id: string): void;
}
@@ -20,6 +20,6 @@
},
"files": [
"index.d.ts",
"nuka-carousel-tests.tsx"
"bandagedbd__bdapi-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+7
View File
@@ -0,0 +1,7 @@
import beeper = require('beeper');
beeper();
beeper(3);
beeper(3, () => {});
beeper('****-*-*');
beeper('****-*-*', () => {});
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for beeper 1.1
// Project: https://github.com/sindresorhus/beeper#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = beeper;
declare function beeper(count?: number, cb?: () => void): void;
declare function beeper(melody: string, cb?: () => void): void;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"beeper-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -16,7 +16,7 @@ async function run() {
clientSecret: '',
scope(request) {
const scopes = ['public_profile', 'email'];
if ((request.query as RequestQuery).wantsSharePermission) {
if (request.query.wantsSharePermission) {
scopes.push('publish_actions');
}
return scopes;
+1
View File
@@ -17,6 +17,7 @@ export class BIP32 {
identifier: Buffer;
fingerprint: Buffer;
chainCode: Buffer;
privateKey: Buffer;
publicKey: Buffer;
+8
View File
@@ -8,3 +8,11 @@ bn.byteLength;
bn.toArrayLike(Buffer, 'le', 2);
const test = new BN(1, 'le');
const ctx = BN.red('p224');
ctx.prime.name;
const red = bn.toRed(ctx);
const newRed = red.redAdd(new BN(1));
newRed.cmp(bn);
newRed.fromRed();
+88 -31
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/indutny/bn.js
// Definitions by: Leonid Logvinov <https://github.com/LogvinovLeon>
// Henry Nguyen <https://github.com/HenryNguyen5>
// Gaylor Bosson <https://github.com/Gilthoniel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
@@ -9,36 +10,16 @@
type Endianness = 'le' | 'be';
type IPrimeName = 'k256' | 'p224' | 'p192' | 'p25519';
declare class RedBN {
redAdd(b: RedBN): RedBN;
redIAdd(b: RedBN): RedBN;
redSub(b: RedBN): RedBN;
redISub(b: RedBN): RedBN;
redShl(num: number): RedBN;
redMul(b: RedBN): RedBN;
redIMul(b: RedBN): RedBN;
redSqr(): RedBN;
redISqr(): RedBN;
/**
* @description square root modulo reduction context's prime
*/
redSqrt(): RedBN;
/**
* @description modular inverse of the number
*/
redInvm(): RedBN;
redNeg(): RedBN;
/**
* @description modular exponentiation
*/
redPow(b: RedBN): RedBN;
fromRed(): BN;
interface MPrime {
name: string;
p: BN;
n: number;
k: BN;
}
// FIXME: not sure how to specify the reduction context here
interface ReductionContext {
m: number;
prime: any;
prime: MPrime;
[key: string]: any;
}
@@ -78,11 +59,6 @@ declare class BN {
*/
static min(left: BN, right: BN): BN;
/**
* @description Convert number to red
*/
toRed(reductionContext: ReductionContext): RedBN;
/**
* @description clone number
*/
@@ -522,6 +498,87 @@ declare class BN {
* @description inverse `a` modulo `b`
*/
invm(b: BN): BN;
/**
* @description Convert number to red
*/
toRed(reductionContext: ReductionContext): RedBN;
}
/**
* Big-Number class with additionnal methods that are using modular
* operation.
*/
declare class RedBN extends BN {
/**
* @description Convert back a number using a reduction context
*/
fromRed(): BN;
/**
* @description modular addition
*/
redAdd(b: BN): RedBN;
/**
* @description in-place modular addition
*/
redIAdd(b: BN): RedBN;
/**
* @description modular subtraction
*/
redSub(b: BN): RedBN;
/**
* @description in-place modular subtraction
*/
redISub(b: BN): RedBN;
/**
* @description modular shift left
*/
redShl(num: number): RedBN;
/**
* @description modular multiplication
*/
redMul(b: BN): RedBN;
/**
* @description in-place modular multiplication
*/
redIMul(b: BN): RedBN;
/**
* @description modular square
*/
redSqr(): RedBN;
/**
* @description in-place modular square
*/
redISqr(): RedBN;
/**
* @description modular square root
*/
redSqrt(): RedBN;
/**
* @description modular inverse of the number
*/
redInvm(): RedBN;
/**
* @description modular negation
*/
redNeg(): RedBN;
/**
* @description modular exponentiation
*/
redPow(b: BN): RedBN;
}
export = BN;
@@ -0,0 +1,30 @@
import {
matchesUA,
resolveUserAgent,
normalizeQuery
} from 'browserslist-useragent';
// $ExpectType boolean
matchesUA(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
);
// $ExpectType boolean
matchesUA(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
{
browsers: ['defaults'],
env: 'production',
ignorePath: true,
ignoreMinor: false,
allowHigherVersions: false
}
);
// $ExpectType ResolvedUserAgent
resolveUserAgent(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
);
// $ExpectType string
normalizeQuery('defaults');
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for browserslist-useragent 3.0
// Project: https://github.com/browserslist/browserslist-useragent (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
// Definitions by: nju33 <https://github.com/nju33>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ResolvedUserAgent {
family: string;
version: string;
}
export interface BrowserslistUseragentOptions {
browsers?: string[];
env?: string;
ignorePath?: boolean;
ignoreMinor?: boolean;
allowHigherVersions?: boolean;
}
export function matchesUA(
uaString: string,
opts?: BrowserslistUseragentOptions
): boolean;
export function resolveUserAgent(uaString: string): ResolvedUserAgent;
export function normalizeQuery(query: string): string;
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": ["index.d.ts", "browserslist-useragent-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+31
View File
@@ -36,6 +36,8 @@ declare namespace Bull {
max: number;
/** Per duration in milliseconds */
duration: number;
/** When jobs get rate limited, they stay in the waiting queue and are not moved to the delayed queue */
bounceBack?: boolean;
}
interface QueueOptions {
@@ -68,6 +70,11 @@ declare namespace Bull {
*/
lockDuration?: number;
/**
* Interval in milliseconds on which to acquire the job lock.
*/
lockRenewTime?: number;
/**
* How often check for stalled jobs (use 0 for never checking)
*/
@@ -129,6 +136,25 @@ declare namespace Bull {
*/
finishedOn?: number;
/**
* Which queue this job was part of
*/
queue: Queue<T>;
timestamp: number;
/**
* The named processor name
*/
name: string;
/**
* The stacktrace for any errors
*/
stacktrace: string[];
returnvalue: any;
/**
* Report progress on a job
*/
@@ -340,6 +366,11 @@ declare namespace Bull {
}
interface Queue<T = any> {
/**
* The name of the queue
*/
name: string;
/**
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs.
* This replaces the `ready` event emitted on Queue in previous verisons.
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for cadesplugin 2.1
// Project: https://www.npmjs.com/package/cadesplugin
// Definitions by: Delagen <https://github.com/Delagen>,
// kvmi <https://github.com/kmvi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
declare const cadesplugin: any;
+7
View File
@@ -0,0 +1,7 @@
{
"private": true,
"types": "index",
"typesVersions": {
">=3.1.0-0": { "*": ["ts3.1/*"] }
}
}
+97
View File
@@ -0,0 +1,97 @@
declare namespace CAdESCOM {
interface CPSigner {
Certificate: CAPICOM.Certificate;
CheckCertificate: boolean;
KeyPin: string;
Options: CADES_Common.ValuesOf<CAPICOM.CAPICOM_CERTIFICATE_INCLUDE_OPTION>;
readonly SignatureTimeStampTime: CADES_Common.VarDate;
readonly SigningTime: CADES_Common.VarDate;
TSAAddress: string;
Display(hwndParent?: number, title?: string): void;
Load(fileName: string, password?: string): void;
}
interface CadesSignedData {
readonly Certificates: CAPICOM.Certificates;
Content: string;
ContentEncoding: CADES_Common.ValuesOf<CADESCOM_CONTENT_ENCODING_TYPE>;
DisplayData: CADES_Common.ValuesOf<CADESCOM_DISPLAY_DATA>;
Display(hwndParent?: number, title?: string): void;
EnhanceCades(cadesType?: CADES_Common.ValuesOf<CADESCOM_CADES_TYPE>, TSAAddress?: string, encodingType?: CADES_Common.ValuesOf<CAPICOM.CAPICOM_ENCODING_TYPE>): string;
SignCades(signer?: CPSigner, CadesType?: CADES_Common.ValuesOf<CADESCOM_CADES_TYPE>, bDetached?: boolean, EncodingType?: CADES_Common.ValuesOf<CAPICOM.CAPICOM_ENCODING_TYPE>): string;
VerifyCades(SignedMessage: string, CadesType?: CADES_Common.ValuesOf<CADESCOM_CADES_TYPE>, bDetached?: boolean): void;
}
interface Version {
readonly BuildVersion: number;
readonly MajorVersion: number;
readonly MinorVersion: number;
readonly toStringDefault: string;
toString(): string;
}
interface About {
readonly BuildVersion: number;
readonly MajorVersion: number;
readonly MinorVersion: number;
readonly PluginVersion: Version;
readonly Version: string;
CSPName(ProviderType?: number): string;
CSPVersion(ProviderName?: string, ProviderType?: number): Version;
ProviderVersion(ProviderName?: string, ProviderType?: number): string;
toString(): string;
}
interface CPSigners {
readonly Count: number;
Item(index: number): CPSigner;
}
interface SignedXML {
Content: string;
DigestMethod: string;
SignatureMethod: string;
SignatureType: CADES_Common.ValuesOf<CADESCOM_XML_SIGNATURE_TYPE>;
readonly Signers: CAPICOM.Signers;
Sign(signer?: CPSigner, XPath?: string): string;
Verify(SignedMessage: string, XPath?: string): void;
}
interface CPHashedData {
Algorithm: CADES_Common.ValuesOf<CAPICOM.CAPICOM_HASH_ALGORITHM>;
DataEncoding: CADES_Common.ValuesOf<CADESCOM_CONTENT_ENCODING_TYPE>;
Value: string;
Hash(newVal: string): void;
SetHashValue(newVal: string): void;
}
interface CPAttribute {
Name: CADES_Common.ValuesOf<CADESCOM_ATTRIBUTE>;
Value: any;
ValueEncoding: CADES_Common.ValuesOf<CAPICOM.CAPICOM_ENCODING_TYPE>;
}
interface RawSignature {
SignHash(hash: CPHashedData, certificate?: string): string;
VerifyHash(hash: CPHashedData, certificate: CAPICOM.Certificate, signature: string): void;
}
}
+57
View File
@@ -0,0 +1,57 @@
declare namespace CAdESCOM {
interface CPSignerAsync extends CADES_Common.Async<CPSigner> {
propset_Certificate(certificate: CAPICOM.CertificateAsync): Promise<void>;
propset_CheckCertificate(checkCertificate: boolean): Promise<void>;
propset_KeyPin(keyPin: string): Promise<void>;
propset_Options(options: CADES_Common.ValuesOf<CAPICOM.CAPICOM_CERTIFICATE_INCLUDE_OPTION>): Promise<void>;
propset_TSAAddress(TSAAddress: string): Promise<void>;
}
interface CadesSignedDataAsync extends CADES_Common.Async<CadesSignedData> {
propset_DisplayData(displayData: CADES_Common.ValuesOf<CADESCOM_DISPLAY_DATA>): Promise<void>;
propset_Content(content: string): Promise<void>;
propset_ContentEncoding(contentEncoding: CADES_Common.ValuesOf<CADESCOM_CONTENT_ENCODING_TYPE>): Promise<void>;
}
interface VersionAsync extends CADES_Common.Async<Version> {
}
interface AboutAsync extends CADES_Common.Async<About> {
}
interface CPSignersAsync extends CADES_Common.Async<CPSigners> {
}
interface SignedXMLAsync extends CADES_Common.Async<SignedXML> {
propset_Content(content: string): Promise<void>;
propset_DigestMethod(digestMethod: string): Promise<void>;
propset_SignatureMethod(signatureMethod: string): Promise<void>;
propset_SignatureType(signatureType: CADES_Common.ValuesOf<CADESCOM_XML_SIGNATURE_TYPE>): Promise<void>;
}
interface CPHashedDataAsync extends CADES_Common.Async<CPHashedData> {
propset_Algorithm(algorithm: CADES_Common.ValuesOf<CAPICOM.CAPICOM_HASH_ALGORITHM>): Promise<void>;
propset_DataEncoding(dataEncoding: CADES_Common.ValuesOf<CADESCOM_CONTENT_ENCODING_TYPE>): Promise<void>;
}
interface CPAttributeAsync extends CADES_Common.Async<CPAttribute> {
propset_Name(name: CADES_Common.ValuesOf<CADESCOM_ATTRIBUTE>): Promise<void>;
propset_Value(value: any): Promise<void>;
propset_ValueEncoding(valueEncoding: CADES_Common.ValuesOf<CAPICOM.CAPICOM_ENCODING_TYPE>): Promise<void>;
}
interface RawSignatureAsync extends CADES_Common.Async<RawSignature> {
}
}
+74
View File
@@ -0,0 +1,74 @@
declare namespace CAdESCOM {
interface StoreLocationPlugin {
readonly CADESCOM_LOCAL_MACHINE_STORE: 1;
readonly CADESCOM_CURRENT_USER_STORE: 2;
readonly CADESCOM_CONTAINER_STORE: 100;
}
interface CADESCOM_STORE_LOCATION extends StoreLocationPlugin {
readonly CADESCOM_MEMORY_STORE: 0;
readonly CADESCOM_ACTIVE_DIRECTORY_USER_STORE: 3;
readonly CADESCOM_SMART_CARD_USER_STORE: 4;
}
interface CADESCOM_CADES_TYPE {
readonly CADESCOM_CADES_BES: 1;
readonly CADESCOM_CADES_DEFAULT: 0;
readonly CADESCOM_CADES_T: 5;
readonly CADESCOM_CADES_X_LONG_TYPE_1: 93;
}
interface CADESCOM_CONTENT_ENCODING_TYPE {
readonly CADESCOM_BASE64_TO_BINARY: 1;
readonly CADESCOM_STRING_TO_UCS2LE: 0;
}
interface CADESCOM_XML_SIGNATURE_TYPE {
readonly CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED: 0;
readonly CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING: 1;
readonly CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE: 2;
}
interface CADESCOM_ENCRYPTION_ALGORITHM {
readonly CADESCOM_ENCRYPTION_ALGORITHM_RC2: 0;
readonly CADESCOM_ENCRYPTION_ALGORITHM_RC4: 1;
readonly CADESCOM_ENCRYPTION_ALGORITHM_DES: 2;
readonly CADESCOM_ENCRYPTION_ALGORITHM_3DES: 3;
readonly CADESCOM_ENCRYPTION_ALGORITHM_AES: 4;
readonly CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89: 25;
}
interface CADESCOM_HASH_ALGORITHM {
readonly CADESCOM_HASH_ALGORITHM_SHA1: 0;
readonly CADESCOM_HASH_ALGORITHM_MD2: 1;
readonly CADESCOM_HASH_ALGORITHM_MD4: 2;
readonly CADESCOM_HASH_ALGORITHM_MD5: 3;
readonly CADESCOM_HASH_ALGORITHM_SHA_256: 4;
readonly CADESCOM_HASH_ALGORITHM_SHA_384: 5;
readonly CADESCOM_HASH_ALGORITHM_SHA_512: 6;
readonly CADESCOM_HASH_ALGORITHM_CP_GOST_3411: 100;
readonly CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256: 101;
readonly CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512: 102;
}
interface CADESCOM_ATTRIBUTE {
readonly CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME: 0;
readonly CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME: 1;
readonly CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION: 2;
readonly CADESCOM_ATTRIBUTE_OTHER: -1;
}
interface CADESCOM_DISPLAY_DATA {
readonly CADESCOM_DISPLAY_DATA_NONE: 0;
readonly CADESCOM_DISPLAY_DATA_CONTENT: 1;
readonly CADESCOM_DISPLAY_DATA_ATTRIBUTE: 2;
}
interface CADESCOM_InstallResponseRestrictionFlags {
readonly CADESCOM_AllowNone: 0;
readonly CADESCOM_AllowNoOutstandingRequest: 1;
readonly CADESCOM_AllowUntrustedCertificate: 2;
readonly CADESCOM_AllowUntrustedRoot: 4;
readonly CADESCOM_SkipInstallToStore: 0x10000000;
}
}
@@ -0,0 +1,12 @@
cadesplugin.then(async () => {
if ("CreateObjectAsync" in cadesplugin) {
const pluginAsync: CADESPluginAsync = cadesplugin;
const oAbout = await pluginAsync.CreateObjectAsync("CAdESCOM.About");
const oVersion = await oAbout.CSPVersion();
await oVersion.toString();
}
if ("CreateObject" in cadesplugin) {
const pluginSync: CADESPluginSync = cadesplugin;
pluginSync.CreateObject("CAdESCOM.About").CSPVersion().toString();
}
});
+80
View File
@@ -0,0 +1,80 @@
declare namespace CADES_Plugin {
interface ObjectNames {
"CAPICOM.Store": CAPICOM.Store;
"CAdESCOM.CPSigner": CAdESCOM.CPSigner;
"CAdESCOM.About": CAdESCOM.About;
"CAdESCOM.SignedXML": CAdESCOM.SignedXML;
"CAdESCOM.HashedData": CAdESCOM.CPHashedData;
"CAdESCOM.CadesSignedData": CAdESCOM.CadesSignedData;
"CAdESCOM.CPAttribute": CAdESCOM.CPAttribute;
"CAdESCOM.RawSignature": CAdESCOM.RawSignature;
}
interface ObjectNamesAsync {
"CAdESCOM.Store": CAPICOM.StoreAsync;
"CAdESCOM.CPSigner": CAdESCOM.CPSignerAsync;
"CAdESCOM.About": CAdESCOM.AboutAsync;
"CAdESCOM.SignedXML": CAdESCOM.SignedXMLAsync;
"CAdESCOM.HashedData": CAdESCOM.CPHashedDataAsync;
"CAdESCOM.CadesSignedData": CAdESCOM.CadesSignedDataAsync;
"CAdESCOM.CPAttribute": CAdESCOM.CPAttributeAsync;
"CAdESCOM.RawSignature": CAdESCOM.RawSignatureAsync;
}
interface LogLevel {
readonly LOG_LEVEL_DEBUG: 4;
readonly LOG_LEVEL_INFO: 2;
readonly LOG_LEVEL_ERROR: 1;
}
interface SignedXmlUrls {
readonly XmlDsigGost3410Url: "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411";
readonly XmlDsigGost3410UrlObsolete: "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411";
readonly XmlDsigGost3411Url: "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411";
readonly XmlDsigGost3411UrlObsolete: "http://www.w3.org/2001/04/xmldsig-more#gostr3411";
}
interface EncodingType {
readonly CADESCOM_ENCODE_ANY: -1;
readonly CADESCOM_ENCODE_BASE64: 0;
readonly CADESCOM_ENCODE_BINARY: 1;
}
}
interface CADESPluginBase extends Promise<never>,
CAPICOM.StoreLocationPlugin, CAdESCOM.StoreLocationPlugin, CAPICOM.StoreNamePlugin,
CAPICOM.StoreOpenModePlugin, CAPICOM.CAPICOM_CERTIFICATE_FIND_TYPE,
CADES_Plugin.LogLevel, CAdESCOM.CADESCOM_XML_SIGNATURE_TYPE,
CADES_Plugin.SignedXmlUrls, CAdESCOM.CADESCOM_CADES_TYPE,
CADES_Plugin.EncodingType, CAPICOM.CAPICOM_CERTIFICATE_INCLUDE_OPTION,
CAPICOM.CertIntoTypePlugin, CAPICOM.KeyUsagePlugin,
CAPICOM.PropIDPlugin, CAPICOM.OIDPlugin, CAPICOM.EKUPlugin,
CAPICOM.CAPICOM_ATTRIBUTE, CAdESCOM.CADESCOM_ATTRIBUTE,
CAdESCOM.CADESCOM_CONTENT_ENCODING_TYPE, CAdESCOM.CADESCOM_DISPLAY_DATA,
CAdESCOM.CADESCOM_ENCRYPTION_ALGORITHM, CAdESCOM.CADESCOM_HASH_ALGORITHM,
CAdESCOM.CADESCOM_InstallResponseRestrictionFlags {
readonly JSModuleVersion: string;
readonly current_log_level: number;
async_spawn<T>(generatorFun: (...args: any[]) => Iterator<T>): T;
set(obj: CADESPluginBase): void;
set_log_level(level: CADES_Common.ValuesOf<CADES_Plugin.LogLevel>): void;
getLastError(exception: Error): string;
is_capilite_enabled(): boolean;
}
interface CADESPluginAsync extends CADESPluginBase {
CreateObjectAsync<T extends keyof CADES_Plugin.ObjectNamesAsync>(objName: T): Promise<CADES_Plugin.ObjectNamesAsync[T]>;
ReleasePluginObjects(): Promise<boolean>;
}
interface CADESPluginSync extends CADESPluginBase {
CreateObject<T extends keyof CADES_Plugin.ObjectNames>(objName: T): CADES_Plugin.ObjectNames[T];
}
type CADESPlugin = CADESPluginAsync | CADESPluginSync;
+83
View File
@@ -0,0 +1,83 @@
declare namespace CAPICOM {
interface EncodedData {
readonly Format: string;
Value(EncodingType?: CAPICOM_ENCODING_TYPE): string;
}
interface OID {
FriendlyName: string;
Name: CAPICOM_OID;
Value: string;
}
interface PublicKey {
readonly Algorithm: OID;
readonly EncodedKey: EncodedData;
readonly EncodedParameters: EncodedData;
readonly Length: number;
}
interface Certificate {
readonly Version: number;
readonly Thumbprint: string;
readonly SubjectName: string;
readonly SerialNumber: string;
readonly IssuerName: string;
readonly ValidFromDate: CADES_Common.VarDate;
readonly ValidToDate: CADES_Common.VarDate;
HasPrivateKey(): boolean;
GetInfo(infoType: CAPICOM_CERT_INFO_TYPE): string;
IsValid(): CertificateStatus;
Display(): void;
PublicKey(): PublicKey;
Export(EncodingType: CADES_Common.ValuesOf<CAPICOM_ENCODING_TYPE>): string;
}
interface CertificateStatus {
Result: boolean;
}
interface Certificates {
readonly Count: number;
Item(index: number): Certificate;
Find(findType: CADES_Common.ValuesOf<CAPICOM_CERTIFICATE_FIND_TYPE>, varCriteria?: any, bFindValidOnly?: boolean): Certificates;
Select(title?: string, displayString?: string, bMultiSelect?: boolean): Certificates;
}
interface Store {
readonly Certificates: Certificates;
readonly Location: CADES_Common.ValuesOf<CAPICOM_STORE_LOCATION>;
readonly Name: string;
Open(location?: CADES_Common.ValuesOf<CAPICOM_STORE_LOCATION>, name?: CADES_Common.ValuesOf<CAPICOM_STORE_NAME>, openMode?: CADES_Common.ValuesOf<CAPICOM_STORE_OPEN_MODE>): void;
Close(): void;
Delete(): boolean;
Import(encodedStore: string): void;
}
interface Signers {
readonly Count: number;
Item(index: number): Signer;
}
interface Signer {
Certificate: Certificate;
Options: CAPICOM_CERTIFICATE_INCLUDE_OPTION;
Load(fileName: string, password?: string): void;
}
}
+19
View File
@@ -0,0 +1,19 @@
declare namespace CAPICOM {
interface CertificateAsync extends CADES_Common.Async<Certificate> {
}
interface CertificatesAsync extends CADES_Common.Async<Certificates> {
}
interface StoreAsync extends CADES_Common.Async<Store> {
}
interface EncodedDataAsync extends CADES_Common.Async<EncodedData> {
}
interface OIDAsync extends CADES_Common.Async<OID> {
}
interface PublicKeyAsync extends CADES_Common.Async<PublicKey> {
}
}
+226
View File
@@ -0,0 +1,226 @@
declare namespace CAPICOM {
interface StoreLocationPlugin {
readonly CAPICOM_LOCAL_MACHINE_STORE: 1;
readonly CAPICOM_CURRENT_USER_STORE: 2;
}
interface CAPICOM_STORE_LOCATION {
readonly CAPICOM_MEMORY_STORE: 0;
readonly CAPICOM_LOCAL_MACHINE_STORE: 1;
readonly CAPICOM_CURRENT_USER_STORE: 2;
readonly CAPICOM_ACTIVE_DIRECTORY_USER_STORE: 3;
readonly CAPICOM_SMART_CARD_USER_STORE: 4;
}
interface StoreNamePlugin {
readonly CAPICOM_MY_STORE: "My";
}
interface CAPICOM_STORE_NAME extends StoreNamePlugin {
readonly CAPICOM_CA_STORE: "Ca";
readonly CAPICOM_OTHER_STORE: "AddressBook";
readonly CAPICOM_ROOT_STORE: "Root";
}
interface StoreOpenModePlugin {
readonly CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED: 2;
}
interface CAPICOM_STORE_OPEN_MODE extends StoreOpenModePlugin {
readonly CAPICOM_STORE_OPEN_READ_ONLY: 0;
readonly CAPICOM_STORE_OPEN_READ_WRITE: 1;
readonly CAPICOM_STORE_OPEN_EXISTING_ONLY: 128;
readonly CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED: 256;
}
interface CAPICOM_CERTIFICATE_FIND_TYPE {
readonly CAPICOM_CERTIFICATE_FIND_SHA1_HASH: 0;
readonly CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME: 1;
readonly CAPICOM_CERTIFICATE_FIND_ISSUER_NAME: 2;
readonly CAPICOM_CERTIFICATE_FIND_ROOT_NAME: 3;
readonly CAPICOM_CERTIFICATE_FIND_TEMPLATE_NAME: 4;
readonly CAPICOM_CERTIFICATE_FIND_EXTENSION: 5;
readonly CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY: 6;
readonly CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY: 7;
readonly CAPICOM_CERTIFICATE_FIND_CERTIFICATE_POLICY: 8;
readonly CAPICOM_CERTIFICATE_FIND_TIME_VALID: 9;
readonly CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID: 10;
readonly CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED: 11;
readonly CAPICOM_CERTIFICATE_FIND_KEY_USAGE: 12;
}
interface CAPICOM_CERTIFICATE_INCLUDE_OPTION {
readonly CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT: 0;
readonly CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY: 2;
readonly CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN: 1;
}
interface CertIntoTypePlugin {
readonly CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME: 0;
readonly CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME: 1;
}
interface CAPICOM_CERT_INFO_TYPE extends CertIntoTypePlugin {
readonly CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME: 2;
readonly CAPICOM_CERT_INFO_ISSUER_EMAIL_NAME: 3;
readonly CAPICOM_CERT_INFO_SUBJECT_UPN: 4;
readonly CAPICOM_CERT_INFO_ISSUER_UPN: 5;
readonly CAPICOM_CERT_INFO_SUBJECT_DNS_NAME: 6;
readonly CAPICOM_CERT_INFO_ISSUER_DNS_NAME: 7;
}
interface KeyUsagePlugin {
readonly CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE: 128;
}
interface CAPICOM_KEY_USAGE extends KeyUsagePlugin {
readonly CAPICOM_NON_REPUDIATION_KEY_USAGE: 64;
readonly CAPICOM_KEY_ENCIPHERMENT_KEY_USAGE: 32;
readonly CAPICOM_DATA_ENCIPHERMENT_KEY_USAGE: 16;
readonly CAPICOM_KEY_AGREEMENT_KEY_USAGE: 8;
readonly CAPICOM_KEY_CERT_SIGN_KEY_USAGE: 4;
readonly CAPICOM_OFFLINE_CRL_SIGN_KEY_USAGE: 2;
readonly CAPICOM_CRL_SIGN_KEY_USAGE: 2;
readonly CAPICOM_ENCIPHER_ONLY_KEY_USAGE: 1;
readonly CAPICOM_DECIPHER_ONLY_KEY_USAGE: 32768;
}
interface PropIDPlugin {
readonly CAPICOM_PROPID_ENHKEY_USAGE: 9;
}
interface CAPICOM_PROPID extends PropIDPlugin {
readonly CAPICOM_PROPID_UNKNOWN: 0;
readonly CAPICOM_PROPID_KEY_PROV_HANDLE: 1;
readonly CAPICOM_PROPID_KEY_PROV_INFO: 2;
readonly CAPICOM_PROPID_SHA1_HASH: 3;
readonly CAPICOM_PROPID_HASH_PROP: 3;
readonly CAPICOM_PROPID_MD5_HASH: 4;
readonly CAPICOM_PROPID_KEY_CONTEXT: 5;
readonly CAPICOM_PROPID_KEY_SPEC: 6;
readonly CAPICOM_PROPID_IE30_RESERVED: 7;
readonly CAPICOM_PROPID_PUBKEY_HASH_RESERVED: 8;
readonly CAPICOM_PROPID_CTL_USAGE: 9;
readonly CAPICOM_PROPID_NEXT_UPDATE_LOCATION: 10;
readonly CAPICOM_PROPID_FRIENDLY_NAME: 11;
readonly CAPICOM_PROPID_PVK_FILE: 12;
readonly CAPICOM_PROPID_DESCRIPTION: 13;
readonly CAPICOM_PROPID_ACCESS_STATE: 14;
readonly CAPICOM_PROPID_SIGNATURE_HASH: 15;
readonly CAPICOM_PROPID_SMART_CARD_DATA: 16;
readonly CAPICOM_PROPID_EFS: 17;
readonly CAPICOM_PROPID_FORTEZZA_DATA: 18;
readonly CAPICOM_PROPID_ARCHIVED: 19;
readonly CAPICOM_PROPID_KEY_IDENTIFIER: 20;
readonly CAPICOM_PROPID_AUTO_ENROLL: 21;
readonly CAPICOM_PROPID_PUBKEY_ALG_PARA: 22;
readonly CAPICOM_PROPID_CROSS_CERT_DIST_POINTS: 23;
readonly CAPICOM_PROPID_ISSUER_PUBLIC_KEY_MD5_HASH: 24;
readonly CAPICOM_PROPID_SUBJECT_PUBLIC_KEY_MD5_HASH: 25;
readonly CAPICOM_PROPID_ENROLLMENT: 26;
readonly CAPICOM_PROPID_DATE_STAMP: 27;
readonly CAPICOM_PROPID_ISSUER_SERIAL_NUMBER_MD5_HASH: 28;
readonly CAPICOM_PROPID_SUBJECT_NAME_MD5_HASH: 29;
readonly CAPICOM_PROPID_EXTENDED_ERROR_INFO: 30;
readonly CAPICOM_PROPID_RENEWAL: 64;
readonly CAPICOM_PROPID_ARCHIVED_KEY_HASH: 65;
readonly CAPICOM_PROPID_FIRST_RESERVED: 66;
readonly CAPICOM_PROPID_LAST_RESERVED: 32767;
readonly CAPICOM_PROPID_FIRST_USER: 32768;
readonly CAPICOM_PROPID_LAST_USER: 65535;
}
interface OIDPlugin {
readonly CAPICOM_OID_OTHER: 0;
readonly CAPICOM_OID_KEY_USAGE_EXTENSION: 10;
}
interface CAPICOM_OID extends OIDPlugin {
readonly CAPICOM_OID_AUTHORITY_KEY_IDENTIFIER_EXTENSION: 1;
readonly CAPICOM_OID_KEY_ATTRIBUTES_EXTENSION: 2;
readonly CAPICOM_OID_CERT_POLICIES_95_EXTENSION: 3;
readonly CAPICOM_OID_KEY_USAGE_RESTRICTION_EXTENSION: 4;
readonly CAPICOM_OID_LEGACY_POLICY_MAPPINGS_EXTENSION: 5;
readonly CAPICOM_OID_SUBJECT_ALT_NAME_EXTENSION: 6;
readonly CAPICOM_OID_ISSUER_ALT_NAME_EXTENSION: 7;
readonly CAPICOM_OID_BASIC_CONSTRAINTS_EXTENSION: 8;
readonly CAPICOM_OID_SUBJECT_KEY_IDENTIFIER_EXTENSION: 9;
readonly CAPICOM_OID_PRIVATEKEY_USAGE_PERIOD_EXTENSION: 11;
readonly CAPICOM_OID_SUBJECT_ALT_NAME2_EXTENSION: 12;
readonly CAPICOM_OID_ISSUER_ALT_NAME2_EXTENSION: 13;
readonly CAPICOM_OID_BASIC_CONSTRAINTS2_EXTENSION: 14;
readonly CAPICOM_OID_NAME_CONSTRAINTS_EXTENSION: 15;
readonly CAPICOM_OID_CRL_DIST_POINTS_EXTENSION: 16;
readonly CAPICOM_OID_CERT_POLICIES_EXTENSION: 17;
readonly CAPICOM_OID_POLICY_MAPPINGS_EXTENSION: 18;
readonly CAPICOM_OID_AUTHORITY_KEY_IDENTIFIER2_EXTENSION: 19;
readonly CAPICOM_OID_POLICY_CONSTRAINTS_EXTENSION: 20;
readonly CAPICOM_OID_ENHANCED_KEY_USAGE_EXTENSION: 21;
readonly CAPICOM_OID_CERTIFICATE_TEMPLATE_EXTENSION: 22;
readonly CAPICOM_OID_APPLICATION_CERT_POLICIES_EXTENSION: 23;
readonly CAPICOM_OID_APPLICATION_POLICY_MAPPINGS_EXTENSION: 24;
readonly CAPICOM_OID_APPLICATION_POLICY_CONSTRAINTS_EXTENSION: 25;
readonly CAPICOM_OID_AUTHORITY_INFO_ACCESS_EXTENSION: 26;
readonly CAPICOM_OID_SERVER_AUTH_EKU: 100;
readonly CAPICOM_OID_CLIENT_AUTH_EKU: 101;
readonly CAPICOM_OID_CODE_SIGNING_EKU: 102;
readonly CAPICOM_OID_EMAIL_PROTECTION_EKU: 103;
readonly CAPICOM_OID_IPSEC_END_SYSTEM_EKU: 104;
readonly CAPICOM_OID_IPSEC_TUNNEL_EKU: 105;
readonly CAPICOM_OID_IPSEC_USER_EKU: 106;
readonly CAPICOM_OID_TIME_STAMPING_EKU: 107;
readonly CAPICOM_OID_CTL_USAGE_SIGNING_EKU: 108;
readonly CAPICOM_OID_TIME_STAMP_SIGNING_EKU: 109;
readonly CAPICOM_OID_SERVER_GATED_CRYPTO_EKU: 110;
readonly CAPICOM_OID_ENCRYPTING_FILE_SYSTEM_EKU: 111;
readonly CAPICOM_OID_EFS_RECOVERY_EKU: 112;
readonly CAPICOM_OID_WHQL_CRYPTO_EKU: 113;
readonly CAPICOM_OID_NT5_CRYPTO_EKU: 114;
readonly CAPICOM_OID_OEM_WHQL_CRYPTO_EKU: 115;
readonly CAPICOM_OID_EMBEDED_NT_CRYPTO_EKU: 116;
readonly CAPICOM_OID_ROOT_LIST_SIGNER_EKU: 117;
readonly CAPICOM_OID_QUALIFIED_SUBORDINATION_EKU: 118;
readonly CAPICOM_OID_KEY_RECOVERY_EKU: 119;
readonly CAPICOM_OID_DIGITAL_RIGHTS_EKU: 120;
readonly CAPICOM_OID_LICENSES_EKU: 121;
readonly CAPICOM_OID_LICENSE_SERVER_EKU: 122;
readonly CAPICOM_OID_SMART_CARD_LOGON_EKU: 123;
readonly CAPICOM_OID_PKIX_POLICY_QUALIFIER_CPS: 124;
readonly CAPICOM_OID_PKIX_POLICY_QUALIFIER_USERNOTICE: 125;
}
interface EKUPlugin {
readonly CAPICOM_EKU_OTHER: 0;
readonly CAPICOM_EKU_CLIENT_AUTH: 2;
readonly CAPICOM_EKU_SMARTCARD_LOGON: 5;
}
interface CAPICOM_EKU {
readonly CAPICOM_EKU_SERVER_AUTH: 1;
readonly CAPICOM_EKU_CODE_SIGNING: 3;
readonly CAPICOM_EKU_EMAIL_PROTECTION: 4;
readonly CAPICOM_EKU_ENCRYPTING_FILE_SYSTEM: 6;
}
interface CAPICOM_ATTRIBUTE {
readonly CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME: 0;
readonly CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME: 1;
readonly CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION: 2;
}
interface CAPICOM_HASH_ALGORITHM {
readonly CAPICOM_HASH_ALGORITHM_SHA1: 0;
readonly CAPICOM_HASH_ALGORITHM_MD2: 1;
readonly CAPICOM_HASH_ALGORITHM_MD4: 2;
readonly CAPICOM_HASH_ALGORITHM_MD5: 3;
readonly CAPICOM_HASH_ALGORITHM_SHA_256: 4;
readonly CAPICOM_HASH_ALGORITHM_SHA_384: 5;
readonly CAPICOM_HASH_ALGORITHM_SHA_512: 6;
}
interface CAPICOM_ENCODING_TYPE {
readonly CAPICOM_ENCODE_ANY: -1;
readonly CAPICOM_ENCODE_BASE64: 0;
readonly CAPICOM_ENCODE_BINARY: 1;
}
}
+25
View File
@@ -0,0 +1,25 @@
declare namespace CADES_Common {
type ValuesOf<T> = T[keyof T];
type VarDate = object;
// Extracts the type if wrapped by a Promise
type Unpacked<T> = T extends Promise<infer U> ? U :
T extends CAPICOM.Certificate ? CAPICOM.CertificateAsync :
T extends CAPICOM.Certificates ? CAPICOM.CertificatesAsync :
T extends CAdESCOM.CPSigner ? CAdESCOM.CPSignerAsync :
T extends CAdESCOM.CPHashedData ? CAdESCOM.CPHashedDataAsync :
T extends CAdESCOM.Version ? CAdESCOM.VersionAsync :
T extends CAPICOM.OID ? CAPICOM.OIDAsync :
T extends CAPICOM.EncodedData ? CAPICOM.EncodedDataAsync :
T extends CAPICOM.PublicKey ? CAPICOM.PublicKeyAsync :
T;
type PromisifiedFunction<T extends Function> = // tslint:disable-line ban-types
T extends (...args: infer A) => infer U ? (...args: { [K in keyof A]: Unpacked<A[K]> }) => Promise<Unpacked<U>> :
T;
type Async<T> = {
readonly [K in keyof T]: T[K] extends Function ? PromisifiedFunction<T[K]> : // tslint:disable-line ban-types
Promise<Unpacked<T[K]>>;
};
}
+13
View File
@@ -0,0 +1,13 @@
///<reference path="./common.d.ts"/>
///<reference path="./capicom.d.ts"/>
///<reference path="./capicom_async.d.ts"/>
///<reference path="./capicom_enums.d.ts"/>
///<reference path="./cadescom.d.ts"/>
///<reference path="./cadescom_async.d.ts"/>
///<reference path="./cadescom_enums.d.ts"/>
///<reference path="./cadesplugin.d.ts"/>
declare const cadesplugin: CADESPlugin;
+25
View File
@@ -0,0 +1,25 @@
{
"extends": "../tsconfig",
"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",
"cadesplugin-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+23
View File
@@ -0,0 +1,23 @@
{
"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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -249,7 +249,7 @@ export interface GenerateFuncFlags {
* * ttl - the cache ttl value in milliseconds. Set to 0 to skip storing in the cache. Defaults to the cache global policy.
* @see {@link https://github.com/hapijs/catbox#policy}
*/
export type GenerateFunc<T> = (id: string, flags: GenerateFuncFlags) => Promise<T>;
export type GenerateFunc<T> = (id: Id, flags: GenerateFuncFlags) => Promise<T>;
/**
* An object with logging information about the generation operation containing the following keys (as relevant):
+12 -6
View File
@@ -1372,12 +1372,12 @@ export interface MediaInformation {
* is playing or ones that receiver will play shortly after; instead of sending
* whole list of clips. This is to avoid overflow of MediaStatus message.
*/
breakClips: BreakClip[];
breakClips?: BreakClip[];
/**
* List of breaks.
*/
breaks: Break[];
breaks?: Break[];
/**
* Typically the url of the media.
@@ -1414,12 +1414,18 @@ export interface MediaInformation {
/**
* The format of the HLS media segment.
*/
hlsSegmentFormat: HlsSegmentFormat;
hlsSegmentFormat?: HlsSegmentFormat;
/**
* The media metadata.
*/
metadata: MediaMetadata;
metadata?:
| MediaMetadata
| GenericMediaMetadata
| MovieMediaMetadata
| MusicTrackMediaMetadata
| PhotoMediaMetadata
| TvShowMediaMetadata;
/**
* The stream type.
@@ -1429,12 +1435,12 @@ export interface MediaInformation {
/**
* The style of text track.
*/
textTrackStyle: TextTrackStyle;
textTrackStyle?: TextTrackStyle;
/**
* The media tracks.
*/
tracks: Track[];
tracks?: Track[];
}
/**
+3
View File
@@ -0,0 +1,3 @@
import cliSpinners = require('cli-spinners');
cliSpinners.dots; // $ExpectType Spinner
+87
View File
@@ -0,0 +1,87 @@
// Type definitions for cli-spinners 1.3
// Project: https://github.com/sindresorhus/cli-spinners#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = cliSpinners;
declare const cliSpinners: Record<cliSpinners.SpinnerName, cliSpinners.Spinner>;
declare namespace cliSpinners {
type SpinnerName =
| 'dots'
| 'dots2'
| 'dots3'
| 'dots4'
| 'dots5'
| 'dots6'
| 'dots7'
| 'dots8'
| 'dots9'
| 'dots10'
| 'dots11'
| 'dots12'
| 'line'
| 'line2'
| 'pipe'
| 'simpleDots'
| 'simpleDotsScrolling'
| 'star'
| 'star2'
| 'flip'
| 'hamburger'
| 'growVertical'
| 'growHorizontal'
| 'balloon'
| 'balloon2'
| 'noise'
| 'bounce'
| 'boxBounce'
| 'boxBounce2'
| 'triangle'
| 'arc'
| 'circle'
| 'squareCorners'
| 'circleQuarters'
| 'circleHalves'
| 'squish'
| 'toggle'
| 'toggle2'
| 'toggle3'
| 'toggle4'
| 'toggle5'
| 'toggle6'
| 'toggle7'
| 'toggle8'
| 'toggle9'
| 'toggle10'
| 'toggle11'
| 'toggle12'
| 'toggle13'
| 'arrow'
| 'arrow2'
| 'arrow3'
| 'bouncingBar'
| 'bouncingBall'
| 'smiley'
| 'monkey'
| 'hearts'
| 'clock'
| 'earth'
| 'moon'
| 'runner'
| 'pong'
| 'shark'
| 'dqpb'
| 'weather'
| 'christmas'
| 'grenade'
| 'point'
| 'layer';
interface Spinner {
interval: number;
frames: string[];
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cli-spinners-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -112,5 +112,5 @@ export class CookieJar {
* grab all cookies matching this access_info
* @param accessInfo CookieAccessInfo
*/
getCookies(accessInfo: CookieAccessInfo): ReadonlyArray<Cookie>;
getCookies(accessInfo: CookieAccessInfo): ReadonlyArray<Cookie> & { toValueString(): string };
}
@@ -61,59 +61,89 @@ var demoExtendedData : BLECentralPlugin.PeripheralDataExtended = {
//get updates about the bluethooth states
ble.startStateNotifications((state) => log(`BLE state ${state}`));
ble.startStateNotifications((state) => log(`BLE state ${state}`), (err: string) => log(`things when wrong ${err}`));
ble.isEnabled(()=> log(`bluetooth is enabled`), ()=>log(`bluetooth is not enabled`));
ble.isEnabled(()=> log(`bluetooth is enabled`), err =>log(`bluetooth is not enabled: ${err}`));
//here we try to enable bluetooth
ble.enable(() => log(`yes it worked, or it was already enabled `), () => log(`nope it didn't work, the user pressed cancel, or we are in iOS`));
ble.enable(() => log(`yes it worked, or it was already enabled `), err => log(`nope it didn't work, the user pressed cancel, or we are in iOS: ${err}`));
ble.showBluetoothSettings(() => log(`yes it worked`), () => log(`nope it didn't work`))
//stop getting updates about the bluethooth states
ble.stopStateNotifications()
ble.stopStateNotifications(() => log(`yes it worked`))
ble.stopStateNotifications(() => log(`yes it worked`), () => log(`nope it didn't work`))
//scan 5 seconds
ble.scan([], 5000, (data) => { devices.push(data); }, ()=> log('couldn\'t connect') );
ble.scan([], 5000, (data) => { devices.push(data); });
ble.scan([], 5000, (data) => { devices.push(data); }, () => log(`couldn't connect`) );
ble.scan([], 5000, (data) => { devices.push(data); }, err => log(`couldn't connect: ${err}`) );
//scan continously
ble.startScan([], (data) => { devices.push(data); }, ()=> log('couldn\'t connect') )
ble.startScan([], (data) => { devices.push(data); })
ble.startScan([], (data) => { devices.push(data); }, () => log('couldn\'t connect') )
ble.startScan([], (data) => { devices.push(data); }, err => log(`couldn't connect: ${err}`) );
////scan continously
ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); }, ()=> log('couldn\'t connect') )
ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); });
ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); }, err => log(`couldn't connect: ${err}`));
//stop scanning
ble.stopScan(()=> log('all good'), ()=> log('couldn\'t stop scanning'));
//are we conenected to that device?
ble.isConnected(demoDevice.id, () => log(`already connected to this device`));
ble.isConnected(demoDevice.id, () => log(`already connected to this device`), ()=> log(`not yet connected to that device`));
//connect to a specific device
var extendedData : BLECentralPlugin.PeripheralDataExtended;
ble.connect(demoDevice.id, (data)=> extendedData = data, () => log(`couldn't connect to the device`) );
ble.connect(demoDevice.id, (data)=> extendedData = data, err => log(`couldn't connect to the device: ${err}`) );
//read some data from a characteristic
var charsOfOneOfItsServices = demoExtendedData.characteristics.filter((value) => value.service == demoExtendedData.services[0]);
ble.read(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic);
ble.read(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, (data) => log(`we've received some data`), ()=> log(`couldn't read any data`));
//read the rssi
ble.readRSSI(demoDevice.id, (rssi)=>log(`Device ${demoDevice.name} has an RSSI of ${rssi}`));
ble.readRSSI(demoDevice.id, (rssi)=>log(`Device ${demoDevice.name} has an RSSI of ${rssi}`), err => log(`Unable to read RSSI: ${err}`));
// request mtu
ble.requestMtu(demoDevice.id, 10);
ble.requestMtu(demoDevice.id, 10, () => log('it worked'));
ble.requestMtu(demoDevice.id, 10, () => log('it worked'), () => log('it failed'));
// refreshDeviceCache
ble.refreshDeviceCache(demoDevice.id, 10);
ble.refreshDeviceCache(demoDevice.id, 10, () => log('it worked'));
ble.refreshDeviceCache(demoDevice.id, 10, () => log('it worked'), () => log('it failed'));
var notificationsReceived : number = 0;
//get notified of changes for that characteristic
ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, (data)=> notificationsReceived++, ()=> log(`darn`));
ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic,
(data)=> notificationsReceived++);
ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic,
(data)=> notificationsReceived++, err => log(`darn: ${err}`));
//write some data
ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40));
ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`));
ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`), ()=> log(`could't write`));
//write some data without getting notified
ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40));
ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`));
ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`), ()=> log(`could't write`));
//stop getting notified of changes.
ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic);
ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, () => log('it worked'));
ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, () => log('it worked'), () => log('it failed'));
//notificationsReceived == 1
//just disconnect
ble.disconnect(demoDevice.id);
ble.disconnect(demoDevice.id, () => log('it worked'));
ble.disconnect(demoDevice.id, () => log('it worked'), () => log('it failed'));
+61 -50
View File
@@ -1,12 +1,13 @@
// Type definitions for cordova-plugin-ble-central 1.1.2
// Type definitions for cordova-plugin-ble-central 1.2.2
// Project: https://github.com/don/cordova-plugin-ble-central
// Definitions by: Gidon Junge <https://github.com/gjunge>
// Philip Peitsch <https://github.com/peitschie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace BLECentralPlugin {
interface PeripheralCharacteristic {
interface PeripheralCharacteristic {
service: string;
characteristic: string;
properties: string[];
@@ -26,7 +27,12 @@ declare namespace BLECentralPlugin {
characteristics: PeripheralCharacteristic[]
}
interface BLEError {
name: string;
id: string;
errorMessage: string;
}
interface StartScanOptions {
@@ -34,75 +40,80 @@ declare namespace BLECentralPlugin {
}
export interface BLECentralPluginStatic {
scan(services: string[], seconds: number, success : (data: PeripheralData) => any): void;
scan(services: string[], seconds: number, success : (data: PeripheralData) => any, failure : () => any): void;
startScan(services: string[], success: (data: PeripheralData) => any): void;
startScan(services: string[], success: (data: PeripheralData) => any, failure: () => any): void;
scan(services: string[], seconds: number, success : (data: PeripheralData) => any, failure? : (error: string) => any): void;
startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any): void;
startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure: () => any): void;
startScan(services: string[], success: (data: PeripheralData) => any, failure?: (error: string|BLEError) => any): void;
startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure?: (error: string) => any): void;
stopScan(): void;
stopScan(success: () => any): void;
stopScan(success: () => any, failure: () => any): void;
connect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: () => any): void;
stopScan(success: () => any, failure?: () => any): void;
disconnect(device_id:string): void;
disconnect(device_id:string, success: () => any): void;
disconnect(device_id:string, success: () => any, failure: () => any): void;
connect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: (error: string|BLEError) => any): void;
read(device_id: string, service_uuid:string, characteristic_uuid:string): void;
read(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any): void;
read(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure: () => any): void;
/* Automatically connect to a device when it is in range of the phone
[iOS] background notifications on ios must be enabled if you want to run in the background
[Android] this relies on the autoConnect argument of BluetoothDevice.connectGatt(). Not all Android devices implement this feature correctly. */
autoConnect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: (error: string|BLEError) => any): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any, failure: () => any): void;
disconnect(device_id:string, success?: () => any, failure?: (error: string|BLEError) => any): void;
/* Writes data to a characteristic without a response from the peripheral. You are not notified if the write fails in the BLE stack.
read(device_id: string, service_uuid:string, characteristic_uuid:string, success?: (rawData: ArrayBuffer) => any, failure?: (error: string|BLEError) => any): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success?: () => any, failure?: (error: string|BLEError) => any): void;
/* Writes data to a characteristic without a response from the peripheral. You are not notified if the write fails in the BLE stack.
The success callback is be called when the characteristic is written.*/
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer): void;
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any): void;
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any, failure: () => any): void;
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success?: () => any, failure?: (error: string) => any): void;
/* Register to be notified when the value of a characteristic changes. */
startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any): void;
startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure: () => any): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: () => any): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: () => any, failure: () => any): void;
startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure?: (error: string|BLEError) => any): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success?: () => any, failure?: (error: string|BLEError) => any): void;
/* Reports if bluetooth is enabled. */
isEnabled(success: () => any , failure: () => any): void;
isEnabled(success: () => any , failure: (error: string) => any): void;
/* Calls the success callback when the peripheral is connected and the failure callback when not connected. */
isConnected(device_id: string, success: () => any): void;
isConnected(device_id: string, success: () => any, failure: () => any): void;
isConnected(device_id: string, success: () => any, failure?: (error: string) => any): void;
startStateNotifications(success: (state: string) => any): void;
startStateNotifications(success: (state: string) => any, failure: () => any): void;
/* May be used to request (on Android) a larger MTU size to be able to send more data at once
[iOS] requestMtu is not supported on iOS. */
requestMtu(device_id: string, mtu: number, success?: () => any, failure?: () => any): void;
/* Clears cached services and characteristics info for some poorly behaved devices. Uses an undocumented API,
so it is not guaranteed to work.
[iOS] refreshDeviceCache is not supported on iOS. */
refreshDeviceCache(device_id: string, timeout_millis: number, success?: (data: PeripheralDataExtended) => any, failure?: (error: string|BLEError) => any): void;
startStateNotifications(success: (state: string) => any, failure?: (error: string) => any): void;
stopStateNotifications(success?: () => any, failure?: () => any): void;
stopStateNotifications(): void;
stopStateNotifications(success: () => any): void;
stopStateNotifications(success: () => any, failure: () => any): void;
/* Opens the Bluetooth settings for the operating systems.
[iOS] showBluetoothSettings is not supported on iOS. */
showBluetoothSettings(): void;
showBluetoothSettings(success: () => any): void;
showBluetoothSettings(success: () => any, failure: () => any): void;
/* Enable Bluetooth on the device.
[iOS] enable is not supported on iOS. */
enable(success: () => any, failure: () => any): void;
enable(success: () => any, failure: (error: string) => any): void;
readRSSI(device_id:string, success: (rssi: number) => any): void;
readRSSI(device_id:string, success: (rssi: number) => any, failure: () => any): void;
readRSSI(device_id:string, success: (rssi: number) => any, failure?: (error: string) => any): void;
/* Find connected peripherals offering the listed service UUIDs.
This function wraps CBCentralManager.retrieveConnectedPeripheralsWithServices.
[Android] peripheralsWithIdentifiers is not supported on Android. */
connectedPeripheralsWithServices(services: string[], success: (data: PeripheralData[]) => any, failure: () => any): void;
/* Find known (but not necessarily connected) peripherals offering the listed service UUIDs.
This function wraps CBCentralManager.retrievePeripheralsWithIdentifiers
[Android] peripheralsWithIdentifiers is not supported on Android. */
peripheralsWithIdentifiers(services: string[], success: (data: PeripheralData[]) => any, failure: () => any): void;
/* Find the bonded devices.
[iOS] bondedDevices is not supported on iOS. */
bondedDevices(success: (data: PeripheralData[]) => any, failure: () => any): void;
}
}
declare var ble: BLECentralPlugin.BLECentralPluginStatic;
declare var ble: BLECentralPlugin.BLECentralPluginStatic;

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