diff --git a/notNeededPackages.json b/notNeededPackages.json index 6c4e1ce887..cf5c9449d7 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -636,6 +636,12 @@ "sourceRepoURL": "https://github.com/mikedeboer/node-github", "asOfVersion": "7.1.0" }, + { + "libraryName": "gitlab", + "typingsPackageName": "gitlab", + "sourceRepoURL": "https://github.com/jdalrymple/node-gitlab", + "asOfVersion": "2.0.0" + }, { "libraryName": "graphene-pk11", "typingsPackageName": "graphene-pk11", diff --git a/types/auth0/index.d.ts b/types/auth0/index.d.ts index ed0e9d1f3f..39d9d36fd7 100644 --- a/types/auth0/index.d.ts +++ b/types/auth0/index.d.ts @@ -4,8 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as Promise from 'bluebird'; - export interface ManagementClientOptions { token?: string; domain: string; diff --git a/types/await-timeout/await-timeout-tests.ts b/types/await-timeout/await-timeout-tests.ts new file mode 100644 index 0000000000..96dcdefdee --- /dev/null +++ b/types/await-timeout/await-timeout-tests.ts @@ -0,0 +1,131 @@ +import Timeout from "await-timeout"; + +/** + * This test is just a TS-friendly version of the await-timeout README: + * https://github.com/vitalets/await-timeout/blob/v0.3.0/README.md + * + * How to generate this file: + * 1. Paste the source code of README.md + * 2. Replace every code fence with async () => {} + * 3. Comment out all other lines + * 4. Add and remove import statements and repeated statements + * 5. Declare required globals + */ + +// -- Globals -- +declare const fetch: (url: string) => Promise; +declare const console: any; +declare const MyTimeoutError: any; + +// --- README --- + +// ## Usage +// 1. Just wait some time: +async () => { + // wait 1000 ms and resolve + await Timeout.set(1000); + + // wait 1000 ms and reject with 'Error' + await Timeout.set(1000, 'Error'); +}; + +// 2. Use `Timeout` instance inside `try...finally` block to make proper cleanup: +async () => { + const timer = new Timeout(); + try { + await Promise.race([ + fetch('https://example.com'), + timer.set(1000) + .then(() => Promise.reject('Timeout')) + ]); + } finally { + timer.clear(); + } +}; + +// ## API +// ### new Timeout() +// Constructs new timeout instance. It does not start timer but creates variable for timer manipulation. +async () => { + const timer = new Timeout(); +}; +// > Note : having separate variable is useful for clearing timeout in `finally` block + +// ### .set(ms, [message]) ⇒ `Promise` +// Starts new timer like `setTimeout()` and returns promise. The promise will be resolved after `ms` milliseconds: +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => console.log('1000 ms passed.')); +}; + +// If you need to reject after timeout: +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => {throw new Error('Timeout'); }); +}; + +// Or reject with custom error: +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => {throw new MyTimeoutError(); }); +}; +// The second parameter `message` is just convenient way to reject with `new Error(message)`: +async () => { + const timer = new Timeout(); + timer.set(1000, 'Timeout'); + // is equivalent to + timer.set(1000).then(() => {throw new Error('Timeout'); }); +}; + +// If you need to just wait some time - use static version of `.set()` : +async () => { + Timeout.set(1000).then(/*...*/); +}; + +// ### .wrap(promise, ms, [message]) ⇒ `Promise` +// Wraps existing promise with timeout: +// * promise automatically rejected after timeout +// * timeout automatically cleared if promise fulfills first +async () => { + const promise = fetch('https://example.com'); + + const timeoutedPromise = Timeout.wrap(promise, 1000, 'Timeout'); +}; +// Actually it is a shortcut for : +async () => { + const promise = fetch('https://example.com'); + + const timer = new Timeout(); + try { + const timeoutedPromise = await Promise.race([ + promise, + timer.set(1000, 'Timeout') + ]); + } finally { + timer.clear(); + } +}; + +// ### .clear() +// Clears existing timeout like `clearTimeout()`. +async () => { + const timer = new Timeout(); + timer.set(1000) + .then(() => console.log('This will never be called, because timeout is cleared on the next line')); + timer.clear(); +}; + +// With [ES7 async / await ] `.clear()` can be used in `finally` block: +async () => { + async function foo() { + const timer = new Timeout(); + try { + // some async stuff + } finally { + timer.clear(); + } + } +}; diff --git a/types/await-timeout/index.d.ts b/types/await-timeout/index.d.ts new file mode 100644 index 0000000000..ce202c6024 --- /dev/null +++ b/types/await-timeout/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for await-timeout 0.3 +// Project: https://github.com/vitalets/await-timeout +// Definitions by: Sean Zhu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export default Timeout; + +declare class Timeout { + static set(delay: number): Promise; + static set(delay: number, message: string): Promise; + + static wrap(promise: Promise, delay: number, error?: string): Promise; + + set(delay: number): Promise; + set(delay: number, message: string): Promise; + clear(): void; +} diff --git a/types/await-timeout/tsconfig.json b/types/await-timeout/tsconfig.json new file mode 100644 index 0000000000..2ecb27e688 --- /dev/null +++ b/types/await-timeout/tsconfig.json @@ -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", + "await-timeout-tests.ts" + ] +} diff --git a/types/await-timeout/tslint.json b/types/await-timeout/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/await-timeout/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/code/code-tests.ts b/types/code/code-tests.ts index 9e5f12645f..f9b55ca72e 100644 --- a/types/code/code-tests.ts +++ b/types/code/code-tests.ts @@ -103,6 +103,7 @@ expect("abcd").to.have.length(4); expect(5).to.equal(5); expect({ a: 1 }).to.equal({ a: 1 }); +expect([1, 2, 3]).to.equal([1, 2, 3]); expect(Object.create(null)).to.equal({}, { prototype: false }); diff --git a/types/code/index.d.ts b/types/code/index.d.ts index 3bdca4be9a..7047fc0702 100644 --- a/types/code/index.d.ts +++ b/types/code/index.d.ts @@ -125,9 +125,9 @@ export interface Values { /** Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys. */ length(size: number): AssertionChain; /** Asserts that the reference value equals the provided value. */ - equal(value: T, options?: any): AssertionChain; + equal(value: T | T[], options?: any): AssertionChain; /** Asserts that the reference value equals the provided value. */ - equals(value: T, options?: any): AssertionChain; + equals(value: T | T[], options?: any): AssertionChain; /** Asserts that the reference value is greater than (>) the provided value. */ above(value: T): AssertionChain; /** Asserts that the reference value is greater than (>) the provided value. */ diff --git a/types/cookie/index.d.ts b/types/cookie/index.d.ts index bb7fc2cb54..cb03c91980 100644 --- a/types/cookie/index.d.ts +++ b/types/cookie/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cookie 0.3 // Project: https://github.com/jshttp/cookie -// Definitions by: Pine Mizune +// Definitions by: Pine Mizune // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface CookieSerializeOptions { diff --git a/types/country-list/country-list-tests.ts b/types/country-list/country-list-tests.ts index d96fe630e2..50952d2a87 100644 --- a/types/country-list/country-list-tests.ts +++ b/types/country-list/country-list-tests.ts @@ -1,5 +1,4 @@ -import countries from 'country-list'; -const Countries = countries(); +import * as Countries from 'country-list'; Countries.getCode('Barbados'); // BB @@ -14,3 +13,5 @@ Countries.getName('BB'); // Barbados Countries.getNameList(); Countries.getNames(); + +Countries.overwrite([{ code: 'TW', name: 'Taiwan' }]); diff --git a/types/country-list/index.d.ts b/types/country-list/index.d.ts index 6c1747ff2a..ac3c80c9d5 100644 --- a/types/country-list/index.d.ts +++ b/types/country-list/index.d.ts @@ -1,41 +1,45 @@ -// Type definitions for country-list 1.1 +// Type definitions for country-list 2.1 // Project: https://github.com/fannarsh/country-list // Definitions by: Kyle Roach +// Adam Binford // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default function Countries(): { - /** - * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. - */ - getName(code: string): string | undefined; +/** + * Expects an array of code and country name pairs to add to the list. Doesn't return anything. + */ +export function overwrite(countries: Array<{ code: string, name: string}>): void; - /** - * Expects the English country name. Returns the code for that country. If not found, it returns undefined. - */ - getCode(name: string): string | undefined; +/** + * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. + */ +export function getName(code: string): string | undefined; - /** - * Returns an array of all country names. - */ - getNames(): string[]; +/** + * Expects the English country name. Returns the code for that country. If not found, it returns undefined. + */ +export function getCode(name: string): string | undefined; - /** - * Returns an array of all country codes. - */ - getCodes(): string[]; +/** + * Returns an array of all country names. + */ +export function getNames(): string[]; - /** - * Returns a key-value object of all countries using the name as key. - */ - getNameList(): {[name: string]: string}; +/** + * Returns an array of all country codes. + */ +export function getCodes(): string[]; - /** - * Returns a key-value object of all countries using the code as key. - */ - getCodeList(): {[code: string]: string}; +/** + * Returns a key-value object of all countries using the name as key. + */ +export function getNameList(): {[name: string]: string}; - /** - * Returns an array of all country information, in the same format as it gets imported. - */ - getData(): Array<{ code: string, name: string }>; -}; +/** + * Returns a key-value object of all countries using the code as key. + */ +export function getCodeList(): {[code: string]: string}; + +/** + * Returns an array of all country information, in the same format as it gets imported. + */ +export function getData(): Array<{ code: string, name: string }>; diff --git a/types/country-list/v1/country-list-tests.ts b/types/country-list/v1/country-list-tests.ts new file mode 100644 index 0000000000..d96fe630e2 --- /dev/null +++ b/types/country-list/v1/country-list-tests.ts @@ -0,0 +1,16 @@ +import countries from 'country-list'; +const Countries = countries(); + +Countries.getCode('Barbados'); // BB + +Countries.getCodes(); + +Countries.getCodeList(); + +Countries.getData(); + +Countries.getName('BB'); // Barbados + +Countries.getNameList(); + +Countries.getNames(); diff --git a/types/country-list/v1/index.d.ts b/types/country-list/v1/index.d.ts new file mode 100644 index 0000000000..e225845bde --- /dev/null +++ b/types/country-list/v1/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for country-list 1.1 +// Project: https://github.com/fannarsh/country-list +// Definitions by: Kyle Roach +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default function Countries(): { + /** + * Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined. + */ + getName(code: string): string | undefined; + + /** + * Expects the English country name. Returns the code for that country. If not found, it returns undefined. + */ + getCode(name: string): string | undefined; + + /** + * Returns an array of all country names. + */ + getNames(): string[]; + + /** + * Returns an array of all country codes. + */ + getCodes(): string[]; + + /** + * Returns a key-value object of all countries using the name as key. + */ + getNameList(): {[name: string]: string}; + + /** + * Returns a key-value object of all countries using the code as key. + */ + getCodeList(): {[code: string]: string}; + + /** + * Returns an array of all country information, in the same format as it gets imported. + */ + getData(): Array<{ code: string, name: string }>; +}; diff --git a/types/country-list/v1/tsconfig.json b/types/country-list/v1/tsconfig.json new file mode 100644 index 0000000000..f10adfdde5 --- /dev/null +++ b/types/country-list/v1/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "country-list": ["country-list/v1"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "country-list-tests.ts" + ] +} \ No newline at end of file diff --git a/types/country-list/v1/tslint.json b/types/country-list/v1/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/country-list/v1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/deps-sort/deps-sort-tests.ts b/types/deps-sort/deps-sort-tests.ts new file mode 100644 index 0000000000..e706edaefb --- /dev/null +++ b/types/deps-sort/deps-sort-tests.ts @@ -0,0 +1,31 @@ +import depsSort = require("deps-sort"); + +function browserifyTest(opts: depsSort.Options) { + const depsOpts: depsSort.Options = { + index: opts != null && opts.index, + dedupe: opts != null && opts.dedupe, + expose: opts.expose || { id: "file.txt" } + }; + + const res = depsSort(); // 'opts' are optional + res.pipe(depsSort(depsOpts)); + + res.once("error", (err: any) => { + console.error("module-deps error: ", err); + }); + + const inst: NodeJS.ReadWriteStream = depsSort({ + index: true, + expose: { id: "file.txt" } + }); + + inst.on("file", (file, id) => { + console.log("file", file, id); + }); + inst.on("package", (pkg) => { + console.log("package", pkg); + }); + inst.on("transform", (tr, file) => { + console.log("transform", tr, file); + }); +} diff --git a/types/deps-sort/index.d.ts b/types/deps-sort/index.d.ts new file mode 100644 index 0000000000..e32c826771 --- /dev/null +++ b/types/deps-sort/index.d.ts @@ -0,0 +1,85 @@ +// Type definitions for deps-sort 2.0 +// Project: https://github.com/browserify/deps-sort +// Definitions by: TeamworkGuy2 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as stream from "stream"; + +/** + * Return a new through stream that should get written module-deps objects and will output sorted objects. + */ +declare function depsSort(opts?: depsSort.Options): stream.Transform; + +/** + * Sort module-deps output for deterministic browserify bundles. + */ +declare namespace depsSort { + /** + * module-deps constructor options + */ + interface Options { + /** + * When true, for each module-deps row, insert 'row.index' with the numeric index and + * 'row.indexDeps' like 'row.deps' but mapping require strings to row indices + */ + index?: boolean; + + /** + * array of names or object mapping names to true not to mangle with integer indexes when 'index' is turned on. + * If 'expose' maps names to strings, those strings will be used to resolve the indexed references. + */ + expose?: string[] | { [name: string]: boolean | string }; + + /** + * Set 'row.dedupe' for files that match existing contents. Sets 'row.dedupeIndex' when 'index' is enabled. + * When 'row.dedupe' is set, 'row.sameDeps' will be set to a boolean of whether the dependencies at the dedupe target match (true) or just the source content (false). + */ + dedupe?: boolean; + + [prop: string]: any; + } + + /** + * Input objects are file objects in the module-deps shape. They must at least have these properties: + */ + interface InputRow { + /** + * a unique identifier for the file + */ + id: string; + /** + * the file contents + */ + source: string; + /** + * dependencies for this file, mapping strings as used in require() to row IDs + */ + deps: string[]; + } + + /** + * All the input properties, and: + */ + interface OutputRow { + /** + * when 'opts.index' is true, the sorted numeric index of the row + */ + index: number; + /** + * like 'row.deps', but mapping to 'row.index' instead of 'row.id' + */ + indexDeps: { [id: string]: number }; + /** + * when 'opts.dedupe' is true, contains the row ID of a file with identical contents + */ + dedupe: string; + /** + * like 'row.dedupe', but contains the 'row.index' instead of 'row.id' + */ + dedupeIndex: number; + } +} + +export = depsSort; diff --git a/types/gitlab/tsconfig.json b/types/deps-sort/tsconfig.json similarity index 93% rename from types/gitlab/tsconfig.json rename to types/deps-sort/tsconfig.json index f1297faf67..15871fb95e 100644 --- a/types/gitlab/tsconfig.json +++ b/types/deps-sort/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "gitlab-tests.ts" + "deps-sort-tests.ts" ] -} +} \ No newline at end of file diff --git a/types/deps-sort/tslint.json b/types/deps-sort/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/deps-sort/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/dplayer/index.d.ts b/types/dplayer/index.d.ts index a8fbd9e162..38cf0e4e54 100644 --- a/types/dplayer/index.d.ts +++ b/types/dplayer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dplayer 1.24 +// Type definitions for dplayer 1.25 // Project: https://github.com/DIYgod/DPlayer#readme // Definitions by: Guanyunhan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -9,6 +9,7 @@ export type Preload = 'none' | 'metadata' | 'auto'; export type VideoType = 'auto' | 'hls' | 'flv' | 'dash' | 'webtorrent' | 'normal'; export type SubTitleType = 'webvtt' | 'ass'; export type DirectionType = 'top' | 'right' | 'bottom'; +export type FullScreenType = 'web' | 'browser'; export enum DPlayerEvents { abort = 'abort', @@ -98,12 +99,20 @@ export interface DPlayerHighLightItem { time: number; } +export interface DPlayerVideoQuality { + name: string; + url: string; + type?: string; +} + export interface DPlayerVideo { url: string; pic?: string; thumbnails?: string; type?: VideoType | string; customType?: any; + quality?: DPlayerVideoQuality[]; + defaultQuality?: number; } export interface DPlayerSubTitle { @@ -131,8 +140,31 @@ export interface DPlayerAPIBackend { send(endpoint: any, danmakuData: DPlayerDanmakuItem, callback: () => void): void; } +export interface Danmaku { + send(danmaku: DPlayerDanmakuItem, callback: () => void): void; + + draw(danmaku: DPlayerDanmakuItem): void; + + opacity(percentage: number): void; + + clear(): void; + + hide(): void; + + show(): void; +} + +export interface FullScreen { + request(type: FullScreenType): void; + + cancel(type: FullScreenType): void; +} + export default class DPlayer { events: any; + video: HTMLVideoElement; + danmaku: Danmaku; + fullScreen: FullScreen; constructor(options: DPlayerOptions); diff --git a/types/dts-bundle/index.d.ts b/types/dts-bundle/index.d.ts index ffdbed678f..87be2e5c7d 100644 --- a/types/dts-bundle/index.d.ts +++ b/types/dts-bundle/index.d.ts @@ -8,15 +8,21 @@ interface Options { name: string; main: string; baseDir?: string; - exclude?: RegExp; - externals?: boolean; - indent?: string; - newLine?: string; out?: string; - prefix?: string; + externals?: boolean; + referenceExternals?: boolean; + exclude?: RegExp | ((file: string, external: boolean) => boolean); removeSource?: boolean; + newLine?: string; + indent?: string; + prefix?: string; separator?: string; verbose?: boolean; + emitOnIncludedFileNotFound?: boolean; + emitOnNoIncludedFileNotFound?: boolean; + outputAsModuleFolder?: boolean; + headerPath?: string; + headerText?: string; } export declare function bundle(opts: Options): void; diff --git a/types/element-resize-detector/index.d.ts b/types/element-resize-detector/index.d.ts index e2648dd311..1139efad8f 100644 --- a/types/element-resize-detector/index.d.ts +++ b/types/element-resize-detector/index.d.ts @@ -9,9 +9,34 @@ declare function elementResizeDetectorMaker(options?: elementResizeDetectorMaker declare namespace elementResizeDetectorMaker { interface ErdmOptions { strategy?: 'scroll' | 'object'; + /** + * A custom reporter that handles reporting logs, warnings and errors. + * If not provided, a default id handler will be used. + * If set to false, then nothing will be reported. + */ reporter?: ReporterProps; + + /** + * Determines if listeners should be called when they are getting added. + * If true, the listener is guaranteed to be called when it has been added. + * If false, the listener will not be guarenteed to be called when + * it has been added (does not prevent it from being called). + * + * @default true + */ callOnAdd?: boolean; + + /** + * A custom id handler that is responsible for generating, + * setting and retrieving id's for elements. + * If not provided, a default id handler will be used. + */ idHandler?: IdHandlerProps; + + /** + * If set to true, the the system will report debug messages as default + * for the listenTo method. + */ debug?: boolean; } @@ -21,9 +46,9 @@ declare namespace elementResizeDetectorMaker { } interface ReporterProps { - log(): void; - warn(): void; - error(): void; + log(idOrText: string, textOrId: string, element?: HTMLElement): void; + warn(text: string, element?: HTMLElement): void; + error(text: string): void; } interface Erd { diff --git a/types/ember/test/transition.ts b/types/ember/test/transition.ts index f06ee8865e..f6f3e0b4f0 100755 --- a/types/ember/test/transition.ts +++ b/types/ember/test/transition.ts @@ -11,7 +11,7 @@ Ember.Route.extend({ }); Ember.Controller.extend({ - previousTransition: null, + previousTransition: null as Transition | null, actions: { login() { diff --git a/types/ember/v2/index.d.ts b/types/ember/v2/index.d.ts index 93babaa0a7..54b6d2e4a9 100755 --- a/types/ember/v2/index.d.ts +++ b/types/ember/v2/index.d.ts @@ -1895,20 +1895,26 @@ declare module 'ember' { paramsFor(name: string): {}; /** - * Refresh the model on this route and any child routes, firing the - * `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - * to how routes are entered when transitioning in from other route. - * The current route params (e.g. `article_id`) will be passed in - * to the respective model hooks, and if a different model is returned, - * `setupController` and associated route hooks will re-fire as well. - * An example usage of this method is re-querying the server for the - * latest information using the same parameters as when the route - * was first entered. - * Note that this will cause `model` hooks to fire even on routes - * that were provided a model object when the route was initially - * entered. + * A hook you can implement to optionally redirect to another route. + * + * If you call `this.transitionTo` from inside of this hook, this route + * will not be entered in favor of the other hook. + * + * `redirect` and `afterModel` behave very similarly and are + * called almost at the same time, but they have an important + * distinction in the case that, from one of these hooks, a + * redirect into a child route of this route occurs: redirects + * from `afterModel` essentially invalidate the current attempt + * to enter this route, and will result in this route's `beforeModel`, + * `model`, and `afterModel` hooks being fired again within + * the new, redirecting transition. Redirects that occur within + * the `redirect` hook, on the other hand, will _not_ cause + * these hooks to be fired again the second time around; in + * other words, by the time the `redirect` hook has been called, + * both the resolved model and attempted entry into this route + * are considered to be fully validated. */ - redirect(): Transition; + redirect(model: {}, transition: Transition): void; /** * Refresh the model on this route and any child routes, firing the diff --git a/types/ember/v2/test/route.ts b/types/ember/v2/test/route.ts index 84e432dbd3..9ce18b410c 100755 --- a/types/ember/v2/test/route.ts +++ b/types/ember/v2/test/route.ts @@ -86,6 +86,14 @@ Route.extend({ }, }); +class RedirectRoute extends Route { + redirect(model: {}, a: Ember.Transition) { + if (!model) { + this.transitionTo('there'); + } + } +} + class RouteUsingClass extends Route.extend({ randomProperty: 'the .extend + extends bit type-checks properly', }) { diff --git a/types/ember/v2/test/transition.ts b/types/ember/v2/test/transition.ts index 3a64675c24..40057d9828 100755 --- a/types/ember/v2/test/transition.ts +++ b/types/ember/v2/test/transition.ts @@ -10,7 +10,7 @@ Ember.Route.extend({ }); Ember.Controller.extend({ - previousTransition: null, + previousTransition: null as Ember.Transition | null, actions: { login() { diff --git a/types/ember__routing/route.d.ts b/types/ember__routing/route.d.ts index 118bd1f1b5..30c9654be9 100644 --- a/types/ember__routing/route.d.ts +++ b/types/ember__routing/route.d.ts @@ -79,20 +79,26 @@ export default class Route extends EmberObject.extend(ActionHandler, Evented) { paramsFor(name: string): {}; /** - * Refresh the model on this route and any child routes, firing the - * `beforeModel`, `model`, and `afterModel` hooks in a similar fashion - * to how routes are entered when transitioning in from other route. - * The current route params (e.g. `article_id`) will be passed in - * to the respective model hooks, and if a different model is returned, - * `setupController` and associated route hooks will re-fire as well. - * An example usage of this method is re-querying the server for the - * latest information using the same parameters as when the route - * was first entered. - * Note that this will cause `model` hooks to fire even on routes - * that were provided a model object when the route was initially - * entered. + * A hook you can implement to optionally redirect to another route. + * + * If you call `this.transitionTo` from inside of this hook, this route + * will not be entered in favor of the other hook. + * + * `redirect` and `afterModel` behave very similarly and are + * called almost at the same time, but they have an important + * distinction in the case that, from one of these hooks, a + * redirect into a child route of this route occurs: redirects + * from `afterModel` essentially invalidate the current attempt + * to enter this route, and will result in this route's `beforeModel`, + * `model`, and `afterModel` hooks being fired again within + * the new, redirecting transition. Redirects that occur within + * the `redirect` hook, on the other hand, will _not_ cause + * these hooks to be fired again the second time around; in + * other words, by the time the `redirect` hook has been called, + * both the resolved model and attempted entry into this route + * are considered to be fully validated. */ - redirect(): Transition; + redirect(model: {}, transition: Transition): void; /** * Refresh the model on this route and any child routes, firing the diff --git a/types/ember__routing/test/route.ts b/types/ember__routing/test/route.ts index 7e2279d8c4..b347768301 100755 --- a/types/ember__routing/test/route.ts +++ b/types/ember__routing/test/route.ts @@ -80,6 +80,22 @@ Route.extend({ }, }); +class RedirectRoute extends Route { + redirect(model: {}, a: Transition) { + if (!model) { + this.transitionTo('there'); + } + } +} + +class InvalidRedirect extends Route { + redirect(model: {}, a: Transition, anOddArg: any) { // $ExpectError + if (!model) { + this.transitionTo('there'); + } + } +} + class ApplicationController extends Controller {} declare module '@ember/controller' { interface Registry { diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts index 2497d3b53d..84dc4f15e7 100644 --- a/types/firefox-webext-browser/index.d.ts +++ b/types/firefox-webext-browser/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for WebExtension Development in FireFox 63.0 +// Type definitions for WebExtension Development in FireFox 64.0 // Project: https://developer.mozilla.org/en-US/Add-ons/WebExtensions // Definitions by: Jasmin Bom // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -141,6 +141,9 @@ declare namespace browser._manifest { }; hidden?: boolean; theme_experiment?: ThemeExperiment; + user_scripts?: { + api_script?: ExtensionURL; + }; browser_action?: { default_title?: string; default_icon?: IconPath; @@ -163,8 +166,10 @@ declare namespace browser._manifest { instant_url?: string; /** @deprecated Unsupported on Firefox at this time. */ image_url?: string; - /** @deprecated Unsupported on Firefox at this time. */ + /** POST parameters to the search_url as a query string. */ search_url_post_params?: string; + /** POST parameters to the suggest_url as a query string. */ + suggest_url_post_params?: string; /** @deprecated Unsupported on Firefox at this time. */ instant_url_post_params?: string; /** @deprecated Unsupported on Firefox at this time. */ @@ -175,6 +180,22 @@ declare namespace browser._manifest { prepopulated_id?: number; /** Sets the default engine to a built-in engine only. */ is_default?: boolean; + /** + * A list of optional search url parameters. This allows the additon of search url parameters based on + * how the search is performed in Firefox. + */ + params?: Array<{ + /** A url parameter name */ + name: string; + /** The type of param can be either "purpose" or "pref". */ + condition?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition; + /** The preference to retreive the value from. */ + pref?: string; + /** The context that initiates a search, required if condition is "purpose". */ + purpose?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose; + /** A url parameter value. */ + value?: string; + }>; }; }; commands?: { @@ -202,6 +223,7 @@ declare namespace browser._manifest { browser_style?: boolean; show_matches?: MatchPattern[]; hide_matches?: MatchPatternRestricted[]; + pinned?: boolean; }; sidebar_action?: { default_title?: string; @@ -363,9 +385,6 @@ declare namespace browser._manifest { */ type MatchPatternUnestricted = string; - /** Same as MatchPattern above, but includes moz-extension protocol */ - type MatchPatternInternal = string | _MatchPatternInternal; - /** * Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be * set at the same time. Based on InjectDetails, but using underscore rather than camel case naming conventions. @@ -475,6 +494,7 @@ declare namespace browser._manifest { ntp_background?: ThemeColor; ntp_text?: ThemeColor; sidebar?: ThemeColor; + sidebar_border?: ThemeColor; sidebar_text?: ThemeColor; sidebar_highlight?: ThemeColor; sidebar_highlight_text?: ThemeColor; @@ -596,6 +616,7 @@ declare namespace browser._manifest { | "bookmarks" | "find" | "history" + | "menus.overrideContext" | "search" | "activeTab" | "tabs" @@ -632,6 +653,17 @@ declare namespace browser._manifest { | "tabstrip" | "personaltoolbar"; + /** The type of param can be either "purpose" or "pref". */ + type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition = "purpose" | "pref"; + + /** The context that initiates a search, required if condition is "purpose". */ + type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose = + "contextmenu" + | "searchbar" + | "homepage" + | "keyword" + | "newtab"; + type _ProtocolHandlerProtocol = "bitcoin" | "dat" @@ -661,8 +693,6 @@ declare namespace browser._manifest { type _MatchPattern = ""; - type _MatchPatternInternal = ""; - type _ThemeTypeAdditionalBackgroundsAlignment = "bottom" | "center" @@ -785,12 +815,6 @@ declare namespace browser.clipboard { /** Not allowed in: Content scripts, Devtools pages */ declare namespace browser.contentScripts { /* contentScripts types */ - type ExtensionFileOrCode = { - file: _manifest.ExtensionURL; - } | { - code: string; - }; - /** Details of a content script registered programmatically */ interface RegisteredContentScriptOptions { matches: _manifest.MatchPattern[]; @@ -798,9 +822,9 @@ declare namespace browser.contentScripts { includeGlobs?: string[]; excludeGlobs?: string[]; /** The list of CSS files to inject */ - css?: ExtensionFileOrCode[]; + css?: extensionTypes.ExtensionFileOrCode[]; /** The list of JS files to inject */ - js?: ExtensionFileOrCode[]; + js?: extensionTypes.ExtensionFileOrCode[]; /** * If allFrames is `true`, implies that the JavaScript or CSS should be injected into all frames of current * page. By default, it's `false` and is only injected into the top frame. @@ -1912,6 +1936,22 @@ declare namespace browser.extensionTypes { } type Date = string | number | object/*Date*/; + + type ExtensionFileOrCode = { + file: _manifest.ExtensionURL; + } | { + code: string; + }; + + /** A plain JSON value */ + type PlainJSONValue = null | string | number | boolean | _PlainJSONArray | _PlainJSONObject; + + interface _PlainJSONArray extends Array { + } + + interface _PlainJSONObject { + [key: string]: PlainJSONValue; + } } /** @@ -2403,7 +2443,7 @@ declare namespace browser.permissions { interface AnyPermissions { permissions?: _manifest.Permission[]; - origins?: _manifest.MatchPatternInternal[]; + origins?: _manifest.MatchPattern[]; } /* permissions functions */ @@ -2524,7 +2564,8 @@ declare namespace browser.privacy.websites { "allow_all" | "reject_all" | "reject_third_party" - | "allow_visited"; + | "allow_visited" + | "reject_trackers"; /* privacy.websites properties */ /** @@ -3456,6 +3497,64 @@ declare namespace browser.types { } } +/** + * Manifest keys: `user_scripts`, `user_scripts` + * + * Not allowed in: Devtools pages + */ +declare namespace browser.userScripts { + /* userScripts types */ + /** Details of a user script */ + interface UserScriptOptions { + /** The list of JS files to inject */ + js?: extensionTypes.ExtensionFileOrCode[]; + /** An opaque user script metadata value */ + scriptMetadata?: extensionTypes.PlainJSONValue; + matches: _manifest.MatchPattern[]; + excludeMatches?: _manifest.MatchPattern[]; + includeGlobs?: string[]; + excludeGlobs?: string[]; + /** + * If allFrames is `true`, implies that the JavaScript should be injected into all frames of current page. By + * default, it's `false` and is only injected into the top frame. + */ + allFrames?: boolean; + /** + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your + * extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default + * it is `false`. + */ + matchAboutBlank?: boolean; + /** The soonest that the JavaScript will be injected into the tab. Defaults to "document_idle". */ + runAt?: extensionTypes.RunAt; + } + + /** An object that represents a user script registered programmatically */ + interface RegisteredUserScript { + /** Unregister a user script registered programmatically */ + unregister(): Promise; + } + + /** A set of API methods provided by the extensions to its userScripts */ + interface ExportedAPIMethods { + [key: string]: (...args: any[]) => any; + } + + /* userScripts functions */ + /** + * Register a user script programmatically given its `userScripts.UserScriptOptions`, and resolves to a + * `userScripts.RegisteredUserScript` instance + */ + function register(userScriptOptions: UserScriptOptions): Promise; + + /** + * Provides a set of custom API methods available to the registered userScripts + * + * Allowed in: Content scripts only + */ + function setScriptAPIs(exportedAPIMethods: ExportedAPIMethods): void; +} + /** * Use the `browser.webNavigation` API to receive notifications about the status of navigation requests in-flight. * @@ -5302,9 +5401,8 @@ declare namespace browser.devtools.panels { /** * Sets an HTML page to be displayed in the sidebar pane. * @param path Relative path of an extension page to display within the sidebar. - * @deprecated Unsupported on Firefox at this time. */ - setPage?(path: string): void; + setPage(path: _manifest.ExtensionURL): Promise; /** * Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it. @@ -5706,6 +5804,8 @@ declare namespace browser.contextMenus { menuItemId: number | string; /** The parent ID, if any, for the item clicked. */ parentMenuItemId?: number | string; + /** The type of view where the menu is clicked. May be unset if the menu is not associated with a view. */ + viewType?: extension.ViewType; /** * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. */ @@ -5735,6 +5835,8 @@ declare namespace browser.contextMenus { bookmarkId: string; /** An array of keyboard modifiers that were held while the menu item was clicked. */ modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number; /** * An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the * corresponding element. @@ -5749,6 +5851,12 @@ declare namespace browser.contextMenus { | "Ctrl" | "MacCtrl"; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and + * 'tab' are supported. showDefaults cannot be used with this option. + */ + type _OverrideContextContext = "bookmark" | "tab"; + /* contextMenus properties */ /** * The maximum number of top level extension items that can be added to an extension action context menu. Any items @@ -5789,6 +5897,11 @@ declare namespace browser.contextMenus { checked?: boolean; /** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ contexts?: ContextType[]; + /** + * List of view types where the menu item will be shown. Defaults to any view, including those without a + * viewType. + */ + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -5827,9 +5940,13 @@ declare namespace browser.contextMenus { */ function update(id: number | string, updateProperties: { type?: ItemType; + icons?: { + [key: number]: string; + }; title?: string; checked?: boolean; contexts?: ContextType[]; + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -5853,6 +5970,24 @@ declare namespace browser.contextMenus { /** Removes all context menu items added by this extension. */ function removeAll(): Promise; + /** + * Show the matching menu items from this extension instead of the default menu. This should be called during a + * 'contextmenu' DOM event handler, and only applies to the menu that opens after this event. + */ + function overrideContext(contextOptions: { + /** Whether to also include default menu items in the menu. */ + showDefaults?: boolean; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' + * and 'tab' are supported. showDefaults cannot be used with this option. + */ + context?: _OverrideContextContext; + /** Required when context is 'bookmark'. Requires 'bookmark' permission. */ + bookmarkId?: string; + /** Required when context is 'tab'. Requires 'tabs' permission. */ + tabId?: number; + }): void; + /** * Updates the extension items in the shown menu, including changes that have been made since the menu was shown. * Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method @@ -5889,6 +6024,7 @@ declare namespace browser.contextMenus { menuIds: number | string[]; /** A list of all contexts that apply to the menu. */ contexts: ContextType[]; + viewType?: extension.ViewType; editable: boolean; mediaType?: string; linkUrl?: string; @@ -5947,6 +6083,8 @@ declare namespace browser.menus { menuItemId: number | string; /** The parent ID, if any, for the item clicked. */ parentMenuItemId?: number | string; + /** The type of view where the menu is clicked. May be unset if the menu is not associated with a view. */ + viewType?: extension.ViewType; /** * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. */ @@ -5976,6 +6114,8 @@ declare namespace browser.menus { bookmarkId: string; /** An array of keyboard modifiers that were held while the menu item was clicked. */ modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number; /** * An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the * corresponding element. @@ -5990,6 +6130,12 @@ declare namespace browser.menus { | "Ctrl" | "MacCtrl"; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and + * 'tab' are supported. showDefaults cannot be used with this option. + */ + type _OverrideContextContext = "bookmark" | "tab"; + /* menus properties */ /** * The maximum number of top level extension items that can be added to an extension action context menu. Any items @@ -6030,6 +6176,11 @@ declare namespace browser.menus { checked?: boolean; /** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */ contexts?: ContextType[]; + /** + * List of view types where the menu item will be shown. Defaults to any view, including those without a + * viewType. + */ + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -6068,9 +6219,13 @@ declare namespace browser.menus { */ function update(id: number | string, updateProperties: { type?: ItemType; + icons?: { + [key: number]: string; + }; title?: string; checked?: boolean; contexts?: ContextType[]; + viewTypes?: extension.ViewType[]; /** Whether the item is visible in the menu. */ visible?: boolean; /** @@ -6094,6 +6249,24 @@ declare namespace browser.menus { /** Removes all context menu items added by this extension. */ function removeAll(): Promise; + /** + * Show the matching menu items from this extension instead of the default menu. This should be called during a + * 'contextmenu' DOM event handler, and only applies to the menu that opens after this event. + */ + function overrideContext(contextOptions: { + /** Whether to also include default menu items in the menu. */ + showDefaults?: boolean; + /** + * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' + * and 'tab' are supported. showDefaults cannot be used with this option. + */ + context?: _OverrideContextContext; + /** Required when context is 'bookmark'. Requires 'bookmark' permission. */ + bookmarkId?: string; + /** Required when context is 'tab'. Requires 'tabs' permission. */ + tabId?: number; + }): void; + /** * Updates the extension items in the shown menu, including changes that have been made since the menu was shown. * Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method @@ -6130,6 +6303,7 @@ declare namespace browser.menus { menuIds: number | string[]; /** A list of all contexts that apply to the menu. */ contexts: ContextType[]; + viewType?: extension.ViewType; editable: boolean; mediaType?: string; linkUrl?: string; @@ -7108,6 +7282,13 @@ declare namespace browser.tabs { function highlight(highlightInfo: { /** The window that contains the tabs. */ windowId?: number; + /** + * If true, the `windows.Window` returned will have a `tabs` property that contains a list of the `tabs.Tab` + * objects. The `Tab` objects only contain the `url`, `title` and `favIconUrl` properties if the extension's + * manifest file includes the `"tabs"` permission. If false, the `windows.Window` won't have the `tabs` + * property. + */ + populate?: boolean; /** One or more tab indices to highlight. */ tabs: number[] | number; }): Promise; @@ -7632,6 +7813,8 @@ declare namespace browser.windows { state?: WindowState; /** Allow scripts to close the window. */ allowScriptsToClose?: boolean; + /** The CookieStoreId to use for all tabs that were created when the window is opened. */ + cookieStoreId?: string; /** A string to add to the beginning of the window title. */ titlePreface?: string; }): Promise; diff --git a/types/flowdoc/flowdoc-tests.ts b/types/flowdoc/flowdoc-tests.ts index 04b765f65c..0ebdb530da 100644 --- a/types/flowdoc/flowdoc-tests.ts +++ b/types/flowdoc/flowdoc-tests.ts @@ -1,13 +1,25 @@ +const TYPES = { + DOCUMENT: 'DOCUMENT', + PAGE: 'PAGE', + SCREEN: 'SCREEN', + IMAGE: 'IMAGE', + RECTANGLE: 'RECT', + ELLIPSE: 'ELLIPSE', + DIAMOND: 'DIAMOND', + HOTSPOT: 'HOTSPOT', + LAYER: 'LAYER', +} as Flow.Types; + const flowFile: Flow.File = { document: { id: 'cjo45613k00002a5p9gj6nr3b', name: 'Basic Document', - type: Flow.Type.Document, + type: TYPES.DOCUMENT, children: [ { id: 'cjo456d2700002a5p80zudiut', name: 'Page 1', - type: Flow.Type.Page, + type: TYPES.PAGE, backgroundColor: { r: 0, g: 0, @@ -18,7 +30,7 @@ const flowFile: Flow.File = { { id: 'cjo45mq7500002a5p8n8u1bfz', name: 'Sign in', - type: Flow.Type.Screen, + type: TYPES.SCREEN, source: { fileName: 'sign-in.png', dirPath: './assets', @@ -36,7 +48,7 @@ const flowFile: Flow.File = { { id: 'cjo45oi8700002a5pmpnxhfny', name: 'Sign up', - type: Flow.Type.Screen, + type: TYPES.SCREEN, source: { fileName: 'sign-up.png', dirPath: './assets', @@ -65,10 +77,10 @@ flowFile.settings = {}; flowFile.schemaVersion = 1; const document: Flow.Document = flowFile.document; -document.type = Flow.Type.Document; +document.type = TYPES.DOCUMENT; const page: Flow.Page = document.children[0]; -page.type = Flow.Type.Page; +page.type = TYPES.PAGE; page.backgroundColor = { r: 255, g: 255, @@ -79,7 +91,7 @@ page.backgroundColor = { const hotspot: Flow.Layer = { id: 'cjo5mezgg00003g5winhxc8o0', name: 'Layer', - type: Flow.Type.Hotspot, + type: TYPES.HOTSPOT, position: { x: 390, y: 390, @@ -92,10 +104,10 @@ const hotspot: Flow.Layer = { nodeID: 'cjo45mq7500002a5p8n8u1bfz', }], }; -hotspot.type = Flow.Type.Hotspot; +hotspot.type = TYPES.HOTSPOT; const screen = page.children[0] as Flow.Screen; -screen.type = Flow.Type.Screen; +screen.type = TYPES.SCREEN; screen.children.push(hotspot); screen.position = { x: 0, diff --git a/types/flowdoc/index.d.ts b/types/flowdoc/index.d.ts index 9e39a24384..8c32c6794c 100644 --- a/types/flowdoc/index.d.ts +++ b/types/flowdoc/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for flowdoc 1.0 +// Type definitions for flowdoc 1.1 // Project: https://github.com/overflowapp/Flow // Definitions by: Stefan Mansson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,42 +14,42 @@ declare namespace Flow { interface Document { id: string; name: string; - type: Type.Document; + type: Types['DOCUMENT']; children: Page[]; } interface Page extends Node { - type: Type.Page; - children: Array<(Screen | Image | Rectangle | Ellipse | Diamond)>; + type: Types['PAGE']; + children: Array; backgroundColor: Color; startNodeID?: string; } interface Screen extends Graphic { - type: Type.Screen; + type: Types['SCREEN']; children: Layer[]; connections?: Connection[]; } interface Image extends Graphic { - type: Type.Image; + type: Types['IMAGE']; connections?: Connection[]; } interface Rectangle extends Shape { - type: Type.Rectangle; + type: Types['RECTANGLE']; } interface Ellipse extends Shape { - type: Type.Ellipse; + type: Types['ELLIPSE']; } interface Diamond extends Shape { - type: Type.Diamond; + type: Types['DIAMOND']; } interface Layer extends Node { - type: Type.Layer | Type.Hotspot; + type: Types['LAYER'] | Types['HOTSPOT']; position: Point; size: Size; connections?: Connection[]; @@ -87,25 +87,27 @@ declare namespace Flow { w: number; } - const enum Type { - Document = 'DOCUMENT', - Page = 'PAGE', - Screen = 'SCREEN', - Image = 'IMAGE', - Rectangle = 'RECT', - Ellipse = 'ELLIPSE', - Diamond = 'DIAMOND', - Hotspot = 'HOTSPOT', - Layer = 'LAYER', + interface Types { + DOCUMENT: 'DOCUMENT'; + PAGE: 'PAGE'; + SCREEN: 'SCREEN'; + IMAGE: 'IMAGE'; + RECTANGLE: 'RECT'; + ELLIPSE: 'ELLIPSE'; + DIAMOND: 'DIAMOND'; + HOTSPOT: 'HOTSPOT'; + LAYER: 'LAYER'; } type SchemaVersion = 1; } +type NodeType = 'DOCUMENT' | 'PAGE' | 'SCREEN' | 'IMAGE' | 'RECT' | 'ELLIPSE' | 'DIAMOND' | 'HOTSPOT' | 'LAYER'; + interface Node { id: string; name: string; - type: Flow.Type; + type: NodeType; } interface Shape extends Node { diff --git a/types/flowdoc/tslint.json b/types/flowdoc/tslint.json index 3224b40b8b..1061428d6e 100644 --- a/types/flowdoc/tslint.json +++ b/types/flowdoc/tslint.json @@ -1,6 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "no-const-enum": false + "no-object-literal-type-assertion": false } } diff --git a/types/gitlab/ApiBase.d.ts b/types/gitlab/ApiBase.d.ts deleted file mode 100644 index 7187ce4352..0000000000 --- a/types/gitlab/ApiBase.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ApiBaseOptions } from './ApiBase'; -import { Labels } from './Models/Labels'; -import { Users } from './Models/Users'; -import { Notes } from './Models/Notes'; -import { Issues } from './Models/Issues'; -import { Projects } from './Models/Projects'; -import { Groups } from './Models/Groups'; - -export interface ApiBaseOptions { - url?: string; - token?: string; - oauth_token?: string; - base_url?: string; - auth?: any; - [key: string]: any; -} - -export class ApiBase { - constructor(options: ApiBaseOptions); - readonly client: this; - readonly groups: Groups - readonly projects: Projects - readonly issues: Issues - readonly notes: Notes - readonly users: Users - readonly labels: Labels - options: ApiBaseOptions; - - handleOptions(): void; - init(): object; -} diff --git a/types/gitlab/ApiBaseHTTP.d.ts b/types/gitlab/ApiBaseHTTP.d.ts deleted file mode 100644 index 7ed5fb0d69..0000000000 --- a/types/gitlab/ApiBaseHTTP.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ApiBase } from './ApiBase'; - -export class ApiBaseHTTP extends ApiBase { - prepare_opts(opts: T): T; - fn_wrapper(fn: T): T; - get(path: string, fn?: Function): any; - get(path: string, query?: object, fn?: Function): any; - delete(path: string, fn?: Function): any; - post(path: string, data?: object, fn?: Function): any; - put(path: string, data?: object, fn?: Function): any; - patch(path: string, data?: object, fn?: Function): any; -} diff --git a/types/gitlab/ApiV3.d.ts b/types/gitlab/ApiV3.d.ts deleted file mode 100644 index bd3d02557b..0000000000 --- a/types/gitlab/ApiV3.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ApiBaseHTTP } from './ApiBaseHTTP'; - -export class ApiV3 extends ApiBaseHTTP { - -} diff --git a/types/gitlab/BaseModel.d.ts b/types/gitlab/BaseModel.d.ts deleted file mode 100644 index ca6eb4e7c6..0000000000 --- a/types/gitlab/BaseModel.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -export class BaseModel { - load(model: string): object; - get(path: string, fn?: Function): any; - get(path: string, query?: object, fn?: Function): any; - delete(path: string, fn?: Function): any; - post(path: string, data?: object, fn?: Function): any; - put(path: string, data?: object, fn?: Function): any; - patch(path: string, data?: object, fn?: Function): any; -} - -export interface DefParams { - page?: number; - per_page?: number; - [key: string]: any; -} - -export type TId = number | string; diff --git a/types/gitlab/Models/Groups.d.ts b/types/gitlab/Models/Groups.d.ts deleted file mode 100644 index 1b528039f0..0000000000 --- a/types/gitlab/Models/Groups.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BaseModel, DefParams } from "../BaseModel"; - -interface IAccessLevels { - GUEST: number - REPORTER: number - DEVELOPER: number - MASTER: number - OWNER: number -} - -export class Groups extends BaseModel { - readonly access_levels: IAccessLevels; - - init(): object; - all(fn?: Function): any; - all(params?: DefParams, fn?: Function): any; - show(groupId: number, fn?: Function): any; - listProjects(groupId: number, fn?: Function): any; - listMembers(groupId: number, fn?: Function): any; - addMember(groupId: number, userId: number, accessLevel: IAccessLevels[keyof IAccessLevels], fn?: Function): any; - editMember(groupId: number, userId: number, accessLevel: IAccessLevels[keyof IAccessLevels], fn?: Function): any; - removeMember(groupId: number, userId: number, fn?: Function): any; - create(params?: object, fn?: Function): any; - addProject(groupId: number, projectId: number, fn?: Function): any; - deleteGroup(groupId: number, fn?: Function): any; - search(nameOrPath: string, fn?: Function): any; -} diff --git a/types/gitlab/Models/IssueNotes.d.ts b/types/gitlab/Models/IssueNotes.d.ts deleted file mode 100644 index de1821b1df..0000000000 --- a/types/gitlab/Models/IssueNotes.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class IssueNotes extends BaseModel{ - all(projectId: TId, issueId: number, fn?: Function): any - all(projectId: TId, issueId: number, params?: DefParams, fn?: Function): any -} diff --git a/types/gitlab/Models/Issues.d.ts b/types/gitlab/Models/Issues.d.ts deleted file mode 100644 index e751b6a002..0000000000 --- a/types/gitlab/Models/Issues.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Issues extends BaseModel { - all(fn?: Function): any; - all(params?: object, fn?: Function): any; - show(projectId: TId, issueId: TId, fn?: Function): any; - create(projectId: TId, params?: object, fn?: Function): any; - edit(projectId: TId, issueId: TId, params?: object, fn?: Function): any; - remove(projectId: TId, issueId: TId, fn?: Function): any; - subscribe(projectId: TId, issueId: TId, params?: object, fn?: Function): any; - unsubscribe(projectId: TId, issueId: TId, fn?: Function): any; -} diff --git a/types/gitlab/Models/Labels.d.ts b/types/gitlab/Models/Labels.d.ts deleted file mode 100644 index 63f1110b4d..0000000000 --- a/types/gitlab/Models/Labels.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Labels extends BaseModel { - create(projectId: TId, params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/Notes.d.ts b/types/gitlab/Models/Notes.d.ts deleted file mode 100644 index 95b9cd623e..0000000000 --- a/types/gitlab/Models/Notes.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Notes extends BaseModel { - create(projectId: TId, issueId: number, params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/Pipelines.d.ts b/types/gitlab/Models/Pipelines.d.ts deleted file mode 100644 index f65a9e7d25..0000000000 --- a/types/gitlab/Models/Pipelines.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class Pipelines extends BaseModel { - all(projectId: TId, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectBuilds.d.ts b/types/gitlab/Models/ProjectBuilds.d.ts deleted file mode 100644 index df7c33c32a..0000000000 --- a/types/gitlab/Models/ProjectBuilds.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -interface IShowBuildParam { - projectId: TId; - [key: string]: any; -} - -export class ProjectBuilds extends BaseModel { - listBuilds(projectId: TId, fn?: Function): any; - listBuilds(projectId: TId, params?: DefParams, fn?: Function): any; - showBuild(projectId: TId, buildId: string, fn?: Function): any; - triggerBuild(params?: IShowBuildParam, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectDeployKeys.d.ts b/types/gitlab/Models/ProjectDeployKeys.d.ts deleted file mode 100644 index 3be9d66bc4..0000000000 --- a/types/gitlab/Models/ProjectDeployKeys.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -export class ProjectKeys extends BaseModel { - listKeys(projectId: TId, fn?: Function): any; - getKey(projectId: TId, keyId: number, fn?: Function): any; - addKey(projectId: TId, params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectHooks.d.ts b/types/gitlab/Models/ProjectHooks.d.ts deleted file mode 100644 index ce0878eec9..0000000000 --- a/types/gitlab/Models/ProjectHooks.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -interface IAddParam { - url: string; - [key: string]: any; -} - -type HooksCb = (hooks: any[]) => any; - -export class ProjectHooks extends BaseModel { - list(projectId: TId, fn?: HooksCb): any; - show(projectId: TId, hookId: number, fn?: Function): any; - add(projectId: TId, params: IAddParam | string, fn?: Function): any; - update(projectId: TId, hookId: number, url: string, fn?: Function): any; - remove(projectId: TId, hookId: number, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectIssues.d.ts b/types/gitlab/Models/ProjectIssues.d.ts deleted file mode 100644 index 8f7fc439a6..0000000000 --- a/types/gitlab/Models/ProjectIssues.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IssueNotes } from './IssueNotes'; -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class ProjectIssues extends BaseModel { - readonly notes: IssueNotes; - - list(projectId: TId, fn?: Function): any; - list(projectId: TId, params?: DefParams, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectLabels.d.ts b/types/gitlab/Models/ProjectLabels.d.ts deleted file mode 100644 index 2f6ca1dabc..0000000000 --- a/types/gitlab/Models/ProjectLabels.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class ProjectLabels extends BaseModel { - all(projectId: TId, fn?: Function): any; - all(projectId: TId, params?: DefParams, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectMembers.d.ts b/types/gitlab/Models/ProjectMembers.d.ts deleted file mode 100644 index 25aa87332a..0000000000 --- a/types/gitlab/Models/ProjectMembers.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -type MenberCb = (menber: any) => any; -type MenbersCb = (menbers: any[]) => any; - -export class ProjectMembers extends BaseModel { - list(projectId: TId, fn?: MenbersCb): any; - show(projectId: TId, userId: number, fn?: MenberCb): any; - add(projectId: TId, userId: number, accessLevel: number,fn?: Function): any; - update(projectId: TId, userId: number, accessLevel: number, fn?: Function): any; - remove(projectId: TId, userId: number, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectMergeRequests.d.ts b/types/gitlab/Models/ProjectMergeRequests.d.ts deleted file mode 100644 index 37b2ab33e6..0000000000 --- a/types/gitlab/Models/ProjectMergeRequests.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { BaseModel, TId, DefParams } from '../BaseModel'; - -export class ProjectMergeRequests extends BaseModel { - list(projectId: TId, fn?: Function): any; - list(projectId: TId, params?: DefParams, fn?: Function): any; - show(projectId: TId, mergerequestId: number, fn?: Function): any; - add(projectId: TId, sourceBranch: string, targetBranch: string, assigneeId: number, title: string, fn?: Function): any; - update(projectId: TId, mergerequestId: number, params: object, fn?: Function): any; - comment(projectId: TId, mergerequestId: number, note: any, fn?: Function): any; - merge(projectId: TId, mergerequestId: number, params: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectMilestones.d.ts b/types/gitlab/Models/ProjectMilestones.d.ts deleted file mode 100644 index d36d1c016a..0000000000 --- a/types/gitlab/Models/ProjectMilestones.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -type MilestonesCb = (milestones: any[]) => any; -type MilestoneCb = (milestones: any) => any; - -export class ProjectMilestones extends BaseModel { - list(projectId: TId, fn?: MilestonesCb): any; - all(projectId: TId, fn?: MilestonesCb): any; - show(projectId: TId, milestoneId: number, fn?: MilestoneCb): any; - add(projectId: TId, title: string, description: string, due_date: any, fn?: Function): any; - update(projectId: TId, milestoneId: number, title: string, description: string, due_date: any, state_event: any, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectRepository.d.ts b/types/gitlab/Models/ProjectRepository.d.ts deleted file mode 100644 index 7bef1b6212..0000000000 --- a/types/gitlab/Models/ProjectRepository.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { BaseModel, TId } from '../BaseModel'; - -interface ShowFileParams { - file_path: string; - ref?: any; - file_id?: any; - [key: string]: any; -} - -interface AddTagParams { - id: TId; - tag_name: string; - ref: string; - message?: string; - release_description?: string; -} - -export class ProjectRepository extends BaseModel { - listBranches(projectId: TId, fn?: Function): any; - showBranch(projectId: TId, branchId: string, fn?: Function): any; - protectBranch(projectId: TId, branchId: string, params: object, fn?: Function): any; - unprotectBranch(projectId: TId, branchId: string, fn?: Function): any; - createBranch(params: object, fn?: Function): any; - deleteBranch(projectId: TId, branchId: string, fn?: Function): any; - addTag(params: AddTagParams, fn?: Function): any; - deleteTag(projectId: TId, tagName: string, fn?: Function): any; - showTag(projectId: TId, tagName: string, fn?: Function): any; - listTags(projectId: TId, fn?: Function): any; - listCommits(projectId: TId, fn?: Function): any; - showCommit(projectId: TId, sha: string, fn?: Function): any; - diffCommit(projectId: TId, sha: string, fn?: Function): any; - listTree(projectId: TId, fn?: Function): any; - listTree(projectId: TId, params?: object, fn?: Function): any; - showFile(projectId: TId, fn?: Function): any; - showFile(projectId: TId, params?: ShowFileParams, fn?: Function): any; - createFile(params?: object, fn?: Function): any; - updateFile(params?: object, fn?: Function): any; - compare(params?: object, fn?: Function): any; -} diff --git a/types/gitlab/Models/ProjectServices.d.ts b/types/gitlab/Models/ProjectServices.d.ts deleted file mode 100644 index 25c59ae400..0000000000 --- a/types/gitlab/Models/ProjectServices.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { BaseModel, TId } from './../BaseModel'; - -type ServiceCb = (service: any) => any; - -export class ProjectServices extends BaseModel { - show(projectId: TId, serviceName: string, fn?: ServiceCb): any; - update(projectId: TId, serviceName: string, params: object, fn?: ServiceCb): any; - remove(projectId: TId, serviceName: string, fn?: ServiceCb): any; -} diff --git a/types/gitlab/Models/Projects.d.ts b/types/gitlab/Models/Projects.d.ts deleted file mode 100644 index 9ba8faa551..0000000000 --- a/types/gitlab/Models/Projects.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Runners } from './Runners'; -import { Pipelines } from './Pipelines'; -import { ProjectBuilds } from './ProjectBuilds'; -import { ProjectMergeRequests } from './ProjectMergeRequests'; -import { ProjectKeys } from './ProjectDeployKeys'; -import { ProjectMilestones } from './ProjectMilestones'; -import { ProjectRepository } from './ProjectRepository'; -import { ProjectLabels } from './ProjectLabels'; -import { ProjectIssues } from './ProjectIssues'; -import { ProjectHooks } from './ProjectHooks'; -import { ProjectMembers } from './ProjectMembers'; -import { BaseModel, DefParams, TId } from '../BaseModel'; -import { ProjectServices } from './ProjectServices'; - -type ProjectsCb = (projects: any[]) => any; - -export class Projects extends BaseModel { - - readonly members: ProjectMembers; - readonly hooks: ProjectHooks; - readonly issues: ProjectIssues; - readonly labels: ProjectLabels; - readonly repository: ProjectRepository; - readonly milestones: ProjectMilestones; - readonly deploy_keys: ProjectKeys; - readonly merge_requests: ProjectMergeRequests; - readonly services: ProjectServices; - readonly builds: ProjectBuilds; - readonly pipelines: Pipelines; - readonly runners: Runners; - - - all(fn?: ProjectsCb): any; - all(params?: DefParams, fn?: ProjectsCb): any; - allAdmin(fn?: Function): any; - allAdmin(params?: DefParams, fn?: Function): any; - show(projectId: TId, fn?: Function): any; - create(params: object, fn?: Function): any; - create_for_user(params: object, fn?: Function): any; - edit(projectId: TId, params: object, fn?: Function): any; - addMember(params?: object, fn?: Function): any; - editMember(params?: object, fn?: Function): any; - listMembers(params?: object, fn?: Function): any; - listCommits(params?: object, fn?: Function): any; - listTags(params?: object, fn?: Function): any; - remove(projectId: TId, fn?: Function): any; - fork(params?: object, fn?: Function): any; - share(params?: object, fn?: Function): any; - search(projectName: string, fn?: Function): any; - search(projectName: string, params?: object, fn?: Function): any; - listTriggers(projectId: TId, fn?: Function): any; - showTrigger(projectId: TId, token: string, fn?: Function): any; - createTrigger(params?: object, fn?: Function): any; - removeTrigger(projectId: TId, token: string, fn?: Function): any; -} diff --git a/types/gitlab/Models/Runners.d.ts b/types/gitlab/Models/Runners.d.ts deleted file mode 100644 index 1656fe0c5d..0000000000 --- a/types/gitlab/Models/Runners.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { BaseModel, DefParams, TId } from '../BaseModel'; - -export class Runners extends BaseModel { - all(projectId?: TId, fn?: Function): any; - all(projectId?: TId, params?: object, fn?: Function): any; - show(runnerId: number, fn?: Function): any; - update(runnerId: number, attributes: any, fn?: Function): any; - remove(runnerId: number, projectId: any, enable: any, fn?: Function): any; - enable(projectId: TId, runnerId: number, fn?: Function): any; - disable(projectId: TId, runnerId: number, fn?: Function): any; -} diff --git a/types/gitlab/Models/UserKeys.d.ts b/types/gitlab/Models/UserKeys.d.ts deleted file mode 100644 index 5182b5a2d1..0000000000 --- a/types/gitlab/Models/UserKeys.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BaseModel, DefParams, TId } from '../BaseModel'; - -export class UserKeys extends BaseModel { - all(userId?: TId, fn?: Function): any; - addKey(userId: string, title: string, key: any, fn?: Function): any; -} diff --git a/types/gitlab/Models/Users.d.ts b/types/gitlab/Models/Users.d.ts deleted file mode 100644 index e4572ac659..0000000000 --- a/types/gitlab/Models/Users.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { BaseModel, DefParams, TId } from '../BaseModel'; -import { UserKeys } from './UserKeys'; - -type UsersCb = (users: any[]) => any; -type UserCb = (user: any) => any; - -export class Users extends BaseModel { - readonly keys: UserKeys; - - all(fn?: UsersCb): any; - all(params?: DefParams, fn?: UsersCb): any; - current(fn?: Function): any; - show(userId: number, fn?: UserCb): any; - create(params?: DefParams, fn?: Function): any; - session(email: string, password: string, fn?: Function): any; - search(emailOrUsername: string, fn?: Function): any; -} diff --git a/types/gitlab/gitlab-tests.ts b/types/gitlab/gitlab-tests.ts deleted file mode 100644 index 00ab2c761e..0000000000 --- a/types/gitlab/gitlab-tests.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as lib from "gitlab"; - -const gitlab = lib({ - url: 'http://example.com', - token: 'abcdefghij123456' -}); - -const v3 = new lib.ApiV3({ }); - -// From README - -// Listing users -gitlab.users.all((users) => { }); - -// Listing projects -gitlab.projects.all((projects) => { }); - -// From examples/delet-service - -gitlab.projects.services.remove("pid", "name", (service) => { }); diff --git a/types/gitlab/index.d.ts b/types/gitlab/index.d.ts deleted file mode 100644 index 1ff52505ee..0000000000 --- a/types/gitlab/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Type definitions for gitlab 1.8 -// Project: https://github.com/node-gitlab/node-gitlab#readme -// Definitions by: sam -// AryloYeung -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - -import { ApiV3 } from "./ApiV3"; -import { ApiBaseOptions } from "./ApiBase"; - -declare namespace Gitlib { - const ApiV3: new(options: ApiBaseOptions) => ApiV3; -} - -declare function Gitlib(options: ApiBaseOptions): ApiV3; - -export = Gitlib; diff --git a/types/gitlab/tslint.json b/types/gitlab/tslint.json deleted file mode 100644 index 4d35d29327..0000000000 --- a/types/gitlab/tslint.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - // All are TODOs - "ban-types": false, - "interface-name": false, - "no-consecutive-blank-lines": false, - "no-padding": false, - "one-line": false, - "semicolon": false, - "strict-export-declare-modifiers": false, - "whitespace": false - } -} diff --git a/types/google.visualization/index.d.ts b/types/google.visualization/index.d.ts index 2d679583d7..e5e400bc44 100644 --- a/types/google.visualization/index.d.ts +++ b/types/google.visualization/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Visualisation Apis // Project: https://developers.google.com/chart/ -// Definitions by: Dan Ludwig , Gregory Moore , Dan Manastireanu , Michael Cheng , Ivan Bisultanov , Gleb Mazovetskiy +// Definitions by: Dan Ludwig , Gregory Moore , Dan Manastireanu , Michael Cheng , Ivan Bisultanov , Gleb Mazovetskiy , Shrujal Shah // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace google { @@ -478,6 +478,7 @@ declare namespace google { showColorCode?: boolean; textStyle?: ChartTextStyle; trigger?: string; + ignoreBounds?: boolean; } export interface ChartBoundingBox { diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index 34493a8b75..667a210087 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -1,260 +1,401 @@ -// Type definitions for intl-tel-input +// Type definitions for intl-tel-input 14.0 // Project: https://github.com/jackocnr/intl-tel-input -// Definitions by: Fidan Hakaj , Leonard Thieu +// Definitions by: Fidan Hakaj , Leonard Thieu , Márton Molnár // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// - declare namespace IntlTelInput { + interface Static { + /** + * Default options for all instances + */ + defaults: Options; - interface Plugin { - /** - * Get all of the plugin's country data - either to re-use elsewhere - * e.g. to populate a country dropdown. - */ - getCountryData(): CountryData[]; - /** - * Load the utils.js script (included in the lib directory) to enable - * formatting/validation etc. - */ - loadUtils(path: string, utilsScriptDeferred?: boolean): void; + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): intlTelInputUtils.CountryData[]; - /** - * Remove the plugin from the input, and unbind any event listeners. - */ - (method: 'destroy'): void; - /** - * Get the extension from the current number. - * Requires the utilsScript option. - * e.g. if the input value was "(702) 555-5555 ext. 1234", this would - * return "1234". - */ - (method: 'getExtension'): string; - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - */ - (method: 'getNumber'): string; - /** - * Get the type (fixed-line/mobile/toll-free etc) of the current number. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.numberType. - * Note that in the US there's no way to differentiate between fixed-line and - * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. - */ - (method: 'getNumberType'): intlTelInputUtils.numberType; - /** - * Get the country data for the currently selected flag. - */ - (method: 'getSelectedCountryData'): IntlTelInput.CountryData; - /** - * Get more information about a validation error. - * Requires the utilsScript option. - * Returns an integer, which you can match against the various options in the - * global enum intlTelInputUtils.validationError - */ - (method: 'getValidationError'): intlTelInputUtils.validationError; - /** - * Validate the current number. Expects an internationally formatted number - * (unless nationalMode is enabled). If validation fails, you can use - * getValidationError to get more information. - * Requires the utilsScript option. - * Also see getNumberType if you want to make sure the user enters a certain - * type of number e.g. a mobile number. - */ - (method: 'isValidNumber'): boolean; - (method: string): void; - /** - * Change the country selection (e.g. when the user is entering their address). - * @param countryCode country code of the country to be set. - */ - (method: 'setCountry', countryCode: string): void; - /** - * Insert a number, and update the selected flag accordingly. - * Note that by default, if nationalMode is enabled it will try to use - * national formatting. - * @param aNumber number to be set. - */ - (method: 'setNumber', aNumber: string): void; - (method: string, value: string): void; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; + } - /** - * Get the current number in the given format (defaults to E.164 standard). - * The different formats are available in the enum - * intlTelInputUtils.numberFormat - taken from here. - * Requires the utilsScript option. - * Note that even if nationalMode is enabled, this can still return a full - * international number. - * @param numberFormat the format in which the number will be returned. - */ - (method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string; - (method: string, numberFormat: intlTelInputUtils.numberFormat): string; + interface Plugin { + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + destroy(): void; + + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + getExtension(): string; + + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + getNumber(numberFormat?: intlTelInputUtils.numberFormat): string; + + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + getNumberType(): intlTelInputUtils.numberType; + + /** + * Get the country data for the currently selected flag. + */ + getSelectedCountryData(): intlTelInputUtils.CountryData; + + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + getValidationError(): intlTelInputUtils.validationError; + + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + isValidNumber(): boolean; + + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + setCountry(countryCode: string): void; + + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + setNumber(aNumber: string): void; + + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + setPlaceholderNumberType(type: intlTelInputUtils.placeholderNumberType): void; + } + + interface JQueryPlugin { + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: Options): JQueryDeferred; + + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; + + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; + + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat?: intlTelInputUtils.numberFormat): string; + (method: string, numberFormat: intlTelInputUtils.numberFormat): string; + + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): intlTelInputUtils.numberType; + + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): intlTelInputUtils.CountryData; + + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum ValidationError + */ + (method: 'getValidationError'): intlTelInputUtils.validationError; + + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; + + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; + + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; + + /** + * Set the type of the placeholder number + * @param type Placeholder number type to be set + */ + (method: 'setPlaceholderNumberType', type: intlTelInputUtils.placeholderNumberType): void; + } + + interface Options { + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + * Default = true + */ + allowDropdown?: boolean; + + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + * Default = true + */ + autoHideDialCode?: boolean; + + /** + * Set the input's placeholder to an example number for the selected country, and update it if the country changes. + * You can specify the number type using the placeholderNumberType option. + * By default it is set to "polite", which means it will only set the placeholder if the input doesn't already have one. + * You can also set it to "aggressive", which will replace any existing placeholder, or "off". + * Requires the utilsScript option. + * Default = "polite" + */ + autoPlaceholder?: "off" | "polite" | "aggressive"; + + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + * Default = null + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: intlTelInputUtils.CountryData) => string; + + /** + * Expects a node e.g. document.body. Instead of putting the country dropdown next to the input, + * append it to the specified node, and it will then be positioned absolutely next to the input using JavaScript. + * This is useful when the input is inside a container with overflow: hidden. + * Note that the absolute positioning can be broken by scrolling, so it will automatically close on the window scroll event. + * Default = null + */ + dropdownContainer?: Node; + + /** + * In the dropdown, display all countries except the ones you specify here. + * Default = null + */ + excludeCountries?: string[]; + + /** + * Format the input value (according to the nationalMode option) during initialisation, and on setNumber. + * Requires the utilsScript option. + * Default = true + */ + formatOnDisplay?: boolean; + + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location, + * and then calls the success callback with the relevant country code. + * Also note that when instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can + * do something like iti.promise.then(callback) to know when initialisation requests like this have completed. + * Default = null + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; + + /** + * Add a hidden input with the given name (or if your input name contains square brackets then it will give the hidden input the same name, + * replacing the contents of the brackets with the given name). On submit, populate it with the full international number (using getNumber). + * This is a quick way for people using non-ajax forms to get the full international number, even when nationalMode is enabled. + * Note: requires the input to be inside a form element, as this feature works by listening for the submit event on the closest form element. + * Also note that since this uses getNumber internally, it expects a valid number, and so should only be used after validation. + * Default = "" + */ + hiddenInput?: string; + + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; + + /** + * Allows to translate the countries by its given iso code e.g.: { 'de': 'Deutschland' } + * Default = {} + */ + localizedCountries?: object; + + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + * Default = true + */ + nationalMode?: boolean; + + /** + * In the dropdown, display only the countries you specify. + * Default = undefined + */ + onlyCountries?: string[]; + + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + * Default = MOBILE + */ + placeholderNumberType?: intlTelInputUtils.placeholderNumberType; + + /** + * Specify the countries to appear at the top of the list. + * Default = ["us", "gb"] + */ + preferredCountries?: string[]; + + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + * Default = false + */ + separateDialCode?: boolean; + + /** + * Enable formatting/validation etc. by specifying the URL of the included utils.js script + * (or alternatively just point it to the file on cdnjs.com). The script is fetched when the page has finished loading (on the window load event) + * to prevent blocking (the script is ~215KB). When instantiating the plugin, if the Promise object is defined, + * one of those is returned under the promise instance property, so you can do something like + * iti.promise.then(callback) to know when initialisation requests like this have finished. + * Note that if you're lazy loading the plugin script itself (intlTelInput.js) + * this will not work and you will need to use the loadUtils method instead. + * Example: "build/js/utils.js" + * Default = "" + */ + utilsScript?: string; + } +} + +declare namespace intlTelInputUtils { + interface CountryData { + name: string; + iso2: string; + dialCode: string; + } + + enum numberFormat { + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 + } + + enum numberType { + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 + } + + enum validationError { + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 + } + + type placeholderNumberType = + | "FIXED_LINE_OR_MOBILE" + | "FIXED_LINE" + | "MOBILE" + | "PAGER" + | "PERSONAL_NUMBER" + | "PREMIUM_RATE" + | "SHARED_COST" + | "TOLL_FREE" + | "UAN" + | "UNKNOWN" + | "VOICEMAIL" + | "VOIP"; +} + +interface Window { + intlTelInputGlobals: IntlTelInput.Static; /** * initialise the plugin with optional options. * @param options options that can be provided during initialization. */ - (options?: IntlTelInput.Options): JQueryDeferred; - } - - interface Options { - /** - * Whether or not to allow the dropdown. If disabled, there is no dropdown - * arrow, and the selected flag is not clickable. Also we display the - * selected flag on the right instead because it is just a marker of state. - */ - allowDropdown?: boolean; - /** - * If there is just a dial code in the input: remove it on blur or submit, - * and re-add it on focus. This is to prevent just a dial code getting - * submitted with the form. Requires nationalMode to be set to false. - */ - autoHideDialCode?: boolean; - /** - * Set the input's placeholder to an example number for the selected country. - * You can specify the number type using the numberType option. - * If there is already a placeholder attribute set on the input then that - * will take precedence. Requires the utilsScript option. - */ - autoPlaceholder?: boolean; - /** - * Change the placeholder generated by autoPlaceholder. Must return a string. - */ - customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; - /** - * Specify the container for the country dropdown (use a jQuery selector - * e.g. "body"). This is useful when the input is within a scrolling element, - * or an element with overflow: hidden. Wherever you put the dropdown it - * will automatically close on the window scroll event to prevent positioning - * issues. If you want it to close when a different element is scrolled - * (such as the input's parent), simply listen for the that scroll event, - * and trigger $(window).scroll() e.g. - */ - dropdownContainer?: string; - /** - * Don't display the countries you specify. - */ - excludeCountries?: Array; - /** - * Format the input value during initialisation. - */ - formatOnInit?: boolean; - /** - * When setting initialCountry to "auto", you must use this option to - * specify a custom function that looks up the user's location. Also note - * that when instantiating the plugin, we now return a deferred object, so - * you can use .done(callback) to know when initialisation requests like - * this have completed. - * Note that the callback must still be called in the event of an error. - */ - geoIpLookup?: (callback: (countryCode: string) => void) => void; - /** - * Set the initial country selection by specifying it's country code. - * You can also set it to "auto", which will lookup the user's country based - * on their IP address (requires the geoIpLookup option). - * Note that the "auto" option will not update the country selection if the - * input already contains a number. If you leave initialCountry blank, - * it will default to the first country in the list. - */ - initialCountry?: string; - /** - * Allow users to enter national numbers (and not have to think about - * international dial codes). Formatting, validation and placeholders still - * work. Then you can use getNumber to extract a full international number. - * This option now defaults to true, and it is recommended that you leave it - * that way as it provides a better experience for the user. - */ - nationalMode?: boolean; - /** - * Display only the countries you specify. - */ - onlyCountries?: Array; - /** - * Specify one of the keys from the global enum intlTelInputUtils.numberType - * e.g. "FIXED_LINE" to set the number type to use for the placeholder. - */ - placeholderNumberType?: - | "FIXED_LINE_OR_MOBILE" - | "FIXED_LINE" - | "MOBILE" - | "PAGER" - | "PERSONAL_NUMBER" - | "PREMIUM_RATE" - | "SHARED_COST" - | "TOLL_FREE" - | "UAN" - | "UNKNOWN" - | "VOICEMAIL" - | "VOIP"; - /** - * Specify the countries to appear at the top of the list. - */ - preferredCountries?: Array; - /** - * Display the country dial code next to the selected flag so it's not part - * of the typed number. Note that this will disable nationalMode because - * technically we are dealing with international numbers, but with the - * dial code separated. - */ - separateDialCode?: boolean; - /** - * Enable formatting/validation etc. by specifying the path to the included - * utils.js script, which is fetched only when the page has finished loading - * (on window.load) to prevent blocking. When instantiating the plugin, - * we return a deferred object, so you can use .done(callback) to know when - * initialisation requests like this have finished. Note that if you're - * lazy loading the plugin script itself (intlTelInput.js) this will not - * work and you will need to use the loadUtils method instead. - */ - utilsScript?: string; - } - - interface CountryData { - name: string; - iso2: string; - dialCode: string; - } -} - -declare namespace intlTelInputUtils { - - const enum numberFormat { - E164 = 0, - INTERNATIONAL = 1, - NATIONAL = 2, - RFC3966 = 3 - } - - const enum numberType { - FIXED_LINE = 0, - MOBILE = 1, - FIXED_LINE_OR_MOBILE = 2, - TOLL_FREE = 3, - PREMIUM_RATE = 4, - SHARED_COST = 5, - VOIP = 6, - PERSONAL_NUMBER = 7, - PAGER = 8, - UAN = 9, - VOICEMAIL = 10, - UNKNOWN = -1 - } - - const enum validationError { - IS_POSSIBLE = 0, - INVALID_COUNTRY_CODE = 1, - TOO_SHORT = 2, - TOO_LONG = 3, - NOT_A_NUMBER = 4 - } + intlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin; } interface JQuery { - intlTelInput: IntlTelInput.Plugin; + intlTelInput: IntlTelInput.JQueryPlugin; } diff --git a/types/intl-tel-input/intl-tel-input-tests.ts b/types/intl-tel-input/intl-tel-input-tests.ts index e91a5deef1..ab6808bbed 100644 --- a/types/intl-tel-input/intl-tel-input-tests.ts +++ b/types/intl-tel-input/intl-tel-input-tests.ts @@ -1,70 +1,170 @@ +/// + +// Normal version + +const input = document.querySelector("#phone"); +window.intlTelInput(input); + +window.intlTelInput(input, { + customPlaceholder(selectedCountryPlaceholder, selectedCountryData) { + return 'e.g. ' + selectedCountryPlaceholder; + } +}); + +window.intlTelInput(input, { + placeholderNumberType: "MOBILE", +}); + +window.intlTelInput(input, { + geoIpLookup(callback) { + const countryCode = 'XY'; + callback(countryCode); + } +}); + +window.intlTelInput(input).destroy(); + +const extension = window.intlTelInput(input).getExtension(); + +const intlNumber = window.intlTelInput(input).getNumber(); +const ntlNumber = window.intlTelInput(input).getNumber(intlTelInputUtils.numberFormat.NATIONAL); + +const numberType = window.intlTelInput(input).getNumberType(); +if (numberType === intlTelInputUtils.numberType.MOBILE) { } + +const selectedCountryData = window.intlTelInput(input).getSelectedCountryData(); + +const error = window.intlTelInput(input).getValidationError(); +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } + +const isValid = window.intlTelInput(input).isValidNumber(); + +window.intlTelInput(input).setCountry('gb'); + +window.intlTelInput(input).setNumber('+447733123456'); + +window.intlTelInput(input).setPlaceholderNumberType("FIXED_LINE"); + +const countryData = window.intlTelInputGlobals.getCountryData(); +const country = countryData[0]; +const dialCode = country.dialCode; +const iso2 = country.iso2; +const countryName = country.name; + +window.intlTelInputGlobals.loadUtils('build/js/utils.js'); + +window.intlTelInput(input, { + utilsScript: '../../build/js/utils.js' +}); + +window.intlTelInput(input, { + initialCountry: 'auto', + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + }, + utilsScript: '../../build/js/utils.js' +}); + +window.intlTelInput(input, { + nationalMode: true, + utilsScript: '../../build/js/utils.js' +}); + +window.intlTelInput(input, { + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' +}); + +window.intlTelInput(input, { + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: ["us", "uk"], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland" }, + preferredCountries: ["us", "gb"], + separateDialCode: false +}); + +// jQuery-wrapped version + $('#phone').intlTelInput(); $('#phone').intlTelInput({ - customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) { - return 'e.g. ' + selectedCountryPlaceholder; - } + customPlaceholder: (selectedCountryPlaceholder, selectedCountryData) => { + return 'e.g. ' + selectedCountryPlaceholder; + } }); $('#phone').intlTelInput({ - placeholderNumberType: "MOBILE", + placeholderNumberType: "MOBILE", }); $('#phone').intlTelInput({ - geoIpLookup: function(callback) { - $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { - let countryCode = (resp && resp.country) ? resp.country : ''; - callback(countryCode); - }); - } + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + } }); $('#phone').intlTelInput('destroy'); -let extension = $('#phone').intlTelInput('getExtension'); +const jqueryExtension = $('#phone').intlTelInput('getExtension'); -let intlNumber = $('#phone').intlTelInput('getNumber'); -let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); +const jqueryIntlNumber = $('#phone').intlTelInput('getNumber'); +const jqueryNtlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); -let numberType = $('#phone').intlTelInput('getNumberType'); -if (numberType === intlTelInputUtils.numberType.MOBILE) {} +const jqueryNumberType = $('#phone').intlTelInput('getNumberType'); +if (numberType === intlTelInputUtils.numberType.MOBILE) { } -let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); +const jquerySelectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); -let error = $('#phone').intlTelInput('getValidationError'); -if (error === intlTelInputUtils.validationError.TOO_SHORT) {} +const jqueryError = $('#phone').intlTelInput('getValidationError'); +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } -let isValid = $('#phone').intlTelInput('isValidNumber'); +const jqueryIsValid = $('#phone').intlTelInput('isValidNumber'); $('#phone').intlTelInput('setCountry', 'gb'); $('#phone').intlTelInput('setNumber', '+447733123456'); -let countryData = $.fn.intlTelInput.getCountryData(); - -$.fn.intlTelInput.loadUtils('build/js/utils.js'); +$('#phone').intlTelInput('setPlaceholderNumberType', "FIXED_LINE"); $('#phone').intlTelInput({ - utilsScript: '../../build/js/utils.js' + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - initialCountry: 'auto', - geoIpLookup: function(callback) { - $.get('http://ipinfo.io', function() {}, 'jsonp').always(function(resp) { - let countryCode = (resp && resp.country) ? resp.country : ''; - callback(countryCode); - }); - }, - utilsScript: '../../build/js/utils.js' + initialCountry: 'auto', + geoIpLookup: (callback) => { + const countryCode = 'XY'; + callback(countryCode); + }, + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - nationalMode: true, - utilsScript: '../../build/js/utils.js' + nationalMode: true, + utilsScript: '../../build/js/utils.js' }); $('#phone').intlTelInput({ - onlyCountries: ['al'], - utilsScript: '../../build/js/utils.js' + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + allowDropdown: false, + autoHideDialCode: false, + autoPlaceholder: "aggressive", + dropdownContainer: document.body, + excludeCountries: ["us", "uk"], + formatOnDisplay: false, + hiddenInput: "hidden-input", + localizedCountries: { de: "Deutschland" }, + preferredCountries: ["us", "gb"], + separateDialCode: false }); diff --git a/types/intl-tel-input/tsconfig.json b/types/intl-tel-input/tsconfig.json index 380d60229d..e067880440 100644 --- a/types/intl-tel-input/tsconfig.json +++ b/types/intl-tel-input/tsconfig.json @@ -21,4 +21,4 @@ "index.d.ts", "intl-tel-input-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/intl-tel-input/tslint.json b/types/intl-tel-input/tslint.json index b6afb8acee..08b1465cd6 100644 --- a/types/intl-tel-input/tslint.json +++ b/types/intl-tel-input/tslint.json @@ -1,80 +1,6 @@ { "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-const-enum": 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 + "unified-signatures": false } } diff --git a/types/intl-tel-input/v13/index.d.ts b/types/intl-tel-input/v13/index.d.ts new file mode 100644 index 0000000000..a28032e026 --- /dev/null +++ b/types/intl-tel-input/v13/index.d.ts @@ -0,0 +1,260 @@ +// Type definitions for intl-tel-input 13.0 +// Project: https://github.com/jackocnr/intl-tel-input +// Definitions by: Fidan Hakaj , Leonard Thieu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare namespace IntlTelInput { + + interface Plugin { + /** + * Get all of the plugin's country data - either to re-use elsewhere + * e.g. to populate a country dropdown. + */ + getCountryData(): CountryData[]; + /** + * Load the utils.js script (included in the lib directory) to enable + * formatting/validation etc. + */ + loadUtils(path: string, utilsScriptDeferred?: boolean): void; + + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + (method: 'destroy'): void; + /** + * Get the extension from the current number. + * Requires the utilsScript option. + * e.g. if the input value was "(702) 555-5555 ext. 1234", this would + * return "1234". + */ + (method: 'getExtension'): string; + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + */ + (method: 'getNumber'): string; + /** + * Get the type (fixed-line/mobile/toll-free etc) of the current number. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.numberType. + * Note that in the US there's no way to differentiate between fixed-line and + * mobile numbers, so instead it will return FIXED_LINE_OR_MOBILE. + */ + (method: 'getNumberType'): intlTelInputUtils.numberType; + /** + * Get the country data for the currently selected flag. + */ + (method: 'getSelectedCountryData'): IntlTelInput.CountryData; + /** + * Get more information about a validation error. + * Requires the utilsScript option. + * Returns an integer, which you can match against the various options in the + * global enum intlTelInputUtils.validationError + */ + (method: 'getValidationError'): intlTelInputUtils.validationError; + /** + * Validate the current number. Expects an internationally formatted number + * (unless nationalMode is enabled). If validation fails, you can use + * getValidationError to get more information. + * Requires the utilsScript option. + * Also see getNumberType if you want to make sure the user enters a certain + * type of number e.g. a mobile number. + */ + (method: 'isValidNumber'): boolean; + (method: string): void; + /** + * Change the country selection (e.g. when the user is entering their address). + * @param countryCode country code of the country to be set. + */ + (method: 'setCountry', countryCode: string): void; + /** + * Insert a number, and update the selected flag accordingly. + * Note that by default, if nationalMode is enabled it will try to use + * national formatting. + * @param aNumber number to be set. + */ + (method: 'setNumber', aNumber: string): void; + (method: string, value: string): void; + + /** + * Get the current number in the given format (defaults to E.164 standard). + * The different formats are available in the enum + * intlTelInputUtils.numberFormat - taken from here. + * Requires the utilsScript option. + * Note that even if nationalMode is enabled, this can still return a full + * international number. + * @param numberFormat the format in which the number will be returned. + */ + (method: 'getNumber', numberFormat: intlTelInputUtils.numberFormat): string; + (method: string, numberFormat: intlTelInputUtils.numberFormat): string; + + /** + * initialise the plugin with optional options. + * @param options options that can be provided during initialization. + */ + (options?: IntlTelInput.Options): JQueryDeferred; + } + + interface Options { + /** + * Whether or not to allow the dropdown. If disabled, there is no dropdown + * arrow, and the selected flag is not clickable. Also we display the + * selected flag on the right instead because it is just a marker of state. + */ + allowDropdown?: boolean; + /** + * If there is just a dial code in the input: remove it on blur or submit, + * and re-add it on focus. This is to prevent just a dial code getting + * submitted with the form. Requires nationalMode to be set to false. + */ + autoHideDialCode?: boolean; + /** + * Set the input's placeholder to an example number for the selected country. + * You can specify the number type using the numberType option. + * If there is already a placeholder attribute set on the input then that + * will take precedence. Requires the utilsScript option. + */ + autoPlaceholder?: boolean; + /** + * Change the placeholder generated by autoPlaceholder. Must return a string. + */ + customPlaceholder?: (selectedCountryPlaceholder: string, selectedCountryData: CountryData) => string; + /** + * Specify the container for the country dropdown (use a jQuery selector + * e.g. "body"). This is useful when the input is within a scrolling element, + * or an element with overflow: hidden. Wherever you put the dropdown it + * will automatically close on the window scroll event to prevent positioning + * issues. If you want it to close when a different element is scrolled + * (such as the input's parent), simply listen for the that scroll event, + * and trigger $(window).scroll() e.g. + */ + dropdownContainer?: string; + /** + * Don't display the countries you specify. + */ + excludeCountries?: Array; + /** + * Format the input value during initialisation. + */ + formatOnInit?: boolean; + /** + * When setting initialCountry to "auto", you must use this option to + * specify a custom function that looks up the user's location. Also note + * that when instantiating the plugin, we now return a deferred object, so + * you can use .done(callback) to know when initialisation requests like + * this have completed. + * Note that the callback must still be called in the event of an error. + */ + geoIpLookup?: (callback: (countryCode: string) => void) => void; + /** + * Set the initial country selection by specifying it's country code. + * You can also set it to "auto", which will lookup the user's country based + * on their IP address (requires the geoIpLookup option). + * Note that the "auto" option will not update the country selection if the + * input already contains a number. If you leave initialCountry blank, + * it will default to the first country in the list. + */ + initialCountry?: string; + /** + * Allow users to enter national numbers (and not have to think about + * international dial codes). Formatting, validation and placeholders still + * work. Then you can use getNumber to extract a full international number. + * This option now defaults to true, and it is recommended that you leave it + * that way as it provides a better experience for the user. + */ + nationalMode?: boolean; + /** + * Display only the countries you specify. + */ + onlyCountries?: Array; + /** + * Specify one of the keys from the global enum intlTelInputUtils.numberType + * e.g. "FIXED_LINE" to set the number type to use for the placeholder. + */ + placeholderNumberType?: + | "FIXED_LINE_OR_MOBILE" + | "FIXED_LINE" + | "MOBILE" + | "PAGER" + | "PERSONAL_NUMBER" + | "PREMIUM_RATE" + | "SHARED_COST" + | "TOLL_FREE" + | "UAN" + | "UNKNOWN" + | "VOICEMAIL" + | "VOIP"; + /** + * Specify the countries to appear at the top of the list. + */ + preferredCountries?: Array; + /** + * Display the country dial code next to the selected flag so it's not part + * of the typed number. Note that this will disable nationalMode because + * technically we are dealing with international numbers, but with the + * dial code separated. + */ + separateDialCode?: boolean; + /** + * Enable formatting/validation etc. by specifying the path to the included + * utils.js script, which is fetched only when the page has finished loading + * (on window.load) to prevent blocking. When instantiating the plugin, + * we return a deferred object, so you can use .done(callback) to know when + * initialisation requests like this have finished. Note that if you're + * lazy loading the plugin script itself (intlTelInput.js) this will not + * work and you will need to use the loadUtils method instead. + */ + utilsScript?: string; + } + + interface CountryData { + name: string; + iso2: string; + dialCode: string; + } +} + +declare namespace intlTelInputUtils { + + const enum numberFormat { + E164 = 0, + INTERNATIONAL = 1, + NATIONAL = 2, + RFC3966 = 3 + } + + const enum numberType { + FIXED_LINE = 0, + MOBILE = 1, + FIXED_LINE_OR_MOBILE = 2, + TOLL_FREE = 3, + PREMIUM_RATE = 4, + SHARED_COST = 5, + VOIP = 6, + PERSONAL_NUMBER = 7, + PAGER = 8, + UAN = 9, + VOICEMAIL = 10, + UNKNOWN = -1 + } + + const enum validationError { + IS_POSSIBLE = 0, + INVALID_COUNTRY_CODE = 1, + TOO_SHORT = 2, + TOO_LONG = 3, + NOT_A_NUMBER = 4 + } +} + +interface JQuery { + intlTelInput: IntlTelInput.Plugin; +} diff --git a/types/intl-tel-input/v13/intl-tel-input-tests.ts b/types/intl-tel-input/v13/intl-tel-input-tests.ts new file mode 100644 index 0000000000..497a8dff67 --- /dev/null +++ b/types/intl-tel-input/v13/intl-tel-input-tests.ts @@ -0,0 +1,70 @@ +$('#phone').intlTelInput(); + +$('#phone').intlTelInput({ + customPlaceholder: function (selectedCountryPlaceholder, selectedCountryData) { + return 'e.g. ' + selectedCountryPlaceholder; + } +}); + +$('#phone').intlTelInput({ + placeholderNumberType: "MOBILE", +}); + +$('#phone').intlTelInput({ + geoIpLookup: function (callback) { + $.get('http://ipinfo.io', function () { }, 'jsonp').always(function (resp) { + let countryCode = (resp && resp.country) ? resp.country : ''; + callback(countryCode); + }); + } +}); + +$('#phone').intlTelInput('destroy'); + +let extension = $('#phone').intlTelInput('getExtension'); + +let intlNumber = $('#phone').intlTelInput('getNumber'); +let ntlNumber = $('#phone').intlTelInput('getNumber', intlTelInputUtils.numberFormat.NATIONAL); + +let numberType = $('#phone').intlTelInput('getNumberType'); +if (numberType === intlTelInputUtils.numberType.MOBILE) { } + +let selectedCountryData = $('#phone').intlTelInput('getSelectedCountryData'); + +let error = $('#phone').intlTelInput('getValidationError'); +if (error === intlTelInputUtils.validationError.TOO_SHORT) { } + +let isValid = $('#phone').intlTelInput('isValidNumber'); + +$('#phone').intlTelInput('setCountry', 'gb'); + +$('#phone').intlTelInput('setNumber', '+447733123456'); + +let countryData = $.fn.intlTelInput.getCountryData(); + +$.fn.intlTelInput.loadUtils('build/js/utils.js'); + +$('#phone').intlTelInput({ + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + initialCountry: 'auto', + geoIpLookup: function (callback) { + $.get('http://ipinfo.io', function () { }, 'jsonp').always(function (resp) { + let countryCode = (resp && resp.country) ? resp.country : ''; + callback(countryCode); + }); + }, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + nationalMode: true, + utilsScript: '../../build/js/utils.js' +}); + +$('#phone').intlTelInput({ + onlyCountries: ['al'], + utilsScript: '../../build/js/utils.js' +}); diff --git a/types/intl-tel-input/v13/tsconfig.json b/types/intl-tel-input/v13/tsconfig.json new file mode 100644 index 0000000000..f166c4da54 --- /dev/null +++ b/types/intl-tel-input/v13/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "intl-tel-input": [ "intl-tel-input/v13" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "intl-tel-input-tests.ts" + ] +} diff --git a/types/intl-tel-input/v13/tslint.json b/types/intl-tel-input/v13/tslint.json new file mode 100644 index 0000000000..b6afb8acee --- /dev/null +++ b/types/intl-tel-input/v13/tslint.json @@ -0,0 +1,80 @@ +{ + "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-const-enum": 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 + } +} diff --git a/types/karma-fixture/index.d.ts b/types/karma-fixture/index.d.ts index 42af1d5d60..d443359d72 100644 --- a/types/karma-fixture/index.d.ts +++ b/types/karma-fixture/index.d.ts @@ -1,31 +1,28 @@ -// Type definitions for karma-fixture 0.2.7 +// Type definitions for karma-fixture 0.2 // Project: https://github.com/billtrik/karma-fixture // Definitions by: Ezekiel Victor // Afshawn Lotfi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace fixture { - export var el: HTMLElement; - export var json: any[]; + let el: HTMLElement; + let json: any[]; - export function load(...files: string[]): any; - export function load(file1: string, append?: boolean): any; - export function load(file1: string, file2: string, append?: boolean): any; - export function load(file1: string, file2: string, file3: string, append?: boolean): any; - export function load(file1: string, file2: string, file3: string, file4: string, append?: boolean): any; - export function load(file1: string, file2: string, file3: string, file4: string, file5: string, append?: boolean): any; + function load(...files: string[]): any; + function load(file1: string, append?: boolean): any; + function load(file1: string, file2: string, append?: boolean): any; + function load(file1: string, file2: string, file3: string, append?: boolean): any; + function load(file1: string, file2: string, file3: string, file4: string, append?: boolean): any; + function load(file1: string, file2: string, file3: string, file4: string, file5: string, append?: boolean): any; - export function set(...htmlStrs: string[]): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, append?: boolean): HTMLElement|HTMLElement[]; - export function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, htmlStr5: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(...htmlStrs: string[]): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, append?: boolean): HTMLElement|HTMLElement[]; + function set(htmlStr1: string, htmlStr2: string, htmlStr3: string, htmlStr4: string, htmlStr5: string, append?: boolean): HTMLElement|HTMLElement[]; - export function cleanup(): void; + function cleanup(): void; - export function setBase(fixtureBasePath: string): void; + function setBase(fixtureBasePath: string): void; } - -export = fixture; -export as namespace fixture; diff --git a/types/karma-fixture/karma-fixture-tests.ts b/types/karma-fixture/karma-fixture-tests.ts index d8ea8c8794..2096298eb9 100644 --- a/types/karma-fixture/karma-fixture-tests.ts +++ b/types/karma-fixture/karma-fixture-tests.ts @@ -1,4 +1,3 @@ - fixture.setBase('fixtures/base/path'); fixture.load('test1.html', 'test1.json', false); fixture.load('test1.html', 'test2.html', 'test1.json'); diff --git a/types/karma-fixture/tslint.json b/types/karma-fixture/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/karma-fixture/tslint.json +++ b/types/karma-fixture/tslint.json @@ -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" } diff --git a/types/koa-bodyparser/index.d.ts b/types/koa-bodyparser/index.d.ts index deb1eb04e9..3cf420ca12 100644 --- a/types/koa-bodyparser/index.d.ts +++ b/types/koa-bodyparser/index.d.ts @@ -47,6 +47,11 @@ declare namespace bodyParser { */ jsonLimit?: string; + /** + * limit of the text body. Default is 1mb. + */ + textLimit?: string; + /** * when set to true, JSON parser will only accept arrays and objects. Default is true */ diff --git a/types/koa-ratelimit-lru/index.d.ts b/types/koa-ratelimit-lru/index.d.ts new file mode 100644 index 0000000000..f6c560f16a --- /dev/null +++ b/types/koa-ratelimit-lru/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for koa-ratelimit-lru 1.0 +// Project: https://github.com/Dreamacro/koa-ratelimit-lru +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Middleware } from 'koa'; + +declare namespace rateLimit { + interface Options { + readonly duration?: number; + readonly max?: number; + readonly prefix?: string; + readonly store?: any; // lru-cache ? + readonly rate?: number; + readonly id?: string; + readonly headers?: { + readonly remaining?: string; + readonly reset?: string; + readonly total?: string; + }; + readonly errorMessage?: string; + } + } + +declare function rateLimit(options?: rateLimit.Options): Middleware; + +export = rateLimit; diff --git a/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts b/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts new file mode 100644 index 0000000000..84759cb43b --- /dev/null +++ b/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts @@ -0,0 +1,12 @@ +import Koa = require('koa'); +import rateLimit = require('koa-ratelimit-lru'); + +const app = new Koa(); + +app.use(rateLimit({})); + +app.use(async context => { + context.body = "Hello"; +}); + +app.listen(2000); diff --git a/types/koa-ratelimit-lru/tsconfig.json b/types/koa-ratelimit-lru/tsconfig.json new file mode 100644 index 0000000000..7f285be8e3 --- /dev/null +++ b/types/koa-ratelimit-lru/tsconfig.json @@ -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", + "koa-ratelimit-lru-tests.ts" + ] +} diff --git a/types/koa-ratelimit-lru/tslint.json b/types/koa-ratelimit-lru/tslint.json new file mode 100644 index 0000000000..6fafe521cb --- /dev/null +++ b/types/koa-ratelimit-lru/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" + } diff --git a/types/koa/index.d.ts b/types/koa/index.d.ts index ea6bd60a46..802d6a242f 100644 --- a/types/koa/index.d.ts +++ b/types/koa/index.d.ts @@ -659,6 +659,10 @@ declare namespace Application { * Default error handling. */ onerror(err: Error): void; + /** + * Custom properties. + */ + [key: string]: any; } interface Request extends BaseRequest { diff --git a/types/mali-compose/index.d.ts b/types/mali-compose/index.d.ts index 87b23087d3..c70ee7557b 100644 --- a/types/mali-compose/index.d.ts +++ b/types/mali-compose/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/malijs/mali-compose // Definitions by: Daniel Byrne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 import { Context } from "mali"; diff --git a/types/mali-compose/package.json b/types/mali-compose/package.json new file mode 100644 index 0000000000..76d151fcec --- /dev/null +++ b/types/mali-compose/package.json @@ -0,0 +1,8 @@ +{ + "private": true, + "dependencies": { + "grpc": "^1.16.1", + "mali": "^0.10.2", + "protobufjs": "^6.8.8" + } +} diff --git a/types/mali-onerror/index.d.ts b/types/mali-onerror/index.d.ts index c9600d50f0..6fa37b9862 100644 --- a/types/mali-onerror/index.d.ts +++ b/types/mali-onerror/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/malijs/onerror // Definitions by: Daniel Byrne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.3 import { Context } from "mali"; diff --git a/types/mali-onerror/package.json b/types/mali-onerror/package.json new file mode 100644 index 0000000000..76d151fcec --- /dev/null +++ b/types/mali-onerror/package.json @@ -0,0 +1,8 @@ +{ + "private": true, + "dependencies": { + "grpc": "^1.16.1", + "mali": "^0.10.2", + "protobufjs": "^6.8.8" + } +} diff --git a/types/mapbox-gl/index.d.ts b/types/mapbox-gl/index.d.ts index 33a619b9ae..91fb68cd96 100644 --- a/types/mapbox-gl/index.d.ts +++ b/types/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.49.0 +// Type definitions for Mapbox GL JS v0.51.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer , Patrick Reames // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -17,7 +17,7 @@ declare namespace mapboxgl { export function setRTLTextPlugin(pluginURL: string, callback: (error: Error) => void): void; - type LngLatLike = LngLat | { lng: number; lat: number; } | [number, number]; + type LngLatLike = LngLat | { lng: number; lat: number; } | { lon: number; lat: number; } | [number, number]; type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]; type PointLike = Point | [number, number]; type Expression = any[]; diff --git a/types/mapbox-gl/mapbox-gl-tests.ts b/types/mapbox-gl/mapbox-gl-tests.ts index d55cf592e5..422b255900 100644 --- a/types/mapbox-gl/mapbox-gl-tests.ts +++ b/types/mapbox-gl/mapbox-gl-tests.ts @@ -417,6 +417,7 @@ function expectType(value: T) { /* let the compiler handle things */ } expectType(new mapboxgl.LngLat(0, 0)); expectType([0, 0]); expectType({ lng: 0, lat: 0 }); +expectType({ lon: 0, lat: 0 }); /* * LngLat diff --git a/types/nuka-carousel/index.d.ts b/types/nuka-carousel/index.d.ts index 8428f92616..97edd08a6d 100644 --- a/types/nuka-carousel/index.d.ts +++ b/types/nuka-carousel/index.d.ts @@ -1,6 +1,8 @@ -// Type definitions for nuka-carousel 4.3 +// Type definitions for nuka-carousel 4.4 // Project: https://github.com/FormidableLabs/nuka-carousel -// Definitions by: Roman Charugin , Alex Smith +// Definitions by: Roman Charugin +// Alex Smith +// matt-sungwook // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -17,38 +19,23 @@ export type CarouselSlidesToScrollProp = number | 'auto'; export type CarouselSlideWidthProp = string | number; export interface CarouselSlideRenderControlProps { + /** + * Space between slides, as an integer, but reflected as px + */ + cellSpacing: number; /** * Current slide index */ currentSlide: number; - /** - * Total amount of slides - */ - slideCount: number; /** * Current frame width (px) */ frameWidth: number; /** - * Current slide width (px) + * Go to X slide method + * @param index Slide's index to go */ - slideWidth: number; - /** - * Slides to scroll at once - */ - slidesToScroll: number; - /** - * Space between slides, as an integer, but reflected as px - */ - cellSpacing: number; - /** - * Slides to show at once - */ - slidesToShow: number; - /** - * Infinite mode enabled - */ - wrapAround: boolean; + goToSlide: (index: number) => void; /** * Go to the next slide method */ @@ -58,10 +45,25 @@ export interface CarouselSlideRenderControlProps { */ previousSlide: () => void; /** - * Go to X slide method - * @param index Slide's index to go + * Total amount of slides */ - goToSlide: (index: number) => void; + slideCount: number; + /** + * Slides to scroll at once + */ + slidesToScroll: number; + /** + * Slides to show at once + */ + slidesToShow: number; + /** + * Current slide width (px) + */ + slideWidth: number; + /** + * Infinite mode enabled + */ + wrapAround: boolean; } export type CarouselRenderControl = (props: CarouselSlideRenderControlProps) => JSX.Element; @@ -101,6 +103,11 @@ export interface CarouselProps { * Additional className */ className?: string; + /** + * When set to true, disable keyboard controls + * @default false + */ + disableKeyboardControls?: boolean; /** * Enable mouse swipe/dragging */ @@ -144,6 +151,11 @@ export interface CarouselProps { * Window onResize callback */ onResize?: () => void; + /** + * Pause autoPlay when mouse is over carousel + * @default true + */ + pauseOnHover?: boolean; /** * Function for rendering top left control */ @@ -238,6 +250,10 @@ export interface CarouselState { * Is dragging enabled */ dragging: boolean; + /** + * Easing function name + */ + easing: string; /** * Current frame width */ @@ -245,7 +261,10 @@ export interface CarouselState { /** * Current left value */ + isWrappingAround: boolean; left: number; + pauseOnHover: boolean; + resetWrapAroundPosition: boolean; /** * Total amount of slides */ @@ -262,14 +281,8 @@ export interface CarouselState { * Current top value */ top: number; - /** - * Easing function name - */ - easing: string; /** * Is infinite mode enabled */ - isWrappingAround: boolean; wrapToIndex: boolean; - resetWrapAroundPosition: boolean; } diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts index 41e35c0c45..55ee5b6741 100644 --- a/types/openfin/index.d.ts +++ b/types/openfin/index.d.ts @@ -24,35 +24,6 @@ * When running within the OpenFin Runtime your web applications have access to the "fin" namespace and all the modules within the API * without the need to include additional source files. You can treat the "fin" namespace as you would the "window", "navigator" or "documennt" objects. */ -import { Identity } from './_v2/identity'; -import { ApplicationInfo as LaunchInfo, ShortCutConfig, TrayInfo } from './_v2/api/application/application'; -import { ApplicationOption } from './_v2/api/application/applicationOption'; -import { ExternalApplicationInfo } from './_v2/api/external-application/external-application'; -import { ApplicationInfo } from './_v2/api/system/application'; -import { ClearCacheOption } from './_v2/api/system/clearCacheOption'; -import { CookieInfo, CookieOption } from './_v2/api/system/cookie'; -import { AppAssetInfo, AppAssetRequest, RuntimeDownloadOptions, RuntimeDownloadProgress } from './_v2/api/system/download-asset'; -import { DownloadPreloadInfo, DownloadPreloadOption } from './_v2/api/system/download-preload'; -import { EntityInfo } from './_v2/api/system/entity'; -import { ExternalProcessRequestType, ExternalProcessInfo } from './_v2/api/system/external-process'; -import { HostSpecs } from './_v2/api/system/host-specs'; -import { LogInfo } from './_v2/api/system/log'; -import { MonitorInfo } from './_v2/api/system/monitor'; -import { PointTopLeft } from './_v2/api/system/point'; -import { ProcessInfo } from './_v2/api/system/process'; -import { ProxyInfo } from './_v2/api/system/proxy'; -import { RegistryInfo } from './_v2/api/system/registry-info'; -import { RVMInfo} from './_v2/api/system/rvm'; -import { WindowDetail, WindowInfo } from './_v2/api/system/window'; -import { AnchorType } from './_v2/api/window/anchor-type'; -import Bounds from './_v2/api/window/bounds'; -import { Transition, TransitionOptions } from './_v2/api/window/transition'; -import { WindowOption } from './_v2/api/window/windowOption'; - -// tslint:disable-next-line:export-just-namespace -export = fin; -export as namespace fin; - declare namespace fin { var Application: import('./_v2/api/application/application').default; var Clipboard: import('./_v2/api/clipboard/clipboard').default; @@ -64,6 +35,42 @@ declare namespace fin { var System: import('./_v2/api/system/system').default; var Window: import('./_v2/api/window/window').default; + // v2 shapes + type Identity = import('./_v2/identity').Identity; + type LaunchInfo = import('./_v2/api/application/application').ApplicationInfo; + type ShortCutConfig = import('./_v2/api/application/application').ShortCutConfig; + type TrayInfo = import('./_v2/api/application/application').TrayInfo; + type ApplicationOption = import('./_v2/api/application/applicationOption').ApplicationOption; + type ExternalApplicationInfo = import('./_v2/api/external-application/external-application').ExternalApplicationInfo; + type ApplicationInfo = import('./_v2/api/system/application').ApplicationInfo; + type ClearCacheOption = import('./_v2/api/system/clearCacheOption').ClearCacheOption; + type CookieInfo = import('./_v2/api/system/cookie').CookieInfo; + type CookieOption = import('./_v2/api/system/cookie').CookieOption; + type AppAssetInfo = import('./_v2/api/system/download-asset').AppAssetInfo; + type AppAssetRequest = import('./_v2/api/system/download-asset').AppAssetRequest; + type RuntimeDownloadOptions = import('./_v2/api/system/download-asset').RuntimeDownloadOptions; + type RuntimeDownloadProgress = import('./_v2/api/system/download-asset').RuntimeDownloadProgress; + type DownloadPreloadInfo = import('./_v2/api/system/download-preload').DownloadPreloadInfo; + type DownloadPreloadOption = import('./_v2/api/system/download-preload').DownloadPreloadOption; + type EntityInfo = import('./_v2/api/system/entity').EntityInfo; + type ExternalProcessRequestType = import('./_v2/api/system/external-process').ExternalProcessRequestType; + type ExternalProcessInfo = import('./_v2/api/system/external-process').ExternalProcessInfo; + type HostSpecs = import('./_v2/api/system/host-specs').HostSpecs; + type LogInfo = import('./_v2/api/system/log').LogInfo; + type MonitorInfo = import('./_v2/api/system/monitor').MonitorInfo; + type PointTopLeft = import('./_v2/api/system/point').PointTopLeft; + type ProcessInfo = import('./_v2/api/system/process').ProcessInfo; + type ProxyInfo = import('./_v2/api/system/proxy').ProxyInfo; + type RegistryInfo = import('./_v2/api/system/registry-info').RegistryInfo; + type RVMInfo = import('./_v2/api/system/rvm').RVMInfo; + type WindowDetail = import('./_v2/api/system/window').WindowDetail; + type WindowInfo = import('./_v2/api/system/window').WindowInfo; + type AnchorType = import('./_v2/api/window/anchor-type').AnchorType; + type Bounds = import('./_v2/api/window/bounds').default; + type Transition = import('./_v2/api/window/transition').Transition; + type TransitionOptions = import('./_v2/api/window/transition').TransitionOptions; + type WindowOption = import('./_v2/api/window/windowOption').WindowOption; + const desktop: OpenFinDesktop; interface OpenFinDesktop { diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index fed6c45253..bea9987832 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -173,6 +173,20 @@ declare namespace P { * Warning: this option may not be supported by downstream transports. */ useOnlyCustomLevels?: boolean; + + /** + * As an array, the redact option specifies paths that should have their values redacted from any log output. + * + * Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation. + * + * If an object is supplied, three options can be specified: + * + * paths (String[]): Required. An array of paths + * censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]' + * remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false + */ + redact?: string[] | redactOptions; + /** * When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`. */ @@ -420,4 +434,10 @@ declare namespace P { (msg: string, ...args: any[]): void; (obj: object, msg?: string, ...args: any[]): void; } + + interface redactOptions { + paths: string[]; + censor?: string; + remove?: boolean; + } } diff --git a/types/pino/pino-tests.ts b/types/pino/pino-tests.ts index c85f2f6873..d3203b5dd4 100644 --- a/types/pino/pino-tests.ts +++ b/types/pino/pino-tests.ts @@ -102,3 +102,24 @@ const handler = pino.final(logExtreme, (err: Error, finalLogger: pino.BaseLogger }); handler(new Error('error')); + +const redacted = pino({ + redact: ['path'] +}); + +redacted.info({ + msg: 'logged with redacted properties', + path: 'Not shown' +}); + +const anotherRedacted = pino({ + redact: { + paths: ['anotherPath'], + censor: 'Not the log you\re looking for' + } +}); + +anotherRedacted.info({ + msg: 'another logged with redacted properties', + anotherPath: 'Not shown' +}); diff --git a/types/pollyjs__adapter-fetch/index.d.ts b/types/pollyjs__adapter-fetch/index.d.ts new file mode 100644 index 0000000000..3d93435d51 --- /dev/null +++ b/types/pollyjs__adapter-fetch/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for @pollyjs/adapter-fetch 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter-fetch +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import Adapter from '@pollyjs/adapter'; + +export default class FetchAdapter extends Adapter {} diff --git a/types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts b/types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts new file mode 100644 index 0000000000..61b8ef734d --- /dev/null +++ b/types/pollyjs__adapter-fetch/pollyjs__adapter-fetch-tests.ts @@ -0,0 +1,8 @@ +import FetchAdapter from '@pollyjs/adapter-fetch'; +import { Polly } from '@pollyjs/core'; + +Polly.register(FetchAdapter); + +new Polly('', { + adapters: ['xhr', FetchAdapter] +}); diff --git a/types/pollyjs__adapter-fetch/tsconfig.json b/types/pollyjs__adapter-fetch/tsconfig.json new file mode 100644 index 0000000000..03d3076b3c --- /dev/null +++ b/types/pollyjs__adapter-fetch/tsconfig.json @@ -0,0 +1,40 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ], + "@pollyjs/adapter-fetch": [ + "pollyjs__adapter-fetch" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__adapter-fetch-tests.ts" + ] +} diff --git a/types/pollyjs__adapter-fetch/tslint.json b/types/pollyjs__adapter-fetch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__adapter-fetch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__adapter/index.d.ts b/types/pollyjs__adapter/index.d.ts new file mode 100644 index 0000000000..b3810a67bb --- /dev/null +++ b/types/pollyjs__adapter/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @pollyjs/adapter 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/adapter +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export default class Adapter { + static readonly name: string; + static readonly type: string; + connect(): void; + disconnect(): void; +} diff --git a/types/pollyjs__adapter/pollyjs__adapter-tests.ts b/types/pollyjs__adapter/pollyjs__adapter-tests.ts new file mode 100644 index 0000000000..1e5c82a586 --- /dev/null +++ b/types/pollyjs__adapter/pollyjs__adapter-tests.ts @@ -0,0 +1,4 @@ +import Adapter from '@pollyjs/adapter'; + +Adapter.name; +Adapter.type; diff --git a/types/pollyjs__adapter/tsconfig.json b/types/pollyjs__adapter/tsconfig.json new file mode 100644 index 0000000000..ad121d2d9d --- /dev/null +++ b/types/pollyjs__adapter/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__adapter-tests.ts" + ] +} diff --git a/types/pollyjs__adapter/tslint.json b/types/pollyjs__adapter/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__adapter/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__core/index.d.ts b/types/pollyjs__core/index.d.ts new file mode 100644 index 0000000000..83b6b933b9 --- /dev/null +++ b/types/pollyjs__core/index.d.ts @@ -0,0 +1,167 @@ +// Type definitions for @pollyjs/core 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/core +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { MODES } from '@pollyjs/utils'; +import Adapter from '@pollyjs/adapter'; +import Persister from '@pollyjs/persister'; + +export const Timing: { + fixed(ms: number): () => Promise; + relative(ratio: number): (ms: number) => Promise; +}; +export interface PollyConfig { + mode?: MODES; + + adapters?: Array; + adapterOptions?: any; + + persister?: string | typeof Persister; + persisterOptions?: { + keepUnusedRequests?: boolean; + [key: string]: any; + }; + + logging?: boolean; + + recordIfMissing?: boolean; + recordIfExpired?: boolean; + recordFailedRequests?: boolean; + + expiresIn?: string | null; + timing?: ((ms: number) => Promise) | (() => Promise); + + matchRequestsBy?: { + method?: boolean; + headers?: any; + body?: boolean; + order?: boolean; + + url?: { + protocol?: boolean; + username?: boolean; + password?: boolean; + hostname?: boolean; + port?: boolean; + pathname?: boolean; + query?: boolean; + hash?: boolean; + }; + }; +} +export interface Request { + getHeader(name: string): string | null; + setHeader(name: string, value: string): Request; + setHeaders(headers: any): Request; + hasHeader(name: string): boolean; + type(contentType: string): Request; + send(body: any): Request; + json(body: any): Request; + jsonBody(): any; + + method: string; + url: string; + protocol: string; + hostname: string; + port: string; + pathname: string; + hash: string; + headers: Record; + body: any; + query: any; + params: any; + recordingName: string; + responseTime?: number; +} +export interface Response { + statusCode?: number; + headers: Record; + body: any; + status(status: number): Response; + getHeader(name: string): string | null; + setHeader(name: string, value: string): Response; + setHeaders(headers: any): Response; + hasHeader(name: string): boolean; + type(contentType: string): Response; + send(body: any): Response; + sendStatus(status: number): Response; + json(body: any): Response; + jsonBody(): any; + end(): Readonly; +} +export interface Intercept { + abort(): void; + passthrough(): void; +} +export type RequestRouteEvent = 'request'; +export type RecordingRouteEvent = 'beforeReplay' | 'beforePersist'; +export type ResponseRouteEvent = 'beforeResponse' | 'response'; + +export type EventListenerResponse = any; +export type RequestEventListener = (req: Request) => EventListenerResponse; +export type RecordingEventListener = (req: Request, recording: any) => EventListenerResponse; +export type ResponseEventListener = (req: Request, res: Response) => EventListenerResponse; +export type InterceptHandler = ( + req: Request, + res: Response, + intercept: Intercept +) => EventListenerResponse; +export class RouteHandler { + on(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler; + on(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; + on(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; + off(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler; + off(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; + off(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; + once(event: RequestRouteEvent, listener: RequestEventListener): RouteHandler; + once(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; + once(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; + + passthrough(value?: boolean): RouteHandler; + intercept( + fn: (req: Request, res: Response, intercept: Intercept) => EventListenerResponse + ): RouteHandler; + recordingName(recordingName: string): RouteHandler; + configure(config: PollyConfig): RouteHandler; +} +export class PollyServer { + timeout: (ms: number) => Promise; + get: (...args: any[]) => RouteHandler; + put: (...args: any[]) => RouteHandler; + post: (...args: any[]) => RouteHandler; + delete: (...args: any[]) => RouteHandler; + patch: (...args: any[]) => RouteHandler; + head: (...args: any[]) => RouteHandler; + options: (...args: any[]) => RouteHandler; + any: (...args: any[]) => RouteHandler; + host(host: string, callback: () => void): void; + namespace(path: string, callback: () => void): void; +} +export type PollyEvent = 'create' | 'stop' | 'register'; +export type PollyEventListener = (poll: Polly) => void; +export class Polly { + static register(Factory: typeof Adapter | typeof Persister): void; + static on(event: PollyEvent, listener: PollyEventListener): void; + static off(event: PollyEvent, listener: PollyEventListener): void; + static once(event: PollyEvent, listener: PollyEventListener): void; + + constructor(name: string, options?: PollyConfig); + + readonly recordingName: string | null; + mode: MODES; + server: PollyServer; + persister: Persister; + + pause: () => void; + play: () => void; + replay: () => void; + record: () => void; + stop: () => Promise; + flush: () => Promise; + configure(config: PollyConfig): void; + connectTo(name: string | typeof Adapter): void; + disconnectFrom(name: string | typeof Adapter): void; + disconnect(): void; +} diff --git a/types/pollyjs__core/pollyjs__core-tests.ts b/types/pollyjs__core/pollyjs__core-tests.ts new file mode 100644 index 0000000000..22f5516646 --- /dev/null +++ b/types/pollyjs__core/pollyjs__core-tests.ts @@ -0,0 +1,64 @@ +import { Polly, Timing } from '@pollyjs/core'; +import { MODES } from '@pollyjs/utils'; + +const polly = new Polly('test recording', { + mode: MODES.PASSTHROUGH, + recordFailedRequests: true, + adapters: ['xhr', 'fetch'], + persister: 'rest', + timing: Timing.relative(3) +}); + +function log(_: string) { + // no op +} + +async function test() { + polly.pause(); + polly.play(); + const { server } = polly; + server.get('/session').on('request', req => { + req.headers['X-AUTH'] = ''; + req.query.email = 'test@app.com'; + }); + server.get('/session').on('beforeResponse', (req, res) => { + res.setHeader('X-AUTH', ''); + }); + server.get('/session').on('response', (req, res) => { + log(`${req.url} took ${req.responseTime}ms with a status of ${res.statusCode}.`); + }); + + polly.configure({ + adapterOptions: { + fetch: { + context: null + } + } + }); + + server + .get('/session') + .once('request', req => { + req.headers['X-AUTH'] = ''; + req.query.email = 'test@app.com'; + }) + .once('request', () => { + /* Do something else */ + }); + + /* Intercept all Google Analytic requests and respond with a 200 */ + server.get('/google-analytics/*path').intercept((req, res, intercept) => { + if (req.pathname === 'test') { + intercept.abort(); + } else { + res.sendStatus(200); + } + }); + + /* Pass-through all GET requests to /coverage */ + server.get('/coverage') + .configure({ expiresIn: '5d' }) + .passthrough(); + + await polly.flush(); +} diff --git a/types/pollyjs__core/tsconfig.json b/types/pollyjs__core/tsconfig.json new file mode 100644 index 0000000000..4b91defc70 --- /dev/null +++ b/types/pollyjs__core/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__core-tests.ts" + ] +} diff --git a/types/pollyjs__core/tslint.json b/types/pollyjs__core/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__core/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__persister-fs/index.d.ts b/types/pollyjs__persister-fs/index.d.ts new file mode 100644 index 0000000000..3d97b382f7 --- /dev/null +++ b/types/pollyjs__persister-fs/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for @pollyjs/persister-fs 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/persister-fs +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import Persister from '@pollyjs/persister'; + +export default class FSPersister extends Persister {} diff --git a/types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts b/types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts new file mode 100644 index 0000000000..2d624a0f8d --- /dev/null +++ b/types/pollyjs__persister-fs/pollyjs__persister-fs-tests.ts @@ -0,0 +1,8 @@ +import FSPersister from '@pollyjs/persister-fs'; +import { Polly } from '@pollyjs/core'; + +Polly.register(FSPersister); + +new Polly('', { + persister: FSPersister +}); diff --git a/types/pollyjs__persister-fs/tsconfig.json b/types/pollyjs__persister-fs/tsconfig.json new file mode 100644 index 0000000000..7a7eb6733c --- /dev/null +++ b/types/pollyjs__persister-fs/tsconfig.json @@ -0,0 +1,41 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/persister": [ + "pollyjs__persister" + ], + "@pollyjs/persister-fs": [ + "pollyjs__persister-fs" + ], + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/utils": [ + "pollyjs__utils" + ], + "@pollyjs/adapter": [ + "pollyjs__adapter" + ] + } + + }, + "files": [ + "index.d.ts", + "pollyjs__persister-fs-tests.ts" + ] +} diff --git a/types/pollyjs__persister-fs/tslint.json b/types/pollyjs__persister-fs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__persister-fs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__persister/index.d.ts b/types/pollyjs__persister/index.d.ts new file mode 100644 index 0000000000..45fc1fc250 --- /dev/null +++ b/types/pollyjs__persister/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for @pollyjs/persister 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/persister +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default class Persister { + static readonly name: string; + static readonly type: string; + persist(): Promise; +} diff --git a/types/pollyjs__persister/pollyjs__persister-tests.ts b/types/pollyjs__persister/pollyjs__persister-tests.ts new file mode 100644 index 0000000000..7e9448aae0 --- /dev/null +++ b/types/pollyjs__persister/pollyjs__persister-tests.ts @@ -0,0 +1,4 @@ +import Persister from '@pollyjs/persister'; + +Persister.name; +Persister.type; diff --git a/types/pollyjs__persister/tsconfig.json b/types/pollyjs__persister/tsconfig.json new file mode 100644 index 0000000000..b47bfbaa9f --- /dev/null +++ b/types/pollyjs__persister/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/core": [ + "pollyjs__core" + ], + "@pollyjs/persister": [ + "pollyjs__persister" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__persister-tests.ts" + ] +} diff --git a/types/pollyjs__persister/tslint.json b/types/pollyjs__persister/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__persister/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pollyjs__utils/index.d.ts b/types/pollyjs__utils/index.d.ts new file mode 100644 index 0000000000..e87392fcee --- /dev/null +++ b/types/pollyjs__utils/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for @pollyjs/utils 1.2 +// Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/utils +// Definitions by: feinoujc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export enum MODES { + RECORD = 'record', + REPLAY = 'replay', + PASSTHROUGH = 'passthrough', + STOPPED = 'stopped' +} diff --git a/types/pollyjs__utils/pollyjs__utils-tests.ts b/types/pollyjs__utils/pollyjs__utils-tests.ts new file mode 100644 index 0000000000..463a4b4329 --- /dev/null +++ b/types/pollyjs__utils/pollyjs__utils-tests.ts @@ -0,0 +1,6 @@ +import { MODES } from '@pollyjs/utils'; + +MODES.PASSTHROUGH; +MODES.RECORD; +MODES.REPLAY; +MODES.STOPPED; diff --git a/types/pollyjs__utils/tsconfig.json b/types/pollyjs__utils/tsconfig.json new file mode 100644 index 0000000000..7b5421a32f --- /dev/null +++ b/types/pollyjs__utils/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@pollyjs/utils": [ + "pollyjs__utils" + ] + } + }, + "files": [ + "index.d.ts", + "pollyjs__utils-tests.ts" + ] +} diff --git a/types/pollyjs__utils/tslint.json b/types/pollyjs__utils/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pollyjs__utils/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/promise-polyfill/index.d.ts b/types/promise-polyfill/index.d.ts index 703f7a6a8c..83036cf4ff 100644 --- a/types/promise-polyfill/index.d.ts +++ b/types/promise-polyfill/index.d.ts @@ -1,6 +1,13 @@ -// Type definitions for promise v6.0.2 +// Type definitions for promise-polyfill 6.0 // Project: https://www.npmjs.com/package/promise-polyfill // Definitions by: Steve Jenkins +// Daniel Cassidy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default Promise; \ No newline at end of file +export interface PromisePolyfillConstructor extends PromiseConstructor { + _immediateFn?: (handler: (() => void) | string) => void; +} + +declare const Promise: PromisePolyfillConstructor; + +export default Promise; diff --git a/types/promise-polyfill/promise-polyfill-tests.ts b/types/promise-polyfill/promise-polyfill-tests.ts index 280a2bebdf..cfdd803126 100644 --- a/types/promise-polyfill/promise-polyfill-tests.ts +++ b/types/promise-polyfill/promise-polyfill-tests.ts @@ -1,3 +1,5 @@ +import Promise from "promise-polyfill"; + const prom1 = new Promise((resolve, reject) => { resolve(12); }); @@ -15,4 +17,6 @@ Promise.all([prom1, prom2]) .then(result => { console.log(result); }, (exception) => console.error(exception)) -.catch((ex) => console.error(ex)); \ No newline at end of file +.catch((ex) => console.error(ex)); + +Promise._immediateFn = setTimeout; diff --git a/types/promise-polyfill/tslint.json b/types/promise-polyfill/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/promise-polyfill/tslint.json +++ b/types/promise-polyfill/tslint.json @@ -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" } diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 37b652b832..17e738bb2a 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -29,8 +29,8 @@ declare namespace ReactIntl { withRef?: boolean; } - function injectIntl

(component: React.ComponentType

, options?: InjectIntlConfig): - React.ComponentClass>> & { WrappedComponent: React.ComponentType

}; + function injectIntl

(component: React.ComponentType

, options?: InjectIntlConfig): + React.ComponentClass>> & { WrappedComponent: React.ComponentType

}; function addLocaleData(data: Locale[] | Locale): void; diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index b8fa8d2af6..2386fc71c2 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3848,7 +3848,7 @@ export interface ViewabilityConfig { viewAreaCoveragePercentThreshold?: number; /** - * Similar to `viewAreaPercentThreshold`, but considers the percent of the item that is visible, + * Similar to `viewAreaCoveragePercentThreshold`, but considers the percent of the item that is visible, * rather than the fraction of the viewable area it covers. */ itemVisiblePercentThreshold?: number; diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 4e81a26c88..ada96b802f 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -14,7 +14,6 @@ // Steven Miller // Armando Assuncao // Ciaran Liedeman -// Edward Sammut Alessi // Jérémy Magrin // Luca Campana // Ullrich Schaefer @@ -25,6 +24,7 @@ // Denis Frezzato // Mickael Wegerich // Max Davidson +// Alec Hill // Lachlan Young // Jason Killian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -1247,7 +1247,7 @@ export type Omit = Pick>; export type InferProps> = T extends React.ComponentType ? P : never; export interface NavigationInjectedProps

{ - navigation: NavigationScreenProp; + navigation: NavigationScreenProp, P>; } // If the wrapped component is a class, we can get a ref to it diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 66bcf13c3c..116ae92c56 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -17,12 +17,14 @@ import { NavigationNavigateAction, NavigationProp, NavigationResetAction, + NavigationRoute, NavigationRouteConfigMap, NavigationScreenProp, NavigationScreenProps, NavigationSetParamsAction, NavigationStackAction, NavigationStackScreenOptions, + NavigationStateRoute, NavigationTabScreenOptions, NavigationTransitionProps, StackViewTransitionConfigs, @@ -70,10 +72,22 @@ interface StartScreenNavigationParams { */ class StartScreen extends React.Component> { render() { - // Implicit type checks. + // Injected type checks + const props: NavigationInjectedProps = this.props; + // route state... + const navigationState: NavigationRoute = this.props.navigation.state; + const index: number = navigationState.index; + const key: string = navigationState.key; + const routeName: string = navigationState.routeName; + const path: string | undefined = navigationState.path; + let routes: NavigationRoute[]; + if (isNavigationStateRoute(navigationState)) { + routes = navigationState.routes; + } + // params... const navigationStateParams: StartScreenNavigationParams | undefined = this.props.navigation.state.params; - const id = this.props.navigation.state.params && this.props.navigation.state.params.id; - const s = this.props.navigation.state.params && this.props.navigation.state.params.s; + const id: number | undefined = this.props.navigation.state.params && this.props.navigation.state.params.id; + const s: string | undefined = this.props.navigation.state.params && this.props.navigation.state.params.s; return ( @@ -107,17 +121,32 @@ interface NextScreenNavigationParams { class NextScreen extends React.Component> { render() { - // Implicit type checks. - const navigationStateParams: NextScreenNavigationParams | undefined = this.props.navigation.state.params; + // Injected type checks + const props: NavigationInjectedProps = this.props; + // route state... + const navigationState: NavigationRoute = this.props.navigation.state; + const index: number = navigationState.index; + const key: string = navigationState.key; + const routeName: string = navigationState.routeName; + const path: string | undefined = navigationState.path; + let routes: NavigationRoute[]; + if (isNavigationStateRoute(navigationState)) { + routes = navigationState.routes; + } + // params... + const navigationStateParams: NextScreenNavigationParams | undefined = navigationState.params; const id = this.props.navigation.state.params && this.props.navigation.state.params.id; const name = this.props.navigation.getParam('name', 'Peter'); - return ( ); } } +function isNavigationStateRoute

(route: NavigationRoute

): route is NavigationStateRoute

{ + return !!(route as NavigationStateRoute

).routes; +} + const navigationOptions = { headerBackTitle: null, }; diff --git a/types/recompose/index.d.ts b/types/recompose/index.d.ts index 6f61888954..e44ca48706 100644 --- a/types/recompose/index.d.ts +++ b/types/recompose/index.d.ts @@ -1,10 +1,11 @@ -// Type definitions for Recompose 0.27 +// Type definitions for Recompose 0.30 // Project: https://github.com/acdlite/recompose // Definitions by: Iskander Sierra // Curtis Layne // Rasmus Eneman // Lucas Terra // Brian Adams +// Mathieu Masy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -265,6 +266,17 @@ declare module 'recompose' { // toClass: https://github.com/acdlite/recompose/blob/master/docs/API.md#toClass export const toClass: InferableComponentEnhancer<{}>; + // toRenderProps: https://github.com/acdlite/recompose/blob/master/docs/API.md#torenderprops + export function toRenderProps( + hoc: InferableComponentEnhancerWithProps + ): StatelessComponent React.ReactElement }>; + + // fromRenderProps: https://github.com/acdlite/recompose/blob/master/docs/API.md#fromrenderprops + export function fromRenderProps( + RenderPropsComponent: StatelessComponent, + propsMapper: (props: TRenderProps) => Partial, + renderPropName?: string + ): ComponentEnhancer; // Static property helpers: https://github.com/acdlite/recompose/blob/master/docs/API.md#static-property-helpers @@ -586,6 +598,18 @@ declare module 'recompose/toClass' { export default toClass; } +// https://github.com/acdlite/recompose/blob/master/docs/API.md#torenderprops +declare module 'recompose/toRenderProps' { + import { toRenderProps } from 'recompose'; + export default toRenderProps; +} + +// https://github.com/acdlite/recompose/blob/master/docs/API.md#fromrenderprops +declare module 'recompose/fromRenderProps' { + import { fromRenderProps } from 'recompose'; + export default fromRenderProps; +} + // https://github.com/acdlite/recompose/blob/master/docs/API.md#setstatic declare module 'recompose/setStatic' { import { setStatic } from 'recompose'; diff --git a/types/recompose/recompose-tests.tsx b/types/recompose/recompose-tests.tsx index 4958f32e48..a0ba38a87a 100644 --- a/types/recompose/recompose-tests.tsx +++ b/types/recompose/recompose-tests.tsx @@ -7,7 +7,7 @@ import { withState, withReducer, branch, renderComponent, renderNothing, shouldUpdate, pure, onlyUpdateForKeys, onlyUpdateForPropTypes, withContext, getContext, - lifecycle, toClass, withStateHandlers, + lifecycle, toClass, toRenderProps, fromRenderProps, withStateHandlers, // Static property helpers setStatic, setPropTypes, setDisplayName, // Utilities @@ -51,6 +51,8 @@ import withContextStandalone from "recompose/withContext"; import getContextStandalone from "recompose/getContext"; import lifecycleStandalone from "recompose/lifecycle"; import toClassStandalone from "recompose/toClass"; +import toRenderPropsStandalone from "recompose/toRenderProps"; +import fromRenderPropsStandalone from "recompose/fromRenderProps"; import setStaticStandalone from "recompose/setStatic"; import setPropTypesStandalone from "recompose/setPropTypes"; import setDisplayNameStandalone from "recompose/setDisplayName"; @@ -496,3 +498,47 @@ function testSetDisplayName() { ClassResult = hoc(ClassComp); ClassResult = hoc(SfcComp); // $ExpectError } + +function testToRenderProps() { + interface OutterProps { + foo: number; + } + + interface InnerProps { + fooPlusOne: number; + } + + const enhance = withProps(({ foo }) => ({ fooPlusOne: foo + 1 })); + const Enhanced = toRenderProps(enhance); + + return {({ fooPlusOne }) =>

{fooPlusOne}

}; +} + +function testFromRenderProps() { + interface RenderProps { + value: string; + } + + interface InnerProps { + renderValue: string; + outterValue: number; + } + + interface OutterProps { + outterValue: number; + } + + const RenderPropComponent: React.StatelessComponent<{ + render: (renderProps: RenderProps) => React.ReactElement; + }> = ({ render }) => render({ value: 'test' }); + + const component: React.StatelessComponent = ({ renderValue }) =>
{renderValue}
; + + const Enhanced = fromRenderProps( + RenderPropComponent, + ({ value }) => ({ renderValue: value }), + 'render' + )(component); + + return ; +} diff --git a/types/redis/index.d.ts b/types/redis/index.d.ts index ff071e43e4..b838fcc1e9 100644 --- a/types/redis/index.d.ts +++ b/types/redis/index.d.ts @@ -1025,8 +1025,8 @@ export interface Commands { /** * Increment the score of a member in a sorted set. */ - zincrby(key: string, increment: number, member: string, cb?: Callback): R; - ZINCRBY(key: string, increment: number, member: string, cb?: Callback): R; + zincrby(key: string, increment: number, member: string, cb?: Callback): R; + ZINCRBY(key: string, increment: number, member: string, cb?: Callback): R; /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. diff --git a/types/redis/redis-tests.ts b/types/redis/redis-tests.ts index 18b9e11203..5d7d617b91 100644 --- a/types/redis/redis-tests.ts +++ b/types/redis/redis-tests.ts @@ -131,3 +131,5 @@ client.incrbyfloat('a', 1.5, (error, value) => value.startsWith('1')); client.INCRBYFLOAT('a', 1.5, (error, value) => value.startsWith('1')); client.hincrbyfloat('a', 'b', 1.5, (error, value) => value.startsWith('1')); client.HINCRBYFLOAT('a', 'b', 1.5, (error, value) => value.startsWith('1')); +client.zincrby('a', 1, 'b', strCallback); +client.ZINCRBY('a', 1, 'b', strCallback); diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index f80d5acc40..88ed87efae 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -3908,6 +3908,7 @@ declare namespace sequelize { */ findById(identifier?: number | string | Buffer, options?: FindOptions): Promise; findByPrimary(identifier?: number | string | Buffer, options?: FindOptions): Promise; + findByPk(identifier?: number | string | Buffer, options?: FindOptions): Promise; /** * Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 4e0aa9a73d..6b7ea6ea0a 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -981,6 +981,10 @@ User.findByPrimary( 'a string' ); User.findByPrimary( 42 ); User.findByPrimary( Buffer.from('a buffer') ); +User.findByPk( 'a string' ); +User.findByPk( 42 ); +User.findByPk( Buffer.from('a buffer') ); + User.findOne( { where : { username : 'foo' } } ); User.findOne( { where : { id : 1 }, attributes : ['id', ['username', 'name']] } ); User.findOne( { where : { id : 1 }, attributes : ['id'] } ); diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 95dded91e5..b5c3952e7a 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -524,7 +524,7 @@ declare namespace Sinon { * Makes the stub call the provided @param func when invoked. * @param func */ - callsFake(func: () => TReturnValue): SinonStub; + callsFake(func: (...args: TArgs) => TReturnValue): SinonStub; /** * Replaces a new getter for this stub. */ diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 8ae53c7d8e..d5ae4b0eb2 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -422,6 +422,7 @@ function testStub() { stub.callsArgOnAsync(1, instance); stub.callsArgWithAsync(1, 'a', 2); stub.callsArgOnWithAsync(1, instance, 'a', 2); + stub.callsFake((s1, s2, s3) => { }); stub.callsFake(() => { }); stub.get(() => true); stub.set((v) => { }); diff --git a/types/slate-react/index.d.ts b/types/slate-react/index.d.ts index 3d6d0e40df..540316befc 100644 --- a/types/slate-react/index.d.ts +++ b/types/slate-react/index.d.ts @@ -12,7 +12,7 @@ // TypeScript Version: 2.8 import { Document, - Editor as Controller, + Editor as CoreEditor, Mark, Node, Block, @@ -22,6 +22,14 @@ import { Stack, Value, Operation, + MarkProperties, + BlockProperties, + InlineProperties, + Path, + RangeProperties, + NodeProperties, + Range, + Controller } from "slate"; import * as Immutable from "immutable"; import * as React from "react"; @@ -34,7 +42,7 @@ export interface RenderAttributes { export interface RenderMarkProps { attributes: RenderAttributes; children: React.ReactNode; - editor: Controller; + editor: CoreEditor; mark: Mark; marks: Immutable.Set; node: Node; @@ -45,7 +53,7 @@ export interface RenderMarkProps { export interface RenderNodeProps { attributes: RenderAttributes; children: React.ReactNode; - editor: Controller; + editor: CoreEditor; isFocused: boolean; isSelected: boolean; key: string; @@ -55,23 +63,23 @@ export interface RenderNodeProps { } export interface RenderPlaceholderProps { - editor: Controller; + editor: CoreEditor; readOnly: boolean; } export type EventHook = ( event: Event, - editor: Controller, + editor: CoreEditor, next: () => any ) => any; export interface Plugin { - decorateNode?: (node: Node, editor: Controller, next: () => any) => any; - renderEditor?: (props: EditorProps, editor: Controller, next: () => any) => any; - renderMark?: (props: RenderMarkProps, editor: Controller, next: () => any) => any; - renderNode?: (props: RenderNodeProps, editor: Controller, next: () => any) => any; - renderPlaceholder?: (props: RenderPlaceholderProps, editor: Controller, next: () => any) => any; - shouldNodeComponentUpdate?: (previousProps: RenderNodeProps, props: RenderNodeProps, editor: Controller, next: () => any) => any; + decorateNode?: (node: Node, editor: CoreEditor, next: () => any) => any; + renderEditor?: (props: EditorProps, editor: CoreEditor, next: () => any) => any; + renderMark?: (props: RenderMarkProps, editor: CoreEditor, next: () => any) => any; + renderNode?: (props: RenderNodeProps, editor: CoreEditor, next: () => any) => any; + renderPlaceholder?: (props: RenderPlaceholderProps, editor: CoreEditor, next: () => any) => any; + shouldNodeComponentUpdate?: (previousProps: RenderNodeProps, props: RenderNodeProps, editor: CoreEditor, next: () => any) => any; onBeforeInput?: EventHook; onBlur?: EventHook; @@ -118,8 +126,8 @@ export interface EditorState { stack: Stack; } -export class Editor extends React.Component { - controller: Controller; +export class Editor extends React.Component implements Controller { + controller: CoreEditor; schema: Schema; stack: Stack; @@ -128,16 +136,242 @@ export class Editor extends React.Component { readonly readOnly: boolean; readonly value: Value; - // Instance Methods - applyOperation(...args: any[]): Controller; - blur(): void; - command(...args: any[]): Controller; - focus(): void; - normalize(...args: any[]): Controller; - query(...args: any[]): Controller; + // Instance methods resolveController(plugins: Plugin[], schema: Schema, commands: any[], queries: any[]): void; - run(...args: any[]): any; - withoutNormalizing(...args: any[]): Controller; + + // Controller + addMark: CoreEditor['addMark']; + delete: CoreEditor['delete']; + deleteBackward: CoreEditor['deleteBackward']; + deleteForward: CoreEditor['deleteForward']; + insertBlock: CoreEditor['insertBlock']; + insertFragment: CoreEditor['insertFragment']; + insertInline: CoreEditor['insertInline']; + insertText: CoreEditor['insertText']; + setBlocks: CoreEditor['setBlocks']; + setInlines: CoreEditor['setInlines']; + splitBlock: CoreEditor['splitBlock']; + splitInline: CoreEditor['splitInline']; + removeMark: CoreEditor['removeMark']; + replaceMark: CoreEditor['replaceMark']; + toggleMark: CoreEditor['toggleMark']; + unwrapBlock: CoreEditor['unwrapBlock']; + unwrapInline: CoreEditor['unwrapInline']; + wrapBlock: CoreEditor['wrapBlock']; + wrapInline: CoreEditor['wrapInline']; + wrapText: CoreEditor['wrapText']; + blur: CoreEditor['blur']; + deselect: CoreEditor['deselect']; + flip: CoreEditor['flip']; + focus: CoreEditor['focus']; + moveAnchorBackward: CoreEditor['moveAnchorBackward']; + moveAnchorForward: CoreEditor['moveAnchorForward']; + moveAnchorTo: CoreEditor['moveAnchorTo']; + moveAnchorToEndOfBlock: CoreEditor['moveAnchorToEndOfBlock']; + moveAnchorToEndOfInline: CoreEditor['moveAnchorToEndOfInline']; + moveAnchorToEndOfDocument: CoreEditor['moveAnchorToEndOfDocument']; + moveAnchorToEndOfNextBlock: CoreEditor['moveAnchorToEndOfNextBlock']; + moveAnchorToEndOfNextInline: CoreEditor['moveAnchorToEndOfNextInline']; + moveAnchorToEndOfNextText: CoreEditor['moveAnchorToEndOfNextText']; + moveAnchorEndOfNode: CoreEditor['moveAnchorEndOfNode']; + moveAnchorToEndOfPreviousBlock: CoreEditor['moveAnchorToEndOfPreviousBlock']; + moveAnchorToEndOfPreviousInline: CoreEditor['moveAnchorToEndOfPreviousInline']; + moveAnchorToEndOfPreviousText: CoreEditor['moveAnchorToEndOfPreviousText']; + moveAnchorToEndOfText: CoreEditor['moveAnchorToEndOfText']; + moveAnchorToStartOfBlock: CoreEditor['moveAnchorToStartOfBlock']; + moveAnchorToStartOfDocument: CoreEditor['moveAnchorToStartOfDocument']; + moveAnchorToStartOfInline: CoreEditor['moveAnchorToStartOfInline']; + moveAnchorToStartOfNextBlock: CoreEditor['moveAnchorToStartOfNextBlock']; + moveAnchorToStartOfNextInline: CoreEditor['moveAnchorToStartOfNextInline']; + moveAnchorToStartOfNextText: CoreEditor['moveAnchorToStartOfNextText']; + moveAnchorToStartOfNode: CoreEditor['moveAnchorToStartOfNode']; + moveAnchorToStartOfPreviousBlock: CoreEditor['moveAnchorToStartOfPreviousBlock']; + moveAnchorToStartOfPreviousInline: CoreEditor['moveAnchorToStartOfPreviousInline']; + moveAnchorToStartOfPreviousText: CoreEditor['moveAnchorToStartOfPreviousText']; + moveAnchorToStartOfText: CoreEditor['moveAnchorToStartOfText']; + moveEndBackward: CoreEditor['moveEndBackward']; + moveEndForward: CoreEditor['moveEndForward']; + moveEndTo: CoreEditor['moveEndTo']; + moveEndToEndOfBlock: CoreEditor['moveEndToEndOfBlock']; + moveEndToEndOfDocument: CoreEditor['moveEndToEndOfDocument']; + moveEndToEndOfInline: CoreEditor['moveEndToEndOfInline']; + moveEndToEndOfNextBlock: CoreEditor['moveEndToEndOfNextBlock']; + moveEndToEndOfNextInline: CoreEditor['moveEndToEndOfNextInline']; + moveEndToEndOfNextText: CoreEditor['moveEndToEndOfNextText']; + moveEndToEndOfNode: CoreEditor['moveEndToEndOfNode']; + moveEndToEndOfPreviousBlock: CoreEditor['moveEndToEndOfPreviousBlock']; + moveEndToEndOfPreviousInline: CoreEditor['moveEndToEndOfPreviousInline']; + moveEndToEndOfPreviousText: CoreEditor['moveEndToEndOfPreviousText']; + moveEndToEndOfText: CoreEditor['moveEndToEndOfText']; + moveEndToStartOfBlock: CoreEditor['moveEndToStartOfBlock']; + moveEndToStartOfDocument: CoreEditor['moveEndToStartOfDocument']; + moveEndToStartOfInline: CoreEditor['moveEndToStartOfInline']; + moveEndToStartOfNextBlock: CoreEditor['moveEndToStartOfNextBlock']; + moveEndToStartOfNextInline: CoreEditor['moveEndToStartOfNextInline']; + moveEndToStartOfNextText: CoreEditor['moveEndToStartOfNextText']; + moveEndToStartOfNode: CoreEditor['moveEndToStartOfNode']; + moveEndToStartOfPreviousBlock: CoreEditor['moveEndToStartOfPreviousBlock']; + moveEndToStartOfPreviousInline: CoreEditor['moveEndToStartOfPreviousInline']; + moveEndToStartOfPreviousText: CoreEditor['moveEndToStartOfPreviousText']; + moveEndToStartOfText: CoreEditor['moveEndToStartOfText']; + moveFocusBackward: CoreEditor['moveFocusBackward']; + moveFocusForward: CoreEditor['moveFocusForward']; + moveFocusTo: CoreEditor['moveFocusTo']; + moveFocusToEndOfBlock: CoreEditor['moveFocusToEndOfBlock']; + moveFocusToEndOfDocument: CoreEditor['moveFocusToEndOfDocument']; + moveFocusToEndOfInline: CoreEditor['moveFocusToEndOfInline']; + moveFocusToEndOfNextBlock: CoreEditor['moveFocusToEndOfNextBlock']; + moveFocusToEndOfNextInline: CoreEditor['moveFocusToEndOfNextInline']; + moveFocusToEndOfNextText: CoreEditor['moveFocusToEndOfNextText']; + moveFocusToEndOfNode: CoreEditor['moveFocusToEndOfNode']; + moveFocusToEndOfPreviousBlock: CoreEditor['moveFocusToEndOfPreviousBlock']; + moveFocusToEndOfPreviousInline: CoreEditor['moveFocusToEndOfPreviousInline']; + moveFocusToEndOfPreviousText: CoreEditor['moveFocusToEndOfPreviousText']; + moveFocusToEndOfText: CoreEditor['moveFocusToEndOfText']; + moveFocusToStartOfBlock: CoreEditor['moveFocusToStartOfBlock']; + moveFocusToStartOfDocument: CoreEditor['moveFocusToStartOfDocument']; + moveFocusToStartOfInline: CoreEditor['moveFocusToStartOfInline']; + moveFocusToStartOfNextBlock: CoreEditor['moveFocusToStartOfNextBlock']; + moveFocusToStartOfNextInline: CoreEditor['moveFocusToStartOfNextInline']; + moveFocusToStartOfNextText: CoreEditor['moveFocusToStartOfNextText']; + moveFocusToStartOfNode: CoreEditor['moveFocusToStartOfNode']; + moveFocusToStartOfPreviousBlock: CoreEditor['moveFocusToStartOfPreviousBlock']; + moveFocusToStartOfPreviousInline: CoreEditor['moveFocusToStartOfPreviousInline']; + moveFocusToStartOfPreviousText: CoreEditor['moveFocusToStartOfPreviousText']; + moveFocusToStartOfText: CoreEditor['moveFocusToStartOfText']; + moveStartForward: CoreEditor['moveStartForward']; + moveStartBackward: CoreEditor['moveStartBackward']; + moveStartTo: CoreEditor['moveStartTo']; + moveStartToEndOfBlock: CoreEditor['moveStartToEndOfBlock']; + moveStartToEndOfDocument: CoreEditor['moveStartToEndOfDocument']; + moveStartToEndOfInline: CoreEditor['moveStartToEndOfInline']; + moveStartToEndOfNextBlock: CoreEditor['moveStartToEndOfNextBlock']; + moveStartToEndOfNextInline: CoreEditor['moveStartToEndOfNextInline']; + moveStartToEndOfNextText: CoreEditor['moveStartToEndOfNextText']; + moveStartToEndOfNode: CoreEditor['moveStartToEndOfNode']; + moveStartToEndOfPreviousBlock: CoreEditor['moveStartToEndOfPreviousBlock']; + moveStartToEndOfPreviousInline: CoreEditor['moveStartToEndOfPreviousInline']; + moveStartToEndOfPreviousText: CoreEditor['moveStartToEndOfPreviousText']; + moveStartToEndOfText: CoreEditor['moveStartToEndOfText']; + moveStartToStartOfBlock: CoreEditor['moveStartToStartOfBlock']; + moveStartToStartOfDocument: CoreEditor['moveStartToStartOfDocument']; + moveStartToStartOfInline: CoreEditor['moveStartToStartOfInline']; + moveStartToStartOfNextBlock: CoreEditor['moveStartToStartOfNextBlock']; + moveStartToStartOfNextInline: CoreEditor['moveStartToStartOfNextInline']; + moveStartToStartOfNextText: CoreEditor['moveStartToStartOfNextText']; + moveStartToStartOfNode: CoreEditor['moveStartToStartOfNode']; + moveStartToStartOfPreviousBlock: CoreEditor['moveStartToStartOfPreviousBlock']; + moveStartToStartOfPreviousInline: CoreEditor['moveStartToStartOfPreviousInline']; + moveStartToStartOfPreviousText: CoreEditor['moveStartToStartOfPreviousText']; + moveStartToStartOfText: CoreEditor['moveStartToStartOfText']; + moveBackward: CoreEditor['moveBackward']; + moveForward: CoreEditor['moveForward']; + moveTo: CoreEditor['moveTo']; + moveToAnchor: CoreEditor['moveToAnchor']; + moveToFocus: CoreEditor['moveToFocus']; + moveToStart: CoreEditor['moveToStart']; + moveToEnd: CoreEditor['moveToEnd']; + moveToEndOfBlock: CoreEditor['moveToEndOfBlock']; + moveToEndOfDocument: CoreEditor['moveToEndOfDocument']; + moveToEndOfInline: CoreEditor['moveToEndOfInline']; + moveToEndOfNextBlock: CoreEditor['moveToEndOfNextBlock']; + moveToEndOfNextInline: CoreEditor['moveToEndOfNextInline']; + moveToEndOfNextText: CoreEditor['moveToEndOfNextText']; + moveToEndOfNode: CoreEditor['moveToEndOfNode']; + moveToEndOfPreviousBlock: CoreEditor['moveToEndOfPreviousBlock']; + moveToEndOfPreviousInline: CoreEditor['moveToEndOfPreviousInline']; + moveToEndOfPreviousText: CoreEditor['moveToEndOfPreviousText']; + moveToEndOfText: CoreEditor['moveToEndOfText']; + moveToStartOfBlock: CoreEditor['moveToStartOfBlock']; + moveToStartOfDocument: CoreEditor['moveToStartOfDocument']; + moveToStartOfInline: CoreEditor['moveToStartOfInline']; + moveToStartOfNextBlock: CoreEditor['moveToStartOfNextBlock']; + moveToStartOfNextInline: CoreEditor['moveToStartOfNextInline']; + moveToStartOfNextText: CoreEditor['moveToStartOfNextText']; + moveToStartOfNode: CoreEditor['moveToStartOfNode']; + moveToStartOfPreviousBlock: CoreEditor['moveToStartOfPreviousBlock']; + moveToStartOfPreviousInline: CoreEditor['moveToStartOfPreviousInline']; + moveToStartOfPreviousText: CoreEditor['moveToStartOfPreviousText']; + moveToStartOfText: CoreEditor['moveToStartOfText']; + moveToRangeOfDocument: CoreEditor['moveToRangeOfDocument']; + moveToRangeOf: CoreEditor['moveToRangeOf']; + select: CoreEditor['select']; + addMarkAtRange: CoreEditor['addMarkAtRange']; + deleteAtRange: CoreEditor['deleteAtRange']; + deleteCharBackwardAtRange: CoreEditor['deleteCharBackwardAtRange']; + deleteLineBackwardAtRange: CoreEditor['deleteLineBackwardAtRange']; + deleteWordBackwardAtRange: CoreEditor['deleteWordBackwardAtRange']; + deleteBackwardAtRange: CoreEditor['deleteBackwardAtRange']; + deleteCharForwardAtRange: CoreEditor['deleteCharForwardAtRange']; + deleteLineForwardAtRange: CoreEditor['deleteLineForwardAtRange']; + deleteWordForwardAtRange: CoreEditor['deleteWordForwardAtRange']; + deleteForwardAtRange: CoreEditor['deleteForwardAtRange']; + insertBlockAtRange: CoreEditor['insertBlockAtRange']; + insertFragmentAtRange: CoreEditor['insertFragmentAtRange']; + insertInlineAtRange: CoreEditor['insertInlineAtRange']; + insertTextAtRange: CoreEditor['insertTextAtRange']; + setBlocksAtRange: CoreEditor['setBlocksAtRange']; + setInlinesAtRange: CoreEditor['setInlinesAtRange']; + splitBlockAtRange: CoreEditor['splitBlockAtRange']; + splitInlineAtRange: CoreEditor['splitInlineAtRange']; + removeMarkAtRange: CoreEditor['removeMarkAtRange']; + toggleMarkAtRange: CoreEditor['toggleMarkAtRange']; + unwrapBlockAtRange: CoreEditor['unwrapBlockAtRange']; + unwrapInlineAtRange: CoreEditor['unwrapInlineAtRange']; + wrapBlockAtRange: CoreEditor['wrapBlockAtRange']; + wrapInlineAtRange: CoreEditor['wrapInlineAtRange']; + wrapTextAtRange: CoreEditor['wrapTextAtRange']; + addMarkByKey: CoreEditor['addMarkByKey']; + addMarkByPath: CoreEditor['addMarkByPath']; + insertNodeByKey: CoreEditor['insertNodeByKey']; + insertNodeByPath: CoreEditor['insertNodeByPath']; + insertFragmentByKey: CoreEditor['insertFragmentByKey']; + insertFragmentByPath: CoreEditor['insertFragmentByPath']; + insertTextByKey: CoreEditor['insertTextByKey']; + insertTextByPath: CoreEditor['insertTextByPath']; + mergeNodeByKey: CoreEditor['mergeNodeByKey']; + mergeNodeByPath: CoreEditor['mergeNodeByPath']; + moveNodeByKey: CoreEditor['moveNodeByKey']; + moveNodeByPath: CoreEditor['moveNodeByPath']; + removeMarkByKey: CoreEditor['removeMarkByKey']; + removeMarkByPath: CoreEditor['removeMarkByPath']; + removeNodeByKey: CoreEditor['removeNodeByKey']; + removeNodeByPath: CoreEditor['removeNodeByPath']; + replaceNodeByKey: CoreEditor['replaceNodeByKey']; + replaceNodeByPath: CoreEditor['replaceNodeByPath']; + removeTextByKey: CoreEditor['removeTextByKey']; + removeTextByPath: CoreEditor['removeTextByPath']; + setMarkByKey: CoreEditor['setMarkByKey']; + setMarksByPath: CoreEditor['setMarksByPath']; + setNodeByKey: CoreEditor['setNodeByKey']; + setNodeByPath: CoreEditor['setNodeByPath']; + splitNodeByKey: CoreEditor['splitNodeByKey']; + splitNodeByPath: CoreEditor['splitNodeByPath']; + unwrapInlineByKey: CoreEditor['unwrapInlineByKey']; + unwrapInlineByPath: CoreEditor['unwrapInlineByPath']; + unwrapBlockByKey: CoreEditor['unwrapBlockByKey']; + unwrapBlockByPath: CoreEditor['unwrapBlockByPath']; + unwrapNodeByKey: CoreEditor['unwrapNodeByKey']; + unwrapNodeByPath: CoreEditor['unwrapNodeByPath']; + wrapInlineByKey: CoreEditor['wrapInlineByKey']; + wrapInlineByPath: CoreEditor['wrapInlineByPath']; + wrapBlockByKey: CoreEditor['wrapBlockByKey']; + wrapBlockByPath: CoreEditor['wrapBlockByPath']; + wrapNodeByKey: CoreEditor['wrapNodeByKey']; + wrapNodeByPath: CoreEditor['wrapNodeByPath']; + normalize: CoreEditor['normalize']; + withoutNormalizing: CoreEditor['withoutNormalizing']; + withoutSaving: CoreEditor['withoutSaving']; + withoutMerging: CoreEditor['withoutMerging']; + redo: CoreEditor['redo']; + undo: CoreEditor['undo']; + snapshotSelection: CoreEditor['snapshotSelection']; + command: CoreEditor['command']; + query: CoreEditor['query']; + registerCommand: CoreEditor['registerCommand']; + registerQuery: CoreEditor['registerQuery']; + applyOperation: CoreEditor['applyOperation']; + run: CoreEditor['run']; } export type SlateType = diff --git a/types/slate-react/slate-react-tests.tsx b/types/slate-react/slate-react-tests.tsx index d8ef3b29be..4f8f55b47b 100644 --- a/types/slate-react/slate-react-tests.tsx +++ b/types/slate-react/slate-react-tests.tsx @@ -1,5 +1,5 @@ import { Editor, Plugin, EditorProps, RenderNodeProps } from "slate-react"; -import { Value, Editor as Controller, Operation } from "slate"; +import { Value, Editor as Controller, Operation, Point, Range, Inline, Mark, Document } from "slate"; import * as React from "react"; import * as Immutable from "immutable"; @@ -28,11 +28,13 @@ interface MyEditorState { value: Value; } +const value = Value.create(); + class MyEditor extends React.Component { constructor(props: EditorProps) { super(props); this.state = { - value: Value.create() + value }; } render() { @@ -42,3 +44,250 @@ class MyEditor extends React.Component { onChange={ myPlugin.onChange }/>; } } + +const editor = new Editor({ value }); +const point = Point.create({ key: "a", offset: 0 }); +const range = Range.create({ anchor: point, focus: point }); +const inline = Inline.create("text"); +const mark = Mark.create("bold"); +const doc = Document.fromJSON({ + object: "document", + data: {}, + nodes: [] +}); + +editor +.addMark("bold") +.addMarkAtRange(range, "italic") +.addMarkByKey("a", 0, 1, "bold") +.addMarkByPath("a", 0, 1, "bold") +.blur() +.delete() +.deleteAtRange(range) +.deleteBackward(0) +.deleteBackwardAtRange(range, 0) +.deleteCharBackwardAtRange(range) +.deleteCharForwardAtRange(range) +.deleteForward(0) +.deleteForwardAtRange(range, 0) +.deleteLineBackwardAtRange(range) +.deleteLineForwardAtRange(range) +.deleteWordBackwardAtRange(range) +.deleteWordForwardAtRange(range) +.deselect() +.flip() +.focus() +.insertBlock({ + type: "image", + key: "b", + data: { + src: "http://placekitten.com/200/300", + alt: "Kittens", + className: "img-responsive" + } +}) +.insertBlockAtRange(range, "text") +.insertFragment(doc) +.insertFragmentAtRange(range, doc) +.insertFragmentByKey("a", 0, doc) +.insertFragmentByPath("a", 0, doc) +.insertInline(inline) +.insertInlineAtRange(range, inline) +.insertNodeByKey("a", 0, inline) +.insertNodeByPath("a", 0, inline) +.insertText("A bit of rich text, followed by...") +.insertTextAtRange(range, "More text") +.insertTextByKey("a", 0, "text") +.insertTextByPath("a", 0, "text") +.mergeNodeByKey("b") +.mergeNodeByPath("b") +.moveAnchorBackward() +.moveAnchorEndOfNode(inline) +.moveAnchorForward() +.moveAnchorTo("a", 0) +.moveAnchorToEndOfBlock() +.moveAnchorToEndOfDocument() +.moveAnchorToEndOfInline() +.moveAnchorToEndOfNextBlock() +.moveAnchorToEndOfNextInline() +.moveAnchorToEndOfNextText() +.moveAnchorToEndOfPreviousBlock() +.moveAnchorToEndOfPreviousInline() +.moveAnchorToEndOfPreviousText() +.moveAnchorToEndOfText() +.moveAnchorToStartOfBlock() +.moveAnchorToStartOfDocument() +.moveAnchorToStartOfInline() +.moveAnchorToStartOfNextBlock() +.moveAnchorToStartOfNextInline() +.moveAnchorToStartOfNextText() +.moveAnchorToStartOfNode(inline) +.moveAnchorToStartOfPreviousBlock() +.moveAnchorToStartOfPreviousInline() +.moveAnchorToStartOfPreviousText() +.moveAnchorToStartOfText() +.moveBackward() +.moveEndBackward() +.moveEndForward() +.moveEndTo("a", 0) +.moveEndToEndOfBlock() +.moveEndToEndOfDocument() +.moveEndToEndOfInline() +.moveEndToEndOfNextBlock() +.moveEndToEndOfNextInline() +.moveEndToEndOfNextText() +.moveEndToEndOfNode(inline) +.moveEndToEndOfPreviousBlock() +.moveEndToEndOfPreviousInline() +.moveEndToEndOfPreviousText() +.moveEndToEndOfText() +.moveEndToStartOfBlock() +.moveEndToStartOfDocument() +.moveEndToStartOfInline() +.moveEndToStartOfNextBlock() +.moveEndToStartOfNextInline() +.moveEndToStartOfNextText() +.moveEndToStartOfNode(inline) +.moveEndToStartOfPreviousBlock() +.moveEndToStartOfPreviousInline() +.moveEndToStartOfPreviousText() +.moveEndToStartOfText() +.moveFocusBackward() +.moveFocusForward() +.moveFocusTo("a", 0) +.moveFocusToEndOfBlock() +.moveFocusToEndOfDocument() +.moveFocusToEndOfInline() +.moveFocusToEndOfNextBlock() +.moveFocusToEndOfNextInline() +.moveFocusToEndOfNextText() +.moveFocusToEndOfNode(inline) +.moveFocusToEndOfPreviousBlock() +.moveFocusToEndOfPreviousInline() +.moveFocusToEndOfPreviousText() +.moveFocusToEndOfText() +.moveFocusToStartOfBlock() +.moveFocusToStartOfDocument() +.moveFocusToStartOfInline() +.moveFocusToStartOfNextBlock() +.moveFocusToStartOfNextInline() +.moveFocusToStartOfNextText() +.moveFocusToStartOfNode(inline) +.moveFocusToStartOfPreviousBlock() +.moveFocusToStartOfPreviousInline() +.moveFocusToStartOfPreviousText() +.moveFocusToStartOfText() +.moveForward() +.moveNodeByKey("b", "c", 2) +.moveNodeByPath("c", "b", 1) +.moveStartBackward() +.moveStartForward() +.moveStartTo("a", 0) +.moveStartToEndOfBlock() +.moveStartToEndOfDocument() +.moveStartToEndOfInline() +.moveStartToEndOfNextBlock() +.moveStartToEndOfNextInline() +.moveStartToEndOfNextText() +.moveStartToEndOfNode(inline) +.moveStartToEndOfPreviousBlock() +.moveStartToEndOfPreviousInline() +.moveStartToEndOfPreviousText() +.moveStartToEndOfText() +.moveStartToStartOfBlock() +.moveStartToStartOfDocument() +.moveStartToStartOfInline() +.moveStartToStartOfNextBlock() +.moveStartToStartOfNextInline() +.moveStartToStartOfNextText() +.moveStartToStartOfNode(inline) +.moveStartToStartOfPreviousBlock() +.moveStartToStartOfPreviousInline() +.moveStartToStartOfPreviousText() +.moveStartToStartOfText() +.moveTo("a", 0) +.moveToAnchor() +.moveToEnd() +.moveToEndOfBlock() +.moveToEndOfDocument() +.moveToEndOfInline() +.moveToEndOfNextBlock() +.moveToEndOfNextInline() +.moveToEndOfNextText() +.moveToEndOfNode(inline) +.moveToEndOfPreviousBlock() +.moveToEndOfPreviousInline() +.moveToEndOfPreviousText() +.moveToEndOfText() +.moveToFocus() +.moveToRangeOf(inline) +.moveToRangeOfDocument() +.moveToStart() +.moveToStartOfBlock() +.moveToStartOfDocument() +.moveToStartOfInline() +.moveToStartOfNextBlock() +.moveToStartOfNextInline() +.moveToStartOfNextText() +.moveToStartOfNode(inline) +.moveToStartOfPreviousBlock() +.moveToStartOfPreviousInline() +.moveToStartOfPreviousText() +.moveToStartOfText() +.normalize() +.redo() +.removeMark("bold") +.removeMarkAtRange(range, "bold") +.removeMarkByKey("a", 0, 1, "bold") +.removeMarkByPath("a", 0, 1, "bold") +.removeNodeByKey("b") +.removeNodeByPath("b") +.removeTextByKey("a", 0, 1) +.removeTextByPath("a", 0, 1) +.replaceMark("bold", "italic") +.replaceNodeByKey("a", inline) +.replaceNodeByPath("a", inline) +.select(range) +.setBlocks("paragraph") +.setBlocksAtRange(range, "paragraph") +.setInlines("paragraph") +.setInlinesAtRange(range, "paragraph") +.setMarkByKey("a", 0, 1, mark, { type: "bold" }) +.setMarksByPath("a", 0, 1, mark, { type: "bold" }) +.setNodeByKey("a", "paragraph") +.setNodeByPath("a", "paragraph") +.snapshotSelection() +.splitBlock(0) +.splitBlockAtRange(range, 0) +.splitInline(0) +.splitInlineAtRange(range, 0) +.splitNodeByKey("a", 0) +.splitNodeByPath("a", 0) +.toggleMark("bold") +.toggleMarkAtRange(range, "bold") +.undo() +.unwrapBlock("paragraph") +.unwrapBlockAtRange(range, "paragraph") +.unwrapBlockByKey("a", "paragraph") +.unwrapBlockByPath("a", "paragraph") +.unwrapInline("paragraph") +.unwrapInlineAtRange(range, "paragraph") +.unwrapInlineByKey("a", "paragraph") +.unwrapInlineByPath("a", "paragraph") +.unwrapNodeByKey("a") +.unwrapNodeByPath("a") +.withoutMerging(() => { /* noop */ }) +.withoutNormalizing(() => { /* noop */ }) +.withoutSaving(() => { /* noop */ }) +.wrapBlock("paragraph") +.wrapBlockAtRange(range, "paragraph") +.wrapBlockByKey("a", "paragraph") +.wrapBlockByPath("a", "paragraph") +.wrapInline("paragraph") +.wrapInlineAtRange(range, "paragraph") +.wrapInlineByKey("a", "paragraph") +.wrapInlineByPath("a", "paragraph") +.wrapNodeByKey("a", inline) +.wrapNodeByPath("a", inline) +.wrapText("a", "b") +.wrapTextAtRange(range, "a"); diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index bb35c6483f..5656c58bb3 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -1054,7 +1054,7 @@ export interface EditorProperties { value?: Value; } -export class Editor { +export class Editor implements Controller { object: "editor"; onChange: (change: { operations: Immutable.List, value: Value }) => void; plugins: any[]; @@ -1062,35 +1062,12 @@ export class Editor { value: Value; constructor(attributes: EditorProperties) - /** - * Apply an `operation` to the editor, updating its value. - */ - applyOperation(operation: Operation): Editor; - /** * Synchronously flush the current changes to editor, calling onChange. * In normal operation you never need to use this method! Reserved for testing. */ flush(): Editor; - command(name: string, ...args: any[]): void; - query(query: string, ...args: any[]): any; - - /** - * Add a new command by type with the editor. This will make the command available as a top-level method on the editor - */ - registerCommand(command: string): void; - - /** - * Add a new query by type with the editor. This will make the query available as a top-level method on the editor. - */ - registerQuery(query: string): void; - - /** - * Run the middleware stack by key with args, returning its result. - * In normal operation you never need to use this method! Reserved for testing. - */ - run(key: string, ...args: any[]): any; setReadOnly(readOnly: boolean): Editor; /** @@ -1100,81 +1077,361 @@ export class Editor { */ setValue(value: Value, options?: { normalize: boolean }): Editor; - // Built in Command Operations // + // Commandable + addMark(mark: Mark | MarkProperties | string): Editor; + delete(): Editor; + deleteBackward(n: number): Editor; + deleteForward(n: number): Editor; + insertBlock(block: Block | BlockProperties | string): Editor; + insertFragment(fragment: Document): Editor; + insertInline(inline: Inline | InlineProperties): Editor; + insertText(text: string): Editor; + setBlocks(properties: BlockProperties | string): Editor; + setInlines(properties: InlineProperties | string): Editor; + splitBlock(depth: number): Editor; + splitInline(depth: number): Editor; + removeMark(mark: Mark | MarkProperties | string): Editor; + replaceMark( + mark: Mark | MarkProperties | string, + newMark: Mark | MarkProperties | string + ): Editor; + toggleMark(mark: Mark | MarkProperties | string): Editor; + unwrapBlock(properties: BlockProperties | string): Editor; + unwrapInline(properties: InlineProperties | string): Editor; + wrapBlock(properties: BlockProperties | string): Editor; + wrapInline(properties: InlineProperties | string): Editor; + wrapText(prefix: string, suffix?: string): Editor; + blur(): Editor; + deselect(): Editor; + flip(): Editor; + focus(): Editor; + moveAnchorBackward(n?: number): Editor; + moveAnchorForward(n?: number): Editor; + moveAnchorTo(path: Path, offset?: number): Editor; + moveAnchorToEndOfBlock(): Editor; + moveAnchorToEndOfInline(): Editor; + moveAnchorToEndOfDocument(): Editor; + moveAnchorToEndOfNextBlock(): Editor; + moveAnchorToEndOfNextInline(): Editor; + moveAnchorToEndOfNextText(): Editor; + moveAnchorEndOfNode(node: Node): Editor; + moveAnchorToEndOfPreviousBlock(): Editor; + moveAnchorToEndOfPreviousInline(): Editor; + moveAnchorToEndOfPreviousText(): Editor; + moveAnchorToEndOfText(): Editor; + moveAnchorToStartOfBlock(): Editor; + moveAnchorToStartOfDocument(): Editor; + moveAnchorToStartOfInline(): Editor; + moveAnchorToStartOfNextBlock(): Editor; + moveAnchorToStartOfNextInline(): Editor; + moveAnchorToStartOfNextText(): Editor; + moveAnchorToStartOfNode(node: Node): Editor; + moveAnchorToStartOfPreviousBlock(): Editor; + moveAnchorToStartOfPreviousInline(): Editor; + moveAnchorToStartOfPreviousText(): Editor; + moveAnchorToStartOfText(): Editor; + moveEndBackward(n?: number): Editor; + moveEndForward(n?: number): Editor; + moveEndTo(path: Path, offset?: number): Editor; + moveEndToEndOfBlock(): Editor; + moveEndToEndOfDocument(): Editor; + moveEndToEndOfInline(): Editor; + moveEndToEndOfNextBlock(): Editor; + moveEndToEndOfNextInline(): Editor; + moveEndToEndOfNextText(): Editor; + moveEndToEndOfNode(node: Node): Editor; + moveEndToEndOfPreviousBlock(): Editor; + moveEndToEndOfPreviousInline(): Editor; + moveEndToEndOfPreviousText(): Editor; + moveEndToEndOfText(): Editor; + moveEndToStartOfBlock(): Editor; + moveEndToStartOfDocument(): Editor; + moveEndToStartOfInline(): Editor; + moveEndToStartOfNextBlock(): Editor; + moveEndToStartOfNextInline(): Editor; + moveEndToStartOfNextText(): Editor; + moveEndToStartOfNode(node: Node): Editor; + moveEndToStartOfPreviousBlock(): Editor; + moveEndToStartOfPreviousInline(): Editor; + moveEndToStartOfPreviousText(): Editor; + moveEndToStartOfText(): Editor; + moveFocusBackward(n?: number): Editor; + moveFocusForward(n?: number): Editor; + moveFocusTo(path: Path, offset?: number): Editor; + moveFocusToEndOfBlock(): Editor; + moveFocusToEndOfDocument(): Editor; + moveFocusToEndOfInline(): Editor; + moveFocusToEndOfNextBlock(): Editor; + moveFocusToEndOfNextInline(): Editor; + moveFocusToEndOfNextText(): Editor; + moveFocusToEndOfNode(node: Node): Editor; + moveFocusToEndOfPreviousBlock(): Editor; + moveFocusToEndOfPreviousInline(): Editor; + moveFocusToEndOfPreviousText(): Editor; + moveFocusToEndOfText(): Editor; + moveFocusToStartOfBlock(): Editor; + moveFocusToStartOfDocument(): Editor; + moveFocusToStartOfInline(): Editor; + moveFocusToStartOfNextBlock(): Editor; + moveFocusToStartOfNextInline(): Editor; + moveFocusToStartOfNextText(): Editor; + moveFocusToStartOfNode(node: Node): Editor; + moveFocusToStartOfPreviousBlock(): Editor; + moveFocusToStartOfPreviousInline(): Editor; + moveFocusToStartOfPreviousText(): Editor; + moveFocusToStartOfText(): Editor; + moveStartForward(n?: number): Editor; + moveStartBackward(n?: number): Editor; + moveStartTo(path: Path, n?: number): Editor; + moveStartToEndOfBlock(): Editor; + moveStartToEndOfDocument(): Editor; + moveStartToEndOfInline(): Editor; + moveStartToEndOfNextBlock(): Editor; + moveStartToEndOfNextInline(): Editor; + moveStartToEndOfNextText(): Editor; + moveStartToEndOfNode(node: Node): Editor; + moveStartToEndOfPreviousBlock(): Editor; + moveStartToEndOfPreviousInline(): Editor; + moveStartToEndOfPreviousText(): Editor; + moveStartToEndOfText(): Editor; + moveStartToStartOfBlock(): Editor; + moveStartToStartOfDocument(): Editor; + moveStartToStartOfInline(): Editor; + moveStartToStartOfNextBlock(): Editor; + moveStartToStartOfNextInline(): Editor; + moveStartToStartOfNextText(): Editor; + moveStartToStartOfNode(node: Node): Editor; + moveStartToStartOfPreviousBlock(): Editor; + moveStartToStartOfPreviousInline(): Editor; + moveStartToStartOfPreviousText(): Editor; + moveStartToStartOfText(): Editor; + moveBackward(n?: number): Editor; + moveForward(n?: number): Editor; + moveTo(path: Path, offset?: number): Editor; + moveToAnchor(): Editor; + moveToFocus(): Editor; + moveToStart(): Editor; + moveToEnd(): Editor; + moveToEndOfBlock(): Editor; + moveToEndOfDocument(): Editor; + moveToEndOfInline(): Editor; + moveToEndOfNextBlock(): Editor; + moveToEndOfNextInline(): Editor; + moveToEndOfNextText(): Editor; + moveToEndOfNode(node: Node): Editor; + moveToEndOfPreviousBlock(): Editor; + moveToEndOfPreviousInline(): Editor; + moveToEndOfPreviousText(): Editor; + moveToEndOfText(): Editor; + moveToStartOfBlock(): Editor; + moveToStartOfDocument(): Editor; + moveToStartOfInline(): Editor; + moveToStartOfNextBlock(): Editor; + moveToStartOfNextInline(): Editor; + moveToStartOfNextText(): Editor; + moveToStartOfNode(node: Node): Editor; + moveToStartOfPreviousBlock(): Editor; + moveToStartOfPreviousInline(): Editor; + moveToStartOfPreviousText(): Editor; + moveToStartOfText(): Editor; + moveToRangeOfDocument(): Editor; + moveToRangeOf(node: Node): Editor; + select(properties: Range | RangeProperties): Editor; + addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + deleteAtRange(range: Range): Editor; + deleteCharBackwardAtRange(range: Range): Editor; + deleteLineBackwardAtRange(range: Range): Editor; + deleteWordBackwardAtRange(range: Range): Editor; + deleteBackwardAtRange(range: Range, n: number): Editor; + deleteCharForwardAtRange(range: Range): Editor; + deleteLineForwardAtRange(range: Range): Editor; + deleteWordForwardAtRange(range: Range): Editor; + deleteForwardAtRange(range: Range, n: number): Editor; + insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Editor; + insertFragmentAtRange(range: Range, fragment: Document): Editor; + insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Editor; + insertTextAtRange(range: Range, text: string): Editor; + setBlocksAtRange(range: Range, properties: BlockProperties | string): Editor; + setInlinesAtRange(range: Range, properties: InlineProperties | string): Editor; + splitBlockAtRange(range: Range, depth: number): Editor; + splitInlineAtRange(range: Range, depth: number): Editor; + removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + wrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapTextAtRange(range: Range, prefix: string, suffix?: string): Editor; + addMarkByKey( + key: string, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + addMarkByPath( + path: Path, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + insertNodeByKey(key: string, index: number, node: Node): Editor; + insertNodeByPath(path: Path, index: number, node: Node): Editor; + insertFragmentByKey(key: string, index: number, fragment: Document): Editor; + insertFragmentByPath(path: Path, index: number, fragment: Document): Editor; + insertTextByKey( + key: string, + offset: number, + text: string, + marks?: Immutable.Set | Mark[] + ): Editor; + insertTextByPath( + path: Path, + offset: number, + text: string, + marks?: Immutable.Set | Mark[] + ): Editor; + mergeNodeByKey(key: string): Editor; + mergeNodeByPath(path: Path): Editor; + moveNodeByKey(key: string, newKey: string, newIndex: number): Editor; + moveNodeByPath(path: Path, newPath: Path, newIndex: number): Editor; + removeMarkByKey( + key: string, + offset: number, + length: number, + mark: Mark | Mark | string + ): Editor; + removeMarkByPath( + path: Path, + offset: number, + length: number, + mark: MarkProperties | Mark | string + ): Editor; + removeNodeByKey(key: string): Editor; + removeNodeByPath(path: Path): Editor; + replaceNodeByKey(key: string, node: Node): Editor; + replaceNodeByPath(path: Path, newNode: Node): Editor; + removeTextByKey(key: string, offset: number, length: number): Editor; + removeTextByPath(path: Path, offset: number, length: number): Editor; + setMarkByKey( + key: string, + offset: number, + length: number, + mark: Mark, + properties: MarkProperties + ): Editor; + setMarksByPath( + path: Path, + offset: number, + length: number, + mark: Mark, + properties: MarkProperties + ): Editor; + setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Editor; + setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Editor; + splitNodeByKey(key: string, offset: number): Editor; + splitNodeByPath(path: Path, position: number): Editor; + unwrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + unwrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + unwrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + unwrapBlockByPath(path: Path, properties: BlockProperties | string): Editor; + unwrapNodeByKey(key: string): Editor; + unwrapNodeByPath(path: Path): Editor; + wrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + wrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + wrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + wrapBlockByPath(path: Path, block: Block | string): Editor; + wrapNodeByKey(key: string, parent: Node): Editor; + wrapNodeByPath(path: Path, parent: Node): Editor; + normalize(): Editor; + withoutNormalizing(fn: () => void): Editor; + withoutSaving(fn: () => void): Editor; + withoutMerging(fn: () => void): Editor; + redo(): Editor; + undo(): Editor; + snapshotSelection(): Editor; + command(name: string, ...args: any[]): Editor; + query(query: string, ...args: any[]): Editor; + registerCommand(command: string): Editor; + registerQuery(query: string): Editor; + applyOperation(operation: Operation): Editor; + run(key: string, ...args: any[]): Editor; +} + +export interface Controller { // Current Selection Commands // /** * Add a mark to the characters in the current selection */ - addMark(mark: Mark | MarkProperties | string): Editor; + addMark(mark: Mark | MarkProperties | string): Controller; /** * Delete everything in the current selection. */ - delete(): Editor; + delete(): Controller; /** * Delete backward n characters at the current cursor. * If the selection is expanded, behaviour is equivalent to delete() */ - deleteBackward(n: number): Editor; + deleteBackward(n: number): Controller; /** * Delete backward n characters at the current cursor. * If the selection is expanded, behaviour is equivalent to delete() */ - deleteForward(n: number): Editor; + deleteForward(n: number): Controller; /** * Insert a new block at the same level as the current block, splitting the current block to make room if it is non-empty. * If the selection is expanded, it will be deleted first. */ - insertBlock(block: Block | BlockProperties | string): Editor; + insertBlock(block: Block | BlockProperties | string): Controller; /** * Insert a document fragment at the current selection. If the selection is expanded, it will be deleted first. */ - insertFragment(fragment: Document): Editor; + insertFragment(fragment: Document): Controller; /** * Insert a new inline at the current cursor position, splitting the text to make room if it is non-empty. * If the selection is expanded, it will be deleted first. */ - insertInline(inline: Inline | InlineProperties): Editor; + insertInline(inline: Inline | InlineProperties): Controller; /** * Insert a string of text at the current selection. If the selection is expanded, it will be deleted first */ - insertText(text: string): Editor; + insertText(text: string): Controller; /** * Set the properties of the Blocks in the current selection. * Passing a string will set the blocks' type only. */ - setBlocks(properties: BlockProperties | string): Editor; + setBlocks(properties: BlockProperties | string): Controller; /** * Set the properties of the Inlines nodes in the current selection. * Passing a string will set the nodes' type only. */ - setInlines(properties: InlineProperties | string): Editor; + setInlines(properties: InlineProperties | string): Controller; /** * Split the Block in the current selection by depth levels. * If the selection is expanded, it will be deleted first. */ - splitBlock(depth: number): Editor; + splitBlock(depth: number): Controller; /** * Split the Inline node in the current selection by depth levels. * If the selection is expanded, it will be deleted first */ - splitInline(depth: number): Editor; + splitInline(depth: number): Controller; /** * Remove a mark from the characters in the current selection. * Passing a string will implicitly create a Mark of that type for removal. */ - removeMark(mark: Mark | MarkProperties | string): Editor; + removeMark(mark: Mark | MarkProperties | string): Controller; /** * Remove a mark from the characters in the current selection. @@ -1183,595 +1440,595 @@ export class Editor { replaceMark( mark: Mark | MarkProperties | string, newMark: Mark | MarkProperties | string - ): Editor; + ): Controller; /** * Add or remove a mark from the characters in the current selection, depending on it already exists on any or not. * Passing a string will implicitly create a Mark of that type to toggle. */ - toggleMark(mark: Mark | MarkProperties | string): Editor; + toggleMark(mark: Mark | MarkProperties | string): Controller; /** * Unwrap all Block nodes in the current selection that match a type and/or data */ - unwrapBlock(properties: BlockProperties | string): Editor; + unwrapBlock(properties: BlockProperties | string): Controller; /** * Unwrap all Inline nodes in the current selection that match a type and/or data */ - unwrapInline(properties: InlineProperties | string): Editor; + unwrapInline(properties: InlineProperties | string): Controller; /** * Wrap the Block nodes in the current selection with a new Block */ - wrapBlock(properties: BlockProperties | string): Editor; + wrapBlock(properties: BlockProperties | string): Controller; /** * Wrap the Block nodes in the current selection with a new Inline */ - wrapInline(properties: InlineProperties | string): Editor; + wrapInline(properties: InlineProperties | string): Controller; /** * Surround the text in the current selection with prefix and suffix strings. * If the suffix is ommitted, the prefix will be used instead. */ - wrapText(prefix: string, suffix?: string): Editor; + wrapText(prefix: string, suffix?: string): Controller; // Selection Commands // /** * Blur the current selection */ - blur(): Editor; + blur(): Controller; /** * Unset the selection */ - deselect(): Editor; + deselect(): Controller; /** * Flip the selection */ - flip(): Editor; + flip(): Controller; /** * Focus the current selection */ - focus(): Editor; + focus(): Controller; /** * Move the anchor of the current selection backward n characters */ - moveAnchorBackward(n?: number): Editor; + moveAnchorBackward(n?: number): Controller; /** * Move the anchor of the current selection forward n characters */ - moveAnchorForward(n?: number): Editor; + moveAnchorForward(n?: number): Controller; /** * Move the anchor of the current selection to a new path and offset */ - moveAnchorTo(path: Path, offset?: number): Editor; + moveAnchorTo(path: Path, offset?: number): Controller; /** * Move the anchor of the current selection to the end of the closest block parent. */ - moveAnchorToEndOfBlock(): Editor; + moveAnchorToEndOfBlock(): Controller; /** * Move the anchor of the current selection to the end of the closest inline parent. */ - moveAnchorToEndOfInline(): Editor; + moveAnchorToEndOfInline(): Controller; /** * Move the anchor of the current selection to the end of the document. */ - moveAnchorToEndOfDocument(): Editor; + moveAnchorToEndOfDocument(): Controller; /** * Move the anchor of the current selection to the end of the next block. */ - moveAnchorToEndOfNextBlock(): Editor; + moveAnchorToEndOfNextBlock(): Controller; /** * Move the anchor of the current selection to the end of the next inline. */ - moveAnchorToEndOfNextInline(): Editor; + moveAnchorToEndOfNextInline(): Controller; /** * Move the anchor of the current selection to the end of the next text. */ - moveAnchorToEndOfNextText(): Editor; + moveAnchorToEndOfNextText(): Controller; /** * Move the anchor of the current selection to the end of the provided node. */ - moveAnchorEndOfNode(node: Node): Editor; + moveAnchorEndOfNode(node: Node): Controller; /** * Move the anchor of the current selection to the end of the previous block. */ - moveAnchorToEndOfPreviousBlock(): Editor; + moveAnchorToEndOfPreviousBlock(): Controller; /** * Move the anchor of the current selection to the end of the previous inline. */ - moveAnchorToEndOfPreviousInline(): Editor; + moveAnchorToEndOfPreviousInline(): Controller; /** * Move the anchor of the current selection to the end of the previous text. */ - moveAnchorToEndOfPreviousText(): Editor; + moveAnchorToEndOfPreviousText(): Controller; /** * Move the anchor of the current selection to the end of the current text node. */ - moveAnchorToEndOfText(): Editor; + moveAnchorToEndOfText(): Controller; /** * Move the anchor of the current selection to the start of the closest block parent. */ - moveAnchorToStartOfBlock(): Editor; + moveAnchorToStartOfBlock(): Controller; /** * Move the anchor of the current selection to the start of the document. */ - moveAnchorToStartOfDocument(): Editor; + moveAnchorToStartOfDocument(): Controller; /** * Move the anchor of the current selection to the start of the closest inline parent. */ - moveAnchorToStartOfInline(): Editor; + moveAnchorToStartOfInline(): Controller; /** * Move the anchor of the current selection to the start of the next block. */ - moveAnchorToStartOfNextBlock(): Editor; + moveAnchorToStartOfNextBlock(): Controller; /** * Move the anchor of the current selection to the start of the next inline. */ - moveAnchorToStartOfNextInline(): Editor; + moveAnchorToStartOfNextInline(): Controller; /** * Move the anchor of the current selection to the start of the next text node. */ - moveAnchorToStartOfNextText(): Editor; + moveAnchorToStartOfNextText(): Controller; /** * Move the anchor of the current selection to the start of the provided node. */ - moveAnchorToStartOfNode(node: Node): Editor; + moveAnchorToStartOfNode(node: Node): Controller; /** * Move the anchor of the current selection to the start of the previous block. */ - moveAnchorToStartOfPreviousBlock(): Editor; + moveAnchorToStartOfPreviousBlock(): Controller; /** * Move the anchor of the current selection to the start of the previous inline. */ - moveAnchorToStartOfPreviousInline(): Editor; + moveAnchorToStartOfPreviousInline(): Controller; /** * Move the anchor of the current selection to the start of the previous text node. */ - moveAnchorToStartOfPreviousText(): Editor; + moveAnchorToStartOfPreviousText(): Controller; /** * Move the anchor of the current selection to the start of the current text node. */ - moveAnchorToStartOfText(): Editor; + moveAnchorToStartOfText(): Controller; /** * Move the end of the selection backward n characters */ - moveEndBackward(n?: number): Editor; + moveEndBackward(n?: number): Controller; /** * Move the end of the selection foward n characters */ - moveEndForward(n?: number): Editor; + moveEndForward(n?: number): Controller; /** * Move the end of the selection to a new path and offset */ - moveEndTo(path: Path, offset?: number): Editor; + moveEndTo(path: Path, offset?: number): Controller; /** * Move the end of the current selection to the end of the closest block parent. */ - moveEndToEndOfBlock(): Editor; + moveEndToEndOfBlock(): Controller; /** * Move the end of the current selection to the end of the document. */ - moveEndToEndOfDocument(): Editor; + moveEndToEndOfDocument(): Controller; /** * Move the end of the current selection to the end of the closest inline parent. */ - moveEndToEndOfInline(): Editor; + moveEndToEndOfInline(): Controller; /** * Move the anchor of the current selection to the end of the next block. */ - moveEndToEndOfNextBlock(): Editor; + moveEndToEndOfNextBlock(): Controller; /** * Move the end of the current selection to the end of the next inline. */ - moveEndToEndOfNextInline(): Editor; + moveEndToEndOfNextInline(): Controller; /** * Move the end of the current selection to the end of the next text. */ - moveEndToEndOfNextText(): Editor; + moveEndToEndOfNextText(): Controller; /** * Move the end of the current selection to the end of the provided node. */ - moveEndToEndOfNode(node: Node): Editor; + moveEndToEndOfNode(node: Node): Controller; /** * Move the end of the current selection to the end of the previous block. */ - moveEndToEndOfPreviousBlock(): Editor; + moveEndToEndOfPreviousBlock(): Controller; /** * Move the end of the current selection to the end of the previous inline. */ - moveEndToEndOfPreviousInline(): Editor; + moveEndToEndOfPreviousInline(): Controller; /** - * Move the editor of the current selection to the end of the previous text. + * Move the commandable of the current selection to the end of the previous text. */ - moveEndToEndOfPreviousText(): Editor; + moveEndToEndOfPreviousText(): Controller; /** * Move the end of the current selection to the end of the current text node. */ - moveEndToEndOfText(): Editor; + moveEndToEndOfText(): Controller; /** * Move the end of the current selection to the start of the closest block parent. */ - moveEndToStartOfBlock(): Editor; + moveEndToStartOfBlock(): Controller; /** * Move the end of the current selection to the start of the document. */ - moveEndToStartOfDocument(): Editor; + moveEndToStartOfDocument(): Controller; /** * Move the end of the current selection to the start of the closest inline parent. */ - moveEndToStartOfInline(): Editor; + moveEndToStartOfInline(): Controller; /** * Move the end of the current selection to the start of the next block. */ - moveEndToStartOfNextBlock(): Editor; + moveEndToStartOfNextBlock(): Controller; /** * Move the end of the current selection to the start of the next inline. */ - moveEndToStartOfNextInline(): Editor; + moveEndToStartOfNextInline(): Controller; /** * Move the end of the current selection to the start of the next text node. */ - moveEndToStartOfNextText(): Editor; + moveEndToStartOfNextText(): Controller; /** * Move the end of the current selection to the start of the provided node. */ - moveEndToStartOfNode(node: Node): Editor; + moveEndToStartOfNode(node: Node): Controller; /** * Move the end of the current selection to the start of the previous block. */ - moveEndToStartOfPreviousBlock(): Editor; + moveEndToStartOfPreviousBlock(): Controller; /** * Move the end of the current selection to the start of the previous inline. */ - moveEndToStartOfPreviousInline(): Editor; + moveEndToStartOfPreviousInline(): Controller; /** * Move the end of the current selection to the start of the previous text node. */ - moveEndToStartOfPreviousText(): Editor; + moveEndToStartOfPreviousText(): Controller; /** * Move the end of the current selection to the start of the current text node. */ - moveEndToStartOfText(): Editor; + moveEndToStartOfText(): Controller; /** * Move the focus of the current selection backward n characters */ - moveFocusBackward(n?: number): Editor; + moveFocusBackward(n?: number): Controller; /** * Move the focus of the current selection forward n characters */ - moveFocusForward(n?: number): Editor; + moveFocusForward(n?: number): Controller; /** * Move the focus of the current selection to a new path and offset */ - moveFocusTo(path: Path, offset?: number): Editor; + moveFocusTo(path: Path, offset?: number): Controller; /** * Move the focus of the current selection to the end of the closest block parent. */ - moveFocusToEndOfBlock(): Editor; + moveFocusToEndOfBlock(): Controller; /** * Move the focus of the current selection to the end of the document. */ - moveFocusToEndOfDocument(): Editor; + moveFocusToEndOfDocument(): Controller; /** * Move the focus of the current selection to the end of the closest inline parent. */ - moveFocusToEndOfInline(): Editor; + moveFocusToEndOfInline(): Controller; /** * Move the focus of the current selection to the end of the next block. */ - moveFocusToEndOfNextBlock(): Editor; + moveFocusToEndOfNextBlock(): Controller; /** * Move the focus of the current selection to the end of the next inline. */ - moveFocusToEndOfNextInline(): Editor; + moveFocusToEndOfNextInline(): Controller; /** * Move the focus of the current selection to the end of the next text. */ - moveFocusToEndOfNextText(): Editor; + moveFocusToEndOfNextText(): Controller; /** * Move the focus of the current selection to the end of the provided node. */ - moveFocusToEndOfNode(node: Node): Editor; + moveFocusToEndOfNode(node: Node): Controller; /** * Move the focus of the current selection to the end of the previous block. */ - moveFocusToEndOfPreviousBlock(): Editor; + moveFocusToEndOfPreviousBlock(): Controller; /** * Move the focus of the current selection to the end of the previous inline. */ - moveFocusToEndOfPreviousInline(): Editor; + moveFocusToEndOfPreviousInline(): Controller; /** * Move the focus of the current selection to the end of the previous text. */ - moveFocusToEndOfPreviousText(): Editor; + moveFocusToEndOfPreviousText(): Controller; /** * Move the focus of the current selection to the end of the current text node. */ - moveFocusToEndOfText(): Editor; + moveFocusToEndOfText(): Controller; /** * Move the focus of the current selection to the start of the closest block parent. */ - moveFocusToStartOfBlock(): Editor; + moveFocusToStartOfBlock(): Controller; /** * Move the focus of the current selection to the start of the document. */ - moveFocusToStartOfDocument(): Editor; + moveFocusToStartOfDocument(): Controller; /** * Move the focus of the current selection to the start of the closest inline parent. */ - moveFocusToStartOfInline(): Editor; + moveFocusToStartOfInline(): Controller; /** * Move the focus of the current selection to the start of the next block. */ - moveFocusToStartOfNextBlock(): Editor; + moveFocusToStartOfNextBlock(): Controller; /** * Move the focus of the current selection to the start of the next inline. */ - moveFocusToStartOfNextInline(): Editor; + moveFocusToStartOfNextInline(): Controller; /** * Move the focus of the current selection to the start of the next text node. */ - moveFocusToStartOfNextText(): Editor; + moveFocusToStartOfNextText(): Controller; /** * Move the focus of the current selection to the start of the provided node. */ - moveFocusToStartOfNode(node: Node): Editor; + moveFocusToStartOfNode(node: Node): Controller; /** * Move the focus of the current selection to the start of the previous block. */ - moveFocusToStartOfPreviousBlock(): Editor; + moveFocusToStartOfPreviousBlock(): Controller; /** * Move the focus of the current selection to the start of the previous inline. */ - moveFocusToStartOfPreviousInline(): Editor; + moveFocusToStartOfPreviousInline(): Controller; /** * Move the focus of the current selection to the start of the previous text node. */ - moveFocusToStartOfPreviousText(): Editor; + moveFocusToStartOfPreviousText(): Controller; /** * Move the focus of the current selection to the start of the current text node. */ - moveFocusToStartOfText(): Editor; + moveFocusToStartOfText(): Controller; /** * Move the start of the current selection backward n characters */ - moveStartForward(n?: number): Editor; + moveStartForward(n?: number): Controller; /** * Move the start of the current selection forward n characters */ - moveStartBackward(n?: number): Editor; + moveStartBackward(n?: number): Controller; /** * Move the start of the current selection to a new path and offset */ - moveStartTo(path: Path, n?: number): Editor; + moveStartTo(path: Path, n?: number): Controller; /** * Move the start of the current selection to the end of the closest block parent. */ - moveStartToEndOfBlock(): Editor; + moveStartToEndOfBlock(): Controller; /** * Move the start of the current selection to the end of the document. */ - moveStartToEndOfDocument(): Editor; + moveStartToEndOfDocument(): Controller; /** * Move the start of the current selection to the end of the closest inline parent. */ - moveStartToEndOfInline(): Editor; + moveStartToEndOfInline(): Controller; /** * Move the start of the current selection to the end of the next block. */ - moveStartToEndOfNextBlock(): Editor; + moveStartToEndOfNextBlock(): Controller; /** * Move the start of the current selection to the end of the next inline. */ - moveStartToEndOfNextInline(): Editor; + moveStartToEndOfNextInline(): Controller; /** * Move the start of the current selection to the end of the next text. */ - moveStartToEndOfNextText(): Editor; + moveStartToEndOfNextText(): Controller; /** * Move the start of the current selection to the end of the provided node. */ - moveStartToEndOfNode(node: Node): Editor; + moveStartToEndOfNode(node: Node): Controller; /** * Move the start of the current selection to the end of the previous block. */ - moveStartToEndOfPreviousBlock(): Editor; + moveStartToEndOfPreviousBlock(): Controller; /** * Move the start of the current selection to the end of the previous inline. */ - moveStartToEndOfPreviousInline(): Editor; + moveStartToEndOfPreviousInline(): Controller; /** * Move the start of the current selection to the end of the previous text. */ - moveStartToEndOfPreviousText(): Editor; + moveStartToEndOfPreviousText(): Controller; /** * Move the start of the current selection to the end of the current text node. */ - moveStartToEndOfText(): Editor; + moveStartToEndOfText(): Controller; /** * Move the start of the current selection to the start of the closest block parent. */ - moveStartToStartOfBlock(): Editor; + moveStartToStartOfBlock(): Controller; /** * Move the start of the current selection to the start of the document. */ - moveStartToStartOfDocument(): Editor; + moveStartToStartOfDocument(): Controller; /** * Move the start of the current selection to the start of the closest inline parent. */ - moveStartToStartOfInline(): Editor; + moveStartToStartOfInline(): Controller; /** * Move the start of the current selection to the start of the next block. */ - moveStartToStartOfNextBlock(): Editor; + moveStartToStartOfNextBlock(): Controller; /** * Move the start of the current selection to the start of the next inline. */ - moveStartToStartOfNextInline(): Editor; + moveStartToStartOfNextInline(): Controller; /** * Move the start of the current selection to the start of the next text node. */ - moveStartToStartOfNextText(): Editor; + moveStartToStartOfNextText(): Controller; /** * Move the start of the current selection to the start of the provided node. */ - moveStartToStartOfNode(node: Node): Editor; + moveStartToStartOfNode(node: Node): Controller; /** * Move the start of the current selection to the start of the previous block. */ - moveStartToStartOfPreviousBlock(): Editor; + moveStartToStartOfPreviousBlock(): Controller; /** * Move the start of the current selection to the start of the previous inline. */ - moveStartToStartOfPreviousInline(): Editor; + moveStartToStartOfPreviousInline(): Controller; /** * Move the start of the current selection to the start of the previous text node. */ - moveStartToStartOfPreviousText(): Editor; + moveStartToStartOfPreviousText(): Controller; /** * Move the start of the current selection to the start of the current text node. */ - moveStartToStartOfText(): Editor; + moveStartToStartOfText(): Controller; /** * Move the anchor and focus of the selection backward n characters. */ - moveBackward(n?: number): Editor; + moveBackward(n?: number): Controller; /** * Move the anchor and focus of the selection forward n characters. */ - moveForward(n?: number): Editor; + moveForward(n?: number): Controller; /** * Collapse the current selection at the provided new path and offset. */ - moveTo(path: Path, offset?: number): Editor; + moveTo(path: Path, offset?: number): Controller; /** * Collapse the current selection at the anchor. */ - moveToAnchor(): Editor; + moveToAnchor(): Controller; /** * Collapse the current selection at the focus. */ - moveToFocus(): Editor; + moveToFocus(): Controller; /** * Collapse the current selection at the start. */ - moveToStart(): Editor; + moveToStart(): Controller; /** * Collapse the current selection at the end. */ - moveToEnd(): Editor; + moveToEnd(): Controller; /** * Collapse the current selection at the end of the closest block parent. */ - moveToEndOfBlock(): Editor; + moveToEndOfBlock(): Controller; /** * Collapse the current selection at the end of the document. */ - moveToEndOfDocument(): Editor; + moveToEndOfDocument(): Controller; /** * Collapse the current selection at the end of the closest inline parent. */ - moveToEndOfInline(): Editor; + moveToEndOfInline(): Controller; /** * Collapse the current selection at the end of the next block. */ - moveToEndOfNextBlock(): Editor; + moveToEndOfNextBlock(): Controller; /** * Collapse the current selection at the end of the inline. */ - moveToEndOfNextInline(): Editor; + moveToEndOfNextInline(): Controller; /** * Collapse the current selection at the end of the next text node. */ - moveToEndOfNextText(): Editor; + moveToEndOfNextText(): Controller; /** * Collapse the current selection at the end of the provided node. */ - moveToEndOfNode(node: Node): Editor; + moveToEndOfNode(node: Node): Controller; /** * Collapse the current selection at the end of the previous block. */ - moveToEndOfPreviousBlock(): Editor; + moveToEndOfPreviousBlock(): Controller; /** * Collapse the current selection at the end of the previous inline. */ - moveToEndOfPreviousInline(): Editor; + moveToEndOfPreviousInline(): Controller; /** * Collapse the current selection at the end of the previous text node. */ - moveToEndOfPreviousText(): Editor; + moveToEndOfPreviousText(): Controller; /** * Collapse the current selection at the end of the current text node. */ - moveToEndOfText(): Editor; + moveToEndOfText(): Controller; /** * Collapse the current selection at the start of the nearest block parent. */ - moveToStartOfBlock(): Editor; + moveToStartOfBlock(): Controller; /** * Collapse the current selection at the start of the document. */ - moveToStartOfDocument(): Editor; + moveToStartOfDocument(): Controller; /** * Collapse the current selection at the start of the nearest inline parent. */ - moveToStartOfInline(): Editor; + moveToStartOfInline(): Controller; /** * Collapse the current selection at the start of the next block. */ - moveToStartOfNextBlock(): Editor; + moveToStartOfNextBlock(): Controller; /** * Collapse the current selection at the start of the next inline. */ - moveToStartOfNextInline(): Editor; + moveToStartOfNextInline(): Controller; /** * Collapse the current selection at the start of the next text node. */ - moveToStartOfNextText(): Editor; + moveToStartOfNextText(): Controller; /** * Collapse the current selection at the start of the provided node. */ - moveToStartOfNode(node: Node): Editor; + moveToStartOfNode(node: Node): Controller; /** * Collapse the current selection at the start of the previous block. */ - moveToStartOfPreviousBlock(): Editor; + moveToStartOfPreviousBlock(): Controller; /** * Collapse the current selection at the start of the previous inline. */ - moveToStartOfPreviousInline(): Editor; + moveToStartOfPreviousInline(): Controller; /** * Collapse the current selection at the start of the previous text node. */ - moveToStartOfPreviousText(): Editor; + moveToStartOfPreviousText(): Controller; /** * Collapse the current selection at the start of the current text node. */ - moveToStartOfText(): Editor; + moveToStartOfText(): Controller; /** * Move the current selection's anchor to the start of the document and its focus to the end of it, selecting everything. */ - moveToRangeOfDocument(): Editor; + moveToRangeOfDocument(): Controller; /** * Move the current selection's anchor to the start of the provided node and its focus to the end of it. */ - moveToRangeOf(node: Node): Editor; + moveToRangeOf(node: Node): Controller; /** * Merge the current selection with the provided properties */ - select(properties: Range | RangeProperties): Editor; + select(properties: Range | RangeProperties): Controller; // Document Range Commands // @@ -1779,111 +2036,111 @@ export class Editor { * Add a mark to the characters in the range. * Passing a string as `mark` will implicitly create a mark with that `type` */ - addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + addMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Controller; /** * Delete everything in the range */ - deleteAtRange(range: Range): Editor; + deleteAtRange(range: Range): Controller; /** * Delete backward until the char boundary at a range */ - deleteCharBackwardAtRange(range: Range): Editor; + deleteCharBackwardAtRange(range: Range): Controller; /** * Delete backward until the line boundary at a range */ - deleteLineBackwardAtRange(range: Range): Editor; + deleteLineBackwardAtRange(range: Range): Controller; /** * Delete backward until the word boundary at a range */ - deleteWordBackwardAtRange(range: Range): Editor; + deleteWordBackwardAtRange(range: Range): Controller; /** * Delete backward n characters at a range */ - deleteBackwardAtRange(range: Range, n: number): Editor; + deleteBackwardAtRange(range: Range, n: number): Controller; /** * Delete forward until the char boundary at a range */ - deleteCharForwardAtRange(range: Range): Editor; + deleteCharForwardAtRange(range: Range): Controller; /** * Delete forward until the line boundary at a range */ - deleteLineForwardAtRange(range: Range): Editor; + deleteLineForwardAtRange(range: Range): Controller; /** * Delete forward until the word boundary at a range */ - deleteWordForwardAtRange(range: Range): Editor; + deleteWordForwardAtRange(range: Range): Controller; /** * Delete forward n characters at a range */ - deleteForwardAtRange(range: Range, n: number): Editor; + deleteForwardAtRange(range: Range, n: number): Controller; /** * Insert a block node at range, splitting text to make room if it is non-empty. * If the range is expanded, it will be deleted first. */ - insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Editor; + insertBlockAtRange(range: Range, block: Block | BlockProperties | string): Controller; /** * Insert a document fragment at a range, if the range is expanded, it will be deleted first. */ - insertFragmentAtRange(range: Range, fragment: Document): Editor; + insertFragmentAtRange(range: Range, fragment: Document): Controller; /** * Insert a new inline at range, splitting text to make room if it is non-empty. * If the range is expanded, it will be deleted first. */ - insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Editor; + insertInlineAtRange(range: Range, inline: Inline | InlineProperties): Controller; /** * Insert text at range. If the range is expanded it will be deleted first */ - insertTextAtRange(range: Range, text: string): Editor; + insertTextAtRange(range: Range, text: string): Controller; /** * Set the properties of the block nodes in a range. * Passing a string will set the nodes' type only */ - setBlocksAtRange(range: Range, properties: BlockProperties | string): Editor; + setBlocksAtRange(range: Range, properties: BlockProperties | string): Controller; /** * Set the properties of the inline nodes in a range. * Passing a string will set the nodes' type only */ - setInlinesAtRange(range: Range, properties: InlineProperties | string): Editor; + setInlinesAtRange(range: Range, properties: InlineProperties | string): Controller; /** * Split the block in a range by depth levels. If the range is expanded it will be deleted first. */ - splitBlockAtRange(range: Range, depth: number): Editor; + splitBlockAtRange(range: Range, depth: number): Controller; /** * Split the inline in a range by depth levels. If the range is expanded it will be deleted first. */ - splitInlineAtRange(range: Range, depth: number): Editor; + splitInlineAtRange(range: Range, depth: number): Controller; /** * Remove a mark from characters in the range. Passing a string will * implicitly create a mark of that type for deletion. */ - removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + removeMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Controller; /** * Add or remove a mark from characters in the range. Passing a string will * implicitly create a mark of that type for deletion. */ - toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Editor; + toggleMarkAtRange(range: Range, mark: Mark | MarkProperties | string): Controller; /** * Unwrap all block nodes in a range that match properties */ - unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + unwrapBlockAtRange(range: Range, properties: BlockProperties | string): Controller; /** * Unwrap all inline nodes in a range that match properties */ - unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + unwrapInlineAtRange(range: Range, properties: InlineProperties | string): Controller; /** * wrap all block nodes in a range with a new block node with the provided properties */ - wrapBlockAtRange(range: Range, properties: BlockProperties | string): Editor; + wrapBlockAtRange(range: Range, properties: BlockProperties | string): Controller; /** * wrap all inline nodes in a range with a new inline node with the provided properties */ - wrapInlineAtRange(range: Range, properties: InlineProperties | string): Editor; + wrapInlineAtRange(range: Range, properties: InlineProperties | string): Controller; /** * Surround the text in a range with a prefix and suffix. If the suffix is ommitted, * the prefix will be used instead. */ - wrapTextAtRange(range: Range, prefix: string, suffix?: string): Editor; + wrapTextAtRange(range: Range, prefix: string, suffix?: string): Controller; // Node commands // /** @@ -1894,7 +2151,7 @@ export class Editor { offset: number, length: number, mark: MarkProperties | Mark | string - ): Editor; + ): Controller; /** * Add a mark to length characters starting at an offset in a node by path */ @@ -1903,23 +2160,23 @@ export class Editor { offset: number, length: number, mark: MarkProperties | Mark | string - ): Editor; + ): Controller; /** * Insert a node at index inside a parent node by key */ - insertNodeByKey(key: string, index: number, node: Node): Editor; + insertNodeByKey(key: string, index: number, node: Node): Controller; /** * Insert a node at index inside a parent node by apth */ - insertNodeByPath(path: Path, index: number, node: Node): Editor; + insertNodeByPath(path: Path, index: number, node: Node): Controller; /** * Insert a document fragment at index inside a parent node by key */ - insertFragmentByKey(key: string, index: number, fragment: Document): Editor; + insertFragmentByKey(key: string, index: number, fragment: Document): Controller; /** * Insert a document fragment at index inside a parent node by path */ - insertFragmentByPath(path: Path, index: number, fragment: Document): Editor; + insertFragmentByPath(path: Path, index: number, fragment: Document): Controller; /** * Insert text at an offset in a text node by its key with optional marks */ @@ -1928,7 +2185,7 @@ export class Editor { offset: number, text: string, marks?: Immutable.Set | Mark[] - ): Editor; + ): Controller; /** * Insert text at an offset in a text node by its path with optional marks */ @@ -1937,23 +2194,23 @@ export class Editor { offset: number, text: string, marks?: Immutable.Set | Mark[] - ): Editor; + ): Controller; /** * Merge a node by its key with its previous sibling */ - mergeNodeByKey(key: string): Editor; + mergeNodeByKey(key: string): Controller; /** * Merge a node by its path with its previous sibling */ - mergeNodeByPath(path: Path): Editor; + mergeNodeByPath(path: Path): Controller; /** * Move a node by its key to a new parent node with with newkey at newindex */ - moveNodeByKey(key: string, newKey: string, newIndex: number): Editor; + moveNodeByKey(key: string, newKey: string, newIndex: number): Controller; /** * Move a node by its path to a new parent node with with newpath at newindex */ - moveNodeByPath(path: Path, newPath: Path, newIndex: number): Editor; + moveNodeByPath(path: Path, newPath: Path, newIndex: number): Controller; /** * Remove a mark from length characters starting at an offset in a node by key */ @@ -1962,7 +2219,7 @@ export class Editor { offset: number, length: number, mark: Mark | Mark | string - ): Editor; + ): Controller; /** * Remove a mark from length characters starting at an offset in a node by path */ @@ -1971,31 +2228,31 @@ export class Editor { offset: number, length: number, mark: MarkProperties | Mark | string - ): Editor; + ): Controller; /** * Remove a node from the document by its key */ - removeNodeByKey(key: string): Editor; + removeNodeByKey(key: string): Controller; /** * Remove a node from the document by its path */ - removeNodeByPath(path: Path): Editor; + removeNodeByPath(path: Path): Controller; /** * Replace a node in the document with a new node by key */ - replaceNodeByKey(key: string, node: Node): Editor; + replaceNodeByKey(key: string, node: Node): Controller; /** * Replace a node in the document with a new node by path */ - replaceNodeByPath(path: Path, newNode: Node): Editor; + replaceNodeByPath(path: Path, newNode: Node): Controller; /** * Remove length characters of text starting at an offset in a node by key */ - removeTextByKey(key: string, offset: number, length: number): Editor; + removeTextByKey(key: string, offset: number, length: number): Controller; /** * Remove length characters of text starting at an offset in a node by path */ - removeTextByPath(path: Path, offset: number, length: number): Editor; + removeTextByPath(path: Path, offset: number, length: number): Controller; /** * Set a dictionary of properties on a mark by its key. */ @@ -2005,7 +2262,7 @@ export class Editor { length: number, mark: Mark, properties: MarkProperties - ): Editor; + ): Controller; /** * Set a dictionary of properties on a mark by its path. */ @@ -2015,111 +2272,130 @@ export class Editor { length: number, mark: Mark, properties: MarkProperties - ): Editor; + ): Controller; /** * Set a dictionary of properties on a node by its key. */ - setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Editor; + setNodeByKey(key: string, properties: BlockProperties | InlineProperties | string): Controller; /** * Set a dictionary of properties on a node by its key. */ - setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Editor; + setNodeByPath(path: Path, properties: NodeProperties | InlineProperties | string): Controller; /** * Split a node by its key at an offset */ - splitNodeByKey(key: string, offset: number): Editor; + splitNodeByKey(key: string, offset: number): Controller; /** * Split a node by its path at an offset */ - splitNodeByPath(path: Path, position: number): Editor; + splitNodeByPath(path: Path, position: number): Controller; /** * Unwrap all inner content of an inline node by its key that match properties */ - unwrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + unwrapInlineByKey(key: string, properties: InlineProperties | string): Controller; /** * Unwrap all inner content of an inline node by its path that match properties */ - unwrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + unwrapInlineByPath(path: Path, properties: InlineProperties | string): Controller; /** * Unwrap all inner content of a block node by its key that match properties */ - unwrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + unwrapBlockByKey(key: string, properties: BlockProperties | string): Controller; /** * Unwrap all inner content of a block node by its path that match properties */ - unwrapBlockByPath(path: Path, properties: BlockProperties | string): Editor; + unwrapBlockByPath(path: Path, properties: BlockProperties | string): Controller; /** * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split. * If the node is an only child, it will replace the parent */ - unwrapNodeByKey(key: string): Editor; + unwrapNodeByKey(key: string): Controller; /** * Unwrap a single node from its parent. if the node is surrounded with siblings the parent will be split. * If the node is an only child, it will replace the parent */ - unwrapNodeByPath(path: Path): Editor; + unwrapNodeByPath(path: Path): Controller; /** * Wrap the given node by key in an Inline node that matches properties. */ - wrapInlineByKey(key: string, properties: InlineProperties | string): Editor; + wrapInlineByKey(key: string, properties: InlineProperties | string): Controller; /** * Wrap the given node by path in an Inline node that matches properties. */ - wrapInlineByPath(path: Path, properties: InlineProperties | string): Editor; + wrapInlineByPath(path: Path, properties: InlineProperties | string): Controller; /** * Wrap the given node by key in a block node that matches properties. */ - wrapBlockByKey(key: string, properties: BlockProperties | string): Editor; + wrapBlockByKey(key: string, properties: BlockProperties | string): Controller; /** * Wrap the given node by path in a block node that matches properties. */ - wrapBlockByPath(path: Path, block: Block | string): Editor; + wrapBlockByPath(path: Path, block: Block | string): Controller; /** * Wrap the node with the specified key with the parent node, this will clear all children of the parent. */ - wrapNodeByKey(key: string, parent: Node): Editor; + wrapNodeByKey(key: string, parent: Node): Controller; /** * Wrap the node with the specified key with the parent node, this will clear all children of the parent. */ - wrapNodeByPath(path: Path, parent: Node): Editor; + wrapNodeByPath(path: Path, parent: Node): Controller; // Miscellaneous Commands // /** * Normalizes the document with the value's schema. Run automatically unless manually disabled. * Use it sparingly and strategically, as it can be very expensive. */ - normalize(): Editor; + normalize(): Controller; /** - * Calls the provided function with the current editor as the first argument. + * Calls the provided function with the current commandable as the first argument. * Normalization does not occur while the function is executing and is deferred to execute immediately after completion. * * This allows for sequence change operations to not be interrupted by normalization */ - withoutNormalizing(fn: () => void): Editor; + withoutNormalizing(fn: () => void): Controller; /** - * By default all operations are saved to the editor's history. If you have + * By default all operations are saved to the commandable's history. If you have * changes that you don't want to show up in history, use this function. */ - withoutSaving(fn: () => void): Editor; + withoutSaving(fn: () => void): Controller; /** * Usually all command operations are merged into a single save point in history, * if more control is desired, create single save points using this function. */ - withoutMerging(fn: () => void): Editor; + withoutMerging(fn: () => void): Controller; // History Commands // /** * Move forward one step in the history */ - redo(): Editor; + redo(): Controller; /** * Move backward one step in the history */ - undo(): Editor; + undo(): Controller; /** * Snapshot the current selection for undo purposes. */ - snapshotSelection(): Editor; + snapshotSelection(): Controller; + command(name: string, ...args: any[]): Controller; + query(query: string, ...args: any[]): Controller; + /** + * Add a new command by type to the controller. This will make the command available as a top-level method on the controller + */ + registerCommand(command: string): Controller; + /** + * Add a new query by type to the controller. This will make the query available as a top-level method on the controller. + */ + registerQuery(query: string): Controller; + /** + * Apply an `operation` to the controller, updating its value. + */ + applyOperation(operation: Operation): Controller; + /** + * Run the middleware stack by key with args, returning its result. + * In normal operation you never need to use this method! Reserved for testing. + */ + run(key: string, ...args: any[]): Controller; } export {}; diff --git a/types/ssh2-streams/index.d.ts b/types/ssh2-streams/index.d.ts index a7ff80243b..a780273591 100644 --- a/types/ssh2-streams/index.d.ts +++ b/types/ssh2-streams/index.d.ts @@ -659,8 +659,8 @@ export interface HostKeys { } export interface HostKey { - privatekey: ParsedKey; - publickey: ParsedKey; + privateKey: ParsedKey; + publicKey: ParsedKey; } /** diff --git a/types/ssh2-streams/ssh2-streams-tests.ts b/types/ssh2-streams/ssh2-streams-tests.ts index 7f140b4bbd..9ae121a454 100644 --- a/types/ssh2-streams/ssh2-streams-tests.ts +++ b/types/ssh2-streams/ssh2-streams-tests.ts @@ -2,16 +2,17 @@ import * as stream from "stream"; import * as ssh2 from "ssh2-streams"; declare const SERVER_KEY: string; -declare const HOST_KEYS: { 'ssh-rsa': ssh2.HostKey }; +declare const HOST_KEY: { publicKey: ssh2.ParsedKey; privateKey: ssh2.ParsedKey }; declare const clientBufStream: stream.Transform & { buffer: string; }; declare const serverBufStream: stream.Transform & { buffer: string; }; declare const parsedKey: ssh2.ParsedKey; declare const prompts: ssh2.Prompt[]; declare const buffer: Buffer; +const hostKeys = { 'ssh-rsa': HOST_KEY }; const algos = ['ssh-dss', 'ssh-rsa', 'ecdsa-sha2-nistp521']; const client = new ssh2.SSH2Stream({ algorithms: { serverHostKey: algos } }); -const server = new ssh2.SSH2Stream({ server: true, hostKeys: HOST_KEYS }); +const server = new ssh2.SSH2Stream({ server: true, hostKeys: hostKeys }); client .pipe(server) diff --git a/types/ssh2/ssh2-tests.ts b/types/ssh2/ssh2-tests.ts index e6d03e939f..432fad281d 100644 --- a/types/ssh2/ssh2-tests.ts +++ b/types/ssh2/ssh2-tests.ts @@ -313,7 +313,7 @@ var buffersEqual = require('buffer-equal-constant-time'), //ssh2 = require('ssh2'), utils = ssh2.utils; -var pubKey = utils.genPublicKey(utils.parseKey(fs.readFileSync('user.pub'))); +var pubKey = utils.genPublicKey(utils.parseKey(fs.readFileSync('user.pub')) as ssh2_streams.ParsedKey); new ssh2.Server({ hostKeys: [fs.readFileSync('host.key')] diff --git a/types/store/index.d.ts b/types/store/index.d.ts index 8f46bb9f59..e859491aa0 100644 --- a/types/store/index.d.ts +++ b/types/store/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Vincent Bortone // harry0000 // Roman Nuritdinov (Ky6uk) +// Johnny Edwards (igl00) // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Cross-browser storage for all use cases, used across the web. @@ -25,6 +26,15 @@ interface StoreJsEngine { createStore(storages: any[], plugins?: any[], namespace?: string): StoreJsAPI; } +interface StoreJsStorage { + name: string; + read: (key: string) => string | null; + write: (key: string, data: string) => void; + each: (callback: (val: string, key: string) => any) => void; + remove: (key: string) => void; + clearAll: () => void; +} + declare const store: StoreJsAPI; declare module 'store' { export = store; @@ -73,3 +83,23 @@ declare module 'store/plugins/update' { declare module 'store/plugins/v1-backcompat' { export = Function; } + +declare const storage: StoreJsStorage; +declare module 'store/storages/cookieStorage' { + export = storage; +} +declare module 'store/storages/localStorage' { + export = storage; +} +declare module 'store/storages/memoryStorage' { + export = storage; +} +declare module 'store/storages/oldFF-globalStorage' { + export = storage; +} +declare module 'store/storages/oldIE-userDataStorage' { + export = storage; +} +declare module 'store/storages/sessionStorage' { + export = storage; +} diff --git a/types/storybook__addon-links/react.d.ts b/types/storybook__addon-links/react.d.ts new file mode 100644 index 0000000000..862753ec9c --- /dev/null +++ b/types/storybook__addon-links/react.d.ts @@ -0,0 +1,6 @@ +import * as React from 'react'; + +export default class LinkTo extends React.PureComponent< + React.DetailedHTMLProps, HTMLAnchorElement> & + { story: string, kind?: string } +> {} diff --git a/types/storybook__addon-links/storybook__addon-links-tests.tsx b/types/storybook__addon-links/storybook__addon-links-tests.tsx index e922b0fc00..29c1969d0f 100644 --- a/types/storybook__addon-links/storybook__addon-links-tests.tsx +++ b/types/storybook__addon-links/storybook__addon-links-tests.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { storiesOf } from '@storybook/react'; import { hrefTo, linkTo } from '@storybook/addon-links'; +import LinkTo from '@storybook/addon-links/react'; storiesOf('Button', module) .add('First', () => ( @@ -11,6 +12,9 @@ storiesOf('Button', module) )) .add('With function', () => ( + )) + .add('With component', () => ( + )); hrefTo('Button', 'First').then(link => link); diff --git a/types/storybook__addon-links/tsconfig.json b/types/storybook__addon-links/tsconfig.json index bb3183eaec..eaedb278f0 100644 --- a/types/storybook__addon-links/tsconfig.json +++ b/types/storybook__addon-links/tsconfig.json @@ -17,6 +17,9 @@ "@storybook/addon-links": [ "storybook__addon-links" ], + "@storybook/addon-links/react": [ + "storybook__addon-links/react" + ], "@storybook/react": [ "storybook__react" ] @@ -27,6 +30,7 @@ }, "files": [ "index.d.ts", + "react.d.ts", "storybook__addon-links-tests.tsx" ] } \ No newline at end of file diff --git a/types/systeminformation/index.d.ts b/types/systeminformation/index.d.ts index b8ec674839..0ebeb16f96 100644 --- a/types/systeminformation/index.d.ts +++ b/types/systeminformation/index.d.ts @@ -367,6 +367,7 @@ export namespace Systeminformation { tty: string; user: string; command: string; + name: string; } interface ProcessesProcessLoadData { diff --git a/types/youtube/index.d.ts b/types/youtube/index.d.ts index b04d727378..5739e4c6fd 100644 --- a/types/youtube/index.d.ts +++ b/types/youtube/index.d.ts @@ -5,6 +5,7 @@ // Josh Goldberg // Eliot Fallon // Terry Mun +// Paul Hobbel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -30,7 +31,7 @@ declare namespace YT /** * Known causes for player errors. */ - export const enum PlayerError + export enum PlayerError { /** * The request contained an invalid parameter value. @@ -61,7 +62,7 @@ declare namespace YT /** * Whether to auto-hide video controls. */ - export const enum AutoHide + export enum AutoHide { /** * Controls are visible throughout the video @@ -82,7 +83,7 @@ declare namespace YT /** * Whether to autoplay the video. */ - export const enum AutoPlay + export enum AutoPlay { /** * Video does not autoplay. @@ -98,7 +99,7 @@ declare namespace YT /** * Whether to use user-preferred or forced caption loading. */ - export const enum ClosedCaptionsLoadPolicy + export enum ClosedCaptionsLoadPolicy { /** * Defaults to the user's preferences. @@ -119,7 +120,7 @@ declare namespace YT /** * How video controls are shown. */ - export const enum Controls + export enum Controls { /** * Player controls do not display. @@ -140,7 +141,7 @@ declare namespace YT /** * Whether to allow keyboard controls. */ - export const enum KeyboardControls + export enum KeyboardControls { /** * Keyboard controls are enabled. @@ -156,7 +157,7 @@ declare namespace YT /** * Whether the JavaScript API should be enabled. */ - export const enum JsApi + export enum JsApi { /** * JavaScript API will be disabled. @@ -172,7 +173,7 @@ declare namespace YT /** * Whether to display the full-screen button. */ - export const enum FullscreenButton + export enum FullscreenButton { /** * The full screen button is hidden. @@ -188,7 +189,7 @@ declare namespace YT /** * Whether to show video annotations. */ - export const enum IvLoadPolicy + export enum IvLoadPolicy { /** * Video annotations will be shown. @@ -224,7 +225,7 @@ declare namespace YT /** * Whether a single video should be looped. */ - export const enum Loop + export enum Loop { /** * Video or playlist will be played only once. @@ -240,7 +241,7 @@ declare namespace YT /** * Comma separated list of video IDs to play after the URL path's video. */ - export const enum ModestBranding + export enum ModestBranding { /** * Player will contain full YouTube branding. @@ -256,7 +257,7 @@ declare namespace YT /** * Whether to playback video inline or full-screen in an HTML5 player on iOS */ - export const enum PlaysInline + export enum PlaysInline { /** * Playback in fullscreen. @@ -272,7 +273,7 @@ declare namespace YT /** * Whether to show related videos after the video finishes. */ - export const enum RelatedVideos + export enum RelatedVideos { /** * Hide related videos after playback is complete. @@ -288,7 +289,7 @@ declare namespace YT /** * Whether to show video information before playing. */ - export const enum ShowInfo + export enum ShowInfo { /** * Hide video title and uploader before video starts playing.