mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
+1
-1
@@ -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
|
||||
|
||||
+802
-387
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,4 @@
|
||||
# DefinitelyTyped [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
|
||||
|
||||
[](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: [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
|
||||
* All packages are being published to npm in under 10,000 seconds: [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13)
|
||||
* [typescript-bot](https://github.com/typescript-bot) has been active on DefinitelyTyped [](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).
|
||||
|
||||
[](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).
|
||||
@@ -244,17 +255,71 @@ Here are the [currently requested definitions](https://github.com/DefinitelyType
|
||||
|
||||
If types are part of a web standard, they should be contributed to [TSJS-lib-generator](https://github.com/Microsoft/TSJS-lib-generator) so that they can become part of the default `lib.dom.d.ts`.
|
||||
|
||||
#### Should I add an empty namespace to a package that doesn't export a module to use ES6 style imports?
|
||||
|
||||
Some packages, like [chai-http](https://github.com/chaijs/chai-http), export a function.
|
||||
|
||||
Importing this module with an ES6 style import in the form `import * as foo from "foo";` leads to the error:
|
||||
|
||||
> error TS2497: Module 'foo' resolves to a non-module entity and cannot be imported using this construct
|
||||
|
||||
This error can be suppressed by merging the function declaration with an empty namespace of the same name, but this practice is discouraged.
|
||||
This is a commonly cited [Stack Overflow answer](https://stackoverflow.com/questions/39415661/what-does-resolves-to-a-non-module-entity-and-cannot-be-imported-using-this) regarding this matter.
|
||||
|
||||
It is more appropriate to import the module using the `import foo = require("foo");` syntax.
|
||||
Nevertheless, if you want to use a default import like `import foo from "foo";` you have two options:
|
||||
- you can use the [`--allowSyntheticDefaultImports` compiler option](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#support-for-default-import-interop-with-systemjs) if your module runtime supports an interop scheme for non-ECMAScript modules, i.e. if default imports work in your environment (e.g. Webpack, SystemJS, esm).
|
||||
- you can use the [`--esModuleInterop` compiler option](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop) if you want TypeScript to take care of non-ECMAScript interop (since Typescript 2.7).
|
||||
|
||||
#### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`?
|
||||
|
||||
If you are using TypeScript 2.7 or later, use `--esModuleInterop` in your project.
|
||||
Otherwise, if default imports work in your environment (e.g. Webpack, SystemJS, esm), consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option.
|
||||
Like in the previous question, refer to using either the [`--allowSyntheticDefaultImports`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#support-for-default-import-interop-with-systemjs)
|
||||
or [`--esModuleInterop`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop)
|
||||
compiler options.
|
||||
|
||||
Do not change the type definition if it is accurate.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the export, and `export default` is accurate if `node -p 'require("foo").default'` is the export.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` works to import a module, and `export default` is accurate if `node -p 'require("foo").default'` works to import a module.
|
||||
|
||||
#### I want to use features from TypeScript 2.1 or above.
|
||||
|
||||
Then you will have to add a comment to the last line of your definition header (after `// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped`): `// TypeScript Version: 2.1`.
|
||||
|
||||
#### I want to use features from TypeScript 3.1 or above.
|
||||
|
||||
You can use the same `// TypeScript Version: 3.1` comment as above.
|
||||
However, if your project needs to maintain types that are compatible with 3.1 and above *at the same time as* types that are compatible with 3.0 or below, you will need to use the `typesVersions` feature, which is available in TypeScript 3.1 and above.
|
||||
You can find a detailed explanation of this feature in the [official TypeScript documentation](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#version-selection-with-typesversions).
|
||||
|
||||
Here's a short explanation to get you started:
|
||||
|
||||
1. You'll have to add a `package.json` file to your package definition, with the following contents:
|
||||
|
||||
```json
|
||||
{
|
||||
"private": true,
|
||||
"types": "index",
|
||||
"typesVersions": {
|
||||
">=3.1.0-0": { "*": ["ts3.1/*"] }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. Create the sub-directory mentioned in the `typesVersions` field inside your types directory (`ts3.1/` in this example)
|
||||
and add the types and tests specific for the new TypeScript version. You don't need the typical definition header
|
||||
in any of the files from the `ts3.1/` directory.
|
||||
|
||||
3. Set the `baseUrl` and `typeRoots` options in `ts3.1/tsconfig.json` to the correct paths, they should look something like this:
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": ["../../"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can look [here](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/debounce-promise) and [here](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/create-html-element) for examples.
|
||||
|
||||
#### I want to add a DOM API not present in TypeScript by default.
|
||||
|
||||
This may belong in [TSJS-Lib-Generator](https://github.com/Microsoft/TSJS-lib-generator#readme). See the guidelines there.
|
||||
@@ -322,19 +387,6 @@ When `dts-gen` is used to scaffold a scoped package, the `paths` property has to
|
||||
|
||||
GitHub doesn't [support](http://stackoverflow.com/questions/5646174/how-to-make-github-follow-directory-history-after-renames) file history for renamed files. Use [`git log --follow`](https://www.git-scm.com/docs/git-log) instead.
|
||||
|
||||
#### Should I add an empty namespace to a package that doesn't export a module to use ES6 style imports?
|
||||
|
||||
Some packages, like [chai-http](https://github.com/chaijs/chai-http), export a function.
|
||||
|
||||
Importing this module with an ES6 style import in the form `import * as foo from "foo";` leads to the error:
|
||||
|
||||
> error TS2497: Module 'foo' resolves to a non-module entity and cannot be imported using this construct
|
||||
|
||||
This error can be suppressed by merging the function declaration with an empty namespace of the same name, but this practice is discouraged.
|
||||
This is a commonly cited [Stack Overflow answer](https://stackoverflow.com/questions/39415661/what-does-resolves-to-a-non-module-entity-and-cannot-be-imported-using-this) regarding this matter.
|
||||
|
||||
It is more appropriate to import the module using the `import foo = require("foo");` syntax, or to use a default import like `import foo from "foo";` if using the `--allowSyntheticDefaultImports` flag if your module runtime supports an interop scheme for non-ECMAScript modules as such.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT license.
|
||||
@@ -342,6 +394,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.
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
[](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) Are packages being published to npm in less than 10,000 seconds on average?
|
||||
[](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Has typescript-bot been active on DefinitelyTyped in the last two hours?
|
||||
|
||||
+5
-5
@@ -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",
|
||||
|
||||
@@ -564,6 +564,12 @@
|
||||
"sourceRepoURL": "https://www.npmjs.com/package/fast-simplex-noise",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Fastify-JWT",
|
||||
"typingsPackageName": "fastify-jwt",
|
||||
"sourceRepoURL": "https://github.com/fastify/fastify-jwt",
|
||||
"asOfVersion": "0.8.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "fecha",
|
||||
"typingsPackageName": "fecha",
|
||||
@@ -1068,6 +1074,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",
|
||||
@@ -1656,6 +1668,12 @@
|
||||
"sourceRepoURL": "https://github.com/dpa99c/phonegap-launch-navigator",
|
||||
"asOfVersion": "4.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Universal Router",
|
||||
"typingsPackageName": "universal-router",
|
||||
"sourceRepoURL": "https://github.com/kriasoft/universal-router",
|
||||
"asOfVersion": "8.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "upper-case",
|
||||
"typingsPackageName": "upper-case",
|
||||
@@ -1716,6 +1734,12 @@
|
||||
"sourceRepoURL": "https://github.com/tgdwyer/WebCola",
|
||||
"asOfVersion": "3.2.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "WebdriverIO",
|
||||
"typingsPackageName": "webdriverio",
|
||||
"sourceRepoURL": "git@github.com:webdriverio/webdriverio.git",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "webgme",
|
||||
"typingsPackageName": "webgme",
|
||||
|
||||
@@ -20,11 +20,17 @@ const l3: AcceptLanguageParser.Language = {
|
||||
quality: 0.9
|
||||
};
|
||||
|
||||
type Lang = "en-US" | "ko-KR";
|
||||
const enUs: Lang = "en-US";
|
||||
const koKr: Lang = "ko-KR";
|
||||
|
||||
const parsed1: AcceptLanguageParser.Language[] = AcceptLanguageParser.parse('');
|
||||
const pick1: string | null = AcceptLanguageParser.pick([''], '');
|
||||
const pick2: string | null = AcceptLanguageParser.pick([''], [l1, l2, l3]);
|
||||
const pick3: string | null = AcceptLanguageParser.pick([''], '', {});
|
||||
const pick4: string | null = AcceptLanguageParser.pick([''], '', { loose: true });
|
||||
const pick5: Lang | null = AcceptLanguageParser.pick<Lang>([enUs, koKr], [l1, l2, l3]);
|
||||
const pick6: Lang | null = AcceptLanguageParser.pick([enUs, koKr], [l1, l2, l3]);
|
||||
|
||||
const pickOptions: AcceptLanguageParser.PickOptions = {
|
||||
loose: true
|
||||
|
||||
+5
-4
@@ -1,17 +1,18 @@
|
||||
// Type definitions for accept-language-parser 1.5
|
||||
// Project: https://github.com/opentable/accept-language-parser
|
||||
// Definitions by: Niklas Wulf <https://github.com/kampfgnom>
|
||||
// Wooram Jun <https://github.com/chatoo2412>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.4.1/index.js
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.5.0/index.js
|
||||
|
||||
export function parse(acceptLanguage: string): Language[];
|
||||
export function pick(
|
||||
supportedLanguages: string[],
|
||||
export function pick<T extends string>(
|
||||
supportedLanguages: T[],
|
||||
acceptLanguage: string | Language[],
|
||||
options?: PickOptions
|
||||
): string | null;
|
||||
): T | null;
|
||||
|
||||
export interface Language {
|
||||
code: string;
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
});
|
||||
Vendored
+33
@@ -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;
|
||||
}
|
||||
@@ -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"]
|
||||
}
|
||||
@@ -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);
|
||||
Vendored
+75
@@ -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 [];
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"fastify-jwt-tests.ts"
|
||||
"adlib-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,62 +1,69 @@
|
||||
|
||||
import AdmZip = require("adm-zip");
|
||||
import AdmZip = require('adm-zip');
|
||||
|
||||
// reading archives
|
||||
var zip = new AdmZip("./my_file.zip");
|
||||
var zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records
|
||||
const zip = new AdmZip('./my_file.zip');
|
||||
const zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records
|
||||
|
||||
zipEntries.forEach(function (zipEntry) {
|
||||
zipEntries.forEach(zipEntry => {
|
||||
console.log(zipEntry.toString()); // outputs zip entries information
|
||||
if (zipEntry.entryName == "my_file.txt") {
|
||||
if (zipEntry.entryName === 'my_file.txt') {
|
||||
console.log(zipEntry.getData().toString('utf8'));
|
||||
}
|
||||
});
|
||||
// outputs the content of some_folder/my_file.txt
|
||||
console.log(zip.readAsText("some_folder/my_file.txt"));
|
||||
console.log(zip.readAsText('some_folder/my_file.txt'));
|
||||
// extracts the specified file to the specified location
|
||||
zip.extractEntryTo(/*entry name*/"some_folder/my_file.txt", /*target path*/"/home/me/tempfolder", /*overwrite*/true)
|
||||
zip.extractEntryTo(
|
||||
/*entry name*/ 'some_folder/my_file.txt',
|
||||
/*target path*/ '/home/me/tempfolder',
|
||||
/*overwrite*/ true
|
||||
);
|
||||
// extracts everything
|
||||
zip.extractAllTo(/*target path*/"/home/me/zipcontent/", /*overwrite*/true);
|
||||
zip.extractAllTo(/*target path*/ '/home/me/zipcontent/', /*overwrite*/ true);
|
||||
// extracts everything and calls callback -> async extracction
|
||||
zip.extractAllToAsync(/*target path*/"/home/me/zipcontent/", /*overwrite*/true, (error: Error)=> {});
|
||||
zip.extractAllToAsync(
|
||||
/*target path*/ '/home/me/zipcontent/',
|
||||
/*overwrite*/ true,
|
||||
(error: Error) => {}
|
||||
);
|
||||
|
||||
// creating archives
|
||||
var zip = new AdmZip();
|
||||
new AdmZip();
|
||||
|
||||
// add file directly
|
||||
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
|
||||
zip.addFile('test.txt', new Buffer('inner content of the file'), 'entry comment goes here');
|
||||
// add local file
|
||||
zip.addLocalFile("/home/me/some_picture.png");
|
||||
zip.addLocalFile('/home/me/some_picture.png');
|
||||
// get everything as a buffer
|
||||
var willSendthis = zip.toBuffer();
|
||||
const willSendthis = zip.toBuffer();
|
||||
// or write everything to disk
|
||||
zip.writeZip(/*target file name*/"/home/me/files.zip");
|
||||
zip.writeZip(/*target file name*/ '/home/me/files.zip');
|
||||
|
||||
function processZipEntry(zipEntry: AdmZip.IZipEntry) {
|
||||
console.log('comment', zipEntry.comment);
|
||||
}
|
||||
|
||||
//tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP
|
||||
import Zip = require("adm-zip");
|
||||
// tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP
|
||||
import Zip = require('adm-zip');
|
||||
// loads and parses existing zip file local_file.zip
|
||||
var zip = new Zip("local_file.zip");
|
||||
new Zip('local_file.zip');
|
||||
// creates new in memory zip
|
||||
zip = new Zip();
|
||||
new Zip();
|
||||
// loads and parses existing zip file local_file.zip
|
||||
zip = new Zip("local_file.zip");
|
||||
new Zip('local_file.zip');
|
||||
// get all entries and iterate them
|
||||
zip.getEntries().forEach((entry) => {
|
||||
var entryName = entry.entryName;
|
||||
var decompressedData = zip.readFile(entry); // decompressed buffer of the entry
|
||||
console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry
|
||||
zip.getEntries().forEach(entry => {
|
||||
const entryName = entry.entryName;
|
||||
const decompressedData = zip.readFile(entry); // decompressed buffer of the entry
|
||||
console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry
|
||||
});
|
||||
|
||||
// will extract the file myfile.txt from the archive to /home/user/folder/subfolder/myfile.txt
|
||||
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", true, true);
|
||||
zip.extractEntryTo('folder/subfolder/myfile.txt', '/home/user/', true, true);
|
||||
|
||||
// will extract the file myfile.txt from the archive to /home/user/myfile.txt
|
||||
zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true);
|
||||
zip.extractEntryTo('folder/subfolder/myfile.txt', '/home/user/', false, true);
|
||||
|
||||
function isAdmZipEntry(obj: any): obj is AdmZip.IZipEntry {
|
||||
return obj !== null && typeof obj === "object" && typeof obj['entryName'] === 'string';
|
||||
return obj !== null && typeof obj === 'object' && typeof obj['entryName'] === 'string';
|
||||
}
|
||||
|
||||
Vendored
+93
-155
@@ -1,90 +1,56 @@
|
||||
// Type definitions for adm-zip v0.4.4
|
||||
// Type definitions for adm-zip 0.4
|
||||
// Project: https://github.com/cthackers/adm-zip
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>, Abner Oliveira <https://github.com/abner>
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>
|
||||
// Abner Oliveira <https://github.com/abner>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
declare class AdmZip {
|
||||
/**
|
||||
* Create a new, empty archive.
|
||||
* @param fileNameOrRawData If provided, reads an existing archive. Otherwise creates a new, empty archive.
|
||||
*/
|
||||
constructor();
|
||||
constructor(fileNameOrRawData?: string | Buffer);
|
||||
/**
|
||||
* Read an existing archive.
|
||||
* Extracts the given entry from the archive and returns the content.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @return `Buffer` or `null` in case of error.
|
||||
*/
|
||||
constructor(fileName: string);
|
||||
constructor(rawData: Buffer);
|
||||
readFile(entry: string | AdmZip.IZipEntry): Buffer | null;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry String with the full path of the entry
|
||||
* @return Buffer or Null in case of error
|
||||
* Asynchronous `readFile`.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with a `Buffer` or `null` in case of error.
|
||||
*/
|
||||
readFile(entry: string): Buffer;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry ZipEntry object
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: AdmZip.IZipEntry): Buffer;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry String with the full path of the entry
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: string, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: AdmZip.IZipEntry, callback: (data: Buffer, err: string) => any): void;
|
||||
readFileAsync(
|
||||
entry: string | AdmZip.IZipEntry,
|
||||
callback: (data: Buffer | null, err: string) => any
|
||||
): void;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry String with the full path of the entry
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
* plain text in the given encoding.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsText(fileName: string, encoding?: string): string;
|
||||
readAsText(fileName: string | AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry ZipEntry object
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry String with the full path of the entry
|
||||
* Asynchronous `readAsText`.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsTextAsync(fileName: string, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: AdmZip.IZipEntry, callback: (data: string) => any, encoding?: string): void;
|
||||
readAsTextAsync(
|
||||
fileName: string | AdmZip.IZipEntry,
|
||||
callback: (data: string) => any,
|
||||
encoding?: string
|
||||
): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry String with the full path of the entry
|
||||
* and files if the given entry is a directory.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
*/
|
||||
deleteFile(entry: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry A ZipEntry object.
|
||||
*/
|
||||
deleteFile(entry: AdmZip.IZipEntry): void;
|
||||
deleteFile(entry: string | AdmZip.IZipEntry): void;
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
@@ -92,72 +58,55 @@ declare class AdmZip {
|
||||
*/
|
||||
addZipComment(comment: string): void;
|
||||
/**
|
||||
* Returns the zip comment
|
||||
* @return The zip comment.
|
||||
*/
|
||||
getZipComment(): string;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* Adds a comment to a specified file or `IZipEntry`. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: string, comment: string): void;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry ZipEntry object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: AdmZip.IZipEntry, comment: string): void;
|
||||
addZipEntryComment(entry: string | AdmZip.IZipEntry, comment: string): void;
|
||||
/**
|
||||
* Returns the comment of the specified entry.
|
||||
* @param entry String with the full path of the entry.
|
||||
* @return String The comment of the specified entry.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @return The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: string): string;
|
||||
/**
|
||||
* Returns the comment of the specified entry
|
||||
* @param entry ZipEntry object.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: AdmZip.IZipEntry): string;
|
||||
getZipEntryComment(entry: string | AdmZip.IZipEntry): string;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry String with the full path of the entry.
|
||||
* must be rewritten after updating the content.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: string, content: Buffer): void;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry ZipEntry object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: AdmZip.IZipEntry, content: Buffer): void;
|
||||
updateFile(entry: string | AdmZip.IZipEntry, content: Buffer): void;
|
||||
/**
|
||||
* Adds a file from the disk to the archive.
|
||||
* @param localPath Path to a file on disk.
|
||||
* @param zipPath Path to a directory in the archive. Defaults to the empty
|
||||
* string.
|
||||
* @param zipName Name for the file.
|
||||
*/
|
||||
addLocalFile(localPath: string, zipPath?: string): void;
|
||||
addLocalFile(localPath: string, zipPath?: string, zipName?: string): void;
|
||||
/**
|
||||
* Adds a local directory and all its nested files and directories to the
|
||||
* archive.
|
||||
* @param localPath Path to a folder on disk.
|
||||
* @param zipPath Path to a folder in the archive. Defaults to an empty
|
||||
* string.
|
||||
* @param zipPath Path to a folder in the archive. Default: `""`.
|
||||
* @param filter RegExp or Function if files match will be included.
|
||||
*/
|
||||
addLocalFolder(localPath: string, zipPath?: string): void;
|
||||
addLocalFolder(
|
||||
localPath: string,
|
||||
zipPath?: string,
|
||||
filter?: RegExp | ((filename: string) => boolean)
|
||||
): void;
|
||||
/**
|
||||
* Allows you to create a entry (file or directory) in the zip file.
|
||||
* If you want to create a directory the entryName must end in / and a null
|
||||
* If you want to create a directory the `entryName` must end in `"/"` and a `null`
|
||||
* buffer should be provided.
|
||||
* @param entryName Entry path
|
||||
* @param entryName Entry path.
|
||||
* @param content Content to add to the entry; must be a 0-length buffer
|
||||
* for a directory.
|
||||
* @param comment Comment to add to the entry.
|
||||
@@ -165,89 +114,81 @@ declare class AdmZip {
|
||||
*/
|
||||
addFile(entryName: string, data: Buffer, comment?: string, attr?: number): void;
|
||||
/**
|
||||
* Returns an array of ZipEntry objects representing the files and folders
|
||||
* inside the archive
|
||||
* Returns an array of `IZipEntry` objects representing the files and folders
|
||||
* inside the archive.
|
||||
*/
|
||||
getEntries(): AdmZip.IZipEntry[];
|
||||
/**
|
||||
* Returns a ZipEntry object representing the file or folder specified by
|
||||
* ``name``.
|
||||
* Returns a `IZipEntry` object representing the file or folder specified by `name`.
|
||||
* @param name Name of the file or folder to retrieve.
|
||||
* @return ZipEntry The entry corresponding to the name.
|
||||
* @return The entry corresponding to the `name`.
|
||||
*/
|
||||
getEntry(name: string): AdmZip.IZipEntry;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* Extracts the given entry to the given `targetPath`.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param targetPath Target folder where to write the file.
|
||||
* @param maintainEntryPath If maintainEntryPath is `true` and the entry is
|
||||
* inside a folder, the entry folder will be created in `targetPath` as
|
||||
* well. Default: `true`.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
*
|
||||
* @return Boolean
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
*/
|
||||
extractEntryTo(entryPath: string, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
extractEntryTo(
|
||||
entryPath: string | AdmZip.IZipEntry,
|
||||
targetPath: string,
|
||||
maintainEntryPath?: boolean,
|
||||
overwrite?: boolean
|
||||
): boolean;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry ZipEntry object
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* Extracts the entire archive to the given location.
|
||||
* @param targetPath Target location.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: AdmZip.IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
*/
|
||||
extractAllTo(targetPath: string, overwrite?: boolean): void;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* Extracts the entire archive to the given location.
|
||||
* @param targetPath Target location.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @param callback The callback function will be called afeter extraction
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
* @param callback The callback function will be called after extraction.
|
||||
*/
|
||||
extractAllToAsync(targetPath: string, overwrite: boolean, callback: (error: Error) => void): void;
|
||||
extractAllToAsync(
|
||||
targetPath: string,
|
||||
overwrite?: boolean,
|
||||
callback?: (error: Error) => void
|
||||
): void;
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or
|
||||
* if a zip was opened and no ``targetFileName`` is provided, it will
|
||||
* overwrite the opened zip
|
||||
* @param targetFileName
|
||||
* if a zip was opened and no `targetFileName` is provided, it will
|
||||
* overwrite the opened zip.
|
||||
*/
|
||||
writeZip(targetPath?: string): void;
|
||||
writeZip(targetFileName?: string, callback?: (error: Error | null) => void): void;
|
||||
/**
|
||||
* Returns the content of the entire zip file as a Buffer object
|
||||
* @return Buffer
|
||||
* Returns the content of the entire zip file.
|
||||
*/
|
||||
toBuffer(): Buffer;
|
||||
}
|
||||
|
||||
declare namespace AdmZip {
|
||||
/**
|
||||
* The ZipEntry is more than a structure representing the entry inside the
|
||||
* The `IZipEntry` is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
// disable warning about the I-prefix in interface name to prevent breaking stuff for users without a major bump
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IZipEntry {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
*/
|
||||
entryName: string;
|
||||
rawEntryName: Buffer;
|
||||
readonly rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
@@ -256,15 +197,16 @@ declare namespace AdmZip {
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
name: string;
|
||||
readonly name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
isDirectory: boolean;
|
||||
readonly isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
header: Buffer;
|
||||
attr: number;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
@@ -278,11 +220,7 @@ declare namespace AdmZip {
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: Buffer): void;
|
||||
setData(value: string | Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"adm-zip-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,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);
|
||||
Vendored
+134
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
Vendored
+198
@@ -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>;
|
||||
@@ -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"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
Vendored
+29
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -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),
|
||||
});
|
||||
Vendored
+1392
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,7 +19,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"generateUrls.d.ts",
|
||||
"universal-router-tests.ts"
|
||||
"amap-js-sdk-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,5 +1,7 @@
|
||||
// Tests for Amplitude SDK TypeScript definitions
|
||||
|
||||
import amplitude = require('amplitude-js');
|
||||
|
||||
module Amplitude.Tests {
|
||||
|
||||
function all() {
|
||||
|
||||
Vendored
+136
-137
@@ -4,143 +4,142 @@
|
||||
// Dan Manastireanu <https://github.com/danmana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module amplitude {
|
||||
export as namespace amplitude;
|
||||
|
||||
type Callback = (responseCode: number, responseBody: string, details?: { reason: string; }) => void;
|
||||
type LogReturn = number | void;
|
||||
type Callback = (responseCode: number, responseBody: string, details?: { reason: string; }) => void;
|
||||
type LogReturn = number | void;
|
||||
|
||||
interface Config {
|
||||
apiEndpoint?: string;
|
||||
batchEvents?: boolean;
|
||||
cookieExpiration?: number;
|
||||
cookieName?: string;
|
||||
userId?: string;
|
||||
deviceId?: string;
|
||||
deviceIdFromUrlParam?: boolean;
|
||||
domain?: string;
|
||||
eventUploadPeriodMillis?: number;
|
||||
eventUploadThreshold?: number;
|
||||
forceHttps?: boolean;
|
||||
includeGclid?: boolean;
|
||||
includeReferrer?: boolean;
|
||||
includeUtm?: boolean;
|
||||
language?: string;
|
||||
logLevel?: 'DISABLE' | 'ERROR' | 'WARN' | 'INFO';
|
||||
optOut?: boolean;
|
||||
platform?: string;
|
||||
saveEvents?: boolean;
|
||||
savedMaxCount?: number;
|
||||
saveParamsReferrerOncePerSession?: boolean;
|
||||
sessionTimeout?: number;
|
||||
trackingOptions?: {
|
||||
city?: boolean;
|
||||
country?: boolean;
|
||||
device_model?: boolean;
|
||||
dma?: boolean;
|
||||
ip_address?: boolean;
|
||||
language?: boolean;
|
||||
os_name?: boolean;
|
||||
os_version?: boolean;
|
||||
platform?: boolean;
|
||||
region?: boolean;
|
||||
version_name?: boolean;
|
||||
},
|
||||
unsentKey?: string;
|
||||
unsentIdentifyKey?: string;
|
||||
uploadBatchSize?: number;
|
||||
}
|
||||
|
||||
export class Identify {
|
||||
set(key: string, value: any): Identify;
|
||||
setOnce(key: string, value: any): Identify;
|
||||
add(key: string, value: number | string): Identify;
|
||||
append(key: string, value: any): Identify;
|
||||
prepend(key: string, value: any): Identify;
|
||||
|
||||
unset(key: string): Identify;
|
||||
}
|
||||
|
||||
export class Revenue {
|
||||
|
||||
setProductId(productId: string): Revenue;
|
||||
setQuantity(quantity: number): Revenue;
|
||||
setPrice(price: number): Revenue;
|
||||
setRevenueType(revenueType: string): Revenue;
|
||||
setEventProperties(eventProperties: any): Revenue;
|
||||
}
|
||||
|
||||
export class AmplitudeClient {
|
||||
|
||||
constructor(instanceName?: string);
|
||||
|
||||
options: Config;
|
||||
|
||||
init(apiKey: string, userId?: string, config?: Config, callback?: (client: AmplitudeClient) => void): void;
|
||||
|
||||
setVersionName(versionName: string): void;
|
||||
|
||||
isNewSession(): boolean;
|
||||
setSessionId(sessionId: number): void;
|
||||
getSessionId(): number;
|
||||
|
||||
setDomain(domain: string): void;
|
||||
setUserId(userId: string): void;
|
||||
|
||||
setDeviceId(id: string): void;
|
||||
regenerateDeviceId(): void;
|
||||
|
||||
identify(identify_obj: Identify, opt_callback?: Callback): void;
|
||||
|
||||
setUserProperties(properties: any): void;
|
||||
setGlobalUserProperties(properties: any): void;
|
||||
clearUserProperties(): void;
|
||||
|
||||
setOptOut(enable: boolean): void;
|
||||
|
||||
setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
logEvent(event: string, data?: any, callback?: Callback): LogReturn;
|
||||
logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
|
||||
logRevenueV2(revenue_obj: Revenue): LogReturn;
|
||||
logRevenue(pric: number, quantity: number, product: string): LogReturn;
|
||||
logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
|
||||
}
|
||||
|
||||
// Proxy methods that get executed on the default AmplitudeClient instance (not all client methods are proxied)
|
||||
|
||||
export function init(apiKey: string, userId?: string, options?: Config, callback?: (client: AmplitudeClient) => void): void;
|
||||
|
||||
export function setVersionName(version: string): void;
|
||||
|
||||
export function isNewSession(): boolean;
|
||||
export function getSessionId(): number;
|
||||
|
||||
export function setDomain(domain: string): void;
|
||||
|
||||
export function setUserId(userId: string): void;
|
||||
|
||||
export function setDeviceId(id: string): void;
|
||||
export function regenerateDeviceId(): void;
|
||||
|
||||
export function identify(identify: Identify, callback?: Callback): void;
|
||||
|
||||
export function setUserProperties(properties: any): void;
|
||||
export function setGlobalUserProperties(properties: any): void;
|
||||
export function clearUserProperties(): void;
|
||||
|
||||
export function setOptOut(optOut: boolean): void;
|
||||
|
||||
export function setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
export function logEvent(event: string, data?: any, callback?: Callback): LogReturn;
|
||||
export function logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
|
||||
export function logRevenueV2(revenue_obj: Revenue): LogReturn;
|
||||
export function logRevenue(pric: number, quantity: number, product: string): LogReturn;
|
||||
export function logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
|
||||
|
||||
|
||||
|
||||
export function getInstance(instanceName?: string): AmplitudeClient;
|
||||
export const __VERSION__: string;
|
||||
export var options: Config;
|
||||
interface Config {
|
||||
apiEndpoint?: string;
|
||||
batchEvents?: boolean;
|
||||
cookieExpiration?: number;
|
||||
cookieName?: string;
|
||||
userId?: string;
|
||||
deviceId?: string;
|
||||
deviceIdFromUrlParam?: boolean;
|
||||
domain?: string;
|
||||
eventUploadPeriodMillis?: number;
|
||||
eventUploadThreshold?: number;
|
||||
forceHttps?: boolean;
|
||||
includeGclid?: boolean;
|
||||
includeReferrer?: boolean;
|
||||
includeUtm?: boolean;
|
||||
language?: string;
|
||||
logLevel?: 'DISABLE' | 'ERROR' | 'WARN' | 'INFO';
|
||||
optOut?: boolean;
|
||||
platform?: string;
|
||||
saveEvents?: boolean;
|
||||
savedMaxCount?: number;
|
||||
saveParamsReferrerOncePerSession?: boolean;
|
||||
sessionTimeout?: number;
|
||||
trackingOptions?: {
|
||||
city?: boolean;
|
||||
country?: boolean;
|
||||
device_model?: boolean;
|
||||
dma?: boolean;
|
||||
ip_address?: boolean;
|
||||
language?: boolean;
|
||||
os_name?: boolean;
|
||||
os_version?: boolean;
|
||||
platform?: boolean;
|
||||
region?: boolean;
|
||||
version_name?: boolean;
|
||||
},
|
||||
unsentKey?: string;
|
||||
unsentIdentifyKey?: string;
|
||||
uploadBatchSize?: number;
|
||||
}
|
||||
|
||||
export class Identify {
|
||||
set(key: string, value: any): Identify;
|
||||
setOnce(key: string, value: any): Identify;
|
||||
add(key: string, value: number | string): Identify;
|
||||
append(key: string, value: any): Identify;
|
||||
prepend(key: string, value: any): Identify;
|
||||
|
||||
unset(key: string): Identify;
|
||||
}
|
||||
|
||||
export class Revenue {
|
||||
|
||||
setProductId(productId: string): Revenue;
|
||||
setQuantity(quantity: number): Revenue;
|
||||
setPrice(price: number): Revenue;
|
||||
setRevenueType(revenueType: string): Revenue;
|
||||
setEventProperties(eventProperties: any): Revenue;
|
||||
}
|
||||
|
||||
export class AmplitudeClient {
|
||||
|
||||
constructor(instanceName?: string);
|
||||
|
||||
options: Config;
|
||||
|
||||
init(apiKey: string, userId?: string, config?: Config, callback?: (client: AmplitudeClient) => void): void;
|
||||
|
||||
setVersionName(versionName: string): void;
|
||||
|
||||
isNewSession(): boolean;
|
||||
setSessionId(sessionId: number): void;
|
||||
getSessionId(): number;
|
||||
|
||||
setDomain(domain: string): void;
|
||||
setUserId(userId: string): void;
|
||||
|
||||
setDeviceId(id: string): void;
|
||||
regenerateDeviceId(): void;
|
||||
|
||||
identify(identify_obj: Identify, opt_callback?: Callback): void;
|
||||
|
||||
setUserProperties(properties: any): void;
|
||||
setGlobalUserProperties(properties: any): void;
|
||||
clearUserProperties(): void;
|
||||
|
||||
setOptOut(enable: boolean): void;
|
||||
|
||||
setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
logEvent(event: string, data?: any, callback?: Callback): LogReturn;
|
||||
logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
|
||||
logRevenueV2(revenue_obj: Revenue): LogReturn;
|
||||
logRevenue(pric: number, quantity: number, product: string): LogReturn;
|
||||
logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
|
||||
}
|
||||
|
||||
// Proxy methods that get executed on the default AmplitudeClient instance (not all client methods are proxied)
|
||||
|
||||
export function init(apiKey: string, userId?: string, options?: Config, callback?: (client: AmplitudeClient) => void): void;
|
||||
|
||||
export function setVersionName(version: string): void;
|
||||
|
||||
export function isNewSession(): boolean;
|
||||
export function getSessionId(): number;
|
||||
|
||||
export function setDomain(domain: string): void;
|
||||
|
||||
export function setUserId(userId: string): void;
|
||||
|
||||
export function setDeviceId(id: string): void;
|
||||
export function regenerateDeviceId(): void;
|
||||
|
||||
export function identify(identify: Identify, callback?: Callback): void;
|
||||
|
||||
export function setUserProperties(properties: any): void;
|
||||
export function setGlobalUserProperties(properties: any): void;
|
||||
export function clearUserProperties(): void;
|
||||
|
||||
export function setOptOut(optOut: boolean): void;
|
||||
|
||||
export function setGroup(groupType: string, groupName: string | string[]): void;
|
||||
|
||||
export function logEvent(event: string, data?: any, callback?: Callback): LogReturn;
|
||||
export function logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
|
||||
export function logRevenueV2(revenue_obj: Revenue): LogReturn;
|
||||
export function logRevenue(pric: number, quantity: number, product: string): LogReturn;
|
||||
export function logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
|
||||
|
||||
|
||||
|
||||
export function getInstance(instanceName?: string): AmplitudeClient;
|
||||
export const __VERSION__: string;
|
||||
export var options: Config;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Vendored
+16
-14
@@ -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 +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" }
|
||||
|
||||
Vendored
+1
@@ -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;
|
||||
});
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
Vendored
+1
@@ -88,6 +88,7 @@ declare module 'angular' {
|
||||
withCredentials?: boolean;
|
||||
responseType?: string;
|
||||
interceptor?: IResourceInterceptor;
|
||||
hasBody?: boolean;
|
||||
}
|
||||
|
||||
// Allow specify more resource methods
|
||||
|
||||
@@ -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
|
||||
Vendored
+27
@@ -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;
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Ber, BerReader, BerWriter } from 'asn1';
|
||||
|
||||
let buf: Buffer = Buffer.alloc(0);
|
||||
let bool = false;
|
||||
let str = '';
|
||||
let num = 0;
|
||||
let numOrNull: number | null = 0;
|
||||
const roStrArray: ReadonlyArray<string> = [str];
|
||||
|
||||
const reader = new BerReader(buf);
|
||||
numOrNull = reader.peek();
|
||||
bool = reader.readBoolean();
|
||||
numOrNull = reader.readByte(bool);
|
||||
num = reader.readEnumeration();
|
||||
num = reader.readInt();
|
||||
num = reader.readLength();
|
||||
num = reader.readLength(num);
|
||||
str = reader.readOID();
|
||||
str = reader.readOID(num);
|
||||
numOrNull = reader.readSequence();
|
||||
numOrNull = reader.readSequence(num);
|
||||
str = reader.readString();
|
||||
str = reader.readString(num);
|
||||
buf = reader.readString(num, bool);
|
||||
num = reader._readTag();
|
||||
num = reader._readTag(num);
|
||||
|
||||
let writer = new BerWriter();
|
||||
writer = new BerWriter({
|
||||
size: num,
|
||||
growthFactor: num,
|
||||
});
|
||||
|
||||
buf = writer.buffer;
|
||||
buf = writer._buf;
|
||||
num = writer._size;
|
||||
num = writer._offset;
|
||||
|
||||
writer.endSequence();
|
||||
writer.startSequence();
|
||||
writer.startSequence(num);
|
||||
writer.writeBoolean(bool);
|
||||
writer.writeBoolean(bool, num);
|
||||
writer.writeBuffer(buf, num);
|
||||
writer.writeByte(num);
|
||||
writer.writeEnumeration(num);
|
||||
writer.writeEnumeration(num, num);
|
||||
writer.writeInt(num);
|
||||
writer.writeInt(num, num);
|
||||
writer.writeLength(num);
|
||||
writer.writeNull();
|
||||
writer.writeOID(str, num);
|
||||
writer.writeString(str);
|
||||
writer.writeString(str, num);
|
||||
writer.writeStringArray(roStrArray);
|
||||
writer._ensure(num);
|
||||
|
||||
num = Ber.BMPString;
|
||||
num = Ber.BitString;
|
||||
num = Ber.Boolean;
|
||||
num = Ber.CharacterString;
|
||||
num = Ber.Constructor;
|
||||
num = Ber.Context;
|
||||
num = Ber.EOC;
|
||||
num = Ber.Enumeration;
|
||||
num = Ber.External;
|
||||
num = Ber.GeneralString;
|
||||
num = Ber.GeneralizedTime;
|
||||
num = Ber.GraphicString;
|
||||
num = Ber.IA5String;
|
||||
num = Ber.Integer;
|
||||
num = Ber.Null;
|
||||
num = Ber.NumericString;
|
||||
num = Ber.OID;
|
||||
num = Ber.ObjectDescriptor;
|
||||
num = Ber.OctetString;
|
||||
num = Ber.PDV;
|
||||
num = Ber.PrintableString;
|
||||
num = Ber.Real;
|
||||
num = Ber.RelativeOID;
|
||||
num = Ber.Sequence;
|
||||
num = Ber.Set;
|
||||
num = Ber.T61String;
|
||||
num = Ber.UTCTime;
|
||||
num = Ber.UniversalString;
|
||||
num = Ber.Utf8String;
|
||||
num = Ber.VideotexString;
|
||||
num = Ber.VisibleString;
|
||||
Vendored
+126
@@ -0,0 +1,126 @@
|
||||
// Type definitions for asn1 0.2
|
||||
// Project: https://github.com/joyent/node-asn1
|
||||
// Definitions by: Jim Geurts <https://github.com/jgeurts>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
/// <reference types="node" />
|
||||
|
||||
export class BerReader {
|
||||
readonly buffer: Buffer;
|
||||
readonly offset: number;
|
||||
readonly length: number;
|
||||
readonly remain: number;
|
||||
readonly _buf: Buffer;
|
||||
_size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(data: Buffer);
|
||||
|
||||
peek(): number | null;
|
||||
readBoolean(): boolean;
|
||||
readByte(peek: boolean): number | null;
|
||||
readEnumeration(): number;
|
||||
readInt(): number;
|
||||
readLength(offset?: number): number;
|
||||
readOID(tag?: number): string;
|
||||
readSequence(tag?: number): number | null;
|
||||
readString(tag?: number): string;
|
||||
readString(tag: number, retbuf: boolean): Buffer;
|
||||
_readTag(tag?: number): number;
|
||||
}
|
||||
|
||||
export class BerWriter {
|
||||
readonly buffer: Buffer;
|
||||
readonly _buf: Buffer;
|
||||
readonly _size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(options?: {
|
||||
size: number;
|
||||
growthFactor: number;
|
||||
});
|
||||
|
||||
endSequence(): void;
|
||||
startSequence(tag?: number): void;
|
||||
writeBoolean(b: boolean, tag?: number): void;
|
||||
writeBuffer(buf: Buffer, tag: number): void;
|
||||
writeByte(b: number): void;
|
||||
writeEnumeration(i: number, tag?: number): void;
|
||||
writeInt(i: number, tag?: number): void;
|
||||
writeLength(len: number): void;
|
||||
writeNull(): void;
|
||||
writeOID(s: string, tag: number): void;
|
||||
writeString(s: string, tag?: number): void;
|
||||
writeStringArray(strings: ReadonlyArray<string>): void;
|
||||
_ensure(length: number): void;
|
||||
}
|
||||
|
||||
export namespace Ber {
|
||||
const BMPString: number;
|
||||
const BitString: number;
|
||||
const Boolean: number;
|
||||
const CharacterString: number;
|
||||
const Constructor: number;
|
||||
const Context: number;
|
||||
const EOC: number;
|
||||
const Enumeration: number;
|
||||
const External: number;
|
||||
const GeneralString: number;
|
||||
const GeneralizedTime: number;
|
||||
const GraphicString: number;
|
||||
const IA5String: number;
|
||||
const Integer: number;
|
||||
const Null: number;
|
||||
const NumericString: number;
|
||||
const OID: number;
|
||||
const ObjectDescriptor: number;
|
||||
const OctetString: number;
|
||||
const PDV: number;
|
||||
const PrintableString: number;
|
||||
const Real: number;
|
||||
const RelativeOID: number;
|
||||
const Sequence: number;
|
||||
const Set: number;
|
||||
const T61String: number;
|
||||
const UTCTime: number;
|
||||
const UniversalString: number;
|
||||
const Utf8String: number;
|
||||
const VideotexString: number;
|
||||
const VisibleString: number;
|
||||
}
|
||||
/*
|
||||
declare enum BerType {
|
||||
EOC = 0,
|
||||
Boolean = 1,
|
||||
Integer = 2,
|
||||
BitString = 3,
|
||||
OctetString = 4,
|
||||
Null = 5,
|
||||
OID = 6,
|
||||
ObjectDescriptor = 7,
|
||||
External = 8,
|
||||
Real = 9, // float
|
||||
Enumeration = 10,
|
||||
PDV = 11,
|
||||
Utf8String = 12,
|
||||
RelativeOID = 13,
|
||||
Sequence = 16,
|
||||
Set = 17,
|
||||
NumericString = 18,
|
||||
PrintableString = 19,
|
||||
T61String = 20,
|
||||
VideotexString = 21,
|
||||
IA5String = 22,
|
||||
UTCTime = 23,
|
||||
GeneralizedTime = 24,
|
||||
GraphicString = 25,
|
||||
VisibleString = 26,
|
||||
GeneralString = 28,
|
||||
UniversalString = 29,
|
||||
CharacterString = 30,
|
||||
BMPString = 31,
|
||||
Constructor = 32,
|
||||
Context = 128,
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedParameters": true,
|
||||
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"asn1-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+69
-34
@@ -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;
|
||||
|
||||
@@ -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[]) => { });
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
+3
-29
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+10
@@ -569,6 +569,14 @@ export type SpecErrorCodes =
|
||||
export interface Auth0Error {
|
||||
error: LibErrorCodes | SpecErrorCodes | string;
|
||||
errorDescription: string;
|
||||
// Need to include non-intuitive error fields that Auth0 uses
|
||||
code?: string;
|
||||
description?: string;
|
||||
name?: string;
|
||||
policy?: string;
|
||||
original?: any;
|
||||
statusCode?: number;
|
||||
statusText?: string;
|
||||
}
|
||||
|
||||
export type Auth0ParseHashError = Auth0Error & {
|
||||
@@ -812,6 +820,8 @@ export interface AuthorizeOptions {
|
||||
login_hint?: string;
|
||||
prompt?: string;
|
||||
mode?: "login" | "signUp";
|
||||
accessType?: string;
|
||||
approvalPrompt?: string;
|
||||
}
|
||||
|
||||
export interface CheckSessionOptions extends AuthorizeOptions {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Vendored
+1
-1
@@ -130,7 +130,7 @@ interface Auth0LockConstructorOptions {
|
||||
closable?: boolean;
|
||||
configurationBaseUrl?: string;
|
||||
container?: string;
|
||||
defaultADUsernameFromEmailPrefix?: string;
|
||||
defaultADUsernameFromEmailPrefix?: boolean;
|
||||
defaultDatabaseConnection?: string;
|
||||
defaultEnterpriseConnection?: string;
|
||||
flashMessage?: Auth0LockFlashMessageOptions;
|
||||
|
||||
@@ -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) => {});
|
||||
|
||||
Vendored
+8
-3
@@ -1,6 +1,8 @@
|
||||
// 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>
|
||||
// Alex Bjørlig <https://github.com/dauledk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -32,7 +34,7 @@ export interface RetryOptions {
|
||||
}
|
||||
|
||||
export interface UserMetadata {
|
||||
[propName: string]: string
|
||||
[propName: string]: any
|
||||
}
|
||||
|
||||
export interface AppMetadata {
|
||||
@@ -46,7 +48,10 @@ export interface UserData {
|
||||
verify_email?: boolean;
|
||||
password?: string;
|
||||
phone_number?: string;
|
||||
phone_verified?: boolean,
|
||||
phone_verified?: boolean;
|
||||
given_name?: string;
|
||||
family_name?: string;
|
||||
name?: string;
|
||||
user_metadata?: UserMetadata;
|
||||
app_metadata?: AppMetadata;
|
||||
}
|
||||
|
||||
@@ -1056,3 +1056,113 @@ const firehoseEventHandler: AWSLambda.FirehoseTransformationHandler = (
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
declare let lexEvent: AWSLambda.LexEvent;
|
||||
lexEvent = {
|
||||
currentIntent: {
|
||||
name: 'intent-name',
|
||||
slots: {
|
||||
slot1: null,
|
||||
slot2: 'value2',
|
||||
},
|
||||
slotDetails: {
|
||||
slot1: {
|
||||
resolutions: [
|
||||
{ value: 'value1' },
|
||||
],
|
||||
originalValue: 'originalValue',
|
||||
}
|
||||
},
|
||||
confirmationStatus: 'None',
|
||||
},
|
||||
bot: {
|
||||
name: 'bot name',
|
||||
alias: 'bot alias',
|
||||
version: 'bot version',
|
||||
},
|
||||
userId: 'User ID specified in the POST request to Amazon Lex.',
|
||||
inputTranscript: 'Text used to process the request',
|
||||
invocationSource: 'FulfillmentCodeHook',
|
||||
outputDialogMode: 'Text',
|
||||
messageVersion: '1.0',
|
||||
sessionAttributes: {
|
||||
key1: 'value1',
|
||||
key2: 'value2',
|
||||
},
|
||||
requestAttributes: {
|
||||
key1: 'value1',
|
||||
key2: 'value2',
|
||||
}
|
||||
};
|
||||
|
||||
declare let lexResult: AWSLambda.LexResult;
|
||||
declare let lexDialogAction: AWSLambda.LexDialogAction;
|
||||
declare let lexDialogActionBase: AWSLambda.LexDialogActionBase;
|
||||
declare let lexDialogActionClose: AWSLambda.LexDialogActionClose;
|
||||
declare let lexDialogActionConfirmIntent: AWSLambda.LexDialogActionConfirmIntent;
|
||||
declare let lexDialogActionDelegate: AWSLambda.LexDialogActionDelegate;
|
||||
declare let lexDialogActionElicitIntent: AWSLambda.LexDialogActionElicitIntent;
|
||||
declare let lexDialogActionElicitSlot: AWSLambda.LexDialogActionElicitSlot;
|
||||
declare let lexGenericAttachment: AWSLambda.LexGenericAttachment;
|
||||
|
||||
lexResult = {
|
||||
sessionAttributes: {
|
||||
attrib1: 'Value One',
|
||||
},
|
||||
dialogAction: {
|
||||
type: 'Close',
|
||||
fulfillmentState: 'Failed',
|
||||
},
|
||||
};
|
||||
|
||||
str = lexGenericAttachment.title;
|
||||
str = lexGenericAttachment.subTitle;
|
||||
str = lexGenericAttachment.imageUrl;
|
||||
str = lexGenericAttachment.attachmentLinkUrl;
|
||||
str = lexGenericAttachment.buttons[0].text;
|
||||
str = lexGenericAttachment.buttons[0].value;
|
||||
|
||||
lexDialogAction.type === 'Close';
|
||||
lexDialogAction.type === 'ConfirmIntent';
|
||||
lexDialogAction.type === 'Delegate';
|
||||
lexDialogAction.type === 'ElicitIntent';
|
||||
lexDialogAction.type === 'ElicitSlot';
|
||||
|
||||
lexDialogActionBase.message!.contentType === 'CustomPayload';
|
||||
lexDialogActionBase.message!.contentType === 'PlainText';
|
||||
lexDialogActionBase.message!.contentType === 'SSML';
|
||||
str = lexDialogActionBase.message!.content;
|
||||
num = lexDialogActionBase.responseCard!.version;
|
||||
lexDialogActionBase.responseCard!.contentType === 'application/vnd.amazonaws.card.generic';
|
||||
// $ExpectType LexGenericAttachment
|
||||
lexDialogActionBase.responseCard!.genericAttachments[0];
|
||||
|
||||
lexDialogActionClose.type === 'Close';
|
||||
lexDialogActionClose.fulfillmentState === 'Failed';
|
||||
lexDialogActionClose.fulfillmentState === 'Fulfilled';
|
||||
|
||||
lexDialogActionConfirmIntent.type === 'ConfirmIntent';
|
||||
str = lexDialogActionConfirmIntent.intentName;
|
||||
strOrNull = lexDialogActionConfirmIntent.slots['example'];
|
||||
|
||||
lexDialogActionDelegate.type === 'Delegate';
|
||||
strOrNull = lexDialogActionDelegate.slots['example'];
|
||||
|
||||
lexDialogActionElicitIntent.type === 'ElicitIntent';
|
||||
lexDialogActionElicitSlot.type === 'ElicitSlot';
|
||||
strOrNull = lexDialogActionElicitSlot.slots['example'];
|
||||
str = lexDialogActionElicitSlot.slotToElicit;
|
||||
str = lexDialogActionElicitSlot.intentName;
|
||||
|
||||
const lexEventHandler: AWSLambda.LexHandler = async (
|
||||
event: AWSLambda.LexEvent,
|
||||
context: AWSLambda.Context,
|
||||
) => {
|
||||
// $ExpectType LexEvent
|
||||
event;
|
||||
|
||||
// $ExpectType Context
|
||||
context;
|
||||
str = context.functionName;
|
||||
return lexResult;
|
||||
};
|
||||
|
||||
Vendored
+97
@@ -876,6 +876,100 @@ export interface SQSMessageAttributes {
|
||||
[name: string]: SQSMessageAttribute;
|
||||
}
|
||||
|
||||
// Lex
|
||||
// https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html#supported-event-source-lex
|
||||
export interface LexEvent {
|
||||
currentIntent: {
|
||||
name: string;
|
||||
slots: { [name: string]: string | null };
|
||||
slotDetails: LexSlotDetails;
|
||||
confirmationStatus: 'None' | 'Confirmed' | 'Denied';
|
||||
};
|
||||
bot: {
|
||||
name: string;
|
||||
alias: string;
|
||||
version: string;
|
||||
};
|
||||
userId: string;
|
||||
inputTranscript: string;
|
||||
invocationSource: 'DialogCodeHook' | 'FulfillmentCodeHook';
|
||||
outputDialogMode: 'Text' | 'Voice';
|
||||
messageVersion: '1.0';
|
||||
sessionAttributes: { [key: string]: string };
|
||||
requestAttributes: { [key: string]: string } | null;
|
||||
}
|
||||
|
||||
export interface LexSlotResolution {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface LexSlotDetails {
|
||||
[name: string]: {
|
||||
// The following line only works in TypeScript Version: 3.0, The array should have at least 1 and no more than 5 items
|
||||
// resolutions: [LexSlotResolution, LexSlotResolution?, LexSlotResolution?, LexSlotResolution?, LexSlotResolution?];
|
||||
resolutions: LexSlotResolution[]
|
||||
originalValue: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface LexGenericAttachment {
|
||||
title: string;
|
||||
subTitle: string;
|
||||
imageUrl: string;
|
||||
attachmentLinkUrl: string;
|
||||
buttons: Array<{
|
||||
text: string;
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface LexDialogActionBase {
|
||||
type: 'Close' | 'ElicitIntent' | 'ElicitSlot' | 'ConfirmIntent';
|
||||
message?: {
|
||||
contentType: 'PlainText' | 'SSML' | 'CustomPayload';
|
||||
content: string;
|
||||
};
|
||||
responseCard?: {
|
||||
version: number;
|
||||
contentType: 'application/vnd.amazonaws.card.generic';
|
||||
genericAttachments: LexGenericAttachment[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface LexDialogActionClose extends LexDialogActionBase {
|
||||
type: 'Close';
|
||||
fulfillmentState: 'Fulfilled' | 'Failed';
|
||||
}
|
||||
|
||||
export interface LexDialogActionElicitIntent extends LexDialogActionBase {
|
||||
type: 'ElicitIntent';
|
||||
}
|
||||
|
||||
export interface LexDialogActionElicitSlot extends LexDialogActionBase {
|
||||
type: 'ElicitSlot';
|
||||
intentName: string;
|
||||
slots: { [name: string]: string | null };
|
||||
slotToElicit: string;
|
||||
}
|
||||
|
||||
export interface LexDialogActionConfirmIntent extends LexDialogActionBase {
|
||||
type: 'ConfirmIntent';
|
||||
intentName: string;
|
||||
slots: { [name: string]: string | null };
|
||||
}
|
||||
|
||||
export interface LexDialogActionDelegate {
|
||||
type: 'Delegate';
|
||||
slots: { [name: string]: string | null };
|
||||
}
|
||||
|
||||
export type LexDialogAction = LexDialogActionClose | LexDialogActionElicitIntent | LexDialogActionElicitSlot | LexDialogActionConfirmIntent | LexDialogActionDelegate;
|
||||
|
||||
export interface LexResult {
|
||||
sessionAttributes?: { [key: string]: string };
|
||||
dialogAction: LexDialogAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* AWS Lambda handler function.
|
||||
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
|
||||
@@ -938,6 +1032,9 @@ export type ScheduledHandler = Handler<ScheduledEvent, void>;
|
||||
|
||||
// TODO: Alexa
|
||||
|
||||
export type LexHandler = Handler<LexEvent, LexResult>;
|
||||
export type LexCallback = Callback<LexResult>;
|
||||
|
||||
export type APIGatewayProxyHandler = Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
|
||||
export type APIGatewayProxyCallback = Callback<APIGatewayProxyResult>;
|
||||
export type ProxyHandler = APIGatewayProxyHandler; // Old name
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import axios from "axios";
|
||||
import applyConverters from "axios-case-converter";
|
||||
|
||||
applyConverters(); // $ExpectError
|
||||
|
||||
applyConverters(axios.create()); // $ExpectType AxiosInstance
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for axios-case-converter 0.3
|
||||
// Project: https://github.com/mpyw/axios-case-converter
|
||||
// Definitions by: Derek Kniffin <https://github.com/dkniffin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
import { AxiosInstance } from "axios";
|
||||
|
||||
export default function applyConverters(axios: AxiosInstance): AxiosInstance;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"fastify": ">=1.13.1 || 2.0.0-rc.1"
|
||||
"axios": "^0.16.1"
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"axios-case-converter-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -80,3 +80,14 @@ nh.wns.send('tag', '<payload></payload>', 'wns/toast', { headers: {} }, Response
|
||||
nh.wns.sendToastText01('tag', '<payload></payload>', ResponseCallback);
|
||||
nh.wns.sendToastText01(['tag'], '<payload></payload>', ResponseCallback);
|
||||
nh.wns.sendToastText01('tag', '<payload></payload>', { headers: {} }, ResponseCallback);
|
||||
nh.createOrUpdateInstallation({
|
||||
"installationId":"123-123-123-123",
|
||||
"platform":"gcm",
|
||||
"pushChannel":"aXhytc4zD=",
|
||||
}, () => {});
|
||||
nh.createOrUpdateInstallation({
|
||||
installationId:"123-123-123-123",
|
||||
platform:"gcm",
|
||||
pushChannel:"aXhytc4zD=",
|
||||
tags:["tag1","tag2"]
|
||||
}, {}, () => {});
|
||||
Vendored
+26
@@ -140,6 +140,32 @@ export namespace Azure.ServiceBus {
|
||||
WnsHeaders?: any;
|
||||
}
|
||||
|
||||
export interface NotificationHubInstallation {
|
||||
installationId: string;
|
||||
readonly lastActiveOn?: string;
|
||||
readonly expirationTime?: string;
|
||||
readonly lastUpdate?: string;
|
||||
platform: "apns" | "wns" | "mpns" | "adm" | "gcm";
|
||||
pushChannel: string;
|
||||
readonly expiredPushChannel?: string;
|
||||
tags?: Array<string>;
|
||||
templates?: {
|
||||
[name: string]: {
|
||||
body: string;
|
||||
headers?: any;
|
||||
expiry?: string;
|
||||
tags?: Array<string>;
|
||||
};
|
||||
};
|
||||
secondaryTile?: {
|
||||
[titleId: string]: {
|
||||
pushChannel: string;
|
||||
tags?: Array<string>;
|
||||
templates?: any;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
body: Dictionary<string | object>;
|
||||
headers: Dictionary<string>;
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import { Azure } from 'azure-sb';
|
||||
import Callback = Azure.ServiceBus.ResponseCallback;
|
||||
import NotificationHubRegistration = Azure.ServiceBus.NotificationHubRegistration;
|
||||
import ListNotificationHubsOptions = Azure.ServiceBus.ListNotificationHubsOptions;
|
||||
import NotificationHubInstallation = Azure.ServiceBus.NotificationHubInstallation;
|
||||
|
||||
import ApnsService = require('./apnsservice');
|
||||
import GcmService = require('./gcmservice');
|
||||
@@ -29,10 +30,10 @@ declare class NotificationHubService {
|
||||
options: { headers: object },
|
||||
callback: Callback): void;
|
||||
|
||||
public createOrUpdateInstallation(installation: string,
|
||||
public createOrUpdateInstallation(installation: NotificationHubInstallation,
|
||||
callback: Callback): void;
|
||||
|
||||
public createOrUpdateInstallation(installation: string,
|
||||
public createOrUpdateInstallation(installation: NotificationHubInstallation,
|
||||
options: any,
|
||||
callback: Callback): void;
|
||||
|
||||
|
||||
@@ -150,3 +150,8 @@ const VisitorStateTest: Visitor<SomeVisitorState> = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const VisitorAliasTest: Visitor = {
|
||||
Function() {},
|
||||
Expression() {},
|
||||
};
|
||||
|
||||
Vendored
+2
@@ -145,6 +145,8 @@ export class Binding {
|
||||
|
||||
export type Visitor<S = {}> = VisitNodeObject<S, Node> & {
|
||||
[Type in Node["type"]]?: VisitNode<S, Extract<Node, { type: Type; }>>;
|
||||
} & {
|
||||
[K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>
|
||||
};
|
||||
|
||||
export type VisitNode<S, P> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0"
|
||||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -34,7 +34,7 @@ declare module 'backbone' {
|
||||
|
||||
fetchRelated(key:string, options?:any, update?:boolean):any;
|
||||
|
||||
toJSON():any;
|
||||
toJSON(options?: any):any;
|
||||
|
||||
static setup();
|
||||
|
||||
|
||||
@@ -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
|
||||
});
|
||||
Vendored
+55
@@ -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;
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import beeper = require('beeper');
|
||||
|
||||
beeper();
|
||||
beeper(3);
|
||||
beeper(3, () => {});
|
||||
beeper('****-*-*');
|
||||
beeper('****-*-*', () => {});
|
||||
Vendored
+9
@@ -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;
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -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;
|
||||
|
||||
@@ -69,3 +69,12 @@ trans.default('name');
|
||||
trans.deferred('name');
|
||||
trans.immediate('name');
|
||||
trans.exclusive('name');
|
||||
|
||||
const transTyped = db.transaction((param: number) => stmt.all(param));
|
||||
transTyped(1);
|
||||
trans.default(1);
|
||||
trans.deferred(1);
|
||||
trans.immediate(1);
|
||||
trans.exclusive(1);
|
||||
// $ExpectError
|
||||
transTyped('name');
|
||||
|
||||
Vendored
+15
-8
@@ -4,10 +4,17 @@
|
||||
// Mathew Rumsey <https://github.com/matrumz>
|
||||
// Santiago Aguilar <https://github.com/sant123>
|
||||
// Alessandro Vergani <https://github.com/loghorn>
|
||||
// Andrew Kaiser <https://github.com/andykais>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import Integer = require("integer");
|
||||
|
||||
type VariableArgFunction = (...params: any[]) => any;
|
||||
type ArgumentTypes<F extends VariableArgFunction> = F extends (...args: infer A) => any
|
||||
? A
|
||||
: never;
|
||||
|
||||
declare namespace BetterSqlite3 {
|
||||
interface Statement {
|
||||
database: Database;
|
||||
@@ -34,12 +41,12 @@ declare namespace BetterSqlite3 {
|
||||
type: string | null;
|
||||
}
|
||||
|
||||
interface Transaction {
|
||||
(...params: any[]): any;
|
||||
default(...params: any[]): any;
|
||||
deferred(...params: any[]): any;
|
||||
immediate(...params: any[]): any;
|
||||
exclusive(...params: any[]): any;
|
||||
interface Transaction<F extends VariableArgFunction> {
|
||||
(...params: ArgumentTypes<F>): any;
|
||||
default(...params: ArgumentTypes<F>): any;
|
||||
deferred(...params: ArgumentTypes<F>): any;
|
||||
immediate(...params: ArgumentTypes<F>): any;
|
||||
exclusive(...params: ArgumentTypes<F>): any;
|
||||
}
|
||||
|
||||
interface Database {
|
||||
@@ -50,7 +57,7 @@ declare namespace BetterSqlite3 {
|
||||
inTransaction: boolean;
|
||||
|
||||
prepare(source: string): Statement;
|
||||
transaction(fn: (...params: any[]) => any): Transaction;
|
||||
transaction<F extends VariableArgFunction>(fn: F): Transaction<F>;
|
||||
exec(source: string): this;
|
||||
pragma(source: string, options?: Database.PragmaOptions): any;
|
||||
checkpoint(databaseName?: string): this;
|
||||
@@ -113,7 +120,7 @@ declare namespace Database {
|
||||
type SqliteError = typeof SqliteError;
|
||||
type Statement = BetterSqlite3.Statement;
|
||||
type ColumnDefinition = BetterSqlite3.ColumnDefinition;
|
||||
type Transaction = BetterSqlite3.Transaction;
|
||||
type Transaction = BetterSqlite3.Transaction<VariableArgFunction>;
|
||||
type Database = BetterSqlite3.Database;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -17,6 +17,7 @@ export class BIP32 {
|
||||
|
||||
identifier: Buffer;
|
||||
fingerprint: Buffer;
|
||||
chainCode: Buffer;
|
||||
privateKey: Buffer;
|
||||
publicKey: Buffer;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Vendored
+88
-31
@@ -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,11 @@
|
||||
import { enableBodyScroll, disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
|
||||
|
||||
const dom: HTMLDivElement = new HTMLDivElement();
|
||||
|
||||
disableBodyScroll(dom, {
|
||||
reserveScrollBarGap: false,
|
||||
});
|
||||
|
||||
enableBodyScroll(dom);
|
||||
|
||||
clearAllBodyScrollLocks();
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for body-scroll-lock 2.6
|
||||
// Project: https://github.com/willmcpo/body-scroll-lock
|
||||
// Definitions by: kimcoder <https://github.com/kimcoder>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface BodyScrollOptions {
|
||||
reserveScrollBarGap?: boolean;
|
||||
allowTouchMove?: (el: HTMLElement) => void;
|
||||
}
|
||||
|
||||
export function disableBodyScroll(targetElement: HTMLElement, options?: BodyScrollOptions): void;
|
||||
export function enableBodyScroll(targetElement: HTMLElement): void;
|
||||
export function clearAllBodyScrollLocks(): void;
|
||||
|
||||
export as namespace bodyScrollLock;
|
||||
@@ -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",
|
||||
"body-scroll-lock-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,77 @@
|
||||
$(() => {
|
||||
$('#cp1').colorpicker();
|
||||
|
||||
$('#cp2').colorpicker();
|
||||
|
||||
$('#cp3').colorpicker({
|
||||
color: '#AA3399',
|
||||
format: 'rgb'
|
||||
});
|
||||
|
||||
$('#cp4').colorpicker().on('changeColor', (e) => {
|
||||
$('body')[0].style.backgroundColor = e.color.toString('rgba');
|
||||
});
|
||||
|
||||
$('#cp5').colorpicker({
|
||||
color: "transparent",
|
||||
format: "hex"
|
||||
});
|
||||
|
||||
$('#cp6').colorpicker({
|
||||
color: "#88cc33",
|
||||
horizontal: true
|
||||
});
|
||||
|
||||
$('#cp7').colorpicker({
|
||||
color: '#ffaa00',
|
||||
container: true,
|
||||
inline: true
|
||||
});
|
||||
|
||||
$('#cp8').colorpicker({
|
||||
colorSelectors: {
|
||||
black: '#000000',
|
||||
white: '#ffffff',
|
||||
red: '#FF0000',
|
||||
default: '#777777',
|
||||
primary: '#337ab7',
|
||||
success: '#5cb85c',
|
||||
info: '#5bc0de',
|
||||
warning: '#f0ad4e',
|
||||
danger: '#d9534f'
|
||||
}
|
||||
});
|
||||
|
||||
$('#cp9').colorpicker({
|
||||
customClass: 'colorpicker-2x',
|
||||
sliders: {
|
||||
saturation: {
|
||||
maxLeft: 200,
|
||||
maxTop: 200
|
||||
},
|
||||
hue: {
|
||||
maxTop: 200
|
||||
},
|
||||
alpha: {
|
||||
maxTop: 200
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('.disable-button').click((e) => {
|
||||
e.preventDefault();
|
||||
|
||||
$('#cp10').colorpicker('disable');
|
||||
});
|
||||
|
||||
$('.enable-button').click((e) => {
|
||||
e.preventDefault();
|
||||
|
||||
$('#cp10').colorpicker('enable');
|
||||
});
|
||||
|
||||
$('#cp10').colorpicker();
|
||||
|
||||
|
||||
$('#cp11').colorpicker();
|
||||
});
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
// Type definitions for bootstrap-colorpicker 2.5
|
||||
// Project: https://github.com/farbelous/bootstrap-colorpicker/tree/v2.x
|
||||
// Definitions by: Aleksandar Manukov <https://github.com/aleksandar-manukov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
type ColorFormat = 'hex' | 'rgb' | 'rgba';
|
||||
|
||||
type ColorPickerAlignOptions = 'right' | 'left';
|
||||
|
||||
type ColorPickerEvents = 'create' |
|
||||
'showPicker' |
|
||||
'hidePicker' |
|
||||
'changeColor' |
|
||||
'disable' |
|
||||
'enable' |
|
||||
'destroy';
|
||||
|
||||
/**
|
||||
* You can set colorpicker options either as a plugin parameter or data-* attributes
|
||||
*/
|
||||
interface ColorPickerOptions {
|
||||
/**
|
||||
* If not false, forces the color format to be hex, rgb or rgba, otherwise the format is automatically detected.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
format?: ColorFormat;
|
||||
|
||||
/**
|
||||
* If not false, sets the color to this value.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
color?: string;
|
||||
|
||||
/**
|
||||
* If not false, the picker will be contained inside this element, otherwise it will be appended to the document body.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
container?: boolean;
|
||||
|
||||
/**
|
||||
* Children selector for the component or element that trigger the colorpicker and which background color will change (needs an inner <i> element).
|
||||
*
|
||||
* Default: '.add-on, .input-group-addon'
|
||||
*/
|
||||
component?: string | JQuery;
|
||||
|
||||
/**
|
||||
* Children selector for the input that will store the picker selected value.
|
||||
*
|
||||
* Default: 'input'
|
||||
*/
|
||||
input?: string | JQuery;
|
||||
|
||||
/**
|
||||
* If true, put a '#' (number sign) before hex strings.
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
hexNumberSignPrefix?: boolean;
|
||||
|
||||
/**
|
||||
* If true, the hue and alpha channel bars will be rendered horizontally, above the saturation selector.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
horizontal?: boolean;
|
||||
|
||||
/**
|
||||
* If true, forces to show the colorpicker as an inline element.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
inline?: boolean;
|
||||
|
||||
/**
|
||||
* Vertical sliders configuration (read source code if you really need to tweak this).
|
||||
*/
|
||||
sliders?: object;
|
||||
|
||||
/**
|
||||
* Horizontal sliders configuration (read source code if you really need to tweak this).
|
||||
*/
|
||||
slidersHorz?: object;
|
||||
|
||||
/**
|
||||
* Customizes the default colorpicker HTML template.
|
||||
*/
|
||||
template?: string;
|
||||
|
||||
/**
|
||||
* By default, the colorpicker is aligned to the right of the input. If you need to switch it to the left, set align to 'left'.
|
||||
*
|
||||
* Default: 'right'
|
||||
*/
|
||||
align?: ColorPickerAlignOptions;
|
||||
|
||||
/**
|
||||
* Adds this class to the colorpicker widget.
|
||||
*
|
||||
* Default: null
|
||||
*/
|
||||
customClass?: string;
|
||||
|
||||
/**
|
||||
* List of pre selected colors (hex format). If you choose one of these colors, the alias is returned instead of the hex code.
|
||||
*
|
||||
* Default: null
|
||||
*/
|
||||
colorSelectors?: object;
|
||||
|
||||
/**
|
||||
* Fallback color string that will be applied when the color failed to be parsed. If null, it will keep the current color if any.
|
||||
*
|
||||
* Default: null
|
||||
*/
|
||||
fallbackColor?: string;
|
||||
|
||||
/**
|
||||
* Fallback color format (e.g. when not specified or for alias mode, when selecting non aliased colors)
|
||||
*
|
||||
* Default: hex
|
||||
*/
|
||||
fallbackFormat?: string;
|
||||
}
|
||||
|
||||
interface Color {
|
||||
colors: {};
|
||||
fallbackFormat: string;
|
||||
fallbackValue: string;
|
||||
hexNumberSignPrefix: boolean;
|
||||
origFormat: string;
|
||||
predefinedColors: {};
|
||||
value: {
|
||||
h: number;
|
||||
s: number;
|
||||
b: number;
|
||||
a: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a new color. The value is parsed and tries to do a quess on the format.
|
||||
*/
|
||||
setColor(value: string): void;
|
||||
|
||||
/**
|
||||
* Set the HUE with a value between 0 and 1.
|
||||
*/
|
||||
setHue(value: number): void;
|
||||
|
||||
/**
|
||||
* Set the saturation with a value between 0 and 1.
|
||||
*/
|
||||
setSaturation(value: number): void;
|
||||
|
||||
/**
|
||||
* Set the brightness with a value between 0 and 1.
|
||||
*/
|
||||
setBrightness(value: number): void;
|
||||
|
||||
/**
|
||||
* Set the transparency with a value between 0 and 1.
|
||||
*/
|
||||
setAlpha(value: number): void;
|
||||
|
||||
/**
|
||||
* Returns a hash with red, green, blue and alpha.
|
||||
*/
|
||||
toRGB(): string;
|
||||
|
||||
/**
|
||||
* Returns a string with HEX format for the current color.
|
||||
*/
|
||||
toHex(): string;
|
||||
|
||||
/**
|
||||
* Returns a hash with HSLA values.
|
||||
*/
|
||||
toHSL(): string;
|
||||
|
||||
/**
|
||||
* Returns current color as string in specified format.
|
||||
*/
|
||||
toString(format: ColorFormat): string;
|
||||
}
|
||||
|
||||
interface ColorPicker {
|
||||
color: Color;
|
||||
component: boolean;
|
||||
container: boolean;
|
||||
disabled: boolean;
|
||||
element: JQuery;
|
||||
format: string;
|
||||
input: JQuery;
|
||||
options: ColorPickerOptions;
|
||||
picker: JQuery;
|
||||
}
|
||||
|
||||
interface ColorPickerEventObject extends JQueryEventObject {
|
||||
color: Color;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
/**
|
||||
* Initializes an colorpicker.
|
||||
*/
|
||||
colorpicker(options?: ColorPickerOptions): JQuery;
|
||||
|
||||
/**
|
||||
* Gets the value from the input or the data attribute (if has no input), otherwise returns the default value, which defaults to #000000 if not specified.
|
||||
*/
|
||||
colorpicker(methodName: 'getValue', defaultValue: string): string;
|
||||
|
||||
/**
|
||||
* Set a new value for the color picker (also updates everything). Triggers 'changeColor' event.
|
||||
*/
|
||||
colorpicker(methodName: 'setValue', value: any): any;
|
||||
|
||||
/**
|
||||
* Show the color picker
|
||||
*/
|
||||
colorpicker(methodName: 'show'): void;
|
||||
|
||||
/**
|
||||
* Hide the color picker
|
||||
*/
|
||||
colorpicker(methodName: 'hide'): void;
|
||||
|
||||
/**
|
||||
* Updates the color picker's position relative to the element
|
||||
*/
|
||||
colorpicker(methodName: 'reposition'): void;
|
||||
|
||||
/**
|
||||
* Refreshes the widget colors (this is done automatically)
|
||||
*/
|
||||
colorpicker(methodName: 'update'): void;
|
||||
|
||||
/**
|
||||
* Enable the color picker.
|
||||
*/
|
||||
colorpicker(methodName: 'enable'): void;
|
||||
|
||||
/**
|
||||
* Disable the color picker.
|
||||
*/
|
||||
colorpicker(methodName: 'disable'): void;
|
||||
|
||||
/**
|
||||
* Destroys the colorpicker widget and unbind all .colorpicker events from the element and component
|
||||
*/
|
||||
colorpicker(methodName: 'destroy'): void;
|
||||
|
||||
/**
|
||||
* Access to the colorpicker API directly
|
||||
*/
|
||||
data(methodName: 'colorpicker'): ColorPicker;
|
||||
|
||||
off(events: ColorPickerEvents, selector?: string, handler?: (event: ColorPickerEventObject) => any): JQuery;
|
||||
off(events: ColorPickerEvents, handler: (event: ColorPickerEventObject) => any): JQuery;
|
||||
|
||||
on(events: ColorPickerEvents, selector: string, data: any, handler?: (event: ColorPickerEventObject) => any): JQuery;
|
||||
on(events: ColorPickerEvents, selector: string, handler: (event: ColorPickerEventObject) => any): JQuery;
|
||||
on(events: ColorPickerEvents, handler: (event: ColorPickerEventObject) => any): JQuery;
|
||||
}
|
||||
@@ -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",
|
||||
"bootstrap-colorpicker-tests.ts"
|
||||
]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user