diff --git a/notNeededPackages.json b/notNeededPackages.json index d78bb569ad..0edaa82c1e 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -240,6 +240,12 @@ "sourceRepoURL": "https://github.com/mapbox/cheap-ruler", "asOfVersion": "2.5.0" }, + { + "libraryName": "chokidar", + "typingsPackageName": "chokidar", + "sourceRepoURL": "https://github.com/paulmillr/chokidar", + "asOfVersion": "2.1.3" + }, { "libraryName": "chunked-dc", "typingsPackageName": "chunked-dc", @@ -414,6 +420,12 @@ "sourceRepoURL": "git@github.com:KyleAMathews/deepmerge.git", "asOfVersion": "2.2.0" }, + { + "libraryName": "del", + "typingsPackageName": "del", + "sourceRepoURL": "https://github.com/sindresorhus/del", + "asOfVersion": "4.0.0" + }, { "libraryName": "delay", "typingsPackageName": "delay", @@ -714,6 +726,12 @@ "sourceRepoURL": "https://github.com/ivogabe/gulp-typescript", "asOfVersion": "2.13.0" }, + { + "libraryName": "handlebars", + "typingsPackageName": "handlebars", + "sourceRepoURL": "https://github.com/wycats/handlebars.js", + "asOfVersion": "4.1.0" + }, { "libraryName": "handsontable", "typingsPackageName": "handsontable", @@ -780,6 +798,12 @@ "sourceRepoURL": "https://github.com/taye/interact.js", "asOfVersion": "1.3.0" }, + { + "libraryName": "internal-ip", + "typingsPackageName": "internal-ip", + "sourceRepoURL": "https://github.com/sindresorhus/internal-ip", + "asOfVersion": "4.1.0" + }, { "libraryName": "inversify", "typingsPackageName": "inversify", @@ -828,6 +852,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/is-lower-case", "asOfVersion": "1.1.2" }, + { + "libraryName": "is-online", + "typingsPackageName": "is-online", + "sourceRepoURL": "https://github.com/sindresorhus/is-online", + "asOfVersion": "8.1.0" + }, { "libraryName": "is-plain-object", "typingsPackageName": "is-plain-object", @@ -1104,12 +1134,24 @@ "sourceRepoURL": "https://github.com/theoephraim/node-pg-migrate#readme", "asOfVersion": "2.15.0" }, + { + "libraryName": "png-async", + "typingsPackageName": "png-async", + "sourceRepoURL": "https://github.com/kanreisa/node-png-async", + "asOfVersion": "0.9.4" + }, { "libraryName": "node-waves", "typingsPackageName": "node-waves", "sourceRepoURL": "http://fian.my.id/Waves", "asOfVersion": "0.7.6" }, + { + "libraryName": "normalize-url", + "typingsPackageName": "normalize-url", + "sourceRepoURL": "https://github.com/sindresorhus/normalize-url", + "asOfVersion": "4.2.0" + }, { "libraryName": "Normalizr", "typingsPackageName": "normalizr", @@ -1134,11 +1176,41 @@ "sourceRepoURL": "http://onsen.io", "asOfVersion": "2.0.0" }, + { + "libraryName": "p-event", + "typingsPackageName": "p-event", + "sourceRepoURL": "https://github.com/sindresorhus/p-event", + "asOfVersion": "3.0.0" + }, + { + "libraryName": "p-limit", + "typingsPackageName": "p-limit", + "sourceRepoURL": "https://github.com/sindresorhus/p-limit", + "asOfVersion": "2.2.0" + }, + { + "libraryName": "p-map", + "typingsPackageName": "p-map", + "sourceRepoURL": "https://github.com/sindresorhus/p-map", + "asOfVersion": "2.0.0" + }, + { + "libraryName": "p-pipe", + "typingsPackageName": "p-pipe", + "sourceRepoURL": "https://github.com/sindresorhus/p-pipe", + "asOfVersion": "2.0.1" + }, + { + "libraryName": "p-queue", + "typingsPackageName": "p-queue", + "sourceRepoURL": "https://github.com/sindresorhus/p-queue", + "asOfVersion": "3.2.1" + }, { "libraryName": "p-throttle", "typingsPackageName": "p-throttle", "sourceRepoURL": "https://github.com/sindresorhus/p-throttle", - "asOfVersion": "2.0.0" + "asOfVersion": "2.1.0" }, { "libraryName": "param-case", @@ -1662,6 +1734,12 @@ "sourceRepoURL": "http://tabrisjs.com", "asOfVersion": "1.8.0" }, + { + "libraryName": "tabris-plugin-firebase", + "typingsPackageName": "tabris-plugin-firebase", + "sourceRepoURL": "https://github.com/eclipsesource/tabris-plugin-firebase", + "asOfVersion": "2.1.0" + }, { "libraryName": "tcomb", "typingsPackageName": "tcomb", @@ -1788,6 +1866,12 @@ "sourceRepoURL": "https://github.com/vuejs/vue-router", "asOfVersion": "2.0.0" }, + { + "libraryName": "wait-for-localhost", + "typingsPackageName": "wait-for-localhost", + "sourceRepoURL": "https://github.com/sindresorhus/wait-for-localhost", + "asOfVersion": "3.1.0" + }, { "libraryName": "webcola", "typingsPackageName": "webcola", diff --git a/package.json b/package.json index 1a5124c035..f4c48b1b32 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "scripts": { "compile-scripts": "tsc -p scripts", "not-needed": "node scripts/not-needed.js", + "update-codeowners": "node scripts/update-codeowners.js", "test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed", "lint": "dtslint types" }, diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 899f96af64..6e0fd5a58c 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,13 +1,10 @@ { "compilerOptions": { + "allowJs": true, + "checkJs": true, "module": "commonjs", "target": "es6", - "noImplicitAny": true, - "strictNullChecks": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, + "strict": true, "baseUrl": "../types", "typeRoots": [ "../types" @@ -15,4 +12,4 @@ "types": [], "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +} diff --git a/scripts/update-codeowners.js b/scripts/update-codeowners.js new file mode 100644 index 0000000000..56eda138c6 --- /dev/null +++ b/scripts/update-codeowners.js @@ -0,0 +1,126 @@ +/// +// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally +const cp = require("child_process"); +const Octokit = require("@octokit/rest"); +const { AllPackages, getDefinitelyTyped, loggerWithErrors, + parseDefinitions, parseNProcesses, clean } = require("types-publisher"); +const { writeFile } = require("fs-extra"); + +async function main() { + const options = { definitelyTypedPath: ".", progress: false, parseInParallel: true }; + const log = loggerWithErrors()[0]; + + clean(); + const dt = await getDefinitelyTyped(options, log); + await parseDefinitions(dt, { nProcesses: parseNProcesses(), definitelyTypedPath: "." }, log); + const allPackages = await AllPackages.read(dt); + const typings = allPackages.allTypings(); + const maxPathLen = Math.max(...typings.map(t => t.subDirectoryPath.length)); + const entries = mapDefined(typings, t => getEntry(t, maxPathLen)); + await writeFile([options.definitelyTypedPath, ".github", "CODEOWNERS"].join("/"), `${header}\n\n${entries.join("\n")}\n`, { encoding: "utf-8" }); +} + +const token = /** @type {string} */(process.env.GH_TOKEN); +const gh = new Octokit(); +const reviewers = ["weswigham", "sandersn", "RyanCavanaugh"] +const now = new Date(); +const branchName = `codeowner-update-${now.getFullYear()}${padNum(now.getMonth())}${padNum(now.getDay())}`; +const remoteUrl = `https://${token}@github.com/DefinitelyTyped/DefinitelyTyped.git`; +runSequence([ + ["git", ["checkout", "."]], // reset any changes +]); + +main().then(() => { + runSequence([ + ["git", ["checkout", "-b", branchName]], // create a branch + ["git", ["add", ".github/CODEOWNERS"]], // Add CODEOWNERS + ["git", ["commit", "-m", `"Update CODEOWNERS"`]], // Commit all changes + ["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork + ["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch + ]); + + gh.authenticate({ + type: "token", + token, + }); + return gh.pulls.create({ + owner: "DefinitelyTyped", + repo: "DefinitelyTyped", + maintainer_can_modify: true, + title: `🤖 CODEOWNERS has changed`, + head: `DefinitelyTyped:${branchName}`, + base: "master", + body: + `Please review the diff and merge if no changes are unexpected. + +cc ${reviewers.map(r => "@" + r).join(" ")}`, + }) +}).then(r => { + const num = r.data.number; + console.log(`Pull request ${num} created.`); + return gh.pulls.createReviewRequest({ + owner: "DefinitelyTyped", + repo: "DefinitelyTyped", + number: num, + reviewers, + }); +}).then(() => { + console.log(`Reviewers requested, done.`); +}).catch(e => { + console.error(e); + process.exit(1); +}); + +/** @param {[string, string[]][]} tasks */ +function runSequence(tasks) { + for (const task of tasks) { + console.log(`${task[0]} ${task[1].join(" ")}`); + const result = cp.spawnSync(task[0], task[1], { timeout: 100000, shell: true, stdio: "inherit" }); + if (result.status !== 0) throw new Error(`${task[0]} ${task[1].join(" ")} failed: ${result.stderr && result.stderr.toString()}`); + } +} + +/** @param {number} number */ +function padNum(number) { + const str = "" + number; + return str.length >= 2 ? str : "0" + str; +} + + +const header = +`# This file is generated. +# Add yourself to the "Definitions by:" list instead. +# See https://github.com/DefinitelyTyped/DefinitelyTyped#edit-an-existing-package`; + +/** + * @param { { contributors: ReadonlyArray<{githubUsername?: string }>, subDirectoryPath: string} } pkg + * @param {number} maxPathLen + * @return {string | undefined} + */ +function getEntry(pkg, maxPathLen) { + const users = mapDefined(pkg.contributors, c => c.githubUsername); + if (!users.length) { + return undefined; + } + + const path = `${pkg.subDirectoryPath}/`.padEnd(maxPathLen); + return `/types/${path} ${users.map(u => `@${u}`).join(" ")}`; +} + +/** + * @template T,U + * @param {ReadonlyArray} arr + * @param {(t: T) => U | undefined} mapper + * @return U[] + */ +function mapDefined(arr, mapper) { + const out = []; + for (const a of arr) { + const res = mapper(a); + if (res !== undefined) { + out.push(res); + } + } + return out; +} + diff --git a/types/adone/index.d.ts b/types/adone/index.d.ts index 521bdf6e03..f7249c00b4 100644 --- a/types/adone/index.d.ts +++ b/types/adone/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/ciferox/adone // Definitions by: am , Maximus // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 /// /// diff --git a/types/adone/test/glosses/system/process.ts b/types/adone/test/glosses/system/process.ts index 9ffd3c33a5..9aed20b696 100644 --- a/types/adone/test/glosses/system/process.ts +++ b/types/adone/test/glosses/system/process.ts @@ -223,7 +223,7 @@ namespace adoneTests.system.process { }); ret.on("message", () => {}); - ret.stdout.pipe(adone.fs.createWriteStream(__filename)); + ret.stdout!.pipe(adone.fs.createWriteStream(__filename)); } } @@ -811,7 +811,7 @@ namespace adoneTests.system.process { }); ret.on("message", () => {}); - ret.stdout.pipe(adone.fs.createWriteStream(__filename)); + ret.stdout!.pipe(adone.fs.createWriteStream(__filename)); } } diff --git a/types/adone/tslint.json b/types/adone/tslint.json index 8c265eebb4..177bd33372 100644 --- a/types/adone/tslint.json +++ b/types/adone/tslint.json @@ -13,6 +13,7 @@ "no-unnecessary-qualifier": false, "unified-signatures": false, "space-before-function-paren": false, - "await-promise": false + "await-promise": false, + "no-restricted-globals": false } -} \ No newline at end of file +} diff --git a/types/algoliasearch/algoliasearch-tests.ts b/types/algoliasearch/algoliasearch-tests.ts index fdd0f395fe..1d588f2090 100644 --- a/types/algoliasearch/algoliasearch-tests.ts +++ b/types/algoliasearch/algoliasearch-tests.ts @@ -98,6 +98,7 @@ let _algoliaIndexSettings: IndexSettings = { placeholders: { '': [''] }, camelCaseAttributes: [''], sortFacetValuesBy: 'count', + queryLanguages: ['fr', 'es'], }; let _algoliaQueryParameters: QueryParameters = { diff --git a/types/algoliasearch/index.d.ts b/types/algoliasearch/index.d.ts index 8e3ba4c5ab..1dc50603c7 100644 --- a/types/algoliasearch/index.d.ts +++ b/types/algoliasearch/index.d.ts @@ -6,6 +6,7 @@ // Samuel Vaillant // Kai Eichinger // Nery Ortez +// Antoine Rousseau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -1778,12 +1779,20 @@ declare namespace algoliasearch { }; /** * List of attributes on which to do a decomposition of camel case words. - * - https://www.algolia.com/doc/api-reference/api-parameters/camelCaseAttributes/ + * https://www.algolia.com/doc/api-reference/api-parameters/camelCaseAttributes/ */ camelCaseAttributes?: string[]; - + /** + * Controls how facet values are sorted. + * https://www.algolia.com/doc/api-reference/api-parameters/sortFacetValuesBy/ + */ sortFacetValuesBy?: 'count' | 'alpha'; + /** + * Sets the languages to be used by language-specific settings and functionalities + * such as ignorePlurals, removeStopWords, and CJK word-detection. + * https://www.algolia.com/doc/api-reference/api-parameters/queryLanguages/ + */ + queryLanguages?: Array<'af' | 'ar' | 'az' | 'bg' | 'bn' | 'ca' | 'cs' | 'cy' | 'da' | 'de' | 'el' | 'en' | 'eo' | 'es' | 'et' | 'eu' | 'fa' | 'fi' | 'fo' | 'fr' | 'ga' | 'gl' | 'he' | 'hi' | 'hu' | 'hy' | 'id' | 'is' | 'it' | 'ja' | 'ka' | 'kk' | 'ko' | 'ku' | 'ky' | 'lt' | 'lv' | 'mi' | 'mn' | 'mr' | 'ms' | 'mt' | 'nb' | 'nl' | 'no' | 'ns' | 'pl' | 'ps' | 'pt' | 'pt-br' | 'qu' | 'ro' | 'ru' | 'sk' | 'sq' | 'sv' | 'sw' | 'ta' | 'te' | 'th' | 'tl' | 'tn' | 'tr' | 'tt' | 'uk' | 'ur' | 'uz' | 'zh'>; } interface Response { diff --git a/types/algoliasearch/lite/index.d.ts b/types/algoliasearch/lite/index.d.ts index 11e22f5ccf..74c4b1bf15 100644 --- a/types/algoliasearch/lite/index.d.ts +++ b/types/algoliasearch/lite/index.d.ts @@ -7,6 +7,7 @@ // Claas Brüggemann // Kai Eichinger // Nery Ortez +// Antoine Rousseau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -534,9 +535,16 @@ declare namespace algoliasearch { userData?: string | object; /** + * Controls how facet values are sorted. * https://www.algolia.com/doc/api-reference/api-parameters/sortFacetValuesBy/ */ sortFacetValuesBy?: 'count' | 'alpha'; + /** + * Sets the languages to be used by language-specific settings and functionalities + * such as ignorePlurals, removeStopWords, and CJK word-detection. + * https://www.algolia.com/doc/api-reference/api-parameters/queryLanguages/ + */ + queryLanguages?: Array<'af' | 'ar' | 'az' | 'bg' | 'bn' | 'ca' | 'cs' | 'cy' | 'da' | 'de' | 'el' | 'en' | 'eo' | 'es' | 'et' | 'eu' | 'fa' | 'fi' | 'fo' | 'fr' | 'ga' | 'gl' | 'he' | 'hi' | 'hu' | 'hy' | 'id' | 'is' | 'it' | 'ja' | 'ka' | 'kk' | 'ko' | 'ku' | 'ky' | 'lt' | 'lv' | 'mi' | 'mn' | 'mr' | 'ms' | 'mt' | 'nb' | 'nl' | 'no' | 'ns' | 'pl' | 'ps' | 'pt' | 'pt-br' | 'qu' | 'ro' | 'ru' | 'sk' | 'sq' | 'sv' | 'sw' | 'ta' | 'te' | 'th' | 'tl' | 'tn' | 'tr' | 'tt' | 'uk' | 'ur' | 'uz' | 'zh'>; } namespace SearchForFacetValues { diff --git a/types/amqplib/amqplib-tests.ts b/types/amqplib/amqplib-tests.ts index ef448d5b36..a42d2f717d 100644 --- a/types/amqplib/amqplib-tests.ts +++ b/types/amqplib/amqplib-tests.ts @@ -14,6 +14,14 @@ amqp.connect('amqp://localhost') amqp.connect('amqp://localhost') .then(connection => { + connection.serverProperties.copyright; // $ExpectType string | undefined + connection.serverProperties.platform; // $ExpectType string + connection.serverProperties.information; // $ExpectType string + connection.serverProperties.host; // $ExpectType string + connection.serverProperties.product; // $ExpectType string + connection.serverProperties.version; // $ExpectType string + connection.serverProperties.customField; // $ExpectType string | undefined + return connection.createChannel() .tap(channel => channel.checkQueue('myQueue')) .then(channel => { @@ -37,6 +45,14 @@ import amqpcb = require('amqplib/callback_api'); amqpcb.connect('amqp://localhost', (err, connection) => { if (!err) { + connection.serverProperties.copyright; // $ExpectType string | undefined + connection.serverProperties.platform; // $ExpectType string + connection.serverProperties.information; // $ExpectType string + connection.serverProperties.host; // $ExpectType string + connection.serverProperties.product; // $ExpectType string + connection.serverProperties.version; // $ExpectType string + connection.serverProperties.customField; // $ExpectType string | undefined + connection.createChannel((err, channel) => { if (!err) { channel.assertQueue('myQueue', {}, (err, ok) => { diff --git a/types/amqplib/callback_api.d.ts b/types/amqplib/callback_api.d.ts index 9fca3972e4..56842abc26 100644 --- a/types/amqplib/callback_api.d.ts +++ b/types/amqplib/callback_api.d.ts @@ -1,11 +1,12 @@ import events = require('events'); -import { Replies, Options, Message } from './properties'; +import { Replies, Options, Message, ServerProperties } from './properties'; export * from './properties'; export interface Connection extends events.EventEmitter { close(callback?: (err: any) => void): void; createChannel(callback: (err: any, channel: Channel) => void): void; createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void; + serverProperties: ServerProperties; } export interface Channel extends events.EventEmitter { diff --git a/types/amqplib/index.d.ts b/types/amqplib/index.d.ts index 7087d74edc..77e5d19ca9 100644 --- a/types/amqplib/index.d.ts +++ b/types/amqplib/index.d.ts @@ -8,13 +8,14 @@ import * as Promise from 'bluebird'; import * as events from 'events'; -import { Replies, Options, Message, GetMessage, ConsumeMessage } from './properties'; +import { Replies, Options, Message, GetMessage, ConsumeMessage, ServerProperties } from './properties'; export * from './properties'; export interface Connection extends events.EventEmitter { close(): Promise; createChannel(): Promise; createConfirmChannel(): Promise; + serverProperties: ServerProperties; } export interface Channel extends events.EventEmitter { diff --git a/types/amqplib/properties.d.ts b/types/amqplib/properties.d.ts index 97dc8ac393..4c7a210c6f 100644 --- a/types/amqplib/properties.d.ts +++ b/types/amqplib/properties.d.ts @@ -210,3 +210,13 @@ export interface XDeath { "original-expiration"?: any; "routing-keys": string[]; } + +export interface ServerProperties { + host: string; + product: string; + version: string; + platform: string; + copyright?: string; + information: string; + [key: string]: string | undefined; +} diff --git a/types/angular-material/index.d.ts b/types/angular-material/index.d.ts index 6b012d5677..444e043210 100644 --- a/types/angular-material/index.d.ts +++ b/types/angular-material/index.d.ts @@ -512,5 +512,10 @@ declare module 'angular' { } type IStickyService = (scope: IScope, element: JQuery, elementClone?: JQuery) => void; + + interface IInteractionService { + getLastInteractionType(): string|null; + isUserInvoked(checkDelay?: number): boolean; + } } } diff --git a/types/angular-ui-router/angular-ui-router-tests.ts b/types/angular-ui-router/angular-ui-router-tests.ts index 889e92bfc9..d7dfcbfbde 100644 --- a/types/angular-ui-router/angular-ui-router-tests.ts +++ b/types/angular-ui-router/angular-ui-router-tests.ts @@ -33,7 +33,7 @@ myApp.config(( $urlMatcherFactory.type("fullType", { decode: (val) => parseInt(val, 10), encode: (val) => val && val.toString(), - equals: (a, b) => this.is(a) && a === b, + equals: function (a, b) { return this.is(a) && a === b }, is: (val) => angular.isNumber(val) && isFinite(val) && val % 1 === 0, pattern: /\d+/ }); diff --git a/types/animejs/animejs-tests.ts b/types/animejs/animejs-tests.ts index 697c79f738..8ed6fccf8e 100644 --- a/types/animejs/animejs-tests.ts +++ b/types/animejs/animejs-tests.ts @@ -1,4 +1,4 @@ -import * as anime from 'animejs'; +import anime from 'animejs'; const test1 = anime({ targets: 'div', @@ -17,9 +17,9 @@ const test2 = anime({ }, translateY: '40px', color: [ - {value: '#FF0000', duration: 2000}, - {value: '#00FF00', duration: 2000}, - {value: '#0000FF', duration: 2000}, + { value: '#FF0000', duration: 2000 }, + { value: '#00FF00', duration: 2000 }, + { value: '#0000FF', duration: 2000 }, ], duration: () => { return 1000000000000; @@ -69,3 +69,9 @@ const bezier = anime.bezier(0, 0, 100, 100); anime.easings['hello'] = anime.bezier(0, 0, 1900, 3020); const runningAnims = anime.running; anime.remove(".tiny-divvy-div"); + +anime.timeline().add({ + targets: [], + duration: 1000, + easing: "linear", +}, 0); diff --git a/types/animejs/index.d.ts b/types/animejs/index.d.ts index 069187b15e..607872039f 100644 --- a/types/animejs/index.d.ts +++ b/types/animejs/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for animejs 2.0 // Project: http://animejs.com -// Definitions by: Andrew Babin +// Definitions by: Andrew Babin +// supaiku0 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -110,7 +111,7 @@ declare namespace anime { } interface AnimeTimelineInstance extends AnimeInstance { - add(params: AnimeAnimParams): AnimeTimelineInstance; + add(params: AnimeAnimParams, timelineOffset?: string | number): AnimeTimelineInstance; } // Helpers diff --git a/types/animejs/tsconfig.json b/types/animejs/tsconfig.json index 02c5552371..9ed0aa7d69 100644 --- a/types/animejs/tsconfig.json +++ b/types/animejs/tsconfig.json @@ -14,6 +14,7 @@ "../" ], "types": [], + "allowSyntheticDefaultImports": true, "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/ansi-escapes/index.d.ts b/types/ansi-escapes/index.d.ts index 519d429545..d01e74661a 100644 --- a/types/ansi-escapes/index.d.ts +++ b/types/ansi-escapes/index.d.ts @@ -19,10 +19,10 @@ declare namespace Ansi { interface AnsiEscapes { cursorTo(x: number, y?: number): string; cursorMove(x: number, y?: number): string; - cursorUp(count: number): string; - cursorDown(count: number): string; - cursorForward(count: number): string; - cursorBackward(count: number): string; + cursorUp(count?: number): string; + cursorDown(count?: number): string; + cursorForward(count?: number): string; + cursorBackward(count?: number): string; cursorLeft: string; cursorSavePosition: string; diff --git a/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts b/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts index b02c707d81..838ac825ea 100644 --- a/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts +++ b/types/assets-webpack-plugin/assets-webpack-plugin-tests.ts @@ -8,15 +8,21 @@ const config: webpack.Configuration = { filename: 'assets.json' }), new AssetsPlugin({ + entrypoints: true, filename: 'assets.json', fullPath: false, + fileTypes: ['css'], includeManifest: true, + includeAllFileTypes: false, + keepInMemory: true, + manifestFirst: true, path: '/foo/bar', prettyPrint: true, processOutput: (assets) => ( 'window.assets = ' + JSON.stringify(assets) ), update: true, + useCompilerPath: true, metadata: { meta: 'data' }, diff --git a/types/assets-webpack-plugin/index.d.ts b/types/assets-webpack-plugin/index.d.ts index 63563d6298..397002add3 100644 --- a/types/assets-webpack-plugin/index.d.ts +++ b/types/assets-webpack-plugin/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for assets-webpack-plugin 3.5 +// Type definitions for assets-webpack-plugin 3.9 // Project: https://github.com/ztoben/assets-webpack-plugin // Definitions by: Michael Strobel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -16,18 +16,36 @@ declare namespace AssetsWebpackPlugin { type ProcessOutputFn = (assets: Assets) => string; interface Options { + /** + * If the "entrypoints" option is given, the output will be limited to the entrypoints and the chunks associated with them. + * false by default + */ + entrypoints?: boolean; + /** * Name for the created json file. * "webpack-assets.json" by default */ filename?: string; + /** + * When set and "includeAllFileTypes" is set false, only assets matching these types will be included in the assets file. + * ['js', 'css'] by default + */ + fileTypes?: string[]; + /** * If false the output will not include the full path of the generated file. * true by default */ fullPath?: boolean; + /** + * When set false, falls back to the "fileTypes" option array to decide which file types to include in the assets file. + * true by default + */ + includeAllFileTypes?: boolean; + /** * Inserts the manifest javascript as a text property in your assets. * Accepts the name of your manifest chunk. @@ -38,6 +56,19 @@ declare namespace AssetsWebpackPlugin { */ includeManifest?: boolean; + /** + * When set the assets file will only be generated in memory while running webpack-dev-server and not written to disk. + * false by default + */ + keepInMemory?: boolean; + + /** + * Orders the assets output so that manifest is the first entry. + * This is useful for cases where script tags are generated from the assets json output, and order of import is important. + * false by default + */ + manifestFirst?: boolean; + /** * Inject metadata into the output file. All values will be injected into the key "metadata" */ @@ -66,6 +97,12 @@ declare namespace AssetsWebpackPlugin { * false by default */ update?: boolean; + + /** + * Will override the path to use the compiler output path set in your webpack config. + * false by default + */ + useCompilerPath?: boolean; } } diff --git a/types/autoprefixer/index.d.ts b/types/autoprefixer/index.d.ts index faf11371db..1681c5d838 100644 --- a/types/autoprefixer/index.d.ts +++ b/types/autoprefixer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for autoprefixer 9.1 +// Type definitions for autoprefixer 9.4 // Project: https://github.com/postcss/autoprefixer // Definitions by: Armando Meziat , murt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -15,7 +15,7 @@ declare namespace autoprefixer { remove?: boolean; supports?: boolean; flexbox?: boolean | 'no-2009'; - grid?: boolean; + grid?: boolean | 'autoplace' | 'no-autoplace'; stats?: any; ignoreUnknownVersions?: boolean; } diff --git a/types/awesomplete/awesomplete-tests.ts b/types/awesomplete/awesomplete-tests.ts index a3c66875a4..b019e25ca3 100644 --- a/types/awesomplete/awesomplete-tests.ts +++ b/types/awesomplete/awesomplete-tests.ts @@ -46,7 +46,7 @@ new Awesomplete('input[data-multiple]', { return Awesomplete.FILTER_CONTAINS(text, input.match(/[^,]*$/)[0]); }, - replace: (text: string) => { + replace(text: string) { const before = this.input.value.match(/^.+,\s*|/)[0]; this.input.value = `${before}${text}, `; } diff --git a/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts b/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts index 66655f8dd3..89eff9a8c6 100644 --- a/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts +++ b/types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts @@ -101,3 +101,50 @@ const thingShadows = new awsIot.thingShadow({ thingShadows.on("timeout", function(thingName: string, clientToken: string) { }); + +const jobs = new awsIot.jobs({ + keyPath: "", + certPath: "", + caPath: "", + clientId: "", + region: "", + baseReconnectTimeMs: 1000, + protocol: "wss", + port: 443, + host: "", + debug: false +}); + +jobs.subscribeToJobs("thingname", "operationname", (err, job) => { + console.error("Error", err); + if (err || !job) { + return; + } + console.log("job id", job.id); + console.log("job info", job.document); + console.log("job op", job.operation); + console.log("job status", job.status); + console.log("job status details", job.status.statusDetails); + console.log( + "job status details progress", + job.status.statusDetails.progress + ); + + job.inProgress({ progress: "1" }, err => + console.error("Job progress error", err) + ); + job.failed({ progress: "2" }, err => + console.error("Job failed error", err) + ); + job.succeeded({ progress: "3" }, err => + console.error("Job failed error", err) + ); +}); + +jobs.startJobNotifications("thingname", err => + console.error("Start job notification error", err) +); + +jobs.unsubscribeFromJobs("thingname", "operationame", err => + console.error("Unsubscribe from jobs error", err) +); diff --git a/types/aws-iot-device-sdk/index.d.ts b/types/aws-iot-device-sdk/index.d.ts index f2bcab818c..8b52a68bfc 100644 --- a/types/aws-iot-device-sdk/index.d.ts +++ b/types/aws-iot-device-sdk/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for aws-iot-device-sdk 2.1.0 +// Type definitions for aws-iot-device-sdk 2.2.0 // Project: https://github.com/aws/aws-iot-device-sdk-js // Definitions by: Markus Olsson // Margus Lamp @@ -391,3 +391,115 @@ export class thingShadow extends NodeJS.EventEmitter { /** Emitted when a different client"s update or delete operation is accepted on the shadow. */ on(event: "foreignStateChange", listener: (thingName: string, operation: "update" | "delete", stateObject: any) => void): this; } + +export interface statusDetails { + progress: string; +} + +export interface jobStatus { + status: string; + statusDetails: statusDetails; +} + +export interface jobDocument { + [key: string]: any +} + +export interface job { + /** Object that contains job execution information and functions for updating job execution status. */ + + /** Returns the job id. */ + id: string; + + /** + * The JSON document describing details of the job to be executed eg. + * { + * "operation": "install", + * "otherProperty": "value", + * ... + * } + */ + document: jobDocument; + + /** + * Returns the job operation from the job document. Eg. 'install', 'reboot', etc. + */ + operation: string; + + /** + * Returns the current job status according to AWS Orchestra. + */ + status: jobStatus; + + /** + * Update the status of the job execution to be IN_PROGRESS for the thing associated with the job. + * + * @param statusDetails - optional document describing the status details of the in progress job + * @param callback - function(err) optional callback for when the operation completes, err is null if no error occurred + */ + inProgress(statusDetails?: statusDetails, callback?: (err: Error) => void): void; + + /** + * Update the status of the job execution to be FAILED for the thing associated with the job. + * + * @param statusDetails - optional document describing the status details of the in progress job e.g. + * @param callback - function(err) optional callback for when the operation completes, err is null if no error occurred + */ + failed(statusDetails?: statusDetails, callback?: (err: Error) => void): void; + + /** + * Update the status of the job execution to be SUCCESS for the thing associated with the job. + * + * @param statusDetails - optional document describing the status details of the in progress job e.g. + * @param callback - function(err) optional callback for when the operation completes, err is null if no error occurred + */ + succeeded(statusDetails?: statusDetails, callback?: (err: Error) => void): void; +} + +export class jobs extends device { + /** + * The `jobs` class wraps an instance of the `device` class with additional functionality to + * handle job execution management through the AWS IoT Jobs platform. Arguments in `deviceOptions` + * are the same as those in the device class and the `jobs` class supports all of the + * same events and functions as the `device` class. + */ + constructor(options?: DeviceOptions); + + /** + * Subscribes to job execution notifications for the thing named `thingName`. If + * `operationName` is specified then the callback will only be called when a job + * ready for execution contains a property called `operation` in its job document with + * a value matching `operationName`. If `operationName` is omitted then the callback + * will be called for every job ready for execution that does not match another + * `subscribeToJobs` subscription. + * + * @param thingName - name of the Thing to receive job execution notifications + * @param operationName - optionally filter job execution notifications to jobs with a value + * for the `operation` property that matches `operationName + * @param callback - function (err, job) callback for when a job execution is ready for processing or an error occurs + * - `err` a subscription error or an error that occurs when client is disconnecting + * - `job` an object that contains job execution information and functions for updating job execution status. + */ + subscribeToJobs(thingName: string, operationName: string, callback?: (err: Error, job: job) => void): void; + + /** + * Causes any existing queued job executions for the given thing to be published + * to the appropriate subscribeToJobs handler. Only needs to be called once per thing. + * + * @param thingName - name of the Thing to cancel job execution notifications for + * @param callback - function (err) callback for when the startJobNotifications operation completes + */ + startJobNotifications(thingName: string, callback: (error: Error) => void): mqtt.Client; + + /** + * Unsubscribes from job execution notifications for the thing named `thingName` having + * operations with a value of the given `operationName`. If `operationName` is omitted then + * the default handler for the thing with the given name is unsubscribed. + * + * @param thingName - name of the Thing to cancel job execution notifications for + * @param operationName - optional name of previously subscribed operation names + * @param callback - function (err) callback for when the unsubscribe operation completes + */ + unsubscribeFromJobs(thingName: string, operationName: string, callback: (err: Error) => void): void; + +} diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index 3301feebb5..d3bee679b3 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -26,6 +26,8 @@ // James Gregory // Erik Dalén // Loïk Gaonac'h +// Roberto Zen +// Richard Cornelissen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -34,7 +36,7 @@ export interface APIGatewayEventRequestContext { accountId: string; apiId: string; authorizer?: AuthResponseContext | null; - connectedAt: number; + connectedAt?: number; connectionId?: string; domainName?: string; eventType?: string; @@ -535,10 +537,10 @@ export type StatementResource = MaybeStatementPrincipal & ({ Resource: string | export type StatementPrincipal = MaybeStatementResource & ({ Principal: PrincipalValue } | { NotPrincipal: PrincipalValue }); /** * API Gateway CustomAuthorizer AuthResponse.PolicyDocument.Statement. - * http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-output + * https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html */ export interface AuthResponseContext { - [name: string]: any; + [name: string]: boolean | number | string; } /** diff --git a/types/babel-types/babel-types-tests.ts b/types/babel-types/babel-types-tests.ts index 8ffb1b32de..921608924c 100644 --- a/types/babel-types/babel-types-tests.ts +++ b/types/babel-types/babel-types-tests.ts @@ -53,6 +53,12 @@ traverse(ast, { } }); +// Node type checks +t.isIdentifier(t.identifier("id")); +t.isIdentifier(exp); +t.isIdentifier(null); +t.isIdentifier(undefined); + // TypeScript Types // TODO: Test all variants of these functions' signatures diff --git a/types/babel-types/index.d.ts b/types/babel-types/index.d.ts index d37cdf0a76..f0d781a7ed 100644 --- a/types/babel-types/index.d.ts +++ b/types/babel-types/index.d.ts @@ -1514,246 +1514,246 @@ export function TSUndefinedKeyword(): TSUndefinedKeyword; export function TSUnionType(types: TSType[]): TSUnionType; export function TSVoidKeyword(): TSVoidKeyword; -export function isArrayExpression(node: object, opts?: object): node is ArrayExpression; -export function isAssignmentExpression(node: object, opts?: object): node is AssignmentExpression; -export function isBinaryExpression(node: object, opts?: object): node is BinaryExpression; -export function isDirective(node: object, opts?: object): node is Directive; -export function isDirectiveLiteral(node: object, opts?: object): node is DirectiveLiteral; -export function isBlockStatement(node: object, opts?: object): node is BlockStatement; -export function isBreakStatement(node: object, opts?: object): node is BreakStatement; -export function isCallExpression(node: object, opts?: object): node is CallExpression; -export function isCatchClause(node: object, opts?: object): node is CatchClause; -export function isConditionalExpression(node: object, opts?: object): node is ConditionalExpression; -export function isContinueStatement(node: object, opts?: object): node is ContinueStatement; -export function isDebuggerStatement(node: object, opts?: object): node is DebuggerStatement; -export function isDoWhileStatement(node: object, opts?: object): node is DoWhileStatement; -export function isEmptyStatement(node: object, opts?: object): node is EmptyStatement; -export function isExpressionStatement(node: object, opts?: object): node is ExpressionStatement; -export function isFile(node: object, opts?: object): node is File; -export function isForInStatement(node: object, opts?: object): node is ForInStatement; -export function isForStatement(node: object, opts?: object): node is ForStatement; -export function isFunctionDeclaration(node: object, opts?: object): node is FunctionDeclaration; -export function isFunctionExpression(node: object, opts?: object): node is FunctionExpression; -export function isIdentifier(node: object, opts?: object): node is Identifier; -export function isIfStatement(node: object, opts?: object): node is IfStatement; -export function isLabeledStatement(node: object, opts?: object): node is LabeledStatement; -export function isStringLiteral(node: object, opts?: object): node is StringLiteral; -export function isNumericLiteral(node: object, opts?: object): node is NumericLiteral; -export function isNullLiteral(node: object, opts?: object): node is NullLiteral; -export function isBooleanLiteral(node: object, opts?: object): node is BooleanLiteral; -export function isRegExpLiteral(node: object, opts?: object): node is RegExpLiteral; -export function isLogicalExpression(node: object, opts?: object): node is LogicalExpression; -export function isMemberExpression(node: object, opts?: object): node is MemberExpression; -export function isNewExpression(node: object, opts?: object): node is NewExpression; -export function isProgram(node: object, opts?: object): node is Program; -export function isObjectExpression(node: object, opts?: object): node is ObjectExpression; -export function isObjectMethod(node: object, opts?: object): node is ObjectMethod; -export function isObjectProperty(node: object, opts?: object): node is ObjectProperty; -export function isRestElement(node: object, opts?: object): node is RestElement; -export function isReturnStatement(node: object, opts?: object): node is ReturnStatement; -export function isSequenceExpression(node: object, opts?: object): node is SequenceExpression; -export function isSwitchCase(node: object, opts?: object): node is SwitchCase; -export function isSwitchStatement(node: object, opts?: object): node is SwitchStatement; -export function isThisExpression(node: object, opts?: object): node is ThisExpression; -export function isThrowStatement(node: object, opts?: object): node is ThrowStatement; -export function isTryStatement(node: object, opts?: object): node is TryStatement; -export function isUnaryExpression(node: object, opts?: object): node is UnaryExpression; -export function isUpdateExpression(node: object, opts?: object): node is UpdateExpression; -export function isVariableDeclaration(node: object, opts?: object): node is VariableDeclaration; -export function isVariableDeclarator(node: object, opts?: object): node is VariableDeclarator; -export function isWhileStatement(node: object, opts?: object): node is WhileStatement; -export function isWithStatement(node: object, opts?: object): node is WithStatement; -export function isAssignmentPattern(node: object, opts?: object): node is AssignmentPattern; -export function isArrayPattern(node: object, opts?: object): node is ArrayPattern; -export function isArrowFunctionExpression(node: object, opts?: object): node is ArrowFunctionExpression; -export function isClassBody(node: object, opts?: object): node is ClassBody; -export function isClassDeclaration(node: object, opts?: object): node is ClassDeclaration; -export function isClassExpression(node: object, opts?: object): node is ClassExpression; -export function isExportAllDeclaration(node: object, opts?: object): node is ExportAllDeclaration; -export function isExportDefaultDeclaration(node: object, opts?: object): node is ExportDefaultDeclaration; -export function isExportNamedDeclaration(node: object, opts?: object): node is ExportNamedDeclaration; -export function isExportSpecifier(node: object, opts?: object): node is ExportSpecifier; -export function isForOfStatement(node: object, opts?: object): node is ForOfStatement; -export function isImportDeclaration(node: object, opts?: object): node is ImportDeclaration; -export function isImportDefaultSpecifier(node: object, opts?: object): node is ImportDefaultSpecifier; -export function isImportNamespaceSpecifier(node: object, opts?: object): node is ImportNamespaceSpecifier; -export function isImportSpecifier(node: object, opts?: object): node is ImportSpecifier; -export function isMetaProperty(node: object, opts?: object): node is MetaProperty; -export function isClassMethod(node: object, opts?: object): node is ClassMethod; -export function isObjectPattern(node: object, opts?: object): node is ObjectPattern; -export function isSpreadElement(node: object, opts?: object): node is SpreadElement; -export function isSuper(node: object, opts?: object): node is Super; -export function isTaggedTemplateExpression(node: object, opts?: object): node is TaggedTemplateExpression; -export function isTemplateElement(node: object, opts?: object): node is TemplateElement; -export function isTemplateLiteral(node: object, opts?: object): node is TemplateLiteral; -export function isYieldExpression(node: object, opts?: object): node is YieldExpression; -export function isAnyTypeAnnotation(node: object, opts?: object): node is AnyTypeAnnotation; -export function isArrayTypeAnnotation(node: object, opts?: object): node is ArrayTypeAnnotation; -export function isBooleanTypeAnnotation(node: object, opts?: object): node is BooleanTypeAnnotation; -export function isBooleanLiteralTypeAnnotation(node: object, opts?: object): node is BooleanLiteralTypeAnnotation; -export function isNullLiteralTypeAnnotation(node: object, opts?: object): node is NullLiteralTypeAnnotation; -export function isClassImplements(node: object, opts?: object): node is ClassImplements; -export function isClassProperty(node: object, opts?: object): node is ClassProperty; -export function isDeclareClass(node: object, opts?: object): node is DeclareClass; -export function isDeclareFunction(node: object, opts?: object): node is DeclareFunction; -export function isDeclareInterface(node: object, opts?: object): node is DeclareInterface; -export function isDeclareModule(node: object, opts?: object): node is DeclareModule; -export function isDeclareTypeAlias(node: object, opts?: object): node is DeclareTypeAlias; -export function isDeclareVariable(node: object, opts?: object): node is DeclareVariable; -export function isExistentialTypeParam(node: object, opts?: object): node is ExistentialTypeParam; -export function isFunctionTypeAnnotation(node: object, opts?: object): node is FunctionTypeAnnotation; -export function isFunctionTypeParam(node: object, opts?: object): node is FunctionTypeParam; -export function isGenericTypeAnnotation(node: object, opts?: object): node is GenericTypeAnnotation; -export function isInterfaceExtends(node: object, opts?: object): node is InterfaceExtends; -export function isInterfaceDeclaration(node: object, opts?: object): node is InterfaceDeclaration; -export function isIntersectionTypeAnnotation(node: object, opts?: object): node is IntersectionTypeAnnotation; -export function isMixedTypeAnnotation(node: object, opts?: object): node is MixedTypeAnnotation; -export function isNullableTypeAnnotation(node: object, opts?: object): node is NullableTypeAnnotation; -export function isNumericLiteralTypeAnnotation(node: object, opts?: object): node is NumericLiteralTypeAnnotation; -export function isNumberTypeAnnotation(node: object, opts?: object): node is NumberTypeAnnotation; -export function isStringLiteralTypeAnnotation(node: object, opts?: object): node is StringLiteralTypeAnnotation; -export function isStringTypeAnnotation(node: object, opts?: object): node is StringTypeAnnotation; -export function isThisTypeAnnotation(node: object, opts?: object): node is ThisTypeAnnotation; -export function isTupleTypeAnnotation(node: object, opts?: object): node is TupleTypeAnnotation; -export function isTypeofTypeAnnotation(node: object, opts?: object): node is TypeofTypeAnnotation; -export function isTypeAlias(node: object, opts?: object): node is TypeAlias; -export function isTypeAnnotation(node: object, opts?: object): node is TypeAnnotation; -export function isTypeCastExpression(node: object, opts?: object): node is TypeCastExpression; -export function isTypeParameter(node: object, opts?: object): node is TypeParameter; -export function isTypeParameterDeclaration(node: object, opts?: object): node is TypeParameterDeclaration; -export function isTypeParameterInstantiation(node: object, opts?: object): node is TypeParameterInstantiation; -export function isObjectTypeAnnotation(node: object, opts?: object): node is ObjectTypeAnnotation; -export function isObjectTypeCallProperty(node: object, opts?: object): node is ObjectTypeCallProperty; -export function isObjectTypeIndexer(node: object, opts?: object): node is ObjectTypeIndexer; -export function isObjectTypeProperty(node: object, opts?: object): node is ObjectTypeProperty; -export function isQualifiedTypeIdentifier(node: object, opts?: object): node is QualifiedTypeIdentifier; -export function isUnionTypeAnnotation(node: object, opts?: object): node is UnionTypeAnnotation; -export function isVoidTypeAnnotation(node: object, opts?: object): node is VoidTypeAnnotation; -export function isJSXAttribute(node: object, opts?: object): node is JSXAttribute; -export function isJSXClosingElement(node: object, opts?: object): node is JSXClosingElement; -export function isJSXElement(node: object, opts?: object): node is JSXElement; -export function isJSXEmptyExpression(node: object, opts?: object): node is JSXEmptyExpression; -export function isJSXExpressionContainer(node: object, opts?: object): node is JSXExpressionContainer; -export function isJSXIdentifier(node: object, opts?: object): node is JSXIdentifier; -export function isJSXMemberExpression(node: object, opts?: object): node is JSXMemberExpression; -export function isJSXNamespacedName(node: object, opts?: object): node is JSXNamespacedName; -export function isJSXOpeningElement(node: object, opts?: object): node is JSXOpeningElement; -export function isJSXSpreadAttribute(node: object, opts?: object): node is JSXSpreadAttribute; -export function isJSXText(node: object, opts?: object): node is JSXText; -export function isNoop(node: object, opts?: object): node is Noop; -export function isParenthesizedExpression(node: object, opts?: object): node is ParenthesizedExpression; -export function isAwaitExpression(node: object, opts?: object): node is AwaitExpression; -export function isBindExpression(node: object, opts?: object): node is BindExpression; -export function isDecorator(node: object, opts?: object): node is Decorator; -export function isDoExpression(node: object, opts?: object): node is DoExpression; -export function isExportDefaultSpecifier(node: object, opts?: object): node is ExportDefaultSpecifier; -export function isExportNamespaceSpecifier(node: object, opts?: object): node is ExportNamespaceSpecifier; -export function isRestProperty(node: object, opts?: object): node is RestProperty; -export function isSpreadProperty(node: object, opts?: object): node is SpreadProperty; -export function isExpression(node: object, opts?: object): node is Expression; -export function isBinary(node: object, opts?: object): node is Binary; -export function isScopable(node: object, opts?: object): node is Scopable; -export function isBlockParent(node: object, opts?: object): node is BlockParent; -export function isBlock(node: object, opts?: object): node is Block; -export function isStatement(node: object, opts?: object): node is Statement; -export function isTerminatorless(node: object, opts?: object): node is Terminatorless; -export function isCompletionStatement(node: object, opts?: object): node is CompletionStatement; -export function isConditional(node: object, opts?: object): node is Conditional; -export function isLoop(node: object, opts?: object): node is Loop; -export function isWhile(node: object, opts?: object): node is While; -export function isExpressionWrapper(node: object, opts?: object): node is ExpressionWrapper; -export function isFor(node: object, opts?: object): node is For; -export function isForXStatement(node: object, opts?: object): node is ForXStatement; +export function isArrayExpression(node: object | null | undefined, opts?: object): node is ArrayExpression; +export function isAssignmentExpression(node: object | null | undefined, opts?: object): node is AssignmentExpression; +export function isBinaryExpression(node: object | null | undefined, opts?: object): node is BinaryExpression; +export function isDirective(node: object | null | undefined, opts?: object): node is Directive; +export function isDirectiveLiteral(node: object | null | undefined, opts?: object): node is DirectiveLiteral; +export function isBlockStatement(node: object | null | undefined, opts?: object): node is BlockStatement; +export function isBreakStatement(node: object | null | undefined, opts?: object): node is BreakStatement; +export function isCallExpression(node: object | null | undefined, opts?: object): node is CallExpression; +export function isCatchClause(node: object | null | undefined, opts?: object): node is CatchClause; +export function isConditionalExpression(node: object | null | undefined, opts?: object): node is ConditionalExpression; +export function isContinueStatement(node: object | null | undefined, opts?: object): node is ContinueStatement; +export function isDebuggerStatement(node: object | null | undefined, opts?: object): node is DebuggerStatement; +export function isDoWhileStatement(node: object | null | undefined, opts?: object): node is DoWhileStatement; +export function isEmptyStatement(node: object | null | undefined, opts?: object): node is EmptyStatement; +export function isExpressionStatement(node: object | null | undefined, opts?: object): node is ExpressionStatement; +export function isFile(node: object | null | undefined, opts?: object): node is File; +export function isForInStatement(node: object | null | undefined, opts?: object): node is ForInStatement; +export function isForStatement(node: object | null | undefined, opts?: object): node is ForStatement; +export function isFunctionDeclaration(node: object | null | undefined, opts?: object): node is FunctionDeclaration; +export function isFunctionExpression(node: object | null | undefined, opts?: object): node is FunctionExpression; +export function isIdentifier(node: object | null | undefined, opts?: object): node is Identifier; +export function isIfStatement(node: object | null | undefined, opts?: object): node is IfStatement; +export function isLabeledStatement(node: object | null | undefined, opts?: object): node is LabeledStatement; +export function isStringLiteral(node: object | null | undefined, opts?: object): node is StringLiteral; +export function isNumericLiteral(node: object | null | undefined, opts?: object): node is NumericLiteral; +export function isNullLiteral(node: object | null | undefined, opts?: object): node is NullLiteral; +export function isBooleanLiteral(node: object | null | undefined, opts?: object): node is BooleanLiteral; +export function isRegExpLiteral(node: object | null | undefined, opts?: object): node is RegExpLiteral; +export function isLogicalExpression(node: object | null | undefined, opts?: object): node is LogicalExpression; +export function isMemberExpression(node: object | null | undefined, opts?: object): node is MemberExpression; +export function isNewExpression(node: object | null | undefined, opts?: object): node is NewExpression; +export function isProgram(node: object | null | undefined, opts?: object): node is Program; +export function isObjectExpression(node: object | null | undefined, opts?: object): node is ObjectExpression; +export function isObjectMethod(node: object | null | undefined, opts?: object): node is ObjectMethod; +export function isObjectProperty(node: object | null | undefined, opts?: object): node is ObjectProperty; +export function isRestElement(node: object | null | undefined, opts?: object): node is RestElement; +export function isReturnStatement(node: object | null | undefined, opts?: object): node is ReturnStatement; +export function isSequenceExpression(node: object | null | undefined, opts?: object): node is SequenceExpression; +export function isSwitchCase(node: object | null | undefined, opts?: object): node is SwitchCase; +export function isSwitchStatement(node: object | null | undefined, opts?: object): node is SwitchStatement; +export function isThisExpression(node: object | null | undefined, opts?: object): node is ThisExpression; +export function isThrowStatement(node: object | null | undefined, opts?: object): node is ThrowStatement; +export function isTryStatement(node: object | null | undefined, opts?: object): node is TryStatement; +export function isUnaryExpression(node: object | null | undefined, opts?: object): node is UnaryExpression; +export function isUpdateExpression(node: object | null | undefined, opts?: object): node is UpdateExpression; +export function isVariableDeclaration(node: object | null | undefined, opts?: object): node is VariableDeclaration; +export function isVariableDeclarator(node: object | null | undefined, opts?: object): node is VariableDeclarator; +export function isWhileStatement(node: object | null | undefined, opts?: object): node is WhileStatement; +export function isWithStatement(node: object | null | undefined, opts?: object): node is WithStatement; +export function isAssignmentPattern(node: object | null | undefined, opts?: object): node is AssignmentPattern; +export function isArrayPattern(node: object | null | undefined, opts?: object): node is ArrayPattern; +export function isArrowFunctionExpression(node: object | null | undefined, opts?: object): node is ArrowFunctionExpression; +export function isClassBody(node: object | null | undefined, opts?: object): node is ClassBody; +export function isClassDeclaration(node: object | null | undefined, opts?: object): node is ClassDeclaration; +export function isClassExpression(node: object | null | undefined, opts?: object): node is ClassExpression; +export function isExportAllDeclaration(node: object | null | undefined, opts?: object): node is ExportAllDeclaration; +export function isExportDefaultDeclaration(node: object | null | undefined, opts?: object): node is ExportDefaultDeclaration; +export function isExportNamedDeclaration(node: object | null | undefined, opts?: object): node is ExportNamedDeclaration; +export function isExportSpecifier(node: object | null | undefined, opts?: object): node is ExportSpecifier; +export function isForOfStatement(node: object | null | undefined, opts?: object): node is ForOfStatement; +export function isImportDeclaration(node: object | null | undefined, opts?: object): node is ImportDeclaration; +export function isImportDefaultSpecifier(node: object | null | undefined, opts?: object): node is ImportDefaultSpecifier; +export function isImportNamespaceSpecifier(node: object | null | undefined, opts?: object): node is ImportNamespaceSpecifier; +export function isImportSpecifier(node: object | null | undefined, opts?: object): node is ImportSpecifier; +export function isMetaProperty(node: object | null | undefined, opts?: object): node is MetaProperty; +export function isClassMethod(node: object | null | undefined, opts?: object): node is ClassMethod; +export function isObjectPattern(node: object | null | undefined, opts?: object): node is ObjectPattern; +export function isSpreadElement(node: object | null | undefined, opts?: object): node is SpreadElement; +export function isSuper(node: object | null | undefined, opts?: object): node is Super; +export function isTaggedTemplateExpression(node: object | null | undefined, opts?: object): node is TaggedTemplateExpression; +export function isTemplateElement(node: object | null | undefined, opts?: object): node is TemplateElement; +export function isTemplateLiteral(node: object | null | undefined, opts?: object): node is TemplateLiteral; +export function isYieldExpression(node: object | null | undefined, opts?: object): node is YieldExpression; +export function isAnyTypeAnnotation(node: object | null | undefined, opts?: object): node is AnyTypeAnnotation; +export function isArrayTypeAnnotation(node: object | null | undefined, opts?: object): node is ArrayTypeAnnotation; +export function isBooleanTypeAnnotation(node: object | null | undefined, opts?: object): node is BooleanTypeAnnotation; +export function isBooleanLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is BooleanLiteralTypeAnnotation; +export function isNullLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is NullLiteralTypeAnnotation; +export function isClassImplements(node: object | null | undefined, opts?: object): node is ClassImplements; +export function isClassProperty(node: object | null | undefined, opts?: object): node is ClassProperty; +export function isDeclareClass(node: object | null | undefined, opts?: object): node is DeclareClass; +export function isDeclareFunction(node: object | null | undefined, opts?: object): node is DeclareFunction; +export function isDeclareInterface(node: object | null | undefined, opts?: object): node is DeclareInterface; +export function isDeclareModule(node: object | null | undefined, opts?: object): node is DeclareModule; +export function isDeclareTypeAlias(node: object | null | undefined, opts?: object): node is DeclareTypeAlias; +export function isDeclareVariable(node: object | null | undefined, opts?: object): node is DeclareVariable; +export function isExistentialTypeParam(node: object | null | undefined, opts?: object): node is ExistentialTypeParam; +export function isFunctionTypeAnnotation(node: object | null | undefined, opts?: object): node is FunctionTypeAnnotation; +export function isFunctionTypeParam(node: object | null | undefined, opts?: object): node is FunctionTypeParam; +export function isGenericTypeAnnotation(node: object | null | undefined, opts?: object): node is GenericTypeAnnotation; +export function isInterfaceExtends(node: object | null | undefined, opts?: object): node is InterfaceExtends; +export function isInterfaceDeclaration(node: object | null | undefined, opts?: object): node is InterfaceDeclaration; +export function isIntersectionTypeAnnotation(node: object | null | undefined, opts?: object): node is IntersectionTypeAnnotation; +export function isMixedTypeAnnotation(node: object | null | undefined, opts?: object): node is MixedTypeAnnotation; +export function isNullableTypeAnnotation(node: object | null | undefined, opts?: object): node is NullableTypeAnnotation; +export function isNumericLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is NumericLiteralTypeAnnotation; +export function isNumberTypeAnnotation(node: object | null | undefined, opts?: object): node is NumberTypeAnnotation; +export function isStringLiteralTypeAnnotation(node: object | null | undefined, opts?: object): node is StringLiteralTypeAnnotation; +export function isStringTypeAnnotation(node: object | null | undefined, opts?: object): node is StringTypeAnnotation; +export function isThisTypeAnnotation(node: object | null | undefined, opts?: object): node is ThisTypeAnnotation; +export function isTupleTypeAnnotation(node: object | null | undefined, opts?: object): node is TupleTypeAnnotation; +export function isTypeofTypeAnnotation(node: object | null | undefined, opts?: object): node is TypeofTypeAnnotation; +export function isTypeAlias(node: object | null | undefined, opts?: object): node is TypeAlias; +export function isTypeAnnotation(node: object | null | undefined, opts?: object): node is TypeAnnotation; +export function isTypeCastExpression(node: object | null | undefined, opts?: object): node is TypeCastExpression; +export function isTypeParameter(node: object | null | undefined, opts?: object): node is TypeParameter; +export function isTypeParameterDeclaration(node: object | null | undefined, opts?: object): node is TypeParameterDeclaration; +export function isTypeParameterInstantiation(node: object | null | undefined, opts?: object): node is TypeParameterInstantiation; +export function isObjectTypeAnnotation(node: object | null | undefined, opts?: object): node is ObjectTypeAnnotation; +export function isObjectTypeCallProperty(node: object | null | undefined, opts?: object): node is ObjectTypeCallProperty; +export function isObjectTypeIndexer(node: object | null | undefined, opts?: object): node is ObjectTypeIndexer; +export function isObjectTypeProperty(node: object | null | undefined, opts?: object): node is ObjectTypeProperty; +export function isQualifiedTypeIdentifier(node: object | null | undefined, opts?: object): node is QualifiedTypeIdentifier; +export function isUnionTypeAnnotation(node: object | null | undefined, opts?: object): node is UnionTypeAnnotation; +export function isVoidTypeAnnotation(node: object | null | undefined, opts?: object): node is VoidTypeAnnotation; +export function isJSXAttribute(node: object | null | undefined, opts?: object): node is JSXAttribute; +export function isJSXClosingElement(node: object | null | undefined, opts?: object): node is JSXClosingElement; +export function isJSXElement(node: object | null | undefined, opts?: object): node is JSXElement; +export function isJSXEmptyExpression(node: object | null | undefined, opts?: object): node is JSXEmptyExpression; +export function isJSXExpressionContainer(node: object | null | undefined, opts?: object): node is JSXExpressionContainer; +export function isJSXIdentifier(node: object | null | undefined, opts?: object): node is JSXIdentifier; +export function isJSXMemberExpression(node: object | null | undefined, opts?: object): node is JSXMemberExpression; +export function isJSXNamespacedName(node: object | null | undefined, opts?: object): node is JSXNamespacedName; +export function isJSXOpeningElement(node: object | null | undefined, opts?: object): node is JSXOpeningElement; +export function isJSXSpreadAttribute(node: object | null | undefined, opts?: object): node is JSXSpreadAttribute; +export function isJSXText(node: object | null | undefined, opts?: object): node is JSXText; +export function isNoop(node: object | null | undefined, opts?: object): node is Noop; +export function isParenthesizedExpression(node: object | null | undefined, opts?: object): node is ParenthesizedExpression; +export function isAwaitExpression(node: object | null | undefined, opts?: object): node is AwaitExpression; +export function isBindExpression(node: object | null | undefined, opts?: object): node is BindExpression; +export function isDecorator(node: object | null | undefined, opts?: object): node is Decorator; +export function isDoExpression(node: object | null | undefined, opts?: object): node is DoExpression; +export function isExportDefaultSpecifier(node: object | null | undefined, opts?: object): node is ExportDefaultSpecifier; +export function isExportNamespaceSpecifier(node: object | null | undefined, opts?: object): node is ExportNamespaceSpecifier; +export function isRestProperty(node: object | null | undefined, opts?: object): node is RestProperty; +export function isSpreadProperty(node: object | null | undefined, opts?: object): node is SpreadProperty; +export function isExpression(node: object | null | undefined, opts?: object): node is Expression; +export function isBinary(node: object | null | undefined, opts?: object): node is Binary; +export function isScopable(node: object | null | undefined, opts?: object): node is Scopable; +export function isBlockParent(node: object | null | undefined, opts?: object): node is BlockParent; +export function isBlock(node: object | null | undefined, opts?: object): node is Block; +export function isStatement(node: object | null | undefined, opts?: object): node is Statement; +export function isTerminatorless(node: object | null | undefined, opts?: object): node is Terminatorless; +export function isCompletionStatement(node: object | null | undefined, opts?: object): node is CompletionStatement; +export function isConditional(node: object | null | undefined, opts?: object): node is Conditional; +export function isLoop(node: object | null | undefined, opts?: object): node is Loop; +export function isWhile(node: object | null | undefined, opts?: object): node is While; +export function isExpressionWrapper(node: object | null | undefined, opts?: object): node is ExpressionWrapper; +export function isFor(node: object | null | undefined, opts?: object): node is For; +export function isForXStatement(node: object | null | undefined, opts?: object): node is ForXStatement; // tslint:disable-next-line ban-types -export function isFunction(node: object, opts?: object): node is Function; -export function isFunctionParent(node: object, opts?: object): node is FunctionParent; -export function isPureish(node: object, opts?: object): node is Pureish; -export function isDeclaration(node: object, opts?: object): node is Declaration; -export function isLVal(node: object, opts?: object): node is LVal; -export function isLiteral(node: object, opts?: object): node is Literal; -export function isImmutable(node: object, opts?: object): node is Immutable; -export function isUserWhitespacable(node: object, opts?: object): node is UserWhitespacable; -export function isMethod(node: object, opts?: object): node is Method; -export function isObjectMember(node: object, opts?: object): node is ObjectMember; -export function isProperty(node: object, opts?: object): node is Property; -export function isUnaryLike(node: object, opts?: object): node is UnaryLike; -export function isPattern(node: object, opts?: object): node is Pattern; -export function isClass(node: object, opts?: object): node is Class; -export function isModuleDeclaration(node: object, opts?: object): node is ModuleDeclaration; -export function isExportDeclaration(node: object, opts?: object): node is ExportDeclaration; -export function isModuleSpecifier(node: object, opts?: object): node is ModuleSpecifier; -export function isFlow(node: object, opts?: object): node is Flow; -export function isFlowBaseAnnotation(node: object, opts?: object): node is FlowBaseAnnotation; -export function isFlowDeclaration(node: object, opts?: object): node is FlowDeclaration; -export function isJSX(node: object, opts?: object): node is JSX; -export function isNumberLiteral(node: object, opts?: object): node is NumericLiteral; -export function isRegexLiteral(node: object, opts?: object): node is RegExpLiteral; +export function isFunction(node: object | null | undefined, opts?: object): node is Function; +export function isFunctionParent(node: object | null | undefined, opts?: object): node is FunctionParent; +export function isPureish(node: object | null | undefined, opts?: object): node is Pureish; +export function isDeclaration(node: object | null | undefined, opts?: object): node is Declaration; +export function isLVal(node: object | null | undefined, opts?: object): node is LVal; +export function isLiteral(node: object | null | undefined, opts?: object): node is Literal; +export function isImmutable(node: object | null | undefined, opts?: object): node is Immutable; +export function isUserWhitespacable(node: object | null | undefined, opts?: object): node is UserWhitespacable; +export function isMethod(node: object | null | undefined, opts?: object): node is Method; +export function isObjectMember(node: object | null | undefined, opts?: object): node is ObjectMember; +export function isProperty(node: object | null | undefined, opts?: object): node is Property; +export function isUnaryLike(node: object | null | undefined, opts?: object): node is UnaryLike; +export function isPattern(node: object | null | undefined, opts?: object): node is Pattern; +export function isClass(node: object | null | undefined, opts?: object): node is Class; +export function isModuleDeclaration(node: object | null | undefined, opts?: object): node is ModuleDeclaration; +export function isExportDeclaration(node: object | null | undefined, opts?: object): node is ExportDeclaration; +export function isModuleSpecifier(node: object | null | undefined, opts?: object): node is ModuleSpecifier; +export function isFlow(node: object | null | undefined, opts?: object): node is Flow; +export function isFlowBaseAnnotation(node: object | null | undefined, opts?: object): node is FlowBaseAnnotation; +export function isFlowDeclaration(node: object | null | undefined, opts?: object): node is FlowDeclaration; +export function isJSX(node: object | null | undefined, opts?: object): node is JSX; +export function isNumberLiteral(node: object | null | undefined, opts?: object): node is NumericLiteral; +export function isRegexLiteral(node: object | null | undefined, opts?: object): node is RegExpLiteral; -export function isReferencedIdentifier(node: object, opts?: object): node is Identifier | JSXIdentifier; -export function isReferencedMemberExpression(node: object, opts?: object): node is MemberExpression; -export function isBindingIdentifier(node: object, opts?: object): node is Identifier; -export function isScope(node: object, opts?: object): node is Scopable; -export function isReferenced(node: object, opts?: object): boolean; -export function isBlockScoped(node: object, opts?: object): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration; -export function isVar(node: object, opts?: object): node is VariableDeclaration; -export function isUser(node: object, opts?: object): boolean; -export function isGenerated(node: object, opts?: object): boolean; -export function isPure(node: object, opts?: object): boolean; +export function isReferencedIdentifier(node: object | null | undefined, opts?: object): node is Identifier | JSXIdentifier; +export function isReferencedMemberExpression(node: object | null | undefined, opts?: object): node is MemberExpression; +export function isBindingIdentifier(node: object | null | undefined, opts?: object): node is Identifier; +export function isScope(node: object | null | undefined, opts?: object): node is Scopable; +export function isReferenced(node: object | null | undefined, opts?: object): boolean; +export function isBlockScoped(node: object | null | undefined, opts?: object): node is FunctionDeclaration | ClassDeclaration | VariableDeclaration; +export function isVar(node: object | null | undefined, opts?: object): node is VariableDeclaration; +export function isUser(node: object | null | undefined, opts?: object): boolean; +export function isGenerated(node: object | null | undefined, opts?: object): boolean; +export function isPure(node: object | null | undefined, opts?: object): boolean; -export function isTSAnyKeyword(node: object, opts?: object): node is TSAnyKeyword; -export function isTSArrayType(node: object, opts?: object): node is TSArrayType; -export function isTSAsExpression(node: object, opts?: object): node is TSAsExpression; -export function isTSBooleanKeyword(node: object, opts?: object): node is TSBooleanKeyword; -export function isTSCallSignatureDeclaration(node: object, opts?: object): node is TSCallSignatureDeclaration; -export function isTSConstructSignatureDeclaration(node: object, opts?: object): node is TSTypeElement; -export function isTSConstructorType(node: object, opts?: object): node is TSConstructorType; -export function isTSDeclareFunction(node: object, opts?: object): node is TSDeclareFunction; -export function isTSDeclareMethod(node: object, opts?: object): node is TSDeclareMethod; -export function isTSEnumDeclaration(node: object, opts?: object): node is TSEnumDeclaration; -export function isTSEnumMember(node: object, opts?: object): node is TSEnumMember; -export function isTSExportAssignment(node: object, opts?: object): node is TSExportAssignment; -export function isTSExpressionWithTypeArguments(node: object, opts?: object): node is TSExpressionWithTypeArguments; -export function isTSExternalModuleReference(node: object, opts?: object): node is TSExternalModuleReference; -export function isTSFunctionType(node: object, opts?: object): node is TSFunctionType; -export function isTSImportEqualsDeclaration(node: object, opts?: object): node is TSImportEqualsDeclaration; -export function isTSIndexSignature(node: object, opts?: object): node is TSIndexSignature; -export function isTSIndexedAccessType(node: object, opts?: object): node is TSIndexedAccessType; -export function isTSInterfaceBody(node: object, opts?: object): node is TSInterfaceBody; -export function isTSInterfaceDeclaration(node: object, opts?: object): node is TSInterfaceDeclaration; -export function isTSIntersectionType(node: object, opts?: object): node is TSIntersectionType; -export function isTSLiteralType(node: object, opts?: object): node is TSLiteralType; -export function isTSMappedType(node: object, opts?: object): node is TSMappedType; -export function isTSMethodSignature(node: object, opts?: object): node is TSMethodSignature; -export function isTSModuleBlock(node: object, opts?: object): node is TSModuleBlock; -export function isTSModuleDeclaration(node: object, opts?: object): node is TSModuleDeclaration; -export function isTSNamespaceExportDeclaration(node: object, opts?: object): node is TSNamespaceExportDeclaration; -export function isTSNeverKeyword(node: object, opts?: object): node is TSNeverKeyword; -export function isTSNonNullExpression(node: object, opts?: object): node is TSNonNullExpression; -export function isTSNullKeyword(node: object, opts?: object): node is TSNullKeyword; -export function isTSNumberKeyword(node: object, opts?: object): node is TSNumberKeyword; -export function isTSObjectKeyword(node: object, opts?: object): node is TSObjectKeyword; -export function isTSParameterProperty(node: object, opts?: object): node is TSParameterProperty; -export function isTSParenthesizedType(node: object, opts?: object): node is TSParenthesizedType; -export function isTSPropertySignature(node: object, opts?: object): node is TSPropertySignature; -export function isTSQualifiedName(node: object, opts?: object): node is TSQualifiedName; -export function isTSStringKeyword(node: object, opts?: object): node is TSStringKeyword; -export function isTSSymbolKeyword(node: object, opts?: object): node is TSSymbolKeyword; -export function isTSThisType(node: object, opts?: object): node is TSThisType; -export function isTSTupleType(node: object, opts?: object): node is TSTupleType; -export function isTSTypeAliasDeclaration(node: object, opts?: object): node is TSTypeAliasDeclaration; -export function isTSTypeAnnotation(node: object, opts?: object): node is TSTypeAnnotation; -export function isTSTypeAssertion(node: object, opts?: object): node is TSTypeAssertion; -export function isTSTypeLiteral(node: object, opts?: object): node is TSTypeLiteral; -export function isTSTypeOperator(node: object, opts?: object): node is TSTypeOperator; -export function isTSTypeParameter(node: object, opts?: object): node is TSTypeParameter; -export function isTSTypeParameterDeclaration(node: object, opts?: object): node is TSTypeParameterDeclaration; -export function isTSTypeParameterInstantiation(node: object, opts?: object): node is TSTypeParameterInstantiation; -export function isTSTypePredicate(node: object, opts?: object): node is TSTypePredicate; -export function isTSTypeQuery(node: object, opts?: object): node is TSTypeQuery; -export function isTSTypeReference(node: object, opts?: object): node is TSTypeReference; -export function isTSUndefinedKeyword(node: object, opts?: object): node is TSUndefinedKeyword; -export function isTSUnionType(node: object, opts?: object): node is TSUnionType; -export function isTSVoidKeyword(node: object, opts?: object): node is TSVoidKeyword; +export function isTSAnyKeyword(node: object | null | undefined, opts?: object): node is TSAnyKeyword; +export function isTSArrayType(node: object | null | undefined, opts?: object): node is TSArrayType; +export function isTSAsExpression(node: object | null | undefined, opts?: object): node is TSAsExpression; +export function isTSBooleanKeyword(node: object | null | undefined, opts?: object): node is TSBooleanKeyword; +export function isTSCallSignatureDeclaration(node: object | null | undefined, opts?: object): node is TSCallSignatureDeclaration; +export function isTSConstructSignatureDeclaration(node: object | null | undefined, opts?: object): node is TSTypeElement; +export function isTSConstructorType(node: object | null | undefined, opts?: object): node is TSConstructorType; +export function isTSDeclareFunction(node: object | null | undefined, opts?: object): node is TSDeclareFunction; +export function isTSDeclareMethod(node: object | null | undefined, opts?: object): node is TSDeclareMethod; +export function isTSEnumDeclaration(node: object | null | undefined, opts?: object): node is TSEnumDeclaration; +export function isTSEnumMember(node: object | null | undefined, opts?: object): node is TSEnumMember; +export function isTSExportAssignment(node: object | null | undefined, opts?: object): node is TSExportAssignment; +export function isTSExpressionWithTypeArguments(node: object | null | undefined, opts?: object): node is TSExpressionWithTypeArguments; +export function isTSExternalModuleReference(node: object | null | undefined, opts?: object): node is TSExternalModuleReference; +export function isTSFunctionType(node: object | null | undefined, opts?: object): node is TSFunctionType; +export function isTSImportEqualsDeclaration(node: object | null | undefined, opts?: object): node is TSImportEqualsDeclaration; +export function isTSIndexSignature(node: object | null | undefined, opts?: object): node is TSIndexSignature; +export function isTSIndexedAccessType(node: object | null | undefined, opts?: object): node is TSIndexedAccessType; +export function isTSInterfaceBody(node: object | null | undefined, opts?: object): node is TSInterfaceBody; +export function isTSInterfaceDeclaration(node: object | null | undefined, opts?: object): node is TSInterfaceDeclaration; +export function isTSIntersectionType(node: object | null | undefined, opts?: object): node is TSIntersectionType; +export function isTSLiteralType(node: object | null | undefined, opts?: object): node is TSLiteralType; +export function isTSMappedType(node: object | null | undefined, opts?: object): node is TSMappedType; +export function isTSMethodSignature(node: object | null | undefined, opts?: object): node is TSMethodSignature; +export function isTSModuleBlock(node: object | null | undefined, opts?: object): node is TSModuleBlock; +export function isTSModuleDeclaration(node: object | null | undefined, opts?: object): node is TSModuleDeclaration; +export function isTSNamespaceExportDeclaration(node: object | null | undefined, opts?: object): node is TSNamespaceExportDeclaration; +export function isTSNeverKeyword(node: object | null | undefined, opts?: object): node is TSNeverKeyword; +export function isTSNonNullExpression(node: object | null | undefined, opts?: object): node is TSNonNullExpression; +export function isTSNullKeyword(node: object | null | undefined, opts?: object): node is TSNullKeyword; +export function isTSNumberKeyword(node: object | null | undefined, opts?: object): node is TSNumberKeyword; +export function isTSObjectKeyword(node: object | null | undefined, opts?: object): node is TSObjectKeyword; +export function isTSParameterProperty(node: object | null | undefined, opts?: object): node is TSParameterProperty; +export function isTSParenthesizedType(node: object | null | undefined, opts?: object): node is TSParenthesizedType; +export function isTSPropertySignature(node: object | null | undefined, opts?: object): node is TSPropertySignature; +export function isTSQualifiedName(node: object | null | undefined, opts?: object): node is TSQualifiedName; +export function isTSStringKeyword(node: object | null | undefined, opts?: object): node is TSStringKeyword; +export function isTSSymbolKeyword(node: object | null | undefined, opts?: object): node is TSSymbolKeyword; +export function isTSThisType(node: object | null | undefined, opts?: object): node is TSThisType; +export function isTSTupleType(node: object | null | undefined, opts?: object): node is TSTupleType; +export function isTSTypeAliasDeclaration(node: object | null | undefined, opts?: object): node is TSTypeAliasDeclaration; +export function isTSTypeAnnotation(node: object | null | undefined, opts?: object): node is TSTypeAnnotation; +export function isTSTypeAssertion(node: object | null | undefined, opts?: object): node is TSTypeAssertion; +export function isTSTypeLiteral(node: object | null | undefined, opts?: object): node is TSTypeLiteral; +export function isTSTypeOperator(node: object | null | undefined, opts?: object): node is TSTypeOperator; +export function isTSTypeParameter(node: object | null | undefined, opts?: object): node is TSTypeParameter; +export function isTSTypeParameterDeclaration(node: object | null | undefined, opts?: object): node is TSTypeParameterDeclaration; +export function isTSTypeParameterInstantiation(node: object | null | undefined, opts?: object): node is TSTypeParameterInstantiation; +export function isTSTypePredicate(node: object | null | undefined, opts?: object): node is TSTypePredicate; +export function isTSTypeQuery(node: object | null | undefined, opts?: object): node is TSTypeQuery; +export function isTSTypeReference(node: object | null | undefined, opts?: object): node is TSTypeReference; +export function isTSUndefinedKeyword(node: object | null | undefined, opts?: object): node is TSUndefinedKeyword; +export function isTSUnionType(node: object | null | undefined, opts?: object): node is TSUnionType; +export function isTSVoidKeyword(node: object | null | undefined, opts?: object): node is TSVoidKeyword; // React specific export interface ReactHelpers { @@ -1762,231 +1762,231 @@ export interface ReactHelpers { } export const react: ReactHelpers; -export function assertArrayExpression(node: object, opts?: object): void; -export function assertAssignmentExpression(node: object, opts?: object): void; -export function assertBinaryExpression(node: object, opts?: object): void; -export function assertDirective(node: object, opts?: object): void; -export function assertDirectiveLiteral(node: object, opts?: object): void; -export function assertBlockStatement(node: object, opts?: object): void; -export function assertBreakStatement(node: object, opts?: object): void; -export function assertCallExpression(node: object, opts?: object): void; -export function assertCatchClause(node: object, opts?: object): void; -export function assertConditionalExpression(node: object, opts?: object): void; -export function assertContinueStatement(node: object, opts?: object): void; -export function assertDebuggerStatement(node: object, opts?: object): void; -export function assertDoWhileStatement(node: object, opts?: object): void; -export function assertEmptyStatement(node: object, opts?: object): void; -export function assertExpressionStatement(node: object, opts?: object): void; -export function assertFile(node: object, opts?: object): void; -export function assertForInStatement(node: object, opts?: object): void; -export function assertForStatement(node: object, opts?: object): void; -export function assertFunctionDeclaration(node: object, opts?: object): void; -export function assertFunctionExpression(node: object, opts?: object): void; -export function assertIdentifier(node: object, opts?: object): void; -export function assertIfStatement(node: object, opts?: object): void; -export function assertLabeledStatement(node: object, opts?: object): void; -export function assertStringLiteral(node: object, opts?: object): void; -export function assertNumericLiteral(node: object, opts?: object): void; -export function assertNullLiteral(node: object, opts?: object): void; -export function assertBooleanLiteral(node: object, opts?: object): void; -export function assertRegExpLiteral(node: object, opts?: object): void; -export function assertLogicalExpression(node: object, opts?: object): void; -export function assertMemberExpression(node: object, opts?: object): void; -export function assertNewExpression(node: object, opts?: object): void; -export function assertProgram(node: object, opts?: object): void; -export function assertObjectExpression(node: object, opts?: object): void; -export function assertObjectMethod(node: object, opts?: object): void; -export function assertObjectProperty(node: object, opts?: object): void; -export function assertRestElement(node: object, opts?: object): void; -export function assertReturnStatement(node: object, opts?: object): void; -export function assertSequenceExpression(node: object, opts?: object): void; -export function assertSwitchCase(node: object, opts?: object): void; -export function assertSwitchStatement(node: object, opts?: object): void; -export function assertThisExpression(node: object, opts?: object): void; -export function assertThrowStatement(node: object, opts?: object): void; -export function assertTryStatement(node: object, opts?: object): void; -export function assertUnaryExpression(node: object, opts?: object): void; -export function assertUpdateExpression(node: object, opts?: object): void; -export function assertVariableDeclaration(node: object, opts?: object): void; -export function assertVariableDeclarator(node: object, opts?: object): void; -export function assertWhileStatement(node: object, opts?: object): void; -export function assertWithStatement(node: object, opts?: object): void; -export function assertAssignmentPattern(node: object, opts?: object): void; -export function assertArrayPattern(node: object, opts?: object): void; -export function assertArrowFunctionExpression(node: object, opts?: object): void; -export function assertClassBody(node: object, opts?: object): void; -export function assertClassDeclaration(node: object, opts?: object): void; -export function assertClassExpression(node: object, opts?: object): void; -export function assertExportAllDeclaration(node: object, opts?: object): void; -export function assertExportDefaultDeclaration(node: object, opts?: object): void; -export function assertExportNamedDeclaration(node: object, opts?: object): void; -export function assertExportSpecifier(node: object, opts?: object): void; -export function assertForOfStatement(node: object, opts?: object): void; -export function assertImportDeclaration(node: object, opts?: object): void; -export function assertImportDefaultSpecifier(node: object, opts?: object): void; -export function assertImportNamespaceSpecifier(node: object, opts?: object): void; -export function assertImportSpecifier(node: object, opts?: object): void; -export function assertMetaProperty(node: object, opts?: object): void; -export function assertClassMethod(node: object, opts?: object): void; -export function assertObjectPattern(node: object, opts?: object): void; -export function assertSpreadElement(node: object, opts?: object): void; -export function assertSuper(node: object, opts?: object): void; -export function assertTaggedTemplateExpression(node: object, opts?: object): void; -export function assertTemplateElement(node: object, opts?: object): void; -export function assertTemplateLiteral(node: object, opts?: object): void; -export function assertYieldExpression(node: object, opts?: object): void; -export function assertAnyTypeAnnotation(node: object, opts?: object): void; -export function assertArrayTypeAnnotation(node: object, opts?: object): void; -export function assertBooleanTypeAnnotation(node: object, opts?: object): void; -export function assertBooleanLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertNullLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertClassImplements(node: object, opts?: object): void; -export function assertClassProperty(node: object, opts?: object): void; -export function assertDeclareClass(node: object, opts?: object): void; -export function assertDeclareFunction(node: object, opts?: object): void; -export function assertDeclareInterface(node: object, opts?: object): void; -export function assertDeclareModule(node: object, opts?: object): void; -export function assertDeclareTypeAlias(node: object, opts?: object): void; -export function assertDeclareVariable(node: object, opts?: object): void; -export function assertExistentialTypeParam(node: object, opts?: object): void; -export function assertFunctionTypeAnnotation(node: object, opts?: object): void; -export function assertFunctionTypeParam(node: object, opts?: object): void; -export function assertGenericTypeAnnotation(node: object, opts?: object): void; -export function assertInterfaceExtends(node: object, opts?: object): void; -export function assertInterfaceDeclaration(node: object, opts?: object): void; -export function assertIntersectionTypeAnnotation(node: object, opts?: object): void; -export function assertMixedTypeAnnotation(node: object, opts?: object): void; -export function assertNullableTypeAnnotation(node: object, opts?: object): void; -export function assertNumericLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertNumberTypeAnnotation(node: object, opts?: object): void; -export function assertStringLiteralTypeAnnotation(node: object, opts?: object): void; -export function assertStringTypeAnnotation(node: object, opts?: object): void; -export function assertThisTypeAnnotation(node: object, opts?: object): void; -export function assertTupleTypeAnnotation(node: object, opts?: object): void; -export function assertTypeofTypeAnnotation(node: object, opts?: object): void; -export function assertTypeAlias(node: object, opts?: object): void; -export function assertTypeAnnotation(node: object, opts?: object): void; -export function assertTypeCastExpression(node: object, opts?: object): void; -export function assertTypeParameter(node: object, opts?: object): void; -export function assertTypeParameterDeclaration(node: object, opts?: object): void; -export function assertTypeParameterInstantiation(node: object, opts?: object): void; -export function assertObjectTypeAnnotation(node: object, opts?: object): void; -export function assertObjectTypeCallProperty(node: object, opts?: object): void; -export function assertObjectTypeIndexer(node: object, opts?: object): void; -export function assertObjectTypeProperty(node: object, opts?: object): void; -export function assertQualifiedTypeIdentifier(node: object, opts?: object): void; -export function assertUnionTypeAnnotation(node: object, opts?: object): void; -export function assertVoidTypeAnnotation(node: object, opts?: object): void; -export function assertJSXAttribute(node: object, opts?: object): void; -export function assertJSXClosingElement(node: object, opts?: object): void; -export function assertJSXElement(node: object, opts?: object): void; -export function assertJSXEmptyExpression(node: object, opts?: object): void; -export function assertJSXExpressionContainer(node: object, opts?: object): void; -export function assertJSXIdentifier(node: object, opts?: object): void; -export function assertJSXMemberExpression(node: object, opts?: object): void; -export function assertJSXNamespacedName(node: object, opts?: object): void; -export function assertJSXOpeningElement(node: object, opts?: object): void; -export function assertJSXSpreadAttribute(node: object, opts?: object): void; -export function assertJSXText(node: object, opts?: object): void; -export function assertNoop(node: object, opts?: object): void; -export function assertParenthesizedExpression(node: object, opts?: object): void; -export function assertAwaitExpression(node: object, opts?: object): void; -export function assertBindExpression(node: object, opts?: object): void; -export function assertDecorator(node: object, opts?: object): void; -export function assertDoExpression(node: object, opts?: object): void; -export function assertExportDefaultSpecifier(node: object, opts?: object): void; -export function assertExportNamespaceSpecifier(node: object, opts?: object): void; -export function assertRestProperty(node: object, opts?: object): void; -export function assertSpreadProperty(node: object, opts?: object): void; -export function assertExpression(node: object, opts?: object): void; -export function assertBinary(node: object, opts?: object): void; -export function assertScopable(node: object, opts?: object): void; -export function assertBlockParent(node: object, opts?: object): void; -export function assertBlock(node: object, opts?: object): void; -export function assertStatement(node: object, opts?: object): void; -export function assertTerminatorless(node: object, opts?: object): void; -export function assertCompletionStatement(node: object, opts?: object): void; -export function assertConditional(node: object, opts?: object): void; -export function assertLoop(node: object, opts?: object): void; -export function assertWhile(node: object, opts?: object): void; -export function assertExpressionWrapper(node: object, opts?: object): void; -export function assertFor(node: object, opts?: object): void; -export function assertForXStatement(node: object, opts?: object): void; -export function assertFunction(node: object, opts?: object): void; -export function assertFunctionParent(node: object, opts?: object): void; -export function assertPureish(node: object, opts?: object): void; -export function assertDeclaration(node: object, opts?: object): void; -export function assertLVal(node: object, opts?: object): void; -export function assertLiteral(node: object, opts?: object): void; -export function assertImmutable(node: object, opts?: object): void; -export function assertUserWhitespacable(node: object, opts?: object): void; -export function assertMethod(node: object, opts?: object): void; -export function assertObjectMember(node: object, opts?: object): void; -export function assertProperty(node: object, opts?: object): void; -export function assertUnaryLike(node: object, opts?: object): void; -export function assertPattern(node: object, opts?: object): void; -export function assertClass(node: object, opts?: object): void; -export function assertModuleDeclaration(node: object, opts?: object): void; -export function assertExportDeclaration(node: object, opts?: object): void; -export function assertModuleSpecifier(node: object, opts?: object): void; -export function assertFlow(node: object, opts?: object): void; -export function assertFlowBaseAnnotation(node: object, opts?: object): void; -export function assertFlowDeclaration(node: object, opts?: object): void; -export function assertJSX(node: object, opts?: object): void; -export function assertNumberLiteral(node: object, opts?: object): void; -export function assertRegexLiteral(node: object, opts?: object): void; +export function assertArrayExpression(node: object | null | undefined, opts?: object): void; +export function assertAssignmentExpression(node: object | null | undefined, opts?: object): void; +export function assertBinaryExpression(node: object | null | undefined, opts?: object): void; +export function assertDirective(node: object | null | undefined, opts?: object): void; +export function assertDirectiveLiteral(node: object | null | undefined, opts?: object): void; +export function assertBlockStatement(node: object | null | undefined, opts?: object): void; +export function assertBreakStatement(node: object | null | undefined, opts?: object): void; +export function assertCallExpression(node: object | null | undefined, opts?: object): void; +export function assertCatchClause(node: object | null | undefined, opts?: object): void; +export function assertConditionalExpression(node: object | null | undefined, opts?: object): void; +export function assertContinueStatement(node: object | null | undefined, opts?: object): void; +export function assertDebuggerStatement(node: object | null | undefined, opts?: object): void; +export function assertDoWhileStatement(node: object | null | undefined, opts?: object): void; +export function assertEmptyStatement(node: object | null | undefined, opts?: object): void; +export function assertExpressionStatement(node: object | null | undefined, opts?: object): void; +export function assertFile(node: object | null | undefined, opts?: object): void; +export function assertForInStatement(node: object | null | undefined, opts?: object): void; +export function assertForStatement(node: object | null | undefined, opts?: object): void; +export function assertFunctionDeclaration(node: object | null | undefined, opts?: object): void; +export function assertFunctionExpression(node: object | null | undefined, opts?: object): void; +export function assertIdentifier(node: object | null | undefined, opts?: object): void; +export function assertIfStatement(node: object | null | undefined, opts?: object): void; +export function assertLabeledStatement(node: object | null | undefined, opts?: object): void; +export function assertStringLiteral(node: object | null | undefined, opts?: object): void; +export function assertNumericLiteral(node: object | null | undefined, opts?: object): void; +export function assertNullLiteral(node: object | null | undefined, opts?: object): void; +export function assertBooleanLiteral(node: object | null | undefined, opts?: object): void; +export function assertRegExpLiteral(node: object | null | undefined, opts?: object): void; +export function assertLogicalExpression(node: object | null | undefined, opts?: object): void; +export function assertMemberExpression(node: object | null | undefined, opts?: object): void; +export function assertNewExpression(node: object | null | undefined, opts?: object): void; +export function assertProgram(node: object | null | undefined, opts?: object): void; +export function assertObjectExpression(node: object | null | undefined, opts?: object): void; +export function assertObjectMethod(node: object | null | undefined, opts?: object): void; +export function assertObjectProperty(node: object | null | undefined, opts?: object): void; +export function assertRestElement(node: object | null | undefined, opts?: object): void; +export function assertReturnStatement(node: object | null | undefined, opts?: object): void; +export function assertSequenceExpression(node: object | null | undefined, opts?: object): void; +export function assertSwitchCase(node: object | null | undefined, opts?: object): void; +export function assertSwitchStatement(node: object | null | undefined, opts?: object): void; +export function assertThisExpression(node: object | null | undefined, opts?: object): void; +export function assertThrowStatement(node: object | null | undefined, opts?: object): void; +export function assertTryStatement(node: object | null | undefined, opts?: object): void; +export function assertUnaryExpression(node: object | null | undefined, opts?: object): void; +export function assertUpdateExpression(node: object | null | undefined, opts?: object): void; +export function assertVariableDeclaration(node: object | null | undefined, opts?: object): void; +export function assertVariableDeclarator(node: object | null | undefined, opts?: object): void; +export function assertWhileStatement(node: object | null | undefined, opts?: object): void; +export function assertWithStatement(node: object | null | undefined, opts?: object): void; +export function assertAssignmentPattern(node: object | null | undefined, opts?: object): void; +export function assertArrayPattern(node: object | null | undefined, opts?: object): void; +export function assertArrowFunctionExpression(node: object | null | undefined, opts?: object): void; +export function assertClassBody(node: object | null | undefined, opts?: object): void; +export function assertClassDeclaration(node: object | null | undefined, opts?: object): void; +export function assertClassExpression(node: object | null | undefined, opts?: object): void; +export function assertExportAllDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportDefaultDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportNamedDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportSpecifier(node: object | null | undefined, opts?: object): void; +export function assertForOfStatement(node: object | null | undefined, opts?: object): void; +export function assertImportDeclaration(node: object | null | undefined, opts?: object): void; +export function assertImportDefaultSpecifier(node: object | null | undefined, opts?: object): void; +export function assertImportNamespaceSpecifier(node: object | null | undefined, opts?: object): void; +export function assertImportSpecifier(node: object | null | undefined, opts?: object): void; +export function assertMetaProperty(node: object | null | undefined, opts?: object): void; +export function assertClassMethod(node: object | null | undefined, opts?: object): void; +export function assertObjectPattern(node: object | null | undefined, opts?: object): void; +export function assertSpreadElement(node: object | null | undefined, opts?: object): void; +export function assertSuper(node: object | null | undefined, opts?: object): void; +export function assertTaggedTemplateExpression(node: object | null | undefined, opts?: object): void; +export function assertTemplateElement(node: object | null | undefined, opts?: object): void; +export function assertTemplateLiteral(node: object | null | undefined, opts?: object): void; +export function assertYieldExpression(node: object | null | undefined, opts?: object): void; +export function assertAnyTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertArrayTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertBooleanTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertBooleanLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNullLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertClassImplements(node: object | null | undefined, opts?: object): void; +export function assertClassProperty(node: object | null | undefined, opts?: object): void; +export function assertDeclareClass(node: object | null | undefined, opts?: object): void; +export function assertDeclareFunction(node: object | null | undefined, opts?: object): void; +export function assertDeclareInterface(node: object | null | undefined, opts?: object): void; +export function assertDeclareModule(node: object | null | undefined, opts?: object): void; +export function assertDeclareTypeAlias(node: object | null | undefined, opts?: object): void; +export function assertDeclareVariable(node: object | null | undefined, opts?: object): void; +export function assertExistentialTypeParam(node: object | null | undefined, opts?: object): void; +export function assertFunctionTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertFunctionTypeParam(node: object | null | undefined, opts?: object): void; +export function assertGenericTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertInterfaceExtends(node: object | null | undefined, opts?: object): void; +export function assertInterfaceDeclaration(node: object | null | undefined, opts?: object): void; +export function assertIntersectionTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertMixedTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNullableTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNumericLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertNumberTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertStringLiteralTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertStringTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertThisTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTupleTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTypeofTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTypeAlias(node: object | null | undefined, opts?: object): void; +export function assertTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTypeCastExpression(node: object | null | undefined, opts?: object): void; +export function assertTypeParameter(node: object | null | undefined, opts?: object): void; +export function assertTypeParameterDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTypeParameterInstantiation(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeCallProperty(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeIndexer(node: object | null | undefined, opts?: object): void; +export function assertObjectTypeProperty(node: object | null | undefined, opts?: object): void; +export function assertQualifiedTypeIdentifier(node: object | null | undefined, opts?: object): void; +export function assertUnionTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertVoidTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertJSXAttribute(node: object | null | undefined, opts?: object): void; +export function assertJSXClosingElement(node: object | null | undefined, opts?: object): void; +export function assertJSXElement(node: object | null | undefined, opts?: object): void; +export function assertJSXEmptyExpression(node: object | null | undefined, opts?: object): void; +export function assertJSXExpressionContainer(node: object | null | undefined, opts?: object): void; +export function assertJSXIdentifier(node: object | null | undefined, opts?: object): void; +export function assertJSXMemberExpression(node: object | null | undefined, opts?: object): void; +export function assertJSXNamespacedName(node: object | null | undefined, opts?: object): void; +export function assertJSXOpeningElement(node: object | null | undefined, opts?: object): void; +export function assertJSXSpreadAttribute(node: object | null | undefined, opts?: object): void; +export function assertJSXText(node: object | null | undefined, opts?: object): void; +export function assertNoop(node: object | null | undefined, opts?: object): void; +export function assertParenthesizedExpression(node: object | null | undefined, opts?: object): void; +export function assertAwaitExpression(node: object | null | undefined, opts?: object): void; +export function assertBindExpression(node: object | null | undefined, opts?: object): void; +export function assertDecorator(node: object | null | undefined, opts?: object): void; +export function assertDoExpression(node: object | null | undefined, opts?: object): void; +export function assertExportDefaultSpecifier(node: object | null | undefined, opts?: object): void; +export function assertExportNamespaceSpecifier(node: object | null | undefined, opts?: object): void; +export function assertRestProperty(node: object | null | undefined, opts?: object): void; +export function assertSpreadProperty(node: object | null | undefined, opts?: object): void; +export function assertExpression(node: object | null | undefined, opts?: object): void; +export function assertBinary(node: object | null | undefined, opts?: object): void; +export function assertScopable(node: object | null | undefined, opts?: object): void; +export function assertBlockParent(node: object | null | undefined, opts?: object): void; +export function assertBlock(node: object | null | undefined, opts?: object): void; +export function assertStatement(node: object | null | undefined, opts?: object): void; +export function assertTerminatorless(node: object | null | undefined, opts?: object): void; +export function assertCompletionStatement(node: object | null | undefined, opts?: object): void; +export function assertConditional(node: object | null | undefined, opts?: object): void; +export function assertLoop(node: object | null | undefined, opts?: object): void; +export function assertWhile(node: object | null | undefined, opts?: object): void; +export function assertExpressionWrapper(node: object | null | undefined, opts?: object): void; +export function assertFor(node: object | null | undefined, opts?: object): void; +export function assertForXStatement(node: object | null | undefined, opts?: object): void; +export function assertFunction(node: object | null | undefined, opts?: object): void; +export function assertFunctionParent(node: object | null | undefined, opts?: object): void; +export function assertPureish(node: object | null | undefined, opts?: object): void; +export function assertDeclaration(node: object | null | undefined, opts?: object): void; +export function assertLVal(node: object | null | undefined, opts?: object): void; +export function assertLiteral(node: object | null | undefined, opts?: object): void; +export function assertImmutable(node: object | null | undefined, opts?: object): void; +export function assertUserWhitespacable(node: object | null | undefined, opts?: object): void; +export function assertMethod(node: object | null | undefined, opts?: object): void; +export function assertObjectMember(node: object | null | undefined, opts?: object): void; +export function assertProperty(node: object | null | undefined, opts?: object): void; +export function assertUnaryLike(node: object | null | undefined, opts?: object): void; +export function assertPattern(node: object | null | undefined, opts?: object): void; +export function assertClass(node: object | null | undefined, opts?: object): void; +export function assertModuleDeclaration(node: object | null | undefined, opts?: object): void; +export function assertExportDeclaration(node: object | null | undefined, opts?: object): void; +export function assertModuleSpecifier(node: object | null | undefined, opts?: object): void; +export function assertFlow(node: object | null | undefined, opts?: object): void; +export function assertFlowBaseAnnotation(node: object | null | undefined, opts?: object): void; +export function assertFlowDeclaration(node: object | null | undefined, opts?: object): void; +export function assertJSX(node: object | null | undefined, opts?: object): void; +export function assertNumberLiteral(node: object | null | undefined, opts?: object): void; +export function assertRegexLiteral(node: object | null | undefined, opts?: object): void; -export function assertTSAnyKeyword(node: object, opts?: object): void; -export function assertTSArrayType(node: object, opts?: object): void; -export function assertTSAsExpression(node: object, opts?: object): void; -export function assertTSBooleanKeyword(node: object, opts?: object): void; -export function assertTSCallSignatureDeclaration(node: object, opts?: object): void; -export function assertTSConstructSignatureDeclaration(node: object, opts?: object): void; -export function assertTSConstructorType(node: object, opts?: object): void; -export function assertTSDeclareFunction(node: object, opts?: object): void; -export function assertTSDeclareMethod(node: object, opts?: object): void; -export function assertTSEnumDeclaration(node: object, opts?: object): void; -export function assertTSEnumMember(node: object, opts?: object): void; -export function assertTSExportAssignment(node: object, opts?: object): void; -export function assertTSExpressionWithTypeArguments(node: object, opts?: object): void; -export function assertTSExternalModuleReference(node: object, opts?: object): void; -export function assertTSFunctionType(node: object, opts?: object): void; -export function assertTSImportEqualsDeclaration(node: object, opts?: object): void; -export function assertTSIndexSignature(node: object, opts?: object): void; -export function assertTSIndexedAccessType(node: object, opts?: object): void; -export function assertTSInterfaceBody(node: object, opts?: object): void; -export function assertTSInterfaceDeclaration(node: object, opts?: object): void; -export function assertTSIntersectionType(node: object, opts?: object): void; -export function assertTSLiteralType(node: object, opts?: object): void; -export function assertTSMappedType(node: object, opts?: object): void; -export function assertTSMethodSignature(node: object, opts?: object): void; -export function assertTSModuleBlock(node: object, opts?: object): void; -export function assertTSModuleDeclaration(node: object, opts?: object): void; -export function assertTSNamespaceExportDeclaration(node: object, opts?: object): void; -export function assertTSNeverKeyword(node: object, opts?: object): void; -export function assertTSNonNullExpression(node: object, opts?: object): void; -export function assertTSNullKeyword(node: object, opts?: object): void; -export function assertTSNumberKeyword(node: object, opts?: object): void; -export function assertTSObjectKeyword(node: object, opts?: object): void; -export function assertTSParameterProperty(node: object, opts?: object): void; -export function assertTSParenthesizedType(node: object, opts?: object): void; -export function assertTSPropertySignature(node: object, opts?: object): void; -export function assertTSQualifiedName(node: object, opts?: object): void; -export function assertTSStringKeyword(node: object, opts?: object): void; -export function assertTSSymbolKeyword(node: object, opts?: object): void; -export function assertTSThisType(node: object, opts?: object): void; -export function assertTSTupleType(node: object, opts?: object): void; -export function assertTSTypeAliasDeclaration(node: object, opts?: object): void; -export function assertTSTypeAnnotation(node: object, opts?: object): void; -export function assertTSTypeAssertion(node: object, opts?: object): void; -export function assertTSTypeLiteral(node: object, opts?: object): void; -export function assertTSTypeOperator(node: object, opts?: object): void; -export function assertTSTypeParameter(node: object, opts?: object): void; -export function assertTSTypeParameterDeclaration(node: object, opts?: object): void; -export function assertTSTypeParameterInstantiation(node: object, opts?: object): void; -export function assertTSTypePredicate(node: object, opts?: object): void; -export function assertTSTypeQuery(node: object, opts?: object): void; -export function assertTSTypeReference(node: object, opts?: object): void; -export function assertTSUndefinedKeyword(node: object, opts?: object): void; -export function assertTSUnionType(node: object, opts?: object): void; -export function assertTSVoidKeyword(node: object, opts?: object): void; +export function assertTSAnyKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSArrayType(node: object | null | undefined, opts?: object): void; +export function assertTSAsExpression(node: object | null | undefined, opts?: object): void; +export function assertTSBooleanKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSCallSignatureDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSConstructSignatureDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSConstructorType(node: object | null | undefined, opts?: object): void; +export function assertTSDeclareFunction(node: object | null | undefined, opts?: object): void; +export function assertTSDeclareMethod(node: object | null | undefined, opts?: object): void; +export function assertTSEnumDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSEnumMember(node: object | null | undefined, opts?: object): void; +export function assertTSExportAssignment(node: object | null | undefined, opts?: object): void; +export function assertTSExpressionWithTypeArguments(node: object | null | undefined, opts?: object): void; +export function assertTSExternalModuleReference(node: object | null | undefined, opts?: object): void; +export function assertTSFunctionType(node: object | null | undefined, opts?: object): void; +export function assertTSImportEqualsDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSIndexSignature(node: object | null | undefined, opts?: object): void; +export function assertTSIndexedAccessType(node: object | null | undefined, opts?: object): void; +export function assertTSInterfaceBody(node: object | null | undefined, opts?: object): void; +export function assertTSInterfaceDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSIntersectionType(node: object | null | undefined, opts?: object): void; +export function assertTSLiteralType(node: object | null | undefined, opts?: object): void; +export function assertTSMappedType(node: object | null | undefined, opts?: object): void; +export function assertTSMethodSignature(node: object | null | undefined, opts?: object): void; +export function assertTSModuleBlock(node: object | null | undefined, opts?: object): void; +export function assertTSModuleDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSNamespaceExportDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSNeverKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSNonNullExpression(node: object | null | undefined, opts?: object): void; +export function assertTSNullKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSNumberKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSObjectKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSParameterProperty(node: object | null | undefined, opts?: object): void; +export function assertTSParenthesizedType(node: object | null | undefined, opts?: object): void; +export function assertTSPropertySignature(node: object | null | undefined, opts?: object): void; +export function assertTSQualifiedName(node: object | null | undefined, opts?: object): void; +export function assertTSStringKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSSymbolKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSThisType(node: object | null | undefined, opts?: object): void; +export function assertTSTupleType(node: object | null | undefined, opts?: object): void; +export function assertTSTypeAliasDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSTypeAnnotation(node: object | null | undefined, opts?: object): void; +export function assertTSTypeAssertion(node: object | null | undefined, opts?: object): void; +export function assertTSTypeLiteral(node: object | null | undefined, opts?: object): void; +export function assertTSTypeOperator(node: object | null | undefined, opts?: object): void; +export function assertTSTypeParameter(node: object | null | undefined, opts?: object): void; +export function assertTSTypeParameterDeclaration(node: object | null | undefined, opts?: object): void; +export function assertTSTypeParameterInstantiation(node: object | null | undefined, opts?: object): void; +export function assertTSTypePredicate(node: object | null | undefined, opts?: object): void; +export function assertTSTypeQuery(node: object | null | undefined, opts?: object): void; +export function assertTSTypeReference(node: object | null | undefined, opts?: object): void; +export function assertTSUndefinedKeyword(node: object | null | undefined, opts?: object): void; +export function assertTSUnionType(node: object | null | undefined, opts?: object): void; +export function assertTSVoidKeyword(node: object | null | undefined, opts?: object): void; diff --git a/types/babel-types/tsconfig.json b/types/babel-types/tsconfig.json index 92d7d6442e..f4a6179f99 100644 --- a/types/babel-types/tsconfig.json +++ b/types/babel-types/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/bluebird-global/index.d.ts b/types/bluebird-global/index.d.ts index da33188dd1..8924a941df 100644 --- a/types/bluebird-global/index.d.ts +++ b/types/bluebird-global/index.d.ts @@ -113,12 +113,15 @@ import Bluebird = require("bluebird"); declare global { + type IterateFunction = (item: T, index: number, arrayLength: number) => (R | PromiseLike); /* * Patch all instance method */ interface Promise { - all: Bluebird["all"]; - any: Bluebird["any"]; + all(this: Promise>): Bluebird; + all(): Bluebird; + any(this: Promise>): Bluebird; + any(): Bluebird; asCallback: Bluebird["asCallback"]; bind: Bluebird["bind"]; call: Bluebird["call"]; @@ -128,9 +131,9 @@ declare global { delay: Bluebird["delay"]; disposer: Bluebird["disposer"]; done: Bluebird["done"]; - each: Bluebird["each"]; + each(this: Promise>, iterator: IterateFunction): Bluebird; error: Bluebird["error"]; - filter: Bluebird["filter"]; + filter(this: Promise>, filterer: IterateFunction, options?: Bluebird.ConcurrencyOption): Bluebird; // finally: Bluebird["finally"]; // Provided by lib.es2018.promise.d.ts get: Bluebird["get"]; isCancelled: Bluebird["isCancelled"]; @@ -139,17 +142,18 @@ declare global { isRejected: Bluebird["isRejected"]; isResolved: Bluebird["isResolved"]; lastly: Bluebird["lastly"]; - map: Bluebird["map"]; - mapSeries: Bluebird["mapSeries"]; + map(this: Promise>, mapper: IterateFunction, options?: Bluebird.ConcurrencyOption): Bluebird; + mapSeries(this: Promise>, iterator: IterateFunction): Bluebird; nodeify: Bluebird["nodeify"]; props: Bluebird["props"]; - race: Bluebird["race"]; + race(this: Promise>): Bluebird; + race(): Bluebird; reason: Bluebird["reason"]; - reduce: Bluebird["reduce"]; + reduce(this: Promise>, reducer: (memo: U, item: Q, index: number, arrayLength: number) => (U | PromiseLike), initialValue?: U): Bluebird; reflect: Bluebird["reflect"]; return: Bluebird["return"]; - some: Bluebird["some"]; - spread: Bluebird["spread"]; + some(this: Promise>, count: number): Bluebird; + spread(this: Bluebird>, fulfilledHandler: (...values: Q[]) => (U | PromiseLike)): Bluebird; suppressUnhandledRejections: Bluebird["suppressUnhandledRejections"]; tap: Bluebird["tap"]; tapCatch: Bluebird["tapCatch"]; diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 24c2b79a32..13a11c2e3e 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -37,8 +37,6 @@ type Constructor = new (...args: any[]) => E; type CatchFilter = ((error: E) => boolean) | (object & E); -type IterableItem = R extends Iterable ? U : never; -type IterableOrNever = Extract>; type Resolvable = R | PromiseLike; type IterateFunction = (item: T, index: number, arrayLength: number) => Resolvable; @@ -352,7 +350,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * }); * */ - call(propertyName: U, ...args: any[]): Bluebird any ? ReturnType : never>; + call(this: Bluebird, propertyName: U, ...args: any[]): Bluebird any ? ReturnType : never>; /** * This is a convenience method for doing: @@ -562,12 +560,17 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. */ - spread(fulfilledHandler: (...values: Array>) => Resolvable): Bluebird; + spread(this: Bluebird>, fulfilledHandler: (...values: Q[]) => Resolvable): Bluebird; /** * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - all(): Bluebird>; + all(this: Bluebird>): Bluebird; + + /** + * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + all(): Bluebird; /** * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. @@ -578,42 +581,59 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - any(): Bluebird>; + any(this: Bluebird>): Bluebird; + + /** + * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + any(): Bluebird; /** + * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - some(count: number): Bluebird>; + some(this: Bluebird>, count: number): Bluebird; + + /** + * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + some(count: number): Bluebird; /** * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - race(): Bluebird>; + race(this: Bluebird>): Bluebird; + + /** + * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + race(): Bluebird; /** * Same as calling `Bluebird.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - map(mapper: IterateFunction, U>, options?: Bluebird.ConcurrencyOption): Bluebird ? U[] : never>; + map(this: Bluebird>, mapper: IterateFunction, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - reduce(reducer: (memo: U, item: IterableItem, index: number, arrayLength: number) => Resolvable, initialValue?: U): Bluebird ? U : never>; + reduce(this: Bluebird>, reducer: (memo: U, item: Q, index: number, arrayLength: number) => Resolvable, initialValue?: U): Bluebird; /** * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - filter(filterer: IterateFunction, boolean>, options?: Bluebird.ConcurrencyOption): Bluebird>; + filter(this: Bluebird>, filterer: IterateFunction, options?: Bluebird.ConcurrencyOption): Bluebird; /** * Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - each(iterator: IterateFunction, any>): Bluebird>; + each(this: Bluebird>, iterator: IterateFunction): Bluebird; /** * Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - mapSeries(iterator: IterateFunction, U>): Bluebird ? U[] : never>; + mapSeries(this: Bluebird>, iterator: IterateFunction): Bluebird; /** * Cancel this `promise`. Will not do anything if this promise is already settled or if the cancellation feature has not been enabled diff --git a/types/bootstrap-notify/bootstrap-notify-tests.ts b/types/bootstrap-notify/bootstrap-notify-tests.ts index 2977d39abf..4b288b2ca0 100644 --- a/types/bootstrap-notify/bootstrap-notify-tests.ts +++ b/types/bootstrap-notify/bootstrap-notify-tests.ts @@ -46,4 +46,21 @@ $.notify({ '' + '' + '' -}); \ No newline at end of file +}); + +const notifyResult = $.notify({ + message: 'Callbacks have the popup element as an argument', +},{ + onShow: function($ele) { + notifyResult.$ele === $ele; + }, + onShown: function($ele) { + notifyResult.$ele === $ele; + }, + onClose: function($ele) { + notifyResult.$ele === $ele; + }, + onClosed: function($ele) { + notifyResult.$ele === $ele; + }, +}); diff --git a/types/bootstrap-notify/index.d.ts b/types/bootstrap-notify/index.d.ts index 540f200d9c..75994ad365 100644 --- a/types/bootstrap-notify/index.d.ts +++ b/types/bootstrap-notify/index.d.ts @@ -48,16 +48,16 @@ interface NotifySettings { enter?: string; exit?: string; }; - onShow?: () => void; - onShown?: () => void; - onClose?: () => void; - onClosed?: () => void; + onShow?: ($ele: JQuery) => void; + onShown?: ($ele: JQuery) => void; + onClose?: ($ele: JQuery) => void; + onClosed?: ($ele: JQuery) => void; icon_type?: string; template?: string; } interface NotifyReturn { - $ele: JQueryStatic; + $ele: JQuery; close: () => void; update: (command: string, update: any) => void; } diff --git a/types/bootstrap/bootstrap-tests.ts b/types/bootstrap/bootstrap-tests.ts index 9344423cfb..01e5d5352f 100755 --- a/types/bootstrap/bootstrap-tests.ts +++ b/types/bootstrap/bootstrap-tests.ts @@ -196,6 +196,12 @@ $("#popover").popover({ offset: 10, fallbackPlacement: ["flip", "clockwise"], boundary: "scrollParent", + sanitize: false, + whiteList: { + h1: [], + img: ['src', 'alt', 'title', 'width', 'height'], + }, + sanitizeFn: (x: string) => x.replace("<", ""), }); $("#popover").popover({ @@ -207,6 +213,10 @@ $("#popover").popover({ }, }); +$("#popover").popover({ + sanitizeFn: null, +}); + // -------------------------------------------------------------------------------------- // Scrollspy // -------------------------------------------------------------------------------------- @@ -280,10 +290,23 @@ $("#tooltip").on("hide.bs.tooltip", () => {}); $("#tooltip").tooltip({ animation: false, -}); - -$("#tooltip").tooltip({ container: "#container", + delay: {show: 500, hide: 100}, + html: true, + placement: "auto", + selector: "[rel=\"tooltip\"]", + template: '', + title: "Hello world", + trigger: "hover focus", + offset: 10, + fallbackPlacement: ["flip", "clockwise"], + boundary: "scrollParent", + sanitize: false, + whiteList: { + h1: [], + img: ['src', 'alt', 'title', 'width', 'height'], + }, + sanitizeFn: (x: string) => x.replace("<", ""), }); $("#tooltip").tooltip({ @@ -298,18 +321,6 @@ $("#tooltip").tooltip({ delay: 250, }); -$("#tooltip").tooltip({ - delay: {show: 500, hide: 100}, -}); - -$("#tooltip").tooltip({ - html: true, -}); - -$("#tooltip").tooltip({ - placement: "auto", -}); - $("#tooltip").tooltip({ placement(this, tooltip, trigger) { console.log(this.tip === tooltip); @@ -327,22 +338,10 @@ $("#tooltip").tooltip({ }, }); -$("#tooltip").tooltip({ - selector: "[rel=\"tooltip\"]", -}); - $("#tooltip").tooltip({ selector: false, }); -$("#tooltip").tooltip({ - template: '', -}); - -$("#tooltip").tooltip({ - title: "Hello world", -}); - $("#tooltip").tooltip({ title: document.getElementById("title-element") as HTMLElement, }); @@ -353,14 +352,6 @@ $("#tooltip").tooltip({ }, }); -$("#tooltip").tooltip({ - trigger: "hover focus", -}); - -$("#tooltip").tooltip({ - offset: 10, -}); - $("#tooltip").tooltip({ offset: "10px", }); @@ -369,14 +360,10 @@ $("#tooltip").tooltip({ fallbackPlacement: "clockwise", }); -$("#tooltip").tooltip({ - fallbackPlacement: ["flip", "clockwise"], -}); - -$("#tooltip").tooltip({ - boundary: "scrollParent", -}); - $("#tooltip").tooltip({ boundary: aHtmlElement, }); + +$("#popover").popover({ + sanitizeFn: null, +}); diff --git a/types/bootstrap/index.d.ts b/types/bootstrap/index.d.ts index 2fb473fc29..6dc5f21a28 100755 --- a/types/bootstrap/index.d.ts +++ b/types/bootstrap/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Bootstrap 4.2 +// Type definitions for Bootstrap 4.3 // Project: https://github.com/twbs/bootstrap/, https://getbootstrap.com // Definitions by: denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -352,6 +352,25 @@ export interface TooltipOption { * @default "scrollParent" */ boundary?: Popper.Boundary | HTMLElement; + + /** + * Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized. + * + * @default true + */ + sanitize?: boolean; + + /** + * Object which contains allowed attributes and tags. + */ + whiteList?: {[key: string]: string[]}; + + /** + * Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. + * + * @default null + */ + sanitizeFn?: null | ((input: string) => string); } // -------------------------------------------------------------------------------------- diff --git a/types/bpmn-moddle/index.d.ts b/types/bpmn-moddle/index.d.ts index f4411e05fa..43a6431308 100644 --- a/types/bpmn-moddle/index.d.ts +++ b/types/bpmn-moddle/index.d.ts @@ -25,6 +25,7 @@ declare namespace BPMNModdle { interface TypeDerived { $type: ElementType; + $parent: TypeDerived; } interface BaseElement extends TypeDerived { /** diff --git a/types/browser-sync/index.d.ts b/types/browser-sync/index.d.ts index 72399f1618..58b85e09f3 100644 --- a/types/browser-sync/index.d.ts +++ b/types/browser-sync/index.d.ts @@ -7,7 +7,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -/// /// /// diff --git a/types/browser-sync/package.json b/types/browser-sync/package.json new file mode 100644 index 0000000000..a0e2ec3c5c --- /dev/null +++ b/types/browser-sync/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "chokidar": "^2.1.2" + } +} diff --git a/types/canvas-confetti/canvas-confetti-tests.ts b/types/canvas-confetti/canvas-confetti-tests.ts index d29e57fbdb..2415b91b85 100644 --- a/types/canvas-confetti/canvas-confetti-tests.ts +++ b/types/canvas-confetti/canvas-confetti-tests.ts @@ -43,3 +43,12 @@ confetti({ y: 0.6 } }); + +const canvas = document.createElement('canvas'); +const myConfetti = confetti.create(canvas); + +myConfetti(); + +myConfetti({ + particleCount: 150 +}); diff --git a/types/canvas-confetti/index.d.ts b/types/canvas-confetti/index.d.ts index 3dddc6d750..f9dd65ea12 100644 --- a/types/canvas-confetti/index.d.ts +++ b/types/canvas-confetti/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for canvas-confetti 0.0 +// Type definitions for canvas-confetti 0.1 // Project: https://github.com/catdad/canvas-confetti#readme // Definitions by: Martin Tracey // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -81,6 +81,14 @@ declare namespace confetti { */ y?: number; } + interface GlobalOptions { + resize: boolean; + } + + function create( + canvas: HTMLCanvasElement, + options?: GlobalOptions + ): (options?: Options) => Promise | null; } export = confetti; diff --git a/types/canvas-confetti/tsconfig.json b/types/canvas-confetti/tsconfig.json index 33c159b3e3..e83fb2ef8b 100644 --- a/types/canvas-confetti/tsconfig.json +++ b/types/canvas-confetti/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/cassandra-driver/index.d.ts b/types/cassandra-driver/index.d.ts index 86073ec888..21b6f9d8d1 100644 --- a/types/cassandra-driver/index.d.ts +++ b/types/cassandra-driver/index.d.ts @@ -87,7 +87,8 @@ export namespace policies { interface DecisionInfo { decision: number; - consistency: number; + consistency?: number; + useCurrentHost?: boolean; } interface RequestInfo { @@ -115,8 +116,8 @@ export namespace policies { onReadTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, isDataPresent: boolean): DecisionInfo; onUnavailable(requestInfo: RequestInfo, consistency: types.consistencies, required: number, alive: number): DecisionInfo; onWriteTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, writeType: string): DecisionInfo; - rethrowResult(): { decision: retryDecision }; - retryResult(consistency?: types.consistencies, useCurrentHost?: boolean): { decision: retryDecision, consistency: types.consistencies, useCurrentHost: boolean }; + rethrowResult(): DecisionInfo; + retryResult(consistency?: types.consistencies, useCurrentHost?: boolean): DecisionInfo; } } diff --git a/types/cavy/cavy-tests.tsx b/types/cavy/cavy-tests.tsx new file mode 100644 index 0000000000..e33d0366a7 --- /dev/null +++ b/types/cavy/cavy-tests.tsx @@ -0,0 +1,40 @@ +import * as React from 'react'; +import { TextInput, View, Text } from 'react-native'; + +import { hook, TestScope, WithTestHook, Tester } from 'cavy'; + +type Props = WithTestHook<{ + foo: string; +}>; + +class SampleComponent extends React.Component { + render() { + return ( + + {this.props.foo} + + + ); + } +} + +const HookedSampleComponent = hook(SampleComponent); // $ExpectType ComponentClass<{ foo: string; }, any> + +function sampleSpec(spec: TestScope) { + spec.describe('it has a name and callback', () => { + spec.it('it has a name and callback', async () => { + spec.component.reRender(); // $ExpectType void + spec.component.clearAsync(); // $ExpectType Promise + spec.findComponent('View.Sample'); // $ExpectType Promise> + spec.press('View.Sample'); // $ExpectType Promise + spec.fillIn('Input.Sample', "hello world"); // $ExpectType Promise + spec.pause(1000); // $ExpectType Promise + spec.exists('View.Sample'); // $ExpectType Promise + spec.notExists('View.MissingSample'); // $ExpectType Promise + }); + }); +} + + + +; diff --git a/types/cavy/index.d.ts b/types/cavy/index.d.ts new file mode 100644 index 0000000000..5e74edfe48 --- /dev/null +++ b/types/cavy/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for cavy 0.6 +// Project: https://github.com/pixielabs/cavy +// Definitions by: Tyler Hoffman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +import * as React from 'react'; + +export {}; + +type RefCallback = (element: React.ReactNode | null) => void; + +export type TestHookGenerator = (label: string, callback?: RefCallback) => RefCallback; + +export type WithTestHook = T & { generateTestHook: TestHookGenerator }; + +export function hook(component: React.ComponentClass>): React.ComponentClass; + +export interface TesterProps { + specs: Array<(spec: TestScope) => void>; + waitTime: number; + sendReport?: boolean; +} + +export class Tester extends React.Component { + reRender(): void; + clearAsync(): Promise; +} + +export class TestScope { + component: Tester; + findComponent(identifier: string): Promise; + describe(label: string, fn: () => void): void; + it(label: string, fn: () => void): void; + press(identifier: string): Promise; + fillIn(identifier: string, str: string): Promise; + pause(time: number): Promise; + exists(identifier: string): Promise; + notExists(identifier: string): Promise; +} diff --git a/types/tabris-plugin-firebase/tsconfig.json b/types/cavy/tsconfig.json similarity index 90% rename from types/tabris-plugin-firebase/tsconfig.json rename to types/cavy/tsconfig.json index cac6477844..4b78de6410 100644 --- a/types/tabris-plugin-firebase/tsconfig.json +++ b/types/cavy/tsconfig.json @@ -13,11 +13,12 @@ "../" ], "types": [], + "jsx": "react", "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", - "tabris-plugin-firebase-tests.ts" + "cavy-tests.tsx" ] } \ No newline at end of file diff --git a/types/chokidar/tslint.json b/types/cavy/tslint.json similarity index 100% rename from types/chokidar/tslint.json rename to types/cavy/tslint.json diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 7745713c84..c601631280 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for Chart.js 2.7 -// Project: https://github.com/nnnick/Chart.js, http://www.chartjs.org +// Project: https://github.com/nnnick/Chart.js, https://www.chartjs.org // Definitions by: Alberto Nuti // Fabien Lavocat // KentarouTakeda @@ -357,7 +357,7 @@ declare namespace Chart { cornerRadius?: number; multiKeyBackground?: string; callbacks?: ChartTooltipCallback; - filter?(item: ChartTooltipItem): boolean; + filter?(item: ChartTooltipItem, data: ChartData): boolean; itemSort?(itemA: ChartTooltipItem, itemB: ChartTooltipItem): number; position?: string; caretPadding?: number; diff --git a/types/cheerio/cheerio-tests.ts b/types/cheerio/cheerio-tests.ts index 719c0c70da..89ffb9e28f 100644 --- a/types/cheerio/cheerio-tests.ts +++ b/types/cheerio/cheerio-tests.ts @@ -24,6 +24,8 @@ if ($fromElement("ul > li").length !== 3) { throw new Error("Expecting 3 elements when passing `CheerioElement` to `load()`"); } +$ = cheerio.load(Buffer.from(html)); + $ = cheerio.load(html, { normalizeWhitespace: true, xmlMode: true diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index 6c893021a3..f25c978ed0 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -1,8 +1,10 @@ // Type definitions for Cheerio v0.22.0 // Project: https://github.com/cheeriojs/cheerio -// Definitions by: Bret Little , VILIC VANE , Wayne Maurer , Umar Nizamani , LiJinyao , Chennakrishna , AzSiAz +// Definitions by: Bret Little , VILIC VANE , Wayne Maurer , Umar Nizamani , LiJinyao , Chennakrishna , AzSiAz , Ryo Ota // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + interface Cheerio { // Document References // Cheerio https://github.com/cheeriojs/cheerio @@ -266,7 +268,7 @@ interface CheerioElement { } interface CheerioAPI extends CheerioSelector, CheerioStatic { - load(html: string, options?: CheerioOptionsInterface): CheerioStatic; + load(html: string | Buffer, options?: CheerioOptionsInterface): CheerioStatic; load(element: CheerioElement, options?: CheerioOptionsInterface): CheerioStatic; } diff --git a/types/chocolatechipjs/chocolatechipjs-tests.ts b/types/chocolatechipjs/chocolatechipjs-tests.ts index a723d1b8f9..93cd698da7 100644 --- a/types/chocolatechipjs/chocolatechipjs-tests.ts +++ b/types/chocolatechipjs/chocolatechipjs-tests.ts @@ -213,7 +213,7 @@ $('ul').undelegate('click', 'li', () => { $('li').on('click', () => { $.noop; }); -$('ul').on('click', 'li', () => { +$('ul').on('click', 'li', function() { console.log($(this).text()); }); $('li').off('click'); diff --git a/types/chokidar/chokidar-tests.ts b/types/chokidar/chokidar-tests.ts deleted file mode 100644 index 13e5fe6a90..0000000000 --- a/types/chokidar/chokidar-tests.ts +++ /dev/null @@ -1,57 +0,0 @@ -import * as fs from 'fs'; -import chokidar = require('chokidar'); - -const watcher = chokidar.watch('file, dir, or glob', { - ignored: /[\/\\]\./, persistent: true -}); - -const log = console.log.bind(console); - -watcher - .on('add', (path: string) => { - log('File', path, 'has been added'); - }) - .on('addDir', (path: string) => { - log('Directory', path, 'has been added'); - }) - .on('change', (path: string) => { - log('File', path, 'has been changed'); - }) - .on('unlink', (path: string) => { - log('File', path, 'has been removed'); - }) - .on('unlinkDir', (path: string) => { - log('Directory', path, 'has been removed'); - }) - .on('error', (error: any) => { - log('Error happened', error); - }) - .on('ready', () => { - log('Initial scan complete. Ready for changes.'); - }) - .on('raw', (event: string, path: string, details: any) => { - log('Raw event info:', event, path, details); - }); - -// 'add', 'addDir' and 'change' events also receive stat() results as second -// argument when available: http://nodejs.org/api/fs.html#fs_class_fs_stats -watcher.on('change', (path: string, stats: fs.Stats) => { - if (stats) { - console.log('File', path, 'changed size to', stats.size); - } -}); - -// Watch new files. -watcher.add('new-file'); -watcher.add(['new-file-2', 'new-file-3', '**/other-file*']); - -// Un-watch some files. -watcher.unwatch('new-file*'); - -// Only needed if watching is `persistent: true`. -watcher.close(); - -// One-liner -chokidar.watch('.', { ignored: /[\/\\]\./ }).on('all', (event: string, path: string) => { - console.log(event, path); -}); diff --git a/types/chokidar/index.d.ts b/types/chokidar/index.d.ts deleted file mode 100644 index 6acc9af265..0000000000 --- a/types/chokidar/index.d.ts +++ /dev/null @@ -1,170 +0,0 @@ -// Type definitions for chokidar 1.7 -// Project: https://github.com/paulmillr/chokidar -// Definitions by: Stefan Steinhart -// Felix Becker -// Zach Cardoza -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -import * as fs from 'fs'; -import { EventEmitter } from 'events'; - -/** - * The object's keys are all the directories (using absolute paths unless the `cwd` option was - * used), and the values are arrays of the names of the items contained in each directory. - */ -export interface WatchedPaths { - [directory: string]: string[]; -} - -export class FSWatcher extends EventEmitter implements fs.FSWatcher { - /** - * Constructs a new FSWatcher instance with optional WatchOptions parameter. - */ - constructor(options?: WatchOptions); - - /** - * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one - * string. - */ - add(paths: string | string[]): void; - - /** - * Stop watching files, directories, or glob patterns. Takes an array of strings or just one - * string. - */ - unwatch(paths: string | string[]): void; - - /** - * Returns an object representing all the paths on the file system being watched by this - * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless - * the `cwd` option was used), and the values are arrays of the names of the items contained in - * each directory. - */ - getWatched(): WatchedPaths; - - /** - * Removes all listeners from watched files. - */ - close(): void; -} - -export interface WatchOptions { - /** - * Indicates whether the process should continue to run as long as files are being watched. If - * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`, - * even if the process continues to run. - */ - persistent?: boolean; - - /** - * ([anymatch](https://github.com/es128/anymatch)-compatible definition) Defines files/paths to - * be ignored. The whole relative or absolute path is tested, not just filename. If a function - * with two arguments is provided, it gets called twice per path - once with a single argument - * (the path), second time with two arguments (the path and the - * [`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path). - */ - ignored?: any; - - /** - * If set to `false` then `add`/`addDir` events are also emitted for matching paths while - * instantiating the watching as chokidar discovers these file paths (before the `ready` event). - */ - ignoreInitial?: boolean; - - /** - * When `false`, only the symlinks themselves will be watched for changes instead of following - * the link references and bubbling events through the link's path. - */ - followSymlinks?: boolean; - - /** - * The base directory from which watch `paths` are to be derived. Paths emitted with events will - * be relative to this. - */ - cwd?: string; - - /** - * If set to true then the strings passed to .watch() and .add() are treated as literal path - * names, even if they look like globs. Default: false. - */ - disableGlobbing?: boolean; - - /** - * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU - * utilization, consider setting this to `false`. It is typically necessary to **set this to - * `true` to successfully watch files over a network**, and it may be necessary to successfully - * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides - * the `useFsEvents` default. - */ - usePolling?: boolean; - - /** - * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly - * and `fsevents` is available this supercedes the `usePolling` setting. When set to `false` on - * OS X, `usePolling: true` becomes the default. - */ - useFsEvents?: boolean; - - /** - * If relying upon the [`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats) object that - * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is - * provided even in cases where it wasn't already available from the underlying watch events. - */ - alwaysStat?: boolean; - - /** - * If set, limits how many levels of subdirectories will be traversed. - */ - depth?: number; - - /** - * Interval of file system polling. - */ - interval?: number; - - /** - * Interval of file system polling for binary files. ([see list of binary extensions](https://gi - * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json)) - */ - binaryInterval?: number; - - /** - * Indicates whether to watch files that don't have read permissions if possible. If watching - * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed - * silently. - */ - ignorePermissionErrors?: boolean; - - /** - * `true` if `useFsEvents` and `usePolling` are `false`). Automatically filters out artifacts - * that occur when using editors that use "atomic writes" instead of writing directly to the - * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change` - * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you, - * you can override it by setting `atomic` to a custom value, in milliseconds. - */ - atomic?: boolean | number; - - /** - * can be set to an object in order to adjust timing params: - */ - awaitWriteFinish?: AwaitWriteFinishOptions | boolean; -} - -export interface AwaitWriteFinishOptions { - /** - * Amount of time in milliseconds for a file size to remain constant before emitting its event. - */ - stabilityThreshold?: number; - - /** - * File size polling interval. - */ - pollInterval?: number; -} - -/** - * produces an instance of `FSWatcher`. - */ -export function watch(paths: string | string[], options?: WatchOptions): FSWatcher; diff --git a/types/chromecast-caf-receiver/cast.framework.messages.d.ts b/types/chromecast-caf-receiver/cast.framework.messages.d.ts index 1846fd4840..b6e66ff4db 100644 --- a/types/chromecast-caf-receiver/cast.framework.messages.d.ts +++ b/types/chromecast-caf-receiver/cast.framework.messages.d.ts @@ -1441,6 +1441,12 @@ export interface MediaInformation { * The media tracks. */ tracks?: Track[]; + + /** + * VMAP ad request configuration. Used if breaks and breakClips are not + * provided. + */ + vmapAdsRequest?: VastAdsRequest; } /** diff --git a/types/cipher-base/cipher-base-tests.ts b/types/cipher-base/cipher-base-tests.ts new file mode 100644 index 0000000000..b81238ee98 --- /dev/null +++ b/types/cipher-base/cipher-base-tests.ts @@ -0,0 +1,17 @@ +import CipherBase = require("cipher-base"); + +const buf = new Buffer(1); + +class CipherTest extends CipherBase { + constructor() { + super(); + } + + final() { + return buf; + } + + update(testBuffer: Buffer) { + return testBuffer; + } +} diff --git a/types/cipher-base/index.d.ts b/types/cipher-base/index.d.ts new file mode 100644 index 0000000000..f43ca2cdb9 --- /dev/null +++ b/types/cipher-base/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for cipher-base 1.0 +// Project: https://github.com/crypto-browserify/cipher-base +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare abstract class CipherBase { + constructor(hashMode?: string); + abstract final(): Buffer; + abstract update(value: Buffer, inputEnc?: string, outputEnc?: string): Buffer; +} + +export = CipherBase; diff --git a/types/cipher-base/tsconfig.json b/types/cipher-base/tsconfig.json new file mode 100644 index 0000000000..217193ea64 --- /dev/null +++ b/types/cipher-base/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cipher-base-tests.ts" + ] +} diff --git a/types/cipher-base/tslint.json b/types/cipher-base/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/cipher-base/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/ckeditor__ckeditor5-core/index.d.ts b/types/ckeditor__ckeditor5-core/index.d.ts index e3de076471..bc07e94fd3 100644 --- a/types/ckeditor__ckeditor5-core/index.d.ts +++ b/types/ckeditor__ckeditor5-core/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for @ckeditor/ckeditor5-core 11.0 -// Project: https://github.com/ckeditor/ckeditor5-core, https://ckeditor.com +// Project: https://github.com/ckeditor/ckeditor5-core, https://ckeditor.com/ckeditor-5 // Definitions by: denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/ckeditor__ckeditor5-engine/index.d.ts b/types/ckeditor__ckeditor5-engine/index.d.ts index 4d3e3f4a97..227862c0e3 100644 --- a/types/ckeditor__ckeditor5-engine/index.d.ts +++ b/types/ckeditor__ckeditor5-engine/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for @ckeditor/ckeditor5-engine 11.0 -// Project: https://github.com/ckeditor/ckeditor5-engine, https://ckeditor.com +// Project: https://github.com/ckeditor/ckeditor5-engine, https://ckeditor.com/ckeditor-5 // Definitions by: denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/ckeditor__ckeditor5-utils/index.d.ts b/types/ckeditor__ckeditor5-utils/index.d.ts index 3d943969de..fa270c8ba5 100644 --- a/types/ckeditor__ckeditor5-utils/index.d.ts +++ b/types/ckeditor__ckeditor5-utils/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for @ckeditor/ckeditor5-utils 10.2 -// Project: https://github.com/ckeditor/ckeditor5-utils, https://ckeditor.com +// Project: https://github.com/ckeditor/ckeditor5-utils, https://ckeditor.com/ckeditor-5 // Definitions by: denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/coinbase/index.d.ts b/types/coinbase/index.d.ts index 82fc32a7d3..891361627f 100644 --- a/types/coinbase/index.d.ts +++ b/types/coinbase/index.d.ts @@ -878,7 +878,7 @@ export class Buy implements Resource { /** * Associated transaction (e.g. a bank, fiat account) */ - transaction: ResourceRef; + transaction: ResourceRef | null; /** * Amount in bitcoin, litecoin or ethereum @@ -896,7 +896,7 @@ export class Buy implements Resource { subtotal: MoneyHash; /** - * Fee associated to this buy + * Fees associated to this buy */ fees: Fee[]; @@ -935,6 +935,26 @@ export class Buy implements Resource { */ requires_completion_step: boolean; + /** + * Transfer identifier + */ + id: string; + + /** + * Reference code shown in user's dashboard. + */ + user_reference: string; + + /** + * ISO timestamp + */ + created_at: string; + + /** + * ISO timestamp + */ + updated_at: string; + /** * Completes a buy that is created in commit: false state. * If the exchange rate has changed since the buy was created, this call will fail with the error “The exchange rate updated while you @@ -995,7 +1015,7 @@ export class Sell implements Resource { /** * Associated transaction (e.g. a bank, fiat account) */ - transaction: ResourceRef; + transaction: ResourceRef | null; /** * Amount in bitcoin, litecoin or ethereum @@ -1013,9 +1033,9 @@ export class Sell implements Resource { subtotal: MoneyHash; /** - * Fee associated to this sell + * Fees associated to this sell */ - fee: MoneyHash; + fees: MoneyHash[]; /** * Has this sell been committed? @@ -1032,6 +1052,26 @@ export class Sell implements Resource { */ payout_at?: string; + /** + * Transfer identifier + */ + id: string; + + /** + * Reference code shown in user's dashboard. + */ + user_reference: string; + + /** + * ISO timestamp + */ + created_at: string; + + /** + * ISO timestamp + */ + updated_at: string; + /** * Completes a sell that is created in commit: false state. * If the exchange rate has changed since the sell was created, this call will fail with the error “The exchange rate updated while you diff --git a/types/complex.js/complex.js-tests.ts b/types/complex.js/complex.js-tests.ts new file mode 100644 index 0000000000..0edef20998 --- /dev/null +++ b/types/complex.js/complex.js-tests.ts @@ -0,0 +1,61 @@ +import Complex from "complex.js"; + +Complex.ZERO; +Complex.PI; +Complex.E; +Complex.I; +Complex.INFINITY; +Complex.EPSILON; +Complex.ONE; +Complex.NAN; + +new Complex(1, 0); +new Complex(1, 0).abs(); +new Complex(1, 0).acos(); +new Complex(1, 0).acot(); +new Complex(1, 0).acoth(); +new Complex(1, 0).acsc(); +new Complex(1, 0).acsch(); +new Complex(1, 0).add(1, 2); +new Complex(1, 0).arg(); +new Complex(1, 0).asec(); +new Complex(1, 0).asech(); +new Complex(1, 0).asin(); +new Complex(1, 0).asinh(); +new Complex(1, 0).atan(); +new Complex(1, 0).atanh(); +new Complex(1, 0).ceil(5); +new Complex(1, 0).clone(); +new Complex(1, 0).conjugate(); +new Complex(1, 0).cos(); +new Complex(1, 0).cosh(); +new Complex(1, 0).cot(); +new Complex(1, 0).coth(); +new Complex(1, 0).csc(); +new Complex(1, 0).csch(); +new Complex(1, 0).div(3, 1); +new Complex(1, 0).equals(5, 3); +new Complex(1, 0).exp(); +new Complex(1, 0).floor(6); +new Complex(1, 0).inverse(); +new Complex(1, 0).isFinite(); +new Complex(1, 0).isInfinite(); +new Complex(1, 0).isNaN(); +new Complex(1, 0).isZero(); +new Complex(1, 0).log(); +new Complex(1, 0).mul(3, 1); +new Complex(1, 0).neg(); +new Complex(1, 0).pow(1, 2); +new Complex(1, 0).round(3); +new Complex(1, 0).sec(); +new Complex(1, 0).sech(); +new Complex(1, 0).sign(); +new Complex(1, 0).sin(); +new Complex(1, 0).sinh(); +new Complex(1, 0).sqrt(); +new Complex(1, 0).sub(5, 1); +new Complex(1, 0).tan(); +new Complex(1, 0).tanh(); +new Complex(1, 0).toString(); +new Complex(1, 0).toVector(); +new Complex(1, 0).valueOf(); diff --git a/types/complex.js/index.d.ts b/types/complex.js/index.d.ts new file mode 100644 index 0000000000..487fc4e30d --- /dev/null +++ b/types/complex.js/index.d.ts @@ -0,0 +1,304 @@ +// Type definitions for complex.js 2.0 +// Project: https://github.com/infusion/Complex.js +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class Complex { + /** + * A complex zero value (south pole on the Riemann Sphere). + */ + static ZERO: Complex; + + /** + * A complex one instance. + */ + static ONE: Complex; + + /** + * A complex infinity value (north pole on the Riemann Sphere). + */ + static INFINITY: Complex; + + /** + * A complex NaN value (not on the Riemann Sphere). + */ + static NAN: Complex; + + /** + * An imaginary number i instance. + */ + static I: Complex; + + /** + * A complex PI instance. + */ + static PI: Complex; + + /** + * A complex euler number instance. + */ + static E: Complex; + + /** + * A small epsilon value used for equals() comparison in order to circumvent double inprecision. + */ + static EPSILON: number; + + constructor(x: number, y: number); + + /** + * Returns the complex sign, defined as the complex number + * normalized by it's absolute value. + */ + sign(): Complex; + + /** + * Adds another complex number. + */ + add(a: number, b: number): Complex; + + /** + * Subtracts another complex number. + */ + sub(a: number, b: number): Complex; + + /** + * Multiplies the number with another complex number. + */ + mul(a: number, b: number): Complex; + + /** + * Divides the number by another complex number. + */ + div(a: number, b: number): Complex; + + /** + * Returns the number raised to the complex exponent. + */ + pow(a: number, b: number): Complex; + + /** + * Returns the complex square root of the number. + */ + sqrt(): Complex; + + /** + * Returns e^n with complex exponent n + */ + exp(): Complex; + + /** + * Returns the natural logarithm (base E) of the actual complex number. + */ + log(): Complex; + + /** + * Calculates the magnitude of the complex number. + */ + abs(): number; + + /** + * Calculate the angle of the complex number. + */ + arg(): number; + + /** + * Calculates the multiplicative inverse of the complex number (1 / z). + */ + inverse(): Complex; + + /** + * Calculates the conjugate of the complex number (multiplies the imaginary part with -1). + */ + conjugate(): Complex; + + /** + * Negates the number (multiplies both the real and imaginary part with -1) in order to get the additive inverse. + */ + neg(): Complex; + + /** + * Floors the complex number parts towards zero. + */ + floor(places: number): Complex; + + /** + * Ceils the complex number parts off zero. + */ + ceil(places: number): Complex; + + /** + * Rounds the complex number parts. + */ + round(places: number): Complex; + + /** + * Checks if both numbers are exactly the same, + * if both numbers are infinite they are considered not equal. + */ + equals(a: number, b: number): boolean; + + /** + * Checks if the given number is not a number. + */ + isNaN(): boolean; + + /** + * Determines whether or not a complex number is at the zero pole of the + * Riemann sphere. + */ + isZero(): boolean; + + /** + * Checks if the given number is finite. + */ + isFinite(): boolean; + + /** + * Determines whether or not a complex number is at the infinity pole of the + * Riemann sphere. + */ + isInfinite(): boolean; + + /** + * Returns a new Complex instance with the same real and imaginary properties. + */ + clone(): Complex; + + /** + * Returns a Vector of the actual complex number with two components. + */ + toVector(): number[]; + + /** + * Returns a string representation of the actual number. As of v1.9.0 the output is a bit more human readable. + */ + toString(): string; + + /** + * Returns the real part of the number if imaginary part is zero. Otherwise null. + */ + valueOf(): number|undefined; + + /** + * Calculate the sine of the complex number. + */ + sin(): Complex; + + /** + * Calculate the complex arcus sinus. + */ + asin(): Complex; + + /** + * Calculate the complex sinh. + */ + sinh(): Complex; + + /** + * Calculate the complex asinh. + */ + asinh(): Complex; + + /** + * Calculate the cosine. + */ + cos(): Complex; + + /** + * Calculate the complex arcus cosinus. + */ + acos(): Complex; + + /** + * Calculate the complex cosh. + */ + cosh(): Complex; + + /** + * Calculate the complex asinh. + */ + acosh(): Complex; + + /** + * Calculate the tangent. + */ + tan(): Complex; + + /** + * Calculate the complex arcus tangent. + */ + atan(): Complex; + + /** + * Calculate the complex tanh. + */ + tanh(): Complex; + + /** + * Calculate the complex atanh. + */ + atanh(): Complex; + + /** + * Calculate the cotangent. + */ + cot(): Complex; + + /** + * Calculate the complex arcus cotangent. + */ + acot(): Complex; + + /** + * Calculate the complex coth. + */ + coth(): Complex; + + /** + * Calculate the complex acoth. + */ + acoth(): Complex; + + /** + * Calculate the secant. + */ + sec(): Complex; + + /** + * Calculate the complex arcus secant. + */ + asec(): Complex; + + /** + * Calculate the complex sech. + */ + sech(): Complex; + + /** + * Calculate the complex asech. + */ + asech(): Complex; + + /** + * Calculate the cosecans. + */ + csc(): Complex; + + /** + * Calculate the complex arcus cosecans. + */ + acsc(): Complex; + + /** + * Calculate the complex csch. + */ + csch(): Complex; + + /** + * Calculate the complex acsch. + */ + acsch(): Complex; +} + +export default Complex; diff --git a/types/complex.js/tsconfig.json b/types/complex.js/tsconfig.json new file mode 100644 index 0000000000..b4af58b032 --- /dev/null +++ b/types/complex.js/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "complex.js-tests.ts" + ] +} diff --git a/types/complex.js/tslint.json b/types/complex.js/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/complex.js/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/connect-datadog/index.d.ts b/types/connect-datadog/index.d.ts index c3aad8aac7..9b68fb6a4f 100644 --- a/types/connect-datadog/index.d.ts +++ b/types/connect-datadog/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for connect-datadog 0.0 -// Project: https://github.com/AppPress/node-connect-datadog +// Project: https://github.com/datadog/node-connect-datadog // Definitions by: Moshe Good +// Michael Mifsud // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -19,6 +20,6 @@ declare namespace Factory { method?: boolean; protocol?: boolean; response_code?: boolean; - dogstatsd?: dogstatsd.StatsD; + dogstatsd?: dogstatsd.StatsDClient; } } diff --git a/types/connect-mongo/connect-mongo-tests.ts b/types/connect-mongo/connect-mongo-tests.ts index 351975d84c..4e3c7f8381 100644 --- a/types/connect-mongo/connect-mongo-tests.ts +++ b/types/connect-mongo/connect-mongo-tests.ts @@ -45,8 +45,8 @@ app.use(session({ // NativeMongoPromiseOptions var Client = mongodb.MongoClient; -var mongoDbPromise = Client.connect('mongodb://localhost/test'); +var mongoDbPromise = Client.connect('mongodb://localhost/test').then(client => client.db()) app.use(session({ secret: 'secret', - store: new MongoStore({ dbPromise: mongoDbPromise}) + store: new MongoStore({ dbPromise: mongoDbPromise }) })); diff --git a/types/connect-mongo/tsconfig.json b/types/connect-mongo/tsconfig.json index c0c9ab3043..dc0b76551d 100644 --- a/types/connect-mongo/tsconfig.json +++ b/types/connect-mongo/tsconfig.json @@ -4,14 +4,6 @@ "lib": [ "es6" ], - "paths": { - "mongodb": [ - "mongodb/v2" - ], - "mongoose": [ - "mongoose/v4" - ] - }, "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, diff --git a/types/consul/consul-tests.ts b/types/consul/consul-tests.ts index 988890766d..263b5beff5 100644 --- a/types/consul/consul-tests.ts +++ b/types/consul/consul-tests.ts @@ -511,6 +511,7 @@ consul = new Consul(); // Consul.Health { let health: Consul.Health = consul.health; + let name: string; health = new HealthStatic(consul); consul = health.consul; diff --git a/types/cote/cote-tests.ts b/types/cote/cote-tests.ts index 1851654625..d4af3ce95e 100644 --- a/types/cote/cote-tests.ts +++ b/types/cote/cote-tests.ts @@ -35,6 +35,7 @@ class Readme { }); const req = { + __subset: 'subset', type: 'randomRequest', payload: { val: Math.floor(Math.random() * 10) @@ -52,7 +53,8 @@ class Readme { name: 'Random Responder', namespace: 'rnd', key: 'a certain key', - respondsTo: ['randomRequest'] + respondsTo: ['randomRequest'], + subset: 'subset' }); interface RandomRequest { diff --git a/types/cote/index.d.ts b/types/cote/index.d.ts index 4c959af76b..93f5b7d63f 100644 --- a/types/cote/index.d.ts +++ b/types/cote/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cote 0.17 +// Type definitions for cote 0.19 // Project: https://github.com/dashersw/cote#readme // Definitions by: makepost // Labat Robin @@ -115,6 +115,11 @@ export interface ResponderAdvertisement extends Advertisement { * Request types that a Responder can listen to. */ respondsTo?: string[]; + + /** + * Advertisement attribute that lets you target a subgroup of responders using the __subset property of a request. + */ + subset?: string; } export class Publisher extends Component { diff --git a/types/cron/cron-tests.ts b/types/cron/cron-tests.ts index 21e28f9c0f..d146fe6a61 100644 --- a/types/cron/cron-tests.ts +++ b/types/cron/cron-tests.ts @@ -1,5 +1,7 @@ import cron = require('cron'); +import moment = require('moment'); + var CronJob = cron.CronJob; var CronTime = cron.CronTime; @@ -34,6 +36,16 @@ var job = new CronJob(new Date(), () => { timeZone /* Time zone of this job. */ ); +// Another example with Moment +var job = new CronJob(moment(), () => { + /* runs once at the specified moment. */ + }, () => { + /* This function is executed when the job stops */ + }, + true, /* Start the job right now */ + timeZone /* Time zone of this job. */ +); + // For good measure var job = new CronJob({ cronTime: '00 30 11 * * 1-5', @@ -48,7 +60,8 @@ var job = new CronJob({ timeZone: 'America/Los_Angeles' }); console.log(job.lastDate()); -console.log(job.nextDates(1)); +console.log(job.nextDates());// Should be a Moment object +console.log(job.nextDates(1));// Should be an array of Moment object console.log(job.running); job.setTime(new CronTime('00 30 11 * * 1-2')); job.start(); @@ -67,4 +80,5 @@ try { // Check cronTime fomat new CronTime('* * * * * *'); new CronTime(new Date()); +new CronTime(moment()); diff --git a/types/cron/index.d.ts b/types/cron/index.d.ts index 596a9536ca..b508c0d1fd 100644 --- a/types/cron/index.d.ts +++ b/types/cron/index.d.ts @@ -4,6 +4,8 @@ // Lundarl Gholoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { Moment } from 'moment'; + export declare class CronTime { /** * Create a new ```CronTime```. @@ -11,13 +13,14 @@ export declare class CronTime { * @param zone Timezone name. You can check all timezones available at [Moment Timezone Website](http://momentjs.com/timezone/). * @param utcOffset UTC offset. Don't use both ```zone``` and ```utcOffset``` together or weird things may happen. */ - constructor(source: string | Date, zone?: string, utcOffset?: string | number); + constructor(source: string | Date | Moment, zone?: string, utcOffset?: string | number); /** * Tells you when ```CronTime``` will be run. * @param i Indicate which turn of run after now. If not given return next run time. */ - public sendAt(i?: number): Date; + public sendAt(): Moment; + public sendAt(i?: number): Moment[]; /** * Get the number of milliseconds in the future at which to fire our callbacks. */ @@ -28,7 +31,7 @@ export declare interface CronJobParameters { /** * The time to fire off your job. This can be in the form of cron syntax or a JS ```Date``` object. */ - cronTime: string | Date; + cronTime: string | Date | Moment; /** * The function to fire at the specified time. If an ```onComplete``` callback was provided, ```onTick``` will receive it as an argument. ```onTick``` may call ```onComplete``` when it has finished its work. */ @@ -85,7 +88,7 @@ export declare class CronJob { * @param utcOffset This allows you to specify the offset of your timezone rather than using the ```timeZone``` param. Probably don't use both ```timeZone``` and ```utcOffset``` together or weird things may happen. * @param unrefTimeout If you have code that keeps the event loop running and want to stop the node process when that finishes regardless of the state of your cronjob, you can do so making use of this parameter. This is off by default and cron will run as if it needs to control the event loop. For more information take a look at [timers#timers_timeout_unref](https://nodejs.org/api/timers.html#timers_timeout_unref) from the NodeJS docs. */ - constructor(cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean, utcOffset?: string | number, unrefTimeout?: boolean); + constructor(cronTime: string | Date | Moment, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean, utcOffset?: string | number, unrefTimeout?: boolean); /** * Create a new ```CronJob```. * @param options Job parameters. @@ -113,7 +116,8 @@ export declare class CronJob { * Tells you when a ```CronTime``` will be run. * @param i Indicate which turn of run after now. If not given return next run time. */ - public nextDates(i?: number): Date; + public nextDates(): Moment; + public nextDates(i?: number): Moment[]; /** * Add another ```onTick``` function. * @param callback Target function. @@ -122,8 +126,8 @@ export declare class CronJob { } export declare var job: - ((cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean, utcOffset?: string | number, unrefTimeout?: boolean) => CronJob) + ((cronTime: string | Date | Moment, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean, utcOffset?: string | number, unrefTimeout?: boolean) => CronJob) | ((options: CronJobParameters) => CronJob); -export declare var time: (source: string | Date, zone?: string) => CronTime; -export declare var sendAt: (cronTime: CronTime) => Date; -export declare var timeout: (cronTime: CronTime) => number; +export declare var time: (source: string | Date | Moment, zone?: string) => CronTime; +export declare var sendAt: (cronTime: string | Date | Moment) => Moment; +export declare var timeout: (cronTime: string | Date | Moment) => number; diff --git a/types/cron/package.json b/types/cron/package.json new file mode 100644 index 0000000000..19e5fb0d14 --- /dev/null +++ b/types/cron/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.14.0" + } +} diff --git a/types/cross-spawn/cross-spawn-tests.ts b/types/cross-spawn/cross-spawn-tests.ts index 6cb36510d8..f6dac4ea72 100644 --- a/types/cross-spawn/cross-spawn-tests.ts +++ b/types/cross-spawn/cross-spawn-tests.ts @@ -8,7 +8,7 @@ pw.on('error', (err: Error) => { console.log(err); }); -const r1: Error = spawn.sync('foo').error; +const r1: Error | undefined = spawn.sync('foo').error; const r2: string[] = spawn.sync('foo').output; const r3: Buffer = spawn.sync('foo').stdout; const r4: Buffer = spawn.sync('foo').stderr; diff --git a/types/cypress-axe/index.d.ts b/types/cypress-axe/index.d.ts index 507a5f773d..3ba776e14f 100644 --- a/types/cypress-axe/index.d.ts +++ b/types/cypress-axe/index.d.ts @@ -1,12 +1,21 @@ -// Type definitions for cypress-axe 0.3 +// Type definitions for cypress-axe 0.4 // Project: https://github.com/avanslaars/cypress-axe#readme // Definitions by: Justin Hall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -declare namespace Cypress { - interface Chainable { - injectAxe(): void; - checkA11y(): void; +import { ElementContext, RunOptions } from 'axe-core'; + +declare module 'axe-core' { + interface Node {} +} + +declare global { + namespace Cypress { + interface Chainable { + injectAxe(): void; + checkA11y(context?: ElementContext, options?: RunOptions): void; + configureAxe(options?: RunOptions): void; + } } } diff --git a/types/cypress-axe/package.json b/types/cypress-axe/package.json new file mode 100644 index 0000000000..71df6dd355 --- /dev/null +++ b/types/cypress-axe/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "axe-core": "^3.1.2" + } +} diff --git a/types/cypress-axe/tslint.json b/types/cypress-axe/tslint.json index 3db14f85ea..4f44991c3c 100644 --- a/types/cypress-axe/tslint.json +++ b/types/cypress-axe/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-empty-interface": false + } +} diff --git a/types/d3-cloud/d3-cloud-tests.ts b/types/d3-cloud/d3-cloud-tests.ts index e3bffed4cb..19a140959f 100644 --- a/types/d3-cloud/d3-cloud-tests.ts +++ b/types/d3-cloud/d3-cloud-tests.ts @@ -27,8 +27,11 @@ d3.layout.cloud().size([300, 300]) .font("Impact") .fontSize(function(d:ICompTextSize) { return d.size; }) .on("end", draw) + .random() + .canvas() .start(); + function draw(words:ICompTextSize[]) { d3.select("body").append("svg") .attr("width", 300) diff --git a/types/d3-cloud/index.d.ts b/types/d3-cloud/index.d.ts index fdf2dbc719..b0a3b8a78c 100644 --- a/types/d3-cloud/index.d.ts +++ b/types/d3-cloud/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for d3JS cloud layout plugin by Jason Davies v1.2.2 +// Type definitions for d3JS cloud layout plugin by Jason Davies v1.2.5 // Project: https://github.com/jasondavies/d3-cloud -// Definitions by: hans windhoff +// Definitions by: hans windhoff , locknono // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as d3 from 'd3'; @@ -71,6 +71,24 @@ declare module 'd3' { padding(padding: number): Cloud; padding(padding: (datum: T, index: number) => number): Cloud; + /** + * If specified, sets the internal random number generator,used for selecting the initial position of each word, + * and the clockwise/counterclockwise direction of the spiral for each word. + * + * @param randomFunction should return a number in the range [0, 1).The default is Math.random. + */ + random(): Cloud; + random(randomFunction: () => number): Cloud; + + /** + * If specified, sets the canvas generator function, which is used internally to draw text. + * When using Node.js, you will almost definitely override the default, e.g. using the canvas module. + * @param canvasGenerator should return a HTMLCanvasElement.The default is: ()=>{document.createElement("canvas");} + * + */ + canvas():Cloud; + canvas(canvasGenerator: () => HTMLCanvasElement): Cloud; + on(type: "word", listener: (word: T) => void): Cloud; on(type: "end", listener: (tags: T[], bounds: { x: number; y: number }[]) => void): Cloud; on(type: string, listener: (...args: any[]) => void): Cloud; diff --git a/types/datadog-statsd-metrics-collector/datadog-statsd-metrics-collector-tests.ts b/types/datadog-statsd-metrics-collector/datadog-statsd-metrics-collector-tests.ts new file mode 100644 index 0000000000..ef5691a57d --- /dev/null +++ b/types/datadog-statsd-metrics-collector/datadog-statsd-metrics-collector-tests.ts @@ -0,0 +1,43 @@ +import datadog = require('node-dogstatsd'); +import Collector = require('datadog-statsd-metrics-collector'); + +const client = new datadog.StatsD('localhost'); + +// constructors +let collector = new Collector(client); +collector = new Collector(client, 1000); + +// interface +const key = 'key'; +const timeValue = 99; +const sampleRate = 0.85; +const incrementBy = 7; +const decrementBy = 5; +const gaugeValue = 199; +const tags: string[] = ['tag1', 'tag2']; + +collector.timing(key, timeValue); +collector.timing(key, timeValue, sampleRate); +collector.timing(key, timeValue, sampleRate, tags); + +collector.increment(key); +collector.increment(key, sampleRate); +collector.increment(key, sampleRate, tags); + +collector.incrementBy(key, incrementBy); +collector.incrementBy(key, incrementBy, tags); + +collector.decrement(key); +collector.decrement(key, sampleRate); +collector.decrement(key, sampleRate, tags); + +collector.decrementBy(key, decrementBy); +collector.decrementBy(key, decrementBy, tags); + +collector.gauge(key, gaugeValue); +collector.gauge(key, gaugeValue, sampleRate); +collector.gauge(key, gaugeValue, sampleRate, tags); + +collector.histogram(key, timeValue); +collector.histogram(key, timeValue, sampleRate); +collector.histogram(key, timeValue, sampleRate, tags); diff --git a/types/datadog-statsd-metrics-collector/index.d.ts b/types/datadog-statsd-metrics-collector/index.d.ts new file mode 100644 index 0000000000..741c5a9f43 --- /dev/null +++ b/types/datadog-statsd-metrics-collector/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for datadog-statsd-metrics-collector 1.1 +// Project: https://github.com/xzyfer/datadog-statsd-metrics-collector#readme +// Definitions by: Michael Mifsud +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import dogstatsd = require('node-dogstatsd'); + +declare class Collector implements dogstatsd.StatsDClient { + constructor(client: dogstatsd.StatsDClient, delayMilliseconds?: number); + + timing(stat: string, time: number, sample_rate?: number, tags?: string[]): void; + + increment(stat: string, sample_rate?: number, tags?: string[]): void; + incrementBy(stat: string, value: number, tags?: string[]): void; + + decrement(stat: string, sample_rate?: number, tags?: string[]): void; + decrementBy(stat: string, value: number, tags?: string[]): void; + + gauge(stat: string, value: number, sample_rate?: number, tags?: string[]): void; + + histogram(stat: string, time: number, sample_rate?: number, tags?: string[]): void; +} + +export = Collector; diff --git a/types/datadog-statsd-metrics-collector/tsconfig.json b/types/datadog-statsd-metrics-collector/tsconfig.json new file mode 100644 index 0000000000..d136060376 --- /dev/null +++ b/types/datadog-statsd-metrics-collector/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", + "datadog-statsd-metrics-collector-tests.ts" + ] +} diff --git a/types/internal-ip/tslint.json b/types/datadog-statsd-metrics-collector/tslint.json similarity index 100% rename from types/internal-ip/tslint.json rename to types/datadog-statsd-metrics-collector/tslint.json diff --git a/types/datatables.net/datatables.net-tests.ts b/types/datatables.net/datatables.net-tests.ts index de739a673a..d6903ce1db 100644 --- a/types/datatables.net/datatables.net-tests.ts +++ b/types/datatables.net/datatables.net-tests.ts @@ -578,7 +578,7 @@ $('#example tbody').on('click', 'td', () => { const cell_invalidate_1 = cell.invalidate(); const cell_invalidate_2 = cell.invalidate("data"); -$('#example tbody').on('click', 'td', () => { +$('#example tbody').on('click', 'td', function() { this.innerHTML = (parseInt(this.innerHTML, 10) + 1).toString(); dt.cell(this).invalidate().draw(); }); @@ -773,7 +773,7 @@ let column_search_set = column.search("string"); column_search_set = column.search("string", true); column_search_set = column.search("string", true, false); column_search_set = column.search("string", true, false, true); -$('#column3_search').on('keyup', () => { +$('#column3_search').on('keyup', function() { dt .columns(3) .search((this as HTMLInputElement).value) diff --git a/types/date-and-time/date-and-time-tests.ts b/types/date-and-time/date-and-time-tests.ts new file mode 100644 index 0000000000..aae667f2bc --- /dev/null +++ b/types/date-and-time/date-and-time-tests.ts @@ -0,0 +1,86 @@ +import * as date from "date-and-time"; + +const now = new Date(); +// $ExpectType string +date.format(now, "YYYY/MM/DD HH:mm:ss"); // => '2015/01/02 23:14:05' +// $ExpectType string +date.format(now, "ddd MMM DD YYYY"); // => 'Fri Jan 02 2015' +// $ExpectType string +date.format(now, "hh:mm A [GMT]Z"); // => '11:14 p.m. GMT-0800' +// $ExpectType string +date.format(now, "hh:mm A [GMT]Z", true); // => '07:14 a.m. GMT+0000' + +// $ExpectType number | Date +date.parse("2015/01/02 23:14:05", "YYYY/MM/DD HH:mm:ss"); // => date object +// $ExpectType number | Date +date.parse("02-01-2015", "DD-MM-YYYY"); // => date object +// $ExpectType number | Date +date.parse("Jam 1 2017", "MMM D YYYY"); // => NaN + +// $ExpectType boolean +date.isValid("2015/01/02 23:14:05", "YYYY/MM/DD HH:mm:ss"); // => true +// $ExpectType boolean +date.isValid("29-02-2015", "DD-MM-YYYY"); // => false + +// $ExpectType Date +date.addYears(now, 1); // => Date object + +// $ExpectType Date +date.addMonths(now, 1); // => Date object + +// $ExpectType Date +date.addDays(now, -1); // => Date object + +// $ExpectType Date +date.addHours(now, -1); // => Date object + +// $ExpectType Date +date.addMinutes(now, 2); // => Date object + +// $ExpectType Date +date.addSeconds(now, -3); // => Date object + +// $ExpectType Date +date.addMilliseconds(now, 1); // => Date object + +const today = new Date(2015, 0, 2); +const yesterday = new Date(2015, 0, 1); + +// $ExpectType Subtract +date.subtract(today, yesterday); +// $ExpectType number +date.subtract(today, yesterday).toDays(); // => 1 = today - yesterday +// $ExpectType number +date.subtract(today, yesterday).toHours(); // => 24 +// $ExpectType number +date.subtract(today, yesterday).toMinutes(); // => 1440 +// $ExpectType number +date.subtract(today, yesterday).toSeconds(); // => 86400 +// $ExpectType number +date.subtract(today, yesterday).toMilliseconds(); // => 86400000 + +const date1 = new Date(2015, 0, 2); +const date2 = new Date(2012, 0, 2); +// $ExpectType boolean +date.isLeapYear(date1); // => false +// $ExpectType boolean +date.isLeapYear(date2); // => true + +const date1_ = new Date(2017, 0, 2, 0); // Jan 2 2017 00:00:00 +const date2_ = new Date(2017, 0, 2, 23, 59); // Jan 2 2017 23:59:00 +const date3 = new Date(2017, 0, 1, 23, 59); // Jan 1 2017 23:59:00 +// $ExpectType boolean +date.isSameDay(date1_, date2_); // => true +// $ExpectType boolean +date.isSameDay(date1_, date3); // => false + +// $ExpectType string +date.locale(); + +// $ExpectType any +date.getLocales(); + +// $ExpectType void +date.setLocales("en", { + A: ["AM", "PM"] +}); diff --git a/types/date-and-time/index.d.ts b/types/date-and-time/index.d.ts new file mode 100644 index 0000000000..76f82809b3 --- /dev/null +++ b/types/date-and-time/index.d.ts @@ -0,0 +1,150 @@ +// Type definitions for date-and-time 0.6 +// Project: https://github.com/knowledgecode/date-and-time +// Definitions by: Daniel Plisetsky +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type getDelta = () => number; + +export interface Subtract { + toMilliseconds: getDelta; + toSeconds: getDelta; + toMinutes: getDelta; + toHours: getDelta; + toDays: getDelta; +} + +/** + * Formatting a date + * @param dateObj - Date object + * @param formatString - Format string + * @param [utc] - Output as UTC + * @returns The formatted string + * + */ +export function format( + dateObj: Date, + formatString: string, + utc?: boolean +): string; + +/** + * Parsing a date string + * @param dateString - date string + * @param formatString - format string + * @param [utc] - input as UTC + * @returns the constructed date or NaN + */ +export function parse( + dateString: string, + formatString: string, + utc?: boolean +): Date | number; + +/** + * Validation + * @param dateString - Date string + * @param formatString - Format string + * @returns Whether the date string is a valid date + */ +export function isValid(dateString: string, formatString: string): boolean; + +/** + * Adding years + * @param dateObj - Date object + * @param years - Adding year + * @returns The date after adding the value + */ +export function addYears(dateObj: Date, years: number): Date; + +/** + * Adding months + * @param dateObj - Date object + * @param months - Adding month + * @returns The date after adding the value + */ +export function addMonths(dateObj: Date, months: number): Date; + +/** + * Adding days + * @param dateObj - Date object + * @param days - Adding day + * @returns The date after adding the value + */ +export function addDays(dateObj: Date, days: number): Date; + +/** + * Adding hours + * @param dateObj - Date object + * @param hours - Adding hour + * @returns The date after adding the value + */ +export function addHours(dateObj: Date, hours: number): Date; + +/** + * Adding minutes + * @param dateObj - Date object + * @param minutes - Adding minute + * @returns The date after adding the value + */ +export function addMinutes(dateObj: Date, minutes: number): Date; + +/** + * Adding seconds + * @param dateObj - date object + * @param seconds - adding second + * @returns The date after adding the value + */ +export function addSeconds(dateObj: Date, seconds: number): Date; + +/** + * Adding milliseconds + * @param dateObj - Date object + * @param milliseconds - Adding millisecond + * @returns The date after adding the value + */ +export function addMilliseconds(dateObj: Date, milliseconds: number): Date; + +/** + * Subtracting + * @param date1 - Date object + * @param date2 - Date object + * @returns The result object after subtracting the date + */ +export function subtract(date1: Date, date2: Date): Subtract; + +/** + * Leap year + * @param dateObj - Date object + * @returns Whether the year is a leap year + */ +export function isLeapYear(dateObj: Date): boolean; + +/** + * Comparison of dates + * @param date1 - Target for comparison + * @param date2 - Target for comparison + * @returns Whether the dates are the same day (times are ignored) + */ +export function isSameDay(date1: Date, date2: Date): boolean; + +/** + * Setting a locale + * @param [code] - Language code + * @returns Current language code + */ +export function locale(code?: string): string; + +/** + * Getting a definition of locale + * @param [code] - Language code + * @returns Definition of locale + */ +export function getLocales(code?: string): any; + +/** + * Adding a new definition of locale + * @param code - Language code + * @param options - Definition of locale + * @returns + */ +export function setLocales(code: string, options: any): void; diff --git a/types/date-and-time/tsconfig.json b/types/date-and-time/tsconfig.json new file mode 100644 index 0000000000..96001a795d --- /dev/null +++ b/types/date-and-time/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "date-and-time-tests.ts"] +} diff --git a/types/internal-ip/v2/tslint.json b/types/date-and-time/tslint.json similarity index 100% rename from types/internal-ip/v2/tslint.json rename to types/date-and-time/tslint.json diff --git a/types/del/del-tests.ts b/types/del/del-tests.ts deleted file mode 100644 index f9d01f644f..0000000000 --- a/types/del/del-tests.ts +++ /dev/null @@ -1,47 +0,0 @@ -import del = require('del'); - -let paths = ['build', 'dist/**/*.js']; - -del(['tmp/*.js', '!tmp/unicorn.js']); -del(['tmp/*.js', '!tmp/unicorn.js'], { force: true }); -del(['tmp/*.js', '!tmp/unicorn.js'], { dryRun: true }); -del(['tmp/*.js', '!tmp/unicorn.js'], { concurrency: 20 }); -del(['tmp/*.js', '!tmp/unicorn.js'], { cwd: '' }); - -del(['tmp/*.js', '!tmp/unicorn.js']).then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -del(['tmp/*.js', '!tmp/unicorn.js'], { force: true }).then( - (paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); - } -); - -del('tmp/*.js'); -del('tmp/*.js', { force: true }); -del('tmp/*.js', { dryRun: true }); -del('tmp/*.js', { concurrency: 20 }); -del('tmp/*.js', { cwd: '' }); -del('tmp/*.js').then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -del('tmp/*.js', { force: true }).then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -paths = del.sync(['tmp/*.js', '!tmp/unicorn.js']); -paths = del.sync(['tmp/*.js', '!tmp/unicorn.js'], { force: true }); - -paths = del.sync('tmp/*.js'); -paths = del.sync('tmp/*.js', { force: true }); -paths = del.sync('tmp/*.js', { dryRun: true }); -paths = del.sync('tmp/*.js', { concurrency: 20 }); -paths = del.sync('tmp/*.js', { cwd: '' }); - -const immutable: ReadonlyArray = ['tmp/*.js', '!tmp/unicorn.js']; -const mutable = del(immutable); -const mutablePaths = del.sync(immutable); -mutable.then(paths => paths.push('test')); -mutablePaths.push('test'); diff --git a/types/del/index.d.ts b/types/del/index.d.ts deleted file mode 100644 index ec92f96c84..0000000000 --- a/types/del/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Type definitions for del 3.0 -// Project: https://github.com/sindresorhus/del -// Definitions by: Asana -// Aya Morisawa -// BendingBender -// Jason Dreyzehner -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -import glob = require('glob'); - -declare function del( - patterns: string | ReadonlyArray, - options?: del.Options -): Promise; - -declare namespace del { - function sync( - patterns: string | ReadonlyArray, - options?: Options - ): string[]; - - interface Options extends glob.IOptions { - force?: boolean; - dryRun?: boolean; - concurrency?: number; - } -} - -export = del; diff --git a/types/del/v2/del-tests.ts b/types/del/v2/del-tests.ts deleted file mode 100644 index 09702c4b39..0000000000 --- a/types/del/v2/del-tests.ts +++ /dev/null @@ -1,37 +0,0 @@ -import del = require("del"); - -let paths = ["build", "dist/**/*.js"]; - -del(["tmp/*.js", "!tmp/unicorn.js"]); - -del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}); - -del(["tmp/*.js", "!tmp/unicorn.js"]).then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}).then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -del("tmp/*.js"); - -del("tmp/*.js", {force: true}); - -del("tmp/*.js").then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -del("tmp/*.js", {force: true}).then((paths: string[]) => { - console.log('Deleted files/folders:\n', paths.join('\n')); -}); - -paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]); - -paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true}); - -paths = del.sync("tmp/*.js"); - -paths = del.sync("tmp/*.js", {force: true}); - -paths = del.sync("tmp/*.js", {dryRun: true}); diff --git a/types/del/v2/index.d.ts b/types/del/v2/index.d.ts deleted file mode 100644 index 50634e39eb..0000000000 --- a/types/del/v2/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Type definitions for del 2.2 -// Project: https://github.com/sindresorhus/del -// Definitions by: Asana , Aya Morisawa -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -import glob = require("glob"); - -declare function del(patterns: string | string[], options?: del.Options): Promise; - -declare namespace del { - function sync(patterns: string | string[], options?: Options): string[]; - - interface Options extends glob.IOptions { - force?: boolean; - dryRun?: boolean; - } -} - -export = del; diff --git a/types/del/v2/tslint.json b/types/del/v2/tslint.json deleted file mode 100644 index 65c83fb1e3..0000000000 --- a/types/del/v2/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "dt-header": false - } -} diff --git a/types/detox/index.d.ts b/types/detox/index.d.ts index 977f32e249..e89e73a794 100644 --- a/types/detox/index.d.ts +++ b/types/detox/index.d.ts @@ -42,6 +42,16 @@ declare global { */ cleanup(): Promise; } + + // Detox exports all methods from detox global and all of the global constants. + interface DetoxExport extends Detox { + device: Device; + element: Element; + waitFor: WaitFor; + expect: Expect>; + by: Matchers; + } + interface Device { /** * Launch the app @@ -434,10 +444,6 @@ declare global { } } -export { by, detox, device, element, waitFor }; +declare const detoxExport: Detox.DetoxExport; -// Not exporting the global `expect` from the top of the file here -// because `expect` conflicts with the global `expect` of jest and -// therefore exporting it doesn't work. The global `expect` is kept -// for backwards compatibility though. -export const expect: Detox.Expect>; +export = detoxExport; diff --git a/types/detox/runners/jest/adapter/index.d.ts b/types/detox/runners/jest/adapter/index.d.ts index f479eda256..ca64f30820 100644 --- a/types/detox/runners/jest/adapter/index.d.ts +++ b/types/detox/runners/jest/adapter/index.d.ts @@ -9,4 +9,4 @@ interface DetoxJestAdapter { declare const adapter: DetoxJestAdapter; -export default adapter; +export = adapter; diff --git a/types/detox/runners/mocha/adapter/index.d.ts b/types/detox/runners/mocha/adapter/index.d.ts index 8e13b3bc01..3249031eee 100644 --- a/types/detox/runners/mocha/adapter/index.d.ts +++ b/types/detox/runners/mocha/adapter/index.d.ts @@ -6,4 +6,4 @@ interface DetoxMochaAdapter { declare const adapter: DetoxMochaAdapter; -export default adapter; +export = adapter; diff --git a/types/detox/test/detox-jest-setup-tests.ts b/types/detox/test/detox-jest-setup-tests.ts index 7a2a9a3901..1c38c3658f 100644 --- a/types/detox/test/detox-jest-setup-tests.ts +++ b/types/detox/test/detox-jest-setup-tests.ts @@ -2,7 +2,8 @@ declare var beforeAll: (callback: () => void) => void; declare var beforeEach: (callback: () => void) => void; declare var afterAll: (callback: () => void) => void; -import adapter from "detox/runners/jest/adapter"; +import detox = require("detox"); +import adapter = require("detox/runners/jest/adapter"); // Normally the Detox configuration from the project's package.json like so: // const config = require("./package.json").detox; diff --git a/types/detox/test/detox-mocha-setup-tests.ts b/types/detox/test/detox-mocha-setup-tests.ts index c415eed696..42e955ab4f 100644 --- a/types/detox/test/detox-mocha-setup-tests.ts +++ b/types/detox/test/detox-mocha-setup-tests.ts @@ -5,7 +5,8 @@ declare var beforeEach: (callback: () => void) => void; declare var after: (callback: () => void) => void; declare var afterEach: (callback: () => void) => void; -import adapter from "detox/runners/mocha/adapter"; +import * as detox from "detox"; +import * as adapter from "detox/runners/mocha/adapter"; // Normally the Detox configuration from the project's package.json like so: // const config = require("./package.json").detox; diff --git a/types/discord-rpc/index.d.ts b/types/discord-rpc/index.d.ts index 2d63e363b7..dbb6beeb39 100644 --- a/types/discord-rpc/index.d.ts +++ b/types/discord-rpc/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for discord-rpc 3.0 // Project: https://github.com/discordjs/RPC#readme // Definitions by: Jason Bothell +// Jack Baron // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { EventEmitter } from 'events'; @@ -66,6 +67,10 @@ export class Client extends EventEmitter { subscribe(event: string, args: any, callback: (data: any) => void): Promise; destroy(): Promise; + + on(event: 'ready' | 'connected', listener: () => void): this; + once(event: 'ready' | 'connected', listener: () => void): this; + off(event: 'ready' | 'connected', listener: () => void): this; } export interface RPCClientOptions { diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index 2f58d64a52..1a3eb0e39a 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -623,7 +623,7 @@ declare namespace Draft { interface DraftBlockRenderConfig { element: string; - wrapper?: React.ReactElement; + wrapper?: React.ReactNode; } class EditorState extends Record { diff --git a/types/driftless/driftless-tests.ts b/types/driftless/driftless-tests.ts new file mode 100644 index 0000000000..22df64c992 --- /dev/null +++ b/types/driftless/driftless-tests.ts @@ -0,0 +1,5 @@ +import * as driftless from "driftless"; + +driftless.setDriftlessTimeout(() => "OK", 10); // $ExpectType number +const interval = driftless.setDriftlessInterval((a) => "OK" + a, 100, "foo"); // $ExpectType number +driftless.clearDriftless(interval); // $ExpectType void diff --git a/types/driftless/index.d.ts b/types/driftless/index.d.ts new file mode 100644 index 0000000000..8fddd26dae --- /dev/null +++ b/types/driftless/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for driftless 2.0 +// Project: https://github.com/dbkaplun/driftless +// Definitions by: Dan Delany +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function setDriftlessTimeout( + callback: ((...args: any[]) => void) | string, + delayMs: number, + ...params: any[] +): number; + +export function setDriftlessInterval( + callback: ((...args: any[]) => void) | string, + delayMs: number, + ...params: any[] +): number; + +export function clearDriftless( + id: number, + options?: { + customClearTimeout?: (...args: any[]) => void; + } +): void; diff --git a/types/is-online/tsconfig.json b/types/driftless/tsconfig.json similarity index 94% rename from types/is-online/tsconfig.json rename to types/driftless/tsconfig.json index 7009c26024..3e61f98da4 100644 --- a/types/is-online/tsconfig.json +++ b/types/driftless/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "is-online-tests.ts" + "driftless-tests.ts" ] } diff --git a/types/is-online/tslint.json b/types/driftless/tslint.json similarity index 100% rename from types/is-online/tslint.json rename to types/driftless/tslint.json diff --git a/types/drivelist/index.d.ts b/types/drivelist/index.d.ts index d2acd039df..808cdf10af 100644 --- a/types/drivelist/index.d.ts +++ b/types/drivelist/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for drivelist 6.4 -// Project: https://github.com/resin-io-modules/drivelist +// Project: https://github.com/balena-io-modules/drivelist // Definitions by: Xiao Deng // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/electron-spellchecker/index.d.ts b/types/electron-spellchecker/index.d.ts index fc10d13f34..6db76278d2 100644 --- a/types/electron-spellchecker/index.d.ts +++ b/types/electron-spellchecker/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for electron-spellchecker 1.1 -// Project: https://github.com/paulcbetts/electron-spellchecker +// Project: https://github.com/electron-userland/electron-spellchecker // Definitions by: Daniel Perez Alvarez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 diff --git a/types/ember-data/index.d.ts b/types/ember-data/index.d.ts index 601a45faf3..6cb514556c 100644 --- a/types/ember-data/index.d.ts +++ b/types/ember-data/index.d.ts @@ -543,8 +543,9 @@ export namespace DS { * invoking the callback with the name of each relationship and its relationship * descriptor. */ - eachRelationship( - callback: (name: string, details: RelationshipMeta) => void, + eachRelationship( + this: T, + callback: (name: string, details: RelationshipMeta) => void, binding?: any ): any; /** diff --git a/types/ember-data/test/relationships.ts b/types/ember-data/test/relationships.ts index dee9519b34..13a526ba6a 100644 --- a/types/ember-data/test/relationships.ts +++ b/types/ember-data/test/relationships.ts @@ -26,7 +26,7 @@ p.eachRelationship((n, meta) => { let m: 'belongsTo' | 'hasMany' = meta.kind; }); -class Comment extends DS.Model { +export class Comment extends DS.Model { author = DS.attr('string'); } diff --git a/types/ember-data/test/store.ts b/types/ember-data/test/store.ts index 9c1194c711..b6bb25993c 100644 --- a/types/ember-data/test/store.ts +++ b/types/ember-data/test/store.ts @@ -1,6 +1,7 @@ import Ember from 'ember'; import DS from 'ember-data'; import { assertType } from './lib/assert'; +import { Comment } from './relationships'; declare const store: DS.Store; @@ -119,7 +120,7 @@ const MyRouteAsync = Ember.Route.extend({ const store = this.get('store'); return await store.findRecord('post-comment', 1); }, - async afterModel(): Promise> { + async afterModel(): Promise> { const post = await this.get('store').findRecord('post', 1); return await post.get('comments'); } @@ -132,7 +133,7 @@ class MyRouteAsyncES6 extends Ember.Route { async model(): Promise { return await this.store.findRecord('post-comment', 1); } - async afterModel(): Promise> { + async afterModel(): Promise> { const post = await this.store.findRecord('post', 1); return await post.get('comments'); } diff --git a/types/ember-data/tsconfig.json b/types/ember-data/tsconfig.json index f476362aaf..aadbbe7f5f 100644 --- a/types/ember-data/tsconfig.json +++ b/types/ember-data/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember-data/v2/index.d.ts b/types/ember-data/v2/index.d.ts index 3afd091ffe..e6dd65eb3b 100644 --- a/types/ember-data/v2/index.d.ts +++ b/types/ember-data/v2/index.d.ts @@ -525,7 +525,7 @@ export namespace DS { * invoking the callback with the name of each relationship and its relationship * descriptor. */ - eachRelationship(callback: (name: string, details: RelationshipMeta) => void, binding?: any): any; + eachRelationship(this: T, callback: (name: string, details: RelationshipMeta) => void, binding?: any): any; /** * Represents the model's class name as a string. This can be used to look up the model's class name through * `DS.Store`'s modelFor method. diff --git a/types/ember-data/v2/test/relationships.ts b/types/ember-data/v2/test/relationships.ts index 06795c0e26..21e66c6be5 100644 --- a/types/ember-data/v2/test/relationships.ts +++ b/types/ember-data/v2/test/relationships.ts @@ -26,7 +26,7 @@ p.eachRelationship((n, meta) => { let m: 'belongsTo' | 'hasMany' = meta.kind; }); -class Comment extends DS.Model { +export class Comment extends DS.Model { author = DS.attr('string'); } diff --git a/types/ember-data/v2/test/store.ts b/types/ember-data/v2/test/store.ts index 2584e7bdf3..902ea99852 100644 --- a/types/ember-data/v2/test/store.ts +++ b/types/ember-data/v2/test/store.ts @@ -1,6 +1,7 @@ import Ember from 'ember'; import DS from 'ember-data'; import { assertType } from './lib/assert'; +import { Comment } from './relationships'; declare const store: DS.Store; @@ -119,7 +120,7 @@ const MyRouteAsync = Ember.Route.extend({ const store = this.get('store'); return await store.findRecord('post-comment', 1); }, - async afterModel(): Promise> { + async afterModel(): Promise> { const post = await this.get('store').findRecord('post', 1); return await post.get('comments'); } @@ -132,7 +133,7 @@ class MyRouteAsyncES6 extends Ember.Route { async model(): Promise { return await this.store.findRecord('post-comment', 1); } - async afterModel(): Promise> { + async afterModel(): Promise> { const post = await this.store.findRecord('post', 1); return await post.get('comments'); } diff --git a/types/ember-feature-flags/tsconfig.json b/types/ember-feature-flags/tsconfig.json index 957a7a00f8..dc3260af3a 100644 --- a/types/ember-feature-flags/tsconfig.json +++ b/types/ember-feature-flags/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember-mocha/tsconfig.json b/types/ember-mocha/tsconfig.json index 4e9b406e2e..c6c6a09f65 100644 --- a/types/ember-mocha/tsconfig.json +++ b/types/ember-mocha/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember-modal-dialog/tsconfig.json b/types/ember-modal-dialog/tsconfig.json index 0b0b6f91fb..8fc7a37808 100644 --- a/types/ember-modal-dialog/tsconfig.json +++ b/types/ember-modal-dialog/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember-qunit/tsconfig.json b/types/ember-qunit/tsconfig.json index df4899b37c..92a555a59f 100644 --- a/types/ember-qunit/tsconfig.json +++ b/types/ember-qunit/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember-resolver/tsconfig.json b/types/ember-resolver/tsconfig.json index bc476c5723..7263220f71 100644 --- a/types/ember-resolver/tsconfig.json +++ b/types/ember-resolver/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember-test-helpers/tsconfig.json b/types/ember-test-helpers/tsconfig.json index 2e0ddf49b1..ca139535f3 100644 --- a/types/ember-test-helpers/tsconfig.json +++ b/types/ember-test-helpers/tsconfig.json @@ -35,6 +35,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index fbe058a643..d0f9896eb9 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -38,15 +38,17 @@ import { ComputedPropertyCallback, ObserverMethod } from '@ember/object/-private/types'; -import * as HandlebarsNamespace from 'handlebars'; + // Capitalization is intentional: this makes it much easier to re-export RSVP on // the Ember namespace. import Rsvp from 'rsvp'; + import { TemplateFactory } from 'htmlbars-inline-precompile'; import { Registry as ServiceRegistry } from '@ember/service'; import { Registry as ControllerRegistry } from '@ember/controller'; import * as EmberStringNs from '@ember/string'; +import * as EmberStringHandlebarsNs from '@ember/string/-private/handlebars'; // tslint:disable-next-line:no-duplicate-imports import * as EmberServiceNs from '@ember/service'; import * as EmberPolyfillsNs from '@ember/polyfills'; @@ -424,11 +426,12 @@ export namespace Ember { function K(): any; function createFrame(objec: any): any; function Exception(message: string): void; - const SafeString: typeof HandlebarsNamespace.SafeString; + class SafeString extends EmberStringHandlebarsNs.SafeString {} function parse(string: string): any; function print(ast: any): void; const logger: typeof Logger; function log(level: string, str: string): void; + function registerHelper(name: string, helper: any): void; } namespace String { const camelize: typeof EmberStringNs.camelize; diff --git a/types/ember/test/ember-tests.ts b/types/ember/test/ember-tests.ts index 01aaab7452..eb317c3ab1 100755 --- a/types/ember/test/ember-tests.ts +++ b/types/ember/test/ember-tests.ts @@ -92,10 +92,10 @@ App.userController = Ember.Object.create({ }), }); -Handlebars.registerHelper( +Ember.Handlebars.registerHelper( 'highlight', (property: string, options: any) => - new Handlebars.SafeString('' + 'some value' + '') + new Ember.Handlebars.SafeString('' + 'some value' + '') ); const coolView = App.CoolView.create(); diff --git a/types/ember/test/string.ts b/types/ember/test/string.ts index 4363b375f3..d812a52dd5 100644 --- a/types/ember/test/string.ts +++ b/types/ember/test/string.ts @@ -1,5 +1,5 @@ import Ember from 'ember'; -import { SafeString } from 'handlebars'; +import { SafeString } from '@ember/string/-private/handlebars'; const { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } = Ember.String; diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index be47225e72..6e494f5a03 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -36,6 +36,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember/v1/package.json b/types/ember/v1/package.json new file mode 100644 index 0000000000..77c0c562ac --- /dev/null +++ b/types/ember/v1/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "handlebars": "^4.1.0" + } +} diff --git a/types/ember/v2/package.json b/types/ember/v2/package.json new file mode 100644 index 0000000000..77c0c562ac --- /dev/null +++ b/types/ember/v2/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "handlebars": "^4.1.0" + } +} diff --git a/types/ember/v2/test/mixin.ts b/types/ember/v2/test/mixin.ts index a89f490a11..46566a9df9 100755 --- a/types/ember/v2/test/mixin.ts +++ b/types/ember/v2/test/mixin.ts @@ -6,7 +6,7 @@ interface EditableMixin { isEditing: boolean; } -const EditableMixin: Ember.Mixin = Ember.Mixin.create({ +const EditableMixin = Ember.Mixin.create({ edit() { this.get('controller'); console.log('starting to edit'); diff --git a/types/ember__string/-private/handlebars.d.ts b/types/ember__string/-private/handlebars.d.ts new file mode 100644 index 0000000000..8d8dce118c --- /dev/null +++ b/types/ember__string/-private/handlebars.d.ts @@ -0,0 +1,5 @@ +export class SafeString { + constructor(str: string); + toString(): string; + toHTML(): string; +} diff --git a/types/ember__string/ember__string-tests.ts b/types/ember__string/ember__string-tests.ts index 500c67546e..c6474cd266 100644 --- a/types/ember__string/ember__string-tests.ts +++ b/types/ember__string/ember__string-tests.ts @@ -1,5 +1,5 @@ import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w, isHTMLSafe } from '@ember/string'; -import { SafeString } from 'handlebars'; +import { SafeString } from '@ember/string/-private/handlebars'; dasherize(); // $ExpectError dasherize('blue man group'); // $ExpectType string @@ -37,7 +37,7 @@ const handlebarsSafeString: SafeString = htmlSafe('lorem ipsum...'); htmlSafe('lorem ipsum...'); // $ExpectType SafeString const regularString: string = htmlSafe('lorem ipsum...'); // $ExpectError -function isSafeTest(a: string|Handlebars.SafeString) { +function isSafeTest(a: string | SafeString) { if (isHTMLSafe(a)) { a = a.toString(); } diff --git a/types/ember__string/index.d.ts b/types/ember__string/index.d.ts index c25da1f823..2a65c9b5df 100644 --- a/types/ember__string/index.d.ts +++ b/types/ember__string/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { SafeString } from 'handlebars'; +import { SafeString } from "./-private/handlebars"; export function camelize(str: string): string; export function capitalize(str: string): string; diff --git a/types/ember__string/tsconfig.json b/types/ember__string/tsconfig.json index 100fad10f5..a5a7ecc944 100644 --- a/types/ember__string/tsconfig.json +++ b/types/ember__string/tsconfig.json @@ -15,13 +15,15 @@ "../" ], "paths": { - "@ember/string": ["ember__string"] + "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"] }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ + "-private/handlebars.d.ts", "index.d.ts", "ember__string-tests.ts" ] diff --git a/types/ember__test-helpers/tsconfig.json b/types/ember__test-helpers/tsconfig.json index 7b167f14d5..35638865d8 100644 --- a/types/ember__test-helpers/tsconfig.json +++ b/types/ember__test-helpers/tsconfig.json @@ -38,6 +38,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ember__test/tsconfig.json b/types/ember__test/tsconfig.json index da00f05337..bb95710392 100644 --- a/types/ember__test/tsconfig.json +++ b/types/ember__test/tsconfig.json @@ -36,6 +36,7 @@ "@ember/runloop/*": ["ember__runloop/*"], "@ember/service": ["ember__service"], "@ember/string": ["ember__string"], + "@ember/string/*": ["ember__string/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"], "@ember/utils": ["ember__utils"], diff --git a/types/ethereumjs-abi/ethereumjs-abi-tests.ts b/types/ethereumjs-abi/ethereumjs-abi-tests.ts index f48cdd323c..28626b6304 100644 --- a/types/ethereumjs-abi/ethereumjs-abi-tests.ts +++ b/types/ethereumjs-abi/ethereumjs-abi-tests.ts @@ -1,5 +1,17 @@ -import { methodID, soliditySHA256, soliditySHA3 } from 'ethereumjs-abi'; +import * as abi from 'ethereumjs-abi'; -methodID('foo', ['uint256', 'string']); -soliditySHA3(['uint256', 'string'], [0, 'Alice']); -soliditySHA256(['uint256', 'string'], [0, 'Alice']); +const types = ['uint256', 'string']; +const values = [0, 'Alice']; +const signature = 'foo(uint256,string):(uint256)'; +abi.eventID('foo', types); +abi.methodID('foo', types); +abi.soliditySHA3(types, values); +abi.soliditySHA256(types, values); +abi.solidityRIPEMD160(types, values); +const simpleEncoded = abi.simpleEncode(signature, ...values); +abi.simpleDecode(signature, simpleEncoded); +const rawEncoded = abi.rawEncode(types, values); +abi.rawDecode(types, rawEncoded); +abi.solidityPack(types, values); +const serpentSig = abi.toSerpent(['int256', 'bytes']); +abi.fromSerpent(serpentSig); diff --git a/types/ethereumjs-abi/index.d.ts b/types/ethereumjs-abi/index.d.ts index 98ea94a6fa..6380068984 100644 --- a/types/ethereumjs-abi/index.d.ts +++ b/types/ethereumjs-abi/index.d.ts @@ -1,12 +1,21 @@ // Type definitions for ethereumjs-abi 0.6 // Project: https://github.com/ethereumjs/ethereumjs-abi, https://github.com/axic/ethereumjs-abi // Definitions by: Leonid Logvinov +// Artur Kozak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// export function soliditySHA3(argTypes: string[], args: any[]): Buffer; export function soliditySHA256(argTypes: string[], args: any[]): Buffer; +export function solidityRIPEMD160(argTypes: string[], args: any[]): Buffer; +export function eventID(name: string, types: string[]): Buffer; export function methodID(name: string, types: string[]): Buffer; export function simpleEncode(signature: string, ...args: any[]): Buffer; -export function rawDecode(signature: string[], data: Buffer): any[]; +export function simpleDecode(signature: string, data: Buffer): any[]; +export function rawEncode(types: string[], values: any[]): Buffer; +export function rawDecode(types: string[], data: Buffer): any[]; +export function stringify(types: string[], values: any[]): string; +export function solidityPack(types: string[], values: any[]): Buffer; +export function fromSerpent(signature: string): string[]; +export function toSerpent(types: string[]): string; diff --git a/types/execa/execa-tests.ts b/types/execa/execa-tests.ts index ecc966d3d5..632388106e 100644 --- a/types/execa/execa-tests.ts +++ b/types/execa/execa-tests.ts @@ -43,8 +43,8 @@ execa.shell('echo unicorns').then(result => result.stdout.toLocaleLowerCase()); result = execa.shellSync('noop foo').stdout; } -execa('echo', ['unicorns']).stdout.pipe(process.stdout); -execa('echo', ['unicorns']).stderr.pipe(process.stderr); +execa('echo', ['unicorns']).stdout!.pipe(process.stdout); +execa('echo', ['unicorns']).stderr!.pipe(process.stderr); execa('forever', { extendEnv: false }).pid; execa('forever', { argv0: 'hi' }).pid; @@ -85,7 +85,7 @@ async () => { async () => { const child = execa('stdin'); - child.stdin.end('unicorns'); + child.stdin!.end('unicorns'); const { stdout } = await child; assert(stdout === 'unicorns'); }; @@ -104,7 +104,7 @@ async () => { stdio: [null, 'ignore', null] }); - child.stdout.setEncoding('utf8'); + child.stdout!.setEncoding('utf8'); assert(child.pid === 0); child.kill(); diff --git a/types/expectations/expectations-tests.ts b/types/expectations/expectations-tests.ts index 4e994e7546..8f8bd25985 100644 --- a/types/expectations/expectations-tests.ts +++ b/types/expectations/expectations-tests.ts @@ -1,6 +1,6 @@ // transplant from https://github.com/spmason/expectations/blob/695c25bd35bb1751533a8082a5aa378e3e1b381f/test/expect.tests.js -var root = this; +var root = window; // Stub mocha functions const {describe, it, before, after, beforeEach, afterEach} = null as any as { @@ -451,7 +451,7 @@ describe('expect', ()=> { describe('extensibility', ()=> { it('allows you to add your own assertions', ()=> { - expect.addAssertion('toBeFoo', ()=> { + expect.addAssertion('toBeFoo', function () { if (this.value === 'foo') { return this.pass(); } diff --git a/types/expectations/tsconfig.json b/types/expectations/tsconfig.json index 857a8a1eef..ea4017a1a3 100644 --- a/types/expectations/tsconfig.json +++ b/types/expectations/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": false, @@ -20,4 +21,4 @@ "index.d.ts", "expectations-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/expo-localization/index.d.ts b/types/expo-localization/index.d.ts index 21c6ca8756..b79c777319 100644 --- a/types/expo-localization/index.d.ts +++ b/types/expo-localization/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for expo-localization 1.0 -// Project: https://docs.expo.io/ +// Project: https://docs.expo.io/versions/latest/sdk/localization // Definitions by: Bartosz Dotryw // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index f2ce8d8197..ab34955ce2 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -37,6 +37,7 @@ import { LinearGradient, Linking, Location, + Localization, MailComposer, MapEvent, MapStyleElement, @@ -57,6 +58,16 @@ const reverseGeocode: Promise = Location.reverseGeocodeA longitude: 0 }); +Location.watchPositionAsync({ + accuracy: Location.Accuracy.BestForNavigation, + timeInterval: 10000, + distanceInterval: 0, + timeout: 10000 +}, (data) => { + data.coords; + data.timestamp; +}); + Accelerometer.addListener((obj) => { obj.x; obj.y; @@ -1094,6 +1105,28 @@ async () => { }; // #endregion +// #region Localization + +let locale: string = Localization.locale; +let locales: string[] = Localization.locales; +let country: string | undefined = Localization.country; +let isoCurrencyCodes: string[] | undefined = Localization.isoCurrencyCodes; +let timezone: string = Localization.timezone; +let isRTL: boolean = Localization.isRTL; + +async () => { + const localizationData = await Localization.getLocalizationAsync(); + + locale = localizationData.locale; + locales = localizationData.locales; + country = localizationData.country; + isoCurrencyCodes = localizationData.isoCurrencyCodes; + timezone = localizationData.timezone; + isRTL = localizationData.isRTL; +}; + +// #endregion + // #region Contacts Contacts.Fields.ID === 'id'; Contacts.Fields.Name === 'name'; diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 7e75c1b7d6..338a1c2989 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -2242,6 +2242,38 @@ export namespace Location { function stopGeofencingAsync(taskName: string): Promise; function hasStartedGeofencingAsync(taskName: string): Promise; function setApiKey(key: string): void; + + enum Accuracy { + Lowest = 1, + Low = 2, + Balanced = 3, + High = 4, + Highest = 5, + BestForNavigation = 6 + } +} + +/** + * Localization + */ +export namespace Localization { + const locale: string; + const locales: string[]; + const country: string | undefined; + const isoCurrencyCodes: string[] | undefined; + const timezone: string; + const isRTL: boolean; + + interface LocalizationData { + locale: string; + locales: string[]; + country?: string; + isoCurrencyCodes?: string[]; + timezone: string; + isRTL: boolean; + } + + function getLocalizationAsync(): Promise; } /** diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 5cc59d0941..8e973de1ab 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -103,7 +103,7 @@ export function log(...values: any[]): void; export function warn(...values: any[]): void; /////////////////////////////////////////////////////////////////////////////// -// Data Object Interfaces - These intrface are not specific part of fabric, +// Data Object Interfaces - These interface are not specific part of fabric, // They are just helpful for for defining function parameters ////////////////////////////////////////////////////////////////////////////// interface IDataURLOptions { @@ -135,12 +135,15 @@ interface IDataURLOptions { * Cropping height. Introduced in v1.2.14 */ height?: number; + enableRetinaScaling?: boolean; + withoutTransform?: boolean; + withoutShadow?: boolean; } interface IEvent { e: Event; target?: Object; - transform?: { corner: string }; + transform?: { corner: string }; } interface IFillOptions { @@ -175,6 +178,14 @@ interface IToSVGOptions { * Encoding of SVG output */ encoding: string; + /** + * desired width of svg with or without units + */ + width: number; + /** + * desired height of svg with or without units + */ + height: number; } interface IViewBox { @@ -329,6 +340,14 @@ interface ICanvasAnimation { * @chainable */ fxRemove(object: Object): T; + + /** + * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + * @chainable + */ + fxStraightenObject(object: Object): T; } interface IObjectAnimation { /** @@ -421,6 +440,12 @@ export class Color { */ toHex(): string; + /** + * Returns color representation in HEXA format + * @return {String} ex: FF5555CC + */ + toHexa(): string; + /** * Gets value of alpha channel for this color */ @@ -495,100 +520,87 @@ export class Color { interface IGradientOptions { /** - * @param [options.type] Type of gradient 'radial' or 'linear' + * Horizontal offset for aligning gradients coming from SVG when outside pathgroups + * @type Number */ + offsetX?: number; + /** + * Vertical offset for aligning gradients coming from SVG when outside pathgroups + * @type Number + */ + offsetY?: number; type?: string; - /** - * x-coordinate of start point - */ - x1?: number; - /** - * y-coordinate of start point - */ - y1?: number; - /** - * x-coordinate of end point - */ - x2?: number; - /** - * y-coordinate of end point - */ - y2?: number; - /** - * Radius of start point (only for radial gradients) - */ - r1?: number; - /** - * Radius of end point (only for radial gradients) - */ - r2?: number; + coords?: {x1?: number, y1?: number, x2?: number, y2?: number, r1?: number, r2?: number}; /** * Color stops object eg. {0:string; 1:string; */ colorStops?: any; + gradientTransform?: any; } -interface IGradient extends IGradientOptions { +export interface Gradient extends IGradientOptions { } +export class Gradient { /** * Adds another colorStop * @param colorStop Object with offset and color */ - addColorStop(colorStop: any): IGradient; + addColorStop(colorStop: any): Gradient; /** * Returns object representation of a gradient */ - toObject(): any; + toObject(propertiesToInclude?: any): any; /** * Returns SVG representation of an gradient - * @param object Object to create a gradient for - * @param normalize Whether coords should be normalized - * @return SVG representation of an gradient (linear/radial) + * @param {Object} object Object to create a gradient for + * @return {String} SVG representation of an gradient (linear/radial) */ - toSVG(object: Object, normalize?: boolean): string; - + toSVG(object: any): string; /** * Returns an instance of CanvasGradient * @param ctx Context to render on */ - toLive(ctx: CanvasRenderingContext2D, object?: PathGroup): CanvasGradient; -} -interface IGrandientStatic { - new(options?: IGradientOptions): IGradient; + toLive(ctx: CanvasRenderingContext2D): CanvasGradient; /** - * Returns instance from an SVG element - * @param el SVG gradient element + * Returns {@link fabric.Gradient} instance from an SVG element + * @static + * @memberOf fabric.Gradient + * @param {SVGGradientElement} el SVG gradient element + * @param {fabric.Object} instance + * @return {fabric.Gradient} Gradient instance + * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement + * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement */ - fromElement(el: SVGGradientElement, instance: Object): IGradient; + static fromElement(el: SVGGradientElement, instance: Object): Gradient; /** - * Returns instance from its object representation - * @param [options] Options object + * Returns {@link fabric.Gradient} instance from its object representation + * @static + * @memberOf fabric.Gradient + * @param {Object} obj + * @param {Object} [options] Options object */ - fromObject(obj: any, options: any[]): IGradient; + static forObject(obj: any, options?: IGradientOptions): Gradient; } - export class Intersection { constructor(status?: string); - /** * Appends a point to intersection */ - appendPoint(point: Point): void; + appendPoint(point: Point): Intersection; /** * Appends points to intersection */ - appendPoints(points: Point[]): void; - + appendPoints(points: Point[]): Intersection; /** - * Checks if polygon intersects another polygon + * Checks if one line intersects another */ - static intersectPolygonPolygon(points1: Point[], points2: Point[]): Intersection; + static intersectLineLine(a1: Point, a2: Point, b1: Point, b2: Point): Intersection; /** * Checks if line intersects polygon */ static intersectLinePolygon(a1: Point, a2: Point, points: Point[]): Intersection; /** - * Checks if one line intersects another + * Checks if polygon intersects another polygon */ - static intersectLineLine(a1: Point, a2: Point, b1: Point, b2: Point): Intersection; + static intersectPolygonPolygon(points1: Point[], points2: Point[]): Intersection; /** * Checks if polygon intersects rectangle */ @@ -599,231 +611,293 @@ interface IPatternOptions { /** * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) */ - repeat: string; + repeat?: string; /** * Pattern horizontal offset from object's left/top corner */ - offsetX: number; + offsetX?: number; /** * Pattern vertical offset from object's left/top corner */ - offsetY: number; + offsetY?: number; + /** + * crossOrigin value (one of "", "anonymous", "use-credentials") + * @see https://developer.mozilla.org/en-US/docs/HTML/CORS_settings_attributes + * @type String + */ + crossOrigin?: '' | 'anonymous' | 'use-credentials'; + /** + * Transform matrix to change the pattern, imported from svgs + */ + patternTransform?: number[]; /** * The source for the pattern */ source: string | HTMLImageElement; - /** - * Transform matrix to change the pattern, imported from svgs - */ - patternTransform?: number[]; } export interface Pattern extends IPatternOptions { } export class Pattern { constructor(options?: IPatternOptions); - - initialise(options?: IPatternOptions): Pattern; - /** - * Returns an instance of CanvasPattern - */ - toLive(ctx: CanvasRenderingContext2D): Pattern; - /** * Returns object representation of a pattern + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of a pattern instance */ - toObject(): any; + toObject(propertiesToInclude: any): any; /** * Returns SVG representation of a pattern + * @param {fabric.Object} object + * @return {String} SVG representation of a pattern */ toSVG(object: Object): string; + setOptions(options: IPatternOptions): void; + /** + * Returns an instance of CanvasPattern + * @param {CanvasRenderingContext2D} ctx Context to create pattern + * @return {CanvasPattern} + */ + toLive(ctx: CanvasRenderingContext2D): CanvasPattern; } - export class Point { x: number; y: number; - + type: string; constructor(x: number, y: number); - /** * Adds another point to this one and returns another one + * @param {fabric.Point} that + * @return {fabric.Point} new Point instance with added values */ add(that: Point): Point; - /** * Adds another point to this one + * @param {fabric.Point} that + * @return {fabric.Point} thisArg + * @chainable */ addEquals(that: Point): Point; - /** * Adds value to this point and returns a new one + * @param {Number} scalar + * @return {fabric.Point} new Point with added value */ scalarAdd(scalar: number): Point; - /** * Adds value to this point + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ scalarAddEquals(scalar: number): Point; - /** * Subtracts another point from this point and returns a new one + * @param {fabric.Point} that + * @return {fabric.Point} new Point object with subtracted values */ subtract(that: Point): Point; - /** * Subtracts another point from this point + * @param {fabric.Point} that + * @return {fabric.Point} thisArg + * @chainable */ subtractEquals(that: Point): Point; - /** * Subtracts value from this point and returns a new one + * @param {Number} scalar + * @return {fabric.Point} */ scalarSubtract(scalar: number): Point; - /** * Subtracts value from this point + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ scalarSubtractEquals(scalar: number): Point; - /** - * Miltiplies this point by a value and returns a new one + * Multiplies this point by a value and returns a new one + * @param {Number} scalar + * @return {fabric.Point} */ multiply(scalar: number): Point; - /** - * Miltiplies this point by a value + * Multiplies this point by a value + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ multiplyEquals(scalar: number): Point; - /** * Divides this point by a value and returns a new one + * @param {Number} scalar + * @return {fabric.Point} */ divide(scalar: number): Point; - /** * Divides this point by a value + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable */ divideEquals(scalar: number): Point; - /** * Returns true if this point is equal to another one + * @param {fabric.Point} that + * @return {Boolean} */ eq(that: Point): Point; - /** * Returns true if this point is less than another one + * @param {fabric.Point} that + * @return {Boolean} */ lt(that: Point): Point; - /** * Returns true if this point is less than or equal to another one + * @param {fabric.Point} that + * @return {Boolean} */ lte(that: Point): Point; - /** * Returns true if this point is greater another one + * @param {fabric.Point} that + * @return {Boolean} */ gt(that: Point): Point; - /** * Returns true if this point is greater than or equal to another one + * @param {fabric.Point} that + * @return {Boolean} */ gte(that: Point): Point; - /** * Returns new point which is the result of linear interpolation with this one and another one + * @param {fabric.Point} that + * @param {Number} t , position of interpolation, between 0 and 1 default 0.5 + * @return {fabric.Point} */ lerp(that: Point, t: number): Point; - /** * Returns distance from this point and another one + * @param {fabric.Point} that + * @return {Number} */ distanceFrom(that: Point): number; - /** * Returns the point between this point and another one + * @param {fabric.Point} that + * @return {fabric.Point} */ midPointFrom(that: Point): Point; - /** * Returns a new point which is the min of this and another one + * @param {fabric.Point} that + * @return {fabric.Point} */ min(that: Point): Point; - /** * Returns a new point which is the max of this and another one + * @param {fabric.Point} that + * @return {fabric.Point} */ max(that: Point): Point; - /** * Returns string representation of this point + * @return {String} */ toString(): string; - /** * Sets x/y of this point + * @param {Number} x + * @param {Number} y + * @chainable */ setXY(x: number, y: number): Point; - + /** + * Sets x of this point + * @param {Number} x + * @chainable + */ + setX(x: number): Point; + /** + * Sets y of this point + * @param {Number} y + * @chainable + */ + setY(y: number): Point; /** * Sets x/y of this point from another point + * @param {fabric.Point} that + * @chainable */ setFromPoint(that: Point): Point; - /** * Swaps x/y of this point and another point + * @param {fabric.Point} that */ swap(that: Point): Point; + /** + * return a cloned instance of the point + * @return {fabric.Point} + */ + clone(): Point; } - interface IShadowOptions { - /** - * Whether the shadow should affect stroke operations - */ - affectStrike: boolean; - /** - * Shadow blur - */ - blur: number; /** * Shadow color */ - color: string; + color?: string; /** - * Indicates whether toObject should include default values + * Shadow blur */ - includeDefaultValues: boolean; + blur?: number; /** * Shadow horizontal offset */ - offsetX: number; + offsetX?: number; /** * Shadow vertical offset */ - offsetY: number; + offsetY?: number; + /** + * Whether the shadow should affect stroke operations + */ + affectStrike?: boolean; + /** + * Indicates whether toObject should include default values + */ + includeDefaultValues?: boolean; } export interface Shadow extends IShadowOptions { } export class Shadow { - constructor(options?: IShadowOptions); + constructor(options?: IShadowOptions| string); initialize(options?: IShadowOptions | string): Shadow; /** - * Returns object representation of a shadow - */ - toObject(): any; - /** - * Returns a string representation of an instance, CSS3 text-shadow declaration + * Returns a string representation of an instance + * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow + * @return {String} Returns CSS3 text-shadow declaration */ toString(): string; /** * Returns SVG representation of a shadow + * @param {fabric.Object} object + * @return {String} SVG representation of a shadow */ toSVG(object: Object): string; - /** - * Regex matching shadow offsetX, offsetY and blur, Static + * Returns object representation of a shadow + * @return {Object} Object representation of a shadow instance + */ + toObject(): any; + /** + * Regex matching shadow offsetX, offsetY and blur (ex: "2px 2px 10px rgba(0,0,0,0.2)", "rgb(0,255,0) 2px 2px") + * @static + * @field + * @memberOf fabric.Shadow */ - reOffsetsAndBlur: RegExp; - static reOffsetsAndBlur: RegExp; } @@ -852,162 +926,239 @@ interface ICanvasDimensionsOptions { } interface IStaticCanvasOptions { - /** - * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas - */ - allowTouchScrolling?: boolean; - - /** - * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens - */ - enableRetinaScaling?: boolean; - - /** - * Indicates whether this canvas will use image smoothing, this is on by default in browsers - */ - imageSmoothingEnabled?: boolean; - - /** - * Indicates whether objects should remain in current stack position when selected. - * When false objects are brought to top and rendered as part of the selection group - */ - preserveObjectStacking?: boolean; - - /** - * The transformation (in the format of Canvas transform) which focuses the viewport - */ - viewportTransform?: number[]; - - freeDrawingColor?: string; - freeDrawingLineWidth?: number; - /** * Background color of canvas instance. - * Should be set via setBackgroundColor + * Should be set via {@link fabric.StaticCanvas#setBackgroundColor}. + * @type {(String|fabric.Pattern)} */ backgroundColor?: string | Pattern; /** * Background image of canvas instance. - * Should be set via setBackgroundImage - * Backwards incompatibility note: The "backgroundImageOpacity" and "backgroundImageStretch" properties are deprecated since 1.3.9. + * Should be set via {@link fabric.StaticCanvas#setBackgroundImage}. + * Backwards incompatibility note: The "backgroundImageOpacity" + * and "backgroundImageStretch" properties are deprecated since 1.3.9. + * Use {@link fabric.Image#opacity}, {@link fabric.Image#width} and {@link fabric.Image#height}. + * since 2.4.0 image caching is active, please when putting an image as background, add to the + * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom + * vale. As an alternative you can disable image objectCaching + * @type fabric.Image */ backgroundImage?: Image | string; - backgroundImageOpacity?: number; - backgroundImageStretch?: number; - /** - * Function that determines clipping of entire canvas area - * Being passed context as first argument. See clipping canvas area - */ - clipTo?(context: CanvasRenderingContext2D): void; - - /** - * Indicates whether object controls (borders/controls) are rendered above overlay image - */ - controlsAboveOverlay?: boolean; - - /** - * Indicates whether toObject/toDatalessObject should include default values - */ - includeDefaultValues?: boolean; /** * Overlay color of canvas instance. - * Should be set via setOverlayColor + * Should be set via {@link fabric.StaticCanvas#setOverlayColor} + * @since 1.3.9 + * @type {(String|fabric.Pattern)} */ overlayColor?: string | Pattern; /** * Overlay image of canvas instance. - * Should be set via setOverlayImage - * Backwards incompatibility note: The "overlayImageLeft" and "overlayImageTop" properties are deprecated since 1.3.9. + * Should be set via {@link fabric.StaticCanvas#setOverlayImage}. + * Backwards incompatibility note: The "overlayImageLeft" + * and "overlayImageTop" properties are deprecated since 1.3.9. + * Use {@link fabric.Image#left} and {@link fabric.Image#top}. + * since 2.4.0 image caching is active, please when putting an image as overlay, add to the + * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom + * vale. As an alternative you can disable image objectCaching + * @type fabric.Image */ overlayImage?: Image; - overlayImageLeft?: number; - overlayImageTop?: number; /** - * Indicates whether add, insertAt and remove should also re-render canvas. - * Disabling this option could give a great performance boost when adding/removing a lot of objects to/from canvas at once - * (followed by a manual rendering after addition/deletion) + * Indicates whether toObject/toDatalessObject should include default values + * if set to false, takes precedence over the object value. + * @type Boolean + */ + includeDefaultValues?: boolean; + /** + * Indicates whether objects' state should be saved + * @type Boolean + */ + stateful?: boolean; + /** + * Indicates whether {@link fabric.Collection.add}, {@link fabric.Collection.insertAt} and {@link fabric.Collection.remove}, + * {@link fabric.StaticCanvas.moveTo}, {@link fabric.StaticCanvas.clear} and many more, should also re-render canvas. + * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once + * since the renders are quequed and executed one per frame. + * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() ) + * Left default to true to do not break documentation and old app, fiddles. + * @type Boolean */ renderOnAddRemove?: boolean; /** - * Indicates whether objects' state should be saved + * Function that determines clipping of entire canvas area + * Being passed context as first argument. + * If you are using code minification, ctx argument can be minified/manglied you should use + * as a workaround `var ctx = arguments[0];` in the function; + * See clipping canvas area in {@link https://github.com/kangax/fabric.js/wiki/FAQ} + * @deprecated since 2.0.0 + * @type Function */ - stateful?: boolean; + clipTo?(context: CanvasRenderingContext2D): void; + /** + * Indicates whether object controls (borders/controls) are rendered above overlay image + * @type Boolean + */ + controlsAboveOverlay?: boolean; + /** + * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas + * @type Boolean + */ + allowTouchScrolling?: boolean; + /** + * Indicates whether this canvas will use image smoothing, this is on by default in browsers + */ + imageSmoothingEnabled?: boolean; + /** + * The transformation (in the format of Canvas transform) which focuses the viewport + */ + viewportTransform?: number[]; + /** + * if set to false background image is not affected by viewport transform + * @since 1.6.3 + * @type Boolean + */ + backgroundVpt?: boolean; + /** + * if set to false overlay image is not affected by viewport transform + * @since 1.6.3 + * @type Boolean + */ + overlayVpt?: boolean; + /** + * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens + * @type Boolean + */ + enableRetinaScaling?: boolean; + /** + * Describe canvas element extension over design + * properties are tl,tr,bl,br. + * if canvas is not zoomed/panned those points are the four corner of canvas + * if canvas is viewportTransformed you those points indicate the extension + * of canvas element in plain untrasformed coordinates + * The coordinates get updated with @method calcViewportBoundaries. + * @memberOf fabric.StaticCanvas.prototype + */ + vptCoords?: {tl: number, tr: number, bl: number, br: number} + /** + * Based on vptCoords and object.aCoords, skip rendering of objects that + * are not included in current viewport. + * May greatly help in applications with crowded canvas and use of zoom/pan + * If One of the corner of the bounding box of the object is on the canvas + * the objects get rendered. + * @memberOf fabric.StaticCanvas.prototype + * @type Boolean + */ + skipOffscreen?: boolean; + /** + * a fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the canvas has rendered, and the context is placed in the + * top left corner of the canvas. + * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true + * @type fabric.Object + */ + clipPath?: Object; + /** + * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, + * a zoomed canvas will then produce zoomed SVG output. + * @type Boolean + */ + svgViewportTransformation?: boolean; + } export interface StaticCanvas extends IObservable, IStaticCanvasOptions, ICollection, ICanvasAnimation { } export class StaticCanvas { /** * Constructor - * @param element element to initialize instance on - * @param [options] Options object + * @param {HTMLElement | String} el element to initialize instance on + * @param {Object} [options] Options object + * @return {Object} thisArg */ constructor(element: HTMLCanvasElement | string, options?: ICanvasOptions); /** * Calculates canvas element offset relative to the document * This method is also attached as "resize" event handler of window + * @return {fabric.Canvas} instance + * @chainable */ - calcOffset(): this; + calcOffset(): Canvas; /** * Sets {@link fabric.StaticCanvas#overlayImage|overlay image} for this canvas - * @param image fabric.Image instance or URL of an image to set overlay to - * @param callback callback to invoke when image is loaded and set as an overlay - * @param [options] Optional options to set for the {@link fabric.Image|overlay image}. + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set overlay to + * @param {Function} callback callback to invoke when image is loaded and set as an overlay + * @param {Object} [options] Optional options to set for the {@link fabric.Image|overlay image}. + * @return {fabric.Canvas} thisArg + * @chainable */ - setOverlayImage(image: Image | string, callback: (img: HTMLImageElement) => void, options?: IImageOptions): this; + setOverlayImage(image: Image | string, callback: Function, options?: IImageOptions): Canvas; /** * Sets {@link fabric.StaticCanvas#backgroundImage|background image} for this canvas - * @param image fabric.Image instance or URL of an image to set background to - * @param callback Callback to invoke when image is loaded and set as background - * @param [options] Optional options to set for the {@link fabric.Image|background image}. + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set background to + * @param {Function} callback Callback to invoke when image is loaded and set as background + * @param {Object} [options] Optional options to set for the {@link fabric.Image|background image}. + * @return {fabric.Canvas} thisArg + * @chainable */ - setBackgroundImage(image: Image | string, callback?: (img: HTMLImageElement) => void, options?: IImageOptions): this; + setBackgroundImage(image: Image | string, callback: Function, options?: IImageOptions): Canvas; /** - * Sets {@link fabric.StaticCanvas#overlayColor|background color} for this canvas - * @param overlayColor Color or pattern to set background color to - * @param callback Callback to invoke when background color is set + * Sets {@link fabric.StaticCanvas#overlayColor|foreground color} for this canvas + * @param {(String|fabric.Pattern)} overlayColor Color or pattern to set foreground color to + * @param {Function} callback Callback to invoke when foreground color is set + * @return {fabric.Canvas} thisArg + * @chainable */ - setOverlayColor(overlayColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): this; + setOverlayColor(overlayColor: string | Pattern, callback: Function): Canvas; /** * Sets {@link fabric.StaticCanvas#backgroundColor|background color} for this canvas - * @param backgroundColor Color or pattern to set background color to - * @param callback Callback to invoke when background color is set + * @param {(String|fabric.Pattern)} backgroundColor Color or pattern to set background color to + * @param {Function} callback Callback to invoke when background color is set + * @return {fabric.Canvas} thisArg + * @chainable */ - setBackgroundColor(backgroundColor: string | Pattern, callback: (pattern: Pattern | undefined) => void): StaticCanvas; + setBackgroundColor(backgroundColor: string | Pattern, callback: Function): Canvas; /** * Returns canvas width (in px) + * @return {Number} */ getWidth(): number; /** * Returns canvas height (in px) + * @return {Number} */ getHeight(): number; /** * Sets width of this canvas instance - * @param value Value to set width to - * @param [options] Options object + * @param {Number|String} value Value to set width to + * @param {Object} [options] Options object + * @return {fabric.Canvas} instance + * @chainable true */ - setWidth(value: number | string, options?: ICanvasDimensionsOptions): this; + setWidth(value: number | string, options?: ICanvasDimensionsOptions): Canvas; /** * Sets height of this canvas instance * @param value Value to set height to * @param [options] Options object + * @return {fabric.Canvas} instance + * @chainable true */ - setHeight(value: number | string, options?: ICanvasDimensionsOptions): this; + setHeight(value: number | string, options?: ICanvasDimensionsOptions): Canvas; /** * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em) * @param dimensions Object with width/height properties * @param [options] Options object + * @return {fabric.Canvas} thisArg + * @chainable */ - setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): this; + setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): Canvas; /** * Returns canvas zoom level @@ -1016,191 +1167,295 @@ export class StaticCanvas { /** * Sets viewport transform of this canvas instance - * @param vpt the transform in the form of context.transform + * @param {Array} vpt the transform in the form of context.transform + * @return {fabric.Canvas} instance + * @chainable */ - setViewportTransform(vpt: number[]): this; + setViewportTransform(vpt: number[]): Canvas; /** * Sets zoom level of this canvas instance, zoom centered around point - * @param point to zoom with respect to - * @param value to set zoom to, less than 1 zooms out + * @param {fabric.Point} point to zoom with respect to + * @param {Number} value to set zoom to, less than 1 zooms out + * @return {fabric.Canvas} instance + * @chainable true */ - zoomToPoint(point: Point, value: number): this; + zoomToPoint(point: Point, value: number): Canvas; /** * Sets zoom level of this canvas instance - * @param value to set zoom to, less than 1 zooms out + * @param {Number} value to set zoom to, less than 1 zooms out + * @return {fabric.Canvas} instance + * @chainable */ - setZoom(value: number): this; + setZoom(value: number): Canvas; /** * Pan viewport so as to place point at top left corner of canvas - * @param point to move to + * @param {fabric.Point} point to move to + * @return {fabric.Canvas} instance + * @chainable */ - absolutePan(point: Point): this; + absolutePan(point: Point): Canvas; /** * Pans viewpoint relatively - * @param point (position vector) to move by + * @param {fabric.Point} point (position vector) to move by + * @return {fabric.Canvas} instance + * @chainable */ - relativePan(point: Point): this; + relativePan(point: Point): Canvas; /** * Returns element corresponding to this instance + * @return {HTMLCanvasElement} */ getElement(): HTMLCanvasElement; - /** - * Returns currently selected object, if any - */ - getActiveObject(): Object; - - /** - * Returns currently selected group of object, if any - */ - getActiveGroup(): Group; - /** * Clears specified context of canvas element * @param ctx Context to clear * @chainable */ - clearContext(ctx: CanvasRenderingContext2D): this; + clearContext(ctx: CanvasRenderingContext2D): Canvas; /** * Returns context of canvas where objects are drawn + * @return {CanvasRenderingContext2D} */ getContext(): CanvasRenderingContext2D; /** * Clears all contexts (background, main, top) of an instance - */ - clear(): this; - - /** - * Renders both the top canvas and the secondary container canvas. - * @param [allOnTop] Whether we want to force all images to be rendered on the top canvas + * @return {fabric.Canvas} thisArg * @chainable */ - renderAll(allOnTop?: boolean): this; + clear(): Canvas; /** - * Append a renderAll request to next animation frame. a boolean flag will avoid appending more. + * Renders the canvas + * @return {fabric.Canvas} instance * @chainable */ - requestRenderAll(): this; + renderAll(): Canvas; /** - * Method to render only the top canvas. - * Also used to render the group selection box. + * Function created to be instance bound at initialization + * used in requestAnimationFrame rendering + * Let the fabricJS call it. If you call it manually you could have more + * animationFrame stacking on to of each other + * for an imperative rendering, use canvas.renderAll + * @private + * @return {fabric.Canvas} instance * @chainable */ - renderTop(): StaticCanvas; + renderAndReset(): Canvas; + + /** + * Append a renderAll request to next animation frame. + * unless one is already in progress, in that case nothing is done + * a boolean flag will avoid appending more. + * @return {fabric.Canvas} instance + * @chainable + */ + requestRenderAll(): Canvas; + + /** + * Calculate the position of the 4 corner of canvas with current viewportTransform. + * helps to determinate when an object is in the current rendering viewport using + * object absolute coordinates ( aCoords ) + * @return {Object} points.tl + * @chainable + */ + calcViewportBoundaries(): {tl: Point, br: Point, tr: Point, bl: Point}; + + /** + * Renders background, objects, overlay and controls. + * @param {CanvasRenderingContext2D} ctx + * @param {Array} objects to render + * @return {fabric.Canvas} instance + * @chainable + */ + renderCanvas(ctx: CanvasRenderingContext2D, objects: Object[] ): Canvas; + + /** + * Paint the cached clipPath on the lowerCanvasEl + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawClipPathOnCanvas(ctx: CanvasRenderingContext2D): void; /** * Returns coordinates of a center of canvas. * Returned value is an object with top and left properties + * @return {Object} object with "top" and "left" number values */ getCenter(): { top: number; left: number; }; - /** - * Centers object horizontally. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param object Object to center horizontally - */ - centerObjectH(object: Object): this; /** - * Centers object vertically. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param object Object to center vertically + * Centers object horizontally in the canvas + * @param {fabric.Object} object Object to center horizontally + * @return {fabric.Canvas} thisArg */ - centerObjectV(object: Object): this; + centerObjectH(object: Object): Canvas; /** - * Centers object vertically and horizontally. - * You might need to call `setCoords` on an object after centering, to update controls area. - * @param object Object to center vertically and horizontally + * Centers object vertically in the canvas + * @param {fabric.Object} object Object to center vertically + * @return {fabric.Canvas} thisArg + * @chainable */ - centerObject(object: Object): this; + centerObjectV(object: Object): Canvas; + + /** + * Centers object vertically and horizontally in the canvas + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + centerObject(object: Object): Canvas; + + /** + * Centers object vertically and horizontally in the viewport + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObject(object: Object): Canvas; + + /** + * Centers object horizontally in the viewport, object.top is unchanged + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObjectH(object: Object): Canvas; + + /** + * Centers object Vertically in the viewport, object.top is unchanged + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObjectV(object: Object): Canvas; + + /** + * Calculate the point in canvas that correspond to the center of actual viewport. + * @return {fabric.Point} vpCenter, viewport center + */ + getVpCenter(): Point; /** * Returs dataless JSON representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {String} json string */ toDatalessJSON(propertiesToInclude?: string[]): string; /** * Returns object representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance */ toObject(propertiesToInclude?: string[]): any; /** * Returns dataless object representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance */ toDatalessObject(propertiesToInclude?: string[]): any; - /** - * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, - * a zoomed canvas will then produce zoomed SVG output. - */ - svgViewportTransformation: boolean; - /** * Returns SVG representation of canvas * @param [options] Options object for SVG output * @param [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation. + * @return {String} SVG string */ - toSVG(options: IToSVGOptions, reviver?: Function): string; + toSVG(options?: IToSVGOptions, reviver?: Function): string; /** - * Moves an object to the bottom of the stack of drawn objects - * @param object Object to send to back + * Moves an object or the objects of a multiple selection + * to the bottom of the stack of drawn objects + * @param {fabric.Object} object Object to send to back + * @return {fabric.Canvas} thisArg * @chainable */ - sendToBack(object: Object): this; + sendToBack(object: Object): Canvas; /** - * Moves an object to the top of the stack of drawn objects - * @param object Object to send + * Moves an object or the objects of a multiple selection + * to the top of the stack of drawn objects + * @param {fabric.Object} object Object to send + * @return {fabric.Canvas} thisArg * @chainable */ - bringToFront(object: Object): this; + bringToFront(object: Object): Canvas; /** - * Moves an object down in stack of drawn objects - * @param object Object to send - * @param [intersecting] If `true`, send object behind next lower intersecting object + * Moves an object or a selection down in stack of drawn objects + * An optional paramter, intersecting allowes to move the object in behind + * the first intersecting object. Where intersection is calculated with + * bounding box. If no intersection is found, there will not be change in the + * stack. + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object + * @return {fabric.Canvas} thisArg * @chainable */ - sendBackwards(object: Object): this; + sendBackwards(object: Object, intersecting?: boolean): Canvas; /** - * Moves an object up in stack of drawn objects - * @param object Object to send - * @param [intersecting] If `true`, send object in front of next upper intersecting object + * Moves an object or a selection up in stack of drawn objects + * An optional paramter, intersecting allowes to move the object in front + * of the first intersecting object. Where intersection is calculated with + * bounding box. If no intersection is found, there will not be change in the + * stack. + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object + * @return {fabric.Canvas} thisArg * @chainable */ - bringForward(object: Object): this; + bringForward(object: Object, intersecting?: boolean): Canvas; + /** * Moves an object to specified level in stack of drawn objects - * @param object Object to send - * @param index Position to move to + * @param {fabric.Object} object Object to send + * @param {Number} index Position to move to + * @return {fabric.Canvas} thisArg * @chainable */ - moveTo(object: Object, index: number): this; + moveTo(object: Object, index: number): Canvas; /** - * Clears a canvas element and removes all event listeners - */ - dispose(): this; + * Clears a canvas element and dispose objects + * @return {fabric.Canvas} thisArg + * @chainable */ + dispose(): Canvas; /** * Returns a string representation of an instance + * @return {String} string representation of an instance */ toString(): string; + /** + * @static + * @type String + * @default + */ + static EMPTY_JSON: string; + + /** + * Provides a way to check support of some of the canvas methods + * (either those of HTMLCanvasElement itself, or rendering context) + * + * @param {String} methodName Method to check support for; + * Could be one of "setLineDash" + * @return {Boolean | null} `true` if method is supported (or at least exists), + * `null` if canvas element or context can not be initialized + */ + supports(methodName: "getImageData" | "toDataURL" | "toDataURLWithQuality" | "setLineDash"): boolean; + /** * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately * @param [options] Options object @@ -1208,29 +1463,17 @@ export class StaticCanvas { toDataURL(options?: IDataURLOptions): string; /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - * @return `true` if method is supported (or at least exists), null` if canvas element or context can not be initialized + * Returns JSON representation of canvas + * @param [propertiesToInclude] Any properties that you might want to additionally include in the output */ - supports(methodName: "getImageData" | "toDataURL" | "toDataURLWithQuality" | "setLineDash"): boolean; + static toJSON(propertiesToInclude?: string[]): string; - /** - * Populates canvas with data from the specified JSON. - * JSON format must conform to the one of toJSON formats - * @param json JSON string or object - * @param callback Callback, invoked when json is parsed - * and corresponding objects (e.g: {@link fabric.Image}) - * are initialized - * @param [reviver] Method for further parsing of JSON elements, called after each fabric object created. - */ - loadFromJSON(json: string | any, callback: () => void, reviver?: Function): this; /** * Clones canvas instance * @param [callback] Receives cloned instance as a first argument * @param [properties] Array of properties to include in the cloned canvas and children */ - clone(callback: (canvas: StaticCanvas) => void, properties?: string[]): void; + clone(callback?: any, properties?: string[]): void; /** * Clones canvas instance without cloning existing data. @@ -1238,48 +1481,72 @@ export class StaticCanvas { * but leaves data empty (so that you can populate it with your own) * @param [callback] Receives cloned instance as a first argument */ - cloneWithoutData(callback: (canvas: StaticCanvas) => void): void; + cloneWithoutData(callback?: any): void; /** - * Callback; invoked right before object is about to be scaled/rotated + * Populates canvas with data from the specified dataless JSON. + * JSON format must conform to the one of {@link fabric.Canvas#toDatalessJSON} + * @deprecated since 1.2.2 + * @param {String|Object} json JSON string or object + * @param {Function} callback Callback, invoked when json is parsed + * and corresponding objects (e.g: {@link fabric.Image}) + * are initialized + * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. + * @return {fabric.Canvas} instance + * @chainable + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization} */ - onBeforeScaleRotate(target: Object): void; - - // Functions from object straighten mixin - // -------------------------------------------------------------------------------------------------------------------------------- - + loadFromDatalessJSON(json: any, callback: Function, reviver?: Function): Canvas; + /** + * Populates canvas with data from the specified JSON. + * JSON format must conform to the one of {@link fabric.Canvas#toJSON} + * @param {String|Object} json JSON string or object + * @param {Function} callback Callback, invoked when json is parsed + * and corresponding objects (e.g: {@link fabric.Image}) + * are initialized + * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. + * @return {fabric.Canvas} instance + */ + loadFromJSON(json: any, callback: Function, reviver?: Function): Canvas; + /** + * Creates markup containing SVG font faces, + * font URLs for font faces must be collected by developers + * and are not extracted from the DOM by fabricjs + * @param {Array} objects Array of fabric objects + * @return {String} + */ + createSVGFontFacesMarkup(objects: any[]): string; + /** + * Creates markup containing SVG referenced elements like patterns, gradients etc. + * @return {String} + */ + createSVGRefElementsMarkup(): string; /** * Straightens object, then rerenders canvas - * @param object Object to straighten + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + * @chainable */ - straightenObject(object: Object): this; - - /** - * Same as straightenObject, but animated - * @param object Object to straighten - */ - fxStraightenObject(object: Object): this; - - static EMPTY_JSON: string; - /** - * Provides a way to check support of some of the canvas methods - * (either those of HTMLCanvasElement itself, or rendering context) - * @param methodName Method to check support for; Could be one of "getImageData", "toDataURL", "toDataURLWithQuality" or "setLineDash" - */ - static supports(methodName: "getImageData" | "toDataURL" | "toDataURLWithQuality" | "setLineDash"): boolean; - /** - * Returns JSON representation of canvas - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - static toJSON(propertiesToInclude?: string[]): string; + straightenObject(object: Object): Canvas; } interface ICanvasOptions extends IStaticCanvasOptions { /** * When true, objects can be transformed by one side (unproportionally) + * @type Boolean */ uniScaleTransform?: boolean; + /** + * Indicates which key enable unproportional scaling + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + */ + uniScaleKey?: string; + /** * When true, objects use center point as the origin of scale transformation. * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). @@ -1292,6 +1559,28 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ centeredRotation?: boolean; + /** + * Indicates which key enable centered Transform + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + * @default + */ + centeredKey?: string; + + /** + * Indicates which key enable alternate action on corner + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + * @default + */ + altActionKey?: string; + /** * Indicates that canvas is interactive. This property should not be changed. */ @@ -1302,6 +1591,32 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ selection?: boolean; + /** + * Indicates which key or keys enable multiple click selection + * Pass value as a string or array of strings + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or empty or containing any other string that is not a modifier key + * feature is disabled. + * @since 1.6.2 + * @type String|Array + * @default + */ + selectionKey?: string | string[]; + + /** + * Indicates which key enable alternative selection + * in case of target overlapping with active object + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * For a series of reason that come from the general expectations on how + * things should work, this feature works only for preserveObjectStacking true. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled. + * @since 1.6.5 + * @type null|String + * @default + */ + altSelectionKey?: string | null; + /** * Color of selection */ @@ -1311,7 +1626,7 @@ interface ICanvasOptions extends IStaticCanvasOptions { * Default dash array pattern * If not empty the selection border is dashed */ - selectionDashArray?: any[]; + selectionDashArray?: number[]; /** * Color of the border of selection (usually slightly darker than color of selection itself) @@ -1323,6 +1638,13 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ selectionLineWidth?: number; + /** + * Select only shapes that are fully contained in the dragged selection rectangle. + * @type Boolean + * @default + */ + selectionFullyContained?: boolean; + /** * Default cursor value used when hovering over an object on canvas */ @@ -1348,6 +1670,14 @@ interface ICanvasOptions extends IStaticCanvasOptions { */ rotationCursor?: string; + /** + * Cursor value used for disabled elements ( corners with disabled action ) + * @type String + * @since 2.0.0 + * @default + */ + notAllowedCursor?: string; + /** * Default element class that's given to wrapper (div) element of canvas */ @@ -1374,6 +1704,54 @@ interface ICanvasOptions extends IStaticCanvasOptions { * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas. */ isDrawingMode?: boolean; + + /** + * Indicates whether objects should remain in current stack position when selected. + * When false objects are brought to top and rendered as part of the selection group + * @type Boolean + */ + preserveObjectStacking?: boolean; + + /** + * Indicates the angle that an object will lock to while rotating. + * @type Number + * @since 1.6.7 + */ + snapAngle?: number; + + /** + * Indicates the distance from the snapAngle the rotation will lock to the snapAngle. + * When `null`, the snapThreshold will default to the snapAngle. + * @type null|Number + * @since 1.6.7 + * @default + */ + snapThreshold?: null | number; + + /** + * Indicates if the right click on canvas can output the context menu or not + * @type Boolean + * @since 1.6.5 + * @default + */ + stopContextMenu?: boolean; + + /** + * Indicates if the canvas can fire right click events + * @type Boolean + * @since 1.6.5 + * @default + */ + fireRightClick?: boolean; + + /** + * Indicates if the canvas can fire middle click events + * @type Boolean + * @since 1.7.8 + * @default + */ + fireMiddleClick?: boolean; + } export interface Canvas extends StaticCanvas { } export interface Canvas extends ICanvasOptions { } @@ -1386,106 +1764,129 @@ export class Canvas { constructor(element: HTMLCanvasElement | string, options?: ICanvasOptions); _objects: Object[]; - /** - * Checks if point is contained within an area of given object - * @param e Event object - * @param target Object to test against - */ - containsPoint(e: Event, target: Object): boolean; - /** - * Deactivates all objects on canvas, removing any active group or object - * @return thisArg - */ - deactivateAll(): Canvas; - /** - * Deactivates all objects and dispatches appropriate events - * @param [e] Event (passed along when firing) - * @return thisArg - */ - deactivateAllWithDispatch(e?: Event): Canvas; - /** - * Discards currently active group - * @param [e] Event (passed along when firing) - * @return thisArg - */ - discardActiveGroup(e?: Event): Canvas; - /** - * Discards currently active object - * @param [e] Event (passed along when firing) - * @return thisArg + * Renders both the top canvas and the secondary container canvas. + * @return {fabric.Canvas} instance * @chainable */ - discardActiveObject(e?: Event): Canvas; + renderAll(): Canvas; /** - * Draws objects' controls (borders/controls) - * @param ctx Context to render controls on + * Method to render only the top canvas. + * Also used to render the group selection box. + * @return {fabric.Canvas} thisArg + * @chainable */ - drawControls(ctx: CanvasRenderingContext2D): void; + renderTop(): Canvas; + /** + * Checks if point is contained within an area of given object + * @param {Event} e Event object + * @param {fabric.Object} target Object to test against + * @param {Object} [point] x,y object of point coordinates we want to check. + * @return {Boolean} true if point is contained within an area of given object + */ + containsPoint(e: Event, target: Object, point?: {x: number, y: number}): boolean; + /** + * Returns true if object is transparent at a certain location + * @param {fabric.Object} target Object to check + * @param {Number} x Left coordinate + * @param {Number} y Top coordinate + * @return {Boolean} + */ + isTargetTransparent(target: Object, x: number, y: number): boolean; + /** + * Set the cursor type of the canvas element + * @param {String} value Cursor type of the canvas element. + * @see http://www.w3.org/TR/css3-ui/#cursor + */ + setCursor(value: string): void; /** * Method that determines what object we are clicking on - * @param e mouse event - * @param skipGroup when true, group is skipped and only objects are traversed through + * the skipGroup parameter is for internal use, is needed for shift+click action + * @param {Event} e mouse event + * @param {Boolean} skipGroup when true, activeGroup is skipped and only objects are traversed through + * @return {fabric.Object} the target found */ - findTarget(e: MouseEvent, skipGroup: boolean): Canvas; + findTarget(e: MouseEvent, skipGroup: boolean): Object; /** - * Returns currently active group - * @return Current group + * Returns pointer coordinates without the effect of the viewport + * @param {Object} pointer with "x" and "y" number values + * @return {Object} object with "x" and "y" number values */ - getActiveGroup(): Group; - /** - * Returns currently active object - * @return active object - */ - getActiveObject(): Object; - /** - * Returns an array with the current selected objects - * @return {Object[]} array of active objects - */ - getActiveObjects(): Object[]; + restorePointerVpt(pointer: Point): any; /** * Returns pointer coordinates relative to canvas. - * @return object with "x" and "y" number values + * Can return coordinates with or without viewportTransform. + * ignoreZoom false gives back coordinates that represent + * the point clicked on canvas element. + * ignoreZoom true gives back coordinates after being processed + * by the viewportTransform ( sort of coordinates of what is displayed + * on the canvas where you are clicking. + * ignoreZoom true = HTMLElement coordinates relative to top,left + * ignoreZoom false, default = fabric space coordinates, the same used for shape position + * To interact with your shapes top and left you want to use ignoreZoom true + * most of the time, while ignoreZoom false will give you coordinates + * compatible with the object.oCoords system. + * of the time. + * @param {Event} e + * @param {Boolean} ignoreZoom + * @return {Object} object with "x" and "y" number values */ - getPointer(e: Event, ignoreZoom?: boolean, upperCanvasEl?: CanvasRenderingContext2D): { x: number; y: number; }; + getPointer(e: Event, ignoreZoom?: boolean): { x: number; y: number; }; /** * Returns context of canvas where object selection is drawn + * @return {CanvasRenderingContext2D} */ getSelectionContext(): CanvasRenderingContext2D; /** * Returns element on which object selection is drawn + * @return {HTMLCanvasElement} */ getSelectionElement(): HTMLCanvasElement; /** - * Returns true if object is transparent at a certain location - * @param target Object to check - * @param x Left coordinate - * @param y Top coordinate + * Returns currently active object + * @return {fabric.Object} active object */ - isTargetTransparent(target: Object, x: number, y: number): boolean; + getActiveObject(): Object; /** - * Sets active group to a speicified one - * @param group Group to set as a current one - * @param [e] Event (passed along when firing) + * Returns an array with the current selected objects + * @return {fabric.Object} active object */ - setActiveGroup(group: Group, e?: Event): Canvas; + getActiveObjects(): Object[]; /** * Sets given object as the only active object on canvas - * @param object Object to set as an active one - * @param [e] Event (passed along when firing "object:selected") + * @param {fabric.Object} object Object to set as an active one + * @param {Event} [e] Event (passed along when firing "object:selected") + * @return {fabric.Canvas} thisArg + * @chainable */ setActiveObject(object: Object, e?: Event): Canvas; /** - * Set the cursor type of the canvas element - * @param value Cursor type of the canvas element. - * @see http://www.w3.org/TR/css3-ui/#cursor + * Discards currently active object and fire events. If the function is called by fabric + * as a consequence of a mouse event, the event is passed as a parameter and + * sent to the fire function for the custom events. When used as a method the + * e param does not have any application. + * @param {event} e + * @return {fabric.Canvas} thisArg + * @chainable */ - setCursor(value: string): void; - + discardActiveObject(e?: Event): Canvas; /** - * Removes all event listeners + * Clears a canvas element and removes all event listeners + * @return {fabric.Canvas} thisArg + * @chainable */ - removeListeners(): void; + dispose(): Canvas; + /** + * Clears all contexts (background, main, top) of an instance + * @return {fabric.Canvas} thisArg + * @chainable + */ + clear(): Canvas; + /** + * Draws objects' controls (borders/controls) + * @param {CanvasRenderingContext2D} ctx Context to render controls on + */ + drawControls(ctx: CanvasRenderingContext2D): void; static EMPTY_JSON: string; /** @@ -1499,6 +1900,10 @@ export class Canvas { * @param [propertiesToInclude] Any properties that you might want to additionally include in the output */ static toJSON(propertiesToInclude?: string[]): string; + /** + * Removes all event listeners + */ + removeListeners(): void; } /////////////////////////////////////////////////////////////////////////////// @@ -1514,7 +1919,6 @@ interface ICircleOptions extends IObjectOptions { * Start angle of the circle, moving clockwise */ startAngle?: number; - /** * End angle of the circle */ @@ -1523,12 +1927,6 @@ interface ICircleOptions extends IObjectOptions { export interface Circle extends Object, ICircleOptions { } export class Circle { constructor(options?: ICircleOptions); - - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; /** * Returns horizontal radius of an object (according to how an object is scaled) */ @@ -1541,20 +1939,12 @@ export class Circle { * Sets radius of an object (and updates width accordingly) */ setRadius(value: number): number; - - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; /** * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toSVG(reviver?: Function): string; - + _toSVG(): string; /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement}) */ @@ -1585,88 +1975,65 @@ interface IEllipseOptions extends IObjectOptions { export interface Ellipse extends Object, IEllipseOptions { } export class Ellipse { constructor(options?: IEllipseOptions); - /** * Returns horizontal radius of an object (according to how an object is scaled) */ getRx(): number; - /** * Returns Vertical radius of an object (according to how an object is scaled) */ getRy(): number; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; /** * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toSVG(reviver?: Function): string; - /** - * Returns complexity of an instance - * @return complexity - */ - complexity(): number; - + _toSVG(): string; /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement}) */ static ATTRIBUTE_NAMES: string[]; - /** * Returns Ellipse instance from an SVG element * @param element Element to parse * @param [options] Options object */ static fromElement(element: SVGElement, options?: IEllipseOptions): Ellipse; - /** * Returns Ellipse instance from an object representation * @param object Object to create an instance from */ static fromObject(object: any): Ellipse; } - -export interface Group extends Object, ICollection { } +interface IGroupOptions extends IObjectOptions { + /** + * Indicates if click events should also check for subtargets + * @type Boolean + */ + subTargetCheck?: boolean; + /** + * setOnGroup is a method used for TextBox that is no more used since 2.0.0 The behavior is still + * available setting this boolean to true. + * @type Boolean + * @since 2.0.0 + * @default + */ + useSetOnGroup?: boolean; +} +export interface Group extends Object, ICollection, IGroupOptions { } export class Group { /** * Constructor * @param objects Group objects * @param [options] Options object */ - constructor(items?: any[], options?: IObjectOptions); - - activateAllObjects(): Group; + constructor(objects?: Object[], options?: IGroupOptions, isAlreadyGrouped?: boolean); /** * Adds an object to a group; Then recalculates group's dimension, position. * @return thisArg * @chainable */ addWithUpdate(object: Object): Group; - containsPoint(point: Point): boolean; - /** - * Destroys a group (restoring state of its objects) - * @return thisArg - * @chainable - */ - destroy(): Group; - /** - * make a group an active selection, remove the group from canvas - * the group has to be on canvas for this to work. - * @return {fabric.ActiveSelection} thisArg - * @chainable - */ - toActiveSelection(): ActiveSelection; - /** - * Checks whether this group was moved (since `saveCoords` was called last) - * @return true if an object was moved (since fabric.Group#saveCoords was called) - */ - hasMoved(): boolean; /** * Removes an object from a group; Then recalculates group's dimension, position. * @return thisArg @@ -1679,42 +2046,79 @@ export class Group { */ render(ctx: CanvasRenderingContext2D): void; /** - * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * @param object Zero or more fabric instances - * @return thisArg - * @chainable + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * @return {Boolean} */ - remove(...object: Object[]): Group; + shouldCache(): boolean; /** - * Saves coordinates of this instance (to be used together with `hasMoved`) - * @saveCoords - * @return thisArg + * Check if this object or a child object will cast a shadow + * @return {Boolean} + */ + willDrawShadow(): boolean; + /** + * Check if this group or its parent group are caching, recursively up + * @return {Boolean} + */ + isOnACache(): boolean; + /** + * Execute the drawing operation for an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawObject(ctx: CanvasRenderingContext2D): void; + /** + * Check if cache is dirty + */ + isCacheDirty(skipCanvas?: boolean): boolean; + /** + * Realises the transform from this group onto the supplied object + * i.e. it tells you what would happen if the supplied object was in + * the group, and then the group was destroyed. It mutates the supplied + * object. + * @param {fabric.Object} object + * @return {fabric.Object} transformedObject + */ + realizeTransform(object: Object): Object; + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg * @chainable */ - saveCoords(): Group; + destroy(): Group; + /** + * make a group an active selection, remove the group from canvas + * the group has to be on canvas for this to work. + * @return {fabric.ActiveSelection} thisArg + * @chainable + */ + toActiveSelection(): ActiveSelection; + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg + * @chainable + */ + ungroupOnCanvas(): Group; /** * Sets coordinates of all group objects * @return thisArg * @chainable */ setObjectsCoords(): Group; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns string represenation of a group - */ - toString(): string; /** * Returns svg representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; - + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG(reviver?: Function): string; /** * Returns {@link fabric.Group} instance from an object representation * @param object Object to create a group from @@ -1726,42 +2130,33 @@ export class Group { /////////////////////////////////////////////////////////////////////////////// // ActiveSelection ////////////////////////////////////////////////////////////////////////////// -export interface ActiveSelection extends Object, ICollection { } +export interface ActiveSelection extends Group, ICollection { } export class ActiveSelection { /** * Constructor * @param objects ActiveSelection objects * @param [options] Options object */ - constructor(items?: Object[], options?: IObjectOptions); - + constructor(objects?: Object[], options?: IObjectOptions); /** - * Change te activeSelection to a normal group, - * High level function that automatically adds it to canvas as - * active object. no events fired. - */ + * Change te activeSelection to a normal group, + * High level function that automatically adds it to canvas as + * active object. no events fired. + */ toGroup(): Group; - /** - * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) - * @param object Zero or more fabric instances - * @return thisArg - * @chainable + * If returns true, deselection is cancelled. + * @since 2.0.0 + * @return {Boolean} [cancel] */ - remove(...object: Object[]): Group; - - /** - * Returns string represenation of a group - */ - toString(): string; - + onDeselect(): boolean; /** * Returns {@link fabric.ActiveSelection} instance from an object representation * @memberOf fabric.ActiveSelection * @param object Object to create a group from * @param [callback] Callback to invoke when an ActiveSelection instance is created */ - static fromObject(object: Group, callback: (activeSelection: ActiveSelection) => void): void; + static fromObject(object: any, callback: Function): void; } interface IImageOptions extends IObjectOptions { @@ -1769,26 +2164,38 @@ interface IImageOptions extends IObjectOptions { * crossOrigin value (one of "", "anonymous", "allow-credentials") */ crossOrigin?: string; - /** - * AlignX value, part of preserveAspectRatio (one of "none", "mid", "min", "max") - * This parameter defines how the picture is aligned to its viewport when image element width differs from image width. + * When calling {@link fabric.Image.getSrc}, return value from element src with `element.getAttribute('src')`. + * This allows for relative urls as image src. + * @since 2.7.0 + * @type Boolean */ - alignX?: string; - + srcFromAttribute?: boolean; /** - * AlignY value, part of preserveAspectRatio (one of "none", "mid", "min", "max") - * This parameter defines how the picture is aligned to its viewport when image element height differs from image height. + * minimum scale factor under which any resizeFilter is triggered to resize the image + * 0 will disable the automatic resize. 1 will trigger automatically always. + * number bigger than 1 are not implemented yet. + * @type Number */ - alignY?: string; - + minimumScaleTrigger?: number; /** - * meetOrSlice value, part of preserveAspectRatio (one of "meet", "slice"). - * if meet the image is always fully visibile, if slice the viewport is always filled with image. - * @see http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute + * key used to retrieve the texture representing this image + * @since 2.0.0 + * @type String */ - meetOrSlice?: string; - + cacheKey?: string; + /** + * Image crop in pixels from original image size. + * @since 2.0.0 + * @type Number + */ + cropX?: number; + /** + * Image crop in pixels from original image size. + * @since 2.0.0 + * @type Number + */ + cropY?: number; /** * Image filter array */ @@ -1801,44 +2208,12 @@ export class Image { * @param element Image element * @param [options] Options object */ - constructor(element: HTMLImageElement, objObjects: IObjectOptions); - - initialize(element?: string | HTMLImageElement, options?: IImageOptions): void; - /** - * Applies filters assigned to this image (from "filters" array) or from filter param - * @param {Array} filters to be applied - * @return {thisArg} return the fabric.Image object - * @chainable - */ - applyFilters(filters?: IBaseFilter[]): Image; - /** - * Returns a clone of an instance - * @param callback Callback is invoked with a clone as a first argument - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - clone(callback?: Function, propertiesToInclude?: string[]): void; - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; + constructor(element?: string | HTMLImageElement, options?: IImageOptions); /** * Returns image element which this instance if based on * @return Image element */ getElement(): HTMLImageElement; - /** - * Returns original size of an image - * @return Object with "width" and "height" properties - */ - getOriginalSize(): { width: number; height: number; }; - /** - * Returns source of an image - * @return Source of an image - */ - getSrc(): string; - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** * Sets image element for this instance to a specified one. * If filters defined they are applied to new image. @@ -1847,35 +2222,63 @@ export class Image { * @param [options] Options object */ setElement(element: HTMLImageElement, callback: Function, options: IImageOptions): Image; + /** + * Delete a single texture if in webgl mode + */ + removeTexture(key: any): void; + /** + * Delete textures, reference to elements and eventually JSDOM cleanup + */ + dispose(): void; /** * Sets crossOrigin value (on an instance and corresponding image element) */ setCrossOrigin(value: string): Image; /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return Object representation of an instance + * Returns original size of an image + * @return Object with "width" and "height" properties */ - toObject(propertiesToInclude?: string[]): any; + getOriginalSize(): { width: number; height: number; }; /** - * Returns string representation of an instance - * @return String representation of an instance + * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,hight. + * @return {Boolean} */ - toString(): string; + hasCrop(): boolean; /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - toSVG(reviver?: Function): string; + _toSVG(): string; + /** + * Returns source of an image + * @return Source of an image + */ + getSrc(): string; /** * Sets source of an image - * @param src Source string (URL) - * @param [callback] Callback is invoked when image has been loaded (and all filters have been applied) - * @param [options] Options object + * @param {String} src Source string (URL) + * @param {Function} [callback] Callback is invoked when image has been loaded (and all filters have been applied) + * @param {Object} [options] Options object + * @return {fabric.Image} thisArg + * @chainable */ setSrc(src: string, callback?: Function, options?: IImageOptions): Image; - + applyResizeFilters(): void; + /** + * Applies filters assigned to this image (from "filters" array) or from filter param + * @param {Array} filters to be applied + * @return {thisArg} return the fabric.Image object + * @chainable + */ + applyFilters(filters?: IBaseFilter[]): Image; + /** + * Calculate offset for center and scale factor for the image in order to respect + * the preserveAspectRatio attribute + * @private + * @return {Object} + */ + parsePreserveAspectRatioAttribute(): any; /** * Creates an instance of fabric.Image from an URL string * @param url URL to create an image from @@ -1883,44 +2286,38 @@ export class Image { * @param [imgOptions] Options object */ static fromURL(url: string, callback?: (image: Image) => void, imgOptions?: IImageOptions): Image; - /** - * Creates an instance of fabric.Image from its object representation - * @param object Object to create an instance from - * @param [callback] Callback to invoke when an image instance is created - */ - static fromObject(object: any, callback: (image: Image) => void): void; /** * Returns Image instance from an SVG element * @param element Element to parse * @param callback Callback to execute when fabric.Image object is created * @param [options] Options object */ - static fromElement(element: SVGElement, callback: (image: Image) => void, options?: IImageOptions): void; + static fromElement(element: SVGElement, callback: Function, options?: IImageOptions): Image; /** * Default CSS class name for canvas */ static CSS_CANVAS: string; - static filters: IAllFilters; + static ATTRIBUTE_NAMES: string[]; } interface ILineOptions extends IObjectOptions { /** * x value or first line edge */ - x1: number; + x1?: number; /** * x value or second line edge */ - x2: number; + x2?: number; /** * y value or first line edge */ - y1: number; + y1?: number; /** * y value or second line edge */ - y2: number; + y2?: number; } export interface Line extends Object, ILineOptions { } export class Line { @@ -1929,39 +2326,32 @@ export class Line { * @param [points] Array of points * @param [options] Options object */ - constructor(points?: number[], objObjects?: IObjectOptions); + constructor(points?: number[], objObjects?: ILineOptions); /** - * Returns complexity of an instance - * @return complexity + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance */ - complexity(): number; - initialize(points?: number[], options?: ILineOptions): Line; - /** - * Returns object representation of an instance - * @methd toObject - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude: string[]): any; - /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - - static ATTRIBUTE_NAMES: string[]; + _toSVG(): string; /** * Returns fabric.Line instance from an SVG element - * @param element Element to parse - * @param [options] Options object + * @static + * @memberOf fabric.Line + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + * @param {Function} [callback] callback function invoked after parsing */ - static fromElement(element: SVGElement, options?: ILineOptions): Line; + static fromElement(element: SVGElement, callback?: Function, options?: ILineOptions): Line; /** * Returns fabric.Line instance from an object representation * @param object Object to create an instance from */ static fromObject(object: any): Line; + static ATTRIBUTE_NAMES: string[]; + /** + * Produces a function that calculates distance from canvas edge to Line origin. + */ + makeEdgeToOriginGetter(propertyNames: {origin: number, axis1: any, axis2: any, dimension: any}, originValues: {nearest: any, center: any, farthest: any}): Function; } interface IObjectOptions { @@ -2012,17 +2402,7 @@ interface IObjectOptions { */ scaleY?: number; - /** - * Object skew factor (horizontal) - */ - skewX?: number; - - /** - * Object skew factor (vertical) - */ - skewY?: number; - - /** + /** * When true, an object is rendered as flipped horizontally */ flipX?: boolean; @@ -2042,6 +2422,21 @@ interface IObjectOptions { */ angle?: number; + /** + * Object skew factor (horizontal) + */ + skewX?: number; + + /** + * Object skew factor (vertical) + */ + skewY?: number; + + /** + * Size of object's controlling corners (in pixels) + */ + cornerSize?: number; + /** * When true, object's controlling corners are rendered as transparent inside (i.e. stroke instead of fill) */ @@ -2052,6 +2447,11 @@ interface IObjectOptions { */ hoverCursor?: string; + /** + * Default cursor value used when moving an object on canvas + */ + moveCursor?: string; + /** * Padding between object and its controlling borders (in pixels) */ @@ -2062,26 +2462,16 @@ interface IObjectOptions { */ borderColor?: string; - /** - * Array specifying dash pattern of an object's border (hasBorder must be true) - */ - borderDashArray?: number[]; + /** + * Array specifying dash pattern of an object's border (hasBorder must be true) + */ + borderDashArray?: number[]; /** * Color of controlling corners of an object (when it's active) */ cornerColor?: string; - /** - * Array specifying dash pattern of an object's control (hasBorder must be true) - */ - cornerDashArray?: number[]; - - /** - * Size of object's controlling corners (in pixels) - */ - cornerSize?: number; - /** * Color of controlling corners of an object (when it's active and transparentCorners false) */ @@ -2092,6 +2482,11 @@ interface IObjectOptions { */ cornerStyle?: "rect" | "circle"; + /** + * Array specifying dash pattern of an object's control (hasBorder must be true) + */ + cornerDashArray?: number[]; + /** * When true, this object will use center point as the origin of transformation * when being scaled via the controls. @@ -2129,9 +2524,11 @@ interface IObjectOptions { backgroundColor?: string; /** - * When `true`, object is cached on an additional canvas. + * Selection Background color of an object. colored layer behind the object when it is active. + * does not mix good with globalCompositeOperation methods. + * @type String */ - objectCaching?: boolean; + selectionBackgroundColor?: string; /** * When defined, an object is rendered via stroke and this property specifies its color @@ -2146,7 +2543,14 @@ interface IObjectOptions { /** * Array specifying dash pattern of an object's stroke (stroke must be defined) */ - strokeDashArray?: any[]; + strokeDashArray?: number[]; + + /** + * Line offset of an object's stroke + * @type Number + * @default + */ + strokeDashOffset?: number; /** * Line endings style of an object's stroke (one of "butt", "round", "square") @@ -2240,20 +2644,7 @@ interface IObjectOptions { */ clipTo?: Function; - /** - * A fabricObject that, without stroke define a clipping area with their shape. filled in black - * the clipPath object gets used when the object has rendered, and the context is placed in the center - * of the object cacheCanvas. - * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' - */ - clipPath?: Object; - - /** - * When set to `true`, object's cache will be rerendered next render call. - */ - dirty?: boolean; - - /** + /** * When `true`, object horizontal movement is locked */ lockMovementX?: boolean; @@ -2283,11 +2674,126 @@ interface IObjectOptions { */ lockUniScaling?: boolean; + /** + * When `true`, object horizontal skewing is locked + * @type Boolean + */ + lockSkewingX?: boolean; + + /** + * When `true`, object vertical skewing is locked + * @type Boolean + */ + lockSkewingY?: boolean; + /** * When `true`, object cannot be flipped by scaling into negative values */ lockScalingFlip?: boolean; + /** + * When `true`, object is not exported in OBJECT/JSON + * since 1.6.3 + * @type Boolean + * @default + */ + excludeFromExport?: boolean; + + /** + * When `true`, object is cached on an additional canvas. + */ + objectCaching?: boolean; + + /** + * When `true`, object properties are checked for cache invalidation. In some particular + * situation you may want this to be disabled ( spray brush, very big, groups) + * or if your application does not allow you to modify properties for groups child you want + * to disable it for groups. + * default to false + * since 1.7.0 + * @type Boolean + * @default false + */ + statefullCache?: boolean; + + /** + * When `true`, cache does not get updated during scaling. The picture will get blocky if scaled + * too much and will be redrawn with correct details at the end of scaling. + * this setting is performance and application dependant. + * default to true + * since 1.7.0 + * @type Boolean + */ + noScaleCache?: boolean; + + /** + * When `false`, the stoke width will scale with the object. + * When `true`, the stroke will always match the exact pixel size entered for stroke width. + * default to false + * @since 2.6.0 + * @type Boolean + * @default false + * @type Boolean + */ + strokeUniform?: boolean; + + /** + * When set to `true`, object's cache will be rerendered next render call. + */ + dirty?: boolean; + + /** + * Determines if the fill or the stroke is drawn first (one of "fill" or "stroke") + * @type String + */ + paintFirst?: string; + + /** + * List of properties to consider when checking if state + * of an object is changed (fabric.Object#hasStateChanged) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties?: string[]; + + /** + * List of properties to consider when checking if cache needs refresh + * Those properties are checked by statefullCache ON ( or lazy mode if we want ) or from single + * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty + * and refreshed at the next render + * @type Array + */ + cacheProperties?: string[]; + + /** + * A fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the object has rendered, and the context is placed in the center + * of the object cacheCanvas. + * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' + */ + clipPath?: Object; + + /** + * Meaningful ONLY when the object is used as clipPath. + * if true, the clipPath will make the object clip to the outside of the clipPath + * since 2.4.0 + * @type boolean + * @default false + */ + inverted?: boolean; + + /** + * Meaningful ONLY when the object is used as clipPath. + * if true, the clipPath will have its top and left relative to canvas, and will + * not be influenced by the object transform. This will make the clipPath relative + * to the canvas, but clipping just a particular object. + * WARNING this is beta, this feature may change or be renamed. + * since 2.4.0 + * @type boolean + * @default false + */ + absolutePositioned?: boolean; + /** * Not used by fabric, just for convenience */ @@ -2297,86 +2803,56 @@ interface IObjectOptions { * Not used by fabric, just for convenience */ data?: any; - - /** - * Describes the object's corner position in canvas object absolute properties. - */ - aCoords?: {bl: Point, br: Point, tl: Point, tr: Point}; + /** + * Describe object's corner position in canvas element coordinates. + * properties are tl,mt,tr,ml,mr,bl,mb,br,mtr for the main controls. + * each property is an object with x, y and corner. + * The `corner` property contains in a similar manner the 4 points of the + * interactive area of the corner. + * The coordinates depends from this properties: width, height, scaleX, scaleY + * skewX, skewY, angle, strokeWidth, viewportTransform, top, left, padding. + * The coordinates get updated with @method setCoords. + * You can calculate them without updating with @method calcCoords; + * @memberOf fabric.Object.prototype + */ + oCoords?: {tl: Point, mt: Point, tr: Point, ml: Point, mr: Point, bl: Point, mb: Point, br: Point, mtr: Point}; + /** + * Describe object's corner position in canvas object absolute coordinates + * properties are tl,tr,bl,br and describe the four main corner. + * each property is an object with x, y, instance of Fabric.Point. + * The coordinates depends from this properties: width, height, scaleX, scaleY + * skewX, skewY, angle, strokeWidth, top, left. + * Those coordinates are usefull to understand where an object is. They get updated + * with oCoords but they do not need to be updated when zoom or panning change. + * The coordinates get updated with @method setCoords. + * You can calculate them without updating with @method calcCoords(true); + * @memberOf fabric.Object.prototype + */ + aCoords?: {bl: Point, br: Point, tl: Point, tr: Point}; + /** + * storage for object full transform matrix + */ + matrixCache?: any; + /** + * storage for object transform matrix + */ + ownMatrixCache?: any; } export interface Object extends IObservable, IObjectOptions, IObjectAnimation { } export class Object { - getCurrentWidth(): number; - getCurrentHeight(): number; + constructor(options?: IObjectOptions); + initialize(options?: IObjectOptions): Object; - getAngle(): number; - setAngle(value: number): Object; - - getBorderColor(): string; - setBorderColor(value: string): Object; - - getBorderScaleFactor(): number; - - getCornersize(): number; - setCornersize(value: number): Object; - - getFill(): string; - setFill(value: string): Object; - - getFillRule(): string; - setFillRule(value: string): Object; - - getFlipX(): boolean; - setFlipX(value: boolean): Object; - - getFlipY(): boolean; - setFlipY(value: boolean): Object; - - getHeight(): number; - setHeight(value: number): Object; - - getLeft(): number; - setLeft(value: number): Object; - - getOpacity(): number; - setOpacity(value: number): Object; - - overlayFill: string; - getOverlayFill(): string; - setOverlayFill(value: string): Object; - - getScaleX(): number; - setScaleX(value: number): Object; - - getScaleY(): number; - setScaleY(value: number): Object; - - getSkewX(): number; - setSkewX(value: number): Object; - - getSkewY(): number; - setSkewY(value: number): Object; - - setShadow(options: any): Object; - getShadow(): Object; - - stateProperties: any[]; - getTop(): number; - setTop(value: number): Object; - - getWidth(): number; - setWidth(value: number): Object; - - /* * Sets object's properties from options - * @param {Object} [options] Options object - */ + /* Sets object's properties from options + * @param {Object} [options] Options object + */ setOptions(options: IObjectOptions): void; /** * Transforms context when rendering an object - * @param ctx Context - * @param fromLeft When true, context is transformed to object's top/left corner. This is used when rendering text on Node + * @param {CanvasRenderingContext2D} ctx Context */ - transform(ctx: CanvasRenderingContext2D, fromLeft: boolean): void; + transform(ctx: CanvasRenderingContext2D): void; /** * Returns an object representation of an instance @@ -2396,63 +2872,121 @@ export class Object { toString(): string; /** - * Basic getter - * @param property Property name + * Return the object scale factor counting also the group scaling + * @return {Object} object with scaleX and scaleY properties */ - get(property: K): this[K]; + getObjectScaling(): {scaleX: number, scaleY: number}; /** - * Sets property to a given value. - * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. - * If you need to update those, call `setCoords()`. - * @param key Property name - * @param value Property value (if function, the value is passed into it and its return value is used as a new one) + * Return the object scale factor counting also the group scaling, zoom and retina + * @return {Object} object with scaleX and scaleY properties */ - set(key: K, value: this[K] | ((value: this[K]) => this[K])): this; - /** - * Sets property to a given value. - * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. - * If you need to update those, call `setCoords()`. - * @param options Property object, iterate over the object properties - */ - set(options: Partial): this; + getTotalObjectScaling(): {scaleX: number, scaleY: number}; /** - * Toggles specified property from `true` to `false` or from `false` to `true` - * @param property Property to toggle + * Return the object opacity counting also the group property + * @return {Number} */ - toggle(property: keyof this): this; + getObjectOpacity(): number; /** - * Sets sourcePath of an object - * @param value Value to set sourcePath to + * This callback function is called by the parent group of an object every + * time a non-delegated property changes on the group. It is passed the key + * and value as parameters. Not adding in this function's signature to avoid + * Travis build error about unused variables. */ - setSourcePath(value: string): this; + setOnGroup(): void; /** * Retrieves viewportTransform from Object's canvas if possible */ - getViewportTransform(): boolean; + getViewportTransform(): any[]; /** * Renders an object on a specified context - * @param ctx Context to render on - * @param [noTransform] When true, context is not transformed + * @param {CanvasRenderingContext2D} ctx Context to render on */ - render(ctx: CanvasRenderingContext2D, noTransform?: boolean): void; + render(ctx: CanvasRenderingContext2D): void; + + /** + * When set to `true`, force the object to have its own cache, even if it is inside a group + * it may be needed when your object behave in a particular way on the cache and always needs + * its own isolated canvas to render correctly. + * Created to be overridden + * since 1.7.12 + * @returns false + */ + needsItsOwnCache(): boolean; + + /** + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * @return {Boolean} + */ + shouldCache(): boolean; + + /** + * Check if this object or a child object will cast a shadow + * used by Group.shouldCache to know if child has a shadow recursively + * @return {Boolean} + */ + willDrawShadow(): boolean; + + /** + * Execute the drawing operation for an object clipPath + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawClipPathOnCache(ctx: CanvasRenderingContext2D): void; + + /** + * Execute the drawing operation for an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawObject(ctx: CanvasRenderingContext2D): void; + + /** + * Paint the cached copy of the object on the target context. + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawCacheOnCanvas(ctx: CanvasRenderingContext2D): void; + + /** + * Check if cache is dirty + * @param {Boolean} skipCanvas skip canvas checks because this object is painted + * on parent canvas. + */ + isCacheDirty(skipCanvas?: boolean): boolean; /** * Clones an instance, using a callback method will work for every object. * @param callback Callback is invoked with a clone as a first argument * @param [propertiesToInclude] Any properties that you might want to additionally include in the output */ - clone(callback: (clone: Object) => void, propertiesToInclude?: string[]): void; + clone(callback: Function, propertiesToInclude?: string[]): void; /** * Creates an instance of fabric.Image out of an object * @param callback callback, invoked with an instance as a first argument */ - cloneAsImage(callback: (image: Image) => void): this; + cloneAsImage(callback: Function, options?: IDataURLOptions): Object; + + /** + * Converts an object into a HTMLCanvas element + * @param {Object} options Options object + * @param {Number} [options.multiplier=1] Multiplier to scale by + * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14 + * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14 + * @param {Number} [options.width] Cropping width. Introduced in v1.2.14 + * @param {Number} [options.height] Cropping height. Introduced in v1.2.14 + * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4 + * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 + * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2 + * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format + */ + toCanvasElement(options?: IDataURLOptions): string; /** * Converts an object into a data-url-like string @@ -2483,59 +3017,73 @@ export class Object { * @param property Property name 'stroke' or 'fill' * @param [options] Options object */ - setGradient(property: "stroke" | "fill", options: IGradientOptions): this; + setGradient(property: "stroke" | "fill", options?: IGradientOptions): Object; + /** * Sets pattern fill of an object * @param options Options object */ - setPatternFill(options: IFillOptions): this; + setPatternFill(options: IFillOptions, callback: Function): Object; /** * Sets shadow of an object * @param [options] Options object or string (e.g. "2px 2px 10px rgba(0,0,0,0.2)") */ - setShadow(options?: string | Shadow): this; + setShadow(options?: string | Shadow): Object; /** * Sets "color" of an instance (alias of `set('fill', …)`) * @param color Color value */ - setColor(color: string): this; + setColor(color: string): Object; /** * Sets "angle" of an instance * @param angle Angle value */ - setAngle(angle: number): this; - - /** - * Sets "angle" of an instance - * @param angle Angle value - */ - rotate(angle: number): this; + rotate(angle: number): Object; /** * Centers object horizontally on canvas to which it was added last. * You might need to call `setCoords` on an object after centering, to update controls area. */ - centerH(): this; + centerH(): Object; + + /** + * Centers object horizontally on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenterH(): Object; /** * Centers object vertically on canvas to which it was added last. * You might need to call `setCoords` on an object after centering, to update controls area. */ - centerV(): this; + centerV(): Object; + + /** + * Centers object vertically on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenterV(): Object; /** * Centers object vertically and horizontally on canvas to which is was added last * You might need to call `setCoords` on an object after centering, to update controls area. */ - center(): this; + center(): Object; /** - * Removes object from canvas to which it was added last + * Centers object on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable */ - remove(): Object; + viewportCenter(): Object; /** * Returns coordinates of a pointer relative to an object @@ -2544,11 +3092,52 @@ export class Object { */ getLocalPointer(e: Event, pointer?: { x: number, y: number }): { x: number, y: number }; + /** + * Basic getter + * @param property Property name + */ + get(property: K): this[K]; + + /** + * Sets property to a given value. + * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. + * If you need to update those, call `setCoords()`. + * @param key Property name + * @param value Property value (if function, the value is passed into it and its return value is used as a new one) + */ + set(key: K, value: this[K] | ((value: this[K]) => this[K])): Object; + + /** + * Sets property to a given value. + * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. + * If you need to update those, call `setCoords()`. + * @param options Property object, iterate over the object properties + */ + set(options: Partial): Object; + + /** + * Toggles specified property from `true` to `false` or from `false` to `true` + * @param property Property to toggle + */ + toggle(property: keyof this): Object; + + /** + * Sets sourcePath of an object + * @param value Value to set sourcePath to + */ + setSourcePath(value: string): Object; + + /** + * Sets "angle" of an instance + * @param angle Angle value + */ + setAngle(angle: number): Object; + /** * Sets object's properties from options * @param [options] Options object */ - setOptions(options: any): void; + setOptions(options?: any): void; /** * Sets sourcePath of an object * @param value Value to set sourcePath to @@ -2558,12 +3147,16 @@ export class Object { // ----------------------------------------------------------------------------------------------------------------------------------- /** * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} */ - getSvgStyles(): string; + getSvgStyles(skipShadow?: boolean): string; /** * Returns transform-string for svg-export + * @param {Boolean} use the full transform or the single object one. + * @return {String} */ - getSvgTransform(): string; + getSvgTransform(full?: boolean, additionalTransform?: string): string; /** * Returns transform-string for svg-export from the transform matrix of single elements */ @@ -2573,28 +3166,32 @@ export class Object { // ----------------------------------------------------------------------------------------------------------------------------------- /** * Returns true if object state (one of its state properties) was changed + * @param {String} [propertySet] optional name for the set of property we want to save + * @return {Boolean} true if instance' state has changed since `{@link fabric.Object#saveState}` was called */ - hasStateChanged(): boolean; + hasStateChanged(propertySet: string): boolean; /** * Saves state of an object * @param [options] Object with additional `stateProperties` array to include when saving state * @return thisArg */ - saveState(options?: { stateProperties: any[] }): this; + saveState(options?: { stateProperties: any[] }): Object; /** * Setups state of an object + * @param {Object} [options] Object with additional `stateProperties` array to include when saving state + * @return {fabric.Object} thisArg */ - setupState(): this; + setupState(options?: any): Object; // functions from object straightening mixin // ----------------------------------------------------------------------------------------------------------------------------------- /** * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) */ - straighten(): this; + straighten(): Object; /** * Same as straighten but with animation */ - fxStraighten(callbacks: Callbacks): this; + fxStraighten(callbacks: Callbacks): Object; // functions from object stacking mixin // ----------------------------------------------------------------------------------------------------------------------------------- @@ -2602,25 +3199,25 @@ export class Object { * Moves an object up in stack of drawn objects * @param [intersecting] If `true`, send object in front of next upper intersecting object */ - bringForward(intersecting?: boolean): this; + bringForward(intersecting?: boolean): Object; /** * Moves an object to the top of the stack of drawn objects */ - bringToFront(): this; + bringToFront(): Object; /** * Moves an object down in stack of drawn objects * @param [intersecting] If `true`, send object behind next lower intersecting object */ - sendBackwards(intersecting?: boolean): this; + sendBackwards(intersecting?: boolean): Object; /** * Moves an object to the bottom of the stack of drawn objects */ - sendToBack(): this; + sendToBack(): Object; /** * Moves an object to specified level in stack of drawn objects * @param index New position of object */ - moveTo(index: number): this; + moveTo(index: number): Object; // functions from object origin mixin // ----------------------------------------------------------------------------------------------------------------------------------- @@ -2646,10 +3243,11 @@ export class Object { /** * Returns the coordinates of the object as if it has a different origin - * @param originX Horizontal origin: 'left', 'center' or 'right' - * @param originY Vertical origin: 'top', 'center' or 'bottom' + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} */ - getPointByOrigin(): Point; + getPointByOrigin(originX: string, originY: string) : Point; /** * Returns the point in local coordinates @@ -2678,9 +3276,46 @@ export class Object { * Draws borders of an object's bounding box. * Requires public properties: width, height * Requires public options: padding, borderColor - * @param ctx Context to draw on + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable */ - drawBorders(context: CanvasRenderingContext2D): this; + drawBorders(ctx: CanvasRenderingContext2D, styleOverride?: any): Object; + + /** + * Draws borders of an object's bounding box when it is inside a group. + * Requires public properties: width, height + * Requires public options: padding, borderColor + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {object} options object representing current object parameters + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawBordersInGroup(ctx: CanvasRenderingContext2D, options?: any, styleOverride?: any): Object; + + /** + * Draws corners of an object's bounding box. + * Requires public properties: width, height + * Requires public options: cornerSize, padding + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawControls(ctx: CanvasRenderingContext2D, styleOverride?: any): Object; + + /** + * Draws a colored layer behind the object, inside its selection borders. + * Requires public options: padding, selectionBackgroundColor + * this function is called when the context is transformed + * has checks to be skipped when the object is on a staticCanvas + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @return {fabric.Object} thisArg + * @chainable + */ + drawSelectionBackground(ctx: CanvasRenderingContext2D): Object; /** * Draws corners of an object's bounding box. @@ -2700,7 +3335,7 @@ export class Object { * @param controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. * @param visible true to set the specified control visible, false otherwise */ - setControlVisible(controlName: string, visible: boolean): this; + setControlVisible(controlName: string, visible: boolean): Object; /** * Sets the visibility state of object controls. @@ -2721,77 +3356,186 @@ export class Object { // functions from geometry mixin // ------------------------------------------------------------------------------------------------------------------------------- /** - * Sets corner position coordinates based on current angle, width and height - * See https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords + * Sets corner position coordinates based on current angle, width and height. + * See {@link https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords|When-to-call-setCoords} + * @param {Boolean} [ignoreZoom] set oCoords with or without the viewport transform. + * @param {Boolean} [skipAbsolute] skip calculation of aCoords, usefull in setViewportTransform + * @return {fabric.Object} thisArg + * @chainable */ - setCoords(): this; + setCoords(ignoreZoom?: boolean, skipAbsolute?: boolean): Object; /** * Returns coordinates of object's bounding rectangle (left, top, width, height) - * @param absoluteopt use coordinates without viewportTransform - * @param calculateopt use coordinates of current position instead of .oCoords / .aCoords - * @return Object with left, top, width, height properties + * the box is intented as aligned to axis of canvas. + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords / .aCoords + * @return {Object} Object with left, top, width, height properties */ - getBoundingRect(absoluteopt?: boolean, calculateopt?: boolean): { left: number; top: number; width: number; height: number }; + getBoundingRect(absolute?: boolean, calculate?: boolean): { left: number; top: number; width: number; height: number }; /** * Checks if object is fully contained within area of another object - * @param other Object to test + * @param {Object} other Object to test + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is fully contained within area of another object */ - isContainedWithinObject(other: Object): boolean; + isContainedWithinObject(other: Object, absolute?: boolean, calculate?: boolean): boolean; /** * Checks if object is fully contained within area formed by 2 points * @param pointTL top-left point of area * @param pointBR bottom-right point of area */ - isContainedWithinRect(pointTL: any, pointBR: any): boolean; + isContainedWithinRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean; /** * Checks if point is inside the object - * @param point Point to check against + * @param {fabric.Point} point Point to check against + * @param {Object} [lines] object returned from @method _getImageLines + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if point is inside the object */ - containsPoint(point: Point): boolean; + containsPoint(point: Point, lines?: any, absolute?: boolean, calculate?: boolean): boolean; /** * Scales an object (equally by x and y) * @param value Scale factor * @return thisArg */ - scale(value: number): this; + scale(value: number): Object; /** * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) * @param value New height value */ - scaleToHeight(value: number): this; + scaleToHeight(value: number, absolute?: boolean): Object; /** * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) * @param value New width value */ - scaleToWidth(value: number): this; + scaleToWidth(value: number, absolute?: boolean): Object; /** * Checks if object intersects with another object - * @param other Object to test + * @param {Object} other Object to test + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object intersects with another object */ - intersectsWithObject(other: Object): boolean; + intersectsWithObject(other: Object, absolute?: boolean, calculate?: boolean): boolean; /** * Checks if object intersects with an area formed by 2 points - * @param pointTL top-left point of area - * @param pointBR bottom-right point of area + * @param {Object} pointTL top-left point of area + * @param {Object} pointBR bottom-right point of area + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object intersects with an area formed by 2 points */ - intersectsWithRect(pointTL: any, pointBR: any): boolean; + intersectsWithRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean; + /** + * Animates object's properties + */ + animate(): Object; + /** + * Calculate and returns the .coords of an object. + * @return {Object} Object with tl, tr, br, bl .... + * @chainable + */ + calcCoords(absolute?: boolean): any; + /** + * calculate trasform Matrix that represent current transformation from + * object properties. + * @param {Boolean} [skipGroup] return transformMatrix for object and not go upward with parents + * @return {Array} matrix Transform Matrix for the object + */ + calcTransformMatrix(skipGroup?: boolean): any[]; + /** + * return correct set of coordinates for intersection + */ + getCoords(absolute?: boolean, calculate?: boolean): any; + /** + * Returns height of an object bounding box counting transformations + * before 2.0 it was named getHeight(); + * @return {Number} height value + */ + getScaledHeight(): number; + /** + * Returns width of an object bounding box counting transformations + * before 2.0 it was named getWidth(); + * @return {Number} width value + */ + getScaledWidth(): number; + /** + * Returns id attribute for svg output + * @return {String} + */ + getSvgCommons(): string; + /** + * Returns filter for svg shadow + * @return {String} + */ + getSvgFilter(): string; + /** + * Returns styles-string for svg-export + * @param {Object} style the object from which to retrieve style properties + * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style. + * @return {String} + */ + getSvgSpanStyles(style: any, useWhiteSpace?: boolean): string; + /** + * Returns text-decoration property for svg-export + * @param {Object} style the object from which to retrieve style properties + * @return {String} + */ + getSvgTextDecoration(style: any): string; + /** + * Checks if object is contained within the canvas with current viewportTransform + * the check is done stopping at first point that appears on screen + * @param {Boolean} [calculate] use coordinates of current position instead of .aCoords + * @return {Boolean} true if object is fully or partially contained within canvas + */ + isOnScreen(calculate?: boolean): boolean; + /** + * Checks if object is partially contained within the canvas with current viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is partially contained within canvas + */ + isPartiallyOnScreen(calculate?: boolean): boolean; + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to deselect this object. If the function returns true, the process is cancelled + */ + onDeselect(): void; + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to select this object. If the function returns true, the process is cancelled + */ + onSelect(): void; + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG(reviver?: Function): string; + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG(reviver?: Function): string; + /** + * Translates the coordinates from a set of origin to another (based on the object's dimensions) + * @param {fabric.Point} point The point which corresponds to the originX and originY params + * @param {String} fromOriginX Horizontal origin: 'left', 'center' or 'right' + * @param {String} fromOriginY Vertical origin: 'top', 'center' or 'bottom' + * @param {String} toOriginX Horizontal origin: 'left', 'center' or 'right' + * @param {String} toOriginY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + translateToGivenOrigin(pointL: Point, fromOriginX: string, fromOriginY: string, toOriginX: string, toOriginY: string): Point; } interface IPathOptions extends IObjectOptions { /** * Array of path points */ - path?: any[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; + path?: Point[]; } export interface Path extends Object, IPathOptions { } export class Path { @@ -2800,178 +3544,53 @@ export class Path { * @param path Path data (sequence of coordinates and corresponding "command" tokens) * @param [options] Options object */ - constructor(path?: string | any[], options?: IPathOptions); + constructor(path?: string | Point[], options?: IPathOptions); pathOffset: Point; - initialize(path?: any[], options?: IPathOptions): Path; - /** - * Returns number representation of an instance complexity - * @return complexity of this instance + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance */ - complexity(): number; - - /** - * Renders path on a specified context - * @param ctx context to render path on - * @param [noTransform] When true, context is not transformed - */ - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns dataless object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toDatalessObject(propertiesToInclude?: string[]): any; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns string representation of an instance - * @return string representation of an instance - */ - toString(): string; + toClipPathSVG(reviver?: Function): string; /** * Returns svg representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; - /** * Creates an instance of fabric.Path from an SVG element * @param element to parse * @param callback Callback to invoke when an fabric.Path instance is created * @param [options] Options object */ - static fromElement(element: SVGElement, callback: (path: Path) => any, options?: IPathOptions): void; + static fromElement(element: SVGElement, callback: Function, options?: IPathOptions): Path; /** * Creates an instance of fabric.Path from an object * @param callback Callback to invoke when an fabric.Path instance is created */ - static fromObject(object: any, callback: (path: Path) => any): void; + static fromObject(object: any, callback: Function): Path; + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) + */ + static ATTRIBUTE_NAMES: string[]; } - -export class PathGroup extends Object { - /** - * Constructor - * @param [options] Options object - */ - constructor(paths: Path[], options?: IObjectOptions); - - initialize(paths: Path[], options?: IObjectOptions): void; - /** - * Returns number representation of object's complexity - * @return complexity - */ - complexity(): number; - /** - * Returns true if all paths in this group are of same color - * @return true if all paths are of the same color (`fill`) - */ - isSameColor(): boolean; - /** - * Renders this group on a specified context - * @param ctx Context to render this instance on - */ - render(ctx: CanvasRenderingContext2D): void; - /** - * Returns dataless object representation of this path group - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return dataless object representation of an instance - */ - toDatalessObject(propertiesToInclude?: string[]): any; - /** - * Returns object representation of this path group - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns a string representation of this path group - * @return string representation of an object - */ - toString(): string; - /** - * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** - * Returns all paths in this path group - * @return array of path objects included in this path group - */ - getObjects(): Path[]; - - static fromObject(object: any): PathGroup; - /** - * Creates fabric.PathGroup instance from an object representation - * @param object Object to create an instance from - * @param callback Callback to invoke when an fabric.PathGroup instance is created - */ - static fromObject(object: any, callback: (group: PathGroup) => any): void; -} - -interface IPolygonOptions extends IObjectOptions { - /** - * Points array - */ - points?: Point[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; -} -export interface Polygon extends IPolygonOptions { } -export class Polygon extends Object { +export interface Polygon extends IPolylineOptions { } +export class Polygon extends Polyline { /** * Constructor * @param points Array of points * @param [options] Options object */ - constructor(points: Array<{ x: number; y: number }>, options?: IObjectOptions, skipOffset?: boolean); - - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; - - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) - */ - static ATTRIBUTE_NAMES: string[]; - + constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions); /** * Returns Polygon instance from an SVG element * @param element Element to parse * @param [options] Options object */ - static fromElement(element: SVGElement, options?: IPolygonOptions): Polygon; + static fromElement(element: SVGElement, options?: IPolylineOptions): Polygon; /** * Returns fabric.Polygon instance from an object representation * @param object Object to create an instance from @@ -2984,16 +3603,6 @@ interface IPolylineOptions extends IObjectOptions { * Points array */ points?: Point[]; - - /** - * Minimum X from points values, necessary to offset points - */ - minX?: number; - - /** - * Minimum Y from points values, necessary to offset points - */ - minY?: number; } export interface Polyline extends IPolylineOptions { } export class Polyline extends Object { @@ -3004,30 +3613,10 @@ export class Polyline extends Object { * @param [skipOffset] Whether points offsetting should be skipped */ constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions); - initialize(points: Point[], options?: IPolylineOptions): void; - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return Object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) */ static ATTRIBUTE_NAMES: string[]; - /** * Returns Polyline instance from an SVG element * @param element Element to parse @@ -3042,8 +3631,6 @@ export class Polyline extends Object { } interface IRectOptions extends IObjectOptions { - x?: number; - y?: number; /** * Horizontal border radius */ @@ -3062,25 +3649,6 @@ export class Rect extends Object { * @param [options] Options object */ constructor(options?: IRectOptions); - initialize(points?: number[], options?: any): Rect; - /** - * Returns complexity of an instance - * @return complexity - */ - complexity(): number; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude: any[]): any; - /** - * Returns svg representation of an instance - * @param [reviver] Method for further parsing of svg representation. - * @return svg representation of an instance - */ - toSVG(reviver?: Function): string; - /** * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) */ @@ -3098,606 +3666,779 @@ export class Rect extends Object { static fromObject(object: any): Rect; } -interface ITextOptions extends IObjectOptions { +interface TextOptions extends IObjectOptions { + type?: string; /** * Font size (in pixels) + * @type Number */ fontSize?: number; /** * Font weight (e.g. bold, normal, 400, 600, 800) + * @type {(Number|String)} */ - fontWeight?: number | string; + fontWeight?: string | number; /** * Font family + * @type String */ fontFamily?: string; /** - * Text decoration Possible values?: "", "underline", "overline" or "line-through". - * Feels like this has been deprecated in favor of underline, overline, linethrough props + * Text decoration underline. + * @type Boolean */ - textDecoration?: string; - /** - * Text decoration underline. - * @type Boolean - * @default - */ - underline?: boolean; - /** - * Text decoration overline. - * @type Boolean - * @default - */ - overline?: boolean; - /** - * Text decoration linethrough. - * @type Boolean - * @default - */ - linethrough?: boolean; + underline?: boolean; /** - * Text alignment. Possible values?: "left", "center", or "right". + * Text decoration overline. + * @type Boolean + */ + overline?: boolean; + /** + * Text decoration linethrough. + * @type Boolean + */ + linethrough?: boolean; + /** + * Text alignment. Possible values: "left", "center", "right", "justify", + * "justify-left", "justify-center" or "justify-right". + * @type String */ textAlign?: string; /** - * Font style . Possible values?: "", "normal", "italic" or "oblique". + * Font style . Possible values: "", "normal", "italic" or "oblique". + * @type String */ - fontStyle?: string; + fontStyle?: '' | 'normal' | 'italic' | 'oblique'; /** * Line height + * @type Number */ lineHeight?: number; - /** - * Character spacing - */ - charSpacing?: number; + /** + * Superscript schema object (minimum overlap) + * @type {Object} + */ + superscript?: {size: number, baseline: number}; + /** + * Subscript schema object (minimum overlap) + * @type {Object} + */ + subscript?: {size: number, baseline: number}; + /** + * Background color of text lines + * @type String + */ + textBackgroundColor?: string; /** * When defined, an object is rendered via stroke and this property specifies its color. - * Backwards incompatibility note?: This property was named "strokeStyle" until v1.1.6 + * Backwards incompatibility note: This property was named "strokeStyle" until v1.1.6 */ stroke?: string; /** * Shadow object representing shadow of this shape. - * Backwards incompatibility note?: This property was named "textShadow" (String) until v1.2.11 + * Backwards incompatibility note: This property was named "textShadow" (String) until v1.2.11 + * @type fabric.Shadow */ shadow?: Shadow | string; /** - * Background color of text lines + * additional space between characters + * expressed in thousands of em unit + * @type Number */ - textBackgroundColor?: string; - + charSpacing?: number; + /** + * Object containing character styles - top-level properties -> line numbers, + * 2nd-level properties - charater numbers + * @type Object + */ + styles?: any; + /** + * Baseline shift, stlyes only, keep at 0 for the main text object + * @type {Number} + */ + deltaY?: number; + text?: string; + /** + * List of properties to consider when checking if cache needs refresh + * @type Array + */ + cacheProperties?: string[]; + /** + * List of properties to consider when checking if + * state of an object is changed ({@link fabric.Object#hasStateChanged}) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties?: string[]; +} +export interface Text extends TextOptions { } +export class Text extends Object { + /** + * Constructor + * @param text Text string + * @param [options] Options object + */ + constructor(text: string, options?: TextOptions); + /** + * Return a context for measurement of text string. + * if created it gets stored for reuse + * @return {fabric.Text} thisArg + */ + getMeasuringContext(): CanvasRenderingContext2D; + /** + * Initialize or update text dimensions. + * Updates this.width and this.height with the proper values. + * Does not return dimensions. + */ + initDimensions(): void; + /** + * Enlarge space boxes and shift the others + */ + enlargeSpaces(): void; + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @return {Boolean} + */ + isEndOfWrapping(lineIndex: number): boolean; + /** + * Returns string representation of an instance + */ + toString(): string; + /** + * Computes height of character at given position + * @param {Number} line the line number + * @param {Number} char the character number + * @return {Number} fontSize of the character + */ + getHeightOfChar(line: number, char: number): number; + /** + * measure a text line measuring all characters. + * @param {Number} lineIndex line number + * @return {Object} object.width total width of characters + * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs + */ + measureLine(lineIndex: number): { width: number, numOfSpaces: number }; + /** + * Calculate height of line at 'lineIndex' + * @param {Number} lineIndex index of line to calculate + * @return {Number} + */ + getHeightOfLine(lineIndex: number): number; + /** + * Calculate text box height + */ + calcTextHeight(): number; + /** + * Turns the character into a 'superior figure' (i.e. 'superscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSuperscript(start: number, end: number): Text; + /** + * Turns the character into an 'inferior figure' (i.e. 'subscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSubscript(start: number, end: number): Text; + /** + * Retrieves the value of property at given character position + * @param {Number} lineIndex the line number + * @param {Number} charIndex the charater number + * @param {String} property the property name + * @returns the value of 'property' + */ + getValueOfPropertyAt(lineIndex: number, charIndex: number, property: string): any; + static DEFAULT_SVG_FONT_SIZE: number; + /** + * Returns fabric.Text instance from an SVG element (not yet implemented) + * @static + * @memberOf fabric.Text + * @param {SVGElement} element Element to parse + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + static fromElement(element: SVGElement, callback?: Function, options?: TextOptions): Text; + /** + * Returns fabric.Text instance from an object representation + * @static + * @memberOf fabric.Text + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created + */ + static fromObject(object: any, callback?: Function): Text; + /** + * Check if characters in a text have a value for a property + * whose value matches the textbox's value for that property. If so, + * the character-level property is deleted. If the character + * has no other properties, then it is also deleted. Finally, + * if the line containing that character has no other characters + * then it also is deleted. + * + * @param {string} property The property to compare between characters and text. + */ + cleanStyle(property: string): void; + /** + * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) + * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. + * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. usefull to manage styles. + */ + get2DCursorLocation(selectionStart: number, skipWrapping: boolean): {lineIndex: number, charIndex: number}; + /** + * return a new object that contains all the style property for a character + * the object returned is newly created + * @param {Number} lineIndex of the line where the character is + * @param {Number} charIndex position of the character on the line + * @return {Object} style object + */ + getCompleteStyleDeclaration(lineIndex: number, charIndex: number): any; + /** + * Gets style of a current selection/cursor (at the start position) + * if startIndex or endIndex are not provided, slectionStart or selectionEnd will be used. + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @param {Boolean} [complete] get full style or not + * @return {Array} styles an array with one, zero or more Style objects + */ + getSelectionStyles(startIndex?: number, endIndex?: number, complete?: boolean): any[]; + /** + * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} + */ + getSvgStyles(skipShadow?: boolean): string; + /** + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} + */ + isEmptyStyles(lineIndex: number): boolean; + /** + * Remove a style property or properties from all individual character styles + * in a text object. Deletes the character style object if it contains no other style + * props. Deletes a line style object if it contains no other character styles. + * + * @param {String} props The property to remove from character styles. + */ + removeStyle(property: string): void; + /** + * Sets style of a current selection, if no selection exist, do not set anything. + * @param {Object} [styles] Styles object + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @return {fabric.IText} thisArg + * @chainable + */ + setSelectionStyles(styles: any, startIndex?: number, endIndex?: number): Text; + /** + * Returns true if object has a style property or has it ina specified line + * @param {Number} lineIndex + * @return {Boolean} + */ + styleHas(property: string, lineIndex?: number): boolean; +} +interface ITextOptions extends TextOptions { + /** + * Index where text selection starts (or where cursor is when there is no selection) + * @type Number + */ + selectionStart?: number; + /** + * Index where text selection ends + * @type Number + */ + selectionEnd?: number; + /** + * Color of text selection + * @type String + */ + selectionColor?: string; + /** + * Indicates whether text is in editing mode + * @type Boolean + */ + isEditing?: boolean; + /** + * Indicates whether a text can be edited + * @type Boolean + */ + editable?: boolean; + /** + * Border color of text object while it's in editing mode + * @type String + */ + editingBorderColor?: string; + /** + * Width of cursor (in px) + * @type Number + */ + cursorWidth?: number; + /** + * Color of default cursor (when not overwritten by character style) + * @type String + */ + cursorColor?: string; + /** + * Delay between cursor blink (in ms) + * @type Number + */ + cursorDelay?: number; + /** + * Duration of cursor fadein (in ms) + * @type Number + */ + cursorDuration?: number; + /** + * Indicates whether internal text char widths can be cached + * @type Boolean + */ + caching?: boolean; + /** + * Helps determining when the text is in composition, so that the cursor + * rendering is altered. + */ + inCompositionMode?: boolean; path?: string; useNative?: boolean; - text?: string; + /** + * For functionalities on keyDown + ctrl || cmd + */ + ctrlKeysMapDown?: any; + /** + * For functionalities on keyUp + ctrl || cmd + */ + ctrlKeysMapUp?: any; + /** + * For functionalities on keyDown + * Map a special key to a function of the instance/prototype + * If you need different behaviour for ESC or TAB or arrows, you have to change + * this map setting the name of a function that you build on the fabric.Itext or + * your prototype. + * the map change will affect all Instances unless you need for only some text Instances + * in that case you have to clone this object and assign your Instance. + * this.keysMap = fabric.util.object.clone(this.keysMap); + * The function must be in fabric.Itext.prototype.myFunction And will receive event as args[0] + */ + keysMap?: any; } -export interface Text extends ITextOptions { } -export class Text extends Object { +export interface IText extends ITextOptions { } +export class IText extends Text { /** * Constructor * @param text Text string * @param [options] Options object */ constructor(text: string, options?: ITextOptions); - /** - * Returns complexity of an instance - */ - complexity(): number; - /** - * Returns string representation of an instance - */ - toString(): string; - /** - * Renders text instance on a specified context - * @param ctx Context to render on - */ - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - */ - toObject(propertiesToInclude?: string[]): any; - /** - * Returns SVG representation of an instance - * @param [reviver] Method for further parsing of svg representation. - */ - toSVG(reviver?: Function): string; - /** - * Retrieves object's fontSize - */ - getFontSize(): number; - /** - * Sets object's fontSize - * @param fontSize Font size (in pixels) - */ - setFontSize(fontSize: number): Text; - /** - * Retrieves object's fontWeight - */ - getFontWeight(): number | string; - /** - * Sets object's fontWeight - * @param fontWeight Font weight - */ - setFontWeight(fontWeight: string | number): Text; - /** - * Retrieves object's fontFamily - */ - getFontFamily(): string; - /** - * Sets object's fontFamily - * @param fontFamily Font family - */ - setFontFamily(fontFamily: string): Text; - /** - * Retrieves object's text - */ - getText(): string; - /** - * Sets object's text - * @param text Text - */ - setText(text: string): Text; - /** - * Retrieves object's textDecoration - */ - getTextDecoration(): string; - /** - * Sets object's textDecoration - * @param textDecoration Text decoration - */ - setTextDecoration(textDecoration: string): Text; - /** - * Retrieves object's underline - */ - getUnderline(): boolean; - /** - * Sets object's underline - * @param underline Text underline - */ - setUnderline(underline: boolean): Text; - /** - * Retrieves object's overline - */ - getOverline(): boolean; - /** - * Sets object's overline - * @param overline Text overline - */ - setOverline(overline: boolean): Text; - /** - * Retrieves object's linethrough - */ - getLinethrough(): boolean; - /** - * Sets object's linethrough - * @param linethrough Text linethrough - */ - setLinethrough(linethrough: boolean): Text; - /** - * Retrieves object's fontStyle - */ - getFontStyle(): string; - /** - * Sets object's fontStyle - * @param fontStyle Font style - */ - setFontStyle(fontStyle: string): Text; - /** - * Retrieves object's lineHeight - */ - getLineHeight(): number; - /** - * Sets object's lineHeight - * @param lineHeight Line height - */ - setLineHeight(lineHeight: number): Text; - /** - * Retrieves object's charSpacing - */ - getCharSpacing(): number; - /** - * Sets object's charSpacing - * @param charSpacing Character spacing - */ - setCharSpacing(charSpacing: number): Text; - /** - * Retrieves object's textAlign - */ - getTextAlign(): string; - /** - * Sets object's textAlign - * @param textAlign Text alignment - */ - setTextAlign(textAlign: string): Text; - /** - * Retrieves object's textBackgroundColor - */ - getTextBackgroundColor(): string; - /** - * Sets object's textBackgroundColor - * @param textBackgroundColor Text background color - */ - setTextBackgroundColor(textBackgroundColor: string): Text; - - /** - * List of attribute names to account for when parsing SVG element (used by `fabric.Text.fromElement`) - */ - static ATTRIBUTE_NAMES: string[]; - /** - * Default SVG font size - */ - static DEFAULT_SVG_FONT_SIZE: number; - - /** - * Returns fabric.Text instance from an SVG element (not yet implemented) - * @param element Element to parse - * @param [options] Options object - */ - static fromElement(element: SVGElement, options?: ITextOptions): Text; - /** - * Returns fabric.Text instance from an object representation - * @param object Object to create an instance from - */ - static fromObject(object: any): Text; -} - -interface IITextOptions extends IObjectOptions, ITextOptions { - /** - * Index where text selection starts (or where cursor is when there is no selection) - */ - selectionStart?: number; - - /** - * Index where text selection ends - */ - selectionEnd?: number; - - /** - * Color of text selection - */ - selectionColor?: string; - - /** - * Indicates whether text is in editing mode - */ - isEditing?: boolean; - - /** - * Indicates whether a text can be edited - */ - editable?: boolean; - - /** - * Border color of text object while it's in editing mode - */ - editingBorderColor?: string; - - /** - * Width of cursor (in px) - */ - cursorWidth?: number; - - /** - * Color of default cursor (when not overwritten by character style) - */ - cursorColor?: string; - - /** - * Delay between cursor blink (in ms) - */ - cursorDelay?: number; - - /** - * Duration of cursor fadein (in ms) - */ - cursorDuration?: number; - - /** - * Object containing character styles - * (where top-level properties corresponds to line number and 2nd-level properties -- to char number in a line) - */ - styles?: any; - - /** - * Indicates whether internal text char widths can be cached - */ - caching?: boolean; -} -export interface Textbox extends IText {} -export class Textbox extends IText { - /** - * Constructor - * @param text Text string - * @param [options] Options object - */ - constructor(text: string, options?: IITextOptions); - /** - * Detect if the text line is ended with an hard break - * text and itext do not have wrapping, return false - * @param {Number} lineIndex text to split - * @return {Boolean} - */ - isEndOfWrapping(lineIndex: number): boolean; - /** - * Get minimum width of text box - * @return {Number} - */ - getMinWidth(): number; - /** - * Selects entire text - * @return {fabric.Text} thisArg - * @chainable - */ - selectAll(): Textbox; - /** - * Selects a line based on the index - * @param {Number} selectionStart Index of a character - * @return {fabric.IText} thisArg - * @chainable - */ - selectLine(selectionStart: number): Textbox; - /** - * Enters editing state - * @return {fabric.Textbox} thisArg - * @chainable - */ - enterEditing(): Textbox; - /** - * Exits from editing state - * @return {fabric.Textbox} thisArg - * @chainable - */ - exitEditing(): Textbox; -} -export interface IText extends Text, IITextOptions { } -export class IText extends Object { - /** - * Constructor - * @param text Text string - * @param [options] Options object - */ - constructor(text: string, options?: IITextOptions); - /** - * Returns true if object has no styling or no styling in a line - * @param {Number} lineIndex , lineIndex is on wrapped lines. - */ - isEmptyStyles(lineIndex: number): boolean; - render(ctx: CanvasRenderingContext2D, noTransform: boolean): void; - /** - * Returns object representation of an instance - * @param [propertiesToInclude] Any properties that you might want to additionally include in the output - * @return object representation of an instance - */ - toObject(propertiesToInclude?: string[]): any; - - setText(value: string): Text; /** * Sets selection start (left boundary of a selection) - * @param index Index to set selection start to + * @param {Number} index Index to set selection start to */ setSelectionStart(index: number): void; /** * Sets selection end (right boundary of a selection) - * @param index Index to set selection end to + * @param {Number} index Index to set selection end to */ setSelectionEnd(index: number): void; /** - * Gets style of a current selection/cursor (at the start position) - * @param [startIndex] Start index to get styles at - * @param [endIndex] End index to get styles at - * @return styles Style object at a specified (or current) index + * Prepare and clean the contextTop */ - getSelectionStyles(startIndex: number, endIndex: number, complete?: boolean): any; - /** - * Sets style of a current selection - * @param [styles] Styles object - * @return thisArg - * @chainable - */ - setSelectionStyles(styles: any): Text; - + clearContextTop(skipRestore?: boolean): void; /** * Renders cursor or selection (depending on what exists) */ renderCursorOrSelection(): void; - - /** - * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) - * @param [selectionStart] Optional index. When not given, current selectionStart is used. - */ - get2DCursorLocation(selectionStart?: number): void; - /** - * Returns complete style of char at the current cursor - * @param lineIndex Line index - * @param charIndex Char index - * @return Character style - */ - getCurrentCharStyle(lineIndex: number, charIndex: number): any; - - /** - * Returns fontSize of char at the current cursor - * @param lineIndex Line index - * @param charIndex Char index - * @return Character font size - */ - getCurrentCharFontSize(lineIndex: number, charIndex: number): number; - - /** - * Returns color (fill) of char at the current cursor - * @param lineIndex Line index - * @param charIndex Char index - * @return Character color (fill) - */ - getCurrentCharColor(lineIndex: number, charIndex: number): string; /** * Renders cursor + * @param {Object} boundaries + * @param {CanvasRenderingContext2D} ctx transformed context to draw on */ - renderCursor(boundaries: any): void; - + renderCursor(boundaries: any, ctx: CanvasRenderingContext2D): void; /** * Renders text selection - * @param chars Array of characters - * @param boundaries Object with left/top/leftOffset/topOffset + * @param {Object} boundaries Object with left/top/leftOffset/topOffset + * @param {CanvasRenderingContext2D} ctx transformed context to draw on */ - renderSelection(chars: string[], boundaries: any): void; - - // functions from itext behavior mixin - // ------------------------------------------------------------------------------------------------------------------------ + renderSelection(boundaries: any, ctx: CanvasRenderingContext2D): void; + /** + * High level function to know the height of the cursor. + * the currentChar is the one that precedes the cursor + * Returns fontSize of char at the current cursor + * @return {Number} Character font size + */ + getCurrentCharFontSize(): number; + /** + * High level function to know the color of the cursor. + * the currentChar is the one that precedes the cursor + * Returns color (fill) of char at the current cursor + * @return {String} Character color (fill) + */ + getCurrentCharColor(): string; + /** + * Returns fabric.IText instance from an object representation + * @static + * @memberOf fabric.IText + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as argument + */ + static fromObject(object: any, callback?: Function): IText; /** * Initializes all the interactive behavior of IText */ initBehavior(): void; - - /** - * Initializes "selected" event handler - */ - initSelectedHandler(): void; - + onDeselect(): void; /** * Initializes "added" event handler */ initAddedHandler(): void; - - initRemovedHandler(): void; - /** * Initializes delayed cursor */ - initDelayedCursor(restart: boolean): void; - + initDelayedCursor(): void; /** * Aborts cursor animation and clears all timeouts */ abortCursorAnimation(): void; - /** * Selects entire text + * @return {fabric.IText} thisArg + * @chainable */ - selectAll(): void; - + selectAll(): IText; /** * Returns selected text + * @return {String} */ getSelectedText(): string; - /** * Find new selection index representing start of current word according to current selection index - * @param startFrom Surrent selection index - * @return New selection index + * @param {Number} startFrom Surrent selection index + * @return {Number} New selection index */ findWordBoundaryLeft(startFrom: number): number; - /** * Find new selection index representing end of current word according to current selection index - * @param startFrom Current selection index - * @return New selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index */ findWordBoundaryRight(startFrom: number): number; - /** * Find new selection index representing start of current line according to current selection index - * @param startFrom Current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index */ findLineBoundaryLeft(startFrom: number): number; - /** * Find new selection index representing end of current line according to current selection index - * @param startFrom Current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index */ findLineBoundaryRight(startFrom: number): number; - - /** - * Returns number of newlines in selected text - */ - getNumNewLinesInSelectedText(): number; - /** * Finds index corresponding to beginning or end of a word - * @param selectionStart Index of a character - * @param direction: 1 or -1 + * @param {Number} selectionStart Index of a character + * @param {Number} direction 1 or -1 + * @return {Number} Index of the beginning or end of a word */ searchWordBoundary(selectionStart: number, direction: number): number; - /** * Selects a word based on the index - * @param selectionStart Index of a character + * @param {Number} selectionStart Index of a character */ selectWord(selectionStart: number): void; /** * Selects a line based on the index - * @param selectionStart Index of a character + * @param {Number} selectionStart Index of a character + * @return {fabric.IText} thisArg + * @chainable */ - selectLine(selectionStart: number): void; - + selectLine(selectionStart: number): IText; /** * Enters editing state + * @return {fabric.IText} thisArg + * @chainable */ enterEditing(): IText; - /** * Initializes "mousemove" event handler */ initMouseMoveHandler(): void; /** * Exits from editing state - * @return thisArg + * @return {fabric.IText} thisArg * @chainable */ exitEditing(): IText; - /** - * Inserts a character where cursor is (replacing selection if one exists) - * @param _chars Characters to insert + * remove and reflow a style block from start to end. + * @param {Number} start linear start position for removal (included in removal) + * @param {Number} end linear end position for removal ( excluded from removal ) */ - insertChars(_chars: string, useCopiedStyle?: boolean): void; - /** - * Inserts new style object - * @param lineIndex Index of a line - * @param charIndex Index of a char - * @param isEndOfLine True if it's end of line - */ - insertNewlineStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; - - /** - * Inserts style object for a given line/char index - * @param lineIndex Index of a line - * @param charIndex Index of a char - * @param [style] Style object to insert, if given - */ - insertCharStyleObject(lineIndex: number, charIndex: number, isEndOfLine: boolean): void; - - /** - * Inserts style object(s) - * @param _chars Characters at the location where style is inserted - * @param isEndOfLine True if it's end of line - * @param [useCopiedStyle] Style to insert - */ - insertStyleObjects(_chars: string, isEndOfLine: boolean, useCopiedStyle?: boolean): void; - + removeStyleFromTo(start: number, end: number): void; /** * Shifts line styles up or down - * @param lineIndex Index of a line - * @param offset Can be -1 or +1 + * @param {Number} lineIndex Index of a line + * @param {Number} offset Can any number? */ shiftLineStyles(lineIndex: number, offset: number): void; - /** - * Removes style object - * @param isBeginningOfLine True if cursor is at the beginning of line - * @param [index] Optional index. When not given, current selectionStart is used. + * Inserts new style object + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Number} qty number of lines to add + * @param {Array} copiedStyle Array of objects styles */ - removeStyleObject(isBeginningOfLine: boolean, index?: number): void; + insertNewlineStyleObject(lineIndex: number, charIndex: number, qty: number, copiedStyle: any[]): void; /** - * Inserts new line + * Inserts style object for a given line/char index + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Number} quantity number Style object to insert, if given + * @param {Array} copiedStyle array of style objecs */ - insertNewline(): void; - + insertCharStyleObject(lineIndex: number, charIndex: number, quantity: number, copiedStyle: any[]): void; /** - * Returns fabric.IText instance from an object representation - * @param object Object to create an instance from + * Inserts style object(s) + * @param {Array} insertedText Characters at the location where style is inserted + * @param {Number} start cursor index for inserting style + * @param {Array} [copiedStyle] array of style objects to insert. */ - static fromObject(object: any): IText; + insertNewStyleBlock(insertedText: any[], start: number, copiedStyle?: any[]): void; + /** + * Set the selectionStart and selectionEnd according to the ne postion of cursor + * mimic the key - mouse navigation when shift is pressed. + */ + setSelectionStartEndWithShift(start: number, end: number, newSelection: number): void; + /** + * Copies selected text + */ + copy(): void; + /** + * convert from fabric to textarea values + */ + fromGraphemeToStringSelection(start: number, end: number, _text: string): {selectionStart: string, selectionEnd: string}; + /** + * convert from textarea to grapheme indexes + */ + fromStringToGraphemeSelection(start: number, end: number, text: string): {selectionStart: string, selectionEnd: string}; + /** + * Gets start offset of a selection + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + getDownCursorOffset(e: Event, isRight?: boolean): number; + /** + * Returns index of a character corresponding to where an object was clicked + * @param {Event} e Event object + * @return {Number} Index of a character + */ + getSelectionStartFromPointer(e: Event): number; + /** + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + getUpCursorOffset(e: Event, isRight?: boolean): number; + /** + * Initializes double and triple click event handlers + */ + initClicks(): void; + /** + * Initializes event handlers related to cursor or selection + */ + initCursorSelectionHandlers(): void + /** + * Initializes "dbclick" event handler + */ + initDoubleClickSimulation(): void; + /** + * Initializes hidden textarea (needed to bring up keyboard in iOS) + */ + initHiddenTextarea(): void; + /** + * Initializes "mousedown" event handler + */ + initMousedownHandler(): void; + /** + * Initializes "mouseup" event handler + */ + initMouseupHandler(): void; + /** + * insert characters at start position, before start position. + * start equal 1 it means the text get inserted between actual grapheme 0 and 1 + * if style array is provided, it must be as the same length of text in graphemes + * if end is provided and is bigger than start, old text is replaced. + * start/end ar per grapheme position in _text array. + * + * @param {String} text text to insert + * @param {Array} style array of style objects + * @param {Number} start + * @param {Number} end default to start + 1 + */ + insertChars(text: string, style: any[], start: number, end: number): void; + /** + * Moves cursor down + * @param {Event} e Event object + */ + moveCursorDown(e: Event): void; + /** + * Moves cursor left + * @param {Event} e Event object + */ + moveCursorLeft(e: Event): void; + /** + * Moves cursor left without keeping selection + * @param {Event} e + */ + moveCursorLeftWithoutShift(e: Event): void; + /** + * Moves cursor left while keeping selection + * @param {Event} e + */ + moveCursorLeftWithShift(e: Event): void; + /** + * Moves cursor right + * @param {Event} e Event object + */ + moveCursorRight(e: Event): void; + /** + * Moves cursor right without keeping selection + * @param {Event} e Event object + */ + moveCursorRightWithoutShift(e: Event): void; + /** + * Moves cursor right while keeping selection + * @param {Event} e + */ + moveCursorRightWithShift(e: Event): void; + /** + * Moves cursor up + * @param {Event} e Event object + */ + moveCursorUp(e: Event): void; + /** + * Moves cursor up without shift + * @param {Number} offset + */ + moveCursorWithoutShift(offset: number): void; + /** + * Moves cursor with shift + * @param {Number} offset + */ + moveCursorWithShift(offset: number): void; + /** + * Composition end + */ + onCompositionEnd(): void; + /** + * Composition start + */ + onCompositionStart(): void; + /** + * Handles onInput event + * @param {Event} e Event object + */ + onInput(e: Event): void; + /** + * Handles keyup event + * @param {Event} e Event object + */ + onKeyDown(e: Event): void; + /** + * Handles keyup event + * We handle KeyUp because ie11 and edge have difficulties copy/pasting + * if a copy/cut event fired, keyup is dismissed + * @param {Event} e Event object + */ + onKeyUp(e: Event): void; + /** + * Pastes text + */ + paste(): void; + /** + * Removes characters from start/end + * start/end ar per grapheme position in _text array. + * + * @param {Number} start + * @param {Number} end default to start + 1 + */ + removeChars(start: number, end: number): void; + /** + * Changes cursor location in a text depending on passed pointer (x/y) object + * @param {Event} e Event object + */ + setCursorByClick(e: Event): void; +} +interface ITextboxOptions extends ITextOptions { + /** + * Minimum width of textbox, in pixels. + * @type Number + */ + minWidth?: number; + /** + * Minimum calculated width of a textbox, in pixels. + * fixed to 2 so that an empty textbox cannot go to 0 + * and is still selectable without text. + * @type Number + */ + dynamicMinWidth?: number; + /** + * Override standard Object class values + */ + lockScalingFlip?: boolean; + /** + * Override standard Object class values + * Textbox needs this on false + */ + noScaleCache?: boolean; + /** + * Use this boolean property in order to split strings that have no white space concept. + * this is a cheap way to help with chinese/japaense + * @type Boolean + * @since 2.6.0 + */ + splitByGrapheme?: boolean; +} +export interface Textbox extends ITextboxOptions{} +export class Textbox extends IText { + /** + * Constructor + * @param text Text string + * @param [options] Options object + */ + constructor(text: string, options?: ITextboxOptions); + /** + * Returns true if object has a style property or has it ina specified line + * @param {Number} lineIndex + * @return {Boolean} + */ + styleHas(property: string, lineIndex: number): boolean; + /** + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} + */ + isEmptyStyles(lineIndex: number): boolean; + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @param {Number} lineIndex text to split + * @return {Boolean} + */ + isEndOfWrapping(lineIndex: number): boolean; + /** + * Returns fabric.Textbox instance from an object representation + * @static + * @memberOf fabric.Textbox + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Textbox instance is created + */ + static fromObject(object: any, callback?: Function): Textbox; } - interface ITriangleOptions extends IObjectOptions { } export class Triangle extends Object { /** @@ -3705,19 +4446,12 @@ export class Triangle extends Object { * @param [options] Options object */ constructor(options?: ITriangleOptions); - - /** - * Returns complexity of an instance - * @return complexity of this instance - */ - complexity(): number; /** * Returns SVG representation of an instance * @param [reviver] Method for further parsing of svg representation. * @return svg representation of an instance */ toSVG(reviver?: Function): string; - /** * Returns Triangle instance from an object representation * @param object Object to create an instance from @@ -3774,18 +4508,18 @@ interface IAllFilters { */ fromObject(object: any): IBrightnessFilter }; - ColorMatrix: { - new(options?: { - /** Filter matrix */ - matrix?: number[] - }): IColorMatrix; - /** - * Returns filter instance from an object representation - * @param object Object to create an instance from - */ - fromObject(object: any): IColorMatrix - }; - Convolute: { + ColorMatrix: { + new(options?: { + /** Filter matrix */ + matrix?: number[] + }): IColorMatrix; + /** + * Returns filter instance from an object representation + * @param object Object to create an instance from + */ + fromObject(object: any): IColorMatrix + }; + Convolute: { new(options?: { opaque?: boolean, /** Filter matrix */ @@ -3974,11 +4708,11 @@ interface IBrightnessFilter extends IBaseFilter { applyTo(canvasEl: HTMLCanvasElement): void; } interface IColorMatrix extends IBaseFilter { - /** - * Applies filter to canvas element - * @param canvasEl Canvas element to apply filter to - */ - applyTo(canvasEl: HTMLCanvasElement): void; + /** + * Applies filter to canvas element + * @param canvasEl Canvas element to apply filter to + */ + applyTo(canvasEl: HTMLCanvasElement): void; } interface IConvoluteFilter extends IBaseFilter { /** @@ -4601,7 +5335,7 @@ interface IUtilMisc { * @param elements SVG elements to group * @param [options] Options object */ - groupSVGElements(elements: any[], options?: any, path?: any): PathGroup; + groupSVGElements(elements: any[], options?: any, path?: string): Object | Group; /** * Populates an object with properties of another object @@ -4660,10 +5394,10 @@ interface IUtilMisc { */ qrDecompose(a: number[]): { angle: number, scaleX: number, scaleY: number, skewX: number, skewY: number, translateX: number, translateY: number }; - /** - * Creates a transform matrix with the specified scale and skew - */ - customTransformMatrix(scaleX: number, scaleY: number, skewX: number): number[]; + /** + * Creates a transform matrix with the specified scale and skew + */ + customTransformMatrix(scaleX: number, scaleY: number, skewX: number): number[]; /** * Returns string representation of function body diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index e8d31aef56..3897987589 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for FabricJS 1.5 +// Type definitions for FabricJS 2.6 // Project: http://fabricjs.com/ // Definitions by: Oliver Klemencic // Joseph Livecchi @@ -7,6 +7,8 @@ // Brian Martinson // Rogerio Teixeira // Bradley Hill +// Bryan Krol +// Glenn Gartner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 export import fabric = require("./fabric-impl"); diff --git a/types/fabric/test/index.ts b/types/fabric/test/index.ts index 9a5c0b24d2..16c8f5c747 100644 --- a/types/fabric/test/index.ts +++ b/types/fabric/test/index.ts @@ -12,7 +12,7 @@ function sample1() { }); for (let i = 0; i < 15; i++) { - fabric.Image.fromURL('../assets/ladybug.png', img => { + fabric.Image.fromURL('../assets/ladybug.png', (img: fabric.Image) => { img.set({ left: fabric.util.getRandomInt(0, 600), top: fabric.util.getRandomInt(0, 500), @@ -122,7 +122,7 @@ function sample3() { } }); - const image = fabric.Image.fromURL('../assets/printio.png', img => { + const image = fabric.Image.fromURL('../assets/printio.png', (img: fabric.Image) => { const oImg = img.set({ left: 300, top: 300, angle: -15 }).scale(0.9); canvas.add(oImg).renderAll(); canvas.setActiveObject(oImg); @@ -236,21 +236,21 @@ function sample4() { const topControl = $('top-control'); topControl.onchange = function(this: HTMLInputElement) { - rect.setTop(+this.value).setCoords(); + rect.set('top',+this.value).setCoords(); canvas.renderAll(); }; const leftControl = $('left-control'); leftControl.onchange = function(this: HTMLInputElement) { - rect.setLeft(+this.value).setCoords(); + rect.set('left',+this.value).setCoords(); canvas.renderAll(); }; function updateControls() { - scaleControl.value = rect.getScaleX().toString(); - angleControl.value = rect.getAngle().toString(); - leftControl.value = rect.getLeft().toString(); - topControl.value = rect.getTop().toString(); + scaleControl.value = rect.scaleX.toString(); + angleControl.value = rect.angle.toString(); + leftControl.value = rect.left.toString(); + topControl.value = rect.top.toString(); } canvas.on({ 'object:moving': updateControls, @@ -331,10 +331,10 @@ function sample6() { canvas.centerObject(obj); canvas.add(obj); - obj.clone(clone => canvas.add(clone.set({ left: 100, top: 100, angle: -15 }))); - obj.clone(clone => canvas.add(clone.set({ left: 480, top: 100, angle: 15 }))); - obj.clone(clone => canvas.add(clone.set({ left: 100, top: 400, angle: -15 }))); - obj.clone(clone => canvas.add(clone.set({ left: 480, top: 400, angle: 15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 100, top: 100, angle: -15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 480, top: 100, angle: 15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 100, top: 400, angle: -15 }))); + obj.clone((clone: fabric.Object) => canvas.add(clone.set({ left: 480, top: 400, angle: 15 }))); canvas.on('mouse:move', options => { const p = canvas.getPointer(options.e); @@ -343,7 +343,7 @@ function sample6() { const distX = Math.abs(p.x - obj.left); const distY = Math.abs(p.y - obj.top); const dist = Math.round(Math.sqrt(Math.pow(distX, 2) + Math.pow(distY, 2))); - obj.setOpacity(1 / (dist / 20)); + obj.set('opacity', (1 / (dist / 20))); }); }); }); @@ -357,7 +357,7 @@ function sample7() { const canvas = new fabric.Canvas('c', { selection: false }); setInterval(() => { - fabric.Image.fromURL('../assets/ladybug.png', obj => { + fabric.Image.fromURL('../assets/ladybug.png', (obj: fabric.Object) => { const img = obj; img.set('left', fabric.util.getRandomInt(200, 600)).set('top', -50); img.movingLeft = !!Math.round(Math.random()); @@ -373,7 +373,7 @@ function sample7() { if (img.left > 900 || img.top > 500) { canvas.remove(img); } else { - img.setAngle(img.getAngle() + 2); + img.setAngle(img.angle + 2); } }); canvas.renderAll(); @@ -475,7 +475,7 @@ function sample8() { break; case 'image1': - fabric.Image.fromURL('../assets/pug.jpg', image => { + fabric.Image.fromURL('../assets/pug.jpg', (image: fabric.Image) => { image.set({ left, top, @@ -489,7 +489,7 @@ function sample8() { break; case 'image2': - fabric.Image.fromURL('../assets/logo.png', image => { + fabric.Image.fromURL('../assets/logo.png', (image: fabric.Image) => { image.set({ left, top, @@ -510,14 +510,7 @@ function sample8() { fabric.loadSVGFromURL(`../assets/${match[0]}.svg`, (objects, options) => { const loadedObject = fabric.util.groupSVGElements(objects, options); - loadedObject.set({ - left, - top, - angle, - padding: 10, - cornerSize: 10 - }); - loadedObject/*.scaleToWidth(300)*/.setCoords(); + loadedObject.setCoords(); // loadedObject.hasRotatingPoint = true; @@ -554,15 +547,8 @@ function sample8() { const removeSelectedEl = document.getElementById('remove-selected'); removeSelectedEl.onclick = () => { const activeObject = canvas.getActiveObject(); - const activeGroup = canvas.getActiveGroup(); if (activeObject) { canvas.remove(activeObject); - } else if (activeGroup) { - const objectsInGroup = activeGroup.getObjects(); - canvas.discardActiveGroup(); - objectsInGroup.forEach(object => { - canvas.remove(object); - }); } }; @@ -601,10 +587,9 @@ function sample8() { slider.onchange = function() { const activeObject = canvas.getActiveObject(); - const activeGroup = canvas.getActiveGroup(); - if (activeObject || activeGroup) { - (activeObject || activeGroup).setOpacity(parseInt(( this).value, 10) / 100); + if (activeObject) { + activeObject.set('opacity', (parseInt(( this).value, 10) / 100)); canvas.renderAll(); } }; @@ -632,10 +617,9 @@ function sample8() { colorpicker.onchange = function() { const activeObject = canvas.getActiveObject(); - const activeGroup = canvas.getActiveGroup(); - if (activeObject || activeGroup) { - (activeObject || activeGroup).setFill(( this).value); + if (activeObject) { + activeObject.set('fill', ( this).value); canvas.renderAll(); } }; @@ -768,16 +752,6 @@ function sample8() { updateComplexity(); }); - drawingColorEl.onchange = () => { - canvas.freeDrawingColor = drawingColorEl.value; - }; - drawingLineWidthEl.onchange = () => { - canvas.freeDrawingLineWidth = parseInt(drawingLineWidthEl.value, 10) || 1; // disallow 0, NaN, etc. - }; - - canvas.freeDrawingColor = drawingColorEl.value; - canvas.freeDrawingLineWidth = parseInt(drawingLineWidthEl.value, 10) || 1; - const text = `Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt @@ -802,7 +776,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; }; document.onkeydown = e => { - const obj = canvas.getActiveObject() || canvas.getActiveGroup(); + const obj = canvas.getActiveObject(); if (obj && e.keyCode === 8) { // this is horrible. need to fix, so that unified interface can be used if (obj.type === 'group') { @@ -832,8 +806,7 @@ laboris nisi ut aliquip ex ea commodo consequat.`; const obj = canvas.getActiveObject(); if (obj) { obj.setGradient("fill", { - x2: (getRandomInt(0, 1) ? 0 : obj.width), - y2: (getRandomInt(0, 1) ? 0 : obj.height), + coords: {x2: (getRandomInt(0, 1) ? 0 : obj.width), y2: (getRandomInt(0, 1) ? 0 : obj.height)}, colorStops: { 0: '#' + getRandomColor(), 1: '#' + getRandomColor() @@ -871,8 +844,8 @@ laboris nisi ut aliquip ex ea commodo consequat.`; cmdUnderlineBtn.onclick = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.textDecoration = (activeObject.textDecoration === 'underline' ? '' : 'underline'); - (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; + activeObject.underline = !activeObject.underline; + (this as HTMLElement).className = activeObject.underline ? 'selected' : ''; canvas.renderAll(); } }; @@ -884,8 +857,8 @@ laboris nisi ut aliquip ex ea commodo consequat.`; cmdLinethroughBtn.onclick = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.textDecoration = (activeObject.textDecoration === 'line-through' ? '' : 'line-through'); - (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; + activeObject.linethrough = !activeObject.linethrough; + (this as HTMLElement).className = activeObject.linethrough ? 'selected' : ''; canvas.renderAll(); } }; @@ -897,8 +870,8 @@ laboris nisi ut aliquip ex ea commodo consequat.`; cmdOverlineBtn.onclick = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.textDecoration = (activeObject.textDecoration === 'overline' ? '' : 'overline'); - (this as HTMLElement).className = activeObject.textDecoration ? 'selected' : ''; + activeObject.overline = !activeObject.overline; + (this as HTMLElement).className = activeObject.overline ? 'selected' : ''; canvas.renderAll(); } }; diff --git a/types/facebook-js-sdk/facebook-js-sdk-tests.ts b/types/facebook-js-sdk/facebook-js-sdk-tests.ts index db8b13686e..8bcd07cbed 100644 --- a/types/facebook-js-sdk/facebook-js-sdk-tests.ts +++ b/types/facebook-js-sdk/facebook-js-sdk-tests.ts @@ -48,6 +48,10 @@ FB.logout(function(response: fb.StatusResponse) { console.log(response.authResponse.accessToken); }); +FB.login({ auth_type: 'reauthenticate' }); +FB.login({ auth_type: 'reauthorize' }); +FB.login({ auth_type: 'rerequest' }); + FB.logout(); /** diff --git a/types/facebook-js-sdk/index.d.ts b/types/facebook-js-sdk/index.d.ts index c4f3b78c31..18da6b5ae9 100644 --- a/types/facebook-js-sdk/index.d.ts +++ b/types/facebook-js-sdk/index.d.ts @@ -150,7 +150,7 @@ declare namespace facebook { } interface LoginOptions { - auth_type?: 'rerequest'; + auth_type?: 'reauthenticate' | 'reauthorize' | 'rerequest'; scope?: string; return_scopes?: boolean; enable_profile_selector?: boolean; diff --git a/types/flexmonster/index.d.ts b/types/flexmonster/index.d.ts index 2c5ea0b0ec..fad76ca64d 100644 --- a/types/flexmonster/index.d.ts +++ b/types/flexmonster/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for flexmonster 2.6 -// Project: https://flexmonster.com +// Project: https://flexmonster.com/ // Definitions by: Flexmonster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -135,6 +135,7 @@ declare namespace Flexmonster { showGridAndCharts(type?: string, position?: string, multiple?: boolean): void; sortingMethod(hierarchyName: string, compareFunction: (a: string, b: string) => boolean): void; sortValues(axisName: string, type: string, tuple: number[], measure: MeasureObject): void; + toolbar: Toolbar; updateData(object: DataSource | object[]): void; version: string; fusioncharts?: { @@ -179,6 +180,7 @@ declare namespace Flexmonster { dataSourceInfo?: string; dataSourceType?: string; fieldSeparator?: string; + thousandSeparator?: string; filename?: string; ignoreQuotedLineBreaks?: boolean; proxyUrl?: string; @@ -191,6 +193,8 @@ declare namespace Flexmonster { hash?: string; username?: string; password?: string; + requestHeader?: object; + subquery?: string; } interface Slice { @@ -276,6 +280,7 @@ declare namespace Flexmonster { saveAllFormats?: boolean; showDrillThroughConfigurator?: boolean; grouping?: boolean; + showAllFieldsDrillThrough?: boolean; } interface PrintOptions { @@ -343,6 +348,7 @@ declare namespace Flexmonster { useOlapFormattingInExcel?: boolean; useCustomizeCellForData?: boolean; excelExportAll?: boolean; + requestHeader?: object; } interface Hierarchy { @@ -463,6 +469,34 @@ declare namespace Flexmonster { interface Toolbar { getTabs: () => ToolbarTab[]; + // Connect tab + connectLocalCSVHandler: () => void; + connectLocalJSONHandler: () => void; + connectRemoteCSV: () => void; + connectRemoteJSON: () => void; + connectOLAP: () => void; + // Open tab + openLocalReport: () => void; + openRemoteReport: () => void; + // Save tab + saveHandler: () => void; + // Export tab + printHandler: () => void; + exportHandler: (type: string) => void; + // Grid tab + gridHandler: () => void; + // Charts tab + chartsHandler: (type: string) => void; + chartsMultipleHandler: () => void; + // Format tab + formatCellsHandler: () => void; + conditionalFormattingHandler: () => void; + // Options tab + optionsHandler: () => void; + // Fields tab + fieldsHandler: () => void; + // Fullscreen tab + fullscreenHandler: () => void; } interface ToolbarTab { diff --git a/types/gestalt/index.d.ts b/types/gestalt/index.d.ts index 77c88b6d35..a38b1d94d1 100644 --- a/types/gestalt/index.d.ts +++ b/types/gestalt/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for gestalt 0.75 // Project: https://github.com/pinterest/gestalt, https://pinterest.github.io/gestalt // Definitions by: Nicolás Serrano Arévalo +// Josh Gachnang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -938,7 +939,7 @@ export class Pog extends React.Component {} export class Pulsar extends React.Component {} export class RadioButton extends React.Component {} export class SearchField extends React.Component {} -export class SegmentedControl extends React.Component {} +export class SegmentedControl extends React.Component {} export class SelectList extends React.Component {} export class Spinner extends React.Component {} export class Sticky extends React.Component {} diff --git a/types/get-urls/package.json b/types/get-urls/package.json new file mode 100644 index 0000000000..2dbe933ea4 --- /dev/null +++ b/types/get-urls/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "normalize-url": "*" + } +} diff --git a/types/gijgo/gijgo-tests.ts b/types/gijgo/gijgo-tests.ts index 6e624ad4f6..b1622057cf 100644 --- a/types/gijgo/gijgo-tests.ts +++ b/types/gijgo/gijgo-tests.ts @@ -2,7 +2,7 @@ // Grid $(() => { - this.grid = $('#grid').grid({ + (this as any).grid = $('#grid').grid({ primaryKey: 'ID', columns: [ { field: 'ID', width: 50, sortable: true }, @@ -14,9 +14,9 @@ $(() => { // Dialog $(() => { - this.dialog = $('#playerModal').dialog({ + (this as any).dialog = $('#playerModal').dialog({ autoOpen: false, title: 'Player', width: 400 }); -}); \ No newline at end of file +}); diff --git a/types/giphy-api/giphy-api-tests.ts b/types/giphy-api/giphy-api-tests.ts index c5fc86870e..da286ed612 100644 --- a/types/giphy-api/giphy-api-tests.ts +++ b/types/giphy-api/giphy-api-tests.ts @@ -11,26 +11,26 @@ giphyApi({ apiKey: 'API KEY' }); const searchOptions: giphyApi.SearchOptions = { q: 'pokemon', rating: 'g' }; const giphy: giphyApi.Giphy = giphyApi(); giphy.search('pokemon', cb); -giphy.search('pokemon').then(res => {}); +giphy.search('pokemon').then(res => res.data[0]); giphy.search(searchOptions, cb); -giphy.search({ q: 'pokemon', rating: 'g' }).then(res => {}); +giphy.search({ q: 'pokemon', rating: 'g' }).then(res => res.data[0]); giphy.id('feqkVgjJpYtjy', cb); -giphy.id('feqkVgjJpYtjy').then(res => {}); +giphy.id('feqkVgjJpYtjy').then(res => res.data[0]); giphy.id(['feqkVgjJpYtjy'], cb); -giphy.id(['feqkVgjJpYtjy']).then(res => {}); +giphy.id(['feqkVgjJpYtjy']).then(res => res.data[0]); giphy.translate('superman', cb); -giphy.translate('superman').then(res => {}); +giphy.translate('superman').then(res => res.data.id); giphy.translate({ s: 'superman', rating: 'g', fmt: 'html' }, cb); -giphy.translate({ s: 'superman', rating: 'g' }).then(res => {}); +giphy.translate({ s: 'superman', rating: 'g' }).then(res => res.data.id); giphy.random('superman', cb); -giphy.random('superman').then(res => {}); +giphy.random('superman').then(res => res.data.id); giphy.random({ tag: 'superman', rating: 'g' }, cb); -giphy.random({ tag: 'superman', rating: 'g' }).then(res => {}); +giphy.random({ tag: 'superman', rating: 'g' }).then(res => res.data.id); giphy.trending(cb); -giphy.trending().then(res => {}); +giphy.trending().then(res => res.data[0]); giphy.trending({ limit: 2, rating: 'g' }); -giphy.trending({ limit: 2, rating: 'g' }).then(res => {}); +giphy.trending({ limit: 2, rating: 'g' }).then(res => res.data[0]); diff --git a/types/giphy-api/index.d.ts b/types/giphy-api/index.d.ts index d121eff979..1b9b58b324 100644 --- a/types/giphy-api/index.d.ts +++ b/types/giphy-api/index.d.ts @@ -30,7 +30,16 @@ interface BaseImage { height: string; } -type Callback = (err: Error, res: giphyApi.Result) => void; +interface BaseResponse { + pagination: { total_count: number; count: number; offset: number }; + meta: { + status: number; + msg: string; + response_id: string; + }; +} + +type Callback = (err: Error, res: TResponse) => void; declare function giphyApi(apiKeyOrOptions?: string | giphyApi.GiphyOptions): giphyApi.Giphy; @@ -48,131 +57,131 @@ declare namespace giphyApi { } interface Giphy { - search(queryOrOptions: string | SearchOptions, cb: Callback): void; - search(queryOrOptions: string | SearchOptions): Promise; - id(ids: string | string[], cb: Callback): void; - id(ids: string | string[]): Promise; - translate(termOrOptions: string | TranslateOptions, cb: Callback): void; - translate(termOrOptions: string | TranslateOptions): Promise; - random(tagOrOptions: string | RandomOptions, cb: Callback): void; - random(tagOrOptions: string | RandomOptions): Promise; - trending(options: TrendingOptions, cb: Callback): void; - trending(cb: Callback): void; - trending(options?: TrendingOptions): Promise; + search(queryOrOptions: string | SearchOptions, cb: Callback): void; + search(queryOrOptions: string | SearchOptions): Promise; + id(ids: string | string[], cb: Callback): void; + id(ids: string | string[]): Promise; + translate(termOrOptions: string | TranslateOptions, cb: Callback): void; + translate(termOrOptions: string | TranslateOptions): Promise; + random(tagOrOptions: string | RandomOptions, cb: Callback): void; + random(tagOrOptions: string | RandomOptions): Promise; + trending(options: TrendingOptions, cb: Callback): void; + trending(cb: Callback): void; + trending(options?: TrendingOptions): Promise; } - interface Result { - data: [ - { - type: string; - id: string; - slug: string; - url: string; - bitly_url: string; - embed_url: string; - username: string; - source: string; - rating: Rating; - content_url: string; - user?: { - avatar_url: string; - banner_url: string; - profile_url: string; - username: string; - display_name: string; - twitter: string; - }, - source_tld: string; - source_post_url: string; - update_datetime: string; - create_datetime: string; - import_datetime: string; - trending_datetime: string; - title: string; - images: { - fixed_height: BaseImage & { - size: string; - mp4: string; - mp4_size: string; - webp: string; - webp_size: string; - }; - fixed_height_still: BaseImage; - fixed_height_downsampled: BaseImage & { - size: string; - webp: string; - webp_size: string; - }; - fixed_width: BaseImage & { - size: string; - mp4: string; - mp4_size: string; - webp: string; - webp_size: string; - }; - original_still: BaseImage; - fixed_width_still: BaseImage; - fixed_width_downsampled: BaseImage & { - size: string; - webp: string; - webp_size: string; - }; - fixed_height_small: BaseImage & { - size: string; - mp4: string; - mp4_size: string; - webp: string; - webp_size: string; - }; - fixed_height_small_still: BaseImage; - fixed_width_small: BaseImage & { - size: string; - mp4: string; - mp4_size: string; - webp: string; - webp_size: string; - }; - fixed_width_small_still: BaseImage; - downsized: BaseImage & { - size: string; - }; - downsized_still: BaseImage; - downsized_large: BaseImage & { - size: string; - }; - downsized_medium: BaseImage & { - size: string; - }; - downsized_small: BaseImage & { - size: string; - }; - original: BaseImage & { - size: string; - frames: string; - mp4: string; - mp4_size: string; - webp: string; - webp_size: string; - }; - looping: { mp4: string; }; - preview: { - width: string; - height: string; - mp4: string; - mp4_size: string; - }; - preview_gif: BaseImage & { - size: string; - }; - }; - } - ]; - pagination: { total_count: number; count: number; offset: number }; - meta: { - status: number; - msg: string; - response_id: string; + interface Images { + fixed_height: BaseImage & { + size: string; + mp4: string; + mp4_size: string; + webp: string; + webp_size: string; }; + fixed_height_still: BaseImage; + fixed_height_downsampled: BaseImage & { + size: string; + webp: string; + webp_size: string; + }; + fixed_width: BaseImage & { + size: string; + mp4: string; + mp4_size: string; + webp: string; + webp_size: string; + }; + original_still: BaseImage; + fixed_width_still: BaseImage; + fixed_width_downsampled: BaseImage & { + size: string; + webp: string; + webp_size: string; + }; + fixed_height_small: BaseImage & { + size: string; + mp4: string; + mp4_size: string; + webp: string; + webp_size: string; + }; + fixed_height_small_still: BaseImage; + fixed_width_small: BaseImage & { + size: string; + mp4: string; + mp4_size: string; + webp: string; + webp_size: string; + }; + fixed_width_small_still: BaseImage; + downsized: BaseImage & { + size: string; + }; + downsized_still: BaseImage; + downsized_large: BaseImage & { + size: string; + }; + downsized_medium: BaseImage & { + size: string; + }; + downsized_small: BaseImage & { + size: string; + }; + original: BaseImage & { + size: string; + frames: string; + mp4: string; + mp4_size: string; + webp: string; + webp_size: string; + }; + looping: { mp4: string; }; + preview: { + width: string; + height: string; + mp4: string; + mp4_size: string; + }; + preview_gif: BaseImage & { + size: string; + }; + } + + interface GIFObject { + type: string; + id: string; + slug: string; + url: string; + bitly_url: string; + embed_url: string; + username: string; + source: string; + rating: Rating; + content_url: string; + user?: { + avatar_url: string; + banner_url: string; + profile_url: string; + username: string; + display_name: string; + twitter: string; + }; + source_tld: string; + source_post_url: string; + update_datetime: string; + create_datetime: string; + import_datetime: string; + trending_datetime: string; + title: string; + images: Images; + } + + interface MultiResponse extends BaseResponse { + data: GIFObject[]; + } + + interface SingleResponse extends BaseResponse { + data: GIFObject; } } diff --git a/types/gl-vec3/add.d.ts b/types/gl-vec3/add.d.ts new file mode 100644 index 0000000000..a26dfc655c --- /dev/null +++ b/types/gl-vec3/add.d.ts @@ -0,0 +1,6 @@ +/** + * Adds two number's. + */ +declare function add(out: number[], a: number[], b: number[]): number[]; + +export default add; diff --git a/types/gl-vec3/angle.d.ts b/types/gl-vec3/angle.d.ts new file mode 100644 index 0000000000..366b1cb4b7 --- /dev/null +++ b/types/gl-vec3/angle.d.ts @@ -0,0 +1,6 @@ +/** + * Get the angle between two 3D vectors. + */ +declare function angle(a: number[], b: number[]): number; + +export default angle; diff --git a/types/gl-vec3/clone.d.ts b/types/gl-vec3/clone.d.ts new file mode 100644 index 0000000000..7b56113caa --- /dev/null +++ b/types/gl-vec3/clone.d.ts @@ -0,0 +1,6 @@ +/** + * Creates a new number initialized with values from an existing vector. + */ +declare function clone(a: number[]): number[]; + +export default clone; diff --git a/types/gl-vec3/copy.d.ts b/types/gl-vec3/copy.d.ts new file mode 100644 index 0000000000..821f2493a7 --- /dev/null +++ b/types/gl-vec3/copy.d.ts @@ -0,0 +1,6 @@ +/** + * Copy the values from one number to another. + */ +declare function copy(out: number[], a: number[]): number[]; + +export default copy; diff --git a/types/gl-vec3/create.d.ts b/types/gl-vec3/create.d.ts new file mode 100644 index 0000000000..5577d59d7d --- /dev/null +++ b/types/gl-vec3/create.d.ts @@ -0,0 +1,6 @@ +/** + * Creates a new, empty number. + */ +declare function create(): number[]; + +export default create; diff --git a/types/gl-vec3/dist.d.ts b/types/gl-vec3/dist.d.ts new file mode 100644 index 0000000000..bb4df7b83f --- /dev/null +++ b/types/gl-vec3/dist.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the euclidian distance between two number's. Aliased as dist. + */ +declare function dist(a: number[], b: number[]): number; + +export default dist; diff --git a/types/gl-vec3/div.d.ts b/types/gl-vec3/div.d.ts new file mode 100644 index 0000000000..be3bcf68a0 --- /dev/null +++ b/types/gl-vec3/div.d.ts @@ -0,0 +1,6 @@ +/** + * Divides two number's. Aliased as div. + */ +declare function div(out: number[], a: number[], b: number[]): number[]; + +export default div; diff --git a/types/gl-vec3/dot.d.ts b/types/gl-vec3/dot.d.ts new file mode 100644 index 0000000000..efe2caf624 --- /dev/null +++ b/types/gl-vec3/dot.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the dot product of two number's. + */ +declare function dot(a: number[], b: number[]): number; + +export default dot; diff --git a/types/gl-vec3/equals.d.ts b/types/gl-vec3/equals.d.ts new file mode 100644 index 0000000000..91aeaa3bbd --- /dev/null +++ b/types/gl-vec3/equals.d.ts @@ -0,0 +1,6 @@ +/** + * Returns whether or not the vectors have approximately the same elements in the same position.. + */ +declare function equals(a: number[], b: number[]): boolean; + +export default equals; diff --git a/types/gl-vec3/exactEquals.d.ts b/types/gl-vec3/exactEquals.d.ts new file mode 100644 index 0000000000..c68b328f69 --- /dev/null +++ b/types/gl-vec3/exactEquals.d.ts @@ -0,0 +1,6 @@ +/** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===). + */ +declare function exactEquals(a: number[], b: number[]): boolean; + +export default exactEquals; diff --git a/types/gl-vec3/forEach.d.ts b/types/gl-vec3/forEach.d.ts new file mode 100644 index 0000000000..8805286fb0 --- /dev/null +++ b/types/gl-vec3/forEach.d.ts @@ -0,0 +1,6 @@ +/** + * Perform some operation over an array of numbers. + */ +declare function forEach(a: number[], stride: number, offset: number, count: number, fn: (a: number[], b: number[], arg: object) => number[], arg: object): number[]; + +export default forEach; diff --git a/types/gl-vec3/fromValues.d.ts b/types/gl-vec3/fromValues.d.ts new file mode 100644 index 0000000000..8fd52fbcee --- /dev/null +++ b/types/gl-vec3/fromValues.d.ts @@ -0,0 +1,6 @@ +/** + * Creates a new number initialized with the given values. + */ +declare function fromValues(x: number, y: number, z: number): number[]; + +export default fromValues; diff --git a/types/gl-vec3/gl-vec3-tests.ts b/types/gl-vec3/gl-vec3-tests.ts new file mode 100644 index 0000000000..67be9102a9 --- /dev/null +++ b/types/gl-vec3/gl-vec3-tests.ts @@ -0,0 +1,121 @@ +import * as GlVec3 from "gl-vec3"; +import GLVec3Add from "gl-vec3/add"; +import GLVec3Angle from "gl-vec3/angle"; +import GLVec3Clone from "gl-vec3/clone"; +import GLVec3Copy from "gl-vec3/copy"; +import GLVec3Create from "gl-vec3/create"; +import GLVec3Dist from "gl-vec3/dist"; +import GLVec3Div from "gl-vec3/div"; +import GLVec3Dot from "gl-vec3/dot"; +import GLVec3Equals from "gl-vec3/equals"; +import GLVec3exactEquals from "gl-vec3/exactEquals"; +import GLVec3forEach from "gl-vec3/forEach"; +import GLVec3fromValues from "gl-vec3/fromValues"; +import GLVec3Inverse from "gl-vec3/inverse"; +import GLVec3Len from "gl-vec3/len"; +import GLVec3Lerp from "gl-vec3/lerp"; +import GLVec3Max from "gl-vec3/max"; +import GLVec3Min from "gl-vec3/min"; +import GLVec3Mul from "gl-vec3/mul"; +import GLVec3Negate from "gl-vec3/negate"; +import GLVec3Normalize from "gl-vec3/normalize"; +import GLVec3Random from "gl-vec3/random"; +import GLVec3Scale from "gl-vec3/scale"; +import GLVec3ScaleAndAdd from "gl-vec3/scaleAndAdd"; +import GLVec3Set from "gl-vec3/set"; +import GLVec3SqrDist from "gl-vec3/sqrDist"; +import GLVec3SqrLen from "gl-vec3/sqrLen"; +import GLVec3Sub from "gl-vec3/sub"; +import GLVec3TransformMat3 from "gl-vec3/transformMat3"; +import GLVec3TransformMat4 from "gl-vec3/transformMat4"; +import GLVec3TransformQuat from "gl-vec3/transformQuat"; + +GlVec3.add([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3Add([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.angle([1, 2, 3], [1, 2, 3]); +GLVec3Angle([1, 2, 3], [1, 2, 3]); + +GlVec3.clone([1, 2, 3]); +GLVec3Clone([1, 2, 3]); + +GlVec3.copy([1, 2, 3], [1, 2, 3]); +GLVec3Copy([1, 2, 3], [1, 2, 3]); + +GlVec3.create(); +GLVec3Create(); + +GlVec3.dist([1, 2, 3], [1, 2, 3]); +GLVec3Dist([1, 2, 3], [1, 2, 3]); + +GlVec3.div([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3Div([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.dot([1, 2, 3], [1, 2, 3]); +GLVec3Dot([1, 2, 3], [1, 2, 3]); + +GlVec3.forEach([1, 2, 3], 5, 6, 1, () => [3], {}); +GLVec3forEach([1, 2, 3], 5, 6, 1, () => [3], {}); + +GlVec3.fromValues(1, 2, 3); +GLVec3fromValues(1, 2, 3); + +GlVec3.equals([1, 2, 3], [1, 2, 3]); +GLVec3Equals([1, 2, 3], [1, 2, 3]); + +GlVec3.exactEquals([1, 2, 3], [1, 2, 3]); +GLVec3exactEquals([1, 2, 3], [1, 2, 3]); + +GlVec3.inverse([1, 2, 3], [1, 2, 3]); +GLVec3Inverse([1, 2, 3], [1, 2, 3]); + +GlVec3.len([1, 2, 3]); +GLVec3Len([1, 2, 3]); + +GlVec3.lerp([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); +GLVec3Lerp([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); + +GlVec3.max([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3Max([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.min([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3Min([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.mul([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3Mul([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.negate([1, 2, 3], [1, 2, 3]); +GLVec3Negate([1, 2, 3], [1, 2, 3]); + +GlVec3.normalize([1, 2, 3], [1, 2, 3]); +GLVec3Normalize([1, 2, 3], [1, 2, 3]); + +GlVec3.random([1, 2, 3], 6); +GLVec3Random([1, 2, 3], 6); + +GlVec3.scale([1, 2, 3], [1, 2, 3], 6); +GLVec3Scale([1, 2, 3], [1, 2, 3], 6); + +GlVec3.scaleAndAdd([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); +GLVec3ScaleAndAdd([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); + +GlVec3.set([1, 2, 3], 1, 2, 6); +GLVec3Set([1, 2, 3], 1, 2, 6); + +GlVec3.sqrDist([1, 2, 3], [1, 2, 3]); +GLVec3SqrDist([1, 2, 3], [1, 2, 3]); + +GlVec3.sqrLen([1, 2, 3]); +GLVec3SqrLen([1, 2, 3]); + +GlVec3.sub([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3Sub([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.transformMat3([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3TransformMat3([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.transformMat4([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3TransformMat4([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +GlVec3.transformQuat([1, 2, 3], [1, 2, 3], [1, 2, 3]); +GLVec3TransformQuat([1, 2, 3], [1, 2, 3], [1, 2, 3]); diff --git a/types/gl-vec3/index.d.ts b/types/gl-vec3/index.d.ts new file mode 100644 index 0000000000..0d90cfe981 --- /dev/null +++ b/types/gl-vec3/index.d.ts @@ -0,0 +1,190 @@ +// Type definitions for gl-vec3 1.1 +// Project: https://github.com/stackgl/gl-vec3 +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.3 + +/** + * Adds two number's. + */ +export function add(out: number[], a: number[], b: number[]): number[]; + +/** + * Get the angle between two 3D vectors. + */ +export function angle(a: number[], b: number[]): number; + +/** + * Creates a new number initialized with values from an existing vector. + */ +export function clone(a: number[]): number[]; + +/** + * Math.ceil the components of a number. + */ +export function ceil(out: number[], a: number[]): number[]; + +/** + * Copy the values from one number to another. + */ +export function copy(out: number[], a: number[]): number[]; + +/** + * Creates a new, empty number. + */ +export function create(): number[]; + +/** + * Computes the cross product of two number's. + */ +export function cross(out: number[], a: number[], b: number[]): number[]; + +/** + * Calculates the euclidian distance between two number's. Aliased as dist. + */ +export function dist(a: number[], b: number[]): number; + +/** + * Divides two number's. Aliased as div. + */ +export function div(out: number[], a: number[], b: number[]): number[]; + +/** + * Calculates the dot product of two number's. + */ +export function dot(a: number[], b: number[]): number; + +/** + * Returns whether or not the vectors have approximately the same elements in the same position.. + */ +export function equals(a: number[], b: number[]): boolean; + +/** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===). + */ +export function exactEquals(a: number[], b: number[]): boolean; + +/** + * Math.floor the components of a number. + */ +export function floor(out: number[], a: number[]): number[]; + +/** + * Perform some operation over an array of numbers. + */ +export function forEach(a: number[], stride: number, offset: number, count: number, fn: (a: number[], b: number[], arg: object) => number[], arg: object): number[]; + +/** + * Creates a new number initialized with the given values. + */ +export function fromValues(x: number, y: number, z: number): number[]; + +/** + * Returns the inverse of the components of a number. + */ +export function inverse(out: number[], a: number[]): number[]; + +/** + * Calculates the length of a number. Aliased as len. + */ +export function len(a: number[]): number; + +/** + * Performs a linear interpolation between two number]'s. + */ +export function lerp(out: number[], a: number[], b: number[], t: number): number[]; + +/** + * Returns the maximum of two number's. + */ +export function max(out: number[], a: number[], b: number[]): number[]; + +/** + * Returns the minimum of two number's. + */ +export function min(out: number[], a: number[], b: number[]): number[]; + +/** + * Multiplies two number's. Aliased as mul. + */ +export function mul(out: number[], a: number[], b: number[]): number[]; + +/** + * Negates the components of a number. + */ +export function negate(out: number[], a: number[]): number[]; + +/** + * Normalize a number + */ +export function normalize(out: number[], a: number[]): number[]; + +/** + * Generates a random vector with the given scale. + */ +export function random(out: number[], scale: number): number[]; + +/** + * Rotate a 3D vector around the x-axis. + */ +export function rotateX(out: number[], a: number[], b: number[], c: number): number[]; + +/** + * Rotate a 3D vector around the y-axis. + */ +export function rotateY(out: number[], a: number[], b: number[], c: number): number[]; + +/** + * Rotate a 3D vector around the z-axis. + */ +export function rotateZ(out: number[], a: number[], b: number[], c: number): number[]; + +/** + * Math.round the components of a number. + */ +export function round(out: number[], a: number[]): number[]; + +/** + * Scales a number by a scalar number. + */ +export function scale(out: number[], a: number[], b: number): number[]; + +/** + * Adds two numbers after scaling the second operand by a scalar value. + */ +export function scaleAndAdd(out: number[], a: number[], b: number[], scale: number): number[]; + +/** + * Set the components of a number to the given values. + */ +export function set(out: number[], x: number, y: number, z: number): number[]; + +/** + * Calculates the squared euclidian distance between two number's. Aliased as sqrDist. + */ +export function sqrDist(a: number[], b: number[]): number[]; + +/** + * Calculates the squared length of a number. Aliased as sqrLen. + */ +export function sqrLen(a: number[]): number[]; + +/** + * Subtracts vector b from vector a. Aliased as sub. + */ +export function sub(out: number[], a: number[], b: number[]): number[]; + +/** + * Transforms the number with a mat3. + */ +export function transformMat3(out: number[], a: number[], m: number[]): number[]; + +/** + * Transforms the number with a mat4. 4th vector component is implicitly '1'. + */ +export function transformMat4(out: number[], a: number[], m: number[]): number[]; + +/** + * Transforms the number with a quat. + */ +export function transformQuat(out: number[], a: number[], q: number[]): number[]; diff --git a/types/gl-vec3/inverse.d.ts b/types/gl-vec3/inverse.d.ts new file mode 100644 index 0000000000..bbe2345665 --- /dev/null +++ b/types/gl-vec3/inverse.d.ts @@ -0,0 +1,6 @@ +/** + * Returns the inverse of the components of a number. + */ +declare function inverse(out: number[], a: number[]): number[]; + +export default inverse; diff --git a/types/gl-vec3/len.d.ts b/types/gl-vec3/len.d.ts new file mode 100644 index 0000000000..0bd0473614 --- /dev/null +++ b/types/gl-vec3/len.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the length of a number. Aliased as len. + */ +declare function len(a: number[]): number; + +export default len; diff --git a/types/gl-vec3/lerp.d.ts b/types/gl-vec3/lerp.d.ts new file mode 100644 index 0000000000..a595db2bf8 --- /dev/null +++ b/types/gl-vec3/lerp.d.ts @@ -0,0 +1,6 @@ +/** + * Performs a linear interpolation between two number]'s. + */ +declare function lerp(out: number[], a: number[], b: number[], t: number): number[]; + +export default lerp; diff --git a/types/gl-vec3/max.d.ts b/types/gl-vec3/max.d.ts new file mode 100644 index 0000000000..37458f7eb9 --- /dev/null +++ b/types/gl-vec3/max.d.ts @@ -0,0 +1,6 @@ +/** + * Returns the maximum of two number's. + */ +declare function max(out: number[], a: number[], b: number[]): number[]; + +export default max; diff --git a/types/gl-vec3/min.d.ts b/types/gl-vec3/min.d.ts new file mode 100644 index 0000000000..6c8cdc6600 --- /dev/null +++ b/types/gl-vec3/min.d.ts @@ -0,0 +1,6 @@ +/** + * Returns the minimum of two number's. + */ +declare function min(out: number[], a: number[], b: number[]): number[]; + +export default min; diff --git a/types/gl-vec3/mul.d.ts b/types/gl-vec3/mul.d.ts new file mode 100644 index 0000000000..76559d847a --- /dev/null +++ b/types/gl-vec3/mul.d.ts @@ -0,0 +1,6 @@ +/** + * Multiplies two number's. Aliased as mul. + */ +declare function mul(out: number[], a: number[], b: number[]): number[]; + +export default mul; diff --git a/types/gl-vec3/negate.d.ts b/types/gl-vec3/negate.d.ts new file mode 100644 index 0000000000..84b6443e30 --- /dev/null +++ b/types/gl-vec3/negate.d.ts @@ -0,0 +1,6 @@ +/** + * Negates the components of a number. + */ +declare function negate(out: number[], a: number[]): number[]; + +export default negate; diff --git a/types/gl-vec3/normalize.d.ts b/types/gl-vec3/normalize.d.ts new file mode 100644 index 0000000000..f060e59f73 --- /dev/null +++ b/types/gl-vec3/normalize.d.ts @@ -0,0 +1,6 @@ +/** + * Normalize a number + */ +declare function normalize(out: number[], a: number[]): number[]; + +export default normalize; diff --git a/types/gl-vec3/random.d.ts b/types/gl-vec3/random.d.ts new file mode 100644 index 0000000000..94fd5f57e4 --- /dev/null +++ b/types/gl-vec3/random.d.ts @@ -0,0 +1,6 @@ +/** + * Generates a random vector with the given scale. + */ +declare function random(out: number[], scale: number): number[]; + +export default random; diff --git a/types/gl-vec3/scale.d.ts b/types/gl-vec3/scale.d.ts new file mode 100644 index 0000000000..b5f8b63e9f --- /dev/null +++ b/types/gl-vec3/scale.d.ts @@ -0,0 +1,6 @@ +/** + * Scales a number by a scalar number. + */ +declare function scale(out: number[], a: number[], b: number): number[]; + +export default scale; diff --git a/types/gl-vec3/scaleAndAdd.d.ts b/types/gl-vec3/scaleAndAdd.d.ts new file mode 100644 index 0000000000..a6eea747bd --- /dev/null +++ b/types/gl-vec3/scaleAndAdd.d.ts @@ -0,0 +1,6 @@ +/** + * Adds two numbers after scaling the second operand by a scalar value. + */ +declare function scaleAndAdd(out: number[], a: number[], b: number[], scale: number): number[]; + +export default scaleAndAdd; diff --git a/types/gl-vec3/set.d.ts b/types/gl-vec3/set.d.ts new file mode 100644 index 0000000000..02d24eda97 --- /dev/null +++ b/types/gl-vec3/set.d.ts @@ -0,0 +1,6 @@ +/** + * Set the components of a number to the given values. + */ +declare function set(out: number[], x: number, y: number, z: number): number[]; + +export default set; diff --git a/types/gl-vec3/sqrDist.d.ts b/types/gl-vec3/sqrDist.d.ts new file mode 100644 index 0000000000..9488750632 --- /dev/null +++ b/types/gl-vec3/sqrDist.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the squared euclidian distance between two number's. Aliased as sqrDist. + */ +declare function sqrDist(a: number[], b: number[]): number[]; + +export default sqrDist; diff --git a/types/gl-vec3/sqrLen.d.ts b/types/gl-vec3/sqrLen.d.ts new file mode 100644 index 0000000000..99e072fa44 --- /dev/null +++ b/types/gl-vec3/sqrLen.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the squared length of a number. Aliased as sqrLen. + */ +declare function sqrLen(a: number[]): number[]; + +export default sqrLen; diff --git a/types/gl-vec3/sub.d.ts b/types/gl-vec3/sub.d.ts new file mode 100644 index 0000000000..10bcab9eca --- /dev/null +++ b/types/gl-vec3/sub.d.ts @@ -0,0 +1,6 @@ +/** + * Subtracts vector b from vector a. Aliased as sub. + */ +declare function sub(out: number[], a: number[], b: number[]): number[]; + +export default sub; diff --git a/types/gl-vec3/transformMat3.d.ts b/types/gl-vec3/transformMat3.d.ts new file mode 100644 index 0000000000..bab8234194 --- /dev/null +++ b/types/gl-vec3/transformMat3.d.ts @@ -0,0 +1,6 @@ +/** + * Transforms the number with a mat3. + */ +declare function transformMat3(out: number[], a: number[], m: number[]): number[]; + +export default transformMat3; diff --git a/types/gl-vec3/transformMat4.d.ts b/types/gl-vec3/transformMat4.d.ts new file mode 100644 index 0000000000..35c6424380 --- /dev/null +++ b/types/gl-vec3/transformMat4.d.ts @@ -0,0 +1,6 @@ +/** + * Transforms the number with a mat4. 4th vector component is implicitly '1'. + */ +declare function transformMat4(out: number[], a: number[], m: number[]): number[]; + +export default transformMat4; diff --git a/types/gl-vec3/transformQuat.d.ts b/types/gl-vec3/transformQuat.d.ts new file mode 100644 index 0000000000..2cba13bfc8 --- /dev/null +++ b/types/gl-vec3/transformQuat.d.ts @@ -0,0 +1,6 @@ +/** + * Transforms the number with a quat. + */ +declare function transformQuat(out: number[], a: number[], q: number[]): number[]; + +export default transformQuat; diff --git a/types/gl-vec3/tsconfig.json b/types/gl-vec3/tsconfig.json new file mode 100644 index 0000000000..5382911c1a --- /dev/null +++ b/types/gl-vec3/tsconfig.json @@ -0,0 +1,55 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "angle.d.ts", + "add.d.ts", + "clone.d.ts", + "copy.d.ts", + "create.d.ts", + "dist.d.ts", + "div.d.ts", + "dot.d.ts", + "equals.d.ts", + "exactEquals.d.ts", + "forEach.d.ts", + "fromValues.d.ts", + "inverse.d.ts", + "len.d.ts", + "lerp.d.ts", + "max.d.ts", + "min.d.ts", + "mul.d.ts", + "negate.d.ts", + "normalize.d.ts", + "random.d.ts", + "scale.d.ts", + "scaleAndAdd.d.ts", + "set.d.ts", + "sqrDist.d.ts", + "sqrLen.d.ts", + "sub.d.ts", + "transformMat3.d.ts", + "transformMat4.d.ts", + "transformQuat.d.ts", + "gl-vec3-tests.ts" + ] +} diff --git a/types/gl-vec3/tslint.json b/types/gl-vec3/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/gl-vec3/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/gl-vec4/add.d.ts b/types/gl-vec4/add.d.ts new file mode 100644 index 0000000000..8d7cb4e851 --- /dev/null +++ b/types/gl-vec4/add.d.ts @@ -0,0 +1,6 @@ +/** + * Adds two vec4's. + */ +declare function add(out: number[], a: number[], b: number[]): number[]; + +export default add; diff --git a/types/gl-vec4/clone.d.ts b/types/gl-vec4/clone.d.ts new file mode 100644 index 0000000000..e2b7777cd2 --- /dev/null +++ b/types/gl-vec4/clone.d.ts @@ -0,0 +1,6 @@ +/** + * Creates a new vec4 initialized with values from an existing vector. + */ +declare function clone(a: number[]): number[]; + +export default clone; diff --git a/types/gl-vec4/copy.d.ts b/types/gl-vec4/copy.d.ts new file mode 100644 index 0000000000..76e60c5cf6 --- /dev/null +++ b/types/gl-vec4/copy.d.ts @@ -0,0 +1,6 @@ +/** + * Copy the values from one vec4 to another. + */ +declare function copy(out: number[], a: number[]): number[]; + +export default copy; diff --git a/types/gl-vec4/create.d.ts b/types/gl-vec4/create.d.ts new file mode 100644 index 0000000000..93216fe4b0 --- /dev/null +++ b/types/gl-vec4/create.d.ts @@ -0,0 +1,6 @@ +/** + * Creates a new, empty vec4. + */ +declare function create(): number[]; + +export default create; diff --git a/types/gl-vec4/distance.d.ts b/types/gl-vec4/distance.d.ts new file mode 100644 index 0000000000..201b734b17 --- /dev/null +++ b/types/gl-vec4/distance.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the euclidian distance between two vec4's. + */ +declare function distance(a: number[], b: number[]): number; + +export default distance; diff --git a/types/gl-vec4/divide.d.ts b/types/gl-vec4/divide.d.ts new file mode 100644 index 0000000000..847dd7ce73 --- /dev/null +++ b/types/gl-vec4/divide.d.ts @@ -0,0 +1,6 @@ +/** + * Divides two vec4's. + */ +declare function divide(out: number[], a: number[], b: number[]): number[]; + +export default divide; diff --git a/types/gl-vec4/dot.d.ts b/types/gl-vec4/dot.d.ts new file mode 100644 index 0000000000..218d2bfe91 --- /dev/null +++ b/types/gl-vec4/dot.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the dot product of two vec4's. + */ +declare function dot(a: number[], b: number[]): number; + +export default dot; diff --git a/types/gl-vec4/fromValues.d.ts b/types/gl-vec4/fromValues.d.ts new file mode 100644 index 0000000000..84d60a9c10 --- /dev/null +++ b/types/gl-vec4/fromValues.d.ts @@ -0,0 +1,6 @@ +/** + * Creates a new vec4 initialized with the given values. + */ +declare function fromValues(x: number, y: number, z: number, w: number): number[]; + +export default fromValues; diff --git a/types/gl-vec4/gl-vec4-tests.ts b/types/gl-vec4/gl-vec4-tests.ts new file mode 100644 index 0000000000..302596450a --- /dev/null +++ b/types/gl-vec4/gl-vec4-tests.ts @@ -0,0 +1,102 @@ +import * as glVec from "gl-vec4"; + +import glVecAdd from "gl-vec4/add"; +import glVecClone from "gl-vec4/clone"; +import glVecCopy from "gl-vec4/copy"; +import glVecCreate from "gl-vec4/create"; +import glVecDistance from "gl-vec4/distance"; +import glVecDivide from "gl-vec4/divide"; +import glVecDot from "gl-vec4/dot"; +import glVecFromValues from "gl-vec4/fromValues"; +import glVecInverse from "gl-vec4/inverse"; +import glVecLength from "gl-vec4/length"; +import glVecLerp from "gl-vec4/lerp"; +import glVecMax from "gl-vec4/max"; +import glVecMin from "gl-vec4/min"; +import glVecMultiply from "gl-vec4/multiply"; +import glVecNegate from "gl-vec4/negate"; +import glVecNormalize from "gl-vec4/normalize"; +import glVecRandom from "gl-vec4/random"; +import glVecScale from "gl-vec4/scale"; +import glVecScaleAndAdd from "gl-vec4/scaleAndAdd"; +import glVecSet from "gl-vec4/set"; +import glVecSqrdDistance from "gl-vec4/squaredDistance"; +import glVecSqrdLength from "gl-vec4/squaredLength"; +import glVecSubtract from "gl-vec4/subtract"; +import glVecTransformMat4 from "gl-vec4/transformMat4"; +import glVecTransformQuat from "gl-vec4/transformQuat"; + +glVec.add([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecAdd([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.clone([1, 2, 3]); +glVecClone([1, 2, 3]); + +glVec.copy([1, 2, 3], [1, 2, 3]); +glVecCopy([1, 2, 3], [1, 2, 3]); + +glVec.create(); +glVecCreate(); + +glVec.distance([1, 2, 3], [1, 2, 3]); +glVecDistance([1, 2, 3], [1, 2, 3]); + +glVec.divide([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecDivide([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.dot([1, 2, 3], [1, 2, 3]); +glVecDot([1, 2, 3], [1, 2, 3]); + +glVec.fromValues(1, 2, 4, 5); +glVecFromValues(1, 2, 4, 5); + +glVec.inverse([1, 2, 3], [1, 2, 3]); +glVecInverse([1, 2, 3], [1, 2, 3]); + +glVec.length([1, 2, 3]); +glVecLength([1, 2, 3]); + +glVec.lerp([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); +glVecLerp([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); + +glVec.max([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecMax([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.min([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecMin([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.multiply([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecMultiply([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.negate([1, 2, 3], [1, 2, 3]); +glVecNegate([1, 2, 3], [1, 2, 3]); + +glVec.normalize([1, 2, 3], [1, 2, 3]); +glVecNormalize([1, 2, 3], [1, 2, 3]); + +glVec.random([1, 2, 3], 6); +glVecRandom([1, 2, 3], 6); + +glVec.scale([1, 2, 3], [1, 2, 3], 6); +glVecScale([1, 2, 3], [1, 2, 3], 6); + +glVec.scaleAndAdd([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); +glVecScaleAndAdd([1, 2, 3], [1, 2, 3], [1, 2, 3], 6); + +glVec.set([1, 2, 3], [1, 2, 3], [1, 2, 3], 6, 6); +glVecSet([1, 2, 3], [1, 2, 3], [1, 2, 3], 6, 6); + +glVec.squaredDistance([1, 2, 3], [1, 2, 3]); +glVecSqrdDistance([1, 2, 3], [1, 2, 3]); + +glVec.squaredLength([1, 2, 3]); +glVecSqrdLength([1, 2, 3]); + +glVec.subtract([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecSubtract([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.transformMat4([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecTransformMat4([1, 2, 3], [1, 2, 3], [1, 2, 3]); + +glVec.transformQuat([1, 2, 3], [1, 2, 3], [1, 2, 3]); +glVecTransformQuat([1, 2, 3], [1, 2, 3], [1, 2, 3]); diff --git a/types/gl-vec4/index.d.ts b/types/gl-vec4/index.d.ts new file mode 100644 index 0000000000..3d5e54e562 --- /dev/null +++ b/types/gl-vec4/index.d.ts @@ -0,0 +1,129 @@ +// Type definitions for gl-vec4 1.0 +// Project: https://github.com/stackgl/gl-vec4 +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Adds two vec4's. + */ +export function add(out: number[], a: number[], b: number[]): number[]; + +/** + * Creates a new vec4 initialized with values from an existing vector. + */ +export function clone(a: number[]): number[]; + +/** + * Copy the values from one vec4 to another. + */ +export function copy(out: number[], a: number[]): number[]; + +/** + * Creates a new, empty vec4. + */ +export function create(): number[]; + +/** + * Calculates the euclidian distance between two vec4's. + */ +export function distance(a: number[], b: number[]): number; + +/** + * Divides two vec4's. + */ +export function divide(out: number[], a: number[], b: number[]): number[]; + +/** + * Calculates the dot product of two vec4's. + */ +export function dot(a: number[], b: number[]): number; + +/** + * Creates a new vec4 initialized with the given values. + */ +export function fromValues(x: number, y: number, z: number, w: number): number[]; + +/** + * Returns the inverse of the components of a vec4. + */ +export function inverse(out: number[], a: number[]): number[]; + +/** + * Calculates the length of a vec4. + */ +export function length(a: number[]): number; + +/** + * Performs a linear interpolation between two vec4's. + */ +export function lerp(out: number[], a: number[], b: number[], t: number): number[]; + +/** + * Returns the maximum of two vec4's. + */ +export function max(out: number[], a: number[], b: number[]): number[]; + +/** + * Returns the minimum of two vec4's. + */ +export function min(out: number[], a: number[], b: number[]): number[]; + +/** + * Multiplies two vec4's. + */ +export function multiply(out: number[], a: number[], b: number[]): number[]; + +/** + * Negates the components of a vec4. + */ +export function negate(out: number[], a: number[]): number[]; + +/** + * Normalize a vec4. + */ +export function normalize(out: number[], a: number[]): number[]; + +/** + * Generates a random vector with the given scale. + */ +export function random(out: number[], scale: number): number[]; + +/** + * Scales a vec4 by a scalar number. + */ +export function scale(out: number[], a: number[], b: number): number[]; + +/** + * Adds two vec4's after scaling the second operand by a scalar value. + */ +export function scaleAndAdd(out: number[], a: number[], b: number[], scale: number): number[]; + +/** + * Set the components of a vec4 to the given values. + */ +export function set(out: number[], x: number[], y: number[], z: number, w: number): number[]; + +/** + * Calculates the squared euclidian distance between two vec4's. + */ +export function squaredDistance(a: number[], b: number[]): number; + +/** + * Calculates the squared length of a vec4. + */ +export function squaredLength(a: number[]): number; + +/** + * Subtracts vector b from vector a. + */ +export function subtract(out: number[], a: number[], b: number[]): number[]; + +/** + * Transforms the vec4 with a mat4.. + */ +export function transformMat4(out: number[], a: number[], m: number[]): number[]; + +/** + * Transforms the vec4 with a quat. + */ +export function transformQuat(out: number[], a: number[], q: number[]): number[]; diff --git a/types/gl-vec4/inverse.d.ts b/types/gl-vec4/inverse.d.ts new file mode 100644 index 0000000000..4df5cb7491 --- /dev/null +++ b/types/gl-vec4/inverse.d.ts @@ -0,0 +1,6 @@ +/** + * Returns the inverse of the components of a vec4. + */ +declare function inverse(out: number[], a: number[]): number[]; + +export default inverse; diff --git a/types/gl-vec4/length.d.ts b/types/gl-vec4/length.d.ts new file mode 100644 index 0000000000..229b629c89 --- /dev/null +++ b/types/gl-vec4/length.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the length of a vec4. + */ +declare function length(a: number[]): number; + +export default length; diff --git a/types/gl-vec4/lerp.d.ts b/types/gl-vec4/lerp.d.ts new file mode 100644 index 0000000000..c56471ecf1 --- /dev/null +++ b/types/gl-vec4/lerp.d.ts @@ -0,0 +1,6 @@ +/** + * Performs a linear interpolation between two vec4's. + */ +declare function lerp(out: number[], a: number[], b: number[], t: number): number[]; + +export default lerp; diff --git a/types/gl-vec4/max.d.ts b/types/gl-vec4/max.d.ts new file mode 100644 index 0000000000..ca179a75ab --- /dev/null +++ b/types/gl-vec4/max.d.ts @@ -0,0 +1,6 @@ +/** + * Returns the maximum of two vec4's. + */ +declare function max(out: number[], a: number[], b: number[]): number[]; + +export default max; diff --git a/types/gl-vec4/min.d.ts b/types/gl-vec4/min.d.ts new file mode 100644 index 0000000000..48544195a5 --- /dev/null +++ b/types/gl-vec4/min.d.ts @@ -0,0 +1,6 @@ +/** + * Returns the minimum of two vec4's. + */ +declare function min(out: number[], a: number[], b: number[]): number[]; + +export default min; diff --git a/types/gl-vec4/multiply.d.ts b/types/gl-vec4/multiply.d.ts new file mode 100644 index 0000000000..9708f570ea --- /dev/null +++ b/types/gl-vec4/multiply.d.ts @@ -0,0 +1,6 @@ +/** + * Multiplies two vec4's. + */ +declare function multiply(out: number[], a: number[], b: number[]): number[]; + +export default multiply; diff --git a/types/gl-vec4/negate.d.ts b/types/gl-vec4/negate.d.ts new file mode 100644 index 0000000000..b62a5bab84 --- /dev/null +++ b/types/gl-vec4/negate.d.ts @@ -0,0 +1,6 @@ +/** + * Negates the components of a vec4. + */ +declare function negate(out: number[], a: number[]): number[]; + +export default negate; diff --git a/types/gl-vec4/normalize.d.ts b/types/gl-vec4/normalize.d.ts new file mode 100644 index 0000000000..2d09e91543 --- /dev/null +++ b/types/gl-vec4/normalize.d.ts @@ -0,0 +1,6 @@ +/** + * Normalize a vec4. + */ +declare function normalize(out: number[], a: number[]): number[]; + +export default normalize; diff --git a/types/gl-vec4/random.d.ts b/types/gl-vec4/random.d.ts new file mode 100644 index 0000000000..94fd5f57e4 --- /dev/null +++ b/types/gl-vec4/random.d.ts @@ -0,0 +1,6 @@ +/** + * Generates a random vector with the given scale. + */ +declare function random(out: number[], scale: number): number[]; + +export default random; diff --git a/types/gl-vec4/scale.d.ts b/types/gl-vec4/scale.d.ts new file mode 100644 index 0000000000..cb6d5747a8 --- /dev/null +++ b/types/gl-vec4/scale.d.ts @@ -0,0 +1,6 @@ +/** + * Scales a vec4 by a scalar number. + */ +declare function scale(out: number[], a: number[], b: number): number[]; + +export default scale; diff --git a/types/gl-vec4/scaleAndAdd.d.ts b/types/gl-vec4/scaleAndAdd.d.ts new file mode 100644 index 0000000000..3912aadceb --- /dev/null +++ b/types/gl-vec4/scaleAndAdd.d.ts @@ -0,0 +1,6 @@ +/** + * Adds two vec4's after scaling the second operand by a scalar value. + */ +declare function scaleAndAdd(out: number[], a: number[], b: number[], scale: number): number[]; + +export default scaleAndAdd; diff --git a/types/gl-vec4/set.d.ts b/types/gl-vec4/set.d.ts new file mode 100644 index 0000000000..36040f5638 --- /dev/null +++ b/types/gl-vec4/set.d.ts @@ -0,0 +1,6 @@ +/** + * Set the components of a vec4 to the given values. + */ +declare function set(out: number[], x: number[], y: number[], z: number, w: number): number[]; + +export default set; diff --git a/types/gl-vec4/squaredDistance.d.ts b/types/gl-vec4/squaredDistance.d.ts new file mode 100644 index 0000000000..539f702ffb --- /dev/null +++ b/types/gl-vec4/squaredDistance.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the squared euclidian distance between two vec4's. + */ +declare function squaredDistance(a: number[], b: number[]): number; + +export default squaredDistance; diff --git a/types/gl-vec4/squaredLength.d.ts b/types/gl-vec4/squaredLength.d.ts new file mode 100644 index 0000000000..226d528c81 --- /dev/null +++ b/types/gl-vec4/squaredLength.d.ts @@ -0,0 +1,6 @@ +/** + * Calculates the squared length of a vec4. + */ +declare function squaredLength(a: number[]): number; + +export default squaredLength; diff --git a/types/gl-vec4/subtract.d.ts b/types/gl-vec4/subtract.d.ts new file mode 100644 index 0000000000..1ba0aba3bc --- /dev/null +++ b/types/gl-vec4/subtract.d.ts @@ -0,0 +1,6 @@ +/** + * Subtracts vector b from vector a. + */ +declare function subtract(out: number[], a: number[], b: number[]): number[]; + +export default subtract; diff --git a/types/gl-vec4/transformMat4.d.ts b/types/gl-vec4/transformMat4.d.ts new file mode 100644 index 0000000000..762b5c4bc8 --- /dev/null +++ b/types/gl-vec4/transformMat4.d.ts @@ -0,0 +1,6 @@ +/** + * Transforms the vec4 with a mat4.. + */ +declare function transformMat4(out: number[], a: number[], m: number[]): number[]; + +export default transformMat4; diff --git a/types/gl-vec4/transformQuat.d.ts b/types/gl-vec4/transformQuat.d.ts new file mode 100644 index 0000000000..8f6dadd4c1 --- /dev/null +++ b/types/gl-vec4/transformQuat.d.ts @@ -0,0 +1,6 @@ +/** + * Transforms the vec4 with a quat. + */ +declare function transformQuat(out: number[], a: number[], q: number[]): number[]; + +export default transformQuat; diff --git a/types/gl-vec4/tsconfig.json b/types/gl-vec4/tsconfig.json new file mode 100644 index 0000000000..341f7c3271 --- /dev/null +++ b/types/gl-vec4/tsconfig.json @@ -0,0 +1,50 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "add.d.ts", + "clone.d.ts", + "copy.d.ts", + "create.d.ts", + "distance.d.ts", + "divide.d.ts", + "dot.d.ts", + "fromValues.d.ts", + "inverse.d.ts", + "length.d.ts", + "lerp.d.ts", + "max.d.ts", + "min.d.ts", + "multiply.d.ts", + "negate.d.ts", + "normalize.d.ts", + "random.d.ts", + "scale.d.ts", + "scaleAndAdd.d.ts", + "set.d.ts", + "squaredDistance.d.ts", + "squaredLength.d.ts", + "subtract.d.ts", + "transformMat4.d.ts", + "transformQuat.d.ts", + "gl-vec4-tests.ts" + ] +} diff --git a/types/gl-vec4/tslint.json b/types/gl-vec4/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/gl-vec4/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/google-apps-script/google-apps-script.base.d.ts b/types/google-apps-script/google-apps-script.base.d.ts index 9f7153a6bb..5c2a8d9155 100644 --- a/types/google-apps-script/google-apps-script.base.d.ts +++ b/types/google-apps-script/google-apps-script.base.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2019-01-23 +// Type definitions for Google Apps Script 2019-02-27 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -284,7 +284,9 @@ declare namespace GoogleAppsScript { * // A simple INFO log message, using sprintf() formatting. * console.info('Timing the %s function (%d arguments)', 'myFunction', 1); * - * // Log a JSON object at a DEBUG level. Writes the stringified object to the log. + * // Log a JSON object at a DEBUG level. If the object contains a property called "message", + * // that is used as the summary in the log viewer, otherwise a stringified version of + * // the object is used as the summary. * var parameters = { * isValid: true, * content: 'some string', diff --git a/types/google-apps-script/google-apps-script.data-studio.d.ts b/types/google-apps-script/google-apps-script.data-studio.d.ts index 332dff6dbc..c86bd39447 100644 --- a/types/google-apps-script/google-apps-script.data-studio.d.ts +++ b/types/google-apps-script/google-apps-script.data-studio.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2019-01-23 +// Type definitions for Google Apps Script 2019-02-27 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -127,6 +127,7 @@ declare namespace GoogleAppsScript { getFormula(): string; getGroup(): string; getId(): string; + getIsReaggregatable(): boolean; getName(): string; getType(): FieldType; isDefault(): boolean; @@ -139,6 +140,7 @@ declare namespace GoogleAppsScript { setGroup(group: string): Field; setId(id: string): Field; setIsHidden(isHidden: boolean): Field; + setIsReaggregatable(isReaggregatable: boolean): Field; setName(name: string): Field; setType(type: FieldType): Field; } diff --git a/types/google-apps-script/google-apps-script.spreadsheet.d.ts b/types/google-apps-script/google-apps-script.spreadsheet.d.ts index d8dc3bc4d0..ba28d9719c 100644 --- a/types/google-apps-script/google-apps-script.spreadsheet.d.ts +++ b/types/google-apps-script/google-apps-script.spreadsheet.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Apps Script 2019-01-23 +// Type definitions for Google Apps Script 2019-02-27 // Project: https://developers.google.com/apps-script/ // Definitions by: motemen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -49,6 +49,35 @@ declare namespace GoogleAppsScript { */ export enum BandingTheme { LIGHT_GREY, CYAN, GREEN, YELLOW, ORANGE, BLUE, TEAL, GREY, BROWN, LIGHT_GREEN, INDIGO, PINK } + /** + * Access the existing BigQuery data source specification. To create a new data source + * specification, use SpreadsheetApp.newDataSourceSpec(). + */ + export interface BigQueryDataSourceSpec { + copy(): DataSourceSpecBuilder; + getParameters(): DataSourceParameter[]; + getProjectId(): string; + getRawQuery(): string; + getType(): DataSourceType; + } + + /** + * The builder for BigQueryDataSourceSpecBuilder. + */ + export interface BigQueryDataSourceSpecBuilder { + build(): DataSourceSpec; + copy(): DataSourceSpecBuilder; + getParameters(): DataSourceParameter[]; + getProjectId(): string; + getRawQuery(): string; + getType(): DataSourceType; + removeAllParameters(): BigQueryDataSourceSpecBuilder; + removeParameter(parameterName: string): BigQueryDataSourceSpecBuilder; + setParameterFromCell(parameterName: string, sourceCell: string): BigQueryDataSourceSpecBuilder; + setProjectId(projectId: string): BigQueryDataSourceSpecBuilder; + setRawQuery(rawQuery: string): BigQueryDataSourceSpecBuilder; + } + /** * Access boolean conditions in ConditionalFormatRules. Each * conditional format rule may contain a single boolean condition. The boolean condition itself @@ -167,6 +196,154 @@ declare namespace GoogleAppsScript { */ export enum CopyPasteType { PASTE_NORMAL, PASTE_NO_BORDERS, PASTE_FORMAT, PASTE_FORMULA, PASTE_DATA_VALIDATION, PASTE_VALUES, PASTE_CONDITIONAL_FORMATTING, PASTE_COLUMN_WIDTHS } + /** + * An enumeration of data execution error codes. + */ + export enum DataExecutionErrorCode { DATA_EXECUTION_ERROR_CODE_UNSUPPORTED, NONE, TIME_OUT, TOO_MANY_ROWS, TOO_MANY_CELLS, ENGINE, PARAMETER_INVALID, UNSUPPORTED_DATA_TYPE, DUPLICATE_COLUMN_NAMES, INTERRUPTED, OTHER, TOO_MANY_CHARS_PER_CELL } + + /** + * An enumeration of data execution states. + */ + export enum DataExecutionState { DATA_EXECUTION_STATE_UNSUPPORTED, RUNNING, SUCCESS, ERROR, NOT_STARTED } + + /** + * The data execution status. + */ + export interface DataExecutionStatus { + getErrorCode(): DataExecutionErrorCode; + getErrorMessage(): string; + getExecutionState(): DataExecutionState; + getLastRefreshedTime(): Date; + isTruncated(): boolean; + } + + /** + * Access and modify existing data source. To create a data source table with new data source, see + * DataSourceTable. + */ + export interface DataSource { + getSpec(): DataSourceSpec; + updateSpec(spec: DataSourceSpec): DataSource; + } + + /** + * Access existing data source parameters. + */ + export interface DataSourceParameter { + getName(): string; + getSourceCell(): string; + getType(): DataSourceParameterType; + } + + /** + * An enumeration of data source parameter types. + */ + export enum DataSourceParameterType { DATA_SOURCE_PARAMETER_TYPE_UNSUPPORTED, CELL } + + /** + * Access the general settings of an existing data source spec. To access data source spec for + * certain type, use as...() method. To create a new data source spec, use SpreadsheetApp.newDataSourceSpec(). + * + * This example shows how to get information from a BigQuery data source spec. + * + * var dataSourceTable = + * SpreadsheetApp.getActive().getSheetByName("Data Sheet 1").getDataSourceTables()[0]; + * var spec = dataSourceTable.getDataSource().getSpec(); + * if (spec.getType() == SpreadsheetApp.DataSourceType.BIGQUERY) { + * var bqSpec = spec.asBigQuery(); + * Logger.log("Project ID: %s\n", bqSpec.getProjectId()); + * Logger.log("Raw query string: %s\n", bqSpec.getRawQuery()); + * } + */ + export interface DataSourceSpec { + asBigQuery(): BigQueryDataSourceSpec; + copy(): DataSourceSpecBuilder; + getParameters(): DataSourceParameter[]; + getType(): DataSourceType; + } + + /** + * The builder for DataSourceSpec. To create a specification for certain type, use as...() method. To create a new builder, use SpreadsheetApp.newDataSourceSpec(). To use the specification, see DataSourceTable. + * + * This examples show how to build a BigQuery data source specification. + * + * var spec = SpreadsheetApp.newDataSourceSpec() + * .asBigQuery() + * .setProjectId('big_query_project') + * .setRawQuery('select @FIELD from table limit @LIMIT') + * .setParameterFromCell('FIELD', 'Sheet1!A1') + * .setParameterFromCell('LIMIT', 'namedRangeCell') + * .build(); + */ + export interface DataSourceSpecBuilder { + asBigQuery(): BigQueryDataSourceSpecBuilder; + build(): DataSourceSpec; + copy(): DataSourceSpecBuilder; + getParameters(): DataSourceParameter[]; + getType(): DataSourceType; + removeAllParameters(): DataSourceSpecBuilder; + removeParameter(parameterName: string): DataSourceSpecBuilder; + setParameterFromCell(parameterName: string, sourceCell: string): DataSourceSpecBuilder; + } + + /** + * Access and modify existing data source table. To create a new data source table on a new sheet, + * use Spreadsheet.insertSheetWithDataSourceTable(spec). + * + * This example shows how to create a new data source table. + * + * SpreadsheetApp.enableBigQueryExecution(); + * var spreadsheet = SpreadsheetApp.getActive(); + * var spec = SpreadsheetApp.newDataSourceSpec() + * .asBigQuery() + * .setProjectId('big_query_project') + * .setRawQuery('select @FIELD from table limit @LIMIT') + * .setParameterFromCell('FIELD', 'Sheet1!A1') + * .setParameterFromCell('LIMIT', 'namedRangeCell') + * .build(); + * // Starts data execution asynchronously. + * var dataSheet = spreadsheet.insertSheetWithDataSourceTable(spec); + * var dataSourceTable = dataSheet.getDataSourceTables()[0]; + * // waitForCompletion() blocks script execution until data execution completes. + * dataSourceTable.waitForCompletion(60); + * // Check status after execution. + * Logger.log("Data execution state: %s.", dataSourceTable.getStatus().getExecutionState()); + * + * This example shows how to edit a data source. + * + * SpreadsheetApp.enableBigQueryExecution(); + * var dataSheet = SpreadsheetApp.getActive().getSheetByName("Data Sheet 1"); + * var dataSourceTable = dataSheet.getDataSourceTables()[0]; + * var dataSource = dataSourceTable.getDataSource(); + * var newSpec = dataSource.getSpec() + * .copy() + * .asBigQuery() + * .setRawQuery('select name from table limit 2') + * .removeAllParameters() + * .build(); + * // Updates data source specification and starts data execution asynchronously. + * dataSource.updateSpec(newSpec); + * // Check status during execution. + * Logger.log("Data execution state: %s.", dataSourceTable.getStatus().getExecutionState()); + * // waitForCompletion() blocks script execution until data execution completes. + * dataSourceTable.waitForCompletion(60); + * // Check status after execution. + * Logger.log("Data execution state: %s.", dataSourceTable.getStatus().getExecutionState()); + */ + export interface DataSourceTable { + forceRefreshData(): DataSourceTable; + getDataSource(): DataSource; + getRange(): Range; + getStatus(): DataExecutionStatus; + refreshData(): DataSourceTable; + waitForCompletion(timeoutInSeconds: Integer): DataExecutionStatus; + } + + /** + * An enumeration of data source types. + */ + export enum DataSourceType { DATA_SOURCE_TYPE_UNSUPPORTED, BIGQUERY } + /** * Access data validation rules. To create a new rule, use SpreadsheetApp.newDataValidation() and DataValidationBuilder. You can use * Range.setDataValidation(rule) to set the validation rule for a range. @@ -1215,6 +1392,7 @@ declare namespace GoogleAppsScript { getBandings(): Banding[]; getCell(row: Integer, column: Integer): Range; getColumn(): Integer; + getDataSourceTables(): DataSourceTable[]; getDataSourceUrl(): string; getDataTable(): Charts.DataTable; getDataTable(firstRowIsHeader: boolean): Charts.DataTable; @@ -1493,6 +1671,7 @@ declare namespace GoogleAppsScript { getConditionalFormatRules(): ConditionalFormatRule[]; getCurrentCell(): Range; getDataRange(): Range; + getDataSourceTables(): DataSourceTable[]; getDeveloperMetadata(): DeveloperMetadata[]; getFilter(): Filter; getFormUrl(): string; @@ -1627,6 +1806,7 @@ declare namespace GoogleAppsScript { getColumnWidth(columnPosition: Integer): Integer; getCurrentCell(): Range; getDataRange(): Range; + getDataSourceTables(): DataSourceTable[]; getDeveloperMetadata(): DeveloperMetadata[]; getEditors(): Base.User[]; getFormUrl(): string; @@ -1677,6 +1857,7 @@ declare namespace GoogleAppsScript { insertSheet(sheetName: string, sheetIndex: Integer): Sheet; insertSheet(sheetName: string, sheetIndex: Integer, options: Object): Sheet; insertSheet(sheetName: string, options: Object): Sheet; + insertSheetWithDataSourceTable(spec: DataSourceSpec): Sheet; isColumnHiddenByUser(columnPosition: Integer): boolean; isRowHiddenByFilter(rowPosition: Integer): boolean; isRowHiddenByUser(rowPosition: Integer): boolean; @@ -1728,6 +1909,10 @@ declare namespace GoogleAppsScript { BooleanCriteria: typeof BooleanCriteria; BorderStyle: typeof BorderStyle; CopyPasteType: typeof CopyPasteType; + DataExecutionErrorCode: typeof DataExecutionErrorCode; + DataExecutionState: typeof DataExecutionState; + DataSourceParameterType: typeof DataSourceParameterType; + DataSourceType: typeof DataSourceType; DataValidationCriteria: typeof DataValidationCriteria; DeveloperMetadataLocationType: typeof DeveloperMetadataLocationType; DeveloperMetadataVisibility: typeof DeveloperMetadataVisibility; @@ -1744,6 +1929,8 @@ declare namespace GoogleAppsScript { WrapStrategy: typeof WrapStrategy; create(name: string): Spreadsheet; create(name: string, rows: Integer, columns: Integer): Spreadsheet; + enableAllDataSourcesExecution(): void; + enableBigQueryExecution(): void; flush(): void; getActive(): Spreadsheet; getActiveRange(): Range; @@ -1754,6 +1941,7 @@ declare namespace GoogleAppsScript { getSelection(): Selection; getUi(): Base.Ui; newConditionalFormatRule(): ConditionalFormatRuleBuilder; + newDataSourceSpec(): DataSourceSpecBuilder; newDataValidation(): DataValidationBuilder; newFilterCriteria(): FilterCriteriaBuilder; newRichTextValue(): RichTextValueBuilder; diff --git a/types/google.script.client-side/google.script.client-side-tests.ts b/types/google.script.client-side/google.script.client-side-tests.ts index 5e3c059c01..57867f8456 100644 --- a/types/google.script.client-side/google.script.client-side-tests.ts +++ b/types/google.script.client-side/google.script.client-side-tests.ts @@ -1,7 +1,7 @@ google.script.url.getLocation(location => { - location.hash; // $ExpectedType string - location.parameter; // $ExpectedType { [key: string]: string } - location.parameters; // $ExpectedType { [key: string]: ReadonlyArray } + location.hash; // $ExpectType string + location.parameter; // $ExpectType { [key: string]: string; } + location.parameters; // $ExpectType { [key: string]: ReadonlyArray; } }); google.script.history.push(null); @@ -13,10 +13,10 @@ google.script.history.replace({ timestamp: Date.now() }, { foo: 'bar', fiz: 'baz google.script.history.replace({ timestamp: Date.now() }, { foo: ['bar', 'cat'], fiz: 'baz' }, 'anchor1'); google.script.history.setChangeHandler(e => { - e.state; // $ExpectedType google.script.history.State - e.location.hash; // $ExpectedType string - e.location.parameter; // $ExpectedType { [key: string]: string } - e.location.parameters; // $ExpectedType { [key: string]: ReadonlyArray } + e.state; // $ExpectType State + e.location.hash; // $ExpectType string + e.location.parameter; // $ExpectType { [key: string]: string; } + e.location.parameters; // $ExpectType { [key: string]: ReadonlyArray; } }); google.script.host.origin; // $ExpectType string @@ -25,15 +25,79 @@ google.script.host.editor.focus(); google.script.host.setHeight(450); google.script.host.setWidth(300); -google.script.run.withSuccessHandler(() => {}).executeScript({ message: 'test for google.script.run' }); +google.script.run.withSuccessHandler(() => {}); // $ExpectType Runner +google.script.run.withFailureHandler(() => {}); // $ExpectType Runner +google.script.run.withUserObject({}); // $ExpectType Runner google.script.run .withSuccessHandler(value => {}) - .withFailureHandler(error => {}) - .getEmail(); + .withFailureHandler(error => { + error; // $ExpectType Error + }); google.script.run .withSuccessHandler((value, userObject) => {}) - .withFailureHandler((error, userObject) => {}) - .withUserObject({}) - .getSomeData(Date.now(), { options: 'none' }, 'anchor1', true, null); + .withFailureHandler((error, userObject) => { + error; // $ExpectType Error + }) + .withUserObject({}); + +google.script.run.testFunctionWithoutParameter(); +google.script.run.testFunctionWithNumber(0); +google.script.run.testFunctionWithBoolean(true); +google.script.run.testFunctionWithString(""); +google.script.run.testFunctionWithNull(null); +google.script.run.testFunctionWithArray([ + 0, + true, + "", + null, + undefined, + [], + { + number: 0, + boolean: true, + string: "", + nullValue: null, + undef: undefined, + array: [0, true, "", null, undefined, [], {}], + object: {} + } +]); +google.script.run.testFunctionWithObject({ + number: 0, + boolean: true, + string: "", + nullValue: null, + undef: undefined, + array: [0, true, "", null, undefined, [], {}], + object: {} +}); +google.script.run.testFunctionWithMultipleParameters( + 0, + true, + "", + null, + undefined, + [ + 0, + true, + "", + null, + undefined, + [], + {} + ], + { + number: 0, + boolean: true, + string: "", + nullValue: null, + undef: undefined, + array: [0, true, "", null, undefined, [], {}], + object: {} + } +); +google.script.run.testFunctionWithForm(new HTMLFormElement()); +google.script.run.testFunctionWithDateError(new Date()); // $ExpectError +google.script.run.testFunctionWithFunctionError(() => {}); // $ExpectError diff --git a/types/google.script.client-side/index.d.ts b/types/google.script.client-side/index.d.ts index 7d497fd6c2..23e92255a7 100644 --- a/types/google.script.client-side/index.d.ts +++ b/types/google.script.client-side/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package Google Apps Script Client-side API 0.0 +// Type definitions for non-npm package Google Apps Script Client-side API 0.1 // Project: https://developers.google.com/apps-script/guides/html/reference/host // Definitions by: clomie // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -118,12 +118,14 @@ declare namespace google.script { const run: Runner; - interface Runner { + type Parameter = number | boolean | string | { [index: number]: Parameter } | { [key: string]: Parameter } | null | undefined; + + type Runner = { /** * Executes the server-side Apps Script function with the corresponding name. */ - [functionName: string]: (...args: any[]) => void; - + [functionName: string]: (first?: Parameter | HTMLFormElement, ...rest: Parameter[]) => void; + } & { /** * Sets a callback function to run if the server-side function throws an exception. * Without a failure handler, failures are logged to the JavaScript console. @@ -147,5 +149,5 @@ declare namespace google.script { * User objects cannot, however, be objects constructed with the new operator */ withUserObject(object: any): Runner; - } + }; } diff --git a/types/google.script.client-side/tsconfig.json b/types/google.script.client-side/tsconfig.json index 83c99e2f06..e573df04f9 100644 --- a/types/google.script.client-side/tsconfig.json +++ b/types/google.script.client-side/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/googlemaps/googlemaps-tests.ts b/types/googlemaps/googlemaps-tests.ts index ac7217dd17..a62a0e23b1 100644 --- a/types/googlemaps/googlemaps-tests.ts +++ b/types/googlemaps/googlemaps-tests.ts @@ -4,6 +4,7 @@ let mapOptions: google.maps.MapOptions = { backgroundColor: "#fff", center: { lat: -25.363, lng: 131.044 }, clickableIcons: true, + controlSize: 30, draggable: true, fullscreenControl: true, fullscreenControlOptions: { @@ -124,7 +125,7 @@ data.setStyle({ cursor: "pointer", fillColor: "#79B55B", fillOpacity: 1, - icon: { url: "//maps.google.com/mapfiles/ms/icons/blue.png" }, + icon: { url: "//maps.google.com/mapfiles/ms/icons/blue.png" } as google.maps.Icon, shape: { coords: [1, 2, 3], type: "circle" }, strokeColor: "#79B55B", strokeOpacity: 1, @@ -449,3 +450,8 @@ service.findPlaceFromPhoneNumber({ results[0].name; // $ExpectType string }); + +/***** google.maps.places.Autocomplete *****/ +const autocomplete = new google.maps.places.Autocomplete(document.createElement('input')); +const placeResult = autocomplete.getPlace(); +placeResult.name; // $ExpectType string diff --git a/types/googlemaps/index.d.ts b/types/googlemaps/index.d.ts index 099bb9ef68..000917313b 100644 --- a/types/googlemaps/index.d.ts +++ b/types/googlemaps/index.d.ts @@ -11,6 +11,7 @@ // Sven Kreiss // Umar Bolatov // Michael Gauthier +// Colin Doig // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* @@ -93,6 +94,14 @@ declare namespace google.maps { * interest, also known as a POI. By default map icons are clickable. */ clickableIcons?: boolean + /** + * Size in pixels of the controls appearing on the map. This value must be + * supplied directly when creating the Map, updating this value later may + * bring the controls into an undefined state. Only governs the controls + * made by the Maps API itself. Does not scale developer created custom + * controls. + */ + controlSize?: number; /** Enables/disables all default UI. May be overridden individually. */ disableDefaultUI?: boolean; /** Enables/disables zoom and center on double click. Enabled by default. */ @@ -2726,29 +2735,29 @@ declare namespace google.maps { } export interface PlaceResult { - address_components: GeocoderAddressComponent[]; - adr_address: string; - aspects: PlaceAspectRating[]; - formatted_address: string; - formatted_phone_number: string; - geometry: PlaceGeometry; - html_attributions: string[]; - icon: string; - id: string; - international_phone_number: string; + address_components?: GeocoderAddressComponent[]; + adr_address?: string; + aspects?: PlaceAspectRating[]; + formatted_address?: string; + formatted_phone_number?: string; + geometry?: PlaceGeometry; + html_attributions?: string[]; + icon?: string; + id?: string; + international_phone_number?: string; name: string; - opening_hours: OpeningHours; - permanently_closed: boolean; - photos: PlacePhoto[]; - place_id: string; - price_level: number; - rating: number; - reviews: PlaceReview[]; - types: string[]; - url: string; - utc_offset: number; - vicinity: string; - website: string; + opening_hours?: OpeningHours; + permanently_closed?: boolean; + photos?: PlacePhoto[]; + place_id?: string; + price_level?: number; + rating?: number; + reviews?: PlaceReview[]; + types?: string[]; + url?: string; + utc_offset?: number; + vicinity?: string; + website?: string; } export interface PlaceReview { diff --git a/types/got/index.d.ts b/types/got/index.d.ts index 0c847d6489..a9f289b831 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -36,6 +36,7 @@ declare class HTTPError extends StdError { statusCode: number; statusMessage: string; headers: http.IncomingHttpHeaders; + body: Buffer | string | object; } declare class MaxRedirectsError extends StdError { diff --git a/types/gsap/Animation.d.ts b/types/gsap/Animation.d.ts index 8744e205bf..1c26798810 100644 --- a/types/gsap/Animation.d.ts +++ b/types/gsap/Animation.d.ts @@ -29,8 +29,8 @@ declare namespace gsap { * Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any * parameters that should be passed to that callback. */ - eventCallback(type: string): () => void; - eventCallback(type: string, callback: () => void, params?: any[], scope?: any): Animation; + eventCallback(type: string): (...args: any[]) => void; + eventCallback(type: string, callback: (...args: any[]) => void, params?: any[], scope?: any): Animation; /** * Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded diff --git a/types/gsap/Ease.d.ts b/types/gsap/Ease.d.ts index 56603b5ed1..a7c594ef41 100644 --- a/types/gsap/Ease.d.ts +++ b/types/gsap/Ease.d.ts @@ -1,6 +1,6 @@ declare namespace gsap { class Ease { - constructor(func?: () => void, extraParams?: any[], type?: number, power?: number); + constructor(func?: (...args: any[]) => void, extraParams?: any[], type?: number, power?: number); /** Translates the tween's progress ratio into the corresponding ease ratio. */ getRatio(p: number): number; diff --git a/types/gsap/Timeline.d.ts b/types/gsap/Timeline.d.ts index 232d2ed9a3..74b9e50396 100644 --- a/types/gsap/Timeline.d.ts +++ b/types/gsap/Timeline.d.ts @@ -31,13 +31,13 @@ declare namespace gsap { addLabel(label: string, position: any): TimelineLite; /** Inserts a special callback that pauses playback of the timeline at a particular time or label. */ - addPause(position?: any, callback?: () => void, params?: any[], scope?: any): TimelineLite; + addPause(position?: any, callback?: (...args: any[]) => void, params?: any[], scope?: any): TimelineLite; /** * Adds a callback to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as * add( TweenLite.delayedCall(...) ) but with less code. */ - call(callback: () => void, params?: any[], scope?: any, position?: any): TimelineLite; + call(callback: (...args: any[]) => void, params?: any[], scope?: any, position?: any): TimelineLite; /** Empties the timeline of all tweens, timelines, and callbacks (and optionally labels too). */ clear(labels?: boolean): TimelineLite; @@ -106,7 +106,7 @@ declare namespace gsap { vars: {}, stagger?: number, position?: any, - onCompleteAll?: () => void, + onCompleteAll?: (...args: any[]) => void, onCompleteAllParams?: any[], onCompleteScope?: any ): TimelineLite; @@ -122,7 +122,7 @@ declare namespace gsap { toVars: {}, stagger?: number, position?: any, - onCompleteAll?: () => void, + onCompleteAll?: (...args: any[]) => void, onCompleteAllParams?: any[], onCompleteAllScope?: any ): TimelineLite; @@ -137,7 +137,7 @@ declare namespace gsap { vars: {}, stagger: number, position?: any, - onCompleteAll?: () => void, + onCompleteAll?: (...args: any[]) => void, onCompleteAllParams?: any[], onCompleteAllScope?: any ): TimelineLite; @@ -156,14 +156,14 @@ declare namespace gsap { class TimelineMax extends TimelineLite { constructor(vars?: {}); - addCallback(callback: () => void, position: any, params?: any[], scope?: any): TimelineMax; + addCallback(callback: (...args: any[]) => void, position: any, params?: any[], scope?: any): TimelineMax; currentLabel(): string; currentLabel(value: string): TimelineMax; getActive(nested?: boolean, tweens?: boolean, timelines?: boolean): Tween | Timeline[]; getLabelAfter(time: number): string; getLabelBefore(time: number): string; getLabelsArray(): Array<{ name: string; time: number }>; - removeCallback(callback: () => void, timeOrLabel?: any): TimelineMax; + removeCallback(callback: (...args: any[]) => void, timeOrLabel?: any): TimelineMax; removePause(position: any): TimelineMax; repeat(): number; repeat(value: number): TimelineMax; diff --git a/types/gsap/Tween.d.ts b/types/gsap/Tween.d.ts index 11de164f00..3dd15ca685 100644 --- a/types/gsap/Tween.d.ts +++ b/types/gsap/Tween.d.ts @@ -22,7 +22,7 @@ declare namespace gsap { static ticker: any; /** Provides a simple way to call a () => void after a set amount of time (or frames). */ - static delayedCall(delay: number, callback: () => void, params?: any[], scope?: any, useFrames?: boolean): TweenLite; + static delayedCall(delay: number, callback: (...args: any[]) => void, params?: any[], scope?: any, useFrames?: boolean): TweenLite; /** * Static method for creating a TweenLite instance that tweens backwards - you define the BEGINNING values and the current values are used as the destination values which is great for doing @@ -49,7 +49,7 @@ declare namespace gsap { invalidate(): TweenLite; /** Immediately kills all of the delayedCalls to a particular () => void. */ - static killDelayedCallsTo(func: () => void): void; + static killDelayedCallsTo(func: (...args: any[]) => void): void; /** Kills all the tweens (or specific tweening properties) of a particular object or delayedCalls to a particular () => void. */ static killTweensOf(target: any, onlyActive?: boolean, vars?: any): void; @@ -74,7 +74,7 @@ declare namespace gsap { constructor(target: {}, duration: number, vars: {}); /** Provides a simple way to call a () => void after a set amount of time (or frames). */ - static delayedCall(delay: number, callback: () => void, params?: any[], scope?: {}, useFrames?: boolean): TweenMax; + static delayedCall(delay: number, callback: (...args: any[]) => void, params?: any[], scope?: {}, useFrames?: boolean): TweenMax; /** * Static method for creating a TweenMax instance that tweens backwards - you define the BEGINNING values and the current values are used as the destination values which is great for @@ -110,7 +110,7 @@ declare namespace gsap { static killChildTweensOf(parent: any, complete?: boolean): void; /** Immediately kills all of the delayedCalls to a particular () => void. */ - static killDelayedCallsTo(func: () => void): void; + static killDelayedCallsTo(func: (...args: any[]) => void): void; /** Kills all the tweens (or specific tweening properties) of a particular object or the delayedCalls to a particular () => void. */ static killTweensOf(target: {}, vars?: {}): void; @@ -144,7 +144,7 @@ declare namespace gsap { duration: number, vars: {}, stagger: number, - onCompleteAll?: () => void, + onCompleteAll?: (...args: any[]) => void, onCompleteAllParams?: any[], onCompleteAllScope?: any ): any[]; @@ -159,7 +159,7 @@ declare namespace gsap { fromVars: {}, toVars: {}, stagger: number, - onCompleteAll?: () => void, + onCompleteAll?: (...args: any[]) => void, onCompleteAllParams?: any[], onCompleteAllScope?: any ): any[]; @@ -173,7 +173,7 @@ declare namespace gsap { duration: number, vars: {}, stagger: number, - onCompleteAll?: () => void, + onCompleteAll?: (...args: any[]) => void, onCompleteAllParams?: any[], onCompleteAllScope?: any ): any[]; diff --git a/types/gsap/TweenConfig.d.ts b/types/gsap/TweenConfig.d.ts index 38b00404e6..9912613694 100644 --- a/types/gsap/TweenConfig.d.ts +++ b/types/gsap/TweenConfig.d.ts @@ -23,7 +23,7 @@ declare namespace gsap { overwrite?: string | number; /** A () => void that should be called when the animation has completed. */ - onComplete?: () => void; + onComplete?: (...args: any[]) => void; /** An Array of parameters to pass the onComplete () => void */ onCompleteParams?: any[]; @@ -39,7 +39,7 @@ declare namespace gsap { immediateRender?: boolean; /** A () => void that should be called when the tween has reached its beginning again from the reverse direction. */ - onReverseComplete?: () => void; + onReverseComplete?: (...args: any[]) => void; /** An Array of parameters to pass the onReverseComplete () => void. */ onReverseCompleteParams?: any[]; @@ -48,7 +48,7 @@ declare namespace gsap { onReverseCompleteScope?: {}; /** A () => void that should be called when the tween begins (when its time changes from 0 to some other value which can happen more than once if the tween is restarted multiple times). */ - onStart?: () => void; + onStart?: (...args: any[]) => void; /** An Array of parameters to pass the onStart () => void. */ onStartParams?: any[]; @@ -57,7 +57,7 @@ declare namespace gsap { onStartScope?: {}; /** A () => void that should be called every time the animation updates (on every frame while the animation is active). */ - onUpdate?: () => void; + onUpdate?: (...args: any[]) => void; /** An Array of parameters to pass the onUpdate () => void. */ onUpdateParams?: any[]; @@ -81,7 +81,7 @@ declare namespace gsap { lazy?: boolean; /** A () => void that should be called when the tween gets overwritten by another tween. */ - onOverwrite?: () => void; + onOverwrite?: (...args: any[]) => void; /** If true atuomatically populates the css property for tween on DOM elements */ autoCSS?: boolean; @@ -95,7 +95,7 @@ declare namespace gsap { repeatDelay?: number; - onRepeat?: () => void; + onRepeat?: (...args: any[]) => void; onRepeatScope?: {}; } diff --git a/types/gsap/gsap-tests.ts b/types/gsap/gsap-tests.ts index 36192141be..411ca19d0c 100644 --- a/types/gsap/gsap-tests.ts +++ b/types/gsap/gsap-tests.ts @@ -1,11 +1,22 @@ import { TweenLite, TweenMax } from 'gsap'; +const callbackWithoutParams = () => { + console.log('I Have No Parameters.'); +}; + +const callbackWithParams = (...args: any[]) => { + console.log('I Have Parameters.'); + console.log(args); +}; + + const tweenLiteExample = TweenLite .to(document.getElementById('some-div'), 1, { width: '200px', height: '200px', x: '100px', - y: '200px' + y: '200px', + onComplete: callbackWithoutParams }) .seek(0.5); @@ -14,6 +25,8 @@ const tweenMaxExample = TweenMax width: '200px', height: '200px', x: '100px', - y: '200px' + y: '200px', + onComplete: callbackWithParams, + onCompleteParams: ['foo', 'bar'] }) .seek(0.5); diff --git a/types/gsap/index.d.ts b/types/gsap/index.d.ts index 5e3081cc6a..5f1a20a17d 100644 --- a/types/gsap/index.d.ts +++ b/types/gsap/index.d.ts @@ -5,6 +5,7 @@ // Richard Fox , // Philip Bulley , // Leonardo Melo +// Adem Hodzic // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/gulp-gh-pages/gulp-gh-pages-tests.ts b/types/gulp-gh-pages/gulp-gh-pages-tests.ts index e541f18508..6fee2842e0 100644 --- a/types/gulp-gh-pages/gulp-gh-pages-tests.ts +++ b/types/gulp-gh-pages/gulp-gh-pages-tests.ts @@ -19,5 +19,8 @@ gulp.src("test.css") gulp.src("test.css") .pipe(ghPages({push: false})); +gulp.src("test.css") + .pipe(ghPages({ force: true })); + gulp.src("test.css") .pipe(ghPages({message: "master"})); diff --git a/types/gulp-gh-pages/index.d.ts b/types/gulp-gh-pages/index.d.ts index f01b9890f1..782f9e9b56 100644 --- a/types/gulp-gh-pages/index.d.ts +++ b/types/gulp-gh-pages/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for gulp-gh-pages // Project: https://github.com/rowoot/gulp-gh-pages // Definitions by: Asana +// Ntnyq // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -12,6 +13,7 @@ interface Options { branch?: string; cacheDir?: string; push?: boolean; + force?: boolean; message?: string; } diff --git a/types/gulp-template/index.d.ts b/types/gulp-template/index.d.ts index a2270eb387..f325cfb9c1 100644 --- a/types/gulp-template/index.d.ts +++ b/types/gulp-template/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/sindresorhus/gulp-template#readme // Definitions by: Peter Safranek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 /// diff --git a/types/gulp/package.json b/types/gulp/package.json new file mode 100644 index 0000000000..a0e2ec3c5c --- /dev/null +++ b/types/gulp/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "chokidar": "^2.1.2" + } +} diff --git a/types/gulp/test/index.ts b/types/gulp/test/index.ts index f5ca436450..4b096a8704 100644 --- a/types/gulp/test/index.ts +++ b/types/gulp/test/index.ts @@ -1,12 +1,12 @@ import * as gulp from 'gulp'; import * as undertaker from 'undertaker'; import * as registry from 'undertaker-registry'; -import del = require("del"); const minify: () => any = () => { }; const jade: () => any = () => { }; const someplugin: () => any = () => { }; const promisedDel: (list: string[]) => any = (list) => { }; +const del: (pattern: string | string[]) => any = (pattern) => { }; gulp.src('client/templates/*.jade') .pipe(jade()) diff --git a/types/gun/gun-tests.ts b/types/gun/gun-tests.ts new file mode 100644 index 0000000000..d196fba695 --- /dev/null +++ b/types/gun/gun-tests.ts @@ -0,0 +1,72 @@ +import GunServer = require('gun'); +import Gun = require('gun/gun'); +import 'gun/lib/path.js'; +import 'gun/lib/not.js'; +import 'gun/lib/open.js'; +import 'gun/lib/load.js'; +import 'gun/lib/then.js'; +import 'gun/lib/bye.js'; +import 'gun/lib/later.js'; +import 'gun/lib/unset.js'; +import 'gun/lib/time.js'; + +GunServer('http://yourdomain.com/gun'); +Gun(['http://server1.com/gun', 'http://server2.com/gun']); +Gun({ + s3: { + key: '', + secret: '', + bucket: '' + }, + file: 'file/path.json', + uuid() { + return 'xxxxxx'; + } +}); + +interface AppState { + object: { + num: number; + str: string; + bool: boolean; + obj: { + arr2: Array<{ foo: number; bar: string }>; + }; + }; + chatRoom: Array<{ by: string; message: string }>; +} + +const app = new Gun(); +app.get('object') + .get('bool') + .put(true); +app.get('object') + .get('num') + .put(1); +app.get('object') + .get('obj') + .get('arr2') + .set({ foo: 1, bar: '2' }); + +app.get('object') + .get('bool') + // $ExpectError + .put(1); + +app.get('object').on(data => { + data.bool; +}); +app.get('object').off(); +app.get('object').once(data => { + if (data) data.bool; +}); +async function name() { + const data = await app.get('object').promise!(); + data.put.bool; +} +app.get('chatRoom').time!({ by: 'A', message: 'Hello' }); +app.get('chatRoom').time!(msg => { + msg.by; +}, 20); +// $ExpectError +app.get('object').time!({ a: 1 }); diff --git a/types/gun/gun.d.ts b/types/gun/gun.d.ts new file mode 100644 index 0000000000..47b40a68f7 --- /dev/null +++ b/types/gun/gun.d.ts @@ -0,0 +1,2 @@ +declare const cons: typeof import('./index'); +export = cons; diff --git a/types/gun/index.d.ts b/types/gun/index.d.ts new file mode 100644 index 0000000000..51d02b68d5 --- /dev/null +++ b/types/gun/index.d.ts @@ -0,0 +1,295 @@ +// Type definitions for gun 0.9 +// Project: https://github.com/amark/gun#readme +// Definitions by: Jack Works +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +declare const cons: Gun.Constructor; +export = cons; + +declare namespace Gun { + type ArrayOf = T extends Array ? U : never; + /** Gun does not accept Array value, so we need extract to make types correct */ + type AllowArray = ArrayOf extends never ? T : ArrayOf; + type DisallowArray = ArrayOf extends never ? T : never; + type ArrayAsRecord = ArrayOf extends never ? DataType : Record; + /** + * options['module name'] allows you to pass options to a 3rd party module. + * Their project README will likely list the exposed options + * https://github.com/amark/gun/wiki/Modules + */ + type ConstructorOptions = Partial<{ + /** Undocumented but mentioned. Write data to a JSON. */ + file: string; + /** Undocumented but mentioned. Create a websocket server */ + web: any; + /** Undocumented but mentioned. Amazon S3 */ + s3: { + key: any; + secret: any; + bucket: any; + }; + /** the URLs are properties, and the value is an empty object. */ + peers: Record; + /** default: true, creates and persists local (nodejs) data using Radisk. */ + radisk: boolean; + /** default: true, persists local (browser) data to localStorage. */ + localStorage: boolean; + /** uuid allows you to override the default 24 random alphanumeric soul generator with your own function. */ + uuid(): string; + /** + * allows you to pass options to a 3rd party module. Their project README will likely list the exposed options + * @see https://github.com/amark/gun/wiki/Modules + */ + [key: string]: any; + }>; + type Saveable = Partial | string | number | boolean | null | ChainReference; + type AckCallback = (ack: { err: Error; ok: any } | { err: undefined; ok: string }) => void; + interface ChainReference { + /** + * Save data into gun, syncing it with your connected peers. + * + * * You cannot save primitive values at the root level. + * + * @param data You do not need to re-save the entire object every time, + * gun will automatically merge your data into what already exists as a "partial" update. + * + * * `undefined`, `NaN`, `Infinity`, `array`, will be rejected. + * * Traditional arrays are dangerous in real-time apps. Use `gun.set` instead. + * + * @param callback invoked on each acknowledgment + */ + put(data: DisallowArray, callback?: AckCallback): ChainReference; + /** + * Where to read data from. + * @param key The key is the ID or property name of the data that you saved from earlier + * (or that will be saved later). + * * Note that if you use .put at any depth after a get it first reads the data and then writes, merging the data as a partial update. + * @param callback You will usually be using gun.on or gun.once to actually retrieve your data, + * not this callback (it is intended for more low level control, for module and extensions). + * + * **Avoid use callback. The type in the document may be wrong.** + * + * **Here the type of callback respect to the actual behavior** + */ + get( + key: ArrayOf extends never ? K : never, + callback?: ( + /** the raw data. Internal node of gun. Will not typed here. */ + paramA: Record< + 'gun' | '$' | 'root' | 'id' | 'back' | 'on' | 'tag' | 'get' | 'soul' | 'ack' | 'put', + any + >, + /** the key, ID, or property name of the data. */ + paramB: Record<'off' | 'to' | 'next' | 'the' | 'on' | 'as' | 'back' | 'rid' | 'id', any> + ) => void + ): ChainReference; + /** + * Change the configuration of the gun database instance. + * @param options The options argument is the same object you pass to the constructor. + * + * The options's properties replace those in the instance's configuration but options.peers are **added** to peers known to the gun instance. + * @returns No mention in the document, behavior as `ChainReference` + */ + opt(options: ConstructorOptions): ChainReference; + /** + * Move up to the parent context on the chain. + * + * Every time a new chain is created, a reference to the old context is kept to go back to. + * @param amount The number of times you want to go back up the chain. + * `-1` or `Infinity` will take you to the root. + * @returns Impossible to determinate final type. You must cast it by yourself. + */ + back(amount?: number): ChainReference; + + // Main API + /** + * Subscribe to updates and changes on a node or property in realtime. + * @param option Currently, the only option is to filter out old data, and just be given the changes. + * If you're listening to a node with 100 fields, and just one changes, + * you'll instead be passed a node with a single property representing that change rather than the full node every time. + * @param callback + * Once initially and whenever the property or node you're focused on changes, this callback is immediately fired with the data as it is at that point in time. + * + * Since gun streams data, the callback will probably be called multiple times as new chunk comes in. + * To remove a listener call .off() on the same property or node. + */ + on( + callback: (data: ArrayAsRecord, key: ReferenceKey) => void, + option?: { change: boolean } | boolean + ): ChainReference; + /** + * Get the current data without subscribing to updates. Or `undefined` if it cannot be found. + * @returns In the document, it said the return value may change in the future. Don't rely on it. + */ + once( + callback?: (data: (ArrayAsRecord) | undefined, key: ReferenceKey) => void, + option?: { wait: number } + ): ChainReference; + /** + * **.set does not means 'set data', it means a Mathematical Set** + * + * Add a unique item to an unordered list. + * `gun.set` works like a mathematical set, where each item in the list is unique. + * If the item is added twice, it will be merged. + * + * **This means only objects, for now, are supported.** + */ + set( + data: DataType extends Array + ? U extends { [key: string]: any; [key: number]: any } + ? ArrayOf + : never + : never, + callback?: AckCallback + ): ChainReference>; + /** + * Map iterates over each property and item on a node, passing it down the chain, + * behaving like a forEach on your data. + * It also subscribes to every item as well and listens for newly inserted items. + */ + map( + callback?: (value: ArrayOf, key: DataType) => ArrayOf | undefined + ): ChainReference, ReferenceKey>; + /** + * Undocumented, but extremely useful and mentioned in the document + * + * Remove **all** listener on this node. + */ + off(): void; + + // Extended API + /** + * + * Path does the same thing as `.get` but has some conveniences built in. + * @deprecated This is not friendly with type system. + * + * **Warning**: This extension was removed from core, you probably shouldn't be using it! + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/path.js')` or + * ``! + */ + path?(path: string | string[]): ChainReference; + /** + * Handle cases where data can't be found. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/not.js')` or + * ``! + */ + not?(callback: (key: ReferenceKey) => void): ChainReference; + /** + * Open behaves very similarly to gun.on, except it gives you the **full depth of a document** on every update. + * It also works with graphs, tables, or other data structures. Think of it as opening up a live connection to a document. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/open.js')` or + * ``! + */ + open?(callback: (data: ArrayAsRecord) => void): ChainReference; + /** + * Loads the full object once. It is the same as `open` but with the behavior of `once`. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/load.js')` or + * ``! + */ + load?(callback: (data: ArrayAsRecord) => void): ChainReference; + /** + * Returns a promise for you to use. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/then.js')` or + * ``! + */ + then?>( + onfulfilled?: (value: TResult1) => TResult1 | PromiseLike + ): Promise; + /** + * Returns a promise for you to use. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/then.js')` or + * ``! + */ + promise?< + TResult1 = { put: ArrayAsRecord; key: ReferenceKey; gun: ChainReference } + >( + onfulfilled?: (value: TResult1) => TResult1 | PromiseLike + ): Promise; + /** + * bye lets you change data after that browser peer disconnects. + * This is useful for games and status messages, + * that if a player leaves you can remove them from the game or set a user's status to "away". + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/bye.js')` or + * ``! + */ + bye?(): { + put(data: DisallowArray>): void; + }; + /** + * Say you save some data, but want to do something with it later, like expire it or refresh it. + * Well, then `later` is for you! You could use this to easily implement a TTL or similar behavior. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/later.js')` or + * ``! + */ + later?( + callback: ( + this: ChainReference, + data: ArrayAsRecord, + key: ReferenceKey + ) => void, + seconds: number + ): ChainReference; + /** + * After you save some data in an unordered list, you may need to remove it. + * + * **Warning**: Not included by default! You must include it yourself via `require('gun/lib/unset.js')` or + * ``! + */ + unset?(data: ArrayOf): ChainReference; + /** + * Subscribes to all future events that occur on the Timegraph and retrieve a specified number of old events + * + * **Warning**: The Timegraph extension isn't required by default, you would need to include at "gun/lib/time.js" + */ + time?( + callback: (data: ArrayOf, key: ReferenceKey, time: number) => void, + alsoReceiveNOldEvents?: number + ): ChainReference; + /** Pushes data to a Timegraph with it's time set to Gun.state()'s time */ + time?(data: ArrayOf): void; + } + + interface GunSEA { + // There is no the only content in the api document. + user: { + create(alias: string, passphrase: string, callback: (...args: any[]) => void): any; + }; + } + + interface Constructor { + /** + * @description + * no parameters creates a local datastore using the default persistence layer, either localStorage or Radisk. + * @param options + * passing a URL creates the above local datastore that also tries to sync with the URL. + * + * or you can pass in an array of URLs to sync with multiple peers. + */ + (options?: string | string[] | ConstructorOptions): ChainReference & GunSEA; + new (options?: string | string[] | ConstructorOptions): ChainReference & GunSEA; + node: { + /** Returns true if data is a gun node, otherwise false. */ + is(anything: any): anything is ChainReference; + /** + * Returns data's gun ID (instead of manually grabbing its metadata i.e. data["_"]["#"], which is faster but could change in the future) + * + * Returns undefined if data is not correct gun data. + */ + soul(data: ChainReference): string; + /** Returns a "gun-ified" variant of the json input by injecting a new gun ID into the metadata field. */ + ify(json: any): any; + }; + /** @see https://gun.eco/docs/SEA */ + SEA: any; + } +} +declare const Gun: Gun.Constructor; diff --git a/types/wait-for-localhost/tsconfig.json b/types/gun/tsconfig.json similarity index 91% rename from types/wait-for-localhost/tsconfig.json rename to types/gun/tsconfig.json index fb190a232f..0b6beab5e6 100644 --- a/types/wait-for-localhost/tsconfig.json +++ b/types/gun/tsconfig.json @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", - "wait-for-localhost-tests.ts" + "gun.d.ts", + "gun-tests.ts" ] } diff --git a/types/gun/tslint.json b/types/gun/tslint.json new file mode 100644 index 0000000000..982ecfcd14 --- /dev/null +++ b/types/gun/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json", "rules": { "no-unnecessary-generics": false } } diff --git a/types/handlebars-helpers/package.json b/types/handlebars-helpers/package.json new file mode 100644 index 0000000000..bd9f09c2c3 --- /dev/null +++ b/types/handlebars-helpers/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "handlebars": ">=4.1.0" + } +} diff --git a/types/handlebars-helpers/tsconfig.json b/types/handlebars-helpers/tsconfig.json index e822854459..6b03737014 100644 --- a/types/handlebars-helpers/tsconfig.json +++ b/types/handlebars-helpers/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es2015" ], "noImplicitAny": true, "noImplicitThis": false, diff --git a/types/handlebars/handlebars-tests.ts b/types/handlebars/handlebars-tests.ts deleted file mode 100644 index 340bbde590..0000000000 --- a/types/handlebars/handlebars-tests.ts +++ /dev/null @@ -1,87 +0,0 @@ - -//import Handlebars = require('handlebars'); -import * as Handlebars from 'handlebars'; - -const context = { - author: { firstName: 'Alan', lastName: 'Johnson' }, - body: 'I Love Handlebars', - comments: [{ - author: { firstName: 'Yehuda', lastName: 'Katz' }, - body: 'Me too!' - }] -}; -Handlebars.registerHelper('fullName', (person: typeof context.author) => { - return person.firstName + ' ' + person.lastName; -}); - -Handlebars.registerHelper('agree_button', function() { - return new Handlebars.SafeString( - '' - ); -}); - -const source1 = '

Hello, my name is {{name}}. I am from {{hometown}}. I have ' + - '{{kids.length}} kids:

' + - '
    {{#kids}}
  • {{name}} is {{age}}
  • {{/kids}}
'; -const template1 = Handlebars.compile(source1); -template1({ name: "Alan", hometown: "Somewhere, TX", kids: [{name: "Jimmy", age: 12}, {name: "Sally", age: 4}]}); - -Handlebars.registerHelper('link_to', (context: typeof post) => { - return '' + context.body + ''; -}); -const post = { url: "/hello-world", body: "Hello World!" }; -const context2 = { posts: [post] }; -const source2 = '
    {{#posts}}
  • {{{link_to this}}}
  • {{/posts}}
'; -const template2: HandlebarsTemplateDelegate<{ posts: { url: string, body: string }[] }> = Handlebars.compile(source2); -template2(context2); - -Handlebars.registerHelper('link_to', (title: string, context: typeof post) => { - return '' + title + '!'; -}); -const context3 = { posts: [{url: '/hello-world', body: 'Hello World!'}] }; -const source3 = '
    {{#posts}}
  • {{{link_to "Post" this}}}
  • {{/posts}}
'; -const template3 = Handlebars.compile(source3); -template3(context3); - -const source4 = '
    {{#people}}
  • {{#link}}{{name}}{{/link}}
  • {{/people}}
'; -Handlebars.registerHelper('link', function(context: any) { - return '' + context.fn(this) + ''; -}); -const template4 = Handlebars.compile<{ people: { name: string, id: number }[] }>(source4); -const data2 = { 'people': [ - { 'name': 'Alan', 'id': 1 }, - { 'name': 'Yehuda', 'id': 2 } -]}; -template4(data2); - -const source5 = '
    {{#people}}
  • {{> link}}
  • {{/people}}
'; -Handlebars.registerPartial('link', '{{name}}'); -const template5 = Handlebars.compile(source5); -const data3 = { 'people': [ - { 'name': 'Alan', 'id': 1 }, - { 'name': 'Yehuda', 'id': 2 } -]}; -template5(data3); - -const source6 = '{{#list nav}}{{title}}{{/list}}'; -const template6 = Handlebars.compile(source6); -Handlebars.registerHelper('list', (context, options: Handlebars.HelperOptions) => { - let ret = "
    "; - for(let i=0, j=context.length; i" + options.fn(context[i]) + ""; - } - return ret + "
"; -}); -template6([{url:"", title:""}]) - - -const escapedExpression = Handlebars.Utils.escapeExpression(''); - -Handlebars.helpers !== undefined; - -const parsedTmpl = Handlebars.parse('

Hello, my name is {{name}}.

', { - srcName: "/foo/bar/baz.hbs", - ignoreStandalone: true -}); - -const parsedTmplWithoutOptions = Handlebars.parse('

Hello, my name is {{name}}.

'); diff --git a/types/handlebars/index.d.ts b/types/handlebars/index.d.ts deleted file mode 100644 index d6bebcb457..0000000000 --- a/types/handlebars/index.d.ts +++ /dev/null @@ -1,349 +0,0 @@ -// Type definitions for Handlebars v4.0.11 -// Project: http://handlebarsjs.com/ -// Definitions by: Boris Yankov , Sergei Dorogin -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -declare namespace Handlebars { - export interface TemplateDelegate { - (context: T, options?: RuntimeOptions): string; - } - - export type Template = TemplateDelegate|string; - - export interface RuntimeOptions { - partial?: boolean; - depths?: any[]; - helpers?: { [name: string]: Function }; - partials?: { [name: string]: HandlebarsTemplateDelegate }; - decorators?: { [name: string]: Function }; - data?: any; - blockParams?: any[]; - } - - export interface HelperOptions { - fn: TemplateDelegate; - inverse: TemplateDelegate; - hash: any; - data?: any; - } - - export interface HelperDelegate { - (context?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, options?: HelperOptions): any; - } - export interface HelperDeclareSpec { - [key: string]: HelperDelegate; - } - - export interface ParseOptions { - srcName?: string, - ignoreStandalone?: boolean - } - - export function registerHelper(name: string, fn: HelperDelegate): void; - export function registerHelper(name: HelperDeclareSpec): void; - export function unregisterHelper(name: string): void; - - export function registerPartial(name: string, fn: Template): void; - export function registerPartial(spec: { [name: string]: HandlebarsTemplateDelegate }): void; - export function unregisterPartial(name: string): void; - - // TODO: replace Function with actual signature - export function registerDecorator(name: string, fn: Function): void; - export function unregisterDecorator(name: string): void; - - export function K(): void; - export function createFrame(object: any): any; - export function blockParams(obj: any[], ids: any[]): any[]; - export function Exception(message: string): void; - export function log(level: number, obj: any): void; - export function parse(input: string, options?: ParseOptions): hbs.AST.Program; - export function compile(input: any, options?: CompileOptions): HandlebarsTemplateDelegate; - export function precompile(input: any, options?: PrecompileOptions): TemplateSpecification; - export function template(precompilation: TemplateSpecification): HandlebarsTemplateDelegate; - - export function create(): typeof Handlebars; - - export const escapeExpression: typeof Utils.escapeExpression; - //export const Utils: typeof hbs.Utils; - export const logger: Logger; - export const templates: HandlebarsTemplates; - export const helpers: { [name: string]: HelperDelegate }; - export const partials: { [name: string]: any }; - // TODO: replace Function with actual signature - export const decorators: { [name: string]: Function }; - - export function noConflict(): typeof Handlebars; - - export class SafeString { - constructor(str: string); - toString(): string; - toHTML(): string; - } - - export namespace Utils { - export function escapeExpression(str: string): string; - export function createFrame(object: any): any; - export function blockParams(obj: any[], ids: any[]): any[]; - export function isEmpty(obj: any) : boolean; - export function extend(obj: any, ...source: any[]): any; - export function toString(obj: any): string; - export function isArray(obj: any): boolean; - export function isFunction(obj: any): boolean; - } - - export namespace AST { - export const helpers: hbs.AST.helpers; - } - - interface ICompiler { - accept(node: hbs.AST.Node): void; - Program(program: hbs.AST.Program): void; - BlockStatement(block: hbs.AST.BlockStatement): void; - PartialStatement(partial: hbs.AST.PartialStatement): void; - PartialBlockStatement(partial: hbs.AST.PartialBlockStatement): void; - DecoratorBlock(decorator: hbs.AST.DecoratorBlock): void; - Decorator(decorator: hbs.AST.Decorator): void; - MustacheStatement(mustache: hbs.AST.MustacheStatement): void; - ContentStatement(content: hbs.AST.ContentStatement): void; - CommentStatement(comment?: hbs.AST.CommentStatement): void; - SubExpression(sexpr: hbs.AST.SubExpression): void; - PathExpression(path: hbs.AST.PathExpression): void; - StringLiteral(str: hbs.AST.StringLiteral): void; - NumberLiteral(num: hbs.AST.NumberLiteral): void; - BooleanLiteral(bool: hbs.AST.BooleanLiteral): void; - UndefinedLiteral(): void; - NullLiteral(): void; - Hash(hash: hbs.AST.Hash): void; - } - - export class Visitor implements ICompiler { - accept(node: hbs.AST.Node): void; - acceptKey(node: hbs.AST.Node, name: string): void; - acceptArray(arr: hbs.AST.Expression[]): void; - Program(program: hbs.AST.Program): void; - BlockStatement(block: hbs.AST.BlockStatement): void; - PartialStatement(partial: hbs.AST.PartialStatement): void; - PartialBlockStatement(partial: hbs.AST.PartialBlockStatement): void; - DecoratorBlock(decorator: hbs.AST.DecoratorBlock): void; - Decorator(decorator: hbs.AST.Decorator): void; - MustacheStatement(mustache: hbs.AST.MustacheStatement): void; - ContentStatement(content: hbs.AST.ContentStatement): void; - CommentStatement(comment?: hbs.AST.CommentStatement): void; - SubExpression(sexpr: hbs.AST.SubExpression): void; - PathExpression(path: hbs.AST.PathExpression): void; - StringLiteral(str: hbs.AST.StringLiteral): void; - NumberLiteral(num: hbs.AST.NumberLiteral): void; - BooleanLiteral(bool: hbs.AST.BooleanLiteral): void; - UndefinedLiteral(): void; - NullLiteral(): void; - Hash(hash: hbs.AST.Hash): void; - } -} - -/** -* Implement this interface on your MVW/MVVM/MVC views such as Backbone.View -**/ -interface HandlebarsTemplatable { - template: HandlebarsTemplateDelegate; -} - -// NOTE: for backward compatibility of this typing -type HandlebarsTemplateDelegate = Handlebars.TemplateDelegate; - -interface HandlebarsTemplates { - [index: string]: HandlebarsTemplateDelegate; -} - -interface TemplateSpecification { - -} - -// for backward compatibility of this typing -type RuntimeOptions = Handlebars.RuntimeOptions; - -interface CompileOptions { - data?: boolean; - compat?: boolean; - knownHelpers?: { - helperMissing?: boolean; - blockHelperMissing?: boolean; - each?: boolean; - if?: boolean; - unless?: boolean; - with?: boolean; - log?: boolean; - lookup?: boolean; - }; - knownHelpersOnly?: boolean; - noEscape?: boolean; - strict?: boolean; - assumeObjects?: boolean; - preventIndent?: boolean; - ignoreStandalone?: boolean; - explicitPartialContext?: boolean; -} - -interface PrecompileOptions extends CompileOptions { - srcName?: string; - destName?: string; -} - -declare namespace hbs { - // for backward compatibility of this typing - type SafeString = Handlebars.SafeString; - - type Utils = typeof Handlebars.Utils; -} - -interface Logger { - DEBUG: number; - INFO: number; - WARN: number; - ERROR: number; - level: number; - - methodMap: { [level: number]: string }; - - log(level: number, obj: string): void; -} - -declare namespace hbs { - namespace AST { - interface Node { - type: string; - loc: SourceLocation; - } - - interface SourceLocation { - source: string; - start: Position; - end: Position; - } - - interface Position { - line: number; - column: number; - } - - interface Program extends Node { - body: Statement[]; - blockParams: string[]; - } - - interface Statement extends Node {} - - interface MustacheStatement extends Statement { - path: PathExpression | Literal; - params: Expression[]; - hash: Hash; - escaped: boolean; - strip: StripFlags; - } - - interface Decorator extends MustacheStatement { } - - interface BlockStatement extends Statement { - path: PathExpression; - params: Expression[]; - hash: Hash; - program: Program; - inverse: Program; - openStrip: StripFlags; - inverseStrip: StripFlags; - closeStrip: StripFlags; - } - - interface DecoratorBlock extends BlockStatement { } - - interface PartialStatement extends Statement { - name: PathExpression | SubExpression; - params: Expression[]; - hash: Hash; - indent: string; - strip: StripFlags; - } - - interface PartialBlockStatement extends Statement { - name: PathExpression | SubExpression; - params: Expression[]; - hash: Hash; - program: Program; - openStrip: StripFlags; - closeStrip: StripFlags; - } - - interface ContentStatement extends Statement { - value: string; - original: StripFlags; - } - - interface CommentStatement extends Statement { - value: string; - strip: StripFlags; - } - - interface Expression extends Node {} - - interface SubExpression extends Expression { - path: PathExpression; - params: Expression[]; - hash: Hash; - } - - interface PathExpression extends Expression { - data: boolean; - depth: number; - parts: string[]; - original: string; - } - - interface Literal extends Expression {} - interface StringLiteral extends Literal { - value: string; - original: string; - } - - interface BooleanLiteral extends Literal { - value: boolean; - original: boolean; - } - - interface NumberLiteral extends Literal { - value: number; - original: number; - } - - interface UndefinedLiteral extends Literal {} - - interface NullLiteral extends Literal {} - - interface Hash extends Node { - pairs: HashPair[]; - } - - interface HashPair extends Node { - key: string; - value: Expression; - } - - interface StripFlags { - open: boolean; - close: boolean; - } - - interface helpers { - helperExpression(node: Node): boolean; - scopeId(path: PathExpression): boolean; - simpleId(path: PathExpression): boolean; - } - } -} - -declare module "handlebars" { - export = Handlebars; -} - -declare module "handlebars/runtime" { - export = Handlebars; -} diff --git a/types/handlebars/tsconfig.json b/types/handlebars/tsconfig.json deleted file mode 100644 index 0008e2154e..0000000000 --- a/types/handlebars/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "files": [ - "index.d.ts", - "handlebars-tests.ts" - ], - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - } -} diff --git a/types/handlebars/v1/index.d.ts b/types/handlebars/v1/index.d.ts deleted file mode 100644 index a66c8f7ee6..0000000000 --- a/types/handlebars/v1/index.d.ts +++ /dev/null @@ -1,184 +0,0 @@ -// Type definitions for Handlebars 1.0 -// Project: http://handlebarsjs.com/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -// Use either HandlebarsStatic or HandlebarsRuntimeStatic -declare var Handlebars: HandlebarsStatic; -//declare var Handlebars: HandlebarsRuntimeStatic; - -/** -* Implement this interface on your MVW/MVVM/MVC views such as Backbone.View -**/ -interface HandlebarsTemplatable { - template: HandlebarsTemplateDelegate; -} - -interface HandlebarsTemplateDelegate { - (context: any, options?: any): string; -} - -interface HandlebarsCommon { - registerHelper(name: string, fn: Function, inverse?: boolean): void; - registerPartial(name: string, str: any): void; - K(): void; - createFrame(object: any): any; - - Exception(message: string): void; - SafeString: typeof hbs.SafeString; - Utils: typeof hbs.Utils; - - logger: Logger; - log(level: number, obj: any): void; -} - -interface HandlebarsStatic extends HandlebarsCommon { - parse(input: string): hbs.AST.ProgramNode; - compile(input: any, options?: any): HandlebarsTemplateDelegate; -} - -interface HandlebarsTemplates { - [index: string]: HandlebarsTemplateDelegate; -} - -interface HandlebarsRuntimeStatic extends HandlebarsCommon { - // Handlebars.templates is the default template namespace in precompiler. - templates: HandlebarsTemplates; -} - -declare namespace hbs { - class SafeString { - constructor(str: string); - static toString(): string; - } - - namespace Utils { - function escapeExpression(str: string): string; - } -} - -interface Logger { - DEBUG: number; - INFO: number; - WARN: number; - ERROR: number; - level: number; - - methodMap: { [level: number]: string }; - - log(level: number, obj: string): void; -} - -declare namespace hbs { - namespace AST { - interface IStripInfo { - left?: boolean; - right?: boolean; - inlineStandalone?: boolean; - } - - class NodeBase { - firstColumn: number; - firstLine: number; - lastColumn: number; - lastLine: number; - type: string; - } - - class ProgramNode extends NodeBase { - statements: NodeBase[]; - } - - class IdNode extends NodeBase { - original: string; - parts: string[]; - string: string; - depth: number; - idName: string; - isSimple: boolean; - stringModeValue: string; - } - - class HashNode extends NodeBase { - pairs: {0: string; - 1: NodeBase}[]; - } - - class SexprNode extends NodeBase { - hash: HashNode; - id: NodeBase; - params: NodeBase[]; - isHelper: boolean; - eligibleHelper: boolean; - } - - class MustacheNode extends NodeBase { - strip: IStripInfo; - escaped: boolean; - sexpr: SexprNode; - - } - - class BlockNode extends NodeBase { - mustache: MustacheNode; - program: ProgramNode; - inverse: ProgramNode; - strip: IStripInfo; - isInverse: boolean; - } - - class PartialNameNode extends NodeBase { - name: string; - } - - class PartialNode extends NodeBase { - partialName: PartialNameNode; - context: NodeBase; - hash: HashNode; - strip: IStripInfo; - } - - class RawBlockNode extends NodeBase { - mustache: MustacheNode; - program: ProgramNode; - } - - class ContentNode extends NodeBase { - original: string; - string: string; - } - - class DataNode extends NodeBase { - id: IdNode; - stringModeValue: string; - idName: string; - } - - class StringNode extends NodeBase { - original: string; - string: string; - stringModeValue: string; - } - - class NumberNode extends NodeBase { - original: string; - number: string; - stringModeValue: number; - } - - class BooleanNode extends NodeBase { - bool: string; - stringModeValue: boolean; - } - - class CommentNode extends NodeBase { - comment: string; - strip: IStripInfo; - } - } -} - -declare module "handlebars" { - export = Handlebars; -} diff --git a/types/handlebars/v1/tsconfig.json b/types/handlebars/v1/tsconfig.json deleted file mode 100644 index 96818b903b..0000000000 --- a/types/handlebars/v1/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../../", - "typeRoots": [ - "../../" - ], - "types": [], - "paths": { - "handlebars": [ - "handlebars/v1" - ] - }, - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts" - ] -} \ No newline at end of file diff --git a/types/handlebars/v1/tslint.json b/types/handlebars/v1/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/handlebars/v1/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "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 - } -} diff --git a/types/hbs/package.json b/types/hbs/package.json new file mode 100644 index 0000000000..77c0c562ac --- /dev/null +++ b/types/hbs/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "handlebars": "^4.1.0" + } +} diff --git a/types/hexo-fs/package.json b/types/hexo-fs/package.json new file mode 100644 index 0000000000..a0e2ec3c5c --- /dev/null +++ b/types/hexo-fs/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "chokidar": "^2.1.2" + } +} diff --git a/types/history/v3/index.d.ts b/types/history/v3/index.d.ts index 7a6c8116bd..040f5bb0c5 100644 --- a/types/history/v3/index.d.ts +++ b/types/history/v3/index.d.ts @@ -38,6 +38,7 @@ export interface Location { pathname: Pathname; search: Search; query: Query; + hash: Hash; state: LocationState; action: Action; key: LocationKey; @@ -47,6 +48,7 @@ export interface LocationDescriptorObject { pathname?: Pathname; search?: Search; query?: Query; + hash?: Hash; state?: LocationState; } diff --git a/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx b/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx index 0e1beed2e9..954e4cc191 100644 --- a/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx +++ b/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx @@ -3,44 +3,220 @@ import * as PropTypes from 'prop-types'; import hoistNonReactStatics = require('hoist-non-react-statics'); -class A extends React.Component<{ x: number; y?: number | null }> { - static a = 'a'; +function TestClassComponents() { + class A extends React.Component<{ x: number; y?: number | null }> { + static a = 'a'; - static propTypes = { - x: PropTypes.number.isRequired, - y: PropTypes.number, - }; + static propTypes = { + x: PropTypes.number.isRequired, + y: PropTypes.number, + }; - getA() { - return A.a; + getA() { + return A.a; + } } + + class B extends React.Component { + static b = 'b'; + + static propTypes = { + n: PropTypes.number.isRequired, + }; + + static defaultProps = { + n: 42, + }; + + getB() { + return B.b; + } + } + + const C = hoistNonReactStatics(A, B); + + C.a !== C.b; + + C.propTypes.x; + C.prototype.getA(); + + C.propTypes.n; // $ExpectError + C.defaultProps; // $ExpectError + C.prototype.getB(); // $ExpectError + + ; + + const CWithType: hoistNonReactStatics.NonReactStatics = C; + + CWithType.propTypes; // $ExpectError + CWithType.defaultProps; // $ExpectError + CWithType.prototype.getB(); // $ExpectError + + const D = hoistNonReactStatics(A, B, { a: true, b: true }); + + D.a; + D.b; // $ExpectError + + const DWithType: hoistNonReactStatics.NonReactStatics = D; + const DWithTypeError: hoistNonReactStatics.NonReactStatics = D; // $ExpectError + + DWithType.b; // $ExpectError } -class B extends React.Component { - static b = 'b'; +// NOTE: We use Object.assign() to assign statics to functional components as a +// convenience to avoid having to model the component's type with static fields. - static propTypes = { - n: PropTypes.number.isRequired, - }; +function TestFunctionalComponents() { + const A = ({x, y}: {x: number; y?: number}) =>
{x + (y || 0)}
; - getB() { - return B.b; - } + // tslint:disable-next-line:prefer-object-spread + const AWithStatics = Object.assign(A, { + a: 'a', + propTypes: { + x: PropTypes.number.isRequired, + y: PropTypes.number, + }, + }); + + const B = ({n}: {n: number}) =>
{n}
; + + // tslint:disable-next-line:prefer-object-spread + const BWithStatics = Object.assign(B, { + b: 'b', + propTypes: { + n: PropTypes.number.isRequired, + }, + defaultProps: { + n: 42, + }, + }); + + const C = hoistNonReactStatics(AWithStatics, BWithStatics); + + C.a !== C.b; + + C.propTypes.x; + C.propTypes.n; // $ExpectError + C.defaultProps; // $ExpectError + + ; + + const CWithType: hoistNonReactStatics.NonReactStatics = C; + + CWithType.propTypes; // $ExpectError + CWithType.defaultProps; // $ExpectError + + const D = hoistNonReactStatics(AWithStatics, BWithStatics, { a: true, b: true }); + + D.a; + D.b; // $ExpectError + + const DWithType: hoistNonReactStatics.NonReactStatics = D; + const DWithTypeError: hoistNonReactStatics.NonReactStatics = D; // $ExpectError + + DWithType.b; // $ExpectError } -const C = hoistNonReactStatics(A, B); +function TestMemoComponents() { + const A = ({x, y}: {x: number; y?: number}) =>
{x + (y || 0)}
; -C.a !== C.b; + // tslint:disable-next-line:prefer-object-spread + const AWithStatics = Object.assign(A, { + a: 'a', + propTypes: { + x: PropTypes.number.isRequired, + y: PropTypes.number, + }, + }); -C.propTypes.x; -C.prototype.getA(); + const B = React.memo(({n}: {n: number}) =>
{n}
); -C.propTypes.n; // $ExpectError -C.prototype.getB(); // $ExpectError + // tslint:disable-next-line:prefer-object-spread + const BWithStatics = Object.assign(B, { + b: 'b', + propTypes: { + n: PropTypes.number.isRequired, + }, + defaultProps: { + n: 42, + }, + }); -; + const C = hoistNonReactStatics(AWithStatics, BWithStatics); -const D = hoistNonReactStatics(A, B, { a: true, b: true }); + C.a !== C.b; -D.a; -D.b; // $ExpectError + C.propTypes.x; + C.propTypes.n; // $ExpectError + C.defaultProps; // $ExpectError + + ; + + const CWithType: hoistNonReactStatics.NonReactStatics = C; + + CWithType.propTypes; // $ExpectError + CWithType.defaultProps; // $ExpectError + + const D = hoistNonReactStatics(AWithStatics, BWithStatics, { a: true, b: true }); + + D.a; + D.b; // $ExpectError + + const DWithType: hoistNonReactStatics.NonReactStatics = D; + const DWithTypeError: hoistNonReactStatics.NonReactStatics = D; // $ExpectError + + DWithType.b; // $ExpectError +} + +function TestForwardRefComponents() { + const A = ({x, y}: {x: number; y?: number}) =>
{x + (y || 0)}
; + + // tslint:disable-next-line:prefer-object-spread + const AWithStatics = Object.assign(A, { + a: 'a', + propTypes: { + x: PropTypes.number.isRequired, + y: PropTypes.number, + }, + }); + + const B = React.forwardRef( + ({n}: {n: number}, ref: React.Ref) =>
{n}
+ ); + + // tslint:disable-next-line:prefer-object-spread + const BWithStatics = Object.assign(B, { + b: 'b', + propTypes: { + n: PropTypes.number.isRequired, + }, + defaultProps: { + n: 42, + }, + }); + + const C = hoistNonReactStatics(AWithStatics, BWithStatics); + + C.a !== C.b; + + C.propTypes.x; + C.propTypes.n; // $ExpectError + C.defaultProps; // $ExpectError + + ; + + const CWithType: hoistNonReactStatics.NonReactStatics = C; + + CWithType.propTypes; // $ExpectError + CWithType.defaultProps; // $ExpectError + + const D = hoistNonReactStatics(AWithStatics, BWithStatics, { a: true, b: true }); + + D.a; + D.b; // $ExpectError + + const DWithType: hoistNonReactStatics.NonReactStatics = D; + const DWithTypeError: hoistNonReactStatics.NonReactStatics = D; // $ExpectError + + DWithType.b; // $ExpectError +} diff --git a/types/hoist-non-react-statics/index.d.ts b/types/hoist-non-react-statics/index.d.ts index 414c4c41f0..fc90d9713d 100644 --- a/types/hoist-non-react-statics/index.d.ts +++ b/types/hoist-non-react-statics/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for hoist-non-react-statics 3.0 +// Type definitions for hoist-non-react-statics 3.3 // Project: https://github.com/mridgway/hoist-non-react-statics#readme -// Definitions by: JounQin +// Definitions by: JounQin , James Reggio // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -8,10 +8,12 @@ import * as React from 'react'; interface REACT_STATICS { childContextTypes: true; + contextType: true; contextTypes: true; defaultProps: true; displayName: true; getDefaultProps: true; + getDerivedStateFromError: true; getDerivedStateFromProps: true; mixins: true; propTypes: true; @@ -28,6 +30,41 @@ interface KNOWN_STATICS { arity: true; } +interface MEMO_STATICS { + '$$typeof': true; + compare: true; + defaultProps: true; + displayName: true; + propTypes: true; + type: true; +} + +interface FORWARD_REF_STATICS { + '$$typeof': true; + render: true; + defaultProps: true; + displayName: true; + propTypes: true; +} + +declare namespace hoistNonReactStatics { + type NonReactStatics< + S extends React.ComponentType, + C extends { + [key: string]: true + } = {} + > = { + [key in Exclude< + keyof S, + S extends React.MemoExoticComponent + ? keyof MEMO_STATICS | keyof C + : S extends React.ForwardRefExoticComponent + ? keyof FORWARD_REF_STATICS | keyof C + : keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C + >]: S[key] + }; +} + declare function hoistNonReactStatics< T extends React.ComponentType, S extends React.ComponentType, @@ -38,13 +75,6 @@ declare function hoistNonReactStatics< TargetComponent: T, SourceComponent: S, customStatic?: C, -): T & - { - [key in Exclude< - keyof S, - // only extends static properties, exclude instance properties and known react statics - keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C - >]: S[key] - }; +): T & hoistNonReactStatics.NonReactStatics; export = hoistNonReactStatics; diff --git a/types/howler/index.d.ts b/types/howler/index.d.ts index 0fd16e5f0d..6ab3d6e8f0 100644 --- a/types/howler/index.d.ts +++ b/types/howler/index.d.ts @@ -1,20 +1,25 @@ -// Type definitions for howler.js v2.0.5 +// Type definitions for howler.js v2.1.1 // Project: https://github.com/goldfire/howler.js -// Definitions by: Pedro Casaubon , Todd Dukart , Alexander Leon , Nicholas Higgins +// Definitions by: Pedro Casaubon +// Alexander Leon +// Nicholas Higgins +// Carlos Urango // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface HowlerGlobal { - mute(muted: boolean): void; + mute(muted: boolean): this; volume(): number; volume(volume: number): this; codecs(ext: string): boolean; - unload(): void; + unload(): this; usingWebAudio: boolean; + html5PoolSize: number; noAudio: boolean; - mobileAutoEnable: boolean; + autoUnlock: boolean; autoSuspend: boolean; ctx: AudioContext; masterGain: GainNode; + stereo(pan: number): this; pos(x: number, y: number, z: number): this | void; orientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): this | void; @@ -51,6 +56,7 @@ interface IHowlProperties { onrate?: (soundId: number) => void; onseek?: (soundId: number) => void; onfade?: (soundId: number) => void; + onunlock?: (soundId: number) => void; } interface Howl { @@ -75,7 +81,9 @@ interface Howl { loop(loop?: boolean, id?: number): this; playing(id?: number): boolean; duration(id?: number): number; - + state(): 'unloaded' | 'loading' | 'loaded'; + load(): this; + unload(): void; on(event: 'load', callback: () => void, id?: number): this; on(event: 'loaderror', callback: (soundId: number, error: any) => void, id?: number): this; @@ -90,6 +98,7 @@ interface Howl { on(event: 'seek', callback: (soundId: number) => void, id?: number): this; on(event: 'fade', callback: (soundId: number) => void, id?: number): this; on(event: string, callback: Function, id?: number): this; + on(event: 'unlock', callback: (soundId: number) => void, id?: number): this; once(event: 'load', callback: () => void, id?: number): this; once(event: 'loaderror', callback: (soundId: number, error: any) => void, id?: number): this; @@ -104,12 +113,10 @@ interface Howl { once(event: 'seek', callback: (soundId: number) => void, id?: number): this; once(event: 'fade', callback: (soundId: number) => void, id?: number): this; once(event: string, callback: Function, id?: number): this; + once(event: 'unlock', callback: (soundId: number) => void, id?: number): this; off(event: string, callback?: Function, id?: number): this; - state(): 'unloaded' | 'loading' | 'loaded'; - load(): void; - unload(): void; stereo(pan: number, id?: number): this | void; pos(x: number, y: number, z: number, id?: number): this | void; orientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): this | void; diff --git a/types/html5plus/html5plus-tests.ts b/types/html5plus/html5plus-tests.ts new file mode 100644 index 0000000000..371e463473 --- /dev/null +++ b/types/html5plus/html5plus-tests.ts @@ -0,0 +1,2 @@ +const webview = plus.webview.currentWebview(); +const style = webview.getStyle(); diff --git a/types/html5plus/index.d.ts b/types/html5plus/index.d.ts new file mode 100644 index 0000000000..2993f829b6 --- /dev/null +++ b/types/html5plus/index.d.ts @@ -0,0 +1,15472 @@ +// Type definitions for non-npm package html5plus 1.0 +// Project: https://www.html5plus.org/doc/ +// Definitions by: Dcloud +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * HTML5+接口,统一浏览器自定义扩展,提供增强的功能、性能扩展规范,使得开发者可开发出跨平台的app,并接近原生的功能和性能。 + * + * 参考: [http://www.html5plus.org/doc/h5p.html](http://www.html5plus.org/doc/h5p.html) + */ +declare const plus: Plus; + +/** + * HTML5+接口,统一浏览器自定义扩展,提供增强的功能、性能扩展规范,使得开发者可开发出跨平台的app,并接近原生的功能和性能。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ +interface Plus { + /** + * Accelerometer模块管理设备加速度传感器,用于获取设备加速度信息,包括x(屏幕水平方向)、y(垂直屏幕水平方向)、z(垂直屏幕平面方向)三个方向的加速度信息。通过plus.accelerometer获取设备加速度传感器管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + accelerometer: PlusAccelerometer; + /** + * Native.js for Android封装一条通过JS语法直接调用Native Java接口通道,通过plus.android可调用几乎所有的系统API。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + android: PlusAndroid; + /** + * Audio模块用于提供音频的录制和播放功能,可调用系统的麦克风设备进行录音操作,也可调用系统的扬声器设备播放音频文件。通过plus.audio获取音频管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + audio: PlusAudio; + /** + * Bluetooth模块用于管理蓝牙设备,搜索附近蓝牙设备、连接实现数据通信等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + bluetooth: PlusBluetooth; + /** + * Camera模块管理设备的摄像头,可用于拍照、摄像操作,通过plus.camera获取摄像头管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + camera: PlusCamera; + /** + * Contacts模块管理系统通讯录,用于可对系统通讯录进行增、删、改、查等操作。通过plus.contacts获取系统通讯录管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + contacts: PlusContacts; + /** + * Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI、IMSI、型号、厂商等。通过plus.device获取设备信息管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + device: PlusDevice; + /** + * Screen模块管理设备屏幕信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + screen: PlusScreen; + /** + * Display模块管理应用可使用的显示区域信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + display: PlusDisplay; + /** + * networkinfo模块用于获取网络信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + networkinfo: PlusNetworkinfo; + /** + * OS模块管理操作系统信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + os: PlusOs; + /** + * Downloader模块管理网络文件下载任务,用于从服务器下载各种文件,并支持跨域访问操作。通过plus.downloader获取下载管理对象。Downloader下载使用HTTP的GET/POST方式请求下载文件,符合标准HTTP/HTTPS传输协议。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + downloader: PlusDownloader; + /** + * Fingerprint模块管理指纹识别。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + fingerprint: PlusFingerprint; + /** + * Gallery模块管理系统相册,支持从相册中选择图片或视频文件、保存图片或视频文件到相册等功能。通过plus.gallery获取相册管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + gallery: PlusGallery; + /** + * Geolocation模块管理设备位置信息,用于获取地理位置信息,如经度、纬度等。通过plus.geolocation可获取设备位置管理对象。虽然W3C已经提供标准API获取位置信息,但在某些平台存在差异或未实现,为了保持各平台的统一性,定义此规范接口获取位置信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + geolocation: PlusGeolocation; + /** + * iBeacon模块用于搜索附件的iBeacon设备(*请使用HBuilderX并更新到最新版本*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + ibeacon: PlusIbeacon; + /** + * IO模块管理本地文件系统,用于对文件系统的目录浏览、文件的读取、文件的写入等操作。通过plus.io可获取文件系统管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + io: PlusIo; + /** + * Native.js for iOS封装一条通过JS语法直接调用Native Objective-C接口通道,通过plus.ios可调用几乎所有的系统API。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + ios: PlusIos; + /** + * Key管理设备按键事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + key: PlusKey; + /** + * Messaging模块管理设备通讯功能,可用于短信、彩信、邮件发送等。通过plus.messaging可获取设备通讯管理对象。另外也可以直接通过html中的href直接快速发送短信、拨打电话、发送邮件等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + messaging: PlusMessaging; + /** + * nativeObj管理系统原生对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + nativeObj: PlusNativeObj; + /** + * nativeUI管理系统原生界面,可用于弹出系统原生提示对话框窗口、时间日期选择对话框、等待对话框等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + nativeUI: PlusNativeUI; + /** + * navigator用于管理浏览器运行环境信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + navigator: PlusNavigator; + /** + * Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus.orientation可获取设备方向管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + orientation: PlusOrientation; + /** + * Proximity模块管理设备距离传感器,可获取当前设备的接近距离信息,通过plus.proximity可获取设备距离传感管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) + */ + proximity: PlusProximity; + /** + * Runtime模块管理运行环境,可用于获取当前运行环境信息、与其它程序进行通讯等。通过plus.runtime可获取运行环境管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + runtime: PlusRuntime; + /** + * Storage模块管理应用本地数据存储区,用于应用数据的保存和读取。应用本地数据与localStorage、sessionStorage的区别在于数据有效域不同,前者可在应用内跨域操作,数据存储期是持久化的,并且没有容量限制。通过plus.storage可获取应用本地数据管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + storage: PlusStorage; + /** + * Stream模块操作流应用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + stream: PlusStream; + /** + * Uploader模块管理网络上传任务,用于从本地上传各种文件到服务器,并支持跨域访问操作。通过plus.uploader可获取上传管理对象。Uploader上传使用HTTP的POST方式提交数据,数据格式符合Multipart/form-data规范,即rfc1867(Form-based File Upload in HTML)协议。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + uploader: PlusUploader; + /** + * Video模块管理多媒体视频相关能力,可用创建视频播放控件,直播推流控件等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + video: PlusVideo; + /** + * Webview模块管理应用窗口界面,实现多窗口的逻辑控制管理操作。通过plus.webview可获取应用界面管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + webview: PlusWebview; + /** + * XMLHttpRequest模块管理网络请求,与标准HTML中的XMLHttpRequest用途一致,差别在于前者可以进行跨域访问。通过plus.net可获取网络请求管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + net: PlusNet; + /** + * Zip模块管理文件压缩和解压,通过plus.zip可获取压缩管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + zip: PlusZip; + /** + * Barcode模块管理条码扫描,支持常见的条码(一维码及二维码)的扫描识别功能。可调用设备的摄像头对条码图片扫描进行数据输入,解码后返回码数据及码类型。通过plus.barcode可获取条码码管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + barcode: PlusBarcode; + /** + * Maps模块管理地图控件,用于在web页面中显示地图控件,提供各种接口操作地图控件,如添加标点、路线等。通过plus.maps可获取地图管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + maps: PlusMaps; + /** + * OAuth模块管理客户端的用户登录授权验证功能,允许应用访问第三方平台的资源。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + oauth: PlusOauth; + /** + * Payment模块管理支付功能,用于提供网页安全支付能力,支持通过Web接口进行支付操作。通过plus.payment可获取支付管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + payment: PlusPayment; + /** + * Push模块管理推送消息功能,可以实现在线、离线的消息推送,通过plus.push可获取推送消息管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + push: PlusPush; + /** + * Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + share: PlusShare; + /** + * Speech模块管理语音输入功能,提供语音识别功能,可支持用户通过麦克风设备进行语音输入内容。通过plus.speech可获取语音输入管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + speech: PlusSpeech; + /** + * Statistic模块管理统计功能,用于提供应用内统计的能力,支持统计和分析用户属性和用户行为数据。通过plus.statistic可获取统计管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) + */ + statistic: PlusStatistic; +} + +/** + * Accelerometer模块管理设备加速度传感器,用于获取设备加速度信息,包括x(屏幕水平方向)、y(垂直屏幕水平方向)、z(垂直屏幕平面方向)三个方向的加速度信息。通过plus.accelerometer获取设备加速度传感器管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ +interface PlusAccelerometer { + /** + * 设备加速度信息对象 + * JSON对象,保存获取设备的加速度信息,包括x、y、z三个方向的加速度信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + Acceleration?: PlusAccelerometerAcceleration; + /** + * 监听设备加速度感应器参数 + * JSON对象,用于设置获取设备加速度信息的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + AccelerometerOption?: PlusAccelerometerAccelerometerOption; + /** + * 获取当前设备的加速度信息 + * 加速度是设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速度信息包括x、y、z三个方向的信息。 + * 加速度信息可通过successCB回调函数返回。加速度信息获取失败则调用回调函数errorCB。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + getCurrentAcceleration(successCB?: (result: PlusAccelerometerAcceleration) => void, errorCB?: (result: any) => void): void; + /** + * 监听设备加速度变化信息 + * 加速度是设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速度信息包括x、y、z三个方向的信息。 + * watchAcceleration每隔固定时间就获取一次设备的加速度信息,通过successCB回调函数返回。可通过option的frequency参数设定获取设备加速度信息的时间间隔。 + * 加速度信息获取失败则调用回调函数errorCB。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + watchAcceleration(successCB?: (result: PlusAccelerometerAcceleration) => void, errorCB?: (result: any) => void, options?: PlusAccelerometerAccelerometerOption): number; + /** + * 关闭监听设备加速度信息 + * 关闭监听设备加速度信息,应用关闭调用watchAcceleration方法的开启的监听操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + clearWatch(watchId?: number): void; +} + +/** + * 设备加速度信息对象 + * JSON对象,保存获取设备的加速度信息,包括x、y、z三个方向的加速度信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ +interface PlusAccelerometerAcceleration { + /** + * x轴方向的加速度 + * 获取当前设备x轴方向的加速度,浮点型数据,与物理学中的加速度值一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + xAxis?: number; + /** + * y轴方向的加速度 + * 获取当前设备y轴方向的加速度,浮点型数据,与物理学中的加速度值一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + yAxis?: number; + /** + * z轴方向的加速度 + * 获取当前设备z轴方向的加速度,浮点型数据,与物理学中的加速度值一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + zAxis?: number; +} + +/** + * 监听设备加速度感应器参数 + * JSON对象,用于设置获取设备加速度信息的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ +interface PlusAccelerometerAccelerometerOption { + /** + * 更新加速度信息间隔时间 + * 监听器获取加速度信息的时间间隔,单位为ms,默认值为500ms + * + * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) + */ + frequency?: number; +} + +/** + * Native.js for Android封装一条通过JS语法直接调用Native Java接口通道,通过plus.android可调用几乎所有的系统API。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ +interface PlusAndroid { + /** + * Java类对象 + * Java类对象,可通过其属性获取类的常量,可通过方法来操作类的静态变量和方法,也通过new方法来创建类的实例对象。 + * 对于类的常量,则直接通过.后面跟随常量名称调用即可。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + ClassObject?: PlusAndroidClassObject; + /** + * Java实例对象 + * Java实例对象,可通过其方法来操作实例的变量和方法。 + * 注意:必须通过plusGetAttribute()方法读取实例对象的属性值,通过plusSetAttribute()方法设置实例对象的属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + InstanceObject?: PlusAndroidInstanceObject; + /** + * 导入Java类对象 + * 导入类对象后,就可以通过.操作符直接调用对象(类对象/实例对象)的方法。 + * 注意:导入类对象将会消耗较多的系统资源,通常不应该导入过多的类对象,可以使用plus.android.invoke()来调用未导入类实例对象的方法。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + importClass(classname?: string): PlusAndroidClassObject; + /** + * 创建实例对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + newObject(classname?: string, args?: any): PlusAndroidInstanceObject; + /** + * 获取对象(类对象/实例对象)的属性值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + getAttribute(obj?: PlusAndroidInstanceObject, name?: string): any; + /** + * 设置对象(类对象/实例对象)的属性值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + setAttribute(obj?: PlusAndroidInstanceObject, name?: string, value?: any): void; + /** + * 调用对象(类对象/实例对象)的方法 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + invoke(obj?: PlusAndroidInstanceObject, name?: string, args?: any): any; + /** + * 实现Interface的方法 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + implements(name?: string, obj?: any): PlusAndroidInstanceObject; + /** + * 获取应用主Activity实例对象 + * Android平台完整Java类名为android.app.Activity,完整API请参考Android开发文档 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + runtimeMainActivity(): PlusAndroidInstanceObject; + /** + * 获取当前Webview窗口对象的native层实例对象 + * Android平台完整Java类名为android.webkit.Webview,完整API请参考Android开发文档 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + currentWebview(): PlusAndroidInstanceObject; +} + +/** + * Java类对象 + * Java类对象,可通过其属性获取类的常量,可通过方法来操作类的静态变量和方法,也通过new方法来创建类的实例对象。 + * 对于类的常量,则直接通过.后面跟随常量名称调用即可。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ +interface PlusAndroidClassObject { + /** + * 获取Java类对象的静态属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + plusGetAttribute(name?: string): any; + /** + * 设置Java类对象的静态属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + plusSetAttribute(name?: string, value?: any): void; +} + +/** + * Java实例对象 + * Java实例对象,可通过其方法来操作实例的变量和方法。 + * 注意:必须通过plusGetAttribute()方法读取实例对象的属性值,通过plusSetAttribute()方法设置实例对象的属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ +interface PlusAndroidInstanceObject { + /** + * 获取Java实例对象的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + plusGetAttribute(name?: string): any; + /** + * 设置Java实例对象的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) + */ + plusSetAttribute(name?: string, value?: any): void; +} + +/** + * Audio模块用于提供音频的录制和播放功能,可调用系统的麦克风设备进行录音操作,也可调用系统的扬声器设备播放音频文件。通过plus.audio获取音频管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ +interface PlusAudio { + /** + * 录音对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + AudioRecorder?: PlusAudioAudioRecorder; + /** + * 音频播放对象 + * 音频播放对象,用于音频文件的播放。不能通过new方法直接创建,只能通过audio.createPlayer方法创建。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + AudioPlayer?: PlusAudioAudioPlayer; + /** + * JSON对象,调用麦克风设备进行录音的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + RecordOptions?: PlusAudioRecordOptions; + /** + * 设备的扬声器音频输出线路 + * 音频输出线路常量,值为0。音频播放时在设备的扬声器输出。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + ROUTE_SPEAKER?: number; + /** + * 设备听筒音频输出线路 + * 音频输出线路常量,值为1。音频播放时在设备的听筒输出。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + ROUTE_EARPIECE?: number; + /** + * 获取当前设备的录音对象 + * 获取当前设备的录音对象,进行录音操作,录音对象是设备的独占资源,在同一时间仅可执行一个录音操作,否则可能会导致操作失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + getRecorder(): PlusAudioAudioRecorder; + /** + * 创建音频播放对象 + * 创建一个音频文件播放对象,用于打开音频文件并播放。 + * 可通过path参数指定要播放的音频文件。创建后返回播放对象,通过Audio.play方法开始播放。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + createPlayer(path?: string): PlusAudioAudioPlayer; +} + +/** + * 录音对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ +interface PlusAudioAudioRecorder { + /** + * 数组,设备录音支持的采用率 + * 属性类型为Array(String),若不支持此属性则返回空数组对象。支持的录音采样率,字符串格式为“采样频率”,如“8000”;其单位为Hz。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + supportedSamplerates?: string; + /** + * 数组,设备录音支持的文件格式 + * 属性类型为Array(String),若不支持此属性则返回空数组对象。支持的录音文件的格式,字符串格式为文件格式后缀名,如"mp3"、"aac"、"wav"等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + supportedFormats?: string; + /** + * 调用设备麦克风进行录音操作 + * 调用设备麦克风开始录音操作,录音完成需调用stop方法停止。录音完成后将通过successCB回调返回录音后的文件数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + record(option?: PlusAudioRecordOptions, successCB?: (result: string) => void, errorCB?: (result: any) => void): void; + /** + * 结束录音操作 + * 结束录音操作,通知设备完成录音操作。录音完成后将调用record方法中传入的successCB回调返回录音文件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + stop(): void; +} + +/** + * 音频播放对象 + * 音频播放对象,用于音频文件的播放。不能通过new方法直接创建,只能通过audio.createPlayer方法创建。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ +interface PlusAudioAudioPlayer { + /** + * 开始播放音频 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + play(successCB?: () => void, errorCB?: (result: any) => void): void; + /** + * 暂停播放音频 + * 需先调用createPlayer方法创建音频播放对象,并开始播放。音频播放对象在播放状态才能暂停,在其它状态调用此方法无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + pause(): void; + /** + * 恢复播放音频 + * 音频播放对象在暂停状态才能恢复播放,在其它状态调用此方法无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + resume(): void; + /** + * 停止播放音频 + * 停止播放音频,音频播放对象在播放或暂停状态才能停止播放,在其它状态调用此方法无任何作用。 + * 停止播放后如果需要继续播放,则需调用play方法重新开始播放。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + stop(): void; + /** + * 跳到指定位置播放音频 + * 跳到指定位置播放音频,音频播放对象在播放或暂停状态才能跳到指定播放音频,在其它状态调用此方法无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + seekTo(position?: number): void; + /** + * 获取音频流的总长度 + * 获取音频流的总长度,单位为秒,若长度未知则返回-1。如果还未获取到音频流信息则返回NaN,此时需要延迟获取此信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + getDuration(): number; + /** + * 获取音频流当前播放的位置 + * 获取音频流当前播放的位置(已播放的长度),单位为s。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + getPosition(): number; + /** + * 设置音频输出线路 + * 可在音频文件开始播放前或播放的过程中改变音频输出线路,默认使用扬声器(plus.audio.ROUTE_SPEAKER)输出线路。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + setRoute(route?: number): void; +} + +/** + * JSON对象,调用麦克风设备进行录音的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ +interface PlusAudioRecordOptions { + /** + * 录音声道 + * 可取值: + * "mono" - 单声道录音; + * "stereo" - 立体声道录音。 + * 默认值为"mono"。 + * - mono: 单声道录音 + * - stereo: 立体声录音 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + channels?: 'mono' | 'stereo'; + /** + * 保存录音文件的路径 + * 可设置具体文件名,也可只设置路径,如果以“/”结尾则表明是路径,文件名由录音程序自动生成。 + * 如未设置则使用默认目录生成随机文件名称,默认目录为应用%APPID%下的documents目录。 + * - _www/: 应用资源目录 + * - _doc/: 应用私有文档目录 + * - _documents/: 共享文档目录 + * - _downloads/: 共享下载目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + filename?: '_www/' | '_doc/' | '_documents/' | '_downloads/'; + /** + * 录音文件的采样率 + * 需通过supportedSamplerates属性获取设备支持的采样率,若设置无效的值,则使用系统默认的采样率。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + samplerate?: string; + /** + * 录音文件的格式 + * 需通过supportedFormats属性获取设备支持的录音格式,若设置无效的值,则使用系统默认的录音格式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) + */ + format?: string; +} + +/** + * Bluetooth模块用于管理蓝牙设备,搜索附近蓝牙设备、连接实现数据通信等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ +interface PlusBluetooth { + /** + * 蓝牙设备信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + BluetoothDeviceInfo?: PlusBluetoothBluetoothDeviceInfo; + /** + * 蓝牙设备服务信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + BluetoothService?: PlusBluetoothBluetoothService; + /** + * 蓝牙设备特征值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + Bluetoothcharacteristic?: PlusBluetoothBluetoothcharacteristic; + /** + * 蓝牙设备特征值支持的操作类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + BluetoothcharacteristicProperties?: PlusBluetoothBluetoothcharacteristicProperties; + /** + * 关闭蓝牙模块 + * 断开所有已经建立的连接,释放系统资源,要求在蓝牙功能使用完成后调用(于openBluetoothAdapter成对使用)。 + * 关闭成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + closeBluetoothAdapter(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 获取本机蓝牙适配器状态 + * 获取成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + getBluetoothAdapterState(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 获取已搜索到的蓝牙设备 + * 包括已经和本机处于连接状态的设备。 + * 获取成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + getBluetoothDevices(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 根据uuid获取处于已连接的设备 + * 获取成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + getConnectedBluetoothDevices(services?: any [], success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 监听蓝牙适配器状态变化事件 + * 蓝牙适配器状态发生变化时触发回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + onBluetoothAdapterStateChange(changeCB?: (result: any) => void): void; + /** + * 监听搜索到新设备的事件 + * 搜索到新设备时触发回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + onBluetoothDeviceFound(callback?: (result: any) => void): void; + /** + * 初始化蓝牙模块 + * 初始化成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + openBluetoothAdapter(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 开始搜索附近的蓝牙设备 + * 此操作比较耗费系统资源,请在搜索并连接到设备后调用stopBluetoothDevicesDiscovery方法停止搜索。 + * 搜索成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + startBluetoothDevicesDiscovery(services?: any [], allowDuplicatesKey?: boolean, interval?: number, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 停止搜寻附近的蓝牙外围设备 + * 若已经找到需要的蓝牙设备并不需要继续搜索时,应该调用该接口停止蓝牙搜索。 + * 停止成功后触发options参数中的success回调,失败触发options参数中的fail回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + stopBluetoothDevicesDiscovery(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 断开与低功耗蓝牙设备的连接 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + closeBLEConnection(deviceId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 连接低功耗蓝牙设备 + * 若之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的deviceId尝试连接该设备,无需进行搜索操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + createBLEConnection(deviceId?: string, timeout?: number, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 获取蓝牙设备指定服务中所有特征值(characteristic) + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + getBLEDeviceCharacteristics(deviceId?: string, serviceId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 获取蓝牙设备的所有服务(service) + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + getBLEDeviceServices(deviceId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 启用低功耗蓝牙设备特征值变化时的notify功能,订阅特征值 + * 蓝牙设备服务的特征值必须支持notify或indicate才可以成功调用。 + * 另外,必须先启用notifyBLECharacteristicValueChange才能监听到设备characteristicValueChange事件,即特征值发生变化时通过onBLECharacteristicValueChange注册的事件回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + notifyBLECharacteristicValueChange(deviceId?: string, serviceId?: string, characteristicId?: string, state?: boolean, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 监听低功耗蓝牙设备的特征值变化事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + onBLECharacteristicValueChange(callback?: (result: any) => void): void; + /** + * 监听低功耗蓝牙设备连接状态变化事件 + * 包括开发者主动连接或断开连接,设备丢失,连接异常断开等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + onBLEConnectionStateChange(callback?: (result: any) => void): void; + /** + * 读取低功耗蓝牙设备指定特征值的二进制数据值 + * 指定的特征值需支持read操作才可以成功调用。 + * 并行调用多次可能导致读取失败,读取的数据需要在onBLECharacteristicValueChange方法注册的回调中获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + readBLECharacteristicValue(deviceId?: string, serviceId?: string, characteristicId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 向低功耗蓝牙设备指定特征值写入二进制数据 + * 指定的特征值需支持write操作才可以成功调用。 + * 并行调用多次可能导致读取失败,系统可能会限制单次传输的数据大小,超过最大字节数后可能会发生写入错误,建议每次写入不超过20字节。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + writeBLECharacteristicValue(deviceId?: string, serviceId?: string, characteristicId?: string, value?: ArrayBuffer, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; +} + +/** + * 蓝牙设备信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ +interface PlusBluetoothBluetoothDeviceInfo { + /** + * 蓝牙设备名称 + * 某些设备可能没有此字段值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + name?: string; + /** + * 蓝牙设备的id + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + deviceId?: string; + /** + * 蓝牙设备的信号强度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + RSSI?: string; + /** + * 蓝牙设备的广播数据段中的ManufacturerData数据段 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + advertisData?: ArrayBuffer; + /** + * 蓝牙设备的广播数据段中的ServiceUUIDs数据段 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + advertisServiceUUIDs?: any []; + /** + * 蓝牙设备的广播数据段中的LocalName数据段 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + localName?: string; + /** + * 蓝牙设备的广播数据段中的ServiceData数据段 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + serviceData?: any; +} + +/** + * 蓝牙设备服务信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ +interface PlusBluetoothBluetoothService { + /** + * 蓝牙设备服务的uuid + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + uuid?: string; + /** + * 是否为设备的主服务 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + isPrimary?: boolean; +} + +/** + * 蓝牙设备特征值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ +interface PlusBluetoothBluetoothcharacteristic { + /** + * 蓝牙设备特征值的uuid + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + uuid?: string; + /** + * 设备特征值支持的操作类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + properties?: PlusBluetoothBluetoothcharacteristicProperties; +} + +/** + * 蓝牙设备特征值支持的操作类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ +interface PlusBluetoothBluetoothcharacteristicProperties { + /** + * 特征值是否支持read操作 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + read?: boolean; + /** + * 特征值是否支持write操作 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + write?: boolean; + /** + * 特征值是否支持notify操作 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + notify?: boolean; + /** + * 特征值是否支持indicate操作 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) + */ + indicate?: boolean; +} + +/** + * Camera模块管理设备的摄像头,可用于拍照、摄像操作,通过plus.camera获取摄像头管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ +interface PlusCamera { + /** + * 摄像头对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + Camera?: PlusCameraCamera; + /** + * JSON对象,调用摄像头的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + CameraOptions?: PlusCameraCameraOptions; + /** + * JSON对象,弹出拍照或摄像界面指示位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + PopPosition?: PlusCameraPopPosition; + /** + * 获取摄像头管理对象 + * 获取需要操作的摄像头对象,如果要进行拍照或摄像操作,需先通过此方法获取摄像头对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + getCamera(index?: number): PlusCameraCamera; +} + +/** + * 摄像头对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ +interface PlusCameraCamera { + /** + * 字符串数组,摄像头支持的拍照分辨率 + * 属性类型为String[],若不支持此属性则返回空数组对象。 + * 摄像头支持的拍照图片分辨率字符串形式“WIDTH*Height”,如“400*800”;如果支持任意自定义分辨率则“*”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + supportedImageResolutions?: any []; + /** + * 字符串数组,摄像头支持的摄像分辨率 + * 属性类型为String[],若不支持此属性则返回空数组对象。 + * 摄像头支持的视频分辨率字符串形式为“WIDTH*Height”,如“400*800”;如果支持任意自定义分辨率则“*”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + supportedVideoResolutions?: any []; + /** + * 字符串数组,摄像头支持的拍照文件格式 + * 属性类型为String[],若不支持此属性则返回空数组对象。 + * 摄像头支持的图片文件格式字符串形式为文件格式后缀名,如“jpg”、“png”、“bmp”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + supportedImageFormats?: any []; + /** + * 字符串数组,摄像头支持的摄像文件格式 + * 属性类型为String[],若不支持此属性则返回空数组对象。 + * 摄像头支持的视频文件格式字符串形式为文件格式后缀名,如“3gp”、“mp4”、“avi”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + supportedVideoFormats?: any []; + /** + * 进行拍照操作 + * 摄像头资源为独占资源,如果其它程序或页面已经占用摄像头,再次操作则失败。 + * 拍照操作成功将通过successCB返回拍照获取的图片路径。 + * 可通过option设置摄像头的各种属性参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + captureImage(successCB?: (result: string) => void, errorCB?: (result: any) => void, options?: PlusCameraCameraOptions): void; + /** + * 调用摄像头进行摄像操作 + * 摄像头资源为独占资源,如果其它程序或页面已经占用摄像头,再次操作则失败。 + * 拍照操作成功将通过successCB返回摄像获取的视频文件路径。 + * 可通过option设置摄像头的各种属性参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + startVideoCapture(successCB?: (result: string) => void, errorCB?: (result: any) => void, option?: PlusCameraCameraOptions): void; + /** + * 结束摄像操作 + * 开始调用摄像头进行摄像操作后,可在后台结束摄像操作,与用户在界面结束操作效果一致。 + * 摄像操作成功将通过startVideoCapture函数中的successCB返回拍照获取的图片路径。 + * 用户如果没有进行摄像操作关闭摄像头页面则调用失败回调函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + stopVideoCapture(): void; +} + +/** + * JSON对象,调用摄像头的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ +interface PlusCameraCameraOptions { + /** + * 拍照或摄像文件保存的路径 + * 可设置具体文件名(如"_doc/camera/a.jpg");也可只设置路径,以"/"结尾则表明是路径(如"_doc/camera/")。 + * 如未设置文件名称或设置的文件名冲突则文件名由程序程序自动生成。 + * - _doc/: 应用私有文档目录 + * - _documents/: 共享文档目录 + * - _downloads/: 共享下载目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + filename?: '_doc/' | '_documents/' | '_downloads/'; + /** + * 拍照或摄像的文件格式 + * 可通过Camera对象的supportedImageFormats或supportedVideoFormats获取,如果设置的参数无效则使用系统默认值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + format?: string; + /** + * 拍照或摄像默认使用的摄像头 + * 拍照或摄像界面默认使用的摄像头编号,1表示主摄像头,2表示辅摄像头。 + * - 1: 使用设备主摄像头 + * - 2: 使用设备辅摄像头 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + index?: '1' | '2'; + /** + * 视频长度 + * 单位为秒(s),小于等于0表示不限定视频长度。 + * 默认值为0(不限定视频长度)。 + * 注意:仅在调用拍摄视频(startVideoCapture)时有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + videoMaximumDuration?: number; + /** + * 是否优化图片 + * 自动调整图片的方向,在部分设备上可能出现图片方向不正确的问题,此参数将配置是否自动调整图片方向。 + * 可取值: + * true - 自动调整图片方向; + * false - 不调整。 + * 默认值为true。 + * 注意:自动调整图片方向将消耗部分系统资源,可能会导致拍照后回调触发时机延迟,将此值设置为false则可避免延迟问题。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + optimize?: boolean; + /** + * 拍照或摄像使用的分辨率 + * 可通过Camera对象的supportedImageResolutions或supportedVideoResolutions获取,如果设置的参数无效则使用系统默认值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + resolution?: string; + /** + * 拍照或摄像界面弹出指示区域 + * 对于大屏幕设备如iPad,拍照或摄像界面为弹出窗口,此时可通过此参数设置弹出窗口位置,其为JSON对象,格式如{top:"10px",left:"10px",width:"200px",height:"200px"},默认弹出位置为屏幕居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + popover?: PlusCameraPopPosition; +} + +/** + * JSON对象,弹出拍照或摄像界面指示位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ +interface PlusCameraPopPosition { + /** + * 指示区域距离容器顶部的距离 + * 弹出拍照或摄像窗口指示区域距离容器顶部的距离,支持像素值(如"100px")和百分比(如"50%")。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + top?: string; + /** + * 指示区域距离容器左侧的距离 + * 弹出拍照或摄像窗口指示区域距离容器左侧的距离,支持像素值(如"100px")和百分比(如"50%")。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + left?: string; + /** + * 指示区域的宽度 + * 弹出拍照或摄像窗口指示区域的宽度,支持像素值(如"100px")和百分比(如"50%")。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + width?: string; + /** + * 指示区域的高度 + * 弹出拍照或摄像窗口指示区域的高度,支持像素值(如"100px")和百分比(如"50%")。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) + */ + height?: string; +} + +/** + * Contacts模块管理系统通讯录,用于可对系统通讯录进行增、删、改、查等操作。通过plus.contacts获取系统通讯录管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContacts { + /** + * 通讯录对象 + * 通讯录管理对象,可对系统通讯录进行联系人的增、删、改、查操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + AddressBook?: PlusContactsAddressBook; + /** + * 联系人对象 + * 联系人对象,包括联系人的各种信息,如名称、电话号码、地址等。也包括新增、删除联系人的操作方法。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + Contact?: PlusContactsContact; + /** + * JSON对象,联系人域数据对象 + * 联系人域数据对象,保存联系人特定域信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ContactField?: PlusContactsContactField; + /** + * JSON对象,联系人名称对象 + * 联系人名称对象,保存联系人名称信息,如姓、名等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ContactName?: PlusContactsContactName; + /** + * JSON对象,联系人地址对象 + * 联系人地址对象,保存联系人地址信息,如国家、省份、城市等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ContactAddress?: PlusContactsContactAddress; + /** + * JSON对象,联系人所属组织信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ContactOrganization?: PlusContactsContactOrganization; + /** + * JSON对象,查找联系人参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ContactFindOption?: PlusContactsContactFindOption; + /** + * JSON对象,联系人查找过滤器 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ContactFindFilter?: PlusContactsContactFindFilter; + /** + * 手机通讯录 + * 通讯录类型常量,数值类型,固定值为0,用于获取系统的联系人信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ADDRESSBOOK_PHONE?: number; + /** + * SIM卡通讯录 + * 通讯录类型常量,数值类型,固定值为1,用于获取SIM卡上的联系人信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ADDRESSBOOK_SIM?: number; + /** + * 获取通讯录对象 + * 根据指定通讯录类型获取通讯录对象,获取通讯录对象后可对其进行增、删、改操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + getAddressBook(type?: number, successCB?: (result: PlusContactsAddressBook) => void, errorCB?: (result: any) => void): void; +} + +/** + * 通讯录对象 + * 通讯录管理对象,可对系统通讯录进行联系人的增、删、改、查操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsAddressBook { + /** + * 创建联系人 + * 创建一个系统联系人,并返回联系人对象,可对联系人对象进行操作设置联系人信息,如名称、地址、电话等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + create(): PlusContactsContact; + /** + * 在通讯录中查找联系人 + * 在通讯录中安装指定的规则查找联系人,contactFields可设定查找返回的联系人中包含的字段值,查找联系人成功时通过successCB回调返回,查找联系人失败则通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + find(contactFields?: string [], successCB?: (result: PlusContactsContact) => void, errorCB?: (result: any) => void, findOptions?: PlusContactsContactFindOption): void; +} + +/** + * 联系人对象 + * 联系人对象,包括联系人的各种信息,如名称、电话号码、地址等。也包括新增、删除联系人的操作方法。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContact { + /** + * 联系人的id + * 联系人id由系统分配维护,从系统获取联系人时自动赋值,再次查询时可使用此id值进行检索。 + * 注意:此值为只读属性,改写此值可能会导致无法预期的错误。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + id?: string; + /** + * 联系人显示的名字 + * 联系人显示的名字通常由其姓和名组合而成。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + displayName?: string; + /** + * 联系人的名称 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + name?: PlusContactsContactName; + /** + * 联系人的昵称 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + nickname?: string; + /** + * 数组,联系人的电话 + * 如果联系人中未保存电话信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + phoneNumbers?: PlusContactsContactField; + /** + * 数组,联系人的邮箱 + * 如果联系人中未保存邮箱信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + emails?: PlusContactsContactField; + /** + * 数组,联系人的地址 + * 如果联系人中未保存地址信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + addresses?: PlusContactsContactAddress; + /** + * 数组,联系人的即时通讯地址 + * 如果联系人中未保存即时通讯地址信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + ims?: PlusContactsContactField; + /** + * 数组,联系人所属组织信息 + * 如果联系人中未保存所属组织信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + organizations?: PlusContactsContactOrganization; + /** + * 联系人的生日 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + birthday?: Date; + /** + * 联系人的备注 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + note?: string; + /** + * 数组,联系人的头像 + * 其值为头像图片url地址或图片数据: + * url地址:仅支持本地图片地址,可以是绝对路径或相对路径,如“_doc/a.png”; + * 图片数据:必须符合Data URI scheme(RFC2397)格式的数据,如“image/png;base64,XXXX”,其中XXXX为base64编码的图片数据。在获取联系人时默认返回此类型的数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + photos?: PlusContactsContactField; + /** + * 数组,联系人的组名 + * 如果联系人中未保存组名信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + categories?: PlusContactsContactField; + /** + * 数组,联系人的网址 + * 如果联系人中未保存网址信息,则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + urls?: PlusContactsContactField; + /** + * 克隆联系人 + * 克隆联系人,创建出一个新的联系人对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + clone(): PlusContactsContact; + /** + * 删除联系人 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + remove(successCB?: () => void, errorCB?: (result: any) => void): void; + /** + * 保存联系人 + * 将联系人数据保存到通讯录中,操作成功将通过successCB回调函数返回保存结果,操作失败将通过通过errorCB回调函数返回错误信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + save(successCB?: () => void, errorCB?: (result: any) => void): void; +} + +/** + * JSON对象,联系人域数据对象 + * 联系人域数据对象,保存联系人特定域信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContactField { + /** + * 联系人域类型,如电话号码中的“mobile”、“home”、“company” + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + type?: string; + /** + * 联系人域值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + value?: string; + /** + * 是否为首选项 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + preferred?: boolean; +} + +/** + * JSON对象,联系人名称对象 + * 联系人名称对象,保存联系人名称信息,如姓、名等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContactName { + /** + * 联系人的完整名称,由其它字段组合生成 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + formatted?: string; + /** + * 联系人的姓 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + familyName?: string; + /** + * 联系人的名 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + givenName?: string; + /** + * 联系人的中间名 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + middleName?: string; + /** + * 联系人的前缀(如Mr.或Dr.) + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + honorificPrefix?: string; + /** + * 联系人的后缀 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + honorificSuffix?: string; +} + +/** + * JSON对象,联系人地址对象 + * 联系人地址对象,保存联系人地址信息,如国家、省份、城市等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContactAddress { + /** + * 联系人地址类型,如“home”表示家庭地址、“company”表示单位地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + type?: string; + /** + * 完整地址,由其它字段组合而成 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + formatted?: string; + /** + * 完整的街道地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + streetAddress?: string; + /** + * 城市或地区 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + locality?: string; + /** + * 省或地区 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + region?: string; + /** + * 国家 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + country?: string; + /** + * 邮政编码 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + postalCode?: string; + /** + * 是否为首选项 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + preferred?: boolean; +} + +/** + * JSON对象,联系人所属组织信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContactOrganization { + /** + * 联系人所属组织类型,如"company" + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + type?: string; + /** + * 联系人所属组织名称 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + name?: string; + /** + * 联系人所属组织部门 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + department?: string; + /** + * 联系人在组织中的职位 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + title?: string; + /** + * 是否为首选项 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + preferred?: boolean; +} + +/** + * JSON对象,查找联系人参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContactFindOption { + /** + * 数组,查找时的过滤器 + * 可设置为空,表示不过滤。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + filter?: PlusContactsContactFindFilter; + /** + * 是否查找多个联系人,默认值为true + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + multiple?: boolean; +} + +/** + * JSON对象,联系人查找过滤器 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ +interface PlusContactsContactFindFilter { + /** + * 区配的逻辑 + * 可取“and”、“or”、“not”,默认值为“and”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + logic?: string; + /** + * 区配的联系人域,可取联系人的属性名称 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + field?: string; + /** + * 区配的联系人值,可使用区配符号“?”和“*” + * + * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) + */ + value?: string; +} + +/** + * Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI、IMSI、型号、厂商等。通过plus.device获取设备信息管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ +interface PlusDevice { + /** + * 设备的国际移动设备身份码 + * 调用此属性获取设备的国际移动设备身份码。 + * 如果设备不支持则返回空字符串。 + * 如果设备存在多个身份码,则以“,”字符分割拼接,如“862470039452950,862470039452943”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + imei?: string; + /** + * 设备的国际移动用户识别码 + * 字符串数组类型,获取设备上插入SIM的国际移动设备身份码。 + * 如果设备支持多卡模式则返回所有SIM身份码。 + * 如果设备不支持或没有插入SIM卡则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + imsi?: any []; + /** + * 设备的型号 + * 调用此属性获取设备的型号信息。 + * 如果设备不支持则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + model?: string; + /** + * 设备的生产厂商 + * 调用此属性获取设备的生产厂商信息。 + * 如果设备不支持则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + vendor?: string; + /** + * 设备的唯一标识 + * 调用此属性获取设备的唯一标识号。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + uuid?: string; + /** + * 拨打电话 + * 调用系统程序拨打电话。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + dial(number?: string, confirm?: boolean): void; + /** + * 发出蜂鸣声 + * 调用此方法使得设备发出蜂鸣声。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + beep(times?: number): void; + /** + * 设备振动 + * 调用此方法使得设备振动。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + vibrate(milliseconds?: number): void; + /** + * 设置应用是否保持唤醒(屏幕常亮)状态 + * 调用此方法设置应用是否一直保持唤醒状态,保持唤醒状态将会导致程序屏幕常亮、系统不会自动锁屏,从而导致消耗更多的电量。若未设置一直保持唤醒状态则会根据系统设置自动锁定屏幕。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + setWakelock(lock?: boolean): void; + /** + * 获取程序是否一直保持唤醒(屏幕常亮)状态 + * 调用此方法获取程序是否一致保持唤醒状态。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + isWakelock(): boolean; + /** + * 设置设备的系统音量 + * 调用此方法调节设备的系统音量。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + setVolume(volume?: number): void; + /** + * 获取设备的系统音量 + * 系统音量值范围为0到1,0表示静音,1表示最大音量值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + getVolume(): number; +} + +/** + * Screen模块管理设备屏幕信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ +interface PlusScreen { + /** + * 设备屏幕高度分辨率 + * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,screen获取的是设备屏幕总区域的逻辑分辨率,单位为px。 + * 如果需要获取实际分辨率则需要乘以比例值scale。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + resolutionHeight?: number; + /** + * 设备屏幕宽度分辨率 + * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,screen获取的是设备屏幕总区域的分辨率,单位为px。 + * 如果需要获取实际分辨率则需要乘以比例值scale。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + resolutionWidth?: number; + /** + * 逻辑分辨率与实际分辨率的比例 + * 屏幕分辨率分逻辑分辨率率和实际分辨率,在html页面中使用的像素值都是相对于逻辑分辨率,此值就是逻辑分辨率和实际分辨率的比例,实际分辨率=逻辑分辨率*比例。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + scale?: number; + /** + * 设备屏幕水平方向的密度 + * 设备屏幕的密度为每英寸所显示的像素点数,密度越高显示清晰度越高,单位为dpi。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + dpiX?: number; + /** + * 设备屏幕垂直方向的密度 + * 设备屏幕的密度为每英寸所显示的像素点数,密度越高显示清晰度越高,单位为dpi。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + dpiY?: number; + /** + * 设置屏幕亮度 + * 调用此方法调节设备屏幕亮度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + setBrightness(brightness?: number): void; + /** + * 获取屏幕亮度值 + * 屏幕亮度值范围为0到1,0表示最低亮度值,1表示最高亮度值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + getBrightness(): number; + /** + * 锁定屏幕方向 + * 锁定屏幕方向后屏幕只能按锁定的屏幕方向显示,关闭当前页面后仍然有效。 + * 可再次调用此方法修改屏幕锁定方向或调用unlockOrientation()方法恢复到应用的默认值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + lockOrientation(orientation?: string): void; + /** + * 解除锁定屏幕方向 + * 解除锁定屏幕方向后将恢复应用默认的屏幕显示方向(通常为应用打包发布时设置的方向)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + unlockOrientation(): void; +} + +/** + * Display模块管理应用可使用的显示区域信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ +interface PlusDisplay { + /** + * 应用可使用的屏幕高度逻辑分辨率 + * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,display获取的是应用显示区域的逻辑分辨率,单位为px。 + * 如果需要获取实际分辨率则需要乘以比例值scale。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + resolutionHeight?: number; + /** + * 应用可使用的屏幕宽度逻辑分辨率 + * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,display获取的是应用显示区域的逻辑分辨率,单位为px。 + * 如果需要获取实际分辨率则需要乘以比例值scale。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + resolutionWidth?: number; +} + +/** + * networkinfo模块用于获取网络信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ +interface PlusNetworkinfo { + /** + * 网络连接状态未知 + * 网络状态常量,表示当前设备网络状态未知,固定值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_UNKNOW?: number; + /** + * 未连接网络 + * 网络状态常量,当前设备网络未连接网络,固定值为1。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_NONE?: number; + /** + * 有线网络 + * 网络状态常量,当前设备连接到有线网络,固定值为2。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_ETHERNET?: number; + /** + * 无线WIFI网络 + * 网络状态常量,当前设备连接到无线WIFI网络,固定值为3。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_WIFI?: number; + /** + * 蜂窝移动2G网络 + * 网络状态常量,当前设备连接到蜂窝移动2G网络,固定值为4。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_CELL2G?: number; + /** + * 蜂窝移动3G网络 + * 网络状态常量,当前设备连接到蜂窝移动3G网络,固定值为5。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_CELL3G?: number; + /** + * 蜂窝移动4G网络 + * 网络状态常量,当前设备连接到蜂窝移动4G网络,固定值为6。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + CONNECTION_CELL4G?: number; + /** + * 获取设备当前连接的网络类型 + * 获取当前设备连接的网络类型,返回值为网络类型常量,可取值CONNECTION_*常量。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + getCurrentType(): number; +} + +/** + * OS模块管理操作系统信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ +interface PlusOs { + /** + * 系统语言信息 + * 获取当前操作系统设置的系统语言,字符串类型数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + language?: string; + /** + * 系统版本信息 + * 获取当前操作系统的版本信息,字符串类型数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + version?: string; + /** + * 系统的名称 + * 获取当前操作系统的名称,字符串类型数据。 + * - iOS: + * iOS系统。 + * + * - Android: + * Android系统。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + name?: 'iOS' | 'Android'; + /** + * 系统的供应商信息 + * 获取当前操作系统的供应商名称,字符串类型数据。 + * - Apple: + * iOS设备,包括iPhone、iPad、iTouch。 + * + * - Google: + * Android设备。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) + */ + vendor?: 'Apple' | 'Google'; +} + +/** + * Downloader模块管理网络文件下载任务,用于从服务器下载各种文件,并支持跨域访问操作。通过plus.downloader获取下载管理对象。Downloader下载使用HTTP的GET/POST方式请求下载文件,符合标准HTTP/HTTPS传输协议。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ +interface PlusDownloader { + /** + * Download对象管理一个下载任务 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + Download?: PlusDownloaderDownload; + /** + * 下载任务事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + DownloadEvent?: PlusDownloaderDownloadEvent; + /** + * 下载任务状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + DownloadState?: PlusDownloaderDownloadState; + /** + * 下载任务参数 + * 在创建下载任务时设置的参数,如设置下载任务使用的HTTP协议类型、优先级等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + DownloadOptions?: PlusDownloaderDownloadOptions; + /** + * 新建下载任务 + * 请求下载管理创建新的下载任务,创建成功则返回Download对象,用于管理下载任务。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + createDownload(url?: string, options?: PlusDownloaderDownloadOptions, completedCB?: (result0: PlusDownloaderDownload, result1: number) => void): PlusDownloaderDownload; + /** + * 枚举下载任务 + * 枚举指定状态的下载任务列表,通过enumCB回调函数返回结果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + enumerate(enumCB?: (result: any []) => void, state?: PlusDownloaderDownloadState): void; + /** + * 清除下载任务 + * 清除指定状态的下载任务。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + clear(state?: PlusDownloaderDownloadState): void; + /** + * 开始所有下载任务 + * 开始所有处于为开始调度或暂停状态的下载任务。 + * 若下载任务数超过可并发处理的总数,超出的任务处于调度状态(等待下载),当有任务完成时根据调度状态任务的优先级选择任务开始下载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + startAll(): void; +} + +/** + * Download对象管理一个下载任务 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ +interface PlusDownloaderDownload { + /** + * 下载任务的标识 + * 在创建任务时系统自动分配,用于标识下载任务的唯一性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + id?: string; + /** + * 下载文件的地址 + * 调用plus.donwloader.createDownload()方法创建下载任务时设置的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + url?: string; + /** + * 任务的状态 + * 表示当前下载任务的状态,可通过addEventListener()方法监听statechanged事件监听任务状态的变化。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + state?: PlusDownloaderDownloadState; + /** + * 下载任务的参数 + * 调用plus.donwloader.createDownload()方法创建下载任务时设置的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + options?: PlusDownloaderDownloadOptions; + /** + * 下载的文件名称 + * 下载任务在本地保存的文件路径,下载任务完成时更新,可通过此值访问下载的文件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + filename?: string; + /** + * 已完成下载文件的大小 + * 整数类型,单位为字节(byte),下载任务开始传输数据时,每次触发statechanged事件或下载任务完成时更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + downloadedSize?: number; + /** + * 下载任务文件的总大小 + * 整数类型,单位为字节(byte),下载任务开始传输数据时更新,在此之前其值为0。 + * 此值是从HTTP请求头中获取,如果服务器未返回则此值始终为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + totalSize?: number; + /** + * 取消下载任务 + * 如果任务未完成,则终止下载,并从任务列表中删除。 + * 如下载未完成,将删除已下载的临时文件,如果下载已完成,将不删除已下载的文件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + abort(): void; + /** + * 添加下载任务事件监听器 + * 下载任务添加事件监听器后,当监听的事件发生时触发listener回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + addEventListener(type?: string, listener?: (result0: PlusDownloaderDownload, result1: number) => void, capture?: boolean): void; + /** + * 获取下载请求HTTP响应头部信息 + * HTTP响应头部全部内容作为未解析的字符串返回,如果没有接收到这个HTTP响应头数据或者下载请求未完成则为空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + getAllResponseHeaders(): string; + /** + * 获取下载请求指定的HTTP响应头部的值 + * 其参数是要返回的HTTP响应头部的名称,可以使用任何大小写来制定这个头部名字,和响应头部的比较是不区分大小写的。 + * 如果没有接收到这个头部或者下载请求未完成则为空字符串;如果接收到多个有指定名称的头部,这个头部的值被连接起来并返回,使用逗号和空格分隔开各个头部的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + getResponseHeader(headerName?: string): string; + /** + * 暂停下载任务 + * 暂停下载任务,如果任务已经处于初始状态或暂停状态则无任何响应。 + * 通常在任务已开始后暂停任务。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + pause(): void; + /** + * 恢复暂停的下载任务 + * 继续暂停的下载任务,如果任务处于非暂停状态则无任何响应。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + resume(): void; + /** + * 设置下载请求的HTTP头数据 + * Http的Header应该包含在通过后续start()调用而发起的请求中,此方法必需在调用start()之前设置才能生效。 + * 如果带有指定名称的头部已经被指定了,这个头部的新值就是:之前指定的值,加上逗号、以及这个调用指定的值(形成一个数组)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + setRequestHeader(headerName?: string, headerValue?: string): void; + /** + * 开始下载任务 + * 开始下载任务,如果任务已经处于开始状态则无任何响应。 + * 在创建任务或任务下载失败后调用可重新开始下载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + start(): void; +} + +/** + * 下载任务事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ +interface PlusDownloaderDownloadEvent { + /** + * 下载任务状态变化事件 + * 当下载任务状态发生变化时触发此事件,事件原型参考DownloadStateChangedCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + statechanged?: string; +} + +/** + * 下载任务状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ +type PlusDownloaderDownloadState = undefined | 0 | 1 | 2 | 3 | 4 | 5 | -1; + +/** + * 下载任务参数 + * 在创建下载任务时设置的参数,如设置下载任务使用的HTTP协议类型、优先级等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ +interface PlusDownloaderDownloadOptions { + /** + * 网络请求类型 + * 支持http协议的“GET”、“POST”,默认为“GET”请求。 + * - GET: GET请求 + * - POST: POST请求 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + method?: 'GET' | 'POST'; + /** + * POST请求时提交的数据 + * 仅在网络请求类型method设置为"POST"时有效,"GET"请求时忽略此数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + data?: string; + /** + * 下载文件保存的路径 + * 保存文件路径仅支持以"_downloads/"、"_doc/"、"_documents/"开头的字符串。 + * 文件路径以文件后缀名结尾(如"_doc/download/a.doc")表明指定保存文件目录及名称,以“/”结尾则认为指定保存文件的目录(此时程序自动生成文件名)。 + * 如果指定的文件已经存在,则自动在文件名后面加"(i)",其中i为数字,如果文件名称后面已经是此格式,则数字i递增,如"download(1).doc"。 + * 默认保存目录为("_downloads"),并自动生成文件名称。 + * - _doc/: 应用私有文档目录 + * - _documents/: 共享文档目录 + * - _downloads/: 共享下载目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + filename?: '_doc/' | '_documents/' | '_downloads/'; + /** + * 下载任务的优先级 + * 数值类型,数值越大优先级越高,默认优先级值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + priority?: number; + /** + * 下载任务超时时间 + * 数值类型,单位为s(秒),默认值为120s。 + * 超时时间为服务器响应请求的时间(不是下载任务完成的总时间),如果设置为0则表示永远不超时。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + timeout?: number; + /** + * 下载任务重试次数 + * 数值类型,默认为重试3次。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + retry?: number; + /** + * 下载任务重试间隔时间 + * 数值类型,单位为s(秒),默认值为30s。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) + */ + retryInterval?: number; +} + +/** + * Fingerprint模块管理指纹识别。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ +interface PlusFingerprint { + /** + * JSON对象,指纹识别认证参数 + * 用于设置指纹识别认证界面显示的提示信息等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + AuthenticateOptions?: PlusFingerprintAuthenticateOptions; + /** + * JSON对象,指纹识别错误信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + FingerprintError?: PlusFingerprintFingerprintError; + /** + * 当前设备环境是否支持指纹识别 + * 目前还有很多设备没有指纹识别模块,需要调用此方法判断是否可使用指纹识别功能。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + isSupport(): boolean; + /** + * 当前设备是否设置密码锁屏 + * 如果设备没有设置密码锁屏,则无法使用指纹识别功能,建议调用指纹识别前先使用此接口检查。 + * 调用plus.fingerprint.authenticate会返回失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + isKeyguardSecure(): boolean; + /** + * 当前设备是否已经录入指纹 + * 如果设备没有录入指纹,则无法使用指纹识别功能,建议调用指纹识别前先使用此接口检查。 + * 调用plus.fingerprint.authenticate会返回失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + isEnrolledFingerprints(): boolean; + /** + * 指纹识别认证 + * 用户可以开始输入指纹进行识别,如果认证成功则触发successCB回调,识别失败则触发errorCB回调返回错误信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + authenticate(successCB?: () => void, errorCB?: (result: PlusFingerprintFingerprintError) => void, options?: PlusFingerprintAuthenticateOptions): void; + /** + * 取消指纹识别认证 + * 取消当前正在处理的指纹识别认证操作。 + * 如果当前没有进行指纹识别则不进行任何操作;如果当前正在进行指纹识别则触发错误回调(错误码为“CANCEL”)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + cancel(): void; +} + +/** + * JSON对象,指纹识别认证参数 + * 用于设置指纹识别认证界面显示的提示信息等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ +interface PlusFingerprintAuthenticateOptions { + /** + * 在指纹识别过程中显示在界面上的提示信息 + * 如果指纹识别认证过程中不显示提示框,则不显示此信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + message?: string; +} + +/** + * JSON对象,指纹识别错误信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ +interface PlusFingerprintFingerprintError { + /** + * 不支持指纹识别 + * 当前设备不支持指纹识别功能时返回此错误,错误代码常量值为1。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + UNSUPPORT?: number; + /** + * 设备未设置密码锁屏 + * 当前设备为设置密码锁屏导致无法使用指纹识别功能时返回此错误,错误代码常量值为2。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + KEYGUARD_INSECURE?: number; + /** + * 未录入指纹识别 + * 当前设备未录入指纹导致无法使用指纹识别功能时返回此错误,错误代码常量值为3。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + FINGERPRINT_UNENROLLED?: number; + /** + * 指纹识别不匹配 + * 用户指纹识别认证不通过时返回此错误,错误代码常量值为4。 + * 用户每次尝试指纹识别认证未通过都会触发此错误,此时还可以继续识别认证。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + AUTHENTICATE_MISMATCH?: number; + /** + * 指纹识别次数超过限制 + * 用户多次指纹识别认证不通过时返回此错误,错误代码常量值为5。 + * 通常出现此错误后系统会锁定一段时间禁止使用指纹识别,如果再次调用指纹识别认证会立即返回此错误,因此出现此错误时应该提示用户使用其它方式进行认证。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + AUTHENTICATE_OVERLIMIT?: number; + /** + * 取消指纹识别 + * 用户取消指纹识别认证时返回此错误,错误代码常量值为6。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + CANCEL?: number; + /** + * 未知错误 + * 其它未知错误,错误代码常量值为7。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + UNKNOWN_ERROR?: number; + /** + * 错误代码 + * 取值范围为FingerprintError对象的错误常量值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + code?: number; + /** + * 错误描述信息 + * 详细错误描述信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) + */ + message?: string; +} + +/** + * Gallery模块管理系统相册,支持从相册中选择图片或视频文件、保存图片或视频文件到相册等功能。通过plus.gallery获取相册管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ +interface PlusGallery { + /** + * JSON对象,从相册中选择文件的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + GalleryOptions?: PlusGalleryGalleryOptions; + /** + * 相册选择文件过滤类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + GalleryFilter?: PlusGalleryGalleryFilter; + /** + * 保存图片到相册成功事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + GallerySaveEvent?: PlusGalleryGallerySaveEvent; + /** + * JSON对象,弹出拍照或摄像界面指示位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + PopPosition?: PlusGalleryPopPosition; + /** + * 从系统相册选择文件(图片或视频) + * 从系统相册中选择图片或视频文件。每次仅能选择一个文件,选择后将返回选择的文件路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + pick(succesCB?: (result: string) => void, errorCB?: (result: any) => void, options?: PlusGalleryGalleryOptions): void; + /** + * 保存文件到系统相册中 + * 保存文件到系统相册中。 + * 每次仅能保存一个文件,支持图片类型(jpg/jpeg、png、bmp等格式)和视频文件(3gp、mov等格式)。 + * 若保存的文件系统不支持,则通过errorCB返回错误信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + save(path ?: string, succesCB?: (result: PlusGalleryGallerySaveEvent) => void, errorCB?: (result: any) => void): void; +} + +/** + * JSON对象,从相册中选择文件的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ +interface PlusGalleryGalleryOptions { + /** + * 是否显示系统相册文件选择界面的动画 + * 可取值true、false,默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + animation?: boolean; + /** + * 选择文件保存的路径 + * 某些系统不能直接使用系统相册的路径,这时需要将选择的文件保存到应用可访问的目录中,可通过此参数设置保存文件的路径。 + * 如果路径中包括文件后缀名称,则表明指定文件路径及名称,否则仅指定文件保存目录,文件名称自动生成。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + filename?: string; + /** + * 相册中选择文件类型过滤器 + * 系统相册选择器中可选择的文件类型,可设置为仅选择图片文件(“image”)、视频文件(“video”)或所有文件(“none”),默认值为“image”。 + * - image: 仅可选择图片文件 + * - video: 仅可选择视频文件 + * - none: 可选择图片或视频文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + filter?: 'image' | 'video' | 'none'; + /** + * 最多选择的图片数量 + * 仅在支持多选时有效,取值范围为1到Infinity,默认值为Infinity,即不限制选择的图片数。 + * 如果设置的值非法则使用默认值Infinity。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + maximum?: number; + /** + * 是否支持多选图片 + * 可从系统相册中选择多张图片,选择图片后通过GalleryMultiplePickSuccessCallback回调返回选择的图片。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + multiple?: boolean; + /** + * 超过最多选择图片数量事件 + * 使用相册多选图片时,可通过maximum属性设置最多选择的图片数量,当用户操作选择的数量大于此时触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + onmaxed?: () => void; + /** + * 相册选择界面弹出指示区域 + * 对于大屏幕设备如iPad,相册选择界面为弹出窗口,此时可通过此参数设置弹出窗口位置。 + * 其为JSON对象,格式如{top:"10px",left:"10px",width:"200px",height:"200px"},所有值为像素值,左上坐标相对于容器的位置,默认弹出位置为屏幕居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + popover?: PlusGalleryPopPosition; + /** + * 已选择的图片路径列表 + * 仅在多图片选择时生效,相册选择界面将选中指定的图片路径列表。 + * 如果指定的路径无效,则忽略此项;如果指定的路径数超过maximum属性指定的最大选择数目则超出的图片不选中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + selected?: any []; + /** + * 是否使用系统相册文件选择界面 + * multiple属性设置为true时,如果系统自带相册选择控件时则优先使用,否则使用5+统一相册选择控件;设置为false则不使用系统自带相册选择控件,直接使用5+统一相册选择界面。 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + system?: boolean; +} + +/** + * 相册选择文件过滤类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ +interface PlusGalleryGalleryFilter { + /** + * 仅可选择图片文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + image?: string; + /** + * 仅可选择视频文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + video?: string; + /** + * 不过滤,可选择图片或视频文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + none?: string; +} + +/** + * 保存图片到相册成功事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ +interface PlusGalleryGallerySaveEvent { + /** + * 保存到相册的图片路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + path?: string; +} + +/** + * JSON对象,弹出拍照或摄像界面指示位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ +interface PlusGalleryPopPosition { + /** + * 指示区域距离容器顶部的距离 + * 弹出拍照或摄像窗口指示区域距离容器顶部的距离,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + top?: string; + /** + * 指示区域距离容器左侧的距离 + * 弹出拍照或摄像窗口指示区域距离容器左侧的距离,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + left?: string; + /** + * 指示区域的宽度 + * 弹出拍照或摄像窗口指示区域的宽度,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + width?: string; + /** + * 指示区域的高度 + * 弹出拍照或摄像窗口指示区域的高度,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) + */ + height?: string; +} + +/** + * Geolocation模块管理设备位置信息,用于获取地理位置信息,如经度、纬度等。通过plus.geolocation可获取设备位置管理对象。虽然W3C已经提供标准API获取位置信息,但在某些平台存在差异或未实现,为了保持各平台的统一性,定义此规范接口获取位置信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ +interface PlusGeolocation { + /** + * JSON对象,设备位置信息数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + Position?: PlusGeolocationPosition; + /** + * JSON对象,地址信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + Address?: PlusGeolocationAddress; + /** + * JSON对象,地理坐标信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + Coordinates?: PlusGeolocationCoordinates; + /** + * JSON对象,监听设备位置信息参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + PositionOptions?: PlusGeolocationPositionOptions; + /** + * JSON对象,定位错误信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + GeolocationError?: PlusGeolocationGeolocationError; + /** + * 获取当前设备位置信息 + * 位置信息将通过手机GPS设备或其它信息如IP地址、移动网络信号获取,由于获取位置信息可能需要较长的时间,当成功获取位置信息后将通过successCB回调函数返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + getCurrentPosition(successCB?: (result: PlusGeolocationPosition) => void, errorCB?: (result: PlusGeolocationGeolocationError) => void, options?: PlusGeolocationPositionOptions): void; + /** + * 监听设备位置变化信息 + * 位置信息将通过手机GPS设备或其它信息如IP地址、移动网络信号获取。 + * 当位置信息更新后将通过successCB回调函数返回。 + * 位置信息获取失败则调用回调函数errorCB。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + watchPosition(successCB?: (result: PlusGeolocationPosition) => void, errorCB?: (result: PlusGeolocationGeolocationError) => void, option?: PlusGeolocationPositionOptions): number; + /** + * 关闭监听设备位置信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + clearWatch(watchId?: number): void; +} + +/** + * JSON对象,设备位置信息数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ +interface PlusGeolocationPosition { + /** + * 地理坐标信息,包括经纬度、海拔、速度等信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + coords?: PlusGeolocationCoordinates; + /** + * 获取到地理坐标信息的坐标系类型 + * 可取以下坐标系类型: + * "gps":表示WGS-84坐标系; + * "gcj02":表示国测局经纬度坐标系; + * "bd09":表示百度墨卡托坐标系; + * "bd09ll":表示百度经纬度坐标系。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + coordsType?: string; + /** + * 获取到地理坐标的时间戳信息 + * 时间戳值为从1970年1月1日至今的毫秒数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + timestamp?: number; + /** + * 获取到地理位置对应的地址信息 + * 获取地址信息需要连接到服务器进行解析,所以会消耗更多的资源,如果不需要获取地址信息可通过设置PositionOptions参数的geocode属性值为false避免获取地址信息。 + * 如果没有获取到地址信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + address?: PlusGeolocationAddress; + /** + * 获取完整地址描述信息 + * 如果没有获取到地址信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + addresses?: string; +} + +/** + * JSON对象,地址信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ +interface PlusGeolocationAddress { + /** + * 国家 + * 如“中国”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + country?: string; + /** + * 省份名称 + * 如“北京市”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + province?: string; + /** + * 城市名称 + * 如“北京市”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + city?: string; + /** + * 区(县)名称 + * 如“朝阳区”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + district?: string; + /** + * 街道信息 + * 如“酒仙桥路”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + street?: string; + /** + * 获取街道门牌号信息 + * 如“3号”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + streetNum?: string; + /** + * POI信息 + * 如“电子城.国际电子总部”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + poiName?: string; + /** + * 邮政编码 + * 如“100016”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + postalCode?: string; + /** + * 城市代码 + * 如“010”,如果无法获取此信息则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + cityCode?: string; +} + +/** + * JSON对象,地理坐标信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ +interface PlusGeolocationCoordinates { + /** + * 坐标纬度值 + * 数据类型对象,地理坐标中的纬度值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + latitude?: number; + /** + * 坐标经度值 + * 数据类型对象,地理坐标中的经度值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + longitude?: number; + /** + * 海拔信息 + * 数据类型对象,如果无法获取此信息,则此值为空(null)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + altitude?: number; + /** + * 地理坐标信息的精确度信息 + * 数据类型对象,单位为米,其有效值必须大于0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + accuracy?: number; + /** + * 海拔的精确度信息 + * 数据类型对象,单位为米,其有效值必须大于0。如果无法获取海拔信息,则此值为空(null)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + altitudeAccuracy?: number; + /** + * 表示设备移动的方向 + * 数据类型对象,范围为0到360,表示相对于正北方向的角度。如果无法获取此信息,则此值为空(null)。如果设备没有移动则此值为NaN。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + heading?: number; + /** + * 表示设备移动的速度 + * 数据类型对象,单位为米每秒(m/s),其有效值必须大于0。如果无法获取速度信息,则此值为空(null)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + speed?: number; +} + +/** + * JSON对象,监听设备位置信息参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ +interface PlusGeolocationPositionOptions { + /** + * 是否高精确度获取位置信息 + * 高精度获取表示需要使用更多的系统资源,默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + enableHighAccuracy?: boolean; + /** + * 获取位置信息的超时时间 + * 单位为毫秒(ms),默认值为不超时。如果在指定的时间内没有获取到位置信息则触发错误回调函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + timeout?: number; + /** + * 获取位置信息的间隔时间 + * 单位为毫秒(ms),默认值为5000(即5秒)。调用plus.geolocation.watchPosition时为更新位置信息的间隔时间。 + * 注意:在不同定位模块下支持范围值可能不同,如百度定位模块的间隔范围为大于等于1秒,如果设置的值小于最小值则使用最小值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + maximumAge?: number; + /** + * 优先使用的定位模块 + * 可取以下供应者: + * "system":表示系统定位模块,支持wgs84坐标系; + * "baidu":表示百度定位模块,支持gcj02/bd09/bd09ll坐标系; + * "amap":表示高德定位模板,支持gcj02坐标系。 + * 默认值按以下优先顺序获取(amap>baidu>system),若指定的provider不存在或无效则返回错误回调。 + * 注意:百度/高德定位模块需要配置百度/高德地图相关参数才能正常使用。 + * - system: 优先使用系统定位模块 + * - baidu: 优先使用百度定位模块 + * - amap: 优先使用高德定位模块 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + provider?: 'system' | 'baidu' | 'amap'; + /** + * 指定获取的定位数据坐标系类型 + * 可取以下坐标系类型: + * "wgs84":表示WGS-84坐标系; + * "gcj02":表示国测局经纬度坐标系; + * "bd09":表示百度墨卡托坐标系; + * "bd09ll":表示百度经纬度坐标系; + * provider为"system"时,默认使用"wgs84"坐标系;provider为"baidu"时,默认使用"gcj02"坐标系;provider为"amap"时,默认使用"gcj02"坐标系。 + * 如果设置的坐标系类型provider不支持,则返回错误。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + coordsType?: string; + /** + * 是否解析地址信息 + * 解析的地址信息保存到Position对象的address、addresses属性中,true表示解析地址信息,false表示不解析地址信息,返回的Position对象的address、addresses属性值为undefined,默认值为true。 + * 如果解析地址信息失败则返回的Position对象的address、addresses属性值为null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + geocode?: boolean; +} + +/** + * JSON对象,定位错误信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ +interface PlusGeolocationGeolocationError { + /** + * 访问权限被拒绝 + * 系统不允许程序获取定位功能,错误代码常量值为1。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + PERMISSION_DENIED?: number; + /** + * 位置信息不可用 + * 无法获取有效的位置信息,错误代码常量值为2。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + POSITION_UNAVAILABLE?: number; + /** + * 获取位置信息超时 + * 无法在指定的时间内获取位置信息,错误代码常量值为3。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + TIMEOUT?: number; + /** + * 未知错误 + * 其它未知错误导致无法获取位置信息,错误代码常量值为4。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + UNKNOWN_ERROR?: number; + /** + * 错误代码 + * 取值范围为GeolocationError对象的常量值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + code?: number; + /** + * 错误描述信息 + * 详细错误描述信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) + */ + message?: string; +} + +/** + * iBeacon模块用于搜索附件的iBeacon设备(*请使用HBuilderX并更新到最新版本*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ +interface PlusIbeacon { + /** + * iBeacon设备信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + IBeaconInfo?: PlusIbeaconIBeaconInfo; + /** + * 开始搜索附近的iBeacon设备 + * 搜索成功后触发successCB回调,失败触发errorCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + startBeaconDiscovery(uuids?: any [], ignoretoothAvailable?: boolean, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 停止搜索附近的iBeacon设备 + * 取消成功后触发successCB回调,失败触发errorCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + stopBeaconDiscovery(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 获取已搜索到的iBeacon设备 + * 获取成功后触发successCB回调,失败触发errorCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + getBeacons(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + /** + * 监听iBeacon设备更新 + * iBeacon设备更新后触发updateCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + onBeaconUpdate(updateCB?: (result: any) => void): void; + /** + * 监听iBeacon服务状态变化 + * iBeacon服务状态变化时触发changeCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + onBeaconServiceChange(changeCB?: (result: any) => void): void; +} + +/** + * iBeacon设备信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ +interface PlusIbeaconIBeaconInfo { + /** + * iBeacon设备广播的uuid + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + uuid?: string; + /** + * iBeacon设备的主id + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + major?: string; + /** + * iBeacon设备的次id + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + minor?: string; + /** + * iBeacon设备的距离 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + proximity?: number; + /** + * iBeacon设备的距离精度信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + accuracy?: number; + /** + * iBeacon设备的信号强度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) + */ + rssi?: string; +} + +/** + * IO模块管理本地文件系统,用于对文件系统的目录浏览、文件的读取、文件的写入等操作。通过plus.io可获取文件系统管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIo { + /** + * 文件系统中的目录对象,用于管理特定的本地目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + DirectoryEntry?: PlusIoDirectoryEntry; + /** + * 读取目录信息对象,用于获取目录中包含的文件及子目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + DirectoryReader?: PlusIoDirectoryReader; + /** + * 文件系统中的文件数据对象,用于获取文件的数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + File?: PlusIoFile; + /** + * 文件系统中的文件对象,用于管理特定的本地文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + FileEntry?: PlusIoFileEntry; + /** + * 文件系统中的读取文件对象,用于获取文件的内容 + * FileReader对象是从设备文件系统读取文件FileReader对象是从设备文件系统读取文件的一种方式,文件以文本或者Base64编码的字符串形式读出来。 + * 用户注册自己的事件监听器来接收loadstart、progress、load、loadend、error和abort事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + FileReader?: PlusIoFileReader; + /** + * 文件系统中的写文件对象,用于写入文件内容 + * FileWriter对象是从设备文件系统写入文件FileWriter对象是从设备文件系统写入文件的一种方式,用户注册自己的事件监听器来接收writestart、progress、write、writeend、error和abort事件。 + * 一个FileWriter对象是为单个文件的操作而创建。你可以使用该对象多次对相应文件进行写入操作。FileWriter维护该文件的指针位置及长度属性,这样你就可以寻找和写入文件的任何地方。 + * 默认情况下,FileWriter从文件的开头开始写入(将覆盖现有数据)。FileWriter对象的seek方法可设置文件操作指定位置,如fw.seek(fw.length-1)写入操作就会从文件的末尾开始。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + FileWriter?: PlusIoFileWriter; + /** + * 文件系统对象,用于管理特定本地文件目录 + * 文件系统对象表示一个应用可访问的根目录。name属性用于标识此根目录的名称,与LocalFileSystem中的文件系统类型一一对应。root属性为文件目录对象,用于实际操作文件系统,参考DirectoryEntry。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + FileSystem?: PlusIoFileSystem; + /** + * JSON对象,获取文件操作的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + Flags?: PlusIoFlags; + /** + * JSON对象,保存文件或目录的状态信息对象 + * 可通过DirectoryEntry或FileEntry对象的getMetaData方法获取 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + Metadata?: PlusIoMetadata; + /** + * 文件或目录操作事件对象 + * 所有文件或目录操作事件回调函数中都创建该对象的实例。 + * 该对象从DOMEvent继承而来,可通过该其target属性获取事件触发的文件或目录操作对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + FileEvent?: PlusIoFileEvent; + /** + * 文件路径类型 + * 在文件系统中的文件路径需转换成URL格式,已方便runtime快速加载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + URLType?: PlusIoURLType; + /** + * 相对路径URL + * 只能在扩展API中使用,相对于基座提供的特定目录,以“_”开头。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + RelativeURL?: PlusIoRelativeURL; + /** + * 本地路径URL + * 可在html页面中直接访问本地资源,以“file:///”开头,后面跟随系统的绝对路径。 + * 如示例:“file:///D:/res/hello.html”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + LocalURL?: PlusIoLocalURL; + /** + * 网络路径URL + * 可在html页面中以网络资源模式访问本地资源,以“http://”开头,后面跟随相对路径。 + * 如示例:“http://localhost:13131/_www/res/icon.png”,其中“_www”字段可支持类型与相对路径URL一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + RemoteURL?: PlusIoRemoteURL; + /** + * 应用运行资源目录常量 + * 本地文件系统常量,Number类型,固定值1。应用运行资源目录,仅本应用可访问。 + * 为了确保应用资源的安全性,此目录只可读。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + PRIVATE_WWW?: number; + /** + * 应用私有文档目录常量 + * 本地文件系统常量,Number类型,固定值2。应用私有文档目录,仅本应用可读写。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + PRIVATE_DOC?: number; + /** + * 程序公用文档目录常量 + * 本地文件系统常量,Number类型,固定值3。程序公用文档目录,所有应用可读写。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + PUBLIC_DOCUMENTS?: number; + /** + * 程序公用下载目录常量 + * 本地文件系统常量,Number类型,固定值4。程序公用下载目录,所有应用可读写。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + PUBLIC_DOWNLOADS?: number; + /** + * 请求本地文件系统对象 + * 获取指定的文件系统,可通过type指定获取文件系统的类型。 + * 获取指定的文件系统对象成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + requestFileSystem(type?: number, succesCB?: (result: PlusIoFileSystem) => void, errorCB?: (result: any) => void): void; + /** + * 通过URL参数获取目录对象或文件对象 + * 快速获取指定的目录或文件操作对象,如通过URL值“_www/test.html”可直接获取文件操作对象。 + * url值可支持相对路径URL、本地路径URL。 + * 获取指定的文件或目录操作对象成功通过succesCB回调返回,如果指定URL路径或文件不存在则失败通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + resolveLocalFileSystemURL(url ?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 将本地URL路径转换成平台绝对路径 + * 绝对路径符合各平台文件路径格式,通常用于Native.JS调用系统原生文件操作API,也可以在前面添加“file://”后在html页面中直接使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + convertLocalFileSystemURL(url?: string): string; + /** + * 将平台绝对路径转换成本地URL路径 + * 绝对路径符合各平台文件路径格式,转换后变成RelativeURL类型格式。 + * 功能与convertLocalFileSystemURL方法相反,将绝对路径转换成相对路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + convertAbsoluteFileSystem(path?: string): string; +} + +/** + * 文件系统中的目录对象,用于管理特定的本地目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoDirectoryEntry { + /** + * 操作对象的是否为文件,DirectoryEntry对象固定其值为false + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + isFile?: boolean; + /** + * 操作对象是否为目录,DirectoryEntry对象固定其值为true + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + isDirectory?: boolean; + /** + * 目录操作对象的名称,不包括路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + name?: string; + /** + * 目录操作对象的完整路径,文件系统的绝对路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + fullPath?: string; + /** + * 文件操作对象所属的文件系统对象,参考FileSystem + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + fileSystem?: PlusIoFileSystem; + /** + * 获取目录的属性 + * 用于获取文件或目录的属性信息。 + * 获取属性信息成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + getMetadata(succesCB?: (result: PlusIoMetadata) => void, errorCB?: (result: any) => void, recursive?: boolean): void; + /** + * 移动目录 + * 以下情况移动目录将会导致失败: + * 将父目录移动到子目录中; + * 要移动到的目标目录无效; + * 要移动到的目标路径被文件占用; + * 要移动到的目标目录已经存在并且不为空。 + * 移动目录成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + moveTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 拷贝目录 + * 以下情况拷贝目录将会导致失败: + * 将父目录拷贝到子目录中; + * 要拷贝到的目标目录无效; + * 要拷贝到的目标路径被文件占用; + * 要拷贝到的目标目录已经存在并且不为空。 + * 拷贝目录成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + copyTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 获取目录路径转换为URL地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + toURL(): string; + /** + * 获取目录路径转换为本地路径URL地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + toLocalURL(): string; + /** + * 获取目录路径转换为网络路径URL地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + toRemoteURL(): string; + /** + * 删除目录 + * 以下情况删除目录将会导致失败: + * 目录中存在文件; + * 删除根目录; + * 删除目录成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + remove(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 获取目录所属的父目录 + * 获取父目录成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + getParent(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 创建目录读取对象 + * 创建一个目录读取对象,用户读取目下的文件及子目录。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + createReader(): PlusIoDirectoryReader; + /** + * 创建或打开子目录 + * 创建或打开当前目录指定的目录。 + * 创建或打开目录操作成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + getDirectory(path?: string, flag?: PlusIoFlags, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 创建或打开文件 + * 创建或打开当前目录下指定的文件。 + * 创建或打开文件操作对象成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + getFile(path?: string, flag?: PlusIoFlags, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 递归删除目录 + * 删除目录将会删除其下的所有文件及子目录 + * 不能删除根目录,如果操作删除根目录将会删除目录下的文件及子目录,不会删除根目录自身。 + * 删除目录成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + removeRecursively(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; +} + +/** + * 读取目录信息对象,用于获取目录中包含的文件及子目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoDirectoryReader { + /** + * 获取当前目录中的所有文件和子目录 + * 获取当前目录下的所有文件和子目录。 + * 获取操作成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + readEntries(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; +} + +/** + * 文件系统中的文件数据对象,用于获取文件的数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFile { + /** + * 文件数据对象的数据大小,单位为字节 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + size?: number; + /** + * 文件数据对象MIME类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + type?: string; + /** + * 文件数据对象的名称,不包括路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + name?: string; + /** + * 文件对象的最后修改时间 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + lastModifiedDate?: Date; + /** + * 获取文件指定的数据内容 + * 获取文件指定的数据内容,其中end必须大于start。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + slice(start?: number, end?: number): PlusIoFile; + /** + * 关闭文件数据对象 + * 当文件数据对象不再使用时,可通过此方法关闭,释放系统资源。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + close(): void; +} + +/** + * 文件系统中的文件对象,用于管理特定的本地文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFileEntry { + /** + * 文件操作对象的是否为文件,FileEntry对象固定其值为true + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + isFile?: boolean; + /** + * 文件操作对象是否为目录,FileEntry对象固定其值为false + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + isDirectory?: boolean; + /** + * 文件操作对象的名称,不包括路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + name?: string; + /** + * 文件操作对象的完整路径,文件系统的绝对路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + fullPath?: string; + /** + * 文件操作对象所属的文件系统对象,参考FileSystem + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + fileSystem?: PlusIoFileSystem; + /** + * 获取文件的属性信息 + * 用于获取文件的属性信息。 + * 获取属性信息成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + getMetadata(succesCB?: (result: PlusIoMetadata) => void, errorCB?: (result: any) => void): void; + /** + * 移动文件 + * 以下情况移动目录将会导致失败: + * 要移动到的目标目录无效; + * 要移动到的目标路径被其它文件占用; + * 移动文件成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + moveTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 拷贝文件 + * 以下情况拷贝文件将会导致失败: + * 要拷贝到的目标目录无效; + * 要拷贝到的目标路径被其它文件占用; + * 拷贝文件成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + copyTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 获取文件路径转换为URL地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + toURL(): string; + /** + * 获取文件路径转换为本地路径URL地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + toLocalURL(): string; + /** + * 获取文件路径转换为网络路径URL地址 + * URL地址格式为以“http://localhost:13131/”开头的网络路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + toRemoteURL(): string; + /** + * 删除文件 + * 删除文件成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + remove(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 获取文件所属的父目录 + * 获取父目录成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + getParent(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + /** + * 获取文件关联的写文件操作对象FileWriter + * 获取写文件操作对象成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + createWriter(succesCB?: (result: PlusIoFileWriter) => void, errorCB?: (result: any) => void): void; + /** + * 获取文件数据对象 + * 获取文件数据对象成功通过succesCB回调返回,失败则通过errorCB返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + file(succesCB?: (result: PlusIoFile) => void, errorCB?: (result: any) => void): void; +} + +/** + * 文件系统中的读取文件对象,用于获取文件的内容 + * FileReader对象是从设备文件系统读取文件FileReader对象是从设备文件系统读取文件的一种方式,文件以文本或者Base64编码的字符串形式读出来。 + * 用户注册自己的事件监听器来接收loadstart、progress、load、loadend、error和abort事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFileReader { + /** + * 值为0,开始读取文件状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + EMPTY?: number; + /** + * 值为1,正在读取文件状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + LOADING?: number; + /** + * 值为2,读文件操作完成状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + DONE?: number; + /** + * 当前读取文件所处的状态 + * 可取上面定义的常量值,EMPTY(0)、LOADING(1)、DONE(2)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + readyState?: number; + /** + * 已读取文件的内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + result?: string; + /** + * 文件操作错误代码 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + error?: number; + /** + * 读取文件开始时的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onloadstart?: (result: PlusIoFileEvent) => void; + /** + * 读取文件过程中的回调函数 + * 用于获取文件读取进度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onprogress?: (result: PlusIoFileEvent) => void; + /** + * 读取文件成功完成的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onload?: (result: PlusIoFileEvent) => void; + /** + * 取消读取文件时的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onabort?: (result: PlusIoFileEvent) => void; + /** + * 文件读取操作失败时调用的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onerror?: (result: PlusIoFileEvent) => void; + /** + * 文件读取操作完成时的回调函数 + * 不管成功或失败都会触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onloadend?: (result: PlusIoFileEvent) => void; + /** + * 终止文件读取操作 + * 读取文件操作开始后,可通过此方法取消读取文件。 + * 调用此方法后将触发文件读取对象的onabort事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + abort(): void; + /** + * 以URL编码格式读取文件数据内容 + * 读取文件的数据内容,并将数据内容进行URL编码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + readAsDataURL(file?: PlusIoFile, encoding ?: string): void; + /** + * 以文本格式读取文件数据内容 + * 读取文件的数据内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + readAsText(file?: PlusIoFile, encoding ?: string): void; +} + +/** + * 文件系统中的写文件对象,用于写入文件内容 + * FileWriter对象是从设备文件系统写入文件FileWriter对象是从设备文件系统写入文件的一种方式,用户注册自己的事件监听器来接收writestart、progress、write、writeend、error和abort事件。 + * 一个FileWriter对象是为单个文件的操作而创建。你可以使用该对象多次对相应文件进行写入操作。FileWriter维护该文件的指针位置及长度属性,这样你就可以寻找和写入文件的任何地方。 + * 默认情况下,FileWriter从文件的开头开始写入(将覆盖现有数据)。FileWriter对象的seek方法可设置文件操作指定位置,如fw.seek(fw.length-1)写入操作就会从文件的末尾开始。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFileWriter { + /** + * 值为0,写文件初始化状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + INIT?: number; + /** + * 值为1,正在写入文件状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + WRITING?: number; + /** + * 值为2,写文件操作完成状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + DONE?: number; + /** + * 当前写入文件所处的状态 + * 可取上面定义的常量值,INIT(0)、WRITING(1)、DONE(2)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + readyState?: number; + /** + * 文件当前的长度,单位为字节 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + length?: number; + /** + * 文件当前操作的指针位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + position?: number; + /** + * 文件写入操作错误代码 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + error?: number; + /** + * 写入文件开始时的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onwritestart?: (result: PlusIoFileEvent) => void; + /** + * 写入文件过程中的回调函数 + * 用于获取文件读取进度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onprogress?: (result: PlusIoFileEvent) => void; + /** + * 写入文件成功完成的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onwrite?: (result: PlusIoFileEvent) => void; + /** + * 取消写入文件时的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onabort?: (result: PlusIoFileEvent) => void; + /** + * 文件写入操作失败时调用的回调函数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onerror?: (result: PlusIoFileEvent) => void; + /** + * 文件写入操作完成时的回调函数 + * 不管成功或失败都会触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + onwriteend?: (result: PlusIoFileEvent) => void; + /** + * 终止文件写入操作 + * 写入文件数据操作开始后,可通过此方法取消写入文件数据操作。 + * 调用此方法后将触发文件写入对象的onabort事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + abort(): void; + /** + * 定位文件操作位置 + * 定位文件的操作位置,有效值为0到文件的总长度减1。 + * 0表示文件的起始位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + seek(position?: number): void; + /** + * 按照指定长度截断文件 + * 从文件当前定位的位置开始,按照指定长度截断文件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + truncate(length ?: number): void; + /** + * 向文件中写入数据 + * 从文件当前定位的位置开始,写入数据到文件中。 + * 如果文件中已经存在数据,新写入的数据将覆盖已有数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + write(data ?: string): void; +} + +/** + * 文件系统对象,用于管理特定本地文件目录 + * 文件系统对象表示一个应用可访问的根目录。name属性用于标识此根目录的名称,与LocalFileSystem中的文件系统类型一一对应。root属性为文件目录对象,用于实际操作文件系统,参考DirectoryEntry。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFileSystem { + /** + * 文件系统的名称 + * 值为文件系统类型常量值字符串,如“PRIVATE_WWW”、“PRIVATE_DOCUMENTS”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + name?: string; + /** + * 文件系统的根目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + root?: PlusIoDirectoryEntry; +} + +/** + * JSON对象,获取文件操作的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFlags { + /** + * 是否创建对象标记 + * 指示如果文件或目录不存在时是否进行创建,默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + create?: boolean; + /** + * 反向操作标记 + * 其本身没有任何效果,需与create属性值设置为true时一起使用,如果目标文件或目录已经存在则会导致文件或目录打开失败,默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + exclusive?: boolean; +} + +/** + * JSON对象,保存文件或目录的状态信息对象 + * 可通过DirectoryEntry或FileEntry对象的getMetaData方法获取 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoMetadata { + /** + * 文件或目录的最后修改时间 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + modificationTime?: Date; + /** + * 文件的大小 + * 若获取的是目录对象的属性则值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + size?: number; + /** + * 包含的子目录数 + * 若自身是文件则其值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + directoryCount?: number; + /** + * 目录的文件数 + * 若自身是文件则其值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + fileCount?: number; +} + +/** + * 文件或目录操作事件对象 + * 所有文件或目录操作事件回调函数中都创建该对象的实例。 + * 该对象从DOMEvent继承而来,可通过该其target属性获取事件触发的文件或目录操作对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoFileEvent { + /** + * 文件或目录操作对象 + * 在不同的回调中指向的对象不同,可指向的对象包括:FileEntry、DirectoryEntry、FileReader、FileWriter。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + target?: PlusIoDirectoryEntry; +} + +/** + * 文件路径类型 + * 在文件系统中的文件路径需转换成URL格式,已方便runtime快速加载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoURLType { + /** + * 相对路径URL + * 只能在扩展API中使用,相对于基座提供的特定目录,以“_”开头。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + RelativeURL?: PlusIoRelativeURL; + /** + * 本地路径URL + * 可在html页面中直接访问本地资源,以“file:///”开头,后面跟随系统的绝对路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + LocalURL?: PlusIoLocalURL; + /** + * 网络路径URL + * 可在html页面中以网络资源模式访问本地资源,以“http://”开头,后面跟随相对路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + RomoteURL?: string; +} + +/** + * 相对路径URL + * 只能在扩展API中使用,相对于基座提供的特定目录,以“_”开头。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +interface PlusIoRelativeURL { + /** + * 应用资源目录 + * 保存应用的所有html、css、js等资源文件,与文件系统中根目录PRIVATE_WWW一致,后面加相对路径如“_www/res/icon.png”。 + * 注意:应用资源目录是只读目录,只能读取次目录下的文件,不能修改或新建。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + _www?: string; + /** + * 应用私有文档目录 + * 用于保存应用运行期业务逻辑数据,与文件系统中根目录PRIVATE_DOCUMENTS,如“_doc/userdata.xml”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + _doc?: string; + /** + * 程序公用文档目录 + * 用于保存程序中各应用间可共享文件的目录,与文件系统中根目录PUBLIC_DOCUMENTS,如“_document/share.doc”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + _documents?: string; + /** + * 程序公用下载目录 + * 用于保存程序下载文件的目录,与文件系统中根目录PUBLIC_DOWNLOADS,如“_download/mydoc.doc”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ + _downloads?: string; +} + +/** + * 本地路径URL + * 可在html页面中直接访问本地资源,以“file:///”开头,后面跟随系统的绝对路径。 + * 如示例:“file:///D:/res/hello.html”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +type PlusIoLocalURL = any; +/** + * 网络路径URL + * 可在html页面中以网络资源模式访问本地资源,以“http://”开头,后面跟随相对路径。 + * 如示例:“http://localhost:13131/_www/res/icon.png”,其中“_www”字段可支持类型与相对路径URL一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) + */ +type PlusIoRemoteURL = any; + +/** + * Native.js for iOS封装一条通过JS语法直接调用Native Objective-C接口通道,通过plus.ios可调用几乎所有的系统API。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ +interface PlusIos { + /** + * Objective-C类对象 + * Objective-C类对象,可通过其属性获取类的常量,可通过方法来操作类的静态方法,也通过new方法来创建类的实例对象。 + * 对于类的静态方法,则直接通过.后面跟随方法名称调用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + ClassObject?: PlusIosClassObject; + /** + * Objective-C实例对象 + * Objective-C实例对象,可通过其方法来操作示例的变量和方法。 + * 注意:必须通过plusGetAttribute()方法读取示例对象的属性值,通过plusSetAttribute()方法设置示例对象的属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + InstanceObject?: PlusIosInstanceObject; + /** + * 导入Objective-C类对象 + * 导入类对象后,就可以通过.操作符直接调用对象(类对象/实例对象)的方法。 + * 通过.操作符号调用方法时,不需要使用":"来分割参数。 + * 注意:导入类对象将会消耗较多的系统资源,不应该导入过多的类对象,可以使用plus.ios.invoke()来调用未导入类实例对象的方法。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + importClass(classname?: string): PlusIosClassObject; + /** + * 创建实例对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + newObject(classname?: string, args?: any): PlusIosInstanceObject; + /** + * 销毁实例对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + deleteObject(obj?: any): void; + /** + * 调用对象(类对象/示例对象)的方法 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + invoke(obj?: PlusIosInstanceObject, name?: string, args?: any): any; + /** + * 实现代理的方法 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + implements(name?: string, obj?: any): PlusIosInstanceObject; + /** + * 获取当前Webview窗口对象的native层UIWebview实例对象 + * UIWebview对象的API请参考Apple开发文档 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + currentWebview(): PlusIosInstanceObject; +} + +/** + * Objective-C类对象 + * Objective-C类对象,可通过其属性获取类的常量,可通过方法来操作类的静态方法,也通过new方法来创建类的实例对象。 + * 对于类的静态方法,则直接通过.后面跟随方法名称调用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ +type PlusIosClassObject = any; + +/** + * Objective-C实例对象 + * Objective-C实例对象,可通过其方法来操作示例的变量和方法。 + * 注意:必须通过plusGetAttribute()方法读取示例对象的属性值,通过plusSetAttribute()方法设置示例对象的属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ +interface PlusIosInstanceObject { + /** + * 获取Objective-C实例对象的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + plusGetAttribute(name?: string): any; + /** + * 设置Objective-C示例对象的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) + */ + plusSetAttribute(name?: string, value?: any): void; +} + +/** + * Key管理设备按键事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ +interface PlusKey { + /** + * 按键类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + KeyType?: PlusKeyKeyType; + /** + * 按键事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + KeyEvent?: PlusKeyKeyEvent; + /** + * 添加按键事件监听器 + * 添加按键事件监听器,当指定的按键事件发生时,回调函数将触发。 + * 应用中存在多个Webview窗口时,按照窗口的显示栈顺序从后往前查找,查找到添加按键事件监听器的窗口后停止(中断前面Webview窗口对按键事件的监听),并向窗口触发执行按键回调事件。 + * 在同一Webview窗口中可多次调用此方法对同一事件添加多个监听器,触发时按照添加的顺序先后调用。 + * 注意:此方法无法监听软键盘的按键事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + addEventListener(event?: PlusKeyKeyType, listener?: (result: PlusKeyKeyEvent) => void, capture?: boolean): void; + /** + * 隐藏软键盘 + * 隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + hideSoftKeybord(): void; + /** + * 设置辅助输入类型 + * input的type类型为text获取焦点时,在软键盘上方显示辅助输入条方便用户快速输入。 + * 在页面中input编辑框type类型不为"tel"、"email"时生效(type为tel类型时一定显示tel的辅助输入条,type为email时一定显示email的辅助输入条)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + setAssistantType(type?: string): void; + /** + * 显示软键盘 + * 强制显示系统软键盘,如果软键盘已经显示则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + showSoftKeybord(): void; + /** + * 移除按键事件监听器 + * 从窗口移除指定的事件监听器。若没有查找到对应的事件监听器,则无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + removeEventListener(event?: PlusKeyKeyType, listener?: (result: PlusKeyKeyEvent) => void): void; +} + +/** + * 按键类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ +interface PlusKeyKeyType { + /** + * 设备“返回”按钮按键事件 + * 如果需要改变默认“返回”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"backbutton"事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + backbutton?: string; + /** + * 键按下事件 + * 如果需要改变默认键按下的处理逻辑,则可通过plus.key.addEventListener来注册监听"keydown"事件。 + * 可通过回调函数中KeyEvent对象的keyCode来获取按下的键值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + keydown?: string; + /** + * 键松开事件 + * 如果需要改变默认键松开的处理逻辑,则可通过plus.key.addEventListener来注册监听"keyup"事件。 + * 可通过回调函数中KeyEvent对象的keyCode来获取松开的键值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + keyup?: string; + /** + * 长按键事件 + * 如果需要改变默认长按键的处理逻辑,则可通过plus.key.addEventListener来注册监听"longpressed"事件。 + * 长按键时会多次触发回调函数,通过回调函数中KeyEvent对象的keyCode来获取长按的键值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + longpressed?: string; + /** + * 设备“菜单”按钮按键事件 + * 如果需要改变默认“菜单”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"menubutton"事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + menubutton?: string; + /** + * 设备“搜索”按钮按键事件 + * 如果需要改变默认“搜索”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"searchbutton"事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + searchbutton?: string; + /** + * 设备“音量+”按钮按键事件 + * 如果需要改变默认“音量+”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"volumeupbutton"事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + volumeupbutton?: string; + /** + * 设备“音量-”按钮按键事件 + * 如果需要改变默认“音量-”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"volumedownbutton"事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + volumedownbutton?: string; +} + +/** + * 按键事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ +interface PlusKeyKeyEvent { + /** + * 触发按键事件的键值 + * 键值由各系统平台定义,一些特殊按键在不同的设备上可能存在差异。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + keyCode?: number; + /** + * 按键事件类型 + * 用于表明触发此按键事件的类型,值为KeyType中定义的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) + */ + keyType?: PlusKeyKeyType; +} + +/** + * Messaging模块管理设备通讯功能,可用于短信、彩信、邮件发送等。通过plus.messaging可获取设备通讯管理对象。另外也可以直接通过html中的href直接快速发送短信、拨打电话、发送邮件等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ +interface PlusMessaging { + /** + * 消息对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + Message?: PlusMessagingMessage; + /** + * 消息体内容类型 + * 用于设定消息的消息体内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + BodyType?: PlusMessagingBodyType; + /** + * 简单短信类型常量 + * 消息类型常量,Number类型,固定值为1,用于创建并发送短信。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + TYPE_SMS?: number; + /** + * 彩信类型常量 + * 消息类型常量,Number类型,固定值为2,用于创建并发送多媒体短信(彩信)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + TYPE_MMS?: number; + /** + * 邮件类型常量 + * 消息类型常量,Number类型,固定值为3,用于创建并发送邮件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + TYPE_EMAIL?: number; + /** + * 创建消息对象 + * 创建指定类型的消息,消息类型可取plus.messaging.TYPE_SMS、plus.messaging.TYPE_MMS、plus.messaging.TYPE_EMAIL。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + createMessage(type ?: number): PlusMessagingMessage; + /** + * 发送消息 + * 发送消息,发送成功回调successCB函数,发送失败回调errorCB函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + sendMessage(msg?: PlusMessagingMessage, successCB?: () => void, errorCB?: (result: any) => void): void; +} + +/** + * 消息对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ +interface PlusMessagingMessage { + /** + * 收件人信息 + * 字符串数组类型,输入的地址收件人信息必须符合消息类型格式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + to?: any []; + /** + * 抄送人信息 + * 字符串数组类型,仅发送邮件时有效,输入的地址收件人信息必须符合消息类型格式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + cc?: any []; + /** + * 暗送人信息 + * 字符串数组类型,仅发送邮件时有效,输入的地址收件人信息必须符合消息类型格式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + bcc?: any []; + /** + * 发件人信息 + * 仅在监听接收到的信息时有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + from?: string; + /** + * 发送消息主题 + * 字符串类型,仅发送邮件时有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + subject?: string; + /** + * 发送消息内容 + * 字符串类型,要发送的消息体内容,其格式必须与bodyType指定的一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + body?: string; + /** + * 发送消息内容类型 + * 要发送消息体内容的类型,可取值"text"表示文本内容,"html"表示为html页面,默认值为"text"。 + * - text/plain: 纯文本类型消息体内容 + * - text/html: 网页数据类型消息体内容(用于发送邮件) + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + bodyType?: 'text/plain' | 'text/html'; + /** + * 是否采用静默方式发送消息 + * 布尔类型,可取值为true或false,true表示静默方式发送,不弹出界面;false表示非静默方式发送。默认采用非静默方式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + silent?: boolean; + /** + * 添加附件 + * 向消息中添加附件,仅邮件类型消息支持,其它类型消息不支持。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + addAttachment(url?: string): void; +} + +/** + * 消息体内容类型 + * 用于设定消息的消息体内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ +interface PlusMessagingBodyType { + /** + * 文本类型 + * 纯文本类型消息体内容,默认消息体内容类型。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + 'text/plain'?: string; + /** + * Html类型 + * 网页数据类型消息体内容,可用于发送邮件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) + */ + 'text/html'?: string; +} + +/** + * nativeObj管理系统原生对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObj { + /** + * 原生动画参数 + * 指定动画的类型、持续时间等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + AnimationOptions?: PlusNativeObjAnimationOptions; + /** + * 原生动画窗口样式 + * 指定动画窗口的样式,如背景图片,绘制的文字等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + AnimationViewStyles?: PlusNativeObjAnimationViewStyles; + /** + * 原生图片对象 + * 原生图片对象会占用较大的内存资源,在使用时需谨慎管理,当图片不再使用时应该及时调用clear方法进行销毁。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + Bitmap?: PlusNativeObjBitmap; + /** + * JSON对象,保存图片的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + BitmapSaveOptions?: PlusNativeObjBitmapSaveOptions; + /** + * 原生图片轮播控件对象 + * 原生图片轮播控件对象从原生View控件(plus.nativeObj.View)继承而来,用于绘制图片轮播内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ImageSlider?: PlusNativeObjImageSlider; + /** + * 图片轮播控件样式 + * 从ViewStyles继承而来,扩展支持轮播图片等配置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ImageSliderStyles?: PlusNativeObjImageSliderStyles; + /** + * 图片轮播控件中图片项配置参数 + * 用于指定图片地址等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ImageSliderImageStyles?: PlusNativeObjImageSliderImageStyles; + /** + * 输入框样式 + * 用于定义输入框的显示样式,如字体大小,提示内容等信息。 + * 输入文本内容在指定区域水平居左,垂直居中显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + InputStyles?: PlusNativeObjInputStyles; + /** + * 区域信息对象 + * 包括位置、大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + Rect?: PlusNativeObjRect; + /** + * 绘制区域样式对象 + * 用于定义矩形区域的显示样式,如空心/实心样式、圆角等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + RectStyles?: PlusNativeObjRectStyles; + /** + * 富文本样式 + * 用于定义富文本使用的默认使用的字体名称、字体文件路径等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + RichTextStyles?: PlusNativeObjRichTextStyles; + /** + * 区域信息对象 + * 包括位置、大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + Position?: PlusNativeObjPosition; + /** + * 绘制文本样式对象 + * 用于定义文本的显示样式,如字体大小、字体颜色、字体粗细、字体样式、字体名称等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + TextStyles?: PlusNativeObjTextStyles; + /** + * 原生控件对象 + * 原生控件对象可用于在屏幕上绘制图片或文本内容,当控件不再使用时需要调用close方法销毁控件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + View?: PlusNativeObjView; + /** + * View控件动画参数 + * 指定动画的类型、持续时间等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ViewAnimationOptions?: PlusNativeObjViewAnimationOptions; + /** + * View控件绘制元素参数 + * 指定绘制图片、矩形区域、文本内容等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ViewDrawTagStyles?: PlusNativeObjViewDrawTagStyles; + /** + * View控件事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ViewEvents?: PlusNativeObjViewEvents; + /** + * JSON对象,View控件的系统状态栏区域样式 + * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ViewStatusbarStyles?: PlusNativeObjViewStatusbarStyles; + /** + * View控件样式 + * 包括位置、大小等信息等,其中位置信息相对于父容器控件进行计算。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + ViewStyles?: PlusNativeObjViewStyles; +} + +/** + * 原生动画参数 + * 指定动画的类型、持续时间等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjAnimationOptions { + /** + * 动画类型 + * 可取值: + * "pop-in" - 从右侧平移入栈动画效果(副窗口从右侧向左平移滑出显示,主窗口从当前屏幕区域向左侧平移滑出被遮盖),如果仅传入一个View控件对象则自动降级为slide-in-right动画; + * "pop-out" - 从右侧平移出栈动画效果(副窗口从当前屏幕区域向右侧平移出可视区域,主窗口从左侧向右平移滑出显示),如果仅出入一个View控件对象则自动降级为slide-out-right动画; + * "slide-in-right" - 从右侧横向滑动效果(主窗口从当前屏幕右侧外向内横向滑动显示); + * "slide-out-right - 横向向右侧滑出屏幕动画(主窗口从屏幕中横向向右侧滑动到屏幕外)。 + * - pop-in: + * 从右侧平移入栈动画效果(副窗口从右侧向左平移滑出显示,主窗口从当前屏幕区域向左侧平移滑出被遮盖)。 + * + * - pop-out: + * 从右侧平移出栈动画效果(副窗口从当前屏幕区域向右侧平移出可视区域,主窗口从左侧向右平移滑出显示)。 + * + * - slide-in-right: + * 从右侧横向滑动效果(主窗口从当前屏幕右侧外向内横向滑动显示)。 + * + * - slide-out-right: + * 横向向右侧滑出屏幕动画(主窗口从屏幕中横向向右侧滑动到屏幕外)。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + type?: 'pop-in' | 'pop-out' | 'slide-in-right' | 'slide-out-right'; + /** + * 动画持续时间 + * 单位为毫秒,默认值为200ms。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + duration?: number; +} + +/** + * 原生动画窗口样式 + * 指定动画窗口的样式,如背景图片,绘制的文字等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjAnimationViewStyles { + /** + * 动画窗口上绘制的背景图片 + * 图片可以通过Webview对象的draw方法截图,也可以通过Bitmap的API从本地文件中加载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + bitmap?: PlusNativeObjBitmap; + /** + * 动画窗口上绘制的文本内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + text?: string; + /** + * 动画窗口上绘制的文本样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + textStyles?: PlusNativeObjTextStyles; + /** + * 动画窗口上绘制的文本区域 + * 默认值为{top:'0px',left:'0px',width:'100%',height:'44px'}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + textRect?: PlusNativeObjRect; +} + +/** + * 原生图片对象 + * 原生图片对象会占用较大的内存资源,在使用时需谨慎管理,当图片不再使用时应该及时调用clear方法进行销毁。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjBitmap { + /** + * Bitmap对象的标识 + * 在创建Bitmap对象时设置,如果没有设置标识,此属性值为null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + id?: string; + /** + * 静态方法,获取所有Bitmap图片对象 + * 获取应用运行期创建的所有Bitmap图片对象,包含所有空Bitmap对象,不包含已经销毁的Bitmap对象。返回的Bitmap对象在数组中按创建的属性排列,及数组中第一个是最先创建的Bitmap对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + getItems(): PlusNativeObj []; + /** + * 静态方法,获取指定标识的Bitmap图片对象 + * 在应用中已创建的图片对象中查找指定标识的Bitmap对象并返回。 + * 若存在多个相同标识的Bitmap图片,则返回第一个创建的Bitmap图片。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + getBitmapById(id?: string): PlusNativeObjBitmap; + /** + * 销毁Bitmap图片 + * 释放Bitmap图片占用的内存资源,销毁后图片对象将不可使用,其id属性值为undefined,调用其所有方法操作都会失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + clear(): void; + /** + * 加载Bitmap图片 + * 从指定的路径(仅支持本地文件系统)中加载图片,此操作将覆盖之前的图片内容, + * 如果加载图片失败则保留之前的图片内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + load(path?: string, successCallback?: () => void, errorCallback?: (result: any) => void): void; + /** + * 加载Base64编码格式图片到Bitmap对象 + * 从Base64编码格式图片数据中加载图片,此操作将覆盖之前的图片内容, + * 如果加载图片失败则保留之前的图片内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + loadBase64Data(data?: string, successCallback?: () => void, errorCallback?: (result: any) => void): void; + /** + * 回收Bitmap图片内存 + * 释放Bitmap图片占用的内存资源,但不销毁图片对象,依然可以继续使用图片对象。 + * 当图片对象再次被使用时会自动从设置的路径(构造函数或load/save方法设置)加载到内存中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + recycle(): void; + /** + * 保存图片 + * 将图片保存到指定的路径(仅支持本地文件系统),如果图片为空或者指定的路径文件已经存在则返回失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + save(path?: string, options?: PlusNativeObjBitmapSaveOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 获取图片的Base64编码数据 + * 读取图片的数据内容,并转换为Base64编码格式字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + toBase64Data(): string; +} + +/** + * JSON对象,保存图片的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjBitmapSaveOptions { + /** + * 覆盖保存图片文件 + * 仅在保存的图片路径文件存在时有效: + * true表示覆盖存在的文件; + * false表示不覆盖,如果文件存在,则返回失败。 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + overwrite?: boolean; + /** + * 保存图片的格式 + * 支持"jpg"、"png",如果未指定则默认使用指定的保存路径后缀对应的文件格式,如果后缀文件格式无效则使用jpg格式。 + * - jpg: JPG格式图片 + * - png: PNG格式图片 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + format?: 'jpg' | 'png'; + /** + * 保存图片的质量 + * 取值范围为1-100,1表示使用最低的图片质量(保存后的图片文件最小)、100表示使用最高的图片质量(保存后的图片文件最大); + * 默认值为50。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + quality?: number; + /** + * 指定裁剪区域保存图片 + * 相对于图片的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + clip?: PlusNativeObjRect; +} + +/** + * 原生图片轮播控件对象 + * 原生图片轮播控件对象从原生View控件(plus.nativeObj.View)继承而来,用于绘制图片轮播内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjImageSlider { + /** + * 添加图片轮播控件的图片 + * 动态添加图片轮播控件显示的图片。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + addImages(images?: PlusNativeObj []): void; + /** + * 获取当前图片轮播控件显示的图片索引值 + * 索引值从0开始,即0表示图片轮播控件当前显示第一张图片。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + currentImageIndex(): number; + /** + * 设置图片轮播控件的图片 + * 动态更新图片轮播控件显示的图片。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + setImages(images?: PlusNativeObj []): void; +} + +/** + * 图片轮播控件样式 + * 从ViewStyles继承而来,扩展支持轮播图片等配置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjImageSliderStyles { + /** + * 是否自动播放 + * 可取值: + * "true" - 自动播放; + * "false" - 不自动播放。 + * 默认值为"false"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + autoplay?: boolean; + /** + * 是否可全屏显示 + * 可取值: + * "true" - 表示可全屏显示,用户点击轮播图片时全屏显示; + * "false" - 表示不可全屏显示,用户点击轮播图片时无响应。 + * 默认值为"true"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + fullscreen?: boolean; + /** + * 是否可循环轮播 + * 可取值: + * "true" - 支持循环轮播; + * "false" - 不支持循环轮播。 + * 默认值为"false"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + loop?: boolean; + /** + * 轮播的图片 + * 至少必须设置一张图片的地址信息,否则可能导致图片轮播控件显示不正常。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + images?: PlusNativeObj []; + /** + * 自动播放切换时间 + * 当autoplay属性值为true时生效,单位为毫秒。默认值为3000(3秒)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + interval?: number; +} + +/** + * 图片轮播控件中图片项配置参数 + * 用于指定图片地址等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjImageSliderImageStyles { + /** + * 图片地址 + * 支持本地地址(相对地址、绝对路径、RelativeURL、本地路径URL); + * 也支持网络地址(http://或https://)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + src?: string; + /** + * 图片水平对齐方式 + * 仅在图片显示的宽度与图片轮播控件宽度不一致时有效,可取值: + * "left" - 图片在轮播控件中水平居左对齐; + * "center" - 图片在轮播控件中水平居中对齐; + * "right" - 图片在轮播控件中水平居右对齐。 + * 默认值为"center"。 + * - left: 图片在轮播控件中水平居左对齐 + * - center: 图片在轮播控件中水平居中对齐 + * - right: 图片在轮播控件中水平居右对齐 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + align?: 'left' | 'center' | 'right'; + /** + * 图片显示的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",现对于图片轮播控件的高度; + * 自动计算"auto",如果指定图片宽度(width),则按图片实际大小等比缩放图片高度值,如果没有指定宽度(width值为"auto")则自动缩放图片至可完整显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + height?: string; + /** + * 图片显示的宽度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于图片轮播控件的宽度; + * 自动计算"auto",如果指定图片高度(height),则按图片实际大小等比缩放图片宽度值,如果没有指定高度(height值为"auto")则自动缩放图片至可完整显示。 + * 默认值为"auto"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + width?: string; + /** + * 图片垂直对齐方式 + * 仅在图片显示的高度与图片轮播控件宽度不一致时有效,可取值: + * "top" - 图片在轮播控件中垂直居顶对齐; + * "middle" - 图片在轮播控件中垂直居中对齐; + * "bottom" - 图片在轮播控件中垂直居底对齐。 + * 默认值为"middle"。 + * - top: 图片在轮播控件中垂直居顶对齐 + * - middle: 图片在轮播控件中垂直居中对齐 + * - bottom: 图片在轮播控件中垂直居底对齐 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + verticalAlign?: 'top' | 'middle' | 'bottom'; +} + +/** + * 输入框样式 + * 用于定义输入框的显示样式,如字体大小,提示内容等信息。 + * 输入文本内容在指定区域水平居左,垂直居中显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjInputStyles { + /** + * 输入框类型 + * 可取值: + * "email" - 邮箱地址输入框; + * "number" - 数字输入框; + * "search" - 搜索文本输入框; + * "tel" - 电话号码输入框; + * "text" - 普通文本输入框; + * "url" - URL地址输入框。 + * 默认为text(即普通文本输入框)。 + * - email: 邮箱地址输入框 + * - number: 数字输入框 + * - search: 搜索文本输入框 + * - tel: 电话号码输入框 + * - text: 普通文本输入框 + * - url: URL地址输入框 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + type?: 'email' | 'number' | 'search' | 'tel' | 'text' | 'url'; + /** + * 输入框的提示文本 + * 当用户未输入内容时显示在编辑框中(灰色文字)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + placeholder?: string; + /** + * 输入框的字体大小 + * 可取值:字体高度像素值,数字加"px"格式字符串,如"12px"。 + * 默认值为"16px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + fontSize?: string; + /** + * 输入框的边框颜色 + * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示红色边框。默认值为"#000000"(黑色)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + borderColor?: string; + /** + * 输入框边框圆角半径 + * 可取值:圆角半径像素值,数字加"px"格式字符串,如"6px"。 + * 默认值为"0px"(边框无圆角)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + borderRadius?: string; + /** + * 输入框的边框宽度 + * 可取值:像素值,数字加"px"格式字符串,如"2px"。 默认值为"1px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + borderWidth?: string; + /** + * 输入框完成输入事件 + * 弹出软键盘完成输入后,点击软键盘上的“完成”、“前往”按钮时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + onComplete?: (result: any) => void; + /** + * 输入框获取焦点事件 + * 当编辑框获取焦点时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + onFocus?: (result: any) => void; + /** + * 输入框失去焦点事件 + * 当编辑框失去焦点时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + onBlur?: (result: any) => void; +} + +/** + * 区域信息对象 + * 包括位置、大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjRect { + /** + * 区域左上角的垂直偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于作用对象的高度; + * 自动计算,如"auto",根据height值自动计算,相对于作用对象垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + top?: string; + /** + * 区域左上角的水平偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于作用对象的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于作用对象水平居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + left?: string; + /** + * 区域的宽度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于作用对象的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + width?: string; + /** + * 区域的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于作用对象的高度。 + * 内容自适应,如"wrap_content",根据内容计算高度(如调用drawText绘制文本时支持)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + height?: string; +} + +/** + * 绘制区域样式对象 + * 用于定义矩形区域的显示样式,如空心/实心样式、圆角等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjRectStyles { + /** + * 绘制颜色 + * 矩形填充区域的颜色,可取值: + * "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为"#FFFFFF"(白色)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + color?: string; + /** + * 矩形区域的圆角半径 + * 可取值:圆角半径像素值,数字加"px"格式字符串,如"6px"。 + * 默认值为"0px"(矩形无圆角)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + radius?: string; + /** + * 矩形边框颜色 + * 绘制矩形边框的颜色,可取值: + * "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为矩形填充区域颜色(color属性值)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + borderColor?: string; + /** + * 矩形边框宽度 + * 可取值:像素值,数字加"px"格式字符串,如"2px"。 + * 默认值为"0px"(无边框)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + borderWidth?: string; +} + +/** + * 富文本样式 + * 用于定义富文本使用的默认使用的字体名称、字体文件路径等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjRichTextStyles { + /** + * 富文本内容的水平对齐方式 + * 对整体内容有效,无法单独控制每行的内容。 + * 可取值: + * "left"-字体在指定的区域中水平居左对齐; + * "center"-字体在指定的区域中水平居中对齐; + * "right"-字体在指定的区域中水平居右对齐。 + * 默认值为"left"。 + * - left: 富文本内容水平居左对齐 + * - center: 富文本内容水平居中对齐 + * - right: 富文本内容水平居右对齐 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + align?: 'left' | 'center' | 'right'; + /** + * 富文本默认使用的字体名称 + * 例如"Times New Roman", 如果指定名称的字体不存在,则使用系统默认字体。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + family?: string; + /** + * 富文本默认使用的字体文件路径 + * 加载字体文件路径,必须为本地路径,如果指定的文件路径无效,则使用系统默认字体。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + fontSrc?: string; + /** + * 点击事件回调函数 + * 如果设置此属性,则表示拦截所有RichText上的点击事件(不透传事件)。 + * 如果没有设置此属性,则仅拦截操作包含onclick属性的a/img标签的点击事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + onClick?: (result: any) => void; +} + +/** + * 区域信息对象 + * 包括位置、大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjPosition { + /** + * 区域顶部相对于作用对象(或容器)向下的偏移量 + * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的高度; + * 自动计算,如"auto",根据height值自动计算,相对于作用对象(或容器)垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + top?: string; + /** + * 区域左侧相对于作用对象(或容器)向右的偏移量 + * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于作用对象(或容器)水平居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + left?: string; + /** + * 区域的宽度 + * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + width?: string; + /** + * 区域的高度 + * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + height?: string; + /** + * 区域底部相对于作用对象(或容器)向上的偏移量 + * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的高度。 + * 当设置了top和height值时,忽略此属性值; + * 当未设置top值时,可通过bottom属性值来确定区域的垂直位置; + * 当未设置height值时,可通过top和bottom属性值来确定区域的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + bottom?: string; + /** + * 区域右侧相对于作用对象(或容器)向左的偏移量 + * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的宽度。 + * 当设置了left和width值时,忽略此属性值; + * 当未设置left值时,可通过right属性值来确定区域的水平位置; + * 当未设置width值时,可通过left和right属性值来确定区域的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + right?: string; +} + +/** + * 绘制文本样式对象 + * 用于定义文本的显示样式,如字体大小、字体颜色、字体粗细、字体样式、字体名称等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjTextStyles { + /** + * 水平对齐方式 + * 可取值: + * "left"-字体在指定的区域中水平居左对齐; + * "center"-字体在指定的区域中水平居中对齐; + * "right"-字体在指定的区域中水平居右对齐。 + * 默认值为"center"。 + * - left: 字体在指定的区域中水平居左对齐 + * - center: 字体在指定的区域中水平居中对齐 + * - right: 字体在指定的区域中水平居右对齐 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + align?: 'left' | 'center' | 'right'; + /** + * 字体颜色 + * 可取值: + * "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为"#000000"(黑色)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + color?: string; + /** + * 文本装饰 + * 可取值: + * "none" - 无装饰效果; + * "underline" - 文本带下划线效果; + * "line-through" - 文本带贯穿线(删除线)效果。 + * 默认值为"none"。 + * - none: + * 无装饰效果 + * + * - underline: + * 文本带下划线效果 + * + * - line-through: + * 文本带贯穿线(删除线)效果 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + decoration?: 'none' | 'underline' | 'line-through'; + /** + * 字体名称 + * 例如"Times New Roman", 如果指定名称的字体不存在,则使用默认字体。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + family?: string; + /** + * 字体文件路径 + * 加载字体文件路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + fontSrc?: string; + /** + * 文本的行间距 + * 可取值: + * 像素值,如"100px";百分比,如"10%",相对于字体的高度(size属性); + * 默认值为"20%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + lineSpacing?: string; + /** + * 字体的边距 + * 用于设置字体在绘制目标区域四个方向(top/right/bottom/left)的边距,可取值:像素值,如"10px";百分比,相对于绘制目标区域,如"5%"; + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + margin?: string; + /** + * 文本内容超出显示区域时处理方式 + * 可取值: + * "clip" - 超出显示区域时内容裁剪; + * "ellipsis" - 超出显示区域时尾部显示省略标记(...)。 + * 默认值为"clip"。 + * - clip: + * + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + overflow?: 'clip'; + /** + * 字体大小 + * 可取值:字体高度像素值,数字加"px"格式字符串,如"12px"。 + * 默认值为"16px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + size?: string; + /** + * 字体样式 + * 可取值:"normal" - 正常字体样式;"italic" - 斜体样式。默认值为"normal"。 + * - normal: 正常字体样式 + * - italic: 斜体样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + style?: 'normal' | 'italic'; + /** + * 垂直对齐方式 + * 文本内容在指定绘制区域中的垂直对齐方式,可取值: + * "top" - 垂直居顶对齐; + * "middle" - 垂直居中对齐; + * "bottom" - 垂直居底对齐。 + * 默认值为"middle"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + verticalAlign?: string; + /** + * 字体粗细 + * 可取值:"normal" - 普通字体;"bold" - 粗字体。默认值为"normal"。 + * - normal: 普通字体 + * - bold: 粗字体 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + weight?: 'normal' | 'bold'; + /** + * 文本换行模式 + * 可取值: + * "nowrap" - 不换行,将所有文本在一行中绘制,忽略换行符("\n"); + * "normal" - 自动换行,当指定的宽度无法绘制所有文本时自动换行绘制,碰到'\n'字符时强制换行。 + * 默认值为"nowrap"。 + * - nowrap: + * 不换行,将所有文本在一行中绘制,忽略换行符("\n") + * + * - normal: + * 自动换行,当指定的宽度无法绘制所有文本时自动换行绘制,碰到'\n'字符时强制换行 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + whiteSpace?: 'nowrap' | 'normal'; +} + +/** + * 原生控件对象 + * 原生控件对象可用于在屏幕上绘制图片或文本内容,当控件不再使用时需要调用close方法销毁控件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjView { + /** + * View对象的标识 + * 在创建原生控件View对象时设置,如果没有设置标识,此属性值为null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + id?: string; + /** + * 静态方法,开始原生动画 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + startAnimation(options?: PlusNativeObjAnimationOptions, view?: PlusNativeObjAnimationViewStyles, otherview?: PlusNativeObjAnimationViewStyles, callback?: () => void): void; + /** + * 静态方法,关闭原生动画窗口 + * 通过plus.nativeObj.View.startAnimation方法开始原生动画后,不会自动关闭原生动画窗口对象,需要调用此方法关闭原生动画。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + clearAnimation(type?: string): void; + /** + * 静态方法,获取指定标识的View控件对象 + * 如果存在多个指定id标识的View对象,则返回第一个创建的View控件对象。 + * 如果不存在指定id标识的View对象,则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + getViewById(id?: string): PlusNativeObjView; + /** + * 添加事件监听器 + * 向View控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 可多次调用此方法向Webview添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 + * 可通过setTouchEventRect方法指定监听触屏操作的区域。 + * 注意:默认View控件拦截处理触屏事件,可调用view.interceptTouchEvent(false)改变为不拦截处理触屏事件(透传)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + addEventListener(event?: PlusNativeObjViewEvents, listener?: (result: any) => void, capture?: boolean): void; + /** + * View控件内容动画 + * 动画后可能会导致View控件显示内容改变,可通过调用restore方法恢复。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + animate(options?: PlusNativeObjViewAnimationOptions, callback?: () => void): void; + /** + * 关闭View控件 + * 释放View控件资源,View对象不可再操作,如果View控件已经显示则自动隐藏。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + close(): void; + /** + * 清空矩形区域 + * 清除指定矩形区域内容,透明显示其后面的内容。 + * 可多次调用设置多个区域透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + clearRect(position?: PlusNativeObjPosition, id?: string): void; + /** + * 绘制内容 + * 在当前View控件之上绘制指定的内容,可一次指定绘制多个元素,绘制元素可以是图片/矩形区域/文本, + * 即将多次调用drawBitmap/drawRect/drawText方法合并调用一次draw方法来实现, + * 推荐使用draw方法来替换多次调用drawBitmap/drawRect/drawText。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + draw(tags?: PlusNativeObj []): void; + /** + * 绘制图片 + * 在当前View控件之上绘制指定的图片,如果图片无效则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + drawBitmap(src?: string, sprite?: PlusNativeObjPosition, position?: PlusNativeObjPosition, id?: string): void; + /** + * 绘制矩形区域 + * 在当前View控件之上绘制指定颜色的矩形区域。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + drawRect(styles?: PlusNativeObjRectStyles, position?: PlusNativeObjPosition, id?: string): void; + /** + * 绘制文本 + * 在当前View控件之上绘制指定的文本内容,如果文本为空则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + drawText(text?: string, position?: PlusNativeObjPosition, styles?: PlusNativeObjTextStyles, id?: string): void; + /** + * 绘制富文本 + * 在当前View控件之上绘制指定的文本内容,如果文本为空则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + drawRichText(text?: string, position?: PlusNativeObjPosition, styles?: PlusNativeObjRichTextStyles, id?: string): void; + /** + * 绘制输入框 + * 在当前View控件之上绘制输入框。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + drawInput(position?: PlusNativeObjPosition, styles?: PlusNativeObjInputStyles, id?: string): void; + /** + * 获取编辑框的焦点状态 + * 通过id查找到指定的编辑框,获取其焦点状态。 + * 如果指定的id无效则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + getInputFocusById(id?: string): boolean; + /** + * 获取编辑框的内容 + * 通过id查找到指定的编辑框,获取其输入的字符串。 + * 如果指定的id无效则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + getInputValueById(id?: string): string; + /** + * 重置view控件显示内容 + * 清除调用drawBitmap、drawText方法绘制的内容,将View控件重置为空内容(透明不可见)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + reset(): void; + /** + * 恢复View控件显示内容 + * 恢复调用animate方法改变View控件的内容,更新至动画前的内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + restore(): void; + /** + * 显示View控件 + * 将View控件显示到屏幕,显示在所有Webview窗口之上。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + show(): void; + /** + * 设置编辑框的焦点状态 + * 通过id查找到指定的编辑框,并设置编辑框的焦点状态。 + * 如果指定的id无效则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + setInputFocusById(id?: string, focusable?: boolean): string; + /** + * 设置View控件的样式 + * 动态更新View控件样式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + setStyle(styles?: PlusNativeObjViewStyles): void; + /** + * 指定监听触屏事件区域 + * 当调用addEventListener监听View控件事件时,可调用此方法限定监听事件的区域,仅当用户触屏操作在指定区域时才触发监听事件。 + * 非限定监听事件的区域则不拦截,透传给其它窗口处理。 + * 注意:此操作覆盖之前设置的区域。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + setTouchEventRect(rect?: PlusNativeObj []): void; + /** + * 隐藏View控件 + * 将View控件从屏幕隐藏,如果View控件未显示则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + hide(): void; + /** + * 是否拦截View控件的触屏事件 + * 设置为拦截后View控件上的触屏事件不再传递(即不透传),否则触屏事件将继续传递给View控件下的其它窗口处理(即透传)。 + * 注意:View控件默认拦截触屏事件(不透传)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + interceptTouchEvent(intercept?: boolean): void; + /** + * 获取View控件的显示状态 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + isVisible(): boolean; +} + +/** + * View控件动画参数 + * 指定动画的类型、持续时间等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjViewAnimationOptions { + /** + * 动画类型 + * 可取值:"shrink" - 从上到下分块收缩清除窗口动画。 + * - shrink: 从上到下分块清除动画 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + type?: 'shrink'; + /** + * 动画持续时间 + * 单位为毫秒,默认值为200ms。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + duration?: number; + /** + * 动画帧数 + * 必须为大于0的整数,默认值为12。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + frames?: number; + /** + * 动画作用区域 + * 支持以下属性: + * top - 区域距离控件顶部的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的高度),默认值为'0px'; + * bottom - 区域距离控件底部的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的高度),默认值为'0px'; + * left - 区域距离控件左侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'; + * right - 区域距离控件右侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'。 + * 如“{top:'44px',bottom:'48px'}”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + region?: PlusNativeObjRect; +} + +/** + * View控件绘制元素参数 + * 指定绘制图片、矩形区域、文本内容等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjViewDrawTagStyles { + /** + * 绘制操作标识 + * 可通过view对象的drawBitmap/drawRect/drawText/clearRect方法进行更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + id?: string; + /** + * 绘制操作类型 + * 可取值: + * "img" - 绘制图片,与drawBitmap操作一致,此时id、src、position、sprite属性值有效; + * "rect" - 绘制矩形区域,与drawRect操作一致,此时id、color、position、rectStyles属性值有效; + * "font" - 绘制文本内容,与drawText操作一致,此时id、position、text、textStyles属性值有效; + * "richtext" - 绘制富文本内容,与drawRichText操作一致,此时id、position、text、richTextStyles属性值有效; + * "input" - 绘制输入框内容,此时id、position、inputStyles属性值有效。 + * - img: 绘制图片 + * - rect: 绘制矩形区域 + * - font: 绘制文本内容 + * - richtext: 绘制富文本内容 + * - input: 绘制输入框内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + tag?: 'img' | 'rect' | 'font' | 'richtext' | 'input'; + /** + * 矩形区域颜色 + * 不推荐使用(推荐使用rectStyles),可取值: + * "#RRGGBB"格式字符串,如红色为"#FF0000"。 + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 当tag属性值为"rect"时有效,用于指定矩形区域颜色,默认值为"#FFFFFF"(白色)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + color?: string; + /** + * 绘制输入框的样式 + * 当tag属性值为"input"时有效,用于指定绘制输入框的样式、大小位置等信息。, + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + inputStyles?: PlusNativeObjInputStyles; + /** + * 绘制内容区域 + * 当tag属性值为"img"时,用于指定绘制图片的目标区域; + * 当tag属性值为"rect"时,用于指定绘制的矩形区域; + * 当tag属性值为"font"时,用于指定绘制文本的目标区域,此时height属性值支持设置为"wrap_content",表示文本高度根据内容自动计算,此时通过top来定位文本绘制的起始位置。 + * 相对于View控件的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + position?: PlusNativeObjPosition; + /** + * 绘制区域的样式 + * 当tag属性值为"rect"时有效,用于指定绘制区域的样式、填充颜色、圆角大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + rectStyles?: PlusNativeObjRectStyles; + /** + * 绘制的图片资源 + * 当tag属性值为"img"时有效,可以是图片资源路径(字符串类型)或者图片对象(plus.nativeObj.Bitmap对象)。 + * src路径支持gif图片,但设置的图片路径文件使用".gif"后缀时则认为是gif图片,如"_www/loading.gif"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + src?: string; + /** + * 图片源的绘制区域 + * 当tag属性值为"img"时有效,用于指定图片源的绘制区域,相对于图片的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + sprite?: PlusNativeObjPosition; + /** + * 绘制的文本内容 + * 当tag属性值为"font"时有效,用于保存绘制的文本内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + text?: string; + /** + * 绘制文本的样式 + * 当tag属性值为"font"时有效,用于指定绘制文本内容的字体大小、字体颜色、字体类型等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + textStyles?: PlusNativeObjTextStyles; + /** + * 绘制富文本的样式 + * 当tag属性值为"richtext"时有效,用于指定绘制富文本内容的默认字体颜色、字体类型等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + richTextStyles?: PlusNativeObjRichTextStyles; +} + +/** + * View控件事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjViewEvents { + /** + * 双击事件 + * 双击屏幕时触发。 + * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + doubleclick?: string; + /** + * 点击事件 + * 当手指点击屏幕时触发。 + * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + click?: string; + /** + * 开始触屏事件 + * 当手指触摸屏幕时候触发。 + * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + touchstart?: string; + /** + * 触摸滑屏事件 + * 当手指在屏幕上滑动的时候连续地触发。 + * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + touchmove?: string; + /** + * 结束触屏事件 + * 当手指从屏幕上离开的时候触发。 + * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + touchend?: string; +} + +/** + * JSON对象,View控件的系统状态栏区域样式 + * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjViewStatusbarStyles { + /** + * 系统状态栏区域背景颜色 + * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景,默认值为应用manifest.json中plus->statusbar->background属性配置的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + background?: string; +} + +/** + * View控件样式 + * 包括位置、大小等信息等,其中位置信息相对于父容器控件进行计算。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ +interface PlusNativeObjViewStyles { + /** + * 区域背景颜色 + * 可取值: + * #RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 默认值为"#FFFFFF"(白色)。 "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 默认值为"#FFFFFF"(白色)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + backgroundColor?: string; + /** + * View控件垂直向上的偏移量 + * 现对于父容器底部的距离,可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父容器的高度,如果没有父容器则相对于屏幕高度。 + * 当设置了top和height值时,忽略此属性值; + * 未设置height值时,可通过top和bottom属性值来确定View控件的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + bottom?: string; + /** + * View控件的停靠方式 + * 仅当View控件添加到Webview窗口对象中并且position属性值设置为"dock"时才生效,此时View控件挤压Webview窗口的大小。 + * 可取值: + * "top",控件停靠则页面顶部; + * "bottom",控件停靠在页面底部; + * "right",控件停靠在页面右侧; + * "left",控件停靠在页面左侧。 + * 默认值为"top"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + dock?: string; + /** + * 区域的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父容器的高度,如果没有父容器则相对于屏幕高度; + * 内容自适应,如"wrap_content",根据内容计算控件的高度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + height?: string; + /** + * 区域左上角的水平偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父控件的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于父控件水平居中。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + left?: string; + /** + * View控件的不透明度 + * 取值范围为0-1,0为全透明,1为不透明,默认值为1,即不透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + opacity?: number; + /** + * View控件的排版方式 + * 仅当View控件添加到Webview窗口对象中时才生效。 + * 可取值: + * "static",View控件在页面中正常定位,如果页面存在滚动条则随窗口内容滚动; + * "absolute",Veiw控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动; + * "dock",View控件在页面中停靠,停靠的位置由dock属性值决定。 + * 默认值为"absolute"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + position?: string; + /** + * View控件的状态栏样式 + * 仅在应用设置为沉浸式状态栏样式下有效,设置此属性后将自动保留系统状态栏区域不被View控件占用(即View控件非沉浸式样式显示)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + statusbar?: PlusNativeObjViewStatusbarStyles; + /** + * View控件左上角的垂直偏移量 + * 可取值:像素值,如"100px";百分比,如"10%",相对于父控件的高度;自动计算,如"auto",根据height值自动计算,相对于父控件垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + top?: string; + /** + * 区域的宽度 + * 可取值:像素值,如"100px";百分比,如"10%",相对于父控件的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) + */ + width?: string; +} + +/** + * nativeUI管理系统原生界面,可用于弹出系统原生提示对话框窗口、时间日期选择对话框、等待对话框等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUI { + /** + * JSON对象,原生选择按钮框上按钮的样式参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + ActionButtonStyles?: PlusNativeUIActionButtonStyles; + /** + * JSON对象,原生选择按钮框的样式参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + ActionSheetStyles?: PlusNativeUIActionSheetStyles; + /** + * 确认对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + ConfirmOptions?: PlusNativeUIConfirmOptions; + /** + * JSON对象,图片预览的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + PreviewImageOptions?: PlusNativeUIPreviewImageOptions; + /** + * 日期选择对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + PickDateOption?: PlusNativeUIPickDateOption; + /** + * JSON对象,时间选择对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + PickTimeOption?: PlusNativeUIPickTimeOption; + /** + * 系统原生界面基类对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + NativeUIObj?: PlusNativeUINativeUIObj; + /** + * 系统等待对话框对象 + * 从NativeUIObj对象继承而来,通过plus.nativeUI.showWaiting方法创建时返回。 + * 用于控制系统样式等待对话框的操作,如关闭、设置标题内容等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + WaitingObj?: PlusNativeUIWaitingObj; + /** + * JSON对象,原生等待对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + WaitingOptions?: PlusNativeUIWaitingOptions; + /** + * JSON对象,原生等待对话框上loading图标自定义样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + WaitingLoadingOptions?: PlusNativeUIWaitingLoadingOptions; + /** + * JSON对象,系统提示消息框要设置的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + ToastOptions?: PlusNativeUIToastOptions; + /** + * 弹出系统选择按钮框 + * 从底部动画弹出系统样式选择按钮框,可设置选择框的标题、按钮文字等。 + * 弹出的提示框为非阻塞模式,用户点击选择框上的按钮后关闭,并通过actionsheetCallback回调函数通知用户选择的按钮。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + actionSheet(actionsheetStyle?: PlusNativeUIActionSheetStyles, actionsheetCallback?: (result: any) => void): PlusNativeUINativeUIObj; + /** + * 弹出系统提示对话框 + * 创建并显示系统样式提示对话框,可设置提示对话框的标题、内容、按钮文字等。 + * 弹出的提示对话框为非阻塞模式,用户点击提示对话框上的按钮后关闭,并通过alertCB回调函数通知对话框已关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + alert(message?: string, alertCB?: (result: any) => void, title?: string, buttonCapture?: string): void; + /** + * 弹出系统确认对话框 + * 创建并显示系统样式确认对话框,可设置确认对话框的标题、内容、按钮数目及其文字。 + * 弹出的确认对话框为非阻塞模式,用户点击确认对话框上的按钮后关闭,并通过confirmCB回调函数通知用户点击的按钮索引值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + confirm(message?: string, confirmCB?: (result: any) => void, options?: PlusNativeUIConfirmOptions, buttons?: any []): void; + /** + * 关闭系统等待对话框 + * 关闭已经显示的所有系统样式等待对话框,触发Waiting对象的onclose事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + closeWaiting(): void; + /** + * 关闭自动消失的提示消息 + * 关闭已经显示的所有自动消失的提示框。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + closeToast(): void; + /** + * 预览图片 + * 创建并显示全屏图片预览界面,用户点击图片或返回键退出预览界面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + previewImage(urls?: any [], options?: PlusNativeUIPreviewImageOptions): void; + /** + * 显示系统等待对话框 + * 创建并显示系统样式等待对话框,并返回等待对话框对象Waiting,显示后需调用其close方法进行关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + showWaiting(title?: string, options?: PlusNativeUIWaitingOptions): PlusNativeUIWaitingObj; + /** + * 弹出系统日期选择对话框 + * 创建并显示系统样式日期选择对话框,可进行日期的选择。 + * 用户操作确认后通过successCB回调函数返回用户选择的日期,若用户取消选择则通过errorCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + pickDate(successCB?: (result: any) => void, errorCB?: (result: any) => void, options?: PlusNativeUIPickDateOption): void; + /** + * 弹出系统时间选择对话框 + * 创建并弹出系统样式时间选择对话框,可进行时间的选择。 + * 用户操作确认后通过successCB回调函数返回用户选择的时间,若用户取消选择则通过errorCB回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + pickTime(successCB?: (result: any) => void, errorCB?: (result: any) => void, options?: PlusNativeUIPickTimeOption): void; + /** + * 弹出系统输入对话框 + * 创建并显示系统样式输入对话框,可设置输入对话框的标题、内容、提示输入信息、按钮数目及其文字。 + * 弹出的输入对话框为非阻塞模式,其中包含编辑框供用户输入内容,用户点击输入对话框上的按钮后自动关闭,并通过promptCB回调函数返回用户点击的按钮及输入的内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + prompt(message?: string, promptCB?: (result: any) => void, title?: string, tip?: string, buttons?: any []): void; + /** + * 显示自动消失的提示消息 + * 创建并显示系统样式提示消息,弹出的提示消息为非阻塞模式,显示指定时间后自动消失。 + * 提示消息显示时间可通过options的duration属性控制,长时间提示消息显示时间约为3.5s,短时间提示消息显示时间约为2s。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + toast(message?: string, options?: PlusNativeUIToastOptions): void; +} + +/** + * JSON对象,原生选择按钮框上按钮的样式参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIActionButtonStyles { + /** + * 按钮上显示的文字颜色 + * 可取值: + * "#RRGGBB"格式字符串,如"#FF0000"表示文字颜色为红色; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + color?: string; + /** + * 按钮上显示的文字内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + title?: string; + /** + * 按钮的样式 + * 可取值: + * "destructive" - 表示警示按钮样式,默认文字颜色为红色; + * "default" - 表示默认按钮样式。 + * 默认值为"default"。 + * - destructive: + * 警示按钮样式。 + * + * - default: + * 默认按钮样式。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + style?: 'destructive' | 'default'; +} + +/** + * JSON对象,原生选择按钮框的样式参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIActionSheetStyles { + /** + * 选择按钮框的标题 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + title?: string; + /** + * 取消按钮上显示的文字内容 + * 不设置此属性,则不显示取消按钮。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + cancel?: string; + /** + * 选择框上的按钮,ActionButtonStyles对象数组 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + buttons?: PlusNativeUI []; +} + +/** + * 确认对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIConfirmOptions { + /** + * 确认对话框显示的标题 + * 如果不设置此属性值,则不显示标题。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + title?: string; + /** + * 确认对话框上显示的按钮 + * 字符串数组,每项对应在确认对话框上显示一个按钮,用户点击后通过confirmCB返回用户点击按钮的在数组中的索引值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + buttons?: any []; + /** + * 对话框在屏幕中的垂直分享对齐方式 + * 可取值: + * "top" - 表示垂直居顶对齐; + * "center" - 表示垂直居中对齐; + * "bottom" - 表示垂直居底对齐。 + * 默认值为"center"(垂直居中对齐)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + verticalAlign?: string; +} + +/** + * JSON对象,图片预览的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIPreviewImageOptions { + /** + * 图片预览的背景颜色 + * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景。 + * 默认值为黑色("#000000")。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + background?: string; + /** + * 默认显示图片的索引值 + * 索引值从0开始,默认值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + current?: number; + /** + * 图片指示器样式 + * 可取值: + * "default" - 默认指示器(底部圆点样式); + * "number" - 顶部数字指示器(顶部居中显示,文字为%当前图片索引值(从1开始)%/%图片总数%); + * "none" - 不显示指示器。 + * 默认值为"default"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + indicator?: string; + /** + * 是否可循环预览 + * 可取值: + * "true" - 支持循环预览; + * "false" - 不支持循环预览。 + * 默认值为"false"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + loop?: boolean; +} + +/** + * 日期选择对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIPickDateOption { + /** + * 日期选择对话框显示的标题 + * 如果未设置标题,则默认显示标题为当前选择的日期。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + title?: string; + /** + * 日期选择对话框默认显示的日期 + * 如果未设置默认显示的日期,则显示当前的日期。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + date?: Date; + /** + * 日期选择对话框可选择的最小日期 + * Date类型对象,如果未设置可选择的最小日期,则使用系统默认可选择的最小日期值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + minDate?: Date; + /** + * 日期选择对话框可选择的最大日期 + * Date类型对象,如果未设置可选择的最大日期,则使用系统默认可选择的最大日期值。 + * 其值必须大于minDate设置的值,否则使用系统默认可选择的最大日期值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + maxDate?: Date; + /** + * 时间选择对话框弹出指示区域 + * JSON类型对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,其值为相对于容器Webview的位置。 + * 如未设置此值,默认在屏幕居中显示。仅在iPad上有效,其它设备忽略此值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + popover?: any; +} + +/** + * JSON对象,时间选择对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIPickTimeOption { + /** + * 时间选择对话框默认显示的时间 + * 如果未设置标题,则默认显示标题为当前选择的时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + time?: Date; + /** + * 时间选择对话框显示的标题 + * 如果未设置标题,则默认显示标题为当前选择的时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + title?: string; + /** + * 是否24小时制模式 + * true表示使用24小时制模式显示,fale表示使用12小时制模式显示,默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + is24Hour?: boolean; + /** + * 日期选择对话框弹出指示区域 + * JSON类型对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,其值相对于容器webview的位置。 + * 如未设置此值,默认在屏幕居中显示。仅在iPad上有效,其它设备忽略此值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + popover?: any; +} + +/** + * 系统原生界面基类对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUINativeUIObj { + /** + * 关闭显示的系统原生界面 + * 调用plus.nativeUI.actionSheet方法创建并显示系统界面后,可通过其close方法将原生界面关闭。 + * 此情况下触发界面关闭回调函数参数的index属性值为-1。 + * 注意:一个系统原生界面只能关闭一次,多次调用将无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + close(): void; +} + +/** + * 系统等待对话框对象 + * 从NativeUIObj对象继承而来,通过plus.nativeUI.showWaiting方法创建时返回。 + * 用于控制系统样式等待对话框的操作,如关闭、设置标题内容等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIWaitingObj { + /** + * 等待对话框关闭事件 + * 等待框关闭时触发,当调用close方法或用户点击返回按钮导致等待框关闭时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + onclose?: () => void; + /** + * 设置等待对话框上显示的文字内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + setTitle(title?: string): void; + /** + * 关闭显示的系统等待对话框 + * 调用plus.nativeUI.showWaiting方法创建并显示系统等待界后,可通过其close方法将原生等待控件关闭。 + * 一个系统等待对话框只能关闭一次,多次调用将无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + close(): void; +} + +/** + * JSON对象,原生等待对话框的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIWaitingOptions { + /** + * 等待框背景区域的宽度 + * 值支持像素值("500px")或百分比("50%"),百分比相对于屏幕的宽计算,如果不设置则根据内容自动计算合适的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + width?: string; + /** + * 等待框背景区域的高度 + * 值支持像素绝对值("500px")或百分比("50%"),如果不设置则根据内容自动计算合适的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + height?: string; + /** + * 等待框中文字的颜色 + * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为白色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + color?: string; + /** + * 等待框中文字的字体大小 + * 如"14px"表示使用14像素高的文字,未设置则使用系统默认字体大小。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + size?: string; + /** + * 等待对话框中标题文字的水平对齐方式 + * 对齐方式可选值包括:"left":水平居左对齐显示,"center":水平居中对齐显示,"right":水平居右对齐显示。默认值为水平居中对齐显示,即"center"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + textalign?: string; + /** + * 等待对话框的内边距 + * 值支持像素值("10px")和百分比("5%"),百分比相对于屏幕的宽计算,默认值为"3%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + padding?: string; + /** + * 等待对话框显示区域的背景色 + * 背景色的值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为rgba(0,0,0,0.8)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + background?: string; + /** + * 等待对话框样式 + * 可取值"black"、"white",black表示等待框为黑色雪花样式,通常在背景主色为浅色时使用;white表示等待框为白色雪花样式,通常在背景主色为深色时使用。 + * 仅在iOS平台有效,其它平台忽略此值,未设置时默认值为white。 + * - black: 黑色雪花样式,适合浅色界面使用 + * - white: 白色雪花样式,适合深色界面使用 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + style?: 'black' | 'white'; + /** + * 等待框是否模态显示 + * 模态显示时用户不可操作直到等待对话框关闭,否则用户在等待对话框显示时也可操作下面的内容,未设置时默认为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + modal?: boolean; + /** + * 等待框显示区域的圆角 + * 值支持像素值("10px"),未设置时使用默认值"10px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + round?: number; + /** + * 点击等待显示区域是否自动关闭 + * true表示点击等待对话框显示区域时自动关闭,false则不关闭,未设置时默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + padlock?: boolean; + /** + * 返回键处理方式 + * 可取值"none"表示截获处理返回键,但不做任何响应;"close"表示截获处理返回键并关闭等待框;"transmit"表示不截获返回键,向后传递给Webview窗口继续处理(与未显示等待框的情况一致)。 + * - none: 截获返回键,不做任何响应 + * - close: 截获返回键并关闭等待框 + * - transmit: 不截获返回键,继续传递给Webview窗口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + back?: 'none' | 'close' | 'transmit'; + /** + * 自定义等待框上loading图标样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + loading?: PlusNativeUIWaitingLoadingOptions; +} + +/** + * JSON对象,原生等待对话框上loading图标自定义样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIWaitingLoadingOptions { + /** + * loading图标显示样式 + * 可取值: + * "block"表示图标与文字分开两行显示,上面显示loading图标,下面显示文字; + * "inline"表示loading图标与文字在同一行显示,左边显示loading图标,右边显示文字; + * "none"表示不显示loading图标; + * - block: + * loading图标与文字分开两行显示,上面显示loading图标,下面显示文字。 + * + * - inline: + * loading图标与文字在同一行显示,左边显示loading图标,右边显示文字。 + * + * - none: + * 不显示loading图标。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + display?: 'block' | 'inline' | 'none'; + /** + * loading图标高度 + * 设置loading图标的高度(宽度等比率缩放),取值类型:像素值,如"14px"表示14像素高。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + height?: string; + /** + * loading图标路径 + * 自定义loading图标的路径,png格式,并且必须是本地资源地址; + * loading图要求宽是高的整数倍,显示等待框时按照图片的高横向截取每帧刷新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + icon?: string; + /** + * loading图每帧刷新间隔 + * 单位为ms(毫秒),默认值为100ms。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + interval?: number; +} + +/** + * JSON对象,系统提示消息框要设置的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ +interface PlusNativeUIToastOptions { + /** + * 提示消息框在屏幕中的水平位置 + * 可选值为"left"、"center"、"right",分别为水平居左、居中、居右,未设置时默认值为"center"。 + * - left: 水平居左对齐 + * - center: 水平居中对齐 + * - right: 水平居左对齐 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + align?: 'left' | 'center' | 'right'; + /** + * 提示消息框显示的时间 + * 可选值为"long"、"short",值为"long"时显示时间约为3.5s,值为"short"时显示时间约为2s,未设置时默认值为"short"。 + * - long: 长显示时间 + * - short: 短显示时间 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + duration?: 'long' | 'short'; + /** + * 提示消息框上显示的图标 + * 仅支持本地图片路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + icon?: string; + /** + * 图标的宽度 + * 单位为px(逻辑像素值),默认值为图片的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + iconWidth?: string; + /** + * 图标的高度 + * 单位为px(逻辑像素值),默认值为图片的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + iconHeight?: string; + /** + * 提示消息框上显示的样式 + * 可取值: + * "block"表示图标与文字分两行显示,上面显示图标,下面显示文字; + * "inline"表示图标与文字在同一行显示,左边显示图标,右边显示文字。 + * 默认值为"block"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + style?: string; + /** + * 提示消息框上显示的文本类型 + * 可取值: + * "text" - 显示的消息内容为文本字符串; + * "richtext" - 显示的消息内容为富文本内容。 + * 默认值为"text"。 + * 当type为"text"时,富文本使用html的部分标签,具体标签如下: + * 图片标签<img src="图片资源url地址" width="图片显示的宽度" height="图片显示的高度" onclick="console.log('clicked img')"></img>; + * 字体标签<font color="字体颜色"></font>,内容在一行显示不下时自动换行,行高默认为字体的1.2倍; + * 换行标签<br/>; + * 链接标签<a onclick="console.log('clicked a')">链接地址</a>。 + * 如示例“<img onclick="console.log('clicked img')" src="http://img-cdn-qiniu.dcloud.net.cn/icon2.png"/><a onclick="console.log(clicked a)">链接地址</a>”。 + * - text: 文本字符串 + * - richtext: 富文本内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + type?: 'text' | 'richtext'; + /** + * 富文本样式 + * 当type属性值为"richtext"时有效,用于定义富文本的样式,如其文本对齐方式、使用的字体等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + richTextStyle?: PlusNativeObjRichTextStyles; + /** + * 提示消息在屏幕中的垂直位置 + * 可选值为"top"、"center"、"bottom",分别为垂直居顶、居中、居底,未设置时默认值为"bottom"。 + * - top: 垂直居顶对齐 + * - center: 垂直居中对齐 + * - bottom: 垂直居底对齐 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) + */ + verticalAlign?: 'top' | 'center' | 'bottom'; +} + +/** + * navigator用于管理浏览器运行环境信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ +interface PlusNavigator { + /** + * 创建应用快捷方式要设置的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + ShortcutOptions?: PlusNavigatorShortcutOptions; + /** + * 更新应用启动界面要设置的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + SplashscreenOptions?: PlusNavigatorSplashscreenOptions; + /** + * 运行环境权限类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + PermissionNames?: PlusNavigatorPermissionNames; + /** + * 检查运行环境的权限 + * 向系统检查当前程序的权限状态,不触发权限相对应的功能API的调用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + checkPermission(permission?: PlusNavigatorPermissionNames): string; + /** + * 关闭应用启动界面 + * 很多情况下,应用启动后需要一段时间加载数据,为了避免界面显示空白内容,提高用户体验效果,这时可显示启动界面。 + * 等数据加载完成后再关闭启动界面进入应用,通常可在应用首界面加载数据完成并更新显示内容后调用此方法。 + * 注意:HBuilder7.1版本后启动界面不调用此方法超过6秒后会自动关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + closeSplashscreen(): void; + /** + * 查询设备是否为刘海屏 + * 刘海屏返回true,否则返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + hasNotchInScreen(): boolean; + /** + * 查询应用启动界面是否已关闭 + * 如果启动界面显示返回true,否则返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + hasSplashscreen(): boolean; + /** + * 更新程序启动界面 + * 可设置启动界面显示的图片(仅支持本地文件路径,如果是网络资源可先通过plus.downloader.*下载到本地), + * 更新启动界面后程序下次启动时生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + updateSplashscreen(options?: PlusNavigatorSplashscreenOptions): void; + /** + * 创建应用快捷方式 + * 在系统桌面创建应用的快捷方式,点击后可直接启动应用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + createShortcut(options?: PlusNavigatorShortcutOptions, successCallback?: (result: any) => void): void; + /** + * 查询是否存在应用快捷方式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + hasShortcut(options?: PlusNavigatorShortcutOptions, successCallback?: (result: any) => void): void; + /** + * 判断当前应用是否切换到后台 + * 在多应用运行环境(如流应用)中,启动一个新应用时,之前运行的应用将会自动切换到后台运行,此时plus.navigator.isBackground()返回状态只为true。 + * 注意:此状态不是5+应用切换到系统后台的状态,而是在同一apk中同时运行多个应用时被切换到后台的状态。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + isBackground(): boolean; + /** + * 判断应用当前是否全屏模式显示 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + isFullscreen(): boolean; + /** + * 判断应用当前是否输出日志 + * 日志包括应用原生层内部跟踪日志(ADB、LogCat工具可获取的日志)及JS层跟踪日志(console.log输出的日志)。 + * 开启日志在一定程度上会降低程序的性能,通常建议在正式发布时关闭日志输出,在调试时开启日志输出(此时可以通过工具ADB、LogCat获取分析日志)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + isLogs(): boolean; + /** + * 设置应用是否全屏显示 + * 设置应用在全屏模式显示时,将隐藏系统状态栏,通常游戏类应用才会设置为全屏模式显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + setFullscreen(fullscreen?: boolean): void; + /** + * 设置应用是否输出日志 + * 设置应用是否输出日志信息,默认关闭输出日志功能。 + * 日志包括应用原生层内部跟踪日志(ADB、LogCat工具可获取的日志)及JS层跟踪日志(console.log输出的日志)。 + * 开启日志在一定程度上会降低程序的性能,通常建议在正式发布时关闭日志输出,在调试时开启日志输出(此时可以通过工具ADB、LogCat获取分析日志)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + setLogs(log?: boolean): void; + /** + * 设置系统状态栏背景颜色 + * 设置应用在前台运行时系统状态栏的背景颜色,默认使用系统状态栏默认背景色(有系统状态栏样式决定)。 + * 注意:为了有更好的兼容性,避免设置接近白色或黑色的颜色值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + setStatusBarBackground(color?: string): void; + /** + * 获取系统状态栏背景颜色 + * 获取应用在前台运行时系统状态栏的背景颜色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + getStatusBarBackground(): string; + /** + * 设置系统状态栏样式 + * 设置应用在前台运行时系统状态栏的样式,默认值可通过manifest.json文件的plus->statusbar->style配置。 + * 注意:此操作是应用全局配置,调用的Webview窗口关闭后仍然生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + setStatusBarStyle(style?: string): void; + /** + * 获取系统状态栏样式 + * 获取应用运行时系统状态栏的样式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + getStatusBarStyle(): string; + /** + * 获取系统状态栏高度 + * 单位为像素(px),值为Webview中的逻辑高度单位,如果要获取真实高度则必须乘以plus.screen.scale。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + getStatusbarHeight(): number; + /** + * 判断当前是否为沉浸式状态栏模式 + * 如果当前应用采用沉浸式状态栏则返回true,否则返回false。 + * 注意:如果当前系统版本不支持沉浸式状态栏也返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + isImmersedStatusbar(): boolean; + /** + * 设置userAgent值 + * 设置应用通过navigator.userAgent获取的值,及所有发起Http请求时提交的userAgent值。 + * 如果要设置启动页面的userAgent值则需要在manifest.json中进行配置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + setUserAgent(useragent?: string, checkplus?: boolean): void; + /** + * 获取userAgent值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + getUserAgent(): string; + /** + * 设置Cookie值 + * 设置应用发起Http请求时提交的cookie值,调用此接口后所有的请求都生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + setCookie(url?: string, value?: string): void; + /** + * 获取Cookie值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + getCookie(url?: string): string; + /** + * 删除应用所有Cookie值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + removeAllCookie(): void; + /** + * 删除应用Cookie + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + removeCookie(url?: string): void; + /** + * 删除应用所有会话期Cookie值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + removeSessionCookie(): void; +} + +/** + * 创建应用快捷方式要设置的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ +interface PlusNavigatorShortcutOptions { + /** + * 快捷方式名称 + * 如果未设置则使用应用的名称,manifest.json中name属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + name?: string; + /** + * 快捷方式的图标 + * 如果未设置则优先使用应用中指定的图标(manifest.json中icon节点下对应分辨率的图标),如未区配则使用应用的图标(仅在独立打包时),否则使用runtime提供的默认图标。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + icon?: string; + /** + * 创建快捷方式后的提示信息 + * 快捷方式创建成功后显示,默认提示内容为“"XXXX"已创建桌面快捷方式”,其中"XXXX"为程序的名称,如果不需要提示则设置此值为空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + toast?: string; + /** + * 快捷方式的扩展参数 + * 其中key和value值都必须是字符串类型。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + extra?: any; + /** + * 要启动Activity类名 + * 通常情况下不需要指定此值,仅在5+SDK集成时自定义Activity才用到。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + classname?: string; + /** + * 是否需要强制创建快捷方式 + * true表示强制创建,false表示不强制创建,默认值为true。 + * 强制创建可能会导致在无法判断快捷方式是否存在的设备上重复创建,如果需要尽可能避免出现重复创建桌面快捷方式则应该设置force属性值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + force?: boolean; +} + +/** + * 更新应用启动界面要设置的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ +interface PlusNavigatorSplashscreenOptions { + /** + * 启动界面的图片路径 + * 仅支持本地文件路径,图片必须为png格式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + image?: string; + /** + * 是否自动关闭启动界面 + * true表示应用启动后自动关闭启动界面,false表示应用启动后不自动关闭启动界面,需要在应用调用plus.navigator.closeSplashscreen()方法关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + autoclose?: boolean; + /** + * 是否自动关闭启动界面(WAP2APP应用) + * 与autoclose属性值作用一致,仅在WAP2APP应用中有效。 + * 不推荐设置此值,如果未设置会自动使用autoclose属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + autoclose_w2a?: boolean; + /** + * 启动界面延时关闭时间 + * 仅在设置为自动关闭启动界面时有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + delay?: number; + /** + * 启动界面延时关闭时间(WAP2APP应用) + * 与delay属性值作用一致,仅在WAP2APP应用中有效。 + * 不推荐设置此值,如果未设置会自动使用delay属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + delay_w2a?: number; +} + +/** + * 运行环境权限类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ +interface PlusNavigatorPermissionNames { + /** + * 访问摄像头权限 + * 用于调用摄像头(plus.camera.*、plus.barcode.*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + CAMERA?: string; + /** + * 访问系统联系人权限 + * 用于访问(读、写)系统通讯录(plus.gallery.*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + CONTACTS?: string; + /** + * 访问系统相册权限 + * 用于访问(读、写)系统相册(plus.gallery.*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + GALLERY?: string; + /** + * 定位权限 + * 用于获取当前用户位置信息(plus.geolocation.*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + LOCATION?: string; + /** + * 消息通知权限 + * 用于接收系统消息通知(plus.push.*)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + NOTIFITION?: string; + /** + * 录音权限 + * 用于进行本地录音操作(plus.audio.AudioRecorder)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + RECORD?: string; + /** + * 创建桌面快捷方式权限 + * 用于在系统桌面创建快捷方式图标(plus.navigator.createShortcut)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) + */ + SHORTCUT?: string; +} + +/** + * Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus.orientation可获取设备方向管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ +interface PlusOrientation { + /** + * JSON对象,监听设备方向感应器参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + OrientationOption?: PlusOrientationOrientationOption; + /** + * JSON对象,设备方向信息数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + Rotation?: PlusOrientationRotation; + /** + * 获取当前设备的方向信息,包括alpha、beta、gamma三个方向信息 + * 方向信息是设备相对于水平初始方向分别以z、x、y轴为轴心旋转的角度,对应值为alpha、beta、gamma三个方向的信息。 方向信息可通过successCB回调函数返回。方向信息获取失败则调用回调函数errorCB + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + getCurrentOrientation(successCB?: (result: string) => void, errorCB?: (result: any) => void): void; + /** + * 监听设备方向信息的变化 + * 方向信息是设备相对于水平初始方向分别以z、x、y轴为轴心旋转的角度,对应值为alpha、beta、gamma三个方向的信息。watchOrientation每隔固定时间就获取一次设备的方向信息,通过successCB回调函数返回。可通过option的frequency参数设定获取设备方向信息的时间间隔。方向信息获取失败则调用回调函数errorCB。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + watchOrientation(successCB?: (result: string) => void, errorCB?: (result: any) => void, option?: PlusOrientationOrientationOption): number; + /** + * 关闭监听设备方向信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + clearWatch(watchId?: number): void; +} + +/** + * JSON对象,监听设备方向感应器参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ +interface PlusOrientationOrientationOption { + /** + * 更新方向信息的时间间隔 + * 数值类型,单位为ms,默认值为500ms。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + frequency?: number; +} + +/** + * JSON对象,设备方向信息数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ +interface PlusOrientationRotation { + /** + * 以z方向为轴心的旋转角度 + * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + alpha?: number; + /** + * 以x方向为轴心的旋转角度 + * 浮点数类型,只读属性,取值范围为-180到180(不等于180)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + beta?: number; + /** + * 以y方向为轴心的旋转角度 + * 浮点数类型,只读属性,取值范围为-180到180(不等于180)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + gamma?: number; + /** + * 设备方向与地球磁场北极方向的角度 + * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + magneticHeading?: number; + /** + * 设备方向与地球真实北极方向的角度 + * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + trueHeading?: number; + /** + * 设备方向值的误差值 + * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) + */ + headingAccuracy?: number; +} + +/** + * Proximity模块管理设备距离传感器,可获取当前设备的接近距离信息,通过plus.proximity可获取设备距离传感管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) + */ +interface PlusProximity { + /** + * 获取当前设备的接近距离信息 + * 获取当前接近设备的距离信息,距离值单位为厘米。如果感应器无法获取准确的距离值,则在接近设备时返回0,否则返回Infinity。 获取成功则调用successCB回调函数返接近回距离值。获取失败则调用errorCB回调函数错误信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) + */ + getCurrentProximity(successCB?: (result: number) => void, errorCB?: (result: any) => void): void; + /** + * 监听设备接近距离的变化 + * watchProximity将监听设备的接近距离信息变化事件,当接近距离发生变化时通过changeCB回调函数返回距离值。监听距离变化事件失败则通过errorCB回调函数返回错误信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) + */ + watchProximity(changeCB?: (result: number) => void, errorCB?: (result: any) => void): number; + /** + * 关闭监听设备接近距离变化 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) + */ + clearWatch(watchId?: number): void; +} + +/** + * Runtime模块管理运行环境,可用于获取当前运行环境信息、与其它程序进行通讯等。通过plus.runtime可获取运行环境管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ +interface PlusRuntime { + /** + * JSON对象,打开第三方程序参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + ApplicationInf?: PlusRuntimeApplicationInf; + /** + * JSON对象,应用角标显示需要的通知栏消息的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + BadgeOptions?: PlusRuntimeBadgeOptions; + /** + * JSON对象,打开文件参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + OpenFileOptions?: PlusRuntimeOpenFileOptions; + /** + * JSON对象,应用信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + WidgetInfo?: PlusRuntimeWidgetInfo; + /** + * JSON对象,应用安装参数 + * 可通过对象设置安装的应用是否进行appid校验、版本号校验等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + WidgetOptions?: PlusRuntimeWidgetOptions; + /** + * 当前应用的APPID + * 当前应用的APPID,字符串类型。注意,如果是在HBuilder真机运行获取的是固定值"HBuilder",需要提交App云端打包后运行才能获取真实的APPID值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + appid?: string; + /** + * 第三方程序调用时传递给程序的参数 + * 第三方程序传递过来的参数,字符串格式类型数据。 + * 不是由第三方程序调用启动,则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + arguments?: string; + /** + * 应用的市场推广渠道标识 + * "qihoo:browser"标识360浏览器流应用,"qihoo:appstore "表示360手机助手流应用,"dcloud:streamapps"表示DCloud流应用基座。 + * 注意:仅流应用环境中可用(如果没有特殊配置默认返回运行环境的包名),非流应用环境中返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + channel?: string; + /** + * 应用启动来源 + * 5+ APP启动类型,可取以下值: + * "default":默认启动方式,通常表示应用列表启动(360手助中搜索启动); + * "scheme":通过urlscheme方式触发启动; + * "push":通过点击系统通知方式触发启动; + * "stream":通过流应用api(plus.stream.open)启动; + * "shortcut":通过快捷方式启动,iOS平台表示通过3D Touch快捷方式,Android平台表示通过桌面快捷方式启动; + * "barcode":通过二维码扫描启动; + * "myapp":通过流应用"我的"应用列表或历史列表中触发启动; + * "favorite":通过流应用的"收藏"应用列表启动; + * "browser":通过流应用的内置浏览器导流启动的流应用(地址栏输入url启动应用、点击wap页面链接启动应用); + * "engines":通过流应用的浏览器界面作为搜索引擎启动; + * "search":通过流应用的应用搜索启动应用(如iOS平台的T9键盘搜索); + * "speech":通过流应用的语音识别启动应用; + * "miniProgram":通过微信小程序启动应用。 + * - default: + * 默认启动方式,通常表示从系统桌面图标启动 + * + * - scheme: + * 通过urlscheme方式触发启动 + * + * - push: + * 通过点击系统通知方式触发启动 + * + * - stream: + * 通过流应用api(plus.stream.open)启动 + * + * - shortcut: + * iOS平台表示通过3D Touch快捷方式,Android平台表示通过桌面快捷方式启动 + * + * - barcode: + * 通过二维码扫描启动 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + launcher?: 'default' | 'scheme' | 'push' | 'stream' | 'shortcut' | 'barcode'; + /** + * 应用安装来源 + * 5+应用安装来源,可取以下值: + * "default":默认安装来源,apk/ipa安装包内置安装; + * "stream":通过流应用api(plus.stream.open)安装,仅流应用环境下支持; + * "push":通过点击系统通知方式触发安装,仅流应用环境下支持; + * "scheme":通过urlscheme方式触发安装,仅流应用环境下支持; + * "barcode":通过二维码扫描触发安装,仅流应用环境下支持; + * "silent":通过后台静默方式安装,仅流应用环境下支持; + * "speech":通过语音识别方式触发安装,仅流应用环境下支持; + * "favorite":通过收藏界面启动触发安装,仅流应用环境下支持。 + * - default: + * 默认安装来源,apk/ipa安装包内置安装 + * + * - stream: + * 通过流应用api(plus.stream.open)安装 + * + * - push: + * 通过点击系统通知方式触发安装 + * + * - scheme: + * 通过urlscheme方式触发安装 + * + * - barcode: + * 通过二维码扫描触发安装 + * + * - silent: + * 通过后台静默方式安装 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + origin?: 'default' | 'stream' | 'push' | 'scheme' | 'barcode' | 'silent'; + /** + * 客户端的版本号 + * 字符串类型,在编译环境中设置的apk/ipa版本号。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + version?: string; + /** + * 客户端5+运行环境的版本号 + * 5+运行环境版本号,格式为:[主版本号].[次版本号].[修订版本号].[编译代号]。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + innerVersion?: string; + /** + * 获取当前应用首页加载的时间 + * 应用加载首页面的总时间,从开始加载首页面到首页面加载完成,单位为ms。 + * 注意,应用首页为网络地址则包括网络传输时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + launchLoadedTime?: number; + /** + * 获取当前应用的进程标识 + * 当前应用所属系统进程标识。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + processId?: string; + /** + * 获取当前应用的启动时间 + * 应用启动时间戳,距1970年1月1日之间的毫秒数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + startupTime?: number; + /** + * 获取指定APPID对应的应用信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + getProperty(appid?: string, getPropertyCB?: (result: PlusRuntimeWidgetInfo) => void): void; + /** + * 安装应用 + * 支持以下类型安装包: + * 1. 应用资源安装包(wgt),扩展名为'.wgt'; + * 2. 应用资源差量升级包(wgtu),扩展名为'.wgtu'; + * 3. 系统程序安装包(apk),要求使用当前平台支持的安装包格式。 + * 注意:仅支持本地地址,调用此方法前需把安装包从网络地址或其他位置放置到运行时环境可以访问的本地目录。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + install(filePath?: string, options?: PlusRuntimeWidgetOptions, installSuccessCB?: (result: PlusRuntimeWidgetInfo) => void, installErrorCB?: (result: any) => void): void; + /** + * 退出客户端程序 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + quit(): void; + /** + * 重启当前的应用 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + restart(): void; + /** + * 设置程序快捷方式图标上显示的角标数字 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + setBadgeNumber(number?: number, options?: PlusRuntimeBadgeOptions): void; + /** + * 调用第三方程序打开指定的URL + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + openURL(url?: string, errorCB?: (result: any) => void, identity?: string): void; + /** + * 使用内置Webview窗口打开URL + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + openWeb(url?: string): void; + /** + * 调用第三方程序打开指定的文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + openFile(filepath?: string, options?: PlusRuntimeOpenFileOptions, errorCB?: (result: any) => void): void; + /** + * 处理直达页面链接参数 + * 通过URL Scheme启动时,可以在?后面添加__direct_page参数自定义直达页面地址, + * 如“streamapp://m3w.cn/s/HelloH5?__direct_page=http%3a%2f%2fm.weibo.cn%2fu%2f3196963860”; + * 在流应用SDK集成时也可以通过direct_page参数(原生调用Intent)设置。 + * 注意:仅第一次调用此API时返回直达页面链接地址,再次调用将返回空字符串;如果应用重新被带直达页面链接参数的URL Scheme启动/激活时,可再次调用此方法获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + processDirectPage(): string; + /** + * 调用第三方程序 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + launchApplication(appInf?: PlusRuntimeApplicationInf, errorCB?: (result: any) => void): void; + /** + * 判断第三方程序是否已存在 + * 如果第三方程序已安装则返回true,未安装则返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + isApplicationExist(appInf?: PlusRuntimeApplicationInf): boolean; + /** + * 判断是否自定义应用启动页面加载地址 + * 通过URL Scheme启动时,可以在?后面添加__launch_path参数自定义应用启动首页加载的页面地址, + * 如“streamapp://m3w.cn/s/HelloH5?__launch_path=http%3a%2f%2fm.weibo.cn%2fu%2f3196963860”; + * 在流SDK集成时也可以通过launch_path参数(原生调用Intent)设置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + isCustomLaunchPath(): boolean; +} + +/** + * JSON对象,打开第三方程序参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ +interface PlusRuntimeApplicationInf { + /** + * 第三方程序包名 + * 仅Android平台支持,表示程序的包名,其它平台忽略此属性值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + pname?: string; + /** + * 程序的操作行为 + * Android平台上与系统的action值一致;iOS平台为要调用程序的URLScheme格式字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + action?: string; + /** + * 新任务模式标记 + * 可取值: + * true-使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用; + * false-不使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用。 + * 默认值为true。 + * 注意:由于5+应用配置的launchMode为singleTask,所以另一个5+应用通过plus.runtime.launchApplication启动时如果应用已经在后台运行则不会触发newintent事件,为了避免此问题需要将newTask参数值设置为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + newTask?: boolean; + /** + * 调用程序的参数 + * 仅Android平台支持,为JSON格式,用于传递给要调用程序的参数,如extra:{url:"http://www.html5plus.org"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + extra?: any; +} + +/** + * JSON对象,应用角标显示需要的通知栏消息的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ +interface PlusRuntimeBadgeOptions { + /** + * 消息的标题 + * 默认值为应用的名称。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + title?: string; + /** + * 消息的内容 + * 默认值为“您有x条未读消息"”,其中x未设置的角标数字值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + content?: string; +} + +/** + * JSON对象,打开文件参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ +interface PlusRuntimeOpenFileOptions { + /** + * 优先使用的程序包名 + * 如果指定包名的程序已经安装,则调用其打开文件,若程序不支持打开文件则触发错误回调。 + * 如果指定包名的程序未安装,则弹出系统支持打开此文件的列表,由用户选择程序打开。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + pname?: string; + /** + * 弹出系统选择程序界面指示区域 + * JSON对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,左上坐标相对于容器webview的位置。仅在iPad设备平台有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + popover?: any; +} + +/** + * JSON对象,应用信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ +interface PlusRuntimeWidgetInfo { + /** + * 应用的APPID + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + appid?: string; + /** + * 应用的版本号 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + version?: string; + /** + * 应用的名称 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + name?: string; + /** + * 应用描述信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + description?: string; + /** + * 应用描述信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + author?: string; + /** + * 开发者邮箱地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + email?: string; + /** + * 应用授权描述信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + license?: string; + /** + * 应用授权说明链接地址 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + licensehref?: string; + /** + * 应用许可特性列表 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + features?: string []; +} + +/** + * JSON对象,应用安装参数 + * 可通过对象设置安装的应用是否进行appid校验、版本号校验等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ +interface PlusRuntimeWidgetOptions { + /** + * 是否强制安装 + * true表示强制安装,不进行版本号的校验;false则需要版本号校验,如果将要安装应用的版本号不高于现有应用的版本号则终止安装,并返回安装失败。 + * 仅安装wgt和wgtu时生效,默认值 false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) + */ + force?: boolean; +} + +/** + * Storage模块管理应用本地数据存储区,用于应用数据的保存和读取。应用本地数据与localStorage、sessionStorage的区别在于数据有效域不同,前者可在应用内跨域操作,数据存储期是持久化的,并且没有容量限制。通过plus.storage可获取应用本地数据管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ +interface PlusStorage { + /** + * 获取应用存储区中保存的键值对的个数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + getLength(): number; + /** + * 通过键(key)检索获取应用存储的值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + getItem(key?: string): string; + /** + * 修改或添加键值(key-value)对数据到应用数据存储中 + * 如果设置的键在应用数据存储中已经存在,更新存储的键值。 + * 存储的键和值没有容量限制,但过多的数据量会导致效率降低,建议单个键值数据不要超过10Kb。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + setItem(key?: string, value?: string): void; + /** + * 通过key值删除键值对存储的数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + removeItem(key?: string): void; + /** + * 清除应用所有的键值对存储数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + clear(): void; + /** + * 获取键值对中指定索引值的key值 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) + */ + key(index?: number): void; +} + +/** + * Stream模块操作流应用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStream { + /** + * JSON对象,启动流应用参数 + * 指定要启动的流应用标识、名称、图标、参数等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + StreamOptions?: PlusStreamStreamOptions; + /** + * JSON对象,流应用恢复运行的参数 + * 设置流应用恢复运行时的参数、splash、首页等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + StreamRestoreOptions?: PlusStreamStreamRestoreOptions; + /** + * 流应用恢复运行时启动界面配置参数 + * 设置流应用恢复运行时启动界面,如是否自动关闭、延时关闭时间、超时时间等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + StreamRestoreSplashscreenOptions?: PlusStreamStreamRestoreSplashscreenOptions; + /** + * JSON对象,启动流应用的首页窗口属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + LaunchWebviewStyles?: PlusStreamLaunchWebviewStyles; + /** + * JSON对象,流应用信息 + * 流应用标识、图标、是否下载完成等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + StreamInfo?: PlusStreamStreamInfo; + /** + * JSON对象,免流量操作参数 + * 包含电话号码、验证码等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + FreetrafficOptions?: PlusStreamFreetrafficOptions; + /** + * 免流量状态变化事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + onfreetrafficStateChange?: any; + /** + * 启动流应用 + * 打开指定的流应用,在流应用中通过plus.runtime.launcher获取的值为"stream"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + open(options?: PlusStreamStreamOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 流应用激活统计 + * 提交统计数据到流应用服务器,表明业务系统激活成功。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + activate(): void; + /** + * 已下载流应用列表 + * 获取当前设备上已安装的所有流应用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + list(options?: any, successCallback?: any, errorCallback?: any): void; + /** + * 预加载流应用 + * 预加载指定的流应用资源,下载应用资源等,并不运行流应用。 + * 如果应用资源已经下载,则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + preload(appid?: string): void; + /** + * 删除流应用 + * 删除已下载的流应用,清空应用相关运行期保存的资源(如缓存、配置文件等)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + remove(appid?: string): void; + /** + * 设置流应用恢复运行的参数 + * 当流应用运行数目超过限制(通常最多运行2个流应用),会自动关闭之前切换到后台运行的应用。 + * 可通过此方法设置应用被自动关闭后再次被唤醒恢复运行时的参数,流应用恢复运行流程与第一次启动一致(差别是会使用StreamRestoreOptions中配置的参数)。 + * 如果没有调用setRestoreState方法,则恢复运行时使用启动时(调用plus.stream.open方法)传入的参数。 + * 注意:如果通过plus.stream.open方法启动应用,则忽略此方法设置的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + setRestoreState(options?: PlusStreamStreamRestoreOptions): void; + /** + * 请求免流量验证码 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + freetrafficRequest(options?: PlusStreamFreetrafficOptions, successCallback?: () => void, errorCallback?: (result: any) => void): void; + /** + * 免流量绑定手机号 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + freetrafficBind(options?: PlusStreamFreetrafficOptions, successCallback?: () => void, errorCallback?: (result: any) => void): void; + /** + * 解除免流量绑定 + * 解除当前设备绑定的手机号,如果设备未绑定则不执行操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + freetrafficRelease(): void; + /** + * 获取免流量状态信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + freetrafficInfo(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 免流量是否生效 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + freetrafficIsValid(): boolean; +} + +/** + * JSON对象,启动流应用参数 + * 指定要启动的流应用标识、名称、图标、参数等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStreamStreamOptions { + /** + * 流应用运行模式 + * 可取值:"test"表示测试版模式运行,其它值则为正式版本模式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + appmode?: string; + /** + * 流应用标识 + * 流应用唯一字符串标识。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + appid?: string; + /** + * 启动流应用的直达页面链接地址 + * 可在应用中通过plus.runtime.processDirectPage()方法获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + direct_page?: string; + /** + * 流应用运行参数 + * 启动流应用的扩展参数,可在流应用中通过plus.runtime.arguments获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + extras?: any; + /** + * 流应用图标 + * 流应用显示的图标路径(仅支持本地路径),在启动提示界面中显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + icon?: string; + /** + * 流应用启动类型 + * 流应用的启动类型,可在流应用中通过plus.runtime.launcher获取,默认值为“stream”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + launcher?: string; + /** + * 应用启动界面样式 + * 可取值: + * "auto":自动选择启动界面,如果splash图片已经下载则显示splash图片,否则使用默认加载流应用界面; + * "default":使用默认加载流应用界面(如在360浏览器环境中在标题栏下显示加载进度条)。 + * 默认值为"auto"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + splash?: string; + /** + * 流应用首页窗口对象样式 + * 如果流应用已经运行,从后台激活到前台时忽略此属性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + styles?: PlusStreamLaunchWebviewStyles; + /** + * 流应用名称 + * 流应用显示的标题,在启动提示界面中显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + title?: string; + /** + * 启动流应用的快捷方式逻辑 + * 可取值: + * "auto" - 检查并引导用户打开快捷方式权限,自动创建桌面快捷方式,在不支持快捷方式滤重的系统上仅创建一次; + * "force" - 检查并引导用户打开快捷方式权限,自动创建桌面快捷方式,在不支持快捷方式滤重的系统上每次都尝试创建; + * "none" - 不检查快捷方式权限,不创建桌面快捷方式(与从桌面快捷方式启动的流程一致); + * "query" - 弹出询问提示框(底部显示),用户点击确定后创建桌面快捷方式(检查并引导用户打开快捷方式权限); + * "tipOnce" - 业务逻辑与"auto"类似,差别是只会引导用户打开快捷方式权限一次、toast提示一次。 + * 默认值为"force"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + shortcut?: string; + /** + * 退出流应用的快捷方式逻辑 + * 可取值: + * "query" - 应用退出时检查是否创建桌面快捷方式,如果查询到没有创建则弹出询问框,用户点击确定后创建桌面快捷方式(检查并引导用户打开快捷方式权限); + * "queryOnce" - 仅应用第一次退出检查,检查逻辑同query; + * "none" - 应用退出时不检查是否创建桌面快捷方式。 + * 默认值为"none"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + shortcutQuit?: string; +} + +/** + * JSON对象,流应用恢复运行的参数 + * 设置流应用恢复运行时的参数、splash、首页等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStreamStreamRestoreOptions { + /** + * 流应用运行参数 + * 启动流应用的扩展参数,可在流应用中通过plus.runtime.arguments获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + extras?: any; + /** + * 应用启动界面样式 + * 可取值: + * "auto":自动选择启动界面,如果流应用自动关闭时截图成功则使用截图,如果splash图片已经下载则显示splash图片,否则使用默认加载流应用界面; + * "default":使用默认加载流应用界面(如在360浏览器环境中在标题栏下显示加载进度条)。 + * 默认值为"auto"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + splash?: string; + /** + * 流应用首页窗口对象样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + styles?: PlusStreamLaunchWebviewStyles; + /** + * 流应用恢复运行时启动界面配置参数 + * 用于流应用自动关闭后恢复运行时调整启动界面配置参数,如将自动关闭splash调整为手动关闭,以便恢复上次运行状态后再进入应用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + splashscreen?: PlusStreamStreamRestoreSplashscreenOptions; +} + +/** + * 流应用恢复运行时启动界面配置参数 + * 设置流应用恢复运行时启动界面,如是否自动关闭、延时关闭时间、超时时间等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStreamStreamRestoreSplashscreenOptions { + /** + * 是否自动关闭启动界面 + * true表示应用启动后自动关闭启动界面,false表示应用启动后不自动关闭启动界面,需要在应用调用plus.navigator.closeSplashscreen()方法关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + autoclose?: boolean; + /** + * 启动界面超时时间 + * 单位为毫秒(ms),当启动界面超过此时间仍然未关闭时(不管autoclose值设置true还是false),应用将自动关闭启动界面。 + * 默认值为6000(即6秒)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + timeout?: number; +} + +/** + * JSON对象,启动流应用的首页窗口属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStreamLaunchWebviewStyles { + /** + * 流应用首页是否阻塞网络图片的加载 + * true表示阻塞网络图片的加载,false表示不阻塞网络图片的加载。默认值为false。 + * 设置后可通过Webview窗口对象的setBlockNetworkImage(false)方法修改设置来继续加载网络图片。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + blockNetworkImage?: boolean; + /** + * 指定流应用首页地址 + * 可使用网络地址(http://或https://开头),也可使用本地地址(相对应用资源路径)。 + * 也可使用特定地址: + * about:blank - 使用空白首页,仅加载内置注入的脚本(如all.js、wap2app.js、config.js等)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + launch_path?: string; + /** + * 指定首页Webview的id + * 如果未指定id,则使用应用的appid作为首页Webview的id。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + id?: string; + /** + * 流应用首页是否显示 + * true表示显示,false表示不显示。默认值为true。 + * 注意:流应用首页隐藏后,需要调用首页的setVisible方法显示,如plus.webview.getLaunchWebview().setVisible(true)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + visible?: boolean; +} + +/** + * JSON对象,流应用信息 + * 流应用标识、图标、是否下载完成等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStreamStreamInfo { + /** + * 流应用标识 + * 流应用唯一字符串标识。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + id?: string; + /** + * 流应用的图标 + * 流应用下载的图标路径(本地路径),如果未下载完成则返回空。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + icon?: string; + /** + * 流应用是否下载完成 + * true表示流应用下载完成,false表示流应用未下载完成。 + * 注意,流应用未下载完成以让可以正常启动运行,启动后会自动下载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + complete?: boolean; +} + +/** + * JSON对象,免流量操作参数 + * 包含电话号码、验证码等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ +interface PlusStreamFreetrafficOptions { + /** + * 电话号码 + * 免流量请求验证码、绑定设备使用的电话号码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + phone?: string; + /** + * 验证码 + * 免流量绑定设备使用的验证码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) + */ + code?: string; +} + +/** + * Uploader模块管理网络上传任务,用于从本地上传各种文件到服务器,并支持跨域访问操作。通过plus.uploader可获取上传管理对象。Uploader上传使用HTTP的POST方式提交数据,数据格式符合Multipart/form-data规范,即rfc1867(Form-based File Upload in HTML)协议。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ +interface PlusUploader { + /** + * Upload对象管理一个上传任务 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + Upload?: PlusUploaderUpload; + /** + * 上传任务事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + UploadEvent?: PlusUploaderUploadEvent; + /** + * 上传任务的状态,Number类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + UploadState?: PlusUploaderUploadState; + /** + * JSON对象,创建上传任务的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + UploadOptions?: PlusUploaderUploadOptions; + /** + * JSON对象,添加上传文件的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + UploadFileOptions?: PlusUploaderUploadFileOptions; + /** + * 新建上传任务 + * 请求上传管理创建新的上传任务,创建成功则返回Upload对象,用于管理上传任务。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + createUpload(url?: string, options?: PlusUploaderUploadOptions, completedCB?: (result0: PlusUploaderUpload, result1: number) => void): PlusUploaderUpload; + /** + * 枚举上传任务 + * 枚举指定状态的上传任务列表,通过enumCB回调函数返回结果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + enumerate(enumCB?: (result: PlusUploader []) => void, state?: PlusUploaderUploadState): void; + /** + * 清除上传任务 + * 清除指定状态的上传任务。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + clear(state?: PlusUploaderUploadState): void; + /** + * 开始所有上传任务 + * 开始所有处于未开始调度或暂停状态的上传任务。 + * 若上传任务数超过可并发处理的总数,超出的任务处于调度状态(等待上传),当有任务完成时根据调度状态任务的优先级选择任务开始上传。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + startAll(): void; +} + +/** + * Upload对象管理一个上传任务 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ +interface PlusUploaderUpload { + /** + * 上传任务的标识 + * 在创建任务时系统自动分配,用于标识上传任务的唯一性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + id?: string; + /** + * 上传文件的服务器地址 + * 调用plus.uploader.createUpload()方法创建上传任务时设置的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + url?: string; + /** + * 任务的状态 + * 上传任务的状态,参考UploadState,在UploadCompleteCallback事件和UploadStateChangedCallback事件触发时更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + state?: number; + /** + * 上传任务的参数 + * 上传任务配置的参数,参考UploadOptions。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + options?: PlusUploaderUploadOptions; + /** + * 上传任务完成后服务器返回的数据 + * 表示当前上传任务的状态,可通过addEventListener()方法监听statechanged事件监听任务状态的变化。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + responseText?: string; + /** + * 已完成上传数据的大小) + * 整数类型,单位为字节(byte),上传任务开始传输数据时,每次触发statechanged事件或上传任务完成更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + uploadedSize?: number; + /** + * 上传数据的总大小 + * 整数类型,单位为字节(byte),上传任务开始传输数据时更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + totalSize?: number; + /** + * 添加上传文件 + * 向上传任务中添加文件,必须在任务开始上传前调用。 + * 以下情况会导致添加上传文件失败: + * 1. options参数中指定的key在任务中已经存在,则添加失败返回false; + * 2. path参数指定的文件路径不合法或文件不存在,则添加失败返回false; + * 3. 上传任务已经开始调度,调用此方法则添加失败返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + addFile(path?: string, options?: PlusUploaderUploadFileOptions): boolean; + /** + * 添加上传数据 + * 向上传任务中添加数据,必须在任务开始上传前调用。 + * 以下情况会导致添加上传文件失败: + * 1. key参数中指定的键名在任务中已经存在,则添加失败返回false; + * 2. 上传任务已经开始调度,调用此方法则添加失败返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + addData(key?: string, value?: string): boolean; + /** + * 开始上传任务 + * 开始调度上传任务,如果任务已经处于开始状态则无任何响应。 + * 在创建任务或任务上传失败后调用可重新开始上传。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + start(): void; + /** + * 暂停上传任务 + * 暂停上传任务,如果任务已经处于初始状态或暂停状态则无任何响应。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + pause(): void; + /** + * 恢复暂停的上传任务 + * 继续暂停的上传任务,如果任务处于非暂停状态则无任何响应。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + resume(): void; + /** + * 取消上传任务 + * 如果任务未完成,则终止上传,并从任务列表中删除。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + abort(): void; + /** + * 添加上传任务事件监听器 + * 上传任务添加事件监听器后,当监听的事件发生时触发listener回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + addEventListener(type?: string, listener?: (result0: PlusUploaderUpload, result1: number) => void, capture?: boolean): void; + /** + * 获取上传请求HTTP响应头部信息 + * HTTP响应头部全部内容作为未解析的字符串返回,如果没有接收到这个HTTP响应头数据或者上传请求未完成则为空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + getAllResponseHeaders(): string; + /** + * 获取上传请求指定的HTTP响应头部的值 + * 其参数是要返回的HTTP响应头部的名称,可以使用任何大小写来制定这个头部名字,和响应头部的比较是不区分大小写的。 + * 如果没有接收到这个头部或者伤处请求未完成则为空字符串;如果接收到多个有指定名称的头部,这个头部的值被连接起来并返回,使用逗号和空格分隔开各个头部的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + getResponseHeader(headerName?: string): string; + /** + * 设置上传请求的HTTP头数据 + * Http的Header应该包含在通过后续start()调用而发起的请求中,此方法必需在调用start()之前设置才能生效。 + * 如果带有指定名称的头部已经被指定了,这个头部的新值就是:之前指定的值,加上逗号、以及这个调用指定的值(形成一个数组)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + setRequestHeader(headerName?: string, headerValue?: string): void; +} + +/** + * 上传任务事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ +interface PlusUploaderUploadEvent { + /** + * 上传任务状态变化事件 + * 当上传任务状态发生变化时触发此事件,事件原型参考UploadStateChangedCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + statechanged?: string; +} + +/** + * 上传任务的状态,Number类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ +type PlusUploaderUploadState = undefined | 0 | 1 | 2 | 3 | 4 | 5 | -1; + +/** + * JSON对象,创建上传任务的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ +interface PlusUploaderUploadOptions { + /** + * 网络请求类型 + * 仅支持http协议的“POST”请求。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + method?: string; + /** + * 上传任务每次上传的文件块大小(仅在支持断点续传的服务有效) + * 数值类型,单位为Byte(字节),默认值为102400,若设置值小于等于0则表示不分块上传。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + blocksize?: number; + /** + * 上传任务的优先级 + * 数值类型,数值越大优先级越高,默认优先级值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + priority?: number; + /** + * 上传任务超时时间 + * 数值类型,单位为s(秒),默认值为120s。 + * 超时时间为服务器响应请求的时间(不是上传任务完成的总时间),如果设置为0则表示永远不超时。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + timeout?: number; + /** + * 上传任务重试次数 + * 数值类型,默认为重试3次。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + retry?: number; + /** + * 上传任务重试间隔时间 + * 数值类型,单位为s(秒),默认值为30s。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + retryInterval?: number; +} + +/** + * JSON对象,添加上传文件的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ +interface PlusUploaderUploadFileOptions { + /** + * 文件键名 + * 上传文件在上传任务中的键名,默认值为为文件名称。 + * 上传任务中如果已经存在相同key的上传文件或数据将导致添加文件失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + key?: string; + /** + * 文件名称 + * 上传文件的名称,默认值为上传文件路径中的名称。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + name?: string; + /** + * 文件类型 + * 上传文件的类型(如图片文件为“image/jpeg”),默认值自动根据文件后缀名称生成。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) + */ + mime?: string; +} + +/** + * Video模块管理多媒体视频相关能力,可用创建视频播放控件,直播推流控件等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideo { + /** + * 视频播放控件对象 + * VideoPlayer对象表示视频播放控件对象,在窗口中播放视频,可支持本地视频(mp4/flv),网络视频地址(mp4/flv/m3u8)及流媒体(rtmp/hls/rtsp)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + VideoPlayer?: PlusVideoVideoPlayer; + /** + * 视频播放控件参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + VideoPlayerStyles?: PlusVideoVideoPlayerStyles; + /** + * 视频播放控件事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + VideoPlayerEvents?: PlusVideoVideoPlayerEvents; + /** + * 直播推流控件对象 + * LivePusher对象表示直播推流控件对象,在窗口中显示捕获视频,实时推送到流媒体(RTMP)服务器。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + LivePusher?: PlusVideoLivePusher; + /** + * 直播推流控件配置选项 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + LivePusherStyles?: PlusVideoLivePusherStyles; + /** + * 直播推流控件事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + LivePusherEvents?: PlusVideoLivePusherEvents; + /** + * 创建VideoPlayer对象 + * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 + * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + createVideoPlayer(id?: string, styles?: PlusVideoVideoPlayerStyles): PlusVideoVideoPlayer; + /** + * 创建LivePusher对象 + * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 + * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + createLivePusher(id?: string, styles?: PlusVideoLivePusherStyles): PlusVideoLivePusher; + /** + * 查找已经创建的VideoPlayer对象 + * 查找指定id的VideoPlayer对象,如果不存在则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + getVideoPlayerById(id?: string): PlusVideoVideoPlayer; + /** + * 查找已经创建的LivePusher对象 + * 查找指定id的LivePusher对象,如果不存在则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + getLivePusherById(id?: string): PlusVideoLivePusher; +} + +/** + * 视频播放控件对象 + * VideoPlayer对象表示视频播放控件对象,在窗口中播放视频,可支持本地视频(mp4/flv),网络视频地址(mp4/flv/m3u8)及流媒体(rtmp/hls/rtsp)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideoVideoPlayer { + /** + * 监听视频播放控件事件 + * 向视频播放控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 可多次调用此方法向视频播放控件添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + addEventListener(event?: PlusVideoVideoPlayerEvents, listener?: (result: any) => void, capture?: boolean): void; + /** + * 设置视频播放控件参数 + * 用于动态更新视频播放控件的配置参数。 + * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考VideoPlayerStyles。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + setStyles(styles?: PlusVideoVideoPlayerStyles): void; + /** + * 设置视频播放控件参数(将废弃,使用setStyles) + * 用于动态更新视频播放控件的配置选项。 + * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考VideoPlayerStyles。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + setOptions(options?: PlusVideoVideoPlayerStyles): void; + /** + * 播放视频 + * 如果视频已经处于播放状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + play(): void; + /** + * 暂停视频 + * 如果视频未处于播放状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + pause(): void; + /** + * 跳转到指定位置 + * 如果视频未处于播放状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + seek(position?: number): void; + /** + * 切换到全屏 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + requestFullScreen(direction?: number): void; + /** + * 退出全屏 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + exitFullScreen(): void; + /** + * 停止播放视频 + * 如果视频未处于播放或暂停状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + stop(): void; + /** + * 隐藏视频播放控件 + * 隐藏只是控件不可见,控件依然存在并且不改变播放状态。 + * 如果控件已经隐藏,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + hide(): void; + /** + * 显示视频播放控件 + * 将隐藏的控件显示出来(回复到隐藏前的状态)。 + * 如果控件已经显示,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + show(): void; + /** + * 关闭视频播放控件 + * 关闭操作将释放控件所有资源,不再可用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + close(): void; + /** + * 发送弹幕 + * 如果视频未处于播放状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + sendDanmu(danmu?: any): void; + /** + * 设置倍速播放 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + playbackRate(rate?: number): void; +} + +/** + * 视频播放控件参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideoVideoPlayerStyles { + /** + * 视频资源地址 + * 支持本地地址,也支持网络地址及直播流(RTMP)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + src?: string; + /** + * 视频初始播放位置 + * 单位为秒(s)。 + * 注意:仅在视频开始播放前设置有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'initial-time'?: number; + /** + * 视频长度 + * 单位为秒(s)。 + * 注意:仅在视频开始播放前设置有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + duration?: number; + /** + * 是否显示默认播放控件 + * 默认值为true。 + * 包括播放/暂停按钮、播放进度、时间等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + controls?: boolean; + /** + * 弹幕列表 + * 弹幕JSON对象包括属性:text(String类型,弹幕文本类容),color(String类型,弹幕颜色,格式为#RRGGBB),time(Number类型,弹幕出现的时间,单位为秒)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'danmu-list'?: any []; + /** + * 是否显示弹幕按钮 + * 默认值为false。 + * 注意:仅在控件构造时设置有效,不能动态更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'danmu-btn'?: boolean; + /** + * 是否展示弹幕 + * 默认值为false。 + * 注意:仅在控件构造时设置有效,不能动态更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'enable-danmu'?: boolean; + /** + * 是否自动播放 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + autoplay?: boolean; + /** + * 是否循环播放 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + loop?: boolean; + /** + * 是否静音播放 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + muted?: boolean; + /** + * 设置全屏时视频的方向 + * 不指定则根据宽高比自动判断。 + * 有效值为: 0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)。 + * 默认值为-90。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + direction?: number; + /** + * 是否显示播放进度 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'show-progress'?: boolean; + /** + * 是否显示全屏按钮 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'show-fullscreen-btn'?: boolean; + /** + * 是否显示视频底部控制栏的播放按钮 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'show-play-btn'?: boolean; + /** + * 是否显示视频中间的播放按钮 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'show-center-play-btn'?: boolean; + /** + * 是否开启控制进度的手势 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'enable-progress-gesture'?: boolean; + /** + * 当视频大小与 video 容器大小不一致时,视频的表现形式 + * 有效值为:contain(包含),fill(填充),cover(覆盖)。 + * 默认值为contain。 + * 仅Android平台支持。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + objectFit?: string; + /** + * 视频封面的图片网络资源地址 + * 如果 controls 属性值为 false 则设置 poster 无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + poster?: string; + /** + * VideoPlayer控件左上角的垂直偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度; + * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + top?: string; + /** + * VideoPlayer控件左上角的水平偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + left?: string; + /** + * VideoPlayer控件的宽度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + width?: string; + /** + * VideoPlayer控件的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + height?: string; + /** + * VideoPlayer控件在Webview窗口的布局模式 + * 可取值: + * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; + * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; + * 默认值为"static"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + position?: string; +} + +/** + * 视频播放控件事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideoVideoPlayerEvents { + /** + * 视频播放事件 + * 当视频开始/继续播放时触发。 + * 无事件回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + play?: string; + /** + * 视频暂停事件 + * 当视频暂停播放时触发。 + * 无事件回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + pause?: string; + /** + * 视频结束事件 + * 当视频播放到末尾时触发。 + * 无事件回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + ended?: string; + /** + * 视频播放进度更新事件 + * 当视频播放进度变化时触发,触发频率250ms一次。 + * 事件回调函数参数event.detail = {currentTime:"Number类型,当前播放时间(单位为秒)",duration:"Number类型,视频总长度(单位为秒)"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + timeupdate?: string; + /** + * 视频播放全屏播放状态变化事件 + * 当视频播放进入或退出全屏时触发。 + * 事件回调函数参数event.detail = {fullScreen:"Boolean类型,当前状态是否为全屏", direction:"String类型,vertical或horizontal"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + fullscreenchange?: string; + /** + * 视频缓冲事件 + * 当视频播放出现缓冲时触发。 + * 无事件回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + waiting?: string; + /** + * 视频错误事件 + * 当视频播放出错时触发。 + * 无事件回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + error?: string; +} + +/** + * 直播推流控件对象 + * LivePusher对象表示直播推流控件对象,在窗口中显示捕获视频,实时推送到流媒体(RTMP)服务器。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideoLivePusher { + /** + * 监听直播推流控件事件 + * 向直播推流控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 可多次调用此方法向直播推流控件添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + addEventListener(event?: PlusVideoLivePusherEvents, listener?: (result: any) => void, capture?: boolean): void; + /** + * 设置直播推流控件参数 + * 用于动态更新直播推流控件的配置参数。 + * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考LivePusherStyles。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + setStyles(styles?: PlusVideoLivePusherStyles): void; + /** + * 设置直播推流控件参数(将废弃,使用setStyles) + * 用于动态更新直播推流控件的配置选项。 + * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考LivePusherStyles。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + setOptions(options?: PlusVideoLivePusherStyles): void; + /** + * 预览摄像头采集数据 + * 调用摄像头采集图像数据,并在推流控件中预览(此时不会向服务器推流,需调用start方法才开始推流)。 + * 注意:为了确保预览窗口大小正确,应该在创建控件后延时一定的时间(如500ms)进行预览。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + preview(): void; + /** + * 开始推流 + * 如果已经处于推流状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + start(successCB?: () => void, errorCB?: () => void): void; + /** + * 停止推流 + * 如果未处于推流状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + stop(options?: any): void; + /** + * 暂停推流 + * 如果未处于推流状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + pause(): void; + /** + * 恢复推流 + * 如果未处于暂停状态,则操作无效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + resume(): void; + /** + * 切换前后摄像头 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + switchCamera(): void; + /** + * 快照 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + snapshot(successCB?: () => void, errorCB?: () => void): void; + /** + * 关闭直播推流控件 + * 关闭操作将释放控件所有资源,不再可用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + close(): void; +} + +/** + * 直播推流控件配置选项 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideoLivePusherStyles { + /** + * 推流地址 + * 支持RTMP协议。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + url?: string; + /** + * 推流视频模式 + * 可取值:SD(标清), HD(高清), FHD(超清)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + mode?: string; + /** + * 是否静音 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + muted?: boolean; + /** + * 开启摄像头 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'enable-camera'?: boolean; + /** + * 自动聚集 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + 'auto-focus'?: boolean; + /** + * 是否美颜 + * 可取值0、1,其中0表示不使用美颜,1表示不使用美颜。 + * 默认值为0(不使用美颜)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + beauty?: number; + /** + * 是否美白 + * 可取值0、1、2、3、4、5,其中0表示不使用美白,其余值分别表示美白的程度,值越大美白程度越大。 + * 默认值为0(不使用美白)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + whiteness?: number; + /** + * 宽高比 + * 可取值:3:4, 9:16。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + aspect?: string; + /** + * LivePusher控件左上角的垂直偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度; + * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + top?: string; + /** + * LivePusher控件左上角的水平偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + left?: string; + /** + * LivePusher控件的宽度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + width?: string; + /** + * LivePusher控件的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + height?: string; + /** + * LivePusher控件在Webview窗口的布局模式 + * 可取值: + * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; + * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; + * 默认值为"static"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + position?: string; +} + +/** + * 直播推流控件事件类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ +interface PlusVideoLivePusherEvents { + /** + * 状态变化事件 + * 当推流连接服务器状态变化时触发。 + * 事件回调函数参数event={type:"事件类型,此时为statechange",target:"触发此事件的直播推流控件对象",detail:{code:"状态码,参考后面状态码说明",message:"描述信息"}}。 + * 其中code状态码: + * 1001 - 已经连接推流服务器; + * 1002 - 已经与服务器握手完毕,开始推流; + * 1003 - 打开摄像头成功; + * 1004 - 录屏启动成功; + * 1005 - 推流动态调整分辨率; + * 1006 - 推流动态调整码率; + * 1007 - 首帧画面采集完成; + * 1008 - 编码器启动; + * -1301 - 打开摄像头失败; + * -1302 - 打开麦克风失败; + * -1303 - 视频编码失败; + * -1304 - 音频编码失败; + * -1305 - 不支持的视频分辨率; + * -1306 - 不支持的音频采样率; + * -1307 - 网络断连,且经多次重连抢救无效,更多重试请自行重启推流; + * -1308 - 开始录屏失败,可能是被用户拒绝; + * -1309 - 录屏失败,不支持的Android系统版本,需要5.0以上的系统; + * -1310 - 录屏被其他应用打断了; + * -1311 - Android Mic打开成功,但是录不到音频数据; + * -1312 - 录屏动态切横竖屏失败; + * 1101 - 网络状况不佳:上行带宽太小,上传数据受阻; + * 1102 - 网络断连, 已启动自动重连; + * 1103 - 硬编码启动失败,采用软编码; + * 1104 - 视频编码失败; + * 1105 - 新美颜软编码启动失败,采用老的软编码; + * 1106 - 新美颜软编码启动失败,采用老的软编码; + * 3001 - RTMP -DNS解析失败; + * 3002 - RTMP服务器连接失败; + * 3003 - RTMP服务器握手失败; + * 3004 - RTMP服务器主动断开,请检查推流地址的合法性或防盗链有效期; + * 3005 - RTMP 读/写失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + statechange?: string; + /** + * 网络状态通知事件 + * 当推流的网络状态发生变化时触发。 + * 事件回调函数参数event={type:"事件类型,此时为netstatus",target:"触发此事件的直播推流控件对象",detail:{videoBitrate:"视频码率",audioBitrate:"音频码率",videoFPS:"视频帧率",netSpeed:"推流网速",videoWidth:"视频宽度",videoHeight:"视频高度"}}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + netstatus?: string; + /** + * 渲染错误事件 + * 当推流发生错误是触发。 + * 事件回调函数参数event={type:"事件类型,此时为error",target:"触发此事件的直播推流控件对象",detail:{code:"错误编码,参考后面错误码说明",message:"描述信息"}}。 + * 其中code错误码: + * 1001 - 用户禁止使用摄像头; + * 1002 - 用户禁止使用录音。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) + */ + error?: string; +} + +/** + * Webview模块管理应用窗口界面,实现多窗口的逻辑控制管理操作。通过plus.webview可获取应用界面管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebview { + /** + * 一组用于定义页面或控件显示动画效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + AnimationTypeShow?: PlusWebviewAnimationTypeShow; + /** + * 一组用于定义页面或控件关闭的动画效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + AnimationTypeClose?: PlusWebviewAnimationTypeClose; + /** + * Webview窗口对象,用于操作加载HTML页面的窗口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewObject?: PlusWebviewWebviewObject; + /** + * Webview窗口动画参数 + * 用于指定动画目标窗口,起始位置、目标位置等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewAnimationOptions?: PlusWebviewWebviewAnimationOptions; + /** + * Webview窗口动画样式 + * 用于指定动画窗口的起始位置、目标位置等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewAnimationStyles?: PlusWebviewWebviewAnimationStyles; + /** + * Webview窗口回弹样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewBounceStyle?: PlusWebviewWebviewBounceStyle; + /** + * Webview窗口内容动画参数 + * 指定动画的类型、持续时间等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewContentAnimationOptions?: PlusWebviewWebviewContentAnimationOptions; + /** + * 原生控件在窗口中停靠的方式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewDock?: PlusWebviewWebviewDock; + /** + * Webview窗口滑动事件数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewDragEvent?: PlusWebviewWebviewDragEvent; + /** + * 窗口手势操作参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewDragOptions?: PlusWebviewWebviewDragOptions; + /** + * 手势操作关联对象参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewDragOtherViewOptions?: PlusWebviewWebviewDragOtherViewOptions; + /** + * 截屏绘制操作参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewDrawOptions?: PlusWebviewWebviewDrawOptions; + /** + * 窗口收藏参数 + * 在流应用环境中调用收藏功能时使用的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewFavoriteOptions?: PlusWebviewWebviewFavoriteOptions; + /** + * 创建加载HTML数据参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewLoadDataOptions?: PlusWebviewWebviewLoadDataOptions; + /** + * 窗口的分享参数 + * 在流应用环境中调用分享功能时使用的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewShareOptions?: PlusWebviewWebviewShareOptions; + /** + * 窗口原生子View控件样式 + * 可设置原生控件的标识、大小、位置以及绘制的内容等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewSubNViewStyles?: PlusWebviewWebviewSubNViewStyles; + /** + * 窗口标题栏控件样式 + * 标题栏控件固定高度为44px,可通过Webview窗口对象的getTitleNView方法获取标题栏原生控件对象动态绘制内容。 + * 可以通过WebviewObject对象的getTitleNView()获取标题栏的NView对象,然后调用其setStyle方法更新样式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewTitleNViewStyles?: PlusWebviewWebviewTitleNViewStyles; + /** + * 窗口标题栏自定义按钮样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewTitleNViewButtonStyles?: PlusWebviewWebviewTitleNViewButtonStyles; + /** + * 标题栏控件的进度条样式 + * 显示在标题栏控件底部。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewProgressStyles?: PlusWebviewWebviewProgressStyles; + /** + * 窗口标题栏控件的分割线样式 + * 显示在标题栏控件底部。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewSplitLineStyles?: PlusWebviewWebviewSplitLineStyles; + /** + * Webview窗口事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewEvent?: PlusWebviewWebviewEvent; + /** + * JSON对象,原生窗口扩展参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewExtraOptions?: PlusWebviewWebviewExtraOptions; + /** + * 原生控件在窗口中显示的位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewPosition?: PlusWebviewWebviewPosition; + /** + * Webview窗口下拉刷新样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewPullToRefreshStyles?: PlusWebviewWebviewPullToRefreshStyles; + /** + * Webview窗口rendered事件参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewRenderedEventOptions?: PlusWebviewWebviewRenderedEventOptions; + /** + * 替换H5标准API配置信息 + * 目前仅支持替换H5标准定位接口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewReplaceWebApiOptions?: PlusWebviewWebviewReplaceWebApiOptions; + /** + * JSON对象,Webview窗口的系统状态栏区域样式 + * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewStatusbarStyles?: PlusWebviewWebviewStatusbarStyles; + /** + * JSON对象,Webview窗口对象的样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewStyles?: PlusWebviewWebviewStyles; + /** + * 一组用于定义页面或控件变形的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewTransform?: PlusWebviewWebviewTransform; + /** + * 一组用于定义页面或控件转换效果的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewTransition?: PlusWebviewWebviewTransition; + /** + * 拦截Webview窗口资源请求的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewOverrideResourceOptions?: PlusWebviewWebviewOverrideResourceOptions; + /** + * 拦截Webview窗口URL请求的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewOverrideUrlOptions?: PlusWebviewWebviewOverrideUrlOptions; + /** + * 监听Webview窗口资源加载的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + WebviewListenResourceOptions?: PlusWebviewWebviewListenResourceOptions; + /** + * 获取所有Webview窗口 + * 获取应用中已创建的所有Webview窗口,包括所有未显示的Webview窗口。 + * 返回WebviewObject对象在数组中按创建的先后顺序排列,即数组中第一个WebviewObject对象用是加载应用的入口页面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + all(): PlusWebview []; + /** + * 关闭Webview窗口 + * 关闭已经打开的Webview窗口,需先获取窗口对象或窗口id,并可指定关闭窗口的动画及动画持续时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + close(id_wvobj?: string, aniClose?: string, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; + /** + * 创建新的Webview窗口 + * 创建Webview窗口,用于加载新的HTML页面,可通过styles设置Webview窗口的样式,创建完成后需要调用show方法才能将Webview窗口显示出来。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + create(url?: string, id?: string, styles?: PlusWebviewWebviewStyles, extras?: any): PlusWebviewWebviewObject; + /** + * 获取当前窗口的WebviewObject对象 + * 获取当前页面所属的Webview窗口对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + currentWebview(): PlusWebviewWebviewObject; + /** + * 获取屏幕所有可视的Webview窗口 + * 仅在屏幕区域显示的Webview窗口,如果Webview窗口显示了但被其它Webview窗口盖住则认为不可视。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getDisplayWebview(): PlusWebview []; + /** + * 查找指定标识的WebviewObject窗口 + * 在已创建的窗口列表中查找指定标识的Webview窗口并返回。 + * 若没有查找到指定标识的窗口则返回null,若存在多个相同标识的Webview窗口,则返回第一个创建的Webview窗口。 + * 如果要获取应用入口页面所属的Webview窗口,其标识为应用的%APPID%,可通过plus.runtime.appid获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getWebviewById(id?: string): PlusWebviewWebviewObject; + /** + * 获取应用首页WebviewObject窗口对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getLaunchWebview(): PlusWebviewWebviewObject; + /** + * 获取应用第二个首页WebviewObject窗口对象 + * 在双首页模式下(在manifest.json的plus->secondwebview节点下配置),应用会自动创建两个首页Webview,通过getLaunchWebview()可获取第一个首页窗口对象,通过getSecondWebview()可获取第二个首页窗口对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getSecondWebview(): PlusWebviewWebviewObject; + /** + * 获取应用显示栈顶的WebviewObject窗口对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getTopWebview(): PlusWebviewWebviewObject; + /** + * 隐藏Webview窗口 + * 根据指定的WebviewObject对象或id隐藏Webview窗口,使得窗口不可见。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + hide(id_wvobj?: string, aniHide?: string, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; + /** + * 创建并打开Webview窗口 + * 创建并显示Webview窗口,用于加载新的HTML页面,可通过styles设置Webview窗口的样式,创建完成后自动将Webview窗口显示出来。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + open(url?: string, id?: string, styles?: PlusWebviewWebviewStyles, aniShow?: string, duration?: number, showedCB?: () => void): PlusWebviewWebviewObject; + /** + * 预载网络页面 + * 预载网络页面会向服务器发起http/https请求获取html页面内容, + * 待Webview窗口加载此url页面时会则根据缓存机制优先使用预载的页面内容(加快页面显示速度)。 + * 注意:预载网络页面仅在运行期生效,为了节省内存仅保留最后5个预载页面数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + prefetchURL(url?: string): void; + /** + * 预载网络页面(多个地址) + * 预载网络页面会向服务器发起http/https请求获取html页面内容, + * 待Webview窗口加载此url页面时会则根据缓存机制优先使用预载的页面内容(加快页面显示速度)。 + * 注意:预载网络页面仅在运行期生效,为了节省内存仅保留最后5个预载页面数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + prefetchURLs(urls?: any []): void; + /** + * 显示Webview窗口 + * 显示已创建或隐藏的Webview窗口,需先获取窗口对象或窗口id,并可指定显示窗口的动画及动画持续时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + show(id_wvobj?: string, aniShow?: string, duration?: number, showedCB?: () => void, extras?: PlusWebviewWebviewExtraOptions): PlusWebviewWebviewObject; + /** + * Webview窗口组合动画 + * 同步组合两个Webview窗口动画,动画完成后窗口的位置会发生变化,一次需要在动画属性参数中设置动画起始位置、结束位置等。 + * 注意:此动画操作会改变窗口位置(如left值等),再次调用show方法时需要确保其位置是否在可视区域,如果不在可视区域则需要调用窗口的setStyle方法设置其位置到可视区域内,如setStyle({left:'0px'});。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + startAnimation(options?: PlusWebviewWebviewAnimationOptions, otherOptions?: PlusWebviewWebviewAnimationOptions, callback?: (result: any) => void): void; + /** + * 获取Webview默认是否开启硬件加速 + * 由于不同设备对硬件加速的支持情况存在差异,开启硬件加速能加速HTML页面的渲染,但也会消耗更多的系统资源,从而导致在部分设备上可能出现闪屏、发虚、分块渲染等问题, 因此5+ Runtime会根据设备实际支持情况自动选择是否开启硬件加速。 + * 关闭硬件加速则可能会导致Webview页面无法支持Video标签播放视频等问题,如果在特定情况下需要调整修改默认开启硬件加速的行为,则可通过plus.webview.defaultHardwareAccelerated()方法获取当前设备默认是否开启硬件加速状态,从而决定是否需要显式开启或关闭指定Webview的硬件加速功能(通过WebviewStyles的hardwareAccelerated属性设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + defaultHardwareAccelerated(): boolean; +} + +/** + * 一组用于定义页面或控件显示动画效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewAnimationTypeShow { + /** + * 自动选择动画效果 + * 自动选择动画效果,使用上次显示窗口设置的动画效果,如果是第一次显示则默认动画效果“none”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + auto?: string; + /** + * 无动画效果 + * 立即显示页面,无任何动画效果,页面显示默认的动画效果。 + * 此效果忽略动画时间参数,立即显示。 + * 对应关闭动画"none"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + none?: string; + /** + * 从右侧横向滑动效果 + * 页面从屏幕右侧外向内横向滑动显示。 + * 对应关闭动画"slide-out-right"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-in-right'?: string; + /** + * 从左侧横向滑动效果 + * 页面从屏幕左侧向右横向滑动显示。 + * 对应关闭动画"slide-out-left"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-in-left'?: string; + /** + * 从上侧竖向滑动效果 + * 页面从屏幕上侧向下竖向滑动显示。 + * 对应关闭动画"slide-out-top"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-in-top'?: string; + /** + * 从下侧竖向滑动效果 + * 页面从屏幕下侧向上竖向滑动显示。 + * 对应关闭动画"slide-out-bottom"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-in-bottom'?: string; + /** + * 从透明到不透明逐渐显示效果 + * 页面从完全透明到不透明逐渐显示。 + * 对应关闭动画"fade-out"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'fade-in'?: string; + /** + * 从小到大逐渐放大显示效果 + * 页面在屏幕中间从小到大逐渐放大显示。 + * 对应关闭动画"zoom-in"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'zoom-out'?: string; + /** + * 从小到大逐渐放大并且从透明到不透明逐渐显示效果 + * 页面在屏幕中间从小到大逐渐放大并且从透明到不透明逐渐显示。 + * 对应关闭动画"zoom-fade-in"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'zoom-fade-out'?: string; + /** + * 从右侧平移入栈动画效果 + * 页面从屏幕右侧滑入显示,同时上一个页面带阴影效果从屏幕左侧滑出隐藏。 + * 对应关闭动画"pop-out"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'pop-in'?: string; +} + +/** + * 一组用于定义页面或控件关闭的动画效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewAnimationTypeClose { + /** + * 自动选择动画效果 + * 自动选择显示窗口相对于的动画效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + auto?: string; + /** + * 无动画 + * 立即关闭页面,无任何动画效果。 + * 此效果忽略动画时间参数,立即关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + none?: string; + /** + * 横向向右侧滑出屏幕动画 + * 页面从屏幕中横向向右侧滑动到屏幕外关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-out-right'?: string; + /** + * 横向向左侧滑出屏幕动画 + * 页面从屏幕中横向向左侧滑动到屏幕外关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-out-left'?: string; + /** + * 竖向向上侧滑出屏幕动画 + * 页面从屏幕中竖向向上侧滑动到屏幕外关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-out-top'?: string; + /** + * 竖向向下侧滑出屏幕动画 + * 页面从屏幕中竖向向下侧滑动到屏幕外关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'slide-out-bottom'?: string; + /** + * 从不透明到透明逐渐隐藏动画 + * 页面从不透明到透明逐渐隐藏关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'fade-out'?: string; + /** + * 从大逐渐缩小关闭动画 + * 页面逐渐向页面中心缩小关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'zoom-in'?: string; + /** + * 从大逐渐缩小并且从不透明到透明逐渐隐藏关闭动画 + * 页面逐渐向页面中心缩小并且从不透明到透明逐渐隐藏关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'zoom-fade-in'?: string; + /** + * 从右侧平移出栈动画效果 + * 页面从屏幕右侧滑出消失,同时上一个页面带阴影效果从屏幕左侧滑入显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'pop-out'?: string; +} + +/** + * Webview窗口对象,用于操作加载HTML页面的窗口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewObject { + /** + * Webview窗口的标识 + * 在打开或创建Webview窗口时设置,如果没有设置窗口标识,此属性值为undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + id?: string; + /** + * Webview窗口关闭事件 + * 当Webview窗口关闭时触发此事件,类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + onclose?: (result: any) => void; + /** + * Webview窗口错误事件 + * 当Webview窗口加载错误时触发此事件,类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + onerror?: PlusWebviewWebviewEvent; + /** + * Webview窗口页面加载完成事件 + * 当Webview窗口页面加载完成时触发此事件,类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + onloaded?: PlusWebviewWebviewEvent; + /** + * Webview窗口页面开始加载事件 + * 当Webview窗口开始加载新页面时触发此事件,类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + onloading?: PlusWebviewWebviewEvent; + /** + * 添加事件监听器 + * 向Webview窗口添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 可多次调用此方法向Webview添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + addEventListener(event?: PlusWebviewWebviewEvent, listener?: (result: any) => void, capture?: boolean): void; + /** + * 在Webview窗口中添加子窗口 + * 将另一个Webview窗口作为子窗口添加到当前Webview窗口中,添加后其所有权归父Webview窗口,当父窗口关闭时子窗口自动关闭。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + append(webview?: PlusNativeObjView): void; + /** + * 添加Webview窗口预加载js文件 + * 对于一些网络HTML页面,在无法修改HTML页面时可通过此方法自动加载本地js文件。 + * 当Webview窗口跳转到新页面时也会自动加载指定的js执行,添加多个js文件将按照添加的先后顺序执行。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + appendJsFile(file?: string): void; + /** + * Webview窗口内容动画 + * 动画后可能会导致Webview窗口显示内容改变,可通过调用restore方法恢复。 + * 当Webview窗口内容动画引起内容不可见(透明),将显示此窗口后面的内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + animate(options?: PlusWebviewWebviewContentAnimationOptions, callback?: () => void): void; + /** + * 后退到上次加载的页面 + * Webview窗口历史记录操作,后退到窗口上次加载的HTML页面。 + * 如果窗口历史记录中没有可后退的页面则不触发任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + back(): void; + /** + * 开始Webview窗口的下拉刷新 + * 开始触发下拉刷新效果,与用户操作下拉刷新行为一致(有动画效果)。 + * 触发setPullTorefresh方法设置的下拉刷新事件回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + beginPullToRefresh(): void; + /** + * 查询Webview窗口是否可后退 + * Webview窗口历史记录查询操作,获取Webview是否可后退到历史加载的页面,结果通过queryCallback回调方法返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + canBack(queryCallback?: (result: any) => void): void; + /** + * 查询Webview窗口是否可前进 + * Webview窗口历史记录查询操作,获取Webview是否可前进到历史加载的页面,结果通过queryCallback回调方法返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + canForward(queryCallback?: (result: any) => void): void; + /** + * 检测Webview窗口是否渲染完成 + * 检测方式为判断的Webview窗口内容是否为白屏,如果非白屏则认为渲染完成,否则认为渲染未完成。 + * 通过successCallback回调函数返回结果,如果检测过程中发生错误则触发errorCallback回调函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + checkRenderedContent(options?: PlusWebviewWebviewRenderedEventOptions, successCallback?: () => void, errorCallback?: (result: any) => void): void; + /** + * 获取Webview窗口的所有子Webview窗口 + * 获取添加到Webview窗口中的所有子Webview窗口,如果没有子Webview窗口则返回空数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + children(): PlusWebview []; + /** + * 清空原生Webview窗口加载的内容 + * 清除原生窗口的内容,用于重置原生窗口加载的内容,清除其加载的历史记录等内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + clear(): void; + /** + * 关闭Webview窗口 + * 关闭并销毁Webview窗口,可设置关闭动画和动画持续时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + close(aniClose?: PlusWebviewAnimationTypeClose, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; + /** + * 设置Webview窗口的滑屏操作手势 + * 将Webview窗口的左右滑动手势关联到其它Webview窗口,可实现滑动切换显示Webview的动画效果(如Tab页面切换效果)。 + * 注意:滑屏操作会改变窗口位置(如left值等),如果不在可视区域则需要调用窗口的setStyle方法设置其位置到可视区域内,如setStyle({left:'0px'});。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + drag(options?: PlusWebviewWebviewDragOptions, otherView?: PlusWebviewWebviewDragOtherViewOptions, callback?: (result: PlusWebviewWebviewDragEvent) => void): void; + /** + * 截屏绘制 + * 将Webview窗口的可视区域截屏并绘制到Bitmap图片对象中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + draw(bitmap?: PlusNativeObjBitmap, successCallback?: () => void, errorCallback?: (result: any) => void, options?: PlusWebviewWebviewDrawOptions): void; + /** + * 结束Webview窗口的下拉刷新 + * 关闭下拉刷新效果,恢复到开始下拉刷新之前的效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + endPullToRefresh(): void; + /** + * 在Webview窗口中执行JS脚本 + * 将JS脚本发送到Webview窗口中运行,可用于实现Webview窗口间的数据通讯。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + evalJS(js?: string): void; + /** + * 前进到上次加载的页面 + * Webview窗口历史记录操作,前进到窗口上次加载的HTML页面。 + * 如果窗口历史记录中没有可前进的页面则不触发任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + forward(): void; + /** + * 获取Webview窗口的收藏参数 + * 获取Webview窗口的收藏参数,如收藏页面的标题、图标、地址等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getFavoriteOptions(): PlusWebviewWebviewFavoriteOptions; + /** + * 获取Webview窗口的分享参数 + * 获取Webview窗口的分享参数,如分享的标题、图标、链接地址等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getShareOptions(): PlusWebviewWebviewShareOptions; + /** + * 获取Webview窗口的样式 + * 获取Webview窗口的样式属性,如窗口位置、大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getStyle(): PlusWebviewWebviewStyles; + /** + * 获取Webview窗口的原生子View控件对象 + * 创建Webview窗口的所有原生子View控件。 + * 可以在创建窗口时设置其subNViews属性自动创建(应用首页可通过manfest.json中的plus->launchwebview->subNNViews节点配置创建); + * 也可以通过Webview窗口的append方法将已经创建的原生View控件添加为其子。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getSubNViews(): any []; + /** + * 获取Webview窗口加载HTML页面的标题 + * 标题为HTML页面head节点下title节点中的文本内容,当窗口内容发生页面内跳转时可通过窗口触发的“loaded”事件中调用此方法来获取跳转后页面的标题。 + * 如果HTML页面没有使用title节点来设置标题,则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getTitle(): string; + /** + * 获取Webview窗口的标题栏控件对象 + * 创建Webview窗口时设置其titleNView属性时则自动创建标题栏控件,应用首页可通过manfest.json中的plus->launchwebview->titleNView节点配置创建标题栏控件。 + * 可通过此方法获取Webview窗口创建的标题栏控件,对象类型为plus.nativeObj.View,可通过调用其drawBitmap/drawRect/drawText方法绘制更新内容来实现自定义样式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getTitleNView(): PlusNativeObjView; + /** + * 获取Webview窗口加载HTML页面的地址 + * 当窗口内容发生页面内跳转时可通过窗口触发的“loaded”事件中调用此方法来获取跳转后页面的地址。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + getURL(): string; + /** + * 隐藏Webview窗口 + * 隐藏Webview窗口可保存已加载HTML页面的上下文数据,能降低应用使用的系统资源,通过show方法可将隐藏的Webview窗口显示出来。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + hide(aniHide?: PlusWebviewAnimationTypeClose, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; + /** + * 隐藏标题栏上按钮的红点 + * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + hideTitleNViewButtonRedDot(index?: number): void; + /** + * 是否拦截Webview窗口的触屏事件 + * 拦截后触屏事件不再传递,否则传递给View控件下的其它窗口处理。 + * Webview窗口默认拦截所有触屏事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + interceptTouchEvent(intercept?: boolean): void; + /** + * 查询Webview窗口是否开启硬件加速 + * 若Webview窗口已经开启硬件加速则返回true,否则返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + isHardwareAccelerated(): boolean; + /** + * 查询Webview窗口是否可见 + * 若Webview窗口已经显示(调用过show方法,即使被其它窗口挡住了也认为已显示)则返回true,若Webview窗口被隐藏则返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + isVisible(): boolean; + /** + * 监听页面开始加载资源 + * Webview加载资源时,如果满足options参数中定义的条件,则触发callback回调。 + * 此方法仅触发回调事件,不会阻止资源的加载。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + listenResourceLoading(options?: PlusWebviewWebviewListenResourceOptions, callback?: (result: any) => void): void; + /** + * 加载新HTML数据 + * 触发Webview窗口加载HTML页面数据,如果HTML数据无效将导致页面加载失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + loadData(data?: string, options?: PlusWebviewWebviewLoadDataOptions): void; + /** + * 加载新URL页面 + * 触发Webview窗口从新的URL地址加载页面,如果url地址无效将导致页面显示失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + loadURL(url?: string, additionalHttpHeaders?: any): void; + /** + * 获取Webview窗口对象的原生(Native.JS)实例对象 + * Android平台返回Webview窗口对象的android.webkit.Webview实例对象, + * iOS平台返回Webview窗口对象的UIWebview实例对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + nativeInstanceObject(): PlusAndroidInstanceObject | PlusIosInstanceObject; + /** + * 获取在当前Webview窗口中创建的所有窗口 + * 返回从当前Webview中调用plus.webview.open或plus.webview.create创建的所有Webview窗口数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + opened(): PlusWebview []; + /** + * 获取当前Webview窗口的创建者 + * 创建者为调用plus.webview.open或plus.webview.create方法创建当前窗口的Webview窗口。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + opener(): PlusWebviewWebviewObject; + /** + * 拦截Webview窗口的资源加载 + * 根据区配规则拦截Webview窗口加载资源的URL地址,重定向到其它资源地址(暂仅支持本地地址)。 + * 注意:多次调用overrideResourceRequest时仅以最后一次调用设置的参数值生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + overrideResourceRequest(options?: PlusWebview []): void; + /** + * 拦截Webview窗口的URL请求 + * 拦截URL请求后,Webview窗口将不会跳转到新的URL地址,此时将通过callback回调方法返回拦截的URL地址(可新开Webview窗口加载URL页面等)。 + * 此方法只能拦截窗口的网络超链接跳转(包括调用loadURL方法触发的跳转),不可拦截页面请求资源请求(如加载css/js/png等资源的请求)。 + * 注意:多次调用overrideUrlLoading时仅以最后一次调用设置的参数值生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + overrideUrlLoading(options?: PlusWebviewWebviewOverrideUrlOptions, callback?: (result: any) => void): void; + /** + * 获取当前Webview窗口的父窗口 + * Webview窗口作为子窗口添加(Webview.append)到其它Webview窗口中时有效,这时其它Webview窗口为父窗口。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + parent(): PlusWebviewWebviewObject; + /** + * 重新加载Webview窗口显示的HTML页面 + * 触发Webview窗口重新加载当前显示的页面内容。 + * 如果当前HTML页面未加载完则停止并重新加载,如果当前Webview窗口没有加载任何页面则无响应。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + reload(force?: boolean): void; + /** + * 重置Webview窗口的回弹位置 + * 开启窗口回弹效果后,当窗口中展现的内容滚动到头(顶部或底部)时,再拖拽时窗口整体内容将跟随移动,松开后自动回弹到停靠位置。 + * 这时需要调用此方法来重置窗口的回弹位置,窗口将采用动画方式回弹到其初始显示的位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + resetBounce(): void; + /** + * 恢复Webview控件显示内容 + * 恢复调用animate方法改变Webview控件的内容,更新至动画前显示的内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + restore(): void; + /** + * 移除子Webview窗口 + * 从当前Webview窗口移除指定的子Webview窗口,若指定的webview对象不是当前窗口的子窗口则无任何作用。 + * 移除后子Webview窗口不会关闭,需要调用其close方法才能真正关闭并销毁。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + remove(webview?: PlusNativeObjView): void; + /** + * 移除Webview窗口事件监听器 + * 从Webview窗口移除通过addEventListener方法添加的事件监听器,若没有查找到对应的事件监听器,则无任何作用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + removeEventListener(event?: PlusWebviewWebviewEvent, listener?: (result: any) => void): void; + /** + * 从父窗口中移除 + * 从所属的父Webview窗口移除,如果没有父窗口,则无任何作用。 + * 从父窗口中移除后子Webview窗口不会关闭,需要调用其close方法才能真正关闭并销毁。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + removeFromParent(): void; + /** + * 移除标题栏上按钮的角标 + * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + removeTitleNViewButtonBadge(index?: number): void; + /** + * 设置Webview窗口的回弹效果 + * 开启窗口回弹效果后,当窗口中展现的内容滚动到头(顶部或底部)时,再拖拽时窗口整体内容将跟随移动,松开后自动回弹到停靠位置(可通过style设置)。 + * 拖拽窗口内容时页面显示Webview窗口的背景色,默认为透明,此时显示Webview下面的内容,利用这个特点可以实现自定下拉刷新特效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setBounce(style?: PlusWebviewWebviewBounceStyle): void; + /** + * 设置Webview窗口是否阻塞加载页面中使用的网络图片 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setBlockNetworkImage(block?: boolean): void; + /** + * 设置HTML内容是否可见 + * 设置HTML内容不可见后,将显示Webview窗口的背景色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setContentVisible(visible?: boolean): void; + /** + * 设置预加载的CSS文件 + * 预加载CSS文件不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 + * 设置新的CSS文件后将清空之前设置的值(包括调用setCssText设置的值)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setCssFile(file?: string): void; + /** + * 设置预加载的CSS内容 + * 预加载CSS内容不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 + * 设置新的CSS内容后将清空之前设置的值(包括调用setCssFile设置的值)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setCssText(text?: string): void; + /** + * 设置Webview窗口的收藏参数 + * 仅在流应用环境(流应用/5+浏览器)中有效:用户点击流应用环境的收藏按钮时使用的参数,如设置收藏页面标题,图标、页面地址等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setFavoriteOptions(options?: PlusWebviewWebviewFavoriteOptions): void; + /** + * 设置Webview窗口底部修复区域高度 + * 如果Webview加载页面中存在底部停靠区域(如“蘑菇街”WAP页面的底部Tab栏),在页面滚动时动态改变Webview高度可能会出现底部停靠区域抖动的现象(如360浏览器中向上滑顶部标题栏自动消失引起Webview变高)。 + * 此时可以调用此方法来指定底部停靠区域(通常是底部Tab栏)进行优化修复抖动效果,高度值为底部停靠区域的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setFixBottom(height?: number): void; + /** + * 设置预加载的JS文件 + * 预加载JS文件不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 + * 设置新的JS文件后将清空之前设置的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setJsFile(file?: string): void; + /** + * 设置Webview窗口的下拉刷新效果 + * 开启Webview窗口的下拉刷新功能,显示窗口内置的下拉刷新控件样式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setPullToRefresh(style?: PlusWebviewWebviewPullToRefreshStyles, refreshCB?: () => void): void; + /** + * 设置Webview窗口rendered事件参数 + * 可设置页面渲染完成的判断标准,如判断页面顶部区域、中间区域、或底部区域。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setRenderedEventOptions(options?: PlusWebviewWebviewRenderedEventOptions): void; + /** + * 设置Webview窗口的样式 + * 更新Webview窗口的样式,如窗口位置、大小、背景色等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setStyle(styles?: PlusWebviewWebviewStyles): void; + /** + * 设置Webview窗口的分享参数 + * 仅在流应用环境(流应用/5+浏览器)中有效:用户点击流应用环境的分享按钮时使用的参数,如设置分享的标题、链接地址等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setShareOptions(options?: PlusWebviewWebviewShareOptions): void; + /** + * 设置标题栏上按钮的角标 + * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setTitleNViewButtonBadge(index?: number, text?: string): void; + /** + * 设置Webview窗口是否可见 + * 修改窗口是否可见并不影响窗口的显示栈顺序,窗口显示与隐藏也不会有动画效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + setVisible(visible?: boolean): void; + /** + * 显示Webview窗口 + * 当调用plus.webview.create方法创建Webview窗口后,需要调用其show方法才能显示,并可设置窗口显示动画及动画时间。 + * Webview窗口被隐藏后也可调用此方法来重新显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + show(aniShow?: PlusWebviewAnimationTypeShow, duration?: number, showedCB?: () => void, extras?: PlusWebviewWebviewExtraOptions): void; + /** + * 在指定Webview窗口后显示 + * 当调用plus.webview.create方法创建Webview窗口后,可调用其showBehind方法显示在指定Webview窗口之后。 + * 这种显示方式不会出现动画效果,当指定的Webview窗口关闭后,则自身窗口自动显示出来。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + showBehind(webview?: PlusWebviewWebviewObject): void; + /** + * 设置标题栏上按钮的红点 + * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 + * 注意:设置显示按钮的角标后红点不显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + showTitleNViewButtonRedDot(index?: number): void; + /** + * 停止加载HTML页面内容 + * 触发Webview窗口停止加载页面内容,如果已经加载部分内容则显示部分内容,如果加载完成则显示全部内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + stop(): void; + /** + * 更新Webview窗口的原生子View控件对象 + * 通过WebviewSubNViewStyles中的id属性值匹配子View控件更新绘制内容,如果没有查找到对应id的子View控件则忽略。 + * 此操作仅更新子View控件上绘制的内容,不会添加或删除原生子View控件对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + updateSubNViews(styles?: PlusWebview []): void; +} + +/** + * Webview窗口动画参数 + * 用于指定动画目标窗口,起始位置、目标位置等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewAnimationOptions { + /** + * 执行动画的窗口对象 + * 可取值Webview窗口对象、Webview窗口的id(String类型)、原生View窗口对象(plus.nativeObj.View)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + view?: PlusWebviewWebviewObject; + /** + * 动画样式 + * 用于指定动画窗口的起始位置,目标位置等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + styles?: PlusWebviewWebviewAnimationStyles; + /** + * 窗口动画完成后的行为 + * 可取值: + * "none" - 动画完成后不做任何操作; + * "hide" - 动画完成后隐藏窗口; + * "close" - 动画完成后关闭窗口。 + * 默认值为"none"。 + * - none: 动画完成后不做任何操作 + * - hide: 动画完成后隐藏窗口 + * - close: 动画完成后关闭窗口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + action?: 'none' | 'hide' | 'close'; +} + +/** + * Webview窗口动画样式 + * 用于指定动画窗口的起始位置、目标位置等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewAnimationStyles { + /** + * 画窗口的起始左侧位置 + * 支持百分比、像素值,默认值为当前窗口的位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + fromLeft?: string; + /** + * 画窗口的目标左侧位置 + * 持百分比、像素值。 + * 注意:如果设置的位置与起始位置一直,则无动画效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + toLeft?: string; +} + +/** + * Webview窗口回弹样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewBounceStyle { + /** + * Webview窗口支持回弹效果的方向 + * 可通过此参数设置开启Webview哪个方向支持回弹效果。 + * 支持以下属性: + * top:表示窗口顶部支持回弹效果; + * left:表示窗口左侧支持回弹效果; + * right:表示窗口右侧支持回弹效果; + * bottom:表示窗口底部支持回弹效果。 + * **目前仅支持top属性** + * 属性值:用于指定可拖拽的范围,可取百分比,如"10%";像素值,如"100px";自动计算值,如"auto";无回弹效果值,如"none"; + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + position?: any; + /** + * Webview窗口回弹时停靠的位置 + * 开启窗口回弹效果后,当窗口中展现的内容滚动到头(顶部或底部)时,再拖拽时窗口整体内容将跟随移动,拖拽过程中将触发"dragBounce"事件,松开后自动回弹到停靠位置。 + * 支持以下属性: + * top:表示窗口顶部回弹时停靠的位置。 + * 属性值:用于指定窗口回弹的位置,可取百分比,如"5%";像素值,如"100px";自动计算值,如"auto",默认为可拖拽的范围值的一半; + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + changeoffset?: any; + /** + * Webview窗口侧滑时停靠的位置 + * 开启窗口回弹效果后,当窗口中展现的内容滚动到头(左侧或右侧)时,在拖拽时窗口整体内容将跟随移动,松开后自动停靠的侧滑位置,并触发"slideBounce"事件。 + * 支持以下属性: + * left:表示窗口左侧侧滑的位置; + * right:表示窗口右侧侧滑的位置。 + * 属性值:用于指定滑动后停靠的距离,可取百分比(left/right相对于窗口的宽度,top/bottom相对于窗口的高度),如"30%";像素值,如"100px";自动计算值,为可拖拽范围,如"auto"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + slideoffset?: any; + /** + * Webview窗口拖拽偏移的位置 + * 开启窗口回弹效果后,可以通过此属性值来主动设置拖拽的偏移位置,与手动操作拖拽至此偏移位置松开后的逻辑一致。 + * 支持以下属性: + * top:表示窗口顶部偏移的位置; + * left:表示窗口左侧偏移的位置; + * right:表示窗口右侧偏移的位置; + * bottom:表示窗口底部偏移的位置。 + * 属性值:用于指定偏移的位置,可取百分比,如"5%";像素值,如"100px";有效值范围为0到position属性定义的位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + offset?: any; + /** + * Webview窗口是否阻止touch事件传递给DOM元素 + * 设置为true表示阻止touch事件,设置为false表示不阻止touch事件。当开启侧滑功能(左侧滑和右侧滑)时默认值为true,否则为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + preventTouchEvent?: boolean; +} + +/** + * Webview窗口内容动画参数 + * 指定动画的类型、持续时间等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewContentAnimationOptions { + /** + * 动画类型 + * 可取值:"shrink" - 从上到下分块收缩清除窗口动画。 + * - shrink: 从上到下分块清除动画 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + type?: 'shrink'; + /** + * 动画持续时间 + * 单位为毫秒,默认值为200ms。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + duration?: number; + /** + * 动画帧数 + * 必须为大于0的整数,默认值为12。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + frames?: number; + /** + * 动画作用区域 + * 支持以下属性: + * top - 区域距离控件顶部的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的高度),默认值为'0px'; + * bottom - 区域距离控件底部的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的高度),默认值为'0px'; + * left - 区域距离控件左侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'; + * right - 区域距离控件右侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'。 + * 如“{top:'44px',bottom:'48px'}”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + region?: any; +} + +/** + * 原生控件在窗口中停靠的方式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewDock { + /** + * 控件停靠则页面顶部 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + top?: string; + /** + * 控件停靠在页面底部 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + bottom?: string; + /** + * 控件停靠在页面右侧 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + right?: string; + /** + * 控件停靠在页面左侧 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + left?: string; +} + +/** + * Webview窗口滑动事件数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewDragEvent { + /** + * 手势类型 + * 可取值: + * "rtl" - 从右向左滑动手势; + * "left" - 向左滑动手势,与rtl一致; + * "ltr" - 从左向右滑动手势; + * "right" - 向右滑动手势,与ltr一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + direction?: string; + /** + * 窗口滑动类型 + * 可取值: + * "start" - 表示开始滑动操作; + * "move" - 表示正在滑动; + * "end" - 表示滑动操作结束。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + type?: string; + /** + * 窗口滑动结果 + * 可取值: + * "true" - 表示滑动操作成功; + * "false" - 表示滑动操作失败(恢复到滑动前的状态); + * "undefined" - 无状态值(当type值为"end"时返回此值)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + result?: string; + /** + * 当前操作窗口标识 + * 当type值为"start"/"move"时,保存当前操作窗口(或View控件)的标识; + * 当type值为"end"时保存滑动操作后显示窗口(或View控件)的标识(即result值为"true"则认为关联窗口显示,result值为false则认为主窗口显示)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + id?: string; + /** + * 关联窗口标识 + * 滑动操作关联窗口(或View控件)的标识。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + otherId?: string; + /** + * 主窗口标识 + * 滑动操作主窗口(或View控件)的标识。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + targetId?: string; + /** + * 滑动进度 + * 滑动进度位置信息,取值范围为0-100,如20表示滑动了总距离的20%: + * 当type值为"start"时progress值为0; + * 当type值为"end"时如果result为true则progress值为0,如果result为false则progress值为100; + * 当type值为"move"时,保存当前滑动的进度信息(注:多次触发move事件)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + progress?: number; +} + +/** + * 窗口手势操作参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewDragOptions { + /** + * 滑屏操作回调事件触发步长 + * 用于设置滑屏回调事件触发频率,取值范围为1-100,值越小触发频率越高,值越大触发频率越小,默认值为20。 + * 如设置值为20,则表示滑屏操作移动距离超过可移动范围的20%则触发一次回调事件,可通过回调函数参数(WebviewDragEvent)的progress属性获取。 + * 注意:触发频率过大会影响效率,开发者需谨慎设置此值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + callbackStep?: number; + /** + * 设置的手势类型 + * 可取值: + * 可取值: + * "rtl" - 从右向左滑动手势; + * "left" - 向左滑动手势,与rtl一致; + * "ltr" - 从左向右滑动手势; + * "right" - 向右滑动手势,与ltr一致。 + * - rtl: 从右向左滑动手势 + * - left: 向左滑动手势,与rtl一致 + * - ltr: 从左向右滑动手势 + * - right: 向右滑动手势,与ltr一致 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + direction?: 'rtl' | 'left' | 'ltr' | 'right'; + /** + * 滑动手势模式 + * 可取值: + * "followFinger" - 当前Webview窗口跟随手指滑动; + * "silent" - 当前Webview窗口不跟随手指滑动; + * "bounce" - 当前Webview窗口自动回弹(松手后窗口恢复到拖动前的位置),通常可通过设置此模式来实现Tab项无法继续滑动切换自动回弹效果。 + * - followFinger: 当前Webview窗口跟随手指滑动 + * - silent: 当前Webview窗口不跟随手指滑动 + * - bounce: 当前Webview窗口自动回弹 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + moveMode?: 'followFinger' | 'silent' | 'bounce'; +} + +/** + * 手势操作关联对象参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewDragOtherViewOptions { + /** + * 手势关联对象 + * 可取值Webview窗口的id(String类型)、Webview窗口对象、原生View窗口对象(plus.nativeObj.View)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + view?: string; + /** + * 滑动模式 + * 可取值: + * "follow" - 同步跟随主Webview窗口滑动; + * "silent" - 不跟随主Webview窗口滑动。 + * - follow: 同步跟随主Webview窗口滑动 + * - silent: 不跟随主Webview窗口滑动 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + moveMode?: 'follow' | 'silent'; +} + +/** + * 截屏绘制操作参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewDrawOptions { + /** + * 截屏图片的位深 + * 可取值: + * "RGB565" - RGB565彩色模式,一个像素占两个字节; + * "ARGB" - ARGB彩色模式,保存透明度信息。 + * - RGB565: + * RGB565彩色模式,一个像素占两个字节。 + * + * - ARGB: + * ARGB彩色模式,保存透明度信息。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + bit?: 'RGB565' | 'ARGB'; + /** + * 是否检测截屏图片是否为空白 + * 可取值: + * true - 表示检测到截屏到空白图片时认为操作失败(触发错误回调函数); + * false - 表示不检测,即使为空白图片仍然返回成功。 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + check?: boolean; + /** + * 设置截屏区域 + * 相对于Webview窗口的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + clip?: PlusNativeObj; + /** + * 是否检测当前是否弹出软键盘 + * 可取值: + * true - 表示检测到弹出软键盘是认为截屏操作失败(触发错误回调函数); + * false - 表示不检测软键盘状态,直接截屏。 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + checkKeyboard?: boolean; +} + +/** + * 窗口收藏参数 + * 在流应用环境中调用收藏功能时使用的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewFavoriteOptions { + /** + * 收藏时显示的图标 + * 在收藏列表中显示的图标,默认使用应用图标。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + icon?: string; + /** + * 收藏时显示的标题 + * 在收藏列表中显示的标题字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + title?: string; + /** + * 收藏的页面地址 + * 必须是网络地址。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + href?: string; +} + +/** + * 创建加载HTML数据参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewLoadDataOptions { + /** + * 页面的Base URL + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + baseURL?: string; + /** + * HTML数据的数据类型 + * 默认值为"text/html"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + mimeType?: string; + /** + * HTML数据的编码类型 + * 默认值为"utf-8"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + encoding?: string; +} + +/** + * 窗口的分享参数 + * 在流应用环境中调用分享功能时使用的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewShareOptions { + /** + * 分享时使用的图标 + * 默认使用应用图标。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + icon?: string; + /** + * 分享时使用的标题 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + title?: string; + /** + * 分享时使用的链接地址 + * 必须是网络地址。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + href?: string; +} + +/** + * 窗口原生子View控件样式 + * 可设置原生控件的标识、大小、位置以及绘制的内容等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewSubNViewStyles { + /** + * 原生子View控件的标识 + * 可通过plus.nativeObj.View.getViewById(id)方法传入此标识来获取子View控件对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + id?: string; + /** + * 原生子View控件类型 + * 可取值: + * "NView" - 原生子View控件(plus.nativeObj.NView); + * "ImageSlider" - 原生图片轮播控件(plus.nativeObj.ImageSlider)。 + * 默认值为"NView"。 + * - NView: + * 原生子View控件(plus.nativeObj.NView) + * + * - ImageSlider: + * 原生图片轮播控件(plus.nativeObj.ImageSlider) + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + type?: 'NView' | 'ImageSlider'; + /** + * 原生子View控件的样式 + * 可设置原生控件的位置、大小等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + styles?: PlusNativeObjViewStyles; + /** + * 原生子View控件初始绘制内容 + * 可设置绘制图片、矩形区域、文本等内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + tags?: any []; +} + +/** + * 窗口标题栏控件样式 + * 标题栏控件固定高度为44px,可通过Webview窗口对象的getTitleNView方法获取标题栏原生控件对象动态绘制内容。 + * 可以通过WebviewObject对象的getTitleNView()获取标题栏的NView对象,然后调用其setStyle方法更新样式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewTitleNViewStyles { + /** + * 标题栏控件是否显示左侧返回按钮 + * 可取值: + * "true" - 显示返回按钮; + * "false" - 不显示返回按钮。 + * 默认值为"false"。 + * 返回按钮的颜色为窗口标题文字颜色,按下时颜色自动调整透明度为0.3。 + * 点击返回按钮的逻辑与按下系统返回键逻辑一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + autoBackButton?: boolean; + /** + * 标题栏控件的背景颜色 + * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景,默认值为"#F7F7F7"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + backgroundColor?: string; + /** + * 标题栏上的自定义按钮 + * 创建的自定义按钮数目不限制,实际应用中建议最多设置4个按钮(包括左侧返回按钮)。 + * 注意:此属性不支持动态修改,仅在创建titleNView时设置有效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + buttons?: PlusWebview []; + /** + * 标题栏控件变化作用范围 + * 仅在type值为transparent时有效,页面滚动时标题栏背景透明度将发生变化。 + * 当页面滚动到指定偏移量时标题栏背景变为完全不透明。 + * 支持百分比、像素值,默认为'132px'。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + coverage?: string; + /** + * 标题栏控件是否显示Home按钮 + * 可取值: + * "true" - 显示Home按钮; + * "false" - 不显示Home按钮。 + * 默认值为"false"。 + * Home按钮的颜色为窗口标题文字颜色,按下时颜色自动调整透明度为0.3。 + * 点击Home按钮的逻辑为关闭所有非首页窗口,显示首页窗口。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + homeButton?: boolean; + /** + * 内边距 + * 标题栏左右的内边距,单位为px(逻辑像素值),如"10px"表示10逻辑像素值。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + padding?: string; + /** + * 右内边距 + * 标题栏右侧内边距,单位为px(逻辑像素值),如"10px"表示10逻辑像素值。 + * 默认值为"0px",优先级padding-right > padding。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'padding-right'?: string; + /** + * 左内边距 + * 标题栏左侧内边距,单位为px(逻辑像素值),如"10px"表示10逻辑像素值。 + * 默认值为"0px",优先级padding-left > padding。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + 'padding-left'?: string; + /** + * 标题栏控件的进度条样式 + * 设置此属性则在标题栏控件的底部显示进度条,可配置进度条颜色值即高度。 + * 设置此属性值为undefined或null则隐藏进度条。 + * 默认不显示底部进度条。 + * 注意:此属性将废弃,推荐使用WebviewStyles的progress。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + progress?: PlusWebviewWebviewProgressStyles; + /** + * 标题栏控件的底部分割线 + * 设置此属性则在标题栏控件的底部显示分割线,可配置颜色值及高度。 + * 设置此属性值为undefined或null则隐藏分割线。 + * 默认不显示底部分割线。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + splitLine?: PlusWebviewWebviewSplitLineStyles; + /** + * 标题栏上初始自定义绘制内容 + * 可用于设置自定义绘制图片、矩形区域、文本等内容。 + * 注意:此属性不支持动态修改,仅在创建titleNView时设置有效,如果需要更新绘制内容可根据tags的id调用draw方法操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + tags?: any []; + /** + * 标题栏控件的标题文字颜色 + * 颜色值格式为"#RRGGBB",如"#FF0000"表示标题文字颜色为红色,默认值为"#000000"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + titleColor?: string; + /** + * 标题栏控件的标题文字超出显示区域时处理方式 + * 可取值: + * "clip" - 超出显示区域时内容裁剪; + * "ellipsis" - 超出显示区域时尾部显示省略标记(...)。 + * 默认值为"ellipsis"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + titleOverflow?: string; + /** + * 标题栏控件的标题文字内容 + * 在标题栏控件居中(水平和垂直)显示,左右边距为88px,如果文本过长则尾部裁剪(加三个点"...")显示。 + * 当不设置titleText属性或属性值为undefined/null时,使用当前Webview窗口加载页面的标题,并自动同步更新页面的标题。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + titleText?: string; + /** + * 标题栏控件的标题文字字体大小 + * 字体大小单位为像素,如"20px"表示字体大小为20像素,默认值为17像素。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + titleSize?: string; + /** + * 标题栏控件样式 + * 可取值: + * "default" - 默认样式,顶部停靠显示,挤压Webview页面内容显示区域; + * "transparent" - 透明样式,顶部沉浸式显示覆盖Webview页面内容,标题栏上内容(除按钮外)全部透明,当页面滚动时透明度逐渐变化,直到不透明显示。 + * 默认值为"default"。 + * 注意:此属性不支持动态更新。 + * - default: + * 默认样式,顶部停靠显示,挤压Webview页面内容显示区域 + * + * - transparent: + * 透明样式,顶部沉浸式显示覆盖Webview页面内容,标题栏上内容(除按钮外)全部透明,当页面滚动时透明度逐渐变化,直到不透明显示 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + type?: 'default' | 'transparent'; +} + +/** + * 窗口标题栏自定义按钮样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewTitleNViewButtonStyles { + /** + * 按钮样式 + * 运行环境中内置按钮样式直接使用,内置样式忽略fontSrc和text属性。 + * 可取值: + * "forward" - 前进按钮; + * "back" - 后退按钮; + * "share" - 分享按钮; + * "favorite" - 收藏按钮; + * "home" - 主页按钮; + * "menu" - 菜单按钮; + * "close" - 关闭按钮; + * "none" - 无样式。 + * 默认值为无样式("none"),需通过text属性设置按钮上显示的内容、通过fontSrc属性设置使用的字体库。 + * - forward: 前进按钮 + * - back: 后退按钮 + * - share: 分享按钮 + * - favorite: 收藏按钮 + * - home: 主页按钮 + * - menu: 菜单按钮 + * - close: 关闭按钮 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + type?: 'forward' | 'back' | 'share' | 'favorite' | 'home' | 'menu' | 'close'; + /** + * 按钮的背景颜色 + * 仅在标题栏type=transparent时生效,当标题栏透明时按钮显示的背景颜色。 + * 可取值#RRGGBB和rgba格式颜色字符串,默认值为灰色半透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + background?: string; + /** + * 按钮上显示的角标文本 + * 最多显示3个字符,超过则显示为...。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + badgeText?: string; + /** + * 按钮上文字颜色 + * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色返回键; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为窗口标题栏控件的标题文字颜色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + color?: string; + /** + * 按下状态按钮文字颜色 + * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色返回键; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为color属性值自动调整透明度为0.3。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + colorPressed?: string; + /** + * 按钮在标题栏上的显示位置 + * 可取值: + * "right" - 在标题栏中靠右排列显示; + * "left" - 在标题栏中靠左侧排列显示(在返回键后)。 + * 默认值为"right"。 + * - right: + * 在标题栏中靠右排列显示 + * + * - left: + * 在标题栏中靠左侧排列显示(在返回键后) + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + float?: 'right' | 'left'; + /** + * 按钮上文字的粗细 + * 可取值: + * "normal" - 标准字体; + * "bold" - 加粗字体。 + * 默认值为"normal"。 + * - normal: + * 标准字体 + * + * - bold: + * 加粗字体 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + fontWeight?: 'normal' | 'bold'; + /** + * 按钮上文字大小 + * 可取值:字体高度像素值,数字加"px"格式字符串,如"22px"。 + * 窗口标题栏为透明样式(type="transparent")时,默认值为"22px"; + * 窗口标题栏为默认样式(type="default")时,默认值为"27px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + fontSize?: string; + /** + * 按钮上文字使用的字体文件路径 + * 字体文件路径支持以下类型: + * 相对路径 - 相对于当前页面的host位置,如"a.ttf",注意当前页面为网络地址则不支持; + * 绝对路径 - 系统绝对路径,如Android平台"/sdcard/a.ttf",此类路径通常通过其它5+ API获取的; + * 扩展相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_www/a.ttf"; + * 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + fontSrc?: string; + /** + * 按钮点击后触发的回调函数 + * 回调函数中将返回此JSON对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + onclick?: (result: any) => void; + /** + * 按钮上是否显示红点 + * 设置为true则显示红点,false则不显示红点。默认值为false。 + * 注意:当设置了角标文本时红点不显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + redDot?: boolean; + /** + * 是否显示选择指示图标 + * 设置为true则显示选择指示图标(向下箭头),颜色与文字颜色一致; + * false则不显示。默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + select?: boolean; + /** + * 按钮上显示的文字 + * 推荐使用一个字符,超过一个字符可能无法正常显示,使用字体图标时unicode字符表示必须'\u'开头,如"\ue123"(注意不能写成"\e123")。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + text?: string; + /** + * 按钮的宽度 + * 可取值: + * "*px" - 逻辑像素值,如"10px"表示10逻辑像素值,按钮的内容居中显示; + * "auto" - 自定计算宽度,根据内容自动调整按钮宽度。 + * 默认值为"44px"(适合字体图标)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + width?: string; +} + +/** + * 标题栏控件的进度条样式 + * 显示在标题栏控件底部。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewProgressStyles { + /** + * 进度条颜色 + * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色分割线; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为"#00FF00"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + color?: string; + /** + * 进度条高度 + * 可取值:像素值(逻辑像素),支持小数点,如"1px"表示1像素高;百分比,如"1%",相对于标题栏控件的高度。 + * 默认值为"2px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + height?: string; +} + +/** + * 窗口标题栏控件的分割线样式 + * 显示在标题栏控件底部。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewSplitLineStyles { + /** + * 底部分割线颜色 + * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色分割线; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为"#CCCCCC"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + color?: string; + /** + * 底部分割线高度 + * 可取值:像素值(逻辑像素),支持小数点,如"1px"表示1像素高;百分比,如"1%",相对于标题栏控件的高度。 + * 默认值为"1px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + height?: string; +} + +/** + * Webview窗口事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewEvent { + /** + * Webview窗口关闭事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口关闭时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + close?: string; + /** + * Webview窗口回弹事件 + * 通过WebviewObject对象的setBounce方法开启回弹效果设置顶部下拉回弹changeoffset属性后,当用户向下拖拽窗口时触发发此事件,回调函数类型为BounceEventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + dragBounce?: string; + /** + * Webview窗口回弹事件 + * 通过WebviewObject对象的setBounce方法开启回弹效果设置左右侧侧滑slideoffset属性后,当用户向左右侧拖拽窗口侧滑时触发发此事件,回调函数类型为BounceEventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + slideBounce?: string; + /** + * Webview窗口加载错误事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口加载错误时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + error?: string; + /** + * Webview窗口隐藏事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口隐藏(窗口动画完成后)时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + hide?: string; + /** + * Webview窗口页面开始加载事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口开始加载新页面时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + loading?: string; + /** + * Webview窗口页面加载完成事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口页面加载完成时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + loaded?: string; + /** + * Webview窗口显示遮罩层时点击事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口通过mask属性设置显示遮罩层并且点击时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + maskClick?: string; + /** + * Webview窗口开始渲染事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口开始渲染内容时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + rendering?: string; + /** + * Webview窗口渲染完成事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口渲染完成时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + rendered?: string; + /** + * Webview窗口显示事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口显示(窗口动画完成后)时触发此事件,回调函数类型为EventCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + show?: string; + /** + * Webview加载页面标题更新事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口加载新页面更新标题时触发此事件,回调函数类型为SuccessCallback。 + * 注意:此事件会先于loaded事件触发,通常在加载网络页面时通过此事件可更快获取到页面的标题。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + titleUpdate?: string; + /** + * Webview窗口接收到触屏事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当用户操作按下到Webview窗口时触发此事件,回调函数类型为SuccessCallback。 + * 注意:每按下屏幕触发一次此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + touchstart?: string; + /** + * Webview窗口侧滑返回事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口侧滑返回时触发此事件,回调函数类型为PopGestureCallback。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + popGesture?: string; + /** + * Webview窗口加载进度变化事件 + * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口加载页面进度变化时触发此事件。 + * 回调函数原型为void PorgressCandedCallback(Event e),可通过e.progress获取窗口加载进度,取值范围为0-100。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + progressChanged?: string; + /** + * Webview窗口下拉刷新事件 + * Webview窗口打开下拉刷新功能后,用户操作下拉刷新时或调用beginPullToRefresh方法时触发,用于通知业务逻辑可以开始执行刷新操作。 + * 更新操作完成后调用窗口的endPullToRefresh方法结束下拉刷新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + pullToRefresh?: string; +} + +/** + * JSON对象,原生窗口扩展参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewExtraOptions { + /** + * 窗口动画加速 + * 开启窗口动画加速功能可优化窗口动画效果,提升动画流程度,可避免部分设备上打开(关闭)窗口闪屏的问题。 + * 可取值: + * "auto" - 自动优化窗口动画; + * "none" - 关闭窗口动画加速功能; + * "capture" - 使用截屏方式加速窗口动画。 + * 默认值为"auto"。 + * - auto: + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + acceleration?: 'auto'; + /** + * 窗口动画加速时使用的图片 + * 当使用截屏方式加速窗口动画时,可设置已经创建好的截屏图片,此时不会进行实时截屏操作,加速窗口动画响应时间,提升用户体验。 + * 如果未指定截屏图片,则实时截取当前Webview窗口对象的图片进行动画操作。 + * 如果窗口未使用截屏方式加速动画,则忽略此参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + capture?: PlusNativeObjBitmap; + /** + * 关联窗口动画使用的图片 + * 当使用截屏方式加速窗口动画时,可设置已经创建好的截屏图片,此时不会进行实时截屏操作,加速关联窗口动画响应时间,提升用户体验。 + * 如果未指定截屏图片,则实时截取关联Webview窗口对象的图片进行动画操作。 + * 如果窗口未使用截屏方式加速动画,则忽略此参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + otherCapture?: PlusNativeObjBitmap; +} + +/** + * 原生控件在窗口中显示的位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewPosition { + /** + * 控件在页面中正常定位,如果页面存在滚动条则随窗口内容滚动 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + static?: string; + /** + * 控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + absolute?: string; + /** + * 控件在页面中停靠,停靠的位置通过dock属性进行定义 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + dock?: string; +} + +/** + * Webview窗口下拉刷新样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewPullToRefreshStyles { + /** + * 是否开启Webview窗口的下拉刷新功能 + * true表示开启窗口的下拉刷新功能; + * false表示关闭窗口的下拉刷新功能。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + support?: boolean; + /** + * 下拉刷新控件颜色 + * 颜色值格式为"#RRGGBB",如"#FF0000"为设置下拉属性控件为红色,默认值为"#2BD009"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + color?: string; + /** + * 下拉刷新样式 + * 用于定义下拉刷新风格样式,可取值: + * "default" - 经典下拉刷新样式(下拉拖动时页面内容跟随); + * "circle" - 圆圈样式下拉刷新控件样式(下拉拖动时仅刷新控件跟随)。 + * 默认值为"default"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + style?: string; + /** + * 窗口的下拉刷新控件进入刷新状态的拉拽高度 + * 支持百分比,如"10%";像素值,如"50px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + height?: string; + /** + * 窗口可下拉拖拽的范围 + * 支持百分比,如"10%";像素值,如"50px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + range?: string; + /** + * 下拉刷新控件的起始位置 + * 仅对"circle"样式下拉刷新控件有效,用于定义刷新控件下拉时的起始位置。 + * 相对于Webview的顶部偏移量,支持百分比,如"10%";像素值,如"50px"。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + offset?: string; + /** + * 在下拉可刷新状态时显示的内容 + * 支持以下属性: + * caption:在下拉可刷新状态时下拉刷新控件上显示的标题内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + contentdown?: any; + /** + * 在释放可刷新状态时显示的内容 + * 支持以下属性: + * caption:在释放可刷新状态时下拉刷新控件上显示的标题内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + contentover?: any; + /** + * 在正在刷新状态时显示的内容 + * 支持以下属性: + * caption:在正在刷新状态时下拉刷新控件上显示的标题内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + contentrefresh?: any; +} + +/** + * Webview窗口rendered事件参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewRenderedEventOptions { + /** + * 判断窗口渲染完成类型 + * 可取值: + * "top"-从顶部向下偏移22px横线截屏检测渲染是否完成; + * "bottom"-从底部向上偏移25px横线检测渲染是否完成; + * "center"-从中间横线检测渲染是否完成; + * "auto"为全屏检测(左、中、右三条竖线)。 + * 默认值为"auto"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + type?: string; + /** + * 判断窗口渲染完成间隔时间 + * 单位为ms(毫秒),默认值为150ms。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + interval?: number; +} + +/** + * 替换H5标准API配置信息 + * 目前仅支持替换H5标准定位接口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewReplaceWebApiOptions { + /** + * 替换H5标准定位接口(navigator.geolocation.*) + * 由于网络原因,在部分手机上可能无法调用标准H5定位接口(navigator.geolocation.*)获取定位数据,此时可以通过此属性配置使用原生定位模块替换标准H5定位接口,可取值: + * "alldevice" - 在所有设备上替换标准H5定位接口(navigator.geolocation.*); + * "auto" - 自动替换H5标准定位接口,仅在调用标准H5定位接口无法获取数据的设备上替换; + * "none" - 不替换H5标准定位接口(navigator.geolocation.*)。 + * 默认值为"none"。 + * 注意:替换H5标准定位接口,会导致页面加载速度延迟100ms左右,推荐使用"auto"模式。 + * - alldevice: + * 强制替换H5标准定位接口(navigator.geolocation.*) + * + * - auto: + * 自动替换标准H5定位接口,仅在调用标准H5定位接口无法获取数据的设备上替换 + * + * - none: + * 不替换标准H5定位接口(navigator.geolocation.*) + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + geolocation?: 'alldevice' | 'auto' | 'none'; +} + +/** + * JSON对象,Webview窗口的系统状态栏区域样式 + * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewStatusbarStyles { + /** + * 系统状态栏区域背景颜色 + * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景。 + * 默认值为应用manifest.json中plus->statusbar->background属性配置的值,如果未配置此属性值,则使用系统默认状态栏的背景颜色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + background?: string; +} + +/** + * JSON对象,Webview窗口对象的样式 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewStyles { + /** + * 窗口加载页面时额外添加的HTTP请求头数据 + * 仅在Webview窗口第一次加载页面时使用,如用户点击的触发的链接跳转则不再添加此额外请求头数据。 + * 如果Webview窗口非第一次加载页面时也需要额外添加HTTP请求头数据,可通过loadURL()方法的参数设置。 + * 如果HTTP请求头中已经包含需要额外添加的头数据,则添加的请求数据覆盖默认值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + additionalHttpHeaders?: any; + /** + * 窗口动画优化方式 + * 可取值: + * "auto" - 如果窗口中存在titleNView或subNViews,窗口动画时真实Webview控件从动画窗口中移除加速(避免真实Webview渲染影响动画效率); + * "none" - 窗口动画不使用优化。 + * 默认值为"auto"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + animationOptimization?: string; + /** + * 窗口的缓存模式 + * 可取值: + * "default" - 根据cache-control决定是否使用缓存数据,如果存在缓存并且没有过期则使用本地缓存资源,否则从网络获取; + * "cacheElseNetwork" - 只要存在缓存(即使过期)数据则使用,否则从网络获取; + * "noCache" - 不使用缓存数据,全部从网络获取; + * "cacheOnly" - 仅使用缓存数据,不从网络获取(注:如果没有缓存数据则会导致加载失败)。 + * 默认使用"default"。 + * - default: + * 根据cache-control决定是否使用缓存数据,如果存在缓存并且没有过期则使用本地缓存资源,否则从网络获取。 + * + * - cacheElseNetwork: + * 只要存在缓存(即使过期)数据则使用,否则从网络获取。 + * + * - noCache: + * 不使用缓存数据,全部从网络获取。 + * + * - cacheOnly: + * 仅使用缓存数据,不从网络获取(注:如果没有缓存数据则会导致加载失败)。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + cachemode?: 'default' | 'cacheElseNetwork' | 'noCache' | 'cacheOnly'; + /** + * Webview窗口自动处理返回键逻辑 + * 当Webview窗口在显示栈顶,并且Webview窗口中没有调用JS监听返回键(plus.key.addEventListener('backbutton',...))时按下返回键响应行为。 + * 可取值: + * "hide" - 隐藏Webview窗口,隐藏动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”); + * "close" - 关闭Webview窗口,关闭动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”) ; + * "none" - 不做操作,将返回键传递给下一Webview窗口处理; + * "quit" - 退出应用。 + * - hide: + * 隐藏Webview窗口,隐藏动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”)。 + * + * - close: + * 关闭Webview窗口,关闭动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”)。 + * + * - none: + * 不做操作,将返回键传递给下一Webview窗口处理。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + backButtonAutoControl?: 'hide' | 'close' | 'none'; + /** + * 窗口的背景颜色 + * 窗口空白区域的背景模式,设置background为颜色值(参考CSS Color Names,可取值/十六进制值/rgb值/rgba值),窗口为独占模式显示(占整个屏幕区域); + * 设置background为“transparent”,则表示窗口背景透明,为非独占模式。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + background?: string; + /** + * 窗口顶部背景颜色值 + * 窗口内容滚动到顶部下拉时可见。 + * 可取值: + * "#RRGGBB"格式字符串,如"#FF0000"表示红色; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + backgroundColorTop?: string; + /** + * 窗口底部背景颜色 + * 窗口内容滚动到底部上拉时可见。 + * 可取值: + * "#RRGGBB"格式字符串,如"#FF0000"表示红色; + * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 + * 默认值为透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + backgroundColorBottom?: string; + /** + * 是否阻塞网络图片的加载 + * 布尔类型,true表示阻塞,false表示不阻塞,默认值为false。 + * 阻塞后Webview窗口将不加载页面中使用的所有网络图片,可通过Webview窗口对象的setBlockNetWorkImage()方法动态修改此状态。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + blockNetworkImage?: boolean; + /** + * 窗口垂直向上的偏移量 + * 支持百分比、像素值,默认值无值(根据top和height属性值来自动计算)。 + * 当同时设置了top和height值时,忽略此属性值; + * 当未设置height值时,可通过top和bottom属性值来确定窗口的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + bottom?: string; + /** + * 窗口遇到边框是否有反弹效果 + * 可取值: + * "none" - 表示没有反弹效果; + * "vertical" - 表示垂直方向有反弹效果; + * "horizontal" - 表示水平方向有反弹效果; + * "all" - 表示垂直和水平方向都有反弹效果。 + * 默认值为"none"。 + * - none: 没有反弹效果 + * - vertical: 垂直方向有反弹效果 + * - horizontal: 水平方向有反弹效果 + * - all: 垂直和水平方向都有反弹效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + bounce?: 'none' | 'vertical' | 'horizontal' | 'all'; + /** + * 窗口回弹效果区域的背景 + * 窗口回弹效果区域背景可支持颜色值或图片: + * 颜色值格式为"#RRGGBB",如"#FFFFFF"为设置白色背景; + * 背景图为"url(%image path%)",如"url(./icon.png)"为设置icon.png为背景图,图片采用平铺模式绘制。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + bounceBackground?: string; + /** + * 窗口内容停止滑动的减速度 + * 当Webview加载的内容超过其高度时,可以拖拽滑动内容,decelerationRate属性控制手指松开后页面滑动的速度。 + * 设置值越大手指松开后的滑动速度越快(滑动距离越长),其值域范围为0.0-1.0,默认值为0.989。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + decelerationRate?: number; + /** + * 窗口的停靠方式 + * 当Webview窗口添加到另外一个窗口中时,停靠方式才会生效,采用停靠方式添加会导致原Webview窗口自动调整其大小避免其内容被子窗口盖住。 + * 可取值:"top",控件停靠则页面顶部;"bottom",控件停靠在页面底部;"right",控件停靠在页面右侧;"left",控件停靠在页面左侧。 + * 默认值为"bottom"。 + * - top: 控件停靠则页面顶部 + * - bottom: 控件停靠在页面底部 + * - right: 控件停靠在页面右侧 + * - left: 控件停靠在页面左侧 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + dock?: 'top' | 'bottom' | 'right' | 'left'; + /** + * 窗口加载错误时跳转的页面地址 + * 当Webview窗口无法加载指定的url地址时(如本地页面不存在,或者无法访问的网络地址),此时会自动跳转到指定的错误页面地址(仅支持本地页面地址)。 + * 设置为“none”则关闭跳转到错误页面功能,此时页面显示Webview默认的错误页面内容。默认使用5+ Runtime内置的错误页面。 + * - none: 关闭加载页面错误自动跳转功能 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + errorPage?: 'none'; + /** + * 替换H5标准API + * 用于解决在部分设备上调用H5标准定位接口可能无法获取定位数据的问题。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + replacewebapi?: PlusWebviewWebviewReplaceWebApiOptions; + /** + * 窗口是否开启硬件加速 + * 布尔类型,true表示开启硬件加速,false表示不开启硬件加速,默认情况5+ Runtime会根据设备实际支持情况自动选择是否开启硬件加速,可以通过plus.webview.defaultHardwareAccelerated()方法获取默认Webview是否开启硬件加速。 + * 由于不同设备对硬件加速的支持情况存在差异,开启硬件加速能加速HTML页面的渲染,但也会消耗更多的系统资源,从而导致在部分设备上可能出现闪屏、发虚、分块渲染等问题,因此在特定设备的特定页面如果出现以上问题需要手动设置关闭硬件加速来避免。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + hardwareAccelerated?: boolean; + /** + * 窗口的高度 + * 支持百分比、像素值,默认为100%。 + * 当未设置height属性值时,优先通过top和bottom属性值来计算窗口的高度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + height?: string; + /** + * 窗口使用的内核 + * 可取值: + * "WKWebview" - 在iOS8.0及以上系统使用WKWebview内核,低版本下仍然使用UIWebview内核; + * "UIWebview" - 在所有版本上都使用UIWebview内核。 + * 默认值为"UIWebview"。 + * WKWebview内核的优势是: + * 1. 滚动时懒加载的图片也可以实时渲染,UIWebview在滚动停止后才能渲染; + * 2. WKWebview的video支持AirPlay。 + * 但WKWebview也有些限制和不足,目前已知的问题有: + * 1. 不支持跨域设置cookie,即plus.navigator.setCookie()API无法使用; + * 2. 本地的HTML页面中的XHR不支持跨域访问,需使用plus.net.XMLHttpRequest来替换; + * 3. 不支持使用WebSQL,需使用indexDB来替换; + * 4. 不支持js原生混淆功能,需使用前端js混淆来替换; + * 5. 内存不足时会白屏。 + * 首页的Webview的kernel在manifest中配置(plus->kernel->ios)。 + * - WKWebview: + * 使用"WKWebview"内核。 + * + * - UIWebview: + * 使用"UIWebview"内核。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + kernel?: 'WKWebview' | 'UIWebview'; + /** + * 窗口水平向右的偏移量 + * 支持百分比、像素值,默认值为0px。 + * 未设置left属性值时,优先通过right和width属性值来计算窗口的left位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + left?: string; + /** + * 窗口的边距 + * 用于定位窗口的位置,支持auto,auto表示居中。若设置了left、right、top、bottom则对应的边距值失效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + margin?: string; + /** + * 窗口的遮罩 + * 用于设置Webview窗口的遮罩层样式,遮罩层会覆盖Webview中所有内容,包括子webview,并且截获webview的所有触屏事件,此时Webview窗口的点击操作会触发maskClick事件。 + * 字符串类型,可取值: + * rgba格式字符串,定义纯色遮罩层样式,如"rgba(0,0,0,0.5)",表示黑色半透明; + * "none",表示不使用遮罩层; + * 默认值为"none",即无遮罩层。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + mask?: string; + /** + * 窗口的不透明度 + * 0为全透明,1为不透明,默认值为1,即不透明。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + opacity?: number; + /** + * 控制Webview注入5+ API时机 + * 可取值: + * "ahead" - 尽量提前,拦截页面中网络js请求实现提前注入,如果没有拦截到js请求则在页面loaded时注入; + * "normal" - 页面loaded时注入; + * "later" - 较晚在注入,在loaded事件发生后2s再注入,plusready事件同样延迟; + * "none" - 不注入,页面无法调用5+ API,不触发plusready事件。 + * 默认值为"normal"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + plusrequire?: string; + /** + * 窗口的进度条样式 + * 设置此属性则在Webview窗口的顶部显示进度条,可配置进度条颜色及高度。 + * 设置此属性值为undefined或null则隐藏进度条。 + * 默认不显示进度条。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + progress?: PlusWebviewWebviewProgressStyles; + /** + * 窗口的侧滑返回功能 + * 可取值: + * "none"-无侧滑返回功能; + * "close"-侧滑返回关闭Webview窗口; + * "hide"-侧滑返回隐藏webview窗口。 + * - none: 无侧滑返回功能 + * - close: 侧滑返回关闭Webview窗口 + * - hide: 侧滑返回隐藏webview窗口 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + popGesture?: 'none' | 'close' | 'hide'; + /** + * 窗口下拉刷新配置 + * 设置窗口是否开启下拉刷新功能及样式。 + * 开启下拉刷新后可通过监听窗口的"pullToRefresh"事件处理下拉刷新业务逻辑,更新操作完成后调用窗口的endPullToRefresh方法结束下拉刷新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + pullToRefresh?: PlusWebviewWebviewPullToRefreshStyles; + /** + * 窗口渲染模式 + * 支持以下属性值: + * "onscreen" - Webview窗口在屏幕区可见时渲染,不可见时不进行渲染,此时能减少内存使用量; + * "always" - Webview在任何时候都渲染,在内存较大的设备上使用,被遮挡的窗口在此中模式下显示的时候会有更流畅的效果。 + * 默认值为"onscreen"。 + * 仅Android平台支持。 + * - onscreen: Webview窗口在屏幕区可见时渲染,不可见时不进行渲染,此时能减少内存使用量 + * - always: Webview在任何时候都渲染,在内存较大的设备上使用,被遮挡的窗口在此中模式下显示的时候会有更流畅的效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + render?: 'onscreen' | 'always'; + /** + * 窗口水平向左的偏移量 + * 支持百分比、像素值,默认无值(根据left和width属性值来自动计算)。 + * 当设置了left和width值时,忽略此属性值; + * 当未设置width值时,可通过left和bottom属性值来确定窗口的宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + right?: string; + /** + * 窗口是否可缩放 + * 窗口设置为可缩放(scalable:true)时,用户可通过双指操作放大或缩小页面,此时html页面可通过meta节点设置“name="viewport" content="user-scalable=no"”来限制页面不可缩放。 + * 窗口设置为不可缩放(scalable:false)时,用户不可通过双指操作放大或缩小页面,即使页面中的meta节点也无法开启可缩放功能。 + * 默认值为false,即不可缩放。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + scalable?: boolean; + /** + * 窗口是否显示滚动条 + * 用于控制窗口滚动条样式,可取值: + * "all":垂直和水平滚动条都显示; + * "vertical":仅显示垂直滚动条; + * "horizontal":仅显示水平滚动条; + * "none":垂直和水平滚动条都不显示。 + * 默认值为"all",即垂直和水平滚动条都显示。 + * 注意:显示滚动条的前提条件是窗口中的内容超过窗口显示的宽或高。 + * - all: 垂直和水平滚动条都显示 + * - vertical: 仅显示垂直滚动条 + * - horizontal: 仅显示水平滚动条 + * - none: 垂直和水平滚动条都不显示 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + scrollIndicator?: 'all' | 'vertical' | 'horizontal' | 'none'; + /** + * 点击设备的状态栏时是否滚动返回至顶部 + * true表示点击设备的状态栏可以滚动返回至顶部,false表示点击设备的状态栏不可以,默认值为true。 + * 此功能仅iOS平台支持,在iPhone上有且只有一个Webview窗口的scrollsToTop属性值为true时才生效,所以在显示和关闭Webview窗口时需动态更新所有Webview的scrollsToTop值,已确保此功能生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + scrollsToTop?: boolean; + /** + * 是否可分享窗口加载的链接地址 + * 在流应用环境(流应用/5+浏览器)中可通过分享按钮分享页面链接地址, + * 可取值: + * true - 可分享窗口加载页面链接地址; + * false - 不可分享窗口加载的页面链接地址,此时分享的是应用。 + * 默认值值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + shareable?: boolean; + /** + * 弹出系统软键盘模式 + * 可选值:“adjustPan”- 弹出软键盘时Webview窗口自动上移,以保证当前输入框可见;“adjustResize”- 自动调整Webview窗口大小(屏幕区域减去软键盘区域),同时自动滚动Webview保证输入框可见。 + * 默认值为“adjustPan”。 + * - adjustPan: 弹出软键盘时Webview窗口自动上移,以保证当前输入框可见 + * - adjustResize: 自动调整Webview窗口大小(屏幕区域减去软键盘区域),同时自动滚动Webview保证输入框可见 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + softinputMode?: 'adjustPan' | 'adjustResize'; + /** + * 窗口状态栏样式 + * 仅在应用设置为沉浸式状态栏样式下有效,设置此属性后将自动保留系统状态栏区域不被Webview窗口占用(即Webview窗口非沉浸式样式显示)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + statusbar?: PlusWebviewWebviewStatusbarStyles; + /** + * 定义窗口的原生子View控件 + * 数组类型,可通过配置项设置原生子View控件,每个配置项对应添加一个原生子View控件。 + * 通过Webview窗口的getSubNViews()方法可获取原生子View控件对象数组。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + subNViews?: PlusWebview []; + /** + * 定义窗口的标题栏控件样式 + * 设置此属性值则表明创建Webview窗口的标题栏控件,并可通过其属性值设置背景颜色、文本内容、文本颜色等。 + * 通过Webview窗口的getTitleNView()方法可获取标题栏控件对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + titleNView?: PlusWebviewWebviewTitleNViewStyles; + /** + * 窗口垂直向下的偏移量 + * 支持百分比、像素值,默认值为0px。 + * 未设置top属性值时,优先通过bottom和height属性值来计算窗口的top位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + top?: string; + /** + * 窗口定义窗口变换的动画效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + transition?: PlusWebviewWebviewTransition; + /** + * 窗口定义窗口变形效果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + transform?: PlusWebviewWebviewTransform; + /** + * Webview窗口的排版位置 + * 当Webview窗口添加到另外一个窗口中时,排版位置才会生效,排版位置决定子窗口在父窗口中的定位方式。 + * 可取值:"static",控件在页面中正常定位,如果页面存在滚动条则随窗口内容滚动;"absolute",控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动;"dock",控件在页面中停靠,停靠的位置由dock属性值决定。 + * 默认值为"absolute"。 + * - static: 控件在页面中正常定位,如果页面存在滚动条则随窗口内容滚动 + * - absolute: 控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动 + * - dock: 控件在页面中停靠,停靠的位置由dock属性值决定 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + position?: 'static' | 'absolute' | 'dock'; + /** + * 用户是否可选择内容 + * 可取值: + * true - 表示可选择内容,用户可通过长按来选择页面内容,如文本内容选择后可以弹出系统复制粘贴菜单; + * false - 表示不可选择内容,用户不可通过长按来选择页面内容。 + * 默认值为true。 + * 注意:在Web页面中可通过CSS的user-select对单个页面元素进行控制,前提是Webview对象的userSelect设置为true,否则CSS设置的user-select失效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + userSelect?: boolean; + /** + * 视频全屏播放时的显示方向 + * 可取值: + * "auto": 自动适配,如果当前页面竖屏,则竖屏显示;如果当前页面横盘显示,则横屏;如果当前页面自动感应,则自动感应横竖屏切换。 + * "portrait-primary": 竖屏正方向; + * "portrait-secondary": 竖屏反方向,屏幕正方向按顺时针旋转180°; + * "landscape-primary": 横屏正方向,屏幕正方向按顺时针旋转90°; + * "landscape-secondary": 横屏方向,屏幕正方向按顺时针旋转270°; + * "landscape": 横屏正方向或反方向,根据设备重力感应器自动调整; + * 默认值为“auto”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + videoFullscreen?: string; + /** + * 窗口的宽度 + * 支持百分比、像素值,默认为100%。未设置width属性值时,可同时设置left和right属性值改变窗口的默认宽度。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + width?: string; + /** + * 窗口的堆叠顺序值 + * 拥有更高堆叠顺序的窗口总是会处于堆叠顺序较低的窗口的前面,拥有相同堆叠顺序的窗口后调用show方法则在前面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + zindex?: number; +} + +/** + * 一组用于定义页面或控件变形的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewTransform { + /** + * 暂不支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + rotate?: string; + /** + * 暂不支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + translate?: string; + /** + * 暂不支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + scale?: string; + /** + * 暂不支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + skew?: string; + /** + * 暂不支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + matrix?: string; +} + +/** + * 一组用于定义页面或控件转换效果的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewTransition { + /** + * 产生变换效果的属性 + * 默认值为"all",暂不支持其它值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + property?: string; + /** + * 变换持续的时间 + * 默认值为0,即无动画效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + duration?: string; + /** + * 窗口变换效果 + * 可取值: + * "linear":匀速变化,匀速动画效果; + * "ease-in":匀加速变化,逐渐变快的动画效果; + * "ease-out":匀减速变化,逐渐变慢的动画效果; + * "ease-in-out":先加速后减速变化,先变快后变慢的动画效果。 + * 默认值为"ease-in-out"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + timingfunction?: string; +} + +/** + * 拦截Webview窗口资源请求的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewOverrideResourceOptions { + /** + * 区配需要拦截请求资源的URL地址 + * 支持正则表达式,默认值为空字符串(即不拦截)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + match?: string; + /** + * 拦截重定向的资源地址 + * 仅支持本地资源地址,如"_www"、"_doc"、"_downloads"、"_documents"等开头的路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + redirect?: string; + /** + * 重定向的资源数据类型 + * RFC2045/RFC2046/RFC2047/RFC2048/RFC2049规范中定义的数据类型。 + * 如普通文本(text/plain)、PNG图像(image/png)、GIF图形(image/gif)、JPEG图形(image/jpeg)。 + * 如果未指定mime类型,则根据重定向资源路径自动区配。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + mime?: string; + /** + * 重定向的资源数据编码 + * 如未设置,则使用默认值"UTF-8"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + encoding?: string; + /** + * 设置重定向资源数据的http头数据 + * 可设置标注http头数据(如Content-type),也可设置自定义数据。 + * 通常可通过此属性来设置拦截资源的缓存策略(如Cache-control)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + header?: any; +} + +/** + * 拦截Webview窗口URL请求的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewOverrideUrlOptions { + /** + * 拦截URL请求生效时机 + * 可取值: + * "instant" - 表示立即生效,即调用overrideUrlLoading方法后立即生效; + * "touchstart" - 表示用户操作Webview窗口(触发touchstart事件)后生效,如果用户没有操作Webview窗口则不对URL请求操作进行拦截处理。 + * 默认值为"instant"。 + * - instant: + * 立即生效,即调用overrideUrlLoading方法后立即生效。 + * + * - : + * 表示用户操作Webview窗口(触发touchstart事件)后生效。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + effect?: 'instant' | ''; + /** + * 拦截模式 + * 可取值: + * "allow"表示满足match属性定义的条件时不拦截url继续加载,不满足match属性定义的条件时拦截url跳转并触发callback回调; + * "reject"表示满足match属性定义的提交时拦截url跳转并触发callback回调,不满足match属性定义的条件时不拦截url继续加载。 + * 默认值为"reject"。 + * - allow: + * 满足match属性定义的条件时不拦截url继续加载,不满足match属性定义的条件时拦截url跳转并触发callback回调。 + * + * - reject: + * 满足match属性定义的提交时拦截url跳转并触发callback回调,不满足match属性定义的条件时不拦截url继续加载。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + mode?: 'allow' | 'reject'; + /** + * 区配是否需要处理的URL请求 + * 支持正则表达式,默认值为对所有URL地址生效(相当于正则表达式“.*”)。 + * 如果mode值为"allow"则允许区配的URL请求跳转,mode值为"reject"则拦截区配的URL请求。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + match?: string; + /** + * 排除拦截处理请求类型 + * 不拦截处理指定类型的URL请求,直接使用系统默认处理逻辑。 + * 可取值: + * "none"表示不排除任何URL请求(即拦截处理所有URL请求); + * "redirect"表示排除拦截处理301/302跳转的请求(谨慎使用,非a标签的href触发的URL请求可能会误判断为302跳转)。 + * 默认值为"none"。 + * - none: + * 不排除任何URL请求(即拦截处理所有URL请求)。 + * + * - redirect: + * 排除拦截处理301/302跳转的请求(谨慎使用,非a标签的href触发的URL请求可能会误判断为302跳转)。 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + exclude?: 'none' | 'redirect'; +} + +/** + * 监听Webview窗口资源加载的属性 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ +interface PlusWebviewWebviewListenResourceOptions { + /** + * 区配是否需要处理的URL资源 + * 支持正则表达式,默认值为对所有URL资源请求生效(相当于正则表达式“.*”)。 + * 如果Webview加载的资源区配条件,则触发回调事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) + */ + match?: string; +} + +/** + * XMLHttpRequest模块管理网络请求,与标准HTML中的XMLHttpRequest用途一致,差别在于前者可以进行跨域访问。通过plus.net可获取网络请求管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ +interface PlusNet { + /** + * 跨域网络请求对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + XMLHttpRequest?: PlusNetXMLHttpRequest; + /** + * HTTP请求进度事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + ProgressEvent?: PlusNetProgressEvent; +} + +/** + * 跨域网络请求对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ +interface PlusNetXMLHttpRequest { + /** + * HTTP 请求的状态 + * 当一个 XMLHttpRequest 初次创建时,这个属性的值从 0 开始,直到接收到完整的 HTTP 响应,这个值增加到 4。 + * 5 个状态中每一个都有一个相关联的非正式的名称,下表列出了状态、名称和含义: + * 0 Uninitialized,未初始化状态。XMLHttpRequest对象已创建或已被abort()方法重置。 + * 1 Open,open()方法已调用,但是send()方法未调用。请求还没有被发送。 + * 2 Sent,send()方法已调用,HTTP 请求已发送到Web服务器。未接收到响应。 + * 3 Receiving,所有响应头部都已经接收到。响应体开始接收但未完成。 + * 4 Loaded,HTTP响应已经完全接收。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + readyState?: number; + /** + * 请求从服务器接收到的响应数据 + * 如果没有从服务器接收到数据,则为null; + * 否则根据responseType类型决定: + * 如果responseType设置为空字符串或"text",则返回空字符串; + * 如果responseType设置为"document",则返回Document对象; + * 如果responseType设置为"json",则返回JSON对象; + * 若服务器返回的数据与设置的responseType类型不区配,则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + response?: string; + /** + * 请求从服务器接收到的响应数据(字符串数据) + * 如果还没有接收到数据的话,此属性值为空字符串; + * 如果readyState小于3,此属性值为空字符串; + * 如果readyState为3,此属性值返回目前已经接收的HTTP响应部分数据值; + * 如果readyState为4,此属性值保存了完整的HTTP响应数据体。 + * 如果HTTP请求返回的数据头中包含了Content-Type值中指定字符编码,就使用该编码,否则,使用UTF-8字符集。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + responseText?: string; + /** + * 请求响应数据response的类型 + * 默认值为空字符串,即reponse为String,类型可设置:"document"表示Document对象,"json"表示JSON对象,"text"表示字符串。 + * 此值必须在调用send方法之前设置,否则设置的值不生效,仍使用之前设置的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + responseType?: string; + /** + * 请求响应的Document对象 + * 对请求的响应,解析为 XML 并作为 Document 对象返回。 + * 如果请求未成功,或响应的数据无法被解析为XML,则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + responseXML?: string; + /** + * 服务器返回的HTTP状态代码 + * 服务器返回的HTTP状态代码,如200表示成功,而404表示"Not Found"错误; + * 当readyState小于3的时候此属性值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + status?: number; + /** + * 服务器返回的HTTP状态描述 + * 此属性值用名称而不是数字指定了请求的HTTP的状态代码。 + * 也就是说,当状态为200的时候它是"OK";当状态为404的时候它是"Not Found"。 + * 和status属性类似,当readyState小于3的时候读取这一属性会返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + statusText?: string; + /** + * 请求服务器的超时时间,单位为毫秒(ms) + * 数值类型,单位为ms,其默认值为120秒。 + * 超时时间为服务器响应请求的时间(不是Http请求完成的总时间),如果设置为0则表示永远不超时。 + * 必须在请求发起前设置,否则当前请求将不生效,在当前请求完成后重新发起新请求时生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + timeout?: number; + /** + * 是否支持跨域请求 + * 此对象创建的HTTP请求都支持跨域,所以永远返回true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + withCredentials?: boolean; + /** + * 网络请求状态发生变化事件 + * 网络请求状态发生变化时触发,通常在函数中判断对象的state属性值来获取当前请求的状态。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onreadystatechange?: () => void; + /** + * 网络请求开始事件 + * 通常在调用send方法开始发起HTTP请求时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onloadstart?: (result: PlusNetProgressEvent) => void; + /** + * 网络请求传输数据事件 + * 通常在HTTP请求链接已经建立,开始传输数据时触发,在数据传输的过程中可能多次触发,此事件与onreadystatechange事件触发状态3类似。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onprogress?: (result: PlusNetProgressEvent) => void; + /** + * 网络请求取消事件 + * 通常在调用abort方法取消HTTP请求时触发。 + * 此事件在onreadystatechange事件触发状态4事件之后。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onabort?: (result: PlusNetProgressEvent) => void; + /** + * 网络请求错误事件 + * 通常在HTTP请求发生错误时触发,如无法连接到服务器等各种错误都触发此事件。 + * 此事件在onreadystatechange事件触发状态4事件之后。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onerror?: (result: PlusNetProgressEvent) => void; + /** + * 网络请求成功事件 + * 通常在HTTP请求成功完成时触发,如果HTTP请求发生错误则不触发此事件。 + * 此事件在onreadystatechange事件触发状态4事件之后。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onload?: (result: PlusNetProgressEvent) => void; + /** + * 网络请求超时事件 + * 通常在HTTP请求超时时触发,此时不会触发onerror事件。 + * 此事件在onreadystatechange事件触发状态4事件之后。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + ontimeout?: (result: PlusNetProgressEvent) => void; + /** + * 网络请求结束事件 + * 通常在HTTP请求结束时触发,不管是HTTP请求失败、成功、或超时之后都会触发此事件。 + * 此事件在onreadystatechange事件触发状态4事件之后。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + onloadend?: (result: PlusNetProgressEvent) => void; + /** + * 取消当前响应,关闭连接并且结束任何未决的网络活动 + * 此方法把XMLHttpRequest对象重置为readyState为0的状态,并且取消所有未决的网络活动。 + * 调用此方法后将停止触发XMLHttpRequest对象的所有事件。 + * 例如,如果请求用了太长时间,而且响应不再必要的时候,可以调用这个方法。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + abort(): void; + /** + * 获取HTTP响应头部信息 + * 把HTTP响应头部作为未解析的字符串返回。 如果readyState小于3,这个方法返回null。 + * 否则,它返回服务器发送的所有 HTTP 响应的头部。头部作为单个的字符串返回,一行一个头部。每行用换行符"\r\n"隔开。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + getAllResponseHeaders(): string; + /** + * 获取指定的HTTP响应头部的值 + * 其参数是要返回的 HTTP 响应头部的名称。可以使用任何大小写来制定这个头部名字,和响应头部的比较是不区分大小写的。 + * 该方法的返回值是指定的 HTTP 响应头部的值,如果没有接收到这个头部或者readyState小于3则为空字符串。 + * 如果接收到多个有指定名称的头部,这个头部的值被连接起来并返回,使用逗号和空格分隔开各个头部的值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + getResponseHeader(headerName?: string): string; + /** + * 初始化HTTP请求参数,例如URL和HTTP方法,但是并不发送请求 + * 这个方法初始化请求参数以供 send() 方法稍后使用。它把readyState设置为1,删除之前指定的所有请求头部,以及之前接收的所有响应头部,并且把responseText、responseXML、status 以及 statusText 参数设置为它们的默认值。 + * 当readyState为0的时候(当XMLHttpRequest对象刚创建或者abort()方法调用后)以及当readyState为4时(已经接收响应时),调用这个方法是安全的。 + * 当针对任何其他状态调用的时候,open()方法的行为是为指定的。 + * 除了保存供send()方法使用的请求参数,以及重置 XMLHttpRequest 对象以便复用,open()方法没有其他的行为。 + * 要特别注意,当这个方法调用的时候,实现通常不会打开一个到Web服务器的网络连接。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + open(method?: string, url?: string, username?: string, password?: string): void; + /** + * 重写服务器返回的MIME类型 + * 此方法覆盖HTTP请求返回数据头"Content-Type"字段值中包含的IMIE类型,如果设置的MIME类型无效则继续使用"Content-Type"字段值中包含的IMIE类型。 + * 如果MIME类型中指定了字符集类型(charset),则需按照指定的字符集类型对接收到的数据体(respose)进行处理,否则默认为UTF-8字符集。 + * 注意:此方法需在send方法前调用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + overrideMimeType(mime?: string): void; + /** + * 发送HTTP请求 + * 此方法触发HTTP请求发送,如果之前没有调用open(),或者更具体地说,如果readyState不是1,send()抛出一个异常。否则,将发送HTTP请求,该请求由以下几部分组成: + * 之前调用open()时指定的HTTP方法、URL; + * 之前调用setRequestHeader()时指定的请求头部(如果有的话); + * 传递给这个方法的body参数。 + * 一旦请求发送了,send()把readyState设置为2,并触发onreadystatechange事件; + * 如果服务器响应带有一个HTTP重定向,send()方法在后台线程自动遵从重定向; + * 当所有的HTTP响应头部已经接收,send()或后台线程把readyState设置为3并触发onreadystatechange事件; + * 如果响应较长,send()或后台线程可能在状态3中触发多次onreadystatechange事件; + * 最后,当响应完成,send()或后台线程把readyState设置为4,并最后一次触发onreadystatechange事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + send(body?: string): void; + /** + * 指定一个HTTP请求的Header + * Http的Header应该包含在通过后续send()调用而发起的请求中。 + * 此方法只有当readyState为1的时候才能调用,例如,在调用了open()之后,但在调用send()之前。 + * 如果带有指定名称的头部已经被指定了,这个头部的新值就是:之前指定的值,加上逗号、以及这个调用指定的值(形成一个数组)。 + * 如果Web服务器已经保存了和传递给open()的URL相关联的cookie,适当的Cookie或Cookie2头部也自动地包含到请求中,可以通过调用setRequestHeader()来把这些cookie添加到头部。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + setRequestHeader(headerName?: string, headerValue?: string): void; +} + +/** + * HTTP请求进度事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ +interface PlusNetProgressEvent { + /** + * 事件的目标对象 + * 通知HTTP请求进度事件的XMLHttpRequest对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + target?: PlusNetXMLHttpRequest; + /** + * 进度信息是否可计算 + * HTTP请求进度信息是否有效,如果HTTP请求头中包含Content-Length头信息则为true,否则为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + lengthComputable?: number; + /** + * 当前已经接收到的数据长度 + * HTTP请求接收到的数据长度,单位为字节。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + loaded?: number; + /** + * 总数据长度 + * HTTP请求返回的总数据长度,单位为字节。 + * 如果无法获取则设置为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) + */ + total?: number; +} + +/** + * Zip模块管理文件压缩和解压,通过plus.zip可获取压缩管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ +interface PlusZip { + /** + * JSON对象,配置图片压缩转换的参数 + * 设置width/height属性则表示需对图片进行缩放转换操作; + * 设置rotate属性则表示需对图片进行旋转转换操作; + * 设置clip属性则表示需对图片进行裁剪转换操作; + * 如同时设置了多个转换操作,则按缩放、旋转、裁剪顺序进行操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + CompressImageOptions?: PlusZipCompressImageOptions; + /** + * JSON对象,图片裁剪区域的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + ClipImageOptions?: PlusZipClipImageOptions; + /** + * 压缩生成Zip文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + compress(src?: string, zipfile?: string, successCB?: () => void, errorCB?: (result: any) => void): void; + /** + * 解压缩Zip文件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + decompress(zipfile?: string, target?: string, successCB?: () => void, errorCB?: (result: any) => void): void; + /** + * 图片压缩转换 + * 可用于图片的质量压缩、大小缩放、方向旋转、区域裁剪、格式转换等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + compressImage(options?: PlusZipCompressImageOptions, successCB?: (result: any) => void, errorCB?: (result: any) => void): void; +} + +/** + * JSON对象,配置图片压缩转换的参数 + * 设置width/height属性则表示需对图片进行缩放转换操作; + * 设置rotate属性则表示需对图片进行旋转转换操作; + * 设置clip属性则表示需对图片进行裁剪转换操作; + * 如同时设置了多个转换操作,则按缩放、旋转、裁剪顺序进行操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ +interface PlusZipCompressImageOptions { + /** + * 压缩转换原始图片的路径 + * 支持以下图片路径: + * 相对路径 - 相对于当前页面的host位置,如"a.jpg",注意当前页面为网络地址则不支持; + * 绝对路径 - 系统绝对路径,如Android平台"/storage/sdcard0/Android/data/io.dcloud.HBuilder/.HBuilder/apps/HBuilder/www/a.jpg",iOS平台"/var/mobile/Containers/Data/Application/757966CF-345C-4348-B07F-EEF83CF9A369/Library/Pandora/apps/HBuilder/www/a.png"; + * 相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_www/a.jpg"、"_doc/b.jpg"、"_documents/c.jpg"、"_downloads/d.jpg"; + * 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。 + * - _www/: 应用资源目录 + * - _doc/: 应用私有文档目录 + * - _documents/: 共享文档目录 + * - _downloads/: 共享下载目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + src?: '_www/' | '_doc/' | '_documents/' | '_downloads/'; + /** + * 压缩转换目标图片的路径 + * 支持以下图片路径: + * 绝对路径 - 系统绝对路径,如Android平台"/storage/sdcard0/Android/data/io.dcloud.HBuilder/.HBuilder/apps/HBuilder/doc/a.jpg",iOS平台"/var/mobile/Containers/Data/Application/757966CF-345C-4348-B07F-EEF83CF9A369/Library/Pandora/apps/HBuilder/doc/a.png"; + * 相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_doc/b.jpg"、"_documents/c.jpg"、"_downloads/d.jpg",注意不支持"_www"开头的路径; + * 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。 + * 注意:如果设置的路径无权限访问,则返回失败。 + * - _doc/: 应用私有文档目录 + * - _documents/: 共享文档目录 + * - _downloads/: 共享下载目录 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + dst?: '_doc/' | '_documents/' | '_downloads/'; + /** + * 覆盖生成新文件 + * 仅在dst制定的路径文件存在时有效: + * true表示覆盖存在的文件; + * false表示不覆盖,如果文件存在,则返回失败。 + * 默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + overwrite?: boolean; + /** + * 压缩转换后的图片格式 + * 支持"jpg"、"png",如果未指定则使用源图片的格式。 + * - jpg: JPG格式图片 + * - png: PNG格式图片 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + format?: 'jpg' | 'png'; + /** + * 压缩图片的质量 + * 取值范围为1-100,1表示使用最低的图片质量(转换后的图片文件最小)、100表示使用最高的图片质量(转换后的图片文件最大); + * 默认值为50。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + quality?: number; + /** + * 缩放图片的宽度 + * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即根据height与源图高的缩放比例计算,若未设置height则使用源图高度); + * 默认值为"auto"。 + * 注意:若设置了width属性值不合法(如"0px"),则不对图片进行缩放操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + width?: string; + /** + * 缩放图片的高度 + * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即根据width与源图宽的缩放比例计算,若未设置width则使用源图高度); + * 默认值为"auto"。 + * 注意:若设置了height属性值不合法(如"0px"),则不对图片进行缩放操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + height?: string; + /** + * 旋转图片的角度 + * 支持值:90-表示旋转90度;180-表示旋转180度;270-表示旋转270度。 + * 注意:若设置rotate属性值不合法,则不对图片进行旋转操作。 + * - 90: 旋转90度 + * - 180: 旋转180度 + * - 270: 旋转270度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + rotate?: '90' | '180' | '270'; + /** + * 裁剪图片的区域 + * 值参考ClipImageOptions定义,若设置clip属性值不合法,则不对图片进行裁剪操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + clip?: PlusZipClipImageOptions; +} + +/** + * JSON对象,图片裁剪区域的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ +interface PlusZipClipImageOptions { + /** + * 图片裁剪区域与原图片上边界的偏移距离 + * 支持像素值(如"10px")、百分比(如"10%");默认值为"0px"。 + * 注意:如果top值超出原图片高度,则图片裁剪失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + top?: string; + /** + * 图片裁剪区域与原图片左边界的偏移距离 + * 支持像素值(如"10px")、百分比(如"10%");默认值为"0px"。 + * 注意:如果left值超出原图片宽度,则图片裁剪失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + left?: string; + /** + * 图片裁剪区域的宽度 + * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即从left位置到图片右边界的宽度);默认值为"auto"。 + * 注意:如果left值加width值超出原图片宽度,则使用"auto"值进行裁剪。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + width?: string; + /** + * 图片裁剪区域的高度 + * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即从top位置到图片下边界的高度);默认值为"auto"。 + * 注意:如果top值加height值超出原图片高度,则使用"auto"值进行裁剪。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) + */ + height?: string; +} + +/** + * Barcode模块管理条码扫描,支持常见的条码(一维码及二维码)的扫描识别功能。可调用设备的摄像头对条码图片扫描进行数据输入,解码后返回码数据及码类型。通过plus.barcode可获取条码码管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ +interface PlusBarcode { + /** + * Barcode扫码控件对象 + * Barcode对象表示条码识别控件对象,在窗口中显示条码识别控件,使用此对象可自定义条码识别界面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + Barcode?: PlusBarcodeBarcode; + /** + * Barcode扫码控件样式 + * 设置Barcode扫码控件的样式,如扫码框、扫码条的颜色等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + BarcodeStyles?: PlusBarcodeBarcodeStyles; + /** + * 条码识别控件扫描参数 + * 设置Barcode扫码控件的扫码识别参数,如是否保存扫码功时的截图等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + BarcodeOptions?: PlusBarcodeBarcodeOptions; + /** + * QR二维码,数值为0 + * 1994年由日本Denso-Wave公司发明,QR来自英文Quick Response的缩写,即快速反应的意思,源自发明者希望QR码可让其内容快速被解码。 + * 目前使用最广泛的二维码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + QR?: number; + /** + * EAN条形码标准版,数值为1 + * 国际物品编码协会在全球推广应用的商品条码,是由13位数字组成。 + * 目前使用最广泛的一维条形码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + EAN13?: number; + /** + * ENA条形码简版,数值为2 + * 国际物品编码协会在全球推广应用的商品条码,是由8位数字组成。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + EAN8?: number; + /** + * Aztec二维码,数值为3 + * Andrew Longacre发明于1995年,该代码是用于国际出版。最小的Aztec码符号编码13个数字或12个英文字母。最大的Aztec码符号编码3832数字或3067英文字母或1914字节的数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + AZTEC?: number; + /** + * Data Matrix二维码,数值为4 + * Data Matrix原名Data code,由美国国际资料公司(International Data Matrix, 简称IDMatrix)于1989年发明。可编码字元集包括全部的ASCII字元及扩充ASCII字元,容量可包含2235个英文数字资料、1556个8位元资料,3116个数字资料。由于Data Matrix二维条码只需要读取资料的20%即可精确辨读,因此很适合应用在条码容易受损的场所。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + DATAMATRIX?: number; + /** + * UPC条形码标准版,数值为5 + * UPC码是美国统一代码委员会制定的一种商品用条码,主要用于美国和加拿大地区,常在美国进口的商品上可以看到。UPC码标准版由12位数字构成,故其字码集为数字0~9。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + UPCA?: number; + /** + * UPC条形码缩短版,数值为6 + * UPC码是美国统一代码委员会制定的一种商品用条码,主要用于美国和加拿大地区,常在美国进口的商品上可以看到。UPC码缩短版由8位数字构成,故其字码集为数字0~9。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + UPCE?: number; + /** + * Codabar条形码,数值为7 + * Codabar码最初是为零售价格标签系统而研制开发的。1975年,National Retail Merchants Association(NRMA)选择了其它符号类型作为标准后,Codabar开始在多个方面用于非零售应用领域,如图书馆、货运和医药业。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + CODABAR?: number; + /** + * Code39条形码,数值为8 + * Code 39码是Intermec公司于1975年推出的一维条码, 39码是一种可供使用者双向扫瞄的分散式条码,也就是说相临两资料码之间,39码必须包含一个不具任何意义的空白(或细白,其逻辑值为0),且 39码具有支援文数字的能力,编码规则简单、误码率低、所能表示字符个数多等特点,39码在各个领域有着极为广泛的应用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + CODE39?: number; + /** + * Code93条形码,数值为9 + * Code 93码的条码符号是由Intermec公司于1982年设计的 提供更高的密度和数据安全增强code39 。它是一个字母,长度可变符号。代码93主要用于由加拿大邮政编码补充提供的资料。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + CODE93?: number; + /** + * Code128条形码,数值为10 + * CODE128码是1981年引入的一种高密度条码,CODE128 码可表示从 ASCII 0 到ASCII 127 共128个字符,故称128码。CODE128码是广泛应用在企业内部管理、生产流程、物流控制系统方面的条码码制,由于其优良的特性在管理信息系统的设计中被广泛使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + CODE128?: number; + /** + * ITF条形码,数值为11 + * ITF条码,又称交叉二五条码,由14位数字字符代表组成。主要用于运输包装,是印刷条件较差,不允许印刷EAN-13和UPC-A条码时应选用的一种条码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + ITF?: number; + /** + * MaxiCode二维码,数值为12 + * 1996年时,美国自动辨识协会(AIMUSA)制定统一的符号规格,称为Maxicode二维条码,也有人称USS-Maxicode二维条码(Uniform Symbology Specification-Maxicode)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + MAXICODE?: number; + /** + * PDF 417二维条码,数值为13 + * PDF417条码是由美国SYMBOL公司发明的,PDF(Portable Data File)意思是“便携数据文件”。组成条码的每一个条码字符由4个条和4个空共17个模块构成,故称为PDF417条码。PDF417条码最大的优势在于其庞大的数据容量和极强的纠错能力。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + PDF417?: number; + /** + * RSS 14条形组合码,数值为14 + * RSS条码是有国际物品编码协会EAN和美国统一代码委员会UCC开发的RSS(Reduced Space Symbology)条码符号。它是一种一维码和二维码的组合码。和其它线性条码相比,RSS系列码制具有更高的密度,因为它可以表示更多的字符。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + RSS14?: number; + /** + * 扩展式RSS条形组合码,数值为15 + * RSS条码是有国际物品编码协会EAN和美国统一代码委员会UCC开发的RSS(Reduced Space Symbology)条码符号。它是一种一维码和二维码的组合码。和其它线性条码相比,RSS系列码制具有更高的密度,因为它可以表示更多的字符。扩展式RSS码是长度可以变化的线性码制,能够对74个数字字符或41个字母字符的AI单元数据传数据进行编码。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + RSSEXPANDED?: number; + /** + * 通过图片扫码识别 + * 直接输入图片扫码识别,成功扫描到条码数据后通过successCallback回调返回,失败则通过errorCallback回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + scan(path?: string, successCB?: (result0: number, result1: string, result2: string) => void, errorCB?: (result: any) => void, filters?: any []): void; + /** + * 创建Barcode对象 + * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 + * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + create(id?: string, filters?: any [], styles?: PlusBarcodeBarcodeStyles): PlusBarcodeBarcode; + /** + * 查找已经创建的Barcode对象 + * 调用此方法查找指定id的Barcode对象,如果不存在则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + getBarcodeById(id?: string): PlusBarcodeBarcode; +} + +/** + * Barcode扫码控件对象 + * Barcode对象表示条码识别控件对象,在窗口中显示条码识别控件,使用此对象可自定义条码识别界面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ +interface PlusBarcodeBarcode { + /** + * 条码识别成功事件 + * Barcode扫码控件识别到有效的条码数据时触发的成功事件,并返回扫码结果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + onmarked?: (result0: number, result1: string, result2: string) => void; + /** + * 条码识别错误事件 + * 描控件识别过程中发生错误时触发的失败事件,并返回错误信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + onerror?: (result: any) => void; + /** + * 开始条码识别 + * 开始调用系统摄像头获取图片数据进行扫码识别,当识别出条码数据时通过onmarked回调函数返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + start(optons?: PlusBarcodeBarcodeOptions): void; + /** + * 结束条码识别 + * 结束对摄像头获取图片数据进行条码识别操作,同时关闭摄像头的视频捕获。 + * 结束后可调用start方法重新开始识别。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + cancel(): void; + /** + * 关闭条码识别控件 + * 释放控件占用系统资源,调用close方法后控件对象将不可使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + close(): void; + /** + * 是否开启闪光灯 + * 设置Barcode扫码控件在扫码时是否开启摄像头的闪光灯,默认值为不开启闪光灯。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + setFlash(open?: boolean): void; + /** + * 设置Barcode扫码控件的配置参数 + * 用于动态更新Barcode扫码控件的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + setStyles(styles?: PlusBarcodeBarcodeStyles): void; +} + +/** + * Barcode扫码控件样式 + * 设置Barcode扫码控件的样式,如扫码框、扫码条的颜色等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ +interface PlusBarcodeBarcodeStyles { + /** + * 条码识别控件背景颜色 + * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值,默认值为红色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + background?: string; + /** + * 扫码框颜色 + * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为红色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + frameColor?: string; + /** + * 扫码条颜色 + * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为红色。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + scanbarColor?: string; + /** + * Barcode扫码控件左上角的垂直偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度; + * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + top?: string; + /** + * Barcode扫码控件左上角的水平偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + left?: string; + /** + * Barcode扫码控件的宽度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + width?: string; + /** + * Barcode扫码控件的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + height?: string; + /** + * Barcode扫码控件在Webview窗口的布局模式 + * 可取值: + * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; + * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; + * 默认值为"static"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + position?: string; +} + +/** + * 条码识别控件扫描参数 + * 设置Barcode扫码控件的扫码识别参数,如是否保存扫码功时的截图等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ +interface PlusBarcodeBarcodeOptions { + /** + * 是否保存扫码成功时的截图 + * 如果设置为true则在扫码成功时将图片保存,并通过onmarked回调函数的file参数返回保存文件的路径。 + * 默认值为false,不保存截图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + conserve?: boolean; + /** + * 保存扫码成功时图片保存路径 + * 可通过此参数设置保存截图的路径和名称,如果设置图片文件名称则必须指定文件的后缀名(必须是.png),否则认为是指定目录,文件名称则自动生成。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + filename?: string; + /** + * 扫码成功时是否需要震动提醒 + * 如果设置为true则在扫码成功时震动设备,false则不震动。 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + vibrate?: boolean; + /** + * 扫码成功时播放的提示音 + * 可取值: + * "none" - 不播放提示音; + * "default" - 播放默认提示音(5+引擎内置)。 + * 默认值为"default"。 + * - none: 扫码成功时不播放提示音 + * - default: 扫码成功时播放默认提示音 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) + */ + sound?: 'none' | 'default'; +} + +/** + * Maps模块管理地图控件,用于在web页面中显示地图控件,提供各种接口操作地图控件,如添加标点、路线等。通过plus.maps可获取地图管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMaps { + /** + * 地图控件对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Map?: PlusMapsMap; + /** + * 地图控件对象的参数 + * 设置地图对象显示时使用的参数,如地图的中心位置、缩放级别等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + MapStyles?: PlusMapsMapStyles; + /** + * 地理编码转换的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + GeocodeOptions?: PlusMapsGeocodeOptions; + /** + * 地图坐标转换的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + CoordinateConvertOptions?: PlusMapsCoordinateConvertOptions; + /** + * Point对象用于表示地图元素的坐标 + * 常用语对地图上元素进行定位时使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Point?: PlusMapsPoint; + /** + * 地理区域 + * 有西南及东北坐标点数据组成的矩形区域。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Bounds?: PlusMapsBounds; + /** + * 地图视图类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + MapType?: PlusMapsMapType; + /** + * 地图覆盖物基类对象 + * Overlay是地图上显示元素的基类,用于抽象地图元素,不用于实例化。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Overlay?: PlusMapsOverlay; + /** + * 地图上显示的标点对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Marker?: PlusMapsMarker; + /** + * 地图上显示的气泡对象 + * 此对象不能直接添加到地图上显示,只可关联到地图标点覆盖物上,用户点击标点时弹出显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Bubble?: PlusMapsBubble; + /** + * 地图上显示的圆圈对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Circle?: PlusMapsCircle; + /** + * 地图上显示的折线对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Polyline?: PlusMapsPolyline; + /** + * 地图上显示的多边形对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Polygon?: PlusMapsPolygon; + /** + * 地图检索对象 + * Search对象用于管理地图上的检索功能,包括位置检索、周边检索和范围检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Search?: PlusMapsSearch; + /** + * 检索策略类型 + * 在线路检索时设置检索策略时使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + SearchPolicy?: PlusMapsSearchPolicy; + /** + * 保存位置检索、周边检索和范围检索返回的结果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + SearchPoiResult?: PlusMapsSearchPoiResult; + /** + * 保存位置检索、周边检索和范围检索返回的结果 + * 不可通过new操作符创建SearchRouteResult对象,在触发onRouteSearchComplete()时自动创建。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + SearchRouteResult?: PlusMapsSearchRouteResult; + /** + * 检索结果的位置点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Position?: PlusMapsPosition; + /** + * 地图中的路线对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + Route?: PlusMapsRoute; + /** + * 调用系统第三方程序进行导航 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + openSysMap(dst?: PlusMapsPoint, des?: string, src?: PlusMapsPoint): void; + /** + * 创建Map对象 + * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 + * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + create(id?: string, styles?: PlusMapsMapStyles): PlusMapsMap; + /** + * 查找已经创建的Map对象 + * 调用此方法查找指定id的Map对象,如果不存在则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getMapById(id?: string): PlusMapsMap; +} + +/** + * 地图控件对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsMap { + /** + * 用户点击地图事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onclick?: (result: PlusMapsPoint) => void; + /** + * 地图状态改变事件 + * 用户拖动、缩放地图等操作完成后触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onstatuschanged?: (result: any) => void; + /** + * 静态方法,计算面积 + * 计算指定地理区域的面积,单位为平方米。 + * 注:此功能仅百度地图支持,高德地图暂不支持此功能。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + calculateArea(bounds?: PlusMapsBounds, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 静态方法,计算距离 + * 计算从pointStart坐标点到pointEnd坐标的实际直线距离,单位为米(m)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + calculateDistance(pointStart?: PlusMapsPoint, pointEnd?: PlusMapsPoint, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 静态方法,坐标转换 + * 将第三方坐标系坐标转换成当前地图的坐标系坐标。 + * 转换成功通过successCallback返回,转换失败则通过errorCallback返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + convertCoordinates(point?: PlusMapsPoint, options?: PlusMapsCoordinateConvertOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 静态方法,地理编码 + * 将地理位置信息转换为坐标点。 + * 转换成功通过successCallback返回,转换失败则通过errorCallback返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + geocode(address?: string, options?: PlusMapsGeocodeOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 静态方法,反向地理编码 + * 将坐标点转换为地理位置信息。 + * 转换成功通过successCallback返回,转换失败则通过errorCallback返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + reverseGeocode(point?: PlusMapsPoint, options?: PlusMapsGeocodeOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 向地图中添加覆盖物 + * 此方法用于向地图中添加覆盖物。 + * 支持各种从maps.Overlay对象继承的各种覆盖物对象; + * 如果添加不支持的对象则直接返回false; + * 同一覆盖物对象只能添加到地图中一次,已在地图中的覆盖物再次添加时则返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + addOverlay(overlay?: PlusMapsOverlay): boolean; + /** + * 设置地图初始中心点和缩放级别 + * 用于设置地图的初始中心点和缩放级别,通常在创建地图后立即调用。 + * 默认中心点为天安门,默认缩放级别为12; + * 该方法设置的中心点和缩放级别可通过reset()方法恢复; + * 如果在地图显示后调用将改变地图的中心点和缩放级别并立即更新,并将初始值更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + centerAndZoom(center?: PlusMapsPoint, zoom?: number): void; + /** + * 清除地图中所有覆盖物对象 + * 此方法用于清除地图中所有覆盖物对象。 + * 清除地图中的覆盖物对象后会自动更新地图视图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + clearOverlays(): void; + /** + * 关闭地图控件 + * 关闭地图控件将会销毁地图使用的资源,不可再使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + close(): void; + /** + * 获取当前地图可视范围的地理区域 + * 当旋转或俯视时,是当前地图可视范围的最大外接矩形地理区域。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getBounds(): PlusMapsBounds; + /** + * 获取地图中心点位置 + * 此方法用于获取设置的地图中心点位置(centerAndZoom/setCenter)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getCenter(): PlusMapsPoint; + /** + * 获取当前地图显示的地图中心点位置 + * 此方法用于获取当前地图显示的地图中心点位置,获取成功后通过callback回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getCurrentCenter(callback?: (result0: number, result1: PlusMapsPoint) => void): boolean; + /** + * 获取地图的显示类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getMapType(): PlusMapsMapType; + /** + * 获取用户的当前位置信息 + * 此方法用于获取用户的当前位置信息,获取成功后通过callback回调返回。 + * 获取用户当前位置信息将打开定位设备。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getUserLocation(callback?: (result0: number, result1: PlusMapsPoint) => void): boolean; + /** + * 获取地图的缩放级别 + * 此方法用于设置地图的缩放级别,用于切换当前显示地图缩放级别。 + * 该方法改变缩放级别后地图显示内容将立即更新; + * 该方法不会改变地图显示区域,以当前地图显示的中心点位置来缩放地图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getZoom(): number; + /** + * 隐藏地图控件 + * 此方法用于隐藏地图控件,通常在显示后调用此方法来隐藏。 + * 如果地图已经隐藏再调用此方法将无效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + hide(): void; + /** + * 获取是否显示用户位置 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + isShowUserLocation(): boolean; + /** + * 获取是否显示地图内置缩放控件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + isShowZoomControls(): boolean; + /** + * 获取是否打开地图交通信息图层 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + isTraffic(): boolean; + /** + * 从地图中删除覆盖物对象 + * 此方法用于从地图中删除覆盖物对象。 + * 支持各种从maps.Overlay对象继承的各种覆盖物对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + removeOverlay(overlay?: PlusMapsOverlay): void; + /** + * 重置地图 + * 此方法用于重新设置地图,恢复地图的初始化时的中心点和缩放级别。 + * 该方法将导致显示内容将立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + reset(): void; + /** + * 重设地图控件大小 + * 此方法用于重新计算地图控件大小,保持与构造时传入DOM元素的大小及位置一致。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + resize(): void; + /** + * 设置地图的中心点 + * 此方法用于设置地图的中心点,用于切换当前显示地图位置。 + * 该方法改变中心点后地图显示内容将立即更新; + * 该方法不会改变地图显示的缩放级别。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setCenter(center?: PlusMapsPoint): void; + /** + * 设置地图的视图类型 + * 此方法用于设置地图类型,默认为普通街道视图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setMapType(type?: PlusMapsMapType): void; + /** + * 设置地图控件的配置参数 + * 用于动态更新地图控件的参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStyles(styles?: PlusMapsMapStyles): void; + /** + * 是否打开地图交通信息图层 + * 此方法用于设置是否打开地图交通信息图层,默认不显示。 + * 该方法改变是否显示交通图层后地图显示内容将立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setTraffic(traffic?: boolean): void; + /** + * 设置地图的缩放级别 + * 此方法用于设置地图的缩放级别,用于切换当前显示地图缩放级别。 + * 该方法改变缩放级别后地图显示内容将立即更新; + * 该方法不会改变地图显示区域,以当前地图显示的中心点位置来缩放地图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setZoom(zoom?: number): void; + /** + * 显示地图控件 + * 此方法用于显示地图控件,通常在隐藏后调用此方法来显示。 + * 如果地图已经显示再调用此方法将无效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + show(): void; + /** + * 显示用户位置 + * 此方法将在地图上显示用户位置信息。 + * 显示用户位置将打开定位设备。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + showUserLocation(display?: boolean): void; + /** + * 设置是否显示地图内置缩放控件 + * 此方法将在地图上显示内置缩放控件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + showZoomControls(display?: boolean): void; +} + +/** + * 地图控件对象的参数 + * 设置地图对象显示时使用的参数,如地图的中心位置、缩放级别等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsMapStyles { + /** + * 地图的中心位置 + * 未设置则使用地图的默认中心点(由地图供应商确定)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + center?: PlusMapsPoint; + /** + * 地图的缩放级别 + * 有效范围为1-22,默认值为12,设置无效的值则使用默认值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + zoom?: number; + /** + * 地图的视图类型 + * 可设置普通街道视图、卫星视图,默认值为普通街道视图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + type?: PlusMapsMapType; + /** + * 地图的是否显示交通信息 + * true表示显示地图的交通信息图层,false则不显示,默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + traffic?: boolean; + /** + * 是否显示地图的内置缩放控件 + * true表示显示地图的内置缩放控件,false则不显示,默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + zoomControls?: boolean; + /** + * 地图控件左上角的垂直偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度; + * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + top?: string; + /** + * 地图控件左上角的水平偏移量 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度; + * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 + * 默认值为"0px"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + left?: string; + /** + * 地图控件的宽度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的宽度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + width?: string; + /** + * 地图控件的高度 + * 可取值: + * 像素值,如"100px"; + * 百分比,如"10%",相对于父Webview窗口的高度。 + * 默认值为"100%"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + height?: string; + /** + * 地图控件在Webview窗口的布局模式 + * 可取值: + * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; + * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; + * 默认值为"static"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + position?: string; +} + +/** + * 地理编码转换的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsGeocodeOptions { + /** + * 源数据的坐标系类型 + * 仅在反向地理编码转换时生效。 + * “wgs84”:表示WGS-84坐标系; “gcj02”:表示国测局经纬度坐标系; “bd09”:表示百度墨卡托坐标系; “bd09ll”:表示百度经纬度坐标系; + * 默认使用wgs84坐标系。 + * - wgs84: WGS-84坐标系,即GPS设备采集的原始GPS坐标 + * - gcj02: 国测局经纬度坐标系,soso地图、aliyun地图、mapabc地图和amap地图所用的坐标系 + * - bd09: 百度墨卡托坐标系 + * - bd09ll: 百度经纬度坐标系 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + coordType?: 'wgs84' | 'gcj02' | 'bd09' | 'bd09ll'; + /** + * 源地址所属的城市 + * 仅在地理编码转换时生效,如果不指定则在全国范围内区配转换。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + city?: string; +} + +/** + * 地图坐标转换的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsCoordinateConvertOptions { + /** + * 源数据的坐标系类型 + * “wgs84”:表示WGS-84坐标系; “gcj02”:表示国测局经纬度坐标系; “bd09”:表示百度墨卡托坐标系; “bd09ll”:表示百度经纬度坐标系; + * 默认使用wgs84坐标系。 + * - wgs84: WGS-84坐标系,即GPS设备采集的原始GPS坐标 + * - gcj02: 国测局经纬度坐标系,soso地图、aliyun地图、mapabc地图和amap地图所用的坐标系 + * - bd09: 百度墨卡托坐标系 + * - bd09ll: 百度经纬度坐标系 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + coordType?: 'wgs84' | 'gcj02' | 'bd09' | 'bd09ll'; +} + +/** + * Point对象用于表示地图元素的坐标 + * 常用语对地图上元素进行定位时使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsPoint { + /** + * 设置坐标点的经度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLng(lng?: number): void; + /** + * 获取坐标的经度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLng(): number; + /** + * 设置坐标的纬度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLat(): void; + /** + * 获取坐标的纬度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLat(): number; + /** + * 判断两个坐标点是否相等 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + equals(pt?: PlusMapsPoint): boolean; +} + +/** + * 地理区域 + * 有西南及东北坐标点数据组成的矩形区域。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsBounds { + /** + * 设置地理区域的东北坐标点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setNorthEase(point?: PlusMapsPoint): void; + /** + * 地理区域的东北坐标点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getNorthEase(): PlusMapsPoint; + /** + * 设置地理区域的西南坐标点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setSouthWest(point?: PlusMapsPoint): void; + /** + * 地理区域的西南坐标点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getSouthWest(): PlusMapsPoint; + /** + * 判断制定的坐标是否在地理区域中 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + contains(point?: PlusMapsPoint): boolean; + /** + * 判断两个地理区域是否相等 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + equals(bounds?: PlusMapsBounds): boolean; + /** + * 获取地理区域的中心点坐标 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getCenter(): PlusMapsPoint; +} + +/** + * 地图视图类型 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsMapType { + /** + * 普通街道视图类型 + * 地图视图类型常量,普通街道视图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + MAPTYPE_NORMAL?: number; + /** + * 卫星视图 + * 地图视图类型常量,卫星视图。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + MAPTYPE_SATELLITE?: number; +} + +/** + * 地图覆盖物基类对象 + * Overlay是地图上显示元素的基类,用于抽象地图元素,不用于实例化。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsOverlay { + /** + * 判断地图覆盖物是否可见 + * 地图覆盖物对象默认为可见;地图覆盖物对象是否可见由其自身状态决定,不管其是否被添加到地图层中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + isVisible(): boolean; + /** + * 显示地图上的覆盖物 + * 常用于地图覆盖物在隐藏后调用此方法来显示。 + * 只有添加到地图上的覆盖物才能看到效果; + * 如果覆盖物对象已经在地图上显示再调用此方法将无效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + show(): void; + /** + * 隐藏地图上的覆盖物 + * 常用于地图覆盖物在显示后调用此方法来隐藏。 + * 只有添加到地图上的覆盖物才能看到效果; + * 如果覆盖物对象已经在地图上隐藏再调用此方法将无效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + hide(): void; +} + +/** + * 地图上显示的标点对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsMarker { + /** + * 用户点击地图标点事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onclick?: (result: PlusMapsOverlay) => void; + /** + * 用户拖拽标点事件 + * 可调用标点对象的markObj.setDraggable(true)方法设置标点允许拖拽,当用户拖拽标点对象时触发此事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onDrag?: (result: any) => void; + /** + * 覆盖物显示到最上层 + * 常用于覆盖物相互覆盖时调整覆盖物的显示顺序。 + * 只有添加到地图上的覆盖物才能看到效果; + * 如果覆盖物对象已经在地图上隐藏再调用此方法将无效果。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + bringToTop(): void; + /** + * 设置标点对象的坐标 + * 标点在设置新坐标后将在地图上立即更新标点位置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setPoint(point?: PlusMapsPoint): void; + /** + * 获取标点的坐标 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getPoint(): PlusMapsPoint; + /** + * 设置标点上显示的图标 + * 若未设置则显示默认标点图标,已添加的标点在设置新值后将在地图上立即更新标点内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setIcon(icon?: string): void; + /** + * 设置标点上显示的图标数组 + * 设置图标数组后则按照指定的间隔时间轮播数组中图标。 + * 设置图标数组后将忽略setIcon方法设置的图标,未设置则显示setIcon设置的图标。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setIcons(icons?: any []): void; + /** + * 设置标点上显示的文本标注 + * 若未设置则不显示标注(默认为空字符串),已添加的标点在设置新值后将在地图上立即更新标点内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLabel(label?: string): void; + /** + * 获取标点上显示的文本标注 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLabel(): string; + /** + * 设置标点的气泡内容 + * 设置气泡内容后,用户点击标点时弹出则弹出气泡。 + * 注意:用户点击标点时先弹出标点关联的气泡,再响应标点的onclick事件。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setBubble(buuble?: PlusMapsBubble, pop?: boolean): void; + /** + * 获取标点上显示的文本标注 + * 如果没有设置关联的气泡对象则返回null。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getBubble(): PlusMapsBubble; + /** + * 隐藏标点上显示的气泡 + * 如果没有设置关联的气泡对象或者气泡对象没有弹出显示,则不做任何操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + hideBubble(): void; + /** + * 设置标点的是否允许拖拽 + * 设置标点可拖拽后,用户按住标点后拖动,标点会跟随手的拖拽而移动。 + * 拖拽后会更新标点的坐标信息。 + * 注:拖动前需要先在标点上长按。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setDraggable(draggable?: boolean): void; + /** + * 获取标点是否允许拖拽 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + isDraggable(): boolean; +} + +/** + * 地图上显示的气泡对象 + * 此对象不能直接添加到地图上显示,只可关联到地图标点覆盖物上,用户点击标点时弹出显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsBubble { + /** + * 用户点击气泡事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onclick?: (result: PlusMapsOverlay) => void; + /** + * 设置气泡上显示的图标 + * 若为设置则无默认图标,已添加的显示的气泡在设置新值后将在地图上立即更新内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setIcon(icon?: string): void; + /** + * 设置气泡上显示的文字内容 + * 若未设置则不显示文字(默认为空字符串),已添加的显示的气泡在设置新值后将在地图上立即更新内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLabel(label?: string): void; + /** + * 获取气泡上显示的文字内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLabel(): string; + /** + * 获取气泡所属的标点对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + belongMarker(): PlusMapsMarker; + /** + * 从图片加载气泡显示的内容 + * 通过加载图片来自定义气泡显示的内容,加载图片后将清空气泡使用的图标及文字内容。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + loadImage(path?: string): void; + /** + * 从图片数据加载气泡显示的内容 + * 通过加载图片数据来自定义气泡显示的内容,加载图片后将清空气泡使用的图标及文字内容。 + * 图片数据可通过Canvas自定义绘制后调用toDataURL来获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + loadImageDataURL(data?: string): void; +} + +/** + * 地图上显示的圆圈对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsCircle { + /** + * 设置圆圈中心点的经纬度坐标 + * 该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setCenter(point?: PlusMapsPoint): void; + /** + * 获取圆圈中心点的坐标 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getCenter(): PlusMapsPoint; + /** + * 设置圆圈的半径,单位为米 + * 该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setRadius(radius?: number): void; + /** + * 获取圆圈的半径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getRadius(): number; + /** + * 设置圆圈的边框颜色 + * 圆圈默认的圆圈边框颜色为黑色"#000000",该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStrokeColor(color?: string): void; + /** + * 获取圆圈的边框颜色 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getStrokeColor(): string; + /** + * 设置圆圈的边框颜色 + * 圆圈默认值为不透明。 + * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStrokeOpacity(opacity?: number): void; + /** + * 获取圆圈边框的透明度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getStrokeOpacity(): number; + /** + * 设置圆圈的填充颜色 + * 圆圈默认的圆圈填充颜色为无色,该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setFillColor(color?: string): void; + /** + * 获取圆圈的填充颜色 + * 如果填充颜色为无色,则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getFillColor(): string; + /** + * 设置圆圈填充颜色的透明度 + * 圆圈默认值为不透明。 + * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setFillOpacity(opacity?: number): void; + /** + * 获取圆圈填充色的透明度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getFillOpacity(): number; + /** + * 设置圆圈边框的线条宽度 + * 圆圈边框的默认值为5。 + * 如果设置的值不合法则保持原有的宽度;该方法设置将导致地图中的圆圈立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLineWidth(width?: number): void; + /** + * 获取圆圈边框的线条宽度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLineWidth(): number; +} + +/** + * 地图上显示的折线对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsPolyline { + /** + * 设置折线的顶点坐标 + * 该方法设置将导致地图中的折线立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setPath(points?: any []): void; + /** + * 获取折线的顶点坐标 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getPath(): any []; + /** + * 设置折线的颜色 + * 折线默认的颜色为黑色"#000000",该方法设置将导致地图中的折线立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStrokeColor(color?: string): void; + /** + * 获取折线的颜色 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getStrokeColor(): string; + /** + * 设设置折线的透明度 + * 折线默认值为不透明。 + * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的折线立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStrokeOpacity(opacity?: number): void; + /** + * 获取折线的透明度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getStrokeOpacity(): number; + /** + * 设置折线的线条宽度 + * 折线线条的宽度默认值为5。 + * 如果设置的值不合法则保持原有的宽度;该方法设置将导致地图中的折线立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLineWidth(width?: number): void; + /** + * 获取折线的线条宽度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLineWidth(): number; +} + +/** + * 地图上显示的多边形对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsPolygon { + /** + * 设置多边形的顶点坐标 + * 该方法设置将导致地图中的多边形立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setPath(points?: any []): void; + /** + * 获取多边形的顶点坐标 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getPath(): any []; + /** + * 设置多边形的颜色 + * 多边形边框默认的颜色为黑色"#000000",该方法设置将导致地图中的多边形立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStrokeColor(color?: string): void; + /** + * 获取多边形边框的颜色 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getStrokeColor(): string; + /** + * 设置多边形的透明度 + * 多边形边框默认值为不透明。 + * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的多边形立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setStrokeOpacity(opacity?: number): void; + /** + * 获取多边形边框的透明度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getStrokeOpacity(): number; + /** + * 设置多边形的填充颜色 + * 多边形默认填充颜色为无色,该方法设置将导致地图中的多边形立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setFillColor(color?: string): void; + /** + * 获取多边形的填充色 + * 如果填充色为无色,则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getFillColor(): string; + /** + * 设置多边形填充色的透明度 + * 多边形填充色默认值为不透明。 + * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的多边形立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setFillOpacity(opacity?: number): void; + /** + * 获取多边形填充色的透明度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getFillOpacity(): number; + /** + * 设置多边形的边框宽度 + * 多边形边框的宽度默认值为5。 + * 如果设置的值不合法则保持原有的宽度;该方法设置将导致地图中的多边形立即更新。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setLineWidth(width?: number): void; + /** + * 获取多边形边框的宽度 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getLineWidth(): number; +} + +/** + * 地图检索对象 + * Search对象用于管理地图上的检索功能,包括位置检索、周边检索和范围检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsSearch { + /** + * 兴趣点检索完成事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onPoiSearchComplete?: (result0: number, result1: PlusMapsSearchPoiResult) => void; + /** + * 线路检索完成事件 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + onRouteSearchComplete?: (result0: number, result1: PlusMapsSearchRouteResult) => void; + /** + * 设置检索返回结果每页的信息数目 + * 地图检索结果是按页返回的,默认检索每页返回10条信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setPageCapacity(capacity?: number): void; + /** + * 获取检索返回结果每页的信息数目 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getPageCapacity(): number; + /** + * 城市兴趣点检索 + * 检索结果将通过onPoiSearchComplete事件返回。 + * 如果调用此方法时已经处于POI检索操作中,则终止上次检索操作,重新开始新的检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + poiSearchInCity(city?: string, key?: string, index?: number): boolean; + /** + * 周边检索 + * 周边检索根据中心点、半径与检索词进行检索,检索完成后触发onPoiSearchComplete()事件。 + * 若调用此方法时对象处于POI检索操作中,则终止上次检索操作,重新开始新的检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + poiSearchNearBy(key?: string, pt?: PlusMapsPoint, radius?: number, index?: number): boolean; + /** + * 指定范围检索 + * 根据范围和检索词进行检索,检索完成后触发onPoiSearchComplete()事件。 + * 若调用此方法时对象处于POI检索操作中,则终止上次检索操作,重新开始新的检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + poiSearchInbounds(): boolean; + /** + * 设置公交路线检索策略 + * 默认采用maps.SearchPolicy.TRANSIT_TIME_FIRST策略。 + * 需在调用transitSearch()方法前设置的策略才生效; + * 如果设置非法值则认为设置失败,采用上次设置的检索策略并返回false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setTransitPolicy(policy?: PlusMapsSearchPolicy): boolean; + /** + * 公交路线检索 + * 检索完成后触发onRouteSearchComplete()事件。 + * 若调用此方法时对象处于检索操作中,则终止上次检索操作,重新开始新的检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + transitSearch(start?: string, end?: string, city?: string): boolean; + /** + * 设置驾车路线检索策略 + * 设置驾车路线检索策略,默认采用maps.SearchPolicy.DRIVING_TIME_FIRST策略。 + * 如果设置非法值则认为设置失败,采用上次设置的检索策略并返回false;需在调用drivingSearch()方法前设置的策略才生效。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + setDrivingPolicy(policy?: PlusMapsSearchPolicy): boolean; + /** + * 驾车路线检索 + * 用于驾车路线检索,检索完成后触发onRouteSearchComplete()事件。 + * 调用此方法时对象处于检索操作中,则终止上次检索操作,重新开始新的检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + drivingSearch(start?: string, startCity?: string, end?: string, endCity?: string): boolean; + /** + * 步行路线检索 + * 用于步行路线检索,检索完成后触发onRouteSearchComplete()事件。 + * 调用此方法时对象处于检索操作中,则终止上次检索操作,重新开始新的检索。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + walkingSearch(start?: string, startCity?: string, end?: string, endCity?: string): boolean; +} + +/** + * 检索策略类型 + * 在线路检索时设置检索策略时使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsSearchPolicy { + /** + * 时间优先 + * 检索策略类型常量,用于公交检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + TRANSIT_TIME_FIRST?: number; + /** + * 最少换乘优先 + * 检索策略类型常量,用于公交检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + TRANSIT_TRANSFER_FIRST?: number; + /** + * 最少步行距离优先 + * 检索策略类型常量,用于公交检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + TRANSIT_WALK_FIRST?: number; + /** + * 选择车票花销最少优先 + * 检索策略类型常量,用于公交检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + TRANSIT_FEE_FIRST?: number; + /** + * 最短距离优先 + * 检索策略类型常量,用于驾车检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + DRIVING_DIS_FIRST?: number; + /** + * 无高速公路线路 + * 检索策略类型常量,用于驾车检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + DRIVING_NO_EXPRESSWAY?: number; + /** + * 最少费用优先 + * 检索策略类型常量,用于驾车检索策略 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + DRIVING_FEE_FIRST?: number; +} + +/** + * 保存位置检索、周边检索和范围检索返回的结果 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsSearchPoiResult { + /** + * POI检索总结果数 + * POI检索总结果数,若没有检索到则返回0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + totalNumber?: number; + /** + * 当前页的POI检索结果数 + * 当前页POI检索结果数,若没有检索到则返回0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + currentNumber?: number; + /** + * 本次POI检索的总页数 + * 本次POI检索的总页数,若没有检索到则返回0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + pageNumber?: number; + /** + * 获取当前页的索引 + * 当前页的索引值,从0开始,即0表示第一页。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + pageIndex?: number; + /** + * 本次POI检索结果数组 + * POI检索结果数组,Array数组对象,数组内容为Position对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + poiList?: any []; + /** + * 获取指定索引的检索结果 + * 如果index值超出范围则返回null对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getPosition(): PlusMapsPosition; +} + +/** + * 保存位置检索、周边检索和范围检索返回的结果 + * 不可通过new操作符创建SearchRouteResult对象,在触发onRouteSearchComplete()时自动创建。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsSearchRouteResult { + /** + * 线路的起点位置 + * 线路检索结果的起始位置点对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + startPosition?: PlusMapsPosition; + /** + * 线路的终点位置 + * 线路检索结果的终点位置点对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + endPosition?: PlusMapsPosition; + /** + * 本次线路检索的总方案数 + * 线路检索结果的方案数目,若未检索到有效结果则返回0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + routeNumber?: number; + /** + * 线路检索结果数组 + * 线路检索结果数组,Array数组对象,数组内容为Route对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + routeList?: any []; + /** + * 获取指定索引的线路方案 + * 如果index值超出范围则返回null对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + getRoute(index?: number): PlusMapsRoute; +} + +/** + * 检索结果的位置点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsPosition { + /** + * 位置点的经纬度坐标 + * 如果没有经纬度坐标信息(如果公交、地铁路线数据等),则其值为undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + point?: PlusMapsPoint; + /** + * 位置点的地址信息 + * 如果没有位置点的地址信息则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + address?: string; + /** + * 位置点的所属城市信息 + * 如果没有位置点的所属城市信息则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + city?: string; + /** + * 位置点的名称 + * 如果没有位置点的名称则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + name?: string; + /** + * 位置点的电话信息 + * 如果没有位置点的电话信息则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + phone?: string; + /** + * 位置点的邮编信息 + * 如果没有位置点的邮编信息则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + postcode?: string; +} + +/** + * 地图中的路线对象 + * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ +interface PlusMapsRoute { + /** + * 路线起点地理坐标点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + startPoint?: PlusMapsPoint; + /** + * 路线终点地理坐标点 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + endPoint?: PlusMapsPoint; + /** + * 路线坐标点段数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + pointCount?: PlusMapsPoint; + /** + * 路线的地理坐标点数组 + * 路线的地理坐标点数组,数组中保存Point对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + pointList?: any []; + /** + * 路线总距离 + * 路线从起始点到终点的距离,单位为米。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + distance?: number; + /** + * 线路的提示信息 + * 线路提示信息,没有提示信息则返回空字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) + */ + routeTip?: string; +} + +/** + * OAuth模块管理客户端的用户登录授权验证功能,允许应用访问第三方平台的资源。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ +interface PlusOauth { + /** + * 登录授权认证服务对象 + * AuthService对象用于表示登录授权认证服务,在JS中为对象,用于向系统进行登录授权认证操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + AuthService?: PlusOauthAuthService; + /** + * JSON对象,授权认证参数选项 + * 此对象支持的属性值由登录授权认证服务定义。 + * 例如“微信”,则可配置以下参数: + * scope - 应用授权作用域; + * state - 用于保持请求和回调的状态参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + AuthOptions?: PlusOauthAuthOptions; + /** + * 登录授权认证信息 + * 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 + * 例如“微信”登录授权服务,则包括以下数据: + * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + AuthInfo?: PlusOauthAuthInfo; + /** + * 登录授权用户信息 + * 用于保存登录授权用户的信息。 + * 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 + * 例如“微信”登录授权服务,可能包括以下自定义数据: + * privilege - 用户特权信息,json数组,如微信沃卡用户为(chinaunicom); + * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + UserInfo?: PlusOauthUserInfo; + /** + * 获取登录授权认证服务列表 + * 获取终端支持的权登录认证服务列表,可用于提示用户进行登录平台的选择。获取登录授权认证服务成功后通过successCB回调返回支持的所有服务列表,获取服务失败则通过errorCB回调返回失败信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + getServices(successCB?: (result: PlusOauth []) => void, errorCB?: (result: any) => void): void; +} + +/** + * 登录授权认证服务对象 + * AuthService对象用于表示登录授权认证服务,在JS中为对象,用于向系统进行登录授权认证操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ +interface PlusOauthAuthService { + /** + * 登录授权认证服务标识 + * 用于表示登录授权认证服务标识: + * "weixin" - 表示微信登录授权; + * "qq" - 表示QQ登录授权; + * "sinaweibo" - 表示新浪微博登录授权; + * "qihoo" - 表示360账号登录(仅360手助流应用环境下支持)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + id?: string; + /** + * 登录授权认证服务描述 + * 用于描述登录授权认证服务的信息: + * "微信" - 表示微信登录授权; + * "QQ" - 表示QQ登录授权; + * "新浪微博" - 表示新浪微博登录授权; + * "360账号" - 表示360账号登录(仅360手助流应用环境下支持)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + description?: string; + /** + * 授权认证结果数据 + * 用于保存登录授权认证获取的认证信息,如果值为"undefined"则表示未进行授权认证或者是授权认证失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + authResult?: PlusOauthAuthInfo; + /** + * 登录授权认证用户信息 + * 用于保存登录授权认证获取的用户信息,如果值为"undefined"则表示未获取过用户信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + userInfo?: PlusOauthUserInfo; + /** + * 登录授权认证扩展信息 + * 用于保存登录授权认证服务返回的扩展信息,具体内容由各登录平台决定,如果没有扩展信息则为undefined。 + * 例如“微信”,则可保存以下数据: + * state - 用于保持请求和回调的状态参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + extra?: any; + /** + * 请求授权认证 + * 向开放平台请求进行授权认证,需提供授权域(scope),用户在终端确认后通过成功回调返回授权临时票据(code)。 + * 开发者可以将授权临时票据(code)提交到业务服务器,又业务服务器从微信开放平台获取授权登录等相关信息,避免将appsecret等信息保存在客户端可能引起泄露的问题。 + * 注意:目前仅微信平台支持请求授权认证,其它平台调用此方法将返回错误回调。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + authorize(successCallback?: (result: any) => void, errorCallback?: (result: any) => void, options?: PlusOauthAuthOptions): void; + /** + * 请求登录授权认证操作 + * 对指定的登录授权认证服务进行登录认证操作,在登录前可通过对象的authResult属性判断是否已经登录认证过,通常只需要对没有进行过登录认证的服务进行登录认证操作。 + * 授权认证操作成功后通过successCB回调函数通知,失败则通过errorCB回调函数通知。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + login(successCallback?: (result: any) => void, errorCallback?: (result: any) => void, options?: PlusOauthAuthOptions): void; + /** + * 注销登录授权认证 + * 对指定的登录授权认证服务注销登录认证操作,注销授权认证后,再次操作时需重新进行登录认证操作。 + * 如果第三方平台不需要注销操作,则情况保存的相关登录认证等信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + logout(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 获取登录授权用户信息 + * 获取登录授权认证的用户信息,在获取前可通过对象的userInfo属性判断是否已经获取过,通常只需要对没有获取过用户信息的服务进行操作。 + * 获取用户信息操作成功后通过successCallback回调函数通知,失败则通过errorCallback回调函数通知。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + getUserInfo(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + /** + * 添加用户手机号信息 + * 打开登录授权服务的添加用户手机号界面进行操作,添加用户手机号操作成功后通过successCallback回调函数通知,否则通过errorCallback回调函数通知。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + addPhoneNumber(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; +} + +/** + * JSON对象,授权认证参数选项 + * 此对象支持的属性值由登录授权认证服务定义。 + * 例如“微信”,则可配置以下参数: + * scope - 应用授权作用域; + * state - 用于保持请求和回调的状态参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ +interface PlusOauthAuthOptions { + /** + * 申请的权限作用范围 + * 如果存在多个权限,则以","符号分割。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + scope?: string; + /** + * 客户端的当前状态,可以指定任意值,登录认证后原封不动的返回保存到AuthService对象的extra中 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + state?: string; + /** + * 登录授权认证服务平台申请的appid + * 动态设置登录授权服务中需要使用的appid,仅需要此参数的登录授权服务(如“微信登录”、“QQ登录”)支持。 + * 如果未设置则使用运行环境中内置的appid值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + appid?: string; + /** + * 登录授权认证服务平台申请的appkey + * 动态设置登录授权服务中需要使用的appkey,仅需要此参数的登录授权服务(如“新浪微博登录”、“360登录”)支持。 + * 如果未设置则使用运行环境中内置的appkey值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + appkey?: string; + /** + * 登录授权认证服务平台申请的appsecret + * 动态设置登录授权服务中需要使用的appsecret,仅需要此参数的登录授权服务(如“微信登录”、“新浪微博登录”)支持。 + * 如果未设置则使用运行环境中内置的appkey值(如在HBuilder中可在manifest.json的SDK配置项中进行设置);当开放平台申请的appsecret值涉及到安全问题时,可在应用运行时从服务器获取,然后通过此api动态设置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + appsecret?: string; + /** + * 登录授权认证服务平台申请的redirect_url + * 动态设置登录授权服务中需要使用的redirect_url,仅需要此参数的登录授权服务(如“新浪微博登录”)支持。 + * 如果未设置则使用运行环境中内置的redirect_url值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + redirect_url?: string; +} + +/** + * 登录授权认证信息 + * 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 + * 例如“微信”登录授权服务,则包括以下数据: + * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ +interface PlusOauthAuthInfo { + /** + * 登录授权的访问令牌 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + access_token?: string; + /** + * 登录授权用户的唯一标识 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + openid?: string; + /** + * 登录授权访问令牌过期时间 + * 单位为秒,如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + expires_in?: string; + /** + * 登录授权的更新令牌 + * 用来获取下一次的访问令牌,如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + refresh_token?: string; + /** + * 登录授权的权限范围 + * 如果存在多个权限,则以","符号分割。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + scope?: string; +} + +/** + * 登录授权用户信息 + * 用于保存登录授权用户的信息。 + * 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 + * 例如“微信”登录授权服务,可能包括以下自定义数据: + * privilege - 用户特权信息,json数组,如微信沃卡用户为(chinaunicom); + * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ +interface PlusOauthUserInfo { + /** + * 登录授权用户的唯一标识 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + openid?: string; + /** + * 登录授权用户的头像图片地址 + * 要求为"http://"或"https://"开头的地址,如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + headimgurl?: string; + /** + * 登录授权用户的昵称 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + nickname?: string; + /** + * 登录授权用户的邮箱地址 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + email?: string; + /** + * 登录授权用户的电话号码 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + phonenumber?: string; + /** + * 登录授权用户的性别 + * 1为男性,2为女性。 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + sex?: string; + /** + * 登录授权用户注册的省份信息 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + province?: string; + /** + * 登录授权用户注册的城市信息 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + city?: string; + /** + * 登录授权用户注册的国家信息 + * 如果登录授权服务不支持此属性,则返回"undefined"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) + */ + country?: string; +} + +/** + * Payment模块管理支付功能,用于提供网页安全支付能力,支持通过Web接口进行支付操作。通过plus.payment可获取支付管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPayment { + /** + * 支付通道对象 + * PaymentChannel对象表示特定的支付通道,用于向系统请求支付操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + PaymentChannel?: PlusPaymentPaymentChannel; + /** + * IAP订单数据对象 + * 描述IAP商品订单信息,如标识、数量等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + OrderStatementIAP?: PlusPaymentOrderStatementIAP; + /** + * 支付操作结果对象 + * PaymentResult对象表示支付操作返回结果,用于确认支付操作成功。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + PaymentResult?: PlusPaymentPaymentResult; + /** + * IAP商品对象 + * 描述IAP商品详细信息,如标识、价格、标题、描述信息等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + IAPProduct?: PlusPaymentIAPProduct; + /** + * 购买IAP商品对象 + * 描述购买的IAP商品详细信息,如标识、数量等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + IAPProductInfo?: PlusPaymentIAPProductInfo; + /** + * 购买IAP商品交易信息对象 + * 描述购买的IAP商品交易详细信息,如购买商品信息、交易日期、订单标识等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + IAPTransaction?: PlusPaymentIAPTransaction; + /** + * 获取支付通道 + * 在进行支付操作前需获取终端支持的支付通道列表,用于提示用户进行选择。 + * 获取支付通道成功后通过successCB回调返回支持的所有通道列表,获取支付通道列表失败则通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + getChannels(successCB?: (result: PlusPayment []) => void, errorCB?: (result: any) => void): void; + /** + * 请求支付操作 + * 调用指定的支付通道进行支付操作,其中statement包含支付操作的相关信息,支付模块将弹出支付界面供用户进行支付信息的输入确认操作。 + * 用户支付操作成功后通过successCB回调返回支付操作结果,支付操作失败则通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + request(channel?: PlusPaymentPaymentChannel, statement?: string, successCB?: (result: PlusPaymentPaymentResult) => void, errorCB?: (result: any) => void): void; +} + +/** + * 支付通道对象 + * PaymentChannel对象表示特定的支付通道,用于向系统请求支付操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPaymentPaymentChannel { + /** + * 支付通道标识 + * 用于标识支付通道: + * "alipay" - 表示支付宝; + * "wxpay" - 表示微信支付; + * "appleiap" - 表示苹果应用内支付; + * "qhpay" - 表示360聚合支付(仅360手助流应用环境下支持)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + id?: string; + /** + * 支付通道描述 + * 支付通道的描述信息,如“支付宝”、“微信”、“In-App Purchase”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + description?: string; + /** + * 支付通道服务是否安装 + * 通常特定的支付通道依赖系统安装相关的服务,此属性用于标识其服务是否安装,如果没有安装则为false,否则为true。 + * 若系统环境中没有安装相关的服务,则可能导致调用支付操作失败,这时可以调用installService方法进行安装。 + * 注意:如果支付通道不需要依赖系统安装服务,则永远返回true。例如支付宝,如果设备上未安装支付宝客户端则调用Wap页面进行支付,因此值固定返回true; + * 而微信支付则依赖微信客户端,如果设备上未安装微信客户端则serviceReady值为false,此时应该提示用户安装微信客户端才能进行支付操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + serviceReady?: boolean; + /** + * 安装支付通道依赖的服务 + * 对于某些支付通道,通常特定的支付通道依赖系统安装相关的服务,调用此方法将安装其依赖的支付服务。 + * 如支付宝,则在系统中安装支付宝客户端程序。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + installService(): void; + /** + * 向IAP服务器请求支付订单 + * IAP支付在调用plus.payment.request方法支付前须先向服务器请求获取商品的详细信息,否则会支付失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + requestOrder(ids?: any [], successCB?: (result: PlusPayment []) => void, errorCB?: (result: any) => void): void; + /** + * 向IAP服务器请求已经购买的非消耗性商品和订阅商品 + * 注意:不能获取已购买的消耗性商品。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + restoreComplateRequest(options?: any, successCB?: (result: PlusPayment []) => void): void; +} + +/** + * IAP订单数据对象 + * 描述IAP商品订单信息,如标识、数量等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPaymentOrderStatementIAP { + /** + * 商品的标识 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + productid?: string; + /** + * 购买用户名称 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + username?: string; + /** + * 商品数量 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + quantity?: string; +} + +/** + * 支付操作结果对象 + * PaymentResult对象表示支付操作返回结果,用于确认支付操作成功。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPaymentPaymentResult { + /** + * 支付通道对象 + * 用于发起支付操作的支付通道对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + channel?: PlusPaymentPaymentChannel; + /** + * 交易编号信息 + * 如果支付平台不支持此数据则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + tradeno?: string; + /** + * 交易描述信息 + * 如果支付平台不支持此数据则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + description?: boolean; + /** + * 查找支付交易信息地址 + * 用于向支付平台查询交易信息,如果支付平台不支持此数据则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + url?: boolean; + /** + * 支付操作指纹信息 + * 用于向支付平台查询支付订单信息,如果支付平台不支持此数据则返回undefined。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + signature?: string; + /** + * 支付平台返回的原始数据 + * 如果支付平台返回key-value类型字符串,则组合成符合JSON格式的字符串。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + rawdata?: string; +} + +/** + * IAP商品对象 + * 描述IAP商品详细信息,如标识、价格、标题、描述信息等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPaymentIAPProduct { + /** + * 商品的标识 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + productid?: string; + /** + * 商品的价格 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + price?: string; + /** + * 商品标题 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + title?: string; + /** + * 商品的描述信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + description?: string; +} + +/** + * 购买IAP商品对象 + * 描述购买的IAP商品详细信息,如标识、数量等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPaymentIAPProductInfo { + /** + * 商品的标识 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + productIdentifier?: string; + /** + * 商品的数量 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + quantity?: string; +} + +/** + * 购买IAP商品交易信息对象 + * 描述购买的IAP商品交易详细信息,如购买商品信息、交易日期、订单标识等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ +interface PlusPaymentIAPTransaction { + /** + * 购买商品的信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + payment?: string; + /** + * 购买商品的交易日期 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + transactionDate?: string; + /** + * 购买商品的交易订单标识 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + transactionIdentifier?: string; + /** + * 购买商品的交易收据 + * base64编码格式字符串数据。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + transactionReceipt?: string; + /** + * 购买商品的交易状态 + * 可取值:"1"为支付成功;"2"为支付失败;"3"为支付已恢复。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) + */ + transactionState?: string; +} + +/** + * Push模块管理推送消息功能,可以实现在线、离线的消息推送,通过plus.push可获取推送消息管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ +interface PlusPush { + /** + * JSON对象,获取的客户端标识信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + ClientInfo?: PlusPushClientInfo; + /** + * JSON对象,推送消息对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + PushMessage?: PlusPushPushMessage; + /** + * JSON对象,获客户端创建本地消息的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + MessageOptions?: PlusPushMessageOptions; + /** + * 添加推送消息事件监听器 + * 添加推送消息事件监听器,当指定推送事件发出时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + addEventListener(type?: string, listener?: (result: string) => void, capture?: boolean): void; + /** + * 清空所有推送消息 + * 清空系统消息中心所有的推送消息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + clear(): void; + /** + * 创建本地消息 + * 在本地直接创建推送消息,并添加到系统消息中心。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + createMessage(content?: string, payload?: string, options?: PlusPushMessageOptions): void; + /** + * 获取所有推送消息 + * 获取客户端接收到的所有推送消息。 + * 仅包括在系统消息中心显示的推送消息,不包括调用setAutoNotification(false)方法设置不显示推送消息后接收到的消息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + getAllMessage(): PlusPushPushMessage; + /** + * 获取客户端推送标识信息 + * 客户端标识信息用于业务服务器下发推送消息时提交给推送服务器的数据,用于说明下发推送消息的接收者(客户端)。需要客户端在第一次运行时提交到业务服务器保存。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + getClientInfo(): PlusPushClientInfo; + /** + * 设置程序是否将消息显示在系统消息中心 + * 默认情况下程序在接收到推送消息后将会在系统消息中心显示,通过此方法可关闭默认行为,接收到推送消息后不在系统消息中心显示,通过addEventListener方法的“receive”事件监听处理接收到的消息。 + * 在这种模式下可通过createMessage方法创建在系统消息中心显示的消息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + setAutoNotification(notify?: boolean): void; + /** + * 删除推送消息 + * 删除系统消息中心指定的推送消息,可通过getAllMessage方法获取所有的消息后进行操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + remove(message?: PlusPushPushMessage): void; +} + +/** + * JSON对象,获取的客户端标识信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ +interface PlusPushClientInfo { + /** + * 设备令牌(iOS设备唯一标识),用于APNS服务推送中标识设备的身份 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + token?: string; + /** + * 推送服务令牌(设备唯一标识),用于标识推送信息接收者身份 + * 第三方推送服务器管理的设备唯一标识,在iOS平台此值通常与token不同;在其它平台此值通常与token值一致。 + * 此值与设备及应用都相关,即不同的apk/ipa安装到同一台设备上的值都不相同。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + clientid?: string; + /** + * 第三方推送服务的应用标识 + * 第三方推送服务器管理的应用标识,通常需要在第三方推送服务器平台进行注册获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + appid?: string; + /** + * 第三方推送服务器的应用键值 + * 第三方推送服务器管理的应用键值,通常需要在第三方推送服务器平台进行注册获取。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + appkey?: string; +} + +/** + * JSON对象,推送消息对象 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ +interface PlusPushPushMessage { + /** + * 推送消息显示的标题 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + title?: string; + /** + * 推送消息显示的内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + content?: string; + /** + * 推送消息承载的数据 + * 如果推送消息中传输的数据不符合JSON格式,则作为String类型数据保存。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + payload?: any; + /** + * Apple APNS推送协议数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + aps?: any; +} + +/** + * JSON对象,获客户端创建本地消息的参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ +interface PlusPushMessageOptions { + /** + * 要启动流应用的appid + * 默认值为当前流应用的appid。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + appid?: string; + /** + * 是否覆盖上一次提示的消息 + * 可取值true或false,true为覆盖,false不覆盖,默认为permission中设置的cover值。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + cover?: boolean; + /** + * 提示消息延迟显示的时间 + * 当设备接收到推送消息后,可不立即显示,而是延迟一段时间显示,延迟时间单位为s,默认为0s,立即显示。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + delay?: number; + /** + * 推送消息的图标 + * 本地图片地址,相对路径 - 相对于当前页面的host位置,如"a.jpg",注意当前页面为网络地址则不支持; 绝对路径 - 系统绝对路径,如Android平台"/sdcard/logo.png",此类路径通常通过其它5+ API获取的; 扩展相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_www/a.jpg"; 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + icon?: string; + /** + * 推送消息的提示音 + * 显示消息时的播放的提示音,可取值: + * “system”-表示使用系统通知提示音; + * “none”-表示不使用提示音; + * 默认值为“system”。 + * - system: 使用系统通知提示音 + * - none: 不使用提示音 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + sound?: 'system' | 'none'; + /** + * 推送消息的标题 + * 在系统消息中心显示的通知消息标题,默认值为程序的名称。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + title?: string; + /** + * 消息上显示的提示时间 + * 默认为当前时间,如果延迟显示则使用延时后显示消息的时间。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) + */ + when?: Date; +} + +/** + * Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShare { + /** + * JSON对象,分享授权认证参数选项 + * 此对象支持的属性值由分享服务的授权认证模块定义。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + AuthOptions?: PlusShareAuthOptions; + /** + * 分享授权控件对象 + * Authorize对象表示分享控件对象,用于在窗口中显示分享控件,使用此对象可自定义分享授权界面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + Authorize?: PlusShareAuthorize; + /** + * JSON对象,用户位置信息 + * GeoPosition对象用于表示用户分享消息时的位置信息。用于标识分享操作时用户的位置信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + GeoPosition?: PlusShareGeoPosition; + /** + * 分享服务对象 + * ShareService对象用于表示分享服务,在JS中为对象,用于向系统请求分享操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + ShareService?: PlusShareShareService; + /** + * 分享服务标识 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + ShareServerIdentity?: PlusShareShareServerIdentity; + /** + * JSON对象,分享消息对象 + * ShareMessage对象用于表示分享消息内容,在JS中为JSON对象,用于向系统发送分享信息操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + ShareMessage?: PlusShareShareMessage; + /** + * JSON对象,保存分享消息扩展信息 + * ShareMessageExtra对象用于保存各分享平台扩展的参数,用于自定义分享功能。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + ShareMessageExtra?: PlusShareShareMessageExtra; + /** + * JSON对象,微信小程序信息 + * 用于配置分享小程序的参数,如小程序标识、页面路径等。 + * 注意:分享的小程序需要在微信开放平台关联的开发者账号下,否则会分享失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + WeixinMiniProgramOptions?: PlusShareWeixinMiniProgramOptions; + /** + * 获取分享服务 + * 获取终端支持的分享通道列表,可用于提示用户进行分享服务器的选择。获取分享服务成功后通过successCB回调返回支持的所有服务列表,获取服务失败则通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + getServices(successCB?: (result: PlusShare []) => void, errorCB?: (result: any) => void): void; + /** + * 使用系统组件发送分享 + * 调用系统分享组件分享消息,通过msg参数设置分享内容。 + * 发送成功后通过successCB回调函数通知操作完成,发送失败则通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + sendWithSystem(msg?: PlusShareShareMessage, successCB?: () => void, errorCB?: (result: any) => void): void; +} + +/** + * JSON对象,分享授权认证参数选项 + * 此对象支持的属性值由分享服务的授权认证模块定义。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareAuthOptions { + /** + * 分享服务平台申请的appid + * 动态设置分享服务授权认证时需要使用的appid,仅需要此参数的分享服务(如“微信”、“QQ”)支持。 + * 如果未设置则使用运行环境中内置的appid值(如在HBuilder中可在manifest.json的“SDK配置”项中进行设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + appid?: string; + /** + * 分享服务平台申请的appkey + * 动态设置分享服务授权认证时需要使用的appkey,仅需要此参数的分享服务(如“新浪微博”)支持。 + * 如果未设置则使用运行环境中内置的appkey值(如在HBuilder中可在manifest.json的“SDK配置”项中进行设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + appkey?: string; + /** + * 分享服务平台申请的appsecret + * 动态设置分享服务中需要使用的appsecret,仅需要此参数的分享服务(如“微信”、“新浪微博”)支持。 + * 如果未设置则使用运行环境中内置的appsecret值(如在HBuilder中可在manifest.json的“SDK配置”项中进行设置);当开放平台申请的appsecret值涉及到安全问题时,可在应用运行时从服务器获取,然后通过此api动态设置。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + appsecret?: string; + /** + * 分享服务平台申请的redirect_url + * 动态设置分享服务中需要使用的redirect_url,仅需要此参数的登录授权服务(如“新浪微博登录”)支持。 + * 如果未设置则使用运行环境中内置的redirect_url值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + redirect_url?: string; +} + +/** + * 分享授权控件对象 + * Authorize对象表示分享控件对象,用于在窗口中显示分享控件,使用此对象可自定义分享授权界面。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareAuthorize { + /** + * 分享控件加载完成事件 + * 分享授权控件内容加载完成事件,通过调用load方法加载分享授权控件内容,当内容加载完成时触发。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + onloaded?: (result: any) => void; + /** + * 分享授权认证成功事件 + * 用户在分享授权控件上输入操作授权成功时触发,事件方法格式参考ShareSuccessCallback回调函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + onauthenticated?: () => void; + /** + * 分享授权认证失败事件 + * 用户在分享授权控件上输入操作授权认证错误时触发,事件方法格式参考ShareErrorCallback回调函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + onerror?: (result: any) => void; + /** + * 加载分享授权页面 + * 创建分享授权页面后,需要调用此方法指定分享服务标识来加载授权页面数据,此标识可使用ShareService对象的id属性。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + load(id?: string): void; + /** + * 设置分享授权控件是否可见 + * 创建分享授权页面后,调用此方法设置分享授权控件在页面中是否可见。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + setVisible(visible?: boolean): void; +} + +/** + * JSON对象,用户位置信息 + * GeoPosition对象用于表示用户分享消息时的位置信息。用于标识分享操作时用户的位置信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareGeoPosition { + /** + * 用户位置的纬度坐标信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + latitude?: number; + /** + * 用户位置的经度坐标信息 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + longitude?: number; +} + +/** + * 分享服务对象 + * ShareService对象用于表示分享服务,在JS中为对象,用于向系统请求分享操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareShareService { + /** + * 分享服务标识 + * 用于表示分享服务标识: + * "sinaweibo" - 表示新浪微博; + * "tencentweibo" - 表示腾讯微博; + * "weixin" - 表示微信; + * "qq" - 表示腾讯QQ。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + id?: PlusShareShareServerIdentity; + /** + * 分享服务描述 + * 用于描述分享服务的信息: + * 如“新浪微博”、“腾讯微博”、“微信”、“QQ”。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + description?: string; + /** + * 是否授权认证 + * 用于标识此分享是否已经授权认证过,true表示已完成授权认证;false表示未完成授权认证。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + authenticated?: boolean; + /** + * 授权认证信息 + * 仅在authenticated为true时有效,标识客户认证标识信息,用于发送分享信息。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + accessToken?: string; + /** + * 是否存在对应的分享客户端 + * 对于某些分享服务,可直接调用本地客户端程序进行授权认证,此属性即可提供此相关信息,若没有安装本地客户端则可能调用其它方式进行分享操作,如WAP方式等。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + nativeClient?: boolean; + /** + * 授权认证操作 + * 对指定的分享服务进行授权认证操作,在授权前可通过ShareService.authenticated属性判断是否已经授权过,通常只需要对没有进行过授权认证的服务进行授权认证操作。 + * 授权认证操作成功后通过successCB回调函数通知操作完成,操作失败则通过errorCB回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + authorize(successCallback?: (result: PlusShareShareService) => void, errorCallback?: (result: any) => void, options?: PlusShareAuthOptions): void; + /** + * 取消授权认证 + * 对指定的分享服务取消授权认证操作,取消授权认证后,再次分享时需重新进行授权操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + forbid(): void; + /** + * 发送分享 + * 发送分享消息,分享消息的内容通过msg设置。 + * 发送成功后通过successCB回调函数通知操作完成,发送失败则通过errorCB回调返回。若分享服务没有进行授权认证或授权认证失效则触发失败回调函数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + send(msg?: PlusShareShareMessage, successCB?: () => void, errorCB?: (result: any) => void): void; + /** + * 调用微信小程序 + * 注意:需在微信开放平台将应用关联小程序才能正常调用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + launchMiniProgram(options?: PlusShareWeixinMiniProgramOptions): void; +} + +/** + * 分享服务标识 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareShareServerIdentity { + /** + * 新浪微博 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + sinaweibo?: string; + /** + * 腾讯微博 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + tencentweibo?: string; + /** + * 微信 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + weixin?: string; +} + +/** + * JSON对象,分享消息对象 + * ShareMessage对象用于表示分享消息内容,在JS中为JSON对象,用于向系统发送分享信息操作。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareShareMessage { + /** + * 分享消息的类型 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + type?: string; + /** + * 分享消息的文字内容 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + content?: string; + /** + * 分享消息的图片 + * 分享消息中包含的图片路径,仅支持本地路径。 + * 若分享平台仅支持提交一张图片,传入多张图片则仅提交第一张图片。 + * 如果未指定type类型,优先级顺序为:pictures>content(即设置了pictures则认为分享图片类型)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + pictures?: any []; + /** + * 分享消息的缩略图 + * 分享消息中包含的缩略图路径,支持本地路径及网络路径。 + * 若分享平台仅支持提交一张图片,传入多张图片则仅提交第一张图片。 + * 如果分享平台的信息不支持缩略图,若没有设置消息的图片(pictures)则使用缩略图,否则忽略其属性值。 + * 注意:图片有大小限制,推荐图片小于20Kb。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + thumbs?: any []; + /** + * 分享的多媒体资源 + * 分享的多媒体资源地址,当type值为"music"、"video"时有效。 + * 注意: + * 微信分享平台支持音乐、视频类型,仅支持网络地址(以http://或https://开头); + * QQ分享平台支持音乐类型,仅支持网络路径(以http://或https://开头); + * 新浪微博分享平台支持视频类型,仅支持本地文件路径。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + media?: string; + /** + * 分享独立的链接 + * 分享资源地址,仅支持网络地址(以http://或https://开头)。 + * 如果未指定type类型,优先级顺序为:href>pictures>content(即设置了href则认为分享网页类型)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + href?: string; + /** + * 分享消息的标题 + * 仅微信分享网页、音频、视频、小程序类型时支持。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + title?: string; + /** + * 分享消息中包含的用户地理信息数据 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + geo?: PlusShareGeoPosition; + /** + * 分享消息扩展参数 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + extra?: PlusShareShareMessageExtra; + /** + * 分享微信小程序参数 + * 仅微信分享小程序类型时支持。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + miniProgram?: PlusShareWeixinMiniProgramOptions; + /** + * 分享消息的模式 + * 可取值: + * "auto" - 自动选择,如果已经安装微博客户端则采用编辑界面进行分享,否则采用无界面分享; + * "slient" - 静默分享,采用无界面模式进行分享; + * "editable" - 进入编辑界面,用户确认分享内容后发送,如果当前未安装微博客户端则触发错误回调。 + * 默认值为"auto"。 + * (仅新浪微博分享时生效) + * - auto: + * 自动选择,如果已经安装微博客户端则采用编辑界面进行分享,否则采用无界面分享 + * + * - slient: + * 静默分享,采用无界面模式进行分享 + * + * - editable: + * 进入编辑界面,用户确认分享内容后发送,如果当前未安装微博客户端则触发错误回调 + * + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + interface?: 'auto' | 'slient' | 'editable'; +} + +/** + * JSON对象,保存分享消息扩展信息 + * ShareMessageExtra对象用于保存各分享平台扩展的参数,用于自定义分享功能。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareShareMessageExtra { + /** + * 微信分享场景,仅微信分享平台有效 + * 可取值: + * "WXSceneSession"分享到微信的“我的好友”; + * "WXSceneTimeline"分享到微信的“朋友圈”中; + * "WXSceneFavorite"分享到微信的“我的收藏”中。 + * 默认值为"WXSceneSession"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + scene?: string; +} + +/** + * JSON对象,微信小程序信息 + * 用于配置分享小程序的参数,如小程序标识、页面路径等。 + * 注意:分享的小程序需要在微信开放平台关联的开发者账号下,否则会分享失败。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ +interface PlusShareWeixinMiniProgramOptions { + /** + * 微信小程序ID + * 注意:是微信小程序的原始ID("g_"开头的字符串)。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + id?: string; + /** + * 微信小程序打开的页面路径 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + path?: string; + /** + * 微信小程序版本类型 + * 可取值: + * 0-正式版; + * 1-测试版; + * 2-体验版。 + * 默认值为0。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + type?: number; + /** + * 兼容低版本的网页链接 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) + */ + webUrl?: string; +} + +/** + * Speech模块管理语音输入功能,提供语音识别功能,可支持用户通过麦克风设备进行语音输入内容。通过plus.speech可获取语音输入管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ +interface PlusSpeech { + /** + * JSON对象,语音识别参数 + * 控制语音识别引擎内部参数,在JS中为JSON对象,在启动语音识别时使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + SpeechRecognizeOptions?: PlusSpeechSpeechRecognizeOptions; + /** + * 语音识别事件类型 + * 描述语音过程的触发事件列表,可以通过调用plus.sppech.addEventListener方法进行注册监听。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + SpeechRecoginzeEvents?: PlusSpeechSpeechRecoginzeEvents; + /** + * 启动语音识别 + * 启动语音识别时调用,当语音识别成功后通过successCallback回调返回识别出文本内容,调用语音识别失败则通过errorCallback回调返回。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + startRecognize(options?: PlusSpeechSpeechRecognizeOptions, successCB?: (result: string) => void, errorCB?: (result: any) => void): void; + /** + * 停止语音识别 + * 当语音识别完成时或用户取消语音识别时调用,调用此方法将导致errorCallback回调函数的调用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + stopRecognize(): void; + /** + * 监听语音识别事件 + * 向语音识别模块添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 可多次调用此方法添加多个监听器,当监听的事件发生时,将按照添加的先后顺序触发执行。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + addEventListener(event?: PlusSpeechSpeechRecoginzeEvents, listener?: (result: any) => void, capture?: boolean): void; +} + +/** + * JSON对象,语音识别参数 + * 控制语音识别引擎内部参数,在JS中为JSON对象,在启动语音识别时使用。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ +interface PlusSpeechSpeechRecognizeOptions { + /** + * 语音识别是否采用持续模式 + * 设置为true表示语音引擎不会根据语音输入自动结束,识别到文本内容将多次调用successCallback函数返回,如果需要结束语音识别则必须调用stopRecognize接口,默认值为false。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + continue?: boolean; + /** + * 语音识别引擎标识 + * 用于兼容多语音识别引擎的浏览器,使用语音识别厂商的产品名称,如未设置或设置不正确则使用运行环境默认的语音识别引擎。 + * 支持以下语音识别引擎: + * "baidu"-百度语音识别; + * "iFly"-讯飞语音识别。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + engine?: string; + /** + * 语音识别引擎的语言 + * 用于定义语音识别引擎的语言,其取值需符合W3C的Language codes规范。 + * 目前讯飞语音支持以下语言: + * "zh-cn"-中文,普通话; + * "en-us"-英语; + * "zh-cantonese"-中文,粤语; + * "zh-henanese"-中文,河南话(百度语音识别不支持此语言)。 + * 默认值为"zh-cn"。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + lang?: string; + /** + * 指定识别结果识别包括多候选结果 + * 用于指定识别结果识别包括多候选结果。如nbest:3,识别返回3个候选结果,默认值为1。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + nbest?: number; + /** + * 识别结果中是否包含标点符号 + * true表示识别结果文本中包含标点符号,false表示识别结果文本中不包含标点符号。 + * 默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + punctuation?: boolean; + /** + * 语音识别超时时间 + * 语音识别超时的时间,单位为ms,默认值为1000(即10秒)。 + * 注:百度语音识别不支持此参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + timeout?: number; + /** + * 识别时是否显示用户界面 + * 用于指定识别时是否显示用户界面,设置为true表示显示浏览器内置语音识别界面;设置为false表示不显示浏览器内置语音识别界面。默认值为true。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + userInterface?: boolean; + /** + * 语音识别开始事件(已废弃,使用start事件) + * 事件函数,语音识别开始启动,在调用startRecognize方法后触发,与onend事件成对触发。 + * 注:iOS平台未支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + onstart?: (result: any) => void; + /** + * 语音识别结束事件(已废弃,使用end事件) + * 事件函数,语音识别结束,在调用stopRecognize方法后触发,或者在引擎内部自动完成语音识别后触发,与onstart事件成对触发。 + * 注:iOS平台未支持 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + onend?: (result: any) => void; +} + +/** + * 语音识别事件类型 + * 描述语音过程的触发事件列表,可以通过调用plus.sppech.addEventListener方法进行注册监听。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ +interface PlusSpeechSpeechRecoginzeEvents { + /** + * 开始语音识别 + * 调用plus.speech.startRecognize方法开始语音识别时触发。 + * 无回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + start?: string; + /** + * 音量变化 + * 开始语音识别后,麦克风录制到的语音音量变化时触发。 + * 回调函数参数event={volume:"Number类型,取值范围0-1"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + volumeChange?: string; + /** + * 临时语音识别结果 + * 返回临时语音识别结果时触发。 + * 回调函数参数event={partialResult:"String类型,临时识别结果"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + recognizing?: string; + /** + * 最终语音识别 + * 返回最终语音识别结果。 + * 回调函数参数event={result:"String类型,最佳识别结果",results:"String数组类型,所有候选结果"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + recognition?: string; + /** + * 结束语音识别 + * 调用plus.speech.stopRecognize方法结束语音识别或语音识别完成后自动结束时触发。 + * 无回调函数参数。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + end?: string; + /** + * 语音识别错误 + * 语音识别发生错误时触发。 + * 回调函数参数event={code:"Number类型,错误编码",message:"String类型,错误描述信息"}。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) + */ + error?: string; +} + +/** + * Statistic模块管理统计功能,用于提供应用内统计的能力,支持统计和分析用户属性和用户行为数据。通过plus.statistic可获取统计管理对象。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) + */ +interface PlusStatistic { + /** + * 触发事件 + * 触发指定的统计事件,触发的事件必须要先在统计网站上注册事件ID。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) + */ + eventTrig(id?: string, value?: any): void; + /** + * 精确持续事件 + * 精确时长的持续事件统计,触发的事件必须要先在统计网站上注册事件ID。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) + */ + eventDuration(id?: string, duration?: number, value?: any): void; + /** + * 开始持续事件(过期API,不推荐使用) + * 开始指定的持续事件统计,当事件结束时调用eventEnd方法,,触发的事件必须要先在统计网站上注册事件ID。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) + */ + eventStart(id?: string, value?: string): void; + /** + * 结束持续事件(过期API,不推荐使用) + * 结束指定的持续事件统计,需先调用eventStart方法开始持续事件统计,触发的事件必须要先在统计网站上注册事件ID。 + * + * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) + */ + eventEnd(id?: string, label?: string): void; +} diff --git a/types/chokidar/tsconfig.json b/types/html5plus/tsconfig.json similarity index 94% rename from types/chokidar/tsconfig.json rename to types/html5plus/tsconfig.json index 77a34a3964..634c3eb205 100644 --- a/types/chokidar/tsconfig.json +++ b/types/html5plus/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "chokidar-tests.ts" + "html5plus-tests.ts" ] } \ No newline at end of file diff --git a/types/html5plus/tslint.json b/types/html5plus/tslint.json new file mode 100644 index 0000000000..661e47a018 --- /dev/null +++ b/types/html5plus/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "max-line-length": false, + "no-trailing-whitespace": false + } +} \ No newline at end of file diff --git a/types/httperr/httperr-tests.ts b/types/httperr/httperr-tests.ts index ee1f6d8567..db58b1a487 100644 --- a/types/httperr/httperr-tests.ts +++ b/types/httperr/httperr-tests.ts @@ -52,7 +52,7 @@ console.log(err instanceof Error); // true // ---------------------------------------- // Advanced usage: creating custom Error subclasses -var Custom404Error = httperr.createHttpError(404, 'Not Found', config => { +var Custom404Error = httperr.createHttpError(404, 'Not Found', function (config) { this.message = 'The resource was not found'; this['some custom property'] = config.parameters['some custom parameter']; }); diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index 656c492df6..b0f465719a 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/hubotio/hubot // Definitions by: Dirk Gadsden // Kees C. Bakker +// Emil Marklund // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Hubot { @@ -40,6 +41,8 @@ declare namespace Hubot { readonly adapter: A; constructor(adapterPath: string, adapter: string, httpd: boolean, name: string, alias?: string); + catchAll(callback: ListenerCallback): void; + catchAll(options: any, callback: ListenerCallback): void; hear(regex: RegExp, callback: ListenerCallback): void; hear(regex: RegExp, options: any, callback: ListenerCallback): void; helpCommands(): string[]; diff --git a/types/humanize-ms/humanize-ms-tests.ts b/types/humanize-ms/humanize-ms-tests.ts new file mode 100644 index 0000000000..bd329751f3 --- /dev/null +++ b/types/humanize-ms/humanize-ms-tests.ts @@ -0,0 +1,5 @@ +import HumanizeMs = require("humanize-ms"); + +HumanizeMs('1s'); + +HumanizeMs(1000); diff --git a/types/humanize-ms/index.d.ts b/types/humanize-ms/index.d.ts new file mode 100644 index 0000000000..40462c5782 --- /dev/null +++ b/types/humanize-ms/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for humanize-ms 1.2 +// Project: https://github.com/node-modules/humanize-ms +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function HumanizeMS(input: string|number): number; + +export = HumanizeMS; diff --git a/types/humanize-ms/tsconfig.json b/types/humanize-ms/tsconfig.json new file mode 100644 index 0000000000..2e451381a9 --- /dev/null +++ b/types/humanize-ms/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "humanize-ms-tests.ts" + ] +} diff --git a/types/humanize-ms/tslint.json b/types/humanize-ms/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/humanize-ms/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/icepick/icepick-tests.ts b/types/icepick/icepick-tests.ts index 5458509d42..f1d536e78f 100644 --- a/types/icepick/icepick-tests.ts +++ b/types/icepick/icepick-tests.ts @@ -1,5 +1,4 @@ import i = require("icepick"); -import * as _ from 'underscore'; "use strict"; // so attempted modifications of frozen objects will throw errors @@ -146,15 +145,13 @@ class Foo {} { i.map(function(v) { return v * 2 }, [1, 2, 3]); // [2, 4, 6] - var removeEvens = _.partial(i.filter, function(v: number) { return v % 2; }); - - removeEvens([1, 2, 3]); // [1, 3] + i.filter(function(v: number) { return v % 2 === 0; }, [1, 2, 3]); // [1, 3] } { var arr = i.freeze([{ a: 1 }, { b: 2 }]); //ECMAScript 2015 - //arr.find(function(item) { return item.b != null; }); // {b: 2} + //arr.find(function(item) { return item.b != null; }); // {b: 2} } // chain(coll) - not defined diff --git a/types/imap-simple/index.d.ts b/types/imap-simple/index.d.ts index 398bcb6a26..f346d51e52 100644 --- a/types/imap-simple/index.d.ts +++ b/types/imap-simple/index.d.ts @@ -55,7 +55,7 @@ export class ImapSimple extends NodeJS.EventEmitter { getBoxes(callback: (err: Error, boxes: Imap.MailBoxes) => void): void; getBoxes(): Promise; - /** Search for and retrieve mail in the previously opened mailbox. */ + /** Search for and retrieve mail in the currently open mailbox. */ search(searchCriteria: any[], fetchOptions: Imap.FetchOptions, callback: (err: Error, messages: Message[]) => void): void; search(searchCriteria: any[], fetchOptions: Imap.FetchOptions): Promise; diff --git a/types/ink-spinner/package.json b/types/ink-spinner/package.json new file mode 100644 index 0000000000..6c2f5b70e4 --- /dev/null +++ b/types/ink-spinner/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "chalk": "^2.1.0" + } +} diff --git a/types/ink-table/index.d.ts b/types/ink-table/index.d.ts new file mode 100644 index 0000000000..a225084f59 --- /dev/null +++ b/types/ink-table/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for ink-table 1.0 +// Project: https://github.com/maticzav/ink-table#readme +// Definitions by: Łukasz Ostrowski +// Definitions: https://github.com/DefinitelyTyped/ +// TypeScript Version: 2.8 + +import { InkComponent, InkNode, StatelessComponent } from 'ink'; + +export interface TableProps { + cell?: InkComponent; + data?: ReadonlyArray; + header?: InkComponent; + padding?: number; + skeleton?: InkComponent; +} + +export const Cell: StatelessComponent<{ children: InkNode }>; +export const Header: StatelessComponent<{ children: InkNode }>; +export const Skeleton: StatelessComponent<{ children: InkNode }>; + +declare const Table: StatelessComponent; + +export default Table; diff --git a/types/ink-table/ink-table-tests.tsx b/types/ink-table/ink-table-tests.tsx new file mode 100644 index 0000000000..53f3eb0c3b --- /dev/null +++ b/types/ink-table/ink-table-tests.tsx @@ -0,0 +1,45 @@ +/** @jsx h */ +import { h } from 'ink'; +import Table from 'ink-table'; + +const data = [ + { + name: 'Sosa Saunders', + gender: 'male', + age: 17, + email: 'sosa.saunders@mail.com', + phone: '+1 (809) 435-2786' + }, + { + name: 'Angelina Kirk', + gender: 'female', + age: 3, + email: 'angelina@kirk.io', + phone: '+1 (870) 567-3516' + }, + { + name: 'Bradford Rosales', + gender: 'male', + age: 20, + email: 'bradfordrosales@fast.com', + phone: '+1 (918) 573-3240' + }, + { + name: 'Gwen Schroeder', + gender: 'female', + age: 17, + email: 'gwen@corp.xyz', + phone: '+1 (987) 417-2062' + }, + { + name: 'Ellison Mann', + gender: 'male', + age: 5, + email: 'ellisonmann@katakana.com', + phone: '+1 (889) 411-2186' + } +]; + +const Basic = () => ( + +); diff --git a/types/ink-table/tsconfig.json b/types/ink-table/tsconfig.json new file mode 100644 index 0000000000..0bc43e3305 --- /dev/null +++ b/types/ink-table/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "jsx": "react", + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ink-table-tests.tsx" + ] +} diff --git a/types/p-event/tslint.json b/types/ink-table/tslint.json similarity index 100% rename from types/p-event/tslint.json rename to types/ink-table/tslint.json diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index 5d976e896d..74aee08ed3 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -81,6 +81,7 @@ declare namespace inquirer { * Possible values: *
    *
  • input
  • + *
  • number
  • *
  • confirm
  • *
  • list
  • *
  • rawlist
  • diff --git a/types/internal-ip/index.d.ts b/types/internal-ip/index.d.ts deleted file mode 100644 index 1bed7e9059..0000000000 --- a/types/internal-ip/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Type definitions for internal-ip 3.0 -// Project: https://github.com/sindresorhus/internal-ip#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export const v6: IPGetterFn; -export const v4: IPGetterFn; - -export interface IPGetterFn { // tslint:disable-line:interface-name - (): Promise; - sync(): string | null; -} diff --git a/types/internal-ip/internal-ip-tests.ts b/types/internal-ip/internal-ip-tests.ts deleted file mode 100644 index 1b383de2f3..0000000000 --- a/types/internal-ip/internal-ip-tests.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as internalIp from 'internal-ip'; - -internalIp.v6().then(ip => { - // $ExpectType string | null - ip; -}); -// $ExpectType string | null -internalIp.v6.sync(); - -internalIp.v4().then(ip => { - // $ExpectType string | null - ip; -}); -// $ExpectType string | null -internalIp.v4.sync(); diff --git a/types/internal-ip/v2/index.d.ts b/types/internal-ip/v2/index.d.ts deleted file mode 100644 index a82dd8c913..0000000000 --- a/types/internal-ip/v2/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Type definitions for internal-ip 2.0 -// Project: https://github.com/sindresorhus/internal-ip#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export function v6(): Promise; -export function v4(): Promise; diff --git a/types/internal-ip/v2/internal-ip-tests.ts b/types/internal-ip/v2/internal-ip-tests.ts deleted file mode 100644 index e94ec9f510..0000000000 --- a/types/internal-ip/v2/internal-ip-tests.ts +++ /dev/null @@ -1,10 +0,0 @@ -import * as internalIp from 'internal-ip'; - -let str: string; -internalIp.v6().then(ip => { - str = ip; -}); - -internalIp.v4().then(ip => { - str = ip; -}); diff --git a/types/ioredis/index.d.ts b/types/ioredis/index.d.ts index cbe5b0f8e2..99c99dcf04 100644 --- a/types/ioredis/index.d.ts +++ b/types/ioredis/index.d.ts @@ -30,7 +30,7 @@ interface RedisStatic { (port?: number, host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (host?: string, options?: IORedis.RedisOptions): IORedis.Redis; (options?: IORedis.RedisOptions): IORedis.Redis; - Cluster: IORedis.Cluster; + Cluster: IORedis.ClusterStatic; Command: IORedis.Command; } @@ -873,11 +873,16 @@ declare namespace IORedis { type ClusterNode = string | number | NodeConfiguration; + type NodeRole = 'master' | 'slave' | 'all'; + interface Cluster extends NodeJS.EventEmitter, Commander { - new(nodes: ClusterNode[], options?: ClusterOptions): Redis; connect(callback: () => void): Promise; disconnect(): void; - nodes(role: string): Redis[]; + nodes(role?: NodeRole): Redis[]; + } + + interface ClusterStatic extends NodeJS.EventEmitter, Commander { + new (nodes: ClusterNode[], options?: ClusterOptions): Cluster; } interface RedisOptions { diff --git a/types/ioredis/ioredis-tests.ts b/types/ioredis/ioredis-tests.ts index fdb1fafcc1..f3cafe1f18 100644 --- a/types/ioredis/ioredis-tests.ts +++ b/types/ioredis/ioredis-tests.ts @@ -207,3 +207,22 @@ new Redis.Cluster([], { new Redis.Cluster([], { clusterRetryStrategy: (times: number, reason?: Error) => 1 }); + +// Cluster types +const clusterOptions: Redis.ClusterOptions = {}; +const cluster = new Redis.Cluster( + [ + { + host: 'localhost', + port: 6379 + } + ], + clusterOptions +); +cluster.on('end', () => console.log('on end')); +cluster.nodes().map(node => { + node.pipeline() + .flushdb() + .exec() + .then(result => console.log(result)); +}); diff --git a/types/is-online/index.d.ts b/types/is-online/index.d.ts deleted file mode 100644 index 04fa123c44..0000000000 --- a/types/is-online/index.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -// Type definitions for is-online 8.0 -// Project: https://github.com/sindresorhus/is-online#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export = isOnline; - -/** - * Check if the internet connection is up. - * - * The following checks are run in parallel: - * - Retrieve [icanhazip.com](https://github.com/major/icanhaz) via HTTPS - * - Query `myip.opendns.com` on OpenDNS (Node.js only) - * - Retrieve Apple's Captive Portal test page (Node.js only) - * - * When the first check succeeds, the returned Promise is resolved to `true`. - */ -declare function isOnline(options?: isOnline.Options): Promise; - -declare namespace isOnline { - interface Options { - /** - * Milliseconds to wait for a server to respond. - * @default 5000 - */ - timeout?: number; - /** - * Internet Protocol version to use. This is an advanced option that is usually not necessary to be set, - * but it can prove useful to specifically assert IPv6 connectivity. - * @default 'v4' - */ - version?: 'v4' | 'v6'; - } -} diff --git a/types/is-online/is-online-tests.ts b/types/is-online/is-online-tests.ts deleted file mode 100644 index 74dbda5efa..0000000000 --- a/types/is-online/is-online-tests.ts +++ /dev/null @@ -1,6 +0,0 @@ -import isOnline = require('is-online'); - -isOnline(); // $ExpectType Promise -isOnline({ timeout: 10 }); // $ExpectType Promise -isOnline({ version: 'v4' }); // $ExpectType Promise -isOnline({ version: 'v6' }); // $ExpectType Promise diff --git a/types/isotope-layout/index.d.ts b/types/isotope-layout/index.d.ts index 5662da48f7..e10c0ea7c7 100644 --- a/types/isotope-layout/index.d.ts +++ b/types/isotope-layout/index.d.ts @@ -284,6 +284,10 @@ declare global { * Get the Isotope instance from a jQuery object. Isotope instances are useful to access Isotope properties. */ data(methodName: 'isotope'): Isotope; + /** + * Filters, sorts, and lays out items. + */ + isotope(): JQuery; /** * Lays out specified items. * @param elements Array of Isotope.Items diff --git a/types/isotope-layout/isotope-layout-tests.ts b/types/isotope-layout/isotope-layout-tests.ts index d37475cefa..c39b8851db 100644 --- a/types/isotope-layout/isotope-layout-tests.ts +++ b/types/isotope-layout/isotope-layout-tests.ts @@ -81,6 +81,7 @@ $grid = $('.grid').isotope({ }); // test methods using jquery +$grid.isotope(); $grid.isotope('addItems', $('.items')); $grid.isotope('appended', $('.items')[0]); $grid.isotope('hideItemElements', [ new HTMLElement() ]); diff --git a/types/jasmine-ajax/jasmine-ajax-tests.ts b/types/jasmine-ajax/jasmine-ajax-tests.ts index da68ad92a0..cf1db49f28 100644 --- a/types/jasmine-ajax/jasmine-ajax-tests.ts +++ b/types/jasmine-ajax/jasmine-ajax-tests.ts @@ -772,7 +772,7 @@ describe("Jasmine Mock Ajax (for toplevel)", () => { error = jasmine.createSpy("onFailure"); complete = jasmine.createSpy("onComplete"); - onreadystatechange = () => { + onreadystatechange = function() { if (this.readyState === (this.DONE || 4)) { // IE 8 doesn't support DONE if (this.status === 200) { success(this.responseText, this.textStatus, this); diff --git a/types/jasmine-data_driven_tests/index.d.ts b/types/jasmine-data_driven_tests/index.d.ts index 553987ef60..fe786aa735 100644 --- a/types/jasmine-data_driven_tests/index.d.ts +++ b/types/jasmine-data_driven_tests/index.d.ts @@ -6,6 +6,8 @@ declare var all: JasmineDataDrivenTest; declare var xall: JasmineDataDrivenTest; +declare var using: JasmineDataDrivenTest; +declare var xusing: JasmineDataDrivenTest; interface JasmineDataDrivenTest { ( diff --git a/types/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts b/types/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts index 0523a28af0..1e354702c9 100644 --- a/types/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts +++ b/types/jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts @@ -1,5 +1,44 @@ /// +using("A suite", + [ + [1, 2, 3], + [2, 4, 6] + ], + (a, b, c) => { + it("can be data driven", () => { + expect(c).toBe(a + b); + }); + } +); + +xusing("A data driven suite", + [ + [1, 2, 3], + [2, 4, 6] + ], + (a, b, c) => { + it("can be pending", () => { + expect(c).toBe(a + b); + }); + } +); + +using("A data driven suite", + [ 'a', 'b', 'c' ], + lhs => { + beforeEach(() => { + console.log(`lhs = ${lhs}`); + }); + all("can contain data driven tests", + [ 'd', 'e', 'f' ], + rhs => { + expect(lhs).not.toBe(rhs); + } + ); + } +); + all("A data driven test is a suite with multiple specs", ['a', 'b', 'c'], value => { diff --git a/types/jest-environment-puppeteer/index.d.ts b/types/jest-environment-puppeteer/index.d.ts index 79c25e32d8..bcc37c8f9e 100644 --- a/types/jest-environment-puppeteer/index.d.ts +++ b/types/jest-environment-puppeteer/index.d.ts @@ -1,14 +1,43 @@ -// Type definitions for jest-environment-puppeteer 2.2 +// Type definitions for jest-environment-puppeteer 4.0 // Project: https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer // Definitions by: Josh Goldberg +// Ifiok Jr. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Browser, Page } from "puppeteer"; +import { Browser, Page, BrowserContext } from 'puppeteer'; + +interface JestPuppeteer { + /** + * Reset global.page + * + * ```ts + * beforeEach(async () => { + * await jestPuppeteer.resetPage() + * }) + * ``` + */ + resetPage(): Promise; + + /** + * Suspends test execution and gives you opportunity to see what's going on in the browser + * - Jest is suspended (no timeout) + * - A debugger instruction to Chromium, if Puppeteer has been launched with { devtools: true } it will stop + * + * ```ts + * it('should put test in debug mode', async () => { + * await jestPuppeteer.debug() + * }) + * ``` + */ + debug(): Promise; +} declare global { const browser: Browser; + const context: BrowserContext; const page: Page; + const jestPuppeteer: JestPuppeteer; } -export { }; +export {}; diff --git a/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts b/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts index 3de8c3661a..fb424d580b 100644 --- a/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts +++ b/types/jest-environment-puppeteer/jest-environment-puppeteer-tests.ts @@ -2,3 +2,7 @@ import * as puppeteer from "puppeteer"; const myBrowser: puppeteer.Browser = browser; const myPage: puppeteer.Page = page; +const myContext: puppeteer.BrowserContext = context; + +jestPuppeteer.debug(); +jestPuppeteer.resetPage(); diff --git a/types/jest-in-case/jest-in-case-tests.ts b/types/jest-in-case/jest-in-case-tests.ts index b38ccff0bc..2e3631efab 100644 --- a/types/jest-in-case/jest-in-case-tests.ts +++ b/types/jest-in-case/jest-in-case-tests.ts @@ -25,7 +25,7 @@ afterEach(() => { test('array', () => { const title = 'add(augend, addend)'; - const tester = jest.fn(opts => { + const tester = jest.fn((opts, cb) => { expect(add(opts.augend, opts.addend)).toBe(opts.total); }); @@ -59,7 +59,7 @@ test('object', () => { const title = 'add(augend, addend)'; - const tester = jest.fn(opts => { + const tester = jest.fn((opts, cb) => { expect(subtract(opts.minuend, opts.subtrahend)).toBe(opts.difference); }); diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index f0382d2cb5..da84c876af 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -220,9 +220,10 @@ declare namespace jest { * spy.mockRestore(); * }); */ - function spyOn>(object: T, method: M, accessType: 'get'): SpyInstance; - function spyOn>(object: T, method: M, accessType: 'set'): SpyInstance; - function spyOn>(object: T, method: M): T[M] extends (...args: any[]) => any ? SpyInstance, ArgsType> : never; + function spyOn>>(object: T, method: M, accessType: 'get'): SpyInstance[M], []>; + function spyOn>>(object: T, method: M, accessType: 'set'): SpyInstance[M]]>; + function spyOn>>(object: T, method: M): Required[M] extends (...args: any[]) => any ? + SpyInstance[M]>, ArgsType[M]>> : never; /** * Indicates that the module system should never return a mocked version of * the specified module from require() (e.g. that it should always return the real module). @@ -263,10 +264,11 @@ declare namespace jest { } interface Each { - (cases: any[]): (name: string, fn: (...args: any[]) => any) => void; + (cases: any[]): (name: string, fn: (...args: any[]) => any, timeout?: number) => void; (strings: TemplateStringsArray, ...placeholders: any[]): ( name: string, - fn: (arg: any) => any + fn: (arg: any) => any, + timeout?: number ) => void; } @@ -1625,6 +1627,7 @@ declare namespace jest { numPendingTests: number; numPendingTestSuites: number; numRuntimeErrorTestSuites: number; + numTodoTests: number; numTotalTests: number; numTotalTestSuites: number; snapshot: SnapshotSummary; diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 69e68ab6f7..039d996f5c 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -349,11 +349,15 @@ const mockContextVoid = jest.fn().mock; const mockContextString = jest.fn(() => "").mock; jest.fn().mockClear(); - jest.fn().mockReset(); - jest.fn().mockRestore(); +jest.fn().mockImplementation((test: number) => test); +jest.fn().mockResolvedValue(1); +interface SpyInterface { + prop?: number; + method?: (arg1: boolean) => void; +} const spiedTarget = { returnsVoid(): void { }, setValue(value: string): void { @@ -363,7 +367,6 @@ const spiedTarget = { return ""; } }; - class SpiedTargetClass { private _value = 3; private _value2 = ''; @@ -380,6 +383,7 @@ class SpiedTargetClass { this._value2 = value2; } } + const spiedTarget2 = new SpiedTargetClass(); // $ExpectError @@ -425,11 +429,17 @@ const spy5 = jest.spyOn(spiedTarget2, "value", "get"); spy5.mockReturnValue('5'); // $ExpectType SpyInstance -const spy6 = jest.spyOn(spiedTarget2, "value", "set"); +jest.spyOn(spiedTarget2, "value", "set"); -// should compile -jest.fn().mockImplementation((test: number) => test); -jest.fn().mockResolvedValue(1); +let spyInterfaceImpl: SpyInterface = {}; +// $ExpectError +jest.spyOn(spyInterfaceImpl, "method", "get"); +// $ExpectError +jest.spyOn(spyInterfaceImpl, "prop"); +// $ExpectType SpyInstance +jest.spyOn(spyInterfaceImpl, "prop", "get"); +// $ExpectType SpyInstance +jest.spyOn(spyInterfaceImpl, "method"); interface Type1 { a: number; } interface Type2 { b: number; } @@ -1360,6 +1370,14 @@ test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( } ); +test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( + ".add(%i, %i)", + (a, b, expected) => { + expect(a + b).toBe(expected); + }, + 5000 +); + test.each` a | b | expected ${1} | ${1} | ${2} @@ -1369,6 +1387,15 @@ test.each` expect(a + b).toBe(expected); }); +test.each` + a | b | expected + ${1} | ${1} | ${2} + ${1} | ${2} | ${3} + ${2} | ${1} | ${3} +`("returns $expected when $a is added $b", ({ a, b, expected }: Case) => { + expect(a + b).toBe(expected); +}, 5000); + test.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( ".add(%i, %i)", (a, b, expected) => { diff --git a/types/jsdom/index.d.ts b/types/jsdom/index.d.ts index a4267d560e..b591ee3abb 100644 --- a/types/jsdom/index.d.ts +++ b/types/jsdom/index.d.ts @@ -41,7 +41,7 @@ export class JSDOM { * Behind the scenes, a jsdom Window is indeed a VM context. * To get access to this ability, use the runVMScript() method. */ - runVMScript(script: Script): void; + runVMScript(script: Script): any; reconfigure(settings: ReconfigureSettings): void; } diff --git a/types/jsonwebtoken/index.d.ts b/types/jsonwebtoken/index.d.ts index d1c3aeee5f..33d4f7b999 100644 --- a/types/jsonwebtoken/index.d.ts +++ b/types/jsonwebtoken/index.d.ts @@ -59,7 +59,7 @@ export interface SignOptions { export interface VerifyOptions { algorithms?: string[]; - audience?: string | string[]; + audience?: string | RegExp | Array; clockTimestamp?: number; clockTolerance?: number; issuer?: string | string[]; diff --git a/types/jsonwebtoken/jsonwebtoken-tests.ts b/types/jsonwebtoken/jsonwebtoken-tests.ts index 5884ff6d63..924f95e2d4 100644 --- a/types/jsonwebtoken/jsonwebtoken-tests.ts +++ b/types/jsonwebtoken/jsonwebtoken-tests.ts @@ -101,6 +101,12 @@ cert = fs.readFileSync("public.pem"); // get public key jwt.verify(token, cert, { audience: "urn:foo" }, (err, decoded) => { // if audience mismatch, err == invalid audience }); +jwt.verify(token, cert, { audience: /urn:f[o]{2}/ }, (err, decoded) => { + // if audience mismatch, err == invalid audience +}); +jwt.verify(token, cert, { audience: [/urn:f[o]{2}/, "urn:bar"] }, (err, decoded) => { + // if audience mismatch, err == invalid audience +}); // verify issuer cert = fs.readFileSync("public.pem"); // get public key diff --git a/types/jss/index.d.ts b/types/jss/index.d.ts index edcb0ba95f..5326e3f6d7 100644 --- a/types/jss/index.d.ts +++ b/types/jss/index.d.ts @@ -104,7 +104,7 @@ export interface RuleOptions { index: number; className: string; } -export declare class SheetsRegistry { +export class SheetsRegistry { constructor(); registry: ReadonlyArray; readonly index: number; @@ -122,7 +122,7 @@ export type CreateStyleSheetOptions = Partial<{ generateClassName: GenerateClassName; classNamePrefix: string; }>; -export declare class JSS { +export class JSS { constructor(options?: Partial); createStyleSheet( styles: Partial>, diff --git a/types/kafka-node/index.d.ts b/types/kafka-node/index.d.ts index 2f44a7e767..b90acfa762 100644 --- a/types/kafka-node/index.d.ts +++ b/types/kafka-node/index.d.ts @@ -1,6 +1,10 @@ // Type definitions for kafka-node 2.0 // Project: https://github.com/SOHU-Co/kafka-node/ -// Definitions by: Daniel Imrie-Situnayake , Bill , Michael Haan , Amiram Korach +// Definitions by: Daniel Imrie-Situnayake +// Bill +// Michael Haan +// Amiram Korach +// Insanehong // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -61,7 +65,7 @@ export class HighLevelConsumer { client: Client; on(eventName: "message", cb: (message: Message) => any): void; on(eventName: "error" | "offsetOutOfRange", cb: (error: any) => any): void; - on(eventName: "rebalancing" | "rebalanced", cb: () => any): void; + on(eventName: "rebalancing" | "rebalanced" | "connect", cb: () => any): void; addTopics(topics: string[] | Topic[], cb?: (error: any, added: string[] | Topic[]) => any): void; removeTopics(topics: string | string[], cb: (error: any, removed: number) => any): void; commit(cb: (error: any, data: any) => any): void; diff --git a/types/kafka-node/kafka-node-tests.ts b/types/kafka-node/kafka-node-tests.ts index 1e433172ae..0a8713aa27 100644 --- a/types/kafka-node/kafka-node-tests.ts +++ b/types/kafka-node/kafka-node-tests.ts @@ -244,6 +244,8 @@ consumerGroup.on('error', (err) => { }); consumerGroup.on('message', (msg) => { }); +consumerGroup.on('connect', () => { +}); consumerGroup.close(true, () => { }); diff --git a/types/kafkajs/index.d.ts b/types/kafkajs/index.d.ts new file mode 100644 index 0000000000..c416a07063 --- /dev/null +++ b/types/kafkajs/index.d.ts @@ -0,0 +1,538 @@ +// Type definitions for kafkajs 1.4 +// Project: https://github.com/tulios/kafkajs, https://kafka.js.org +// Definitions by: Michal Kaminski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +/// + +import * as tls from "tls"; + +export class Kafka { + constructor(options: KafkaOptions); + + producer(options?: ProducerOptions): Producer; + consumer(options?: ConsumerOptions): Consumer; + admin(options?: AdminOptions): Admin; +} + +export const PartitionAssigners: { + roundRobin: PartitionAssigner; +}; + +export namespace AssignerProtocol { + interface MemberMetadataOptions { + version: number; + topics: string[]; + userData?: Buffer; + } + + interface MemberMetadata { + encode(options: MemberMetadataOptions): Buffer; + decode(buffer: Buffer): MemberMetadataOptions; + } + + interface MemberAssignmentOptions { + version: number; + assignment: { [key: string]: number[] }; + userData?: Buffer; + } + + interface MemberAssignment { + encode(options: MemberAssignmentOptions): Buffer; + decode(buffer: Buffer): MemberAssignmentOptions; + } + + interface AssignerProtocolStatic { + MemberMetadata: MemberMetadata; + MemberAssignment: MemberAssignment; + } +} + +export const AssignerProtocol: AssignerProtocol.AssignerProtocolStatic; + +export enum CompressionTypes { + None = 0, + GZIP = 1, + Snappy = 2, + LZ4 = 3, + ZSTD = 4 +} + +export const CompressionCodecs: { [key in CompressionTypes]: () => any }; + +export enum ResourceTypes { + UNKNOWN = 0, + ANY = 1, + TOPIC = 2, + GROUP = 3, + CLUSTER = 4, + TRANSACTIONAL_ID = 5, + DELEGATION_TOKEN = 6 +} + +export interface KafkaOptions { + clientId?: string; + brokers: string[]; + ssl?: tls.ConnectionOptions; + sasl?: SASLOptions; + connectionTimeout?: number; + requestTimeout?: number; + retry?: RetryOptions; + logLevel?: logLevel; +} + +export interface SASLOptions { + mechanism: "plain" | "scram-sha-256" | "scram-sha-512"; + username: string; + password: string; +} + +export interface RetryOptions { + maxRetryTime?: number; + initialRetryTime?: number; + factor?: number; + multiplier?: number; + retries?: number; + maxInFlightRequests?: number | null; +} + +export enum logLevel { + NOTHING = 0, + ERROR = 1, + WARN = 2, + INFO = 4, + DEBUG = 5 +} + +export interface Producer { + connect(): Promise; + disconnect(): Promise; + + send(payload: MessagePayload): Promise; + sendBatch(payload: MessageBatchPayload): Promise; + + transaction(): Promise; + + events: ProducerEvents; + on( + event: ProducerEvents[keyof ProducerEvents], + cb: (e: InstrumentationEvent) => void + ): () => Producer; +} + +export interface ProducerOptions { + createPartitioner?: () => (options: { + topic: string; + partitionMetadata: PartitionMetadata[]; + message: ProducerMessage; + }) => number; + retry?: RetryOptions; + metadataMaxAge?: number; + allowAutoTopicCreation?: boolean; + transactionTimeout?: number; + idempotent?: boolean; +} + +export interface PartitionerPartitionMetadata { + partitionId: number; + leader: number; +} + +export interface PartitionMetadata { + partitionId: number; + leader: number; + partitionErrorCode?: number; + replicas?: number[]; + isr?: number[]; +} + +export interface MessagePayloadBase { + acks?: AcksBehaviour; + timeout?: number; + compression?: CompressionTypes; +} + +export interface MessagePayload extends MessagePayloadBase { + topic: string; + messages: ProducerMessage[]; + transactionTimeout?: number; + idempotent?: boolean; +} + +export interface MessageBatchPayload extends MessagePayloadBase { + topicMessages: ProducerTopicMessage[]; +} + +export interface ProducerMessage { + partition?: number; + key?: string; + value: string | Buffer | ArrayBuffer; + headers?: { [key: string]: string }; +} + +export interface ProducerTopicMessage { + topic: string; + messages: ProducerMessage[]; +} + +export enum AcksBehaviour { + All = -1, + No = 0, + Leader = 1 +} + +export interface Transaction { + send(payload: MessagePayload): Promise; + sendBatch(payload: MessageBatchPayload): Promise; + + sendOffsets(offsets: TransactionSendOffsets): Promise; + + commit(): Promise; + abort(): Promise; +} + +export interface TransactionSendOffsets { + consumerGroupId: string; + topics: TransactionSendOffsetsTopic[]; +} + +export interface TransactionSendOffsetsTopic { + topic: string; + partitions: TransactionSendOffsetsTopicPartitions[]; +} + +export interface TransactionSendOffsetsTopicPartitions { + partition: number; + offset: string; +} + +export interface Consumer { + connect(): Promise; + disconnect(): Promise; + + subscribe(options: ConsumerSubscribeOptions): Promise; + + run(options: ConsumerRunOptions): Promise; + + pause(topics: Array<{ topic: string }>): void; + resume(topics: Array<{ topic: string }>): void; + seek(options: ConsumerSeekOptions): void; + + describeGroup(): Promise; + + events: ConsumerEvents; + on( + event: ConsumerEvents[keyof ConsumerEvents], + cb: (e: InstrumentationEvent) => void + ): () => Consumer; +} + +export interface ConsumerOptions { + groupId: string; + partitionAssigners?: PartitionAssigner[]; + sessionTimeout?: number; + heartbeatInterval?: number; + metadataMaxAge?: number; + allowAutoTopicCreation?: boolean; + maxBytesPerPartition?: number; + minBytes?: number; + maxBytes?: number; + maxWaitTimeInMs?: number; + retry?: RetryOptions; + readUncommitted?: boolean; +} + +export interface PartitionAssigner { + ({ cluster }: { cluster: any /* TODO */ }): { + name: string; + version: number; + assign: (options: { + members: Array<{ memberId: string }>; + topics: any[]; + userData?: Buffer; + }) => Promise< + Array<{ + memberId: number; + memberAssignment: Buffer; + }> + >; + protocol?: (options: { + topics: any /* TODO */; + }) => { name: string; metadata: Buffer }; + }; +} + +export interface ConsumerRunOptions { + eachMessage?: (payload: ConsumerEachMessagePayload) => Promise; + eachBatch?: (payload: ConsumerEachBatchPayload) => Promise; + eachBatchAutoResolve?: boolean; + autoCommitInterval?: number; + autoCommitThreshold?: number; + autoCommit?: boolean; +} + +export interface ConsumerSubscribeOptions { + topic: string; + fromBeginning?: boolean; +} + +export interface ConsumerMessage { + timestamp: number; + key: string; + value: Buffer; + headers: { [key: string]: string }; + offset: number; +} + +export interface ConsumerBatch { + topic: string; + partition: number; + highWatermark: number; + messages: ConsumerMessage[]; +} + +export interface ConsumerEachMessagePayload { + topic: string; + partition: number; + message: ConsumerMessage; +} + +export interface ConsumerEachBatchPayload { + batch: ConsumerBatch; + resolveOffset: (offset: number) => Promise; + heartbeat: () => Promise; + isRunning: () => boolean; + commitOffsetsIfNecessary: ( + offsets?: OffsetsByTopicPartition + ) => Promise; + uncommittedOffsets: () => OffsetsByTopicPartition; +} + +export interface OffsetsByTopicPartition { + topics: TopicOffsets[]; +} + +export interface TopicOffsets { + partitions: PartitionOffset[]; +} + +export interface PartitionOffset { + partition: string; + offset: string; +} + +export interface ConsumerSeekOptions { + topic: string; + partition: number; + offset: number; +} + +export interface GroupMemberMetadata { + memberId: string; + clientId: string; + clientHost: string; + memberMetadata: Buffer; + memberAssignment: Buffer; +} + +export interface GroupMetadata { + errorCode: number; + groupId: string; + protocolType: string; + protocol: string; + members: GroupMemberMetadata[]; + state: string; +} + +export interface Admin { + connect(): Promise; + disconnect(): Promise; + + createTopics(options: AdminCreateTopicsOptions): Promise; + deleteTopics(options: AdminDeleteTopicsOptions): Promise; + getTopicMetadata(options: { + topics?: string[]; + }): Promise<{ topics: TopicMetadata[] }>; + + fetchOffsets( + options: AdminFetchOffsetsOptions + ): Promise; + resetOffsets(options: AdminResetOffsetsOptions): Promise; + setOffsets(options: AdminSetOffsetsOptions): Promise; + + describeConfigs( + options: AdminDescribeConfigsOptions + ): Promise; + alterConfigs(options: AdminAlterConfigsOptions): Promise; + + events: AdminEvents; + on( + event: AdminEvents[keyof AdminEvents], + cb: (e: InstrumentationEvent) => void + ): () => Admin; +} + +export interface AdminOptions { + retry?: RetryOptions; +} + +export interface AdminCreateTopicsOptions { + validateOnly?: boolean; + waitForLeaders?: boolean; + timeout?: number; + topics: AdminTopic[]; +} + +export interface AdminTopic { + topic: string; + numPartitions?: number; + replicationFactor?: number; + replicaAssignment?: AdminTopicReplicaAssignment[]; + configEntries?: AdminTopicConfigEntry[]; +} + +export interface AdminTopicReplicaAssignment { + partition: number; + replicas: number[]; +} + +export interface AdminTopicConfigEntry { + name: string; + value: string; +} + +export interface AdminDeleteTopicsOptions { + timeout?: number; + topics: string[]; +} + +export interface AdminFetchOffsetsOptions { + groupId: string; + topic: string; +} + +export interface AdminResetOffsetsOptions { + groupId: string; + topic: string; + earliest?: boolean; +} + +export interface TopicMetadata { + name: string; + partitions: PartitionMetadata[]; +} + +export interface AdminDescribeConfigsOptions { + resources: ResourceConfigQuery[]; +} + +export interface ResourceConfigQuery { + type: ResourceTypes; + name: string; + configNames?: string[]; +} + +export interface AdminConfigDescription { + resources: AdminConfigDescriptionResource[]; + throttleTime: number; +} + +export interface AdminConfigDescriptionResource { + configEntries: AdminConfigDescriptionResourceConfigEntry[]; + errorCode: number; + errorMessage: string; + resourceName: string; + resourceType: ResourceTypes; +} + +export interface AdminConfigDescriptionResourceConfigEntry { + configName: string; + configValue: string; + isDefault: boolean; + isSensitive: boolean; + readOnly: boolean; +} + +export interface AdminAlterConfigsOptions { + validateOnly: boolean; + resources: ResourceConfigQuery[]; +} + +export interface ResourceConfigQuery { + type: ResourceTypes; + name: string; + configEntries: ResourceConfigEntry[]; +} + +export interface ResourceConfigEntry { + name: string; + value: string; +} + +export interface AdminAlterConfigReturn { + resources: AdminAlterConfigResource[]; + throttleTime: number; +} + +export interface AdminAlterConfigResource { + errorCode: number; + errorMessage: string; + resourceName: string; + resourceType: ResourceTypes; +} + +export interface AdminTopicOffset { + partition: number; + offset: string; +} + +export interface AdminSetOffsetsSeekEntry { + partition: number; + offset: string; +} + +export interface AdminSetOffsetsOptions { + groupId: string; + topic: string; + partitions: AdminSetOffsetsSeekEntry[]; +} + +export interface InstrumentationEvent { + id: number; + type: string; + timestamp: number; + payload: { [key: string]: any }; +} + +export interface ConsumerEvents { + HEARTBEAT: "consumer.heartbeat"; + COMMIT_OFFSETS: "consumer.commit_offsets"; + GROUP_JOIN: "consumer.group_join"; + FETCH: "consumer.fetch"; + START_BATCH_PROCESS: "consumer.start_batch_process"; + END_BATCH_PROCESS: "consumner.end_batch_process"; + CONNECT: "consumer.connect"; + DISCONNECT: "consumer.disconnect"; + STOP: "consumer.stop"; + CRASH: "consumer.crash"; + REQUEST: "consumer.request"; + REQUEST_TIMEOUT: "consumer.request_timeout"; + REQUEST_QUEUE_SIZE: "consumer.request_queue_size"; +} + +export interface ProducerEvents { + CONNECT: "producer.connect"; + DISCONNECT: "producer.disconnect"; + REQUEST: "producer.request"; + REQUEST_TIMEOUT: "producer.request_timeout"; + REQUEST_QUEUE_SIZE: "producer.request_queue_size"; +} + +export interface AdminEvents { + CONNECT: "admin.connect"; + DISCONNECT: "admin.disconnect"; + REQUEST: "admin.request"; + REQUEST_TIMEOUT: "admin.request_timeout"; + REQUEST_QUEUE_SIZE: "admin.request_queue_size"; +} diff --git a/types/kafkajs/kafkajs-tests.ts b/types/kafkajs/kafkajs-tests.ts new file mode 100644 index 0000000000..3ae0f37c2c --- /dev/null +++ b/types/kafkajs/kafkajs-tests.ts @@ -0,0 +1,145 @@ +import * as fs from "fs"; + +import { + Kafka, + AssignerProtocol, + PartitionAssigners, + logLevel, + CompressionTypes, + CompressionCodecs, + ResourceTypes, + PartitionAssigner +} from "kafkajs"; + +const { MemberMetadata, MemberAssignment } = AssignerProtocol; +const { roundRobin } = PartitionAssigners; + +// COMMON +const host = "localhost"; +const topic = "topic-test"; + +const kafka = new Kafka({ + logLevel: logLevel.INFO, + brokers: [`${host}:9094`, `${host}:9097`, `${host}:9100`], + clientId: "example-consumer", + ssl: { + servername: "localhost", + rejectUnauthorized: false, + ca: [fs.readFileSync("./testHelpers/certs/cert-signed", "utf-8")] + }, + sasl: { + mechanism: "plain", + username: "test", + password: "testtest" + } +}); + +// CONSUMER +const consumer = kafka.consumer({ groupId: "test-group" }); + +const runConsumer = async () => { + await consumer.connect(); + await consumer.subscribe({ topic }); + await consumer.run({ + // eachBatch: async ({ batch }) => { + // console.log(batch) + // }, + eachMessage: async ({ topic, partition, message }) => { + const prefix = `${topic}[${partition} | ${message.offset}] / ${ + message.timestamp + }`; + console.log(`- ${prefix} ${message.key}#${message.value}`); + } + }); + await consumer.disconnect(); +}; + +runConsumer().catch(e => console.error(`[example/consumer] ${e.message}`, e)); + +// PRODUCER +const producer = kafka.producer({ allowAutoTopicCreation: true }); + +const getRandomNumber = () => Math.round(Math.random() * 1000); +const createMessage = (num: number) => ({ + key: `key-${num}`, + value: `value-${num}-${new Date().toISOString()}` +}); + +const sendMessage = () => { + return producer + .send({ + topic, + compression: CompressionTypes.GZIP, + messages: Array(getRandomNumber()) + .fill(0) + .map(_ => createMessage(getRandomNumber())) + }) + .then(console.log) + .catch(e => console.error(`[example/producer] ${e.message}`, e)); +}; + +const runProducer = async () => { + await producer.connect(); + setInterval(sendMessage, 3000); + await producer.disconnect(); +}; + +runProducer().catch(e => console.error(`[example/producer] ${e.message}`, e)); + +// ADMIN +const admin = kafka.admin({ retry: { retries: 10 } }); + +const runAdmin = async () => { + await admin.connect(); + const { topics } = await admin.getTopicMetadata({}); + await admin.createTopics({ topics: [{ topic, numPartitions: 10, replicationFactor: 1}], timeout: 30000, waitForLeaders: true }); + await admin.disconnect(); +}; + +runAdmin().catch(e => console.error(`[example/admin] ${e.message}`, e)); + +// OTHERS +async () => { + await producer.send({ + topic: "topic-name", + compression: CompressionTypes.GZIP, + messages: [{ key: "key1", value: "hello world!" }] + }); +}; + +// import SnappyCodec from "kafkajs-snappy"; +const SnappyCodec: any = undefined; +CompressionCodecs[CompressionTypes.Snappy] = SnappyCodec; + +const myCustomAssignmentArray = [0]; +const assignment: { [key: number]: { [key: string]: number[] } } = { + 0: { a: [0] } +}; +const MyPartitionAssigner: PartitionAssigner = ({ cluster: any }) => ({ + name: "MyPartitionAssigner", + version: 1, + async assign({ members, topics }) { + // perform assignment + return myCustomAssignmentArray.map(memberId => ({ + memberId, + memberAssignment: MemberAssignment.encode({ + version: this.version, + assignment: assignment[memberId] + }) + })); + }, + protocol({ topics }) { + return { + name: this.name, + metadata: MemberMetadata.encode({ + version: this.version, + topics + }) + }; + } +}); + +kafka.consumer({ + groupId: "my-group", + partitionAssigners: [MyPartitionAssigner, roundRobin] +}); diff --git a/types/kafkajs/tsconfig.json b/types/kafkajs/tsconfig.json new file mode 100644 index 0000000000..1cab3080d1 --- /dev/null +++ b/types/kafkajs/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "kafkajs-tests.ts" + ] +} diff --git a/types/p-limit/tslint.json b/types/kafkajs/tslint.json similarity index 100% rename from types/p-limit/tslint.json rename to types/kafkajs/tslint.json diff --git a/types/kendo-ui/index.d.ts b/types/kendo-ui/index.d.ts index 7ea79365ee..17c186697e 100644 --- a/types/kendo-ui/index.d.ts +++ b/types/kendo-ui/index.d.ts @@ -1883,7 +1883,9 @@ declare namespace kendo.ui { navigateToPast(): void; navigateUp(): void; selectDates(): void; - selectDates(): void; + selectDates(datesToSelect : any): void; + //somehow the same interface got implemented twice which are the same + //kendo-ui supports date selection(https://docs.telerik.com/kendo-ui/knowledge-base/calendar-select-range-of-dates) value(): Date; value(value: Date): void; value(value: string): void; diff --git a/types/klaw/v1/klaw-tests.ts b/types/klaw/v1/klaw-tests.ts index 7bfd79ee50..eb9a101017 100644 --- a/types/klaw/v1/klaw-tests.ts +++ b/types/klaw/v1/klaw-tests.ts @@ -16,7 +16,7 @@ klaw('/some/dir') // README.md: Streams 2 & 3 (pull) with error handling klaw('/some/dir') - .on('readable', () => { + .on('readable', function() { while (true) { const item = this.read(); if (!item) break; diff --git a/types/knex/knex-tests.ts b/types/knex/knex-tests.ts index 8b173c0887..1ff232e4a7 100644 --- a/types/knex/knex-tests.ts +++ b/types/knex/knex-tests.ts @@ -173,7 +173,7 @@ knex.select('title', 'author', 'year').from('books'); knex.select({ name: 'title', writer: 'author' }).from(knex.raw('books')); knex.select().table('books'); -knex.avg('sum_column1').from(() => { +knex.avg('sum_column1').from(function() { this.sum('column1 as sum_column1').from('t1').groupBy('column1').as('t1'); }).as('ignored_alias'); @@ -190,7 +190,7 @@ knex('users').where({ knex('users').where('id', 1); -knex('users').where(() => { +knex('users').where(function() { this.where('id', 1).orWhere('id', '>', 10); }).orWhere({name: 'Tester'}); @@ -218,7 +218,7 @@ knex.select('name').from('users') knex('users') .where('name', '=', 'John') - .orWhere(() => { + .orWhere(function() { this.where('votes', '>', 100).andWhere('title', '<>', 'Admin'); }); @@ -230,13 +230,13 @@ knex('users').whereNull('updated_at'); knex('users').whereNotNull('created_at'); -knex('users').whereExists(() => { +knex('users').whereExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); knex('users').whereExists(knex.select('*').from('accounts').whereRaw('users.account_id = accounts.id')); -knex('users').whereNotExists(() => { +knex('users').whereNotExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); @@ -321,15 +321,15 @@ knex('users') .join(knex('contacts').select('user_id', 'phone').as('contacts'), { 'users.id': 'contacts.user_id' }) .select('users.id', 'contacts.phone'); -knex.select('*').from('users').join(knex('accounts').select('id', 'owner_id').as('accounts'), () => { +knex.select('*').from('users').join(knex('accounts').select('id', 'owner_id').as('accounts'), function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); -knex.select('*').from('users').join('accounts', () => { +knex.select('*').from('users').join('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); -knex.select('*').from('users').join('accounts', (join: Knex.JoinClause) => { +knex.select('*').from('users').join('accounts', function(join: Knex.JoinClause) { if (this !== join) { throw new Error("join() callback call semantics wrong"); } @@ -337,120 +337,120 @@ knex.select('*').from('users').join('accounts', (join: Knex.JoinClause) => { join.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); -knex.select('*').from('user').join('contacts', () => { +knex.select('*').from('user').join('contacts', function() { this.on('users.id', '=', knex.raw(7)); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').onIn('contacts.id', [7, 15, 23, 41]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').andOnIn('contacts.id', [7, 15, 23, 41]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').orOnIn('contacts.id', [7, 15, 23, 41]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').onNotIn('contacts.id', [7, 15, 23, 41]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').andOnNotIn('contacts.id', [7, 15, 23, 41]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').orOnNotIn('contacts.id', [7, 15, 23, 41]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').onNull('contacts.email'); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').andOnNull('contacts.email'); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').orOnNull('contacts.email'); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').onNotNull('contacts.email'); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').andOnNotNull('contacts.email'); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').orOnNotNull('contacts.email'); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').onExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').onExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').andOnExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').andOnExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').orOnExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').orOnExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').onNotExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').onNotExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').andOnNotExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').andOnNotExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').orOnNotExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').orOnNotExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').onBetween('contacts.id', [5, 30]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').andOnBetween('contacts.id', [5, 30]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').orOnBetween('contacts.id', [5, 30]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').onNotBetween('contacts.id', [5, 30]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').andOnNotBetween('contacts.id', [5, 30]); }); -knex.select('*').from('users').join('contacts', () => { +knex.select('*').from('users').join('contacts', function() { this.on('users.id', '=', 'contacts.id').orOnNotBetween('contacts.id', [5, 30]); }); -knex.select('*').from('users').join('contacts', () => { - this.on('users.id', '=', 'contacts.id').onNotExists(() => { +knex.select('*').from('users').join('contacts', function() { + this.on('users.id', '=', 'contacts.id').onNotExists(function() { this.select('*').from('accounts').whereRaw('users.account_id = accounts.id'); }); }); @@ -475,7 +475,7 @@ knex.from('users').innerJoin('accounts', 'users.id', 'accounts.user_id'); knex.table('users').innerJoin('accounts', 'users.id', '=', 'accounts.user_id'); -knex('users').innerJoin('accounts', () => { +knex('users').innerJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); @@ -485,7 +485,7 @@ knex('users').innerJoin('accounts', (join: Knex.JoinClause) => { knex.select('*').from('users').leftJoin('accounts', 'users.id', 'accounts.user_id'); -knex.select('*').from('users').leftJoin('accounts', () => { +knex.select('*').from('users').leftJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); @@ -502,13 +502,13 @@ knex.select('*').from('users').leftJoin('accounts', (join) => { knex.select('*').from('users').leftOuterJoin('accounts', 'users.id', 'accounts.user_id'); -knex.select('*').from('users').leftOuterJoin('accounts', () => { +knex.select('*').from('users').leftOuterJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); knex.select('*').from('users').rightJoin('accounts', 'users.id', 'accounts.user_id'); -knex.select('*').from('users').rightJoin('accounts', () => { +knex.select('*').from('users').rightJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); @@ -518,13 +518,13 @@ knex.select('*').from('users').rightJoin('accounts', (join: Knex.JoinClause) => knex.select('*').from('users').rightOuterJoin('accounts', 'users.id', 'accounts.user_id'); -knex.select('*').from('users').rightOuterJoin('accounts', () => { +knex.select('*').from('users').rightOuterJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); knex.select('*').from('users').outerJoin('accounts', 'users.id', 'accounts.user_id'); -knex.select('*').from('users').outerJoin('accounts', () => { +knex.select('*').from('users').outerJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); @@ -534,7 +534,7 @@ knex.select('*').from('users').outerJoin('accounts', (join: Knex.JoinClause) => knex.select('*').from('users').fullOuterJoin('accounts', 'users.id', 'accounts.user_id'); -knex.select('*').from('users').fullOuterJoin('accounts', () => { +knex.select('*').from('users').fullOuterJoin('accounts', function() { this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id'); }); @@ -549,39 +549,39 @@ knex.select('*').from('accounts').joinRaw('natural full join table1').where('id' knex.select('*').from('accounts').join(knex.raw('natural full join table1')).where('id', 1); knex.select('*').from('accounts') - .join(() => { + .join(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .leftJoin(() => { + .leftJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .leftOuterJoin(() => { + .leftOuterJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .rightJoin(() => { + .rightJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .rightOuterJoin(() => { + .rightOuterJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .innerJoin(() => { + .innerJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .crossJoin(() => { + .crossJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .fullOuterJoin(() => { + .fullOuterJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); knex.select('*').from('accounts') - .outerJoin(() => { + .outerJoin(function() { this.select('*').from('accounts').as('special_accounts'); }, 'special_accounts.a', '=', 'accounts.b'); @@ -1044,66 +1044,66 @@ knex.select('*').from('users').where(knex.raw('id = ?', [1])).toSQL(); // knex('users') .select('*') - .join('contacts', (builder) => { - this.on((builder: any) => { + .join('contacts', function(builder) { + this.on(function(builder: any) { let self: Knex.JoinClause = this; self = builder; - }).andOn((builder: any) => { + }).andOn(function(builder: any) { let self: Knex.JoinClause = this; self = builder; - }).orOn((builder: any) => { + }).orOn(function(builder: any) { let self: Knex.JoinClause = this; self = builder; - }).onExists((builder: any) => { + }).onExists(function(builder: any) { let self: Knex.QueryBuilder = this; self = builder; - }).orOnExists((builder: any) => { + }).orOnExists(function(builder: any) { let self: Knex.QueryBuilder = this; self = builder; - }).andOnExists((builder: any) => { + }).andOnExists(function(builder: any) { let self: Knex.QueryBuilder = this; self = builder; - }).onNotExists((builder: any) => { + }).onNotExists(function(builder: any) { let self: Knex.QueryBuilder = this; self = builder; - }).andOnNotExists((builder: any) => { + }).andOnNotExists(function(builder: any) { let self: Knex.QueryBuilder = this; self = builder; - }).orOnNotExists((builder: any) => { + }).orOnNotExists(function(builder: any) { let self: Knex.QueryBuilder = this; self = builder; }); - }).where((builder) => { + }).where(function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).orWhere((builder) => { + }).orWhere(function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).andWhere((builder) => { + }).andWhere(function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).whereIn('column', (builder) => { + }).whereIn('column', function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).orWhereIn('column', (builder) => { + }).orWhereIn('column', function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).whereNotIn('column', (builder) => { + }).whereNotIn('column', function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).orWhereNotIn('column', (builder) => { + }).orWhereNotIn('column', function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).whereWrapped((builder) => { + }).whereWrapped(function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).union((builder) => { + }).union(function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).unionAll((builder) => { + }).unionAll(function(builder) { let self: Knex.QueryBuilder = this; self = builder; - }).modify((builder, aBool) => { + }).modify(function(builder, aBool) { let self: Knex.QueryBuilder = this; self = builder; }, true); @@ -1111,6 +1111,7 @@ knex('users') // // Migrations // +const name = "test"; const config = { directory: "./migrations", extension: "js", @@ -1196,12 +1197,12 @@ knex('characters') knex('characters') .select() - .whereIn('name', () => { + .whereIn('name', function() { this.select('name').from('characters'); }); knex('characters') .select() - .whereIn(['name', 'class'], () => { + .whereIn(['name', 'class'], function() { this.select('name', 'class').from('characters'); }); diff --git a/types/knockout/index.d.ts b/types/knockout/index.d.ts index 8bf99b79db..39eb527c2e 100644 --- a/types/knockout/index.d.ts +++ b/types/knockout/index.d.ts @@ -12,13 +12,30 @@ // TypeScript Version: 2.3 interface KnockoutSubscribableFunctions { - notifySubscribers(valueToWrite?: T, event?: string): void; + /** + * Notify subscribers of knockout "change" event. This doesn't acctually change the observable value. + * @param eventValue A value to be sent with the event. + * @param event The knockout event. + */ + notifySubscribers(eventValue?: T, event?: "change"): void; + /** + * Notify subscribers of a knockout or user defined event. + * @param eventValue A value to be sent with the event. + * @param event The knockout or user defined event name. + */ + notifySubscribers(eventValue: U, event: string): void; } interface KnockoutComputedFunctions { } interface KnockoutObservableFunctions { + /** + * Used by knockout to decide if value of observable has changed and should notify subscribers. Returns true if instances are primitives, and false if are objects. + * If your observable holds an object, this can be overwritten to return equality based on your needs. + * @param a previous value. + * @param b next value. + */ equalityComparer(a: T, b: T): boolean; } @@ -57,7 +74,7 @@ interface KnockoutObservableArrayFunctions extends KnockoutReadonlyObservable pop(): T; /** * Adds a new item to the end of array. - * @param items Items to be added + * @param items Items to be added. */ push(...items: T[]): void; /** @@ -66,7 +83,7 @@ interface KnockoutObservableArrayFunctions extends KnockoutReadonlyObservable shift(): T; /** * Inserts a new item at the beginning of the array. - * @param items Items to be added + * @param items Items to be added. */ unshift(...items: T[]): number; /** @@ -85,24 +102,24 @@ interface KnockoutObservableArrayFunctions extends KnockoutReadonlyObservable // Ko specific /** - * Replaces the first value that equals oldItem with newItem - * @param oldItem Item to be replaced - * @param newItem Replacing item + * Replaces the first value that equals oldItem with newItem. + * @param oldItem Item to be replaced. + * @param newItem Replacing item. */ replace(oldItem: T, newItem: T): void; /** * Removes all values that equal item and returns them as an array. - * @param item The item to be removed + * @param item The item to be removed. */ remove(item: T): T[]; /** * Removes all values and returns them as an array. - * @param removeFunction A function used to determine true if item should be removed and fasle otherwise + * @param removeFunction A function used to determine true if item should be removed and fasle otherwise. */ remove(removeFunction: (item: T) => boolean): T[]; /** - * Removes all values that equal any of the supplied items - * @param items Items to be removed + * Removes all values that equal any of the supplied items. + * @param items Items to be removed. */ removeAll(items: T[]): T[]; /** @@ -140,45 +157,45 @@ interface KnockoutSubscribableStatic { interface KnockoutSubscription { /** - * Terminates a subscription + * Terminates a subscription. */ dispose(): void; } interface KnockoutSubscribable extends KnockoutSubscribableFunctions { /** - * Registers to be notified after the observable's value changes - * @param callback Function that is called whenever the notification happens - * @param target Defines the value of 'this' in the callback function - * @param event The name of the event to receive notification for + * Registers to be notified after the observable's value changes. + * @param callback Function that is called whenever the notification happens. + * @param target Defines the value of 'this' in the callback function. + * @param event The knockout event name. */ subscribe(callback: (newValue: T) => void, target?: any, event?: "change"): KnockoutSubscription; /** - * Registers to be notified before the observable's value changes - * @param callback Function that is called whenever the notification happens - * @param target Defines the value of 'this' in the callback function - * @param event The name of the event to receive notification for + * Registers to be notified before the observable's value changes. + * @param callback Function that is called whenever the notification happens. + * @param target Defines the value of 'this' in the callback function. + * @param event The knockout event name. */ subscribe(callback: (newValue: T) => void, target: any, event: "beforeChange"): KnockoutSubscription; /** - * Registers to be notified when the observable's value changes - * @param callback Function that is called whenever the notification happens - * @param target Defines the value of 'this' in the callback function - * @param event The name of the event to receive notification for + * Registers to be notified when a knockout or user defined event happens. + * @param callback Function that is called whenever the notification happens. eventValue can be anything. No relation to underlying observable. + * @param target Defines the value of 'this' in the callback function. + * @param event The knockout or user defined event name. */ - subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + subscribe(callback: (eventValue: U) => void, target: any, event: string): KnockoutSubscription; /** - * Customizes observables basic functionality + * Customizes observables basic functionality. * @param requestedExtenders Name of the extender feature and its value, e.g. { notify: 'always' }, { rateLimit: 50 } */ extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable; /** - * Gets total number of subscribers + * Gets total number of subscribers. */ getSubscriptionsCount(): number; /** - * Gets number of subscribers of a particular event - * @param event Event name + * Gets number of subscribers of a particular event. + * @param event Event name. */ getSubscriptionsCount(event: string): number; } @@ -187,26 +204,32 @@ interface KnockoutComputedStatic { fn: KnockoutComputedFunctions; /** - * Creates computed observable + * Creates computed observable. */ (): KnockoutComputed; /** - * Creates computed observable - * @param evaluatorFunction Function that computes the observable value - * @param context Defines the value of 'this' when evaluating the computed observable - * @param options An object with further properties for the computed observable + * Creates computed observable. + * @param evaluatorFunction Function that computes the observable value. + * @param context Defines the value of 'this' when evaluating the computed observable. + * @param options An object with further properties for the computed observable. */ (evaluatorFunction: () => T, context?: any, options?: KnockoutComputedOptions): KnockoutComputed; /** - * Creates computed observable - * @param options An object that defines the computed observable options and behavior - * @param context Defines the value of 'this' when evaluating the computed observable + * Creates computed observable. + * @param options An object that defines the computed observable options and behavior. + * @param context Defines the value of 'this' when evaluating the computed observable. */ (options: KnockoutComputedDefine, context?: any): KnockoutComputed; } interface KnockoutReadonlyComputed extends KnockoutReadonlyObservable { + /** + * Returns whether the computed observable may be updated in the future. A computed observable is inactive if it has no dependencies. + */ isActive(): boolean; + /** + * Returns the current number of dependencies of the computed observable. + */ getDependenciesCount(): number; } @@ -220,15 +243,7 @@ interface KnockoutComputed extends KnockoutReadonlyComputed, KnockoutObser */ dispose(): void; /** - * Returns whether the computed observable may be updated in the future. A computed observable is inactive if it has no dependencies. - */ - isActive(): boolean; - /** - * Returns the current number of dependencies of the computed observable. - */ - getDependenciesCount(): number; - /** - * Customizes observables basic functionality + * Customizes observables basic functionality. * @param requestedExtenders Name of the extender feature and it's value, e.g. { notify: 'always' }, { rateLimit: 50 } */ extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed; @@ -249,19 +264,19 @@ interface KnockoutReadonlyObservableArray extends KnockoutReadonlyObservable< subscribe(callback: (newValue: KnockoutArrayChange[]) => void, target: any, event: "arrayChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target: any, event: "beforeChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target?: any, event?: "change"): KnockoutSubscription; - subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + subscribe(callback: (newValue: U) => void, target: any, event: string): KnockoutSubscription; } /* - NOTE: In theory this should extend both Observable and ReadonlyObservableArray, + NOTE: In theory this should extend both KnockoutObservable and KnockoutReadonlyObservableArray, but can't since they both provide conflicting typings of .subscribe. - So it extends Observable and duplicates the subscribe definitions, which should be kept in sync + So it extends KnockoutObservable and duplicates the subscribe definitions, which should be kept in sync */ interface KnockoutObservableArray extends KnockoutObservable, KnockoutObservableArrayFunctions { subscribe(callback: (newValue: KnockoutArrayChange[]) => void, target: any, event: "arrayChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target: any, event: "beforeChange"): KnockoutSubscription; subscribe(callback: (newValue: T[]) => void, target?: any, event?: "change"): KnockoutSubscription; - subscribe(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription; + subscribe(callback: (newValue: U) => void, target: any, event: string): KnockoutSubscription; extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray; } @@ -281,9 +296,8 @@ interface KnockoutObservableStatic { interface KnockoutReadonlyObservable extends KnockoutSubscribable, KnockoutObservableFunctions { (): T; - /** - * Returns the current value of the computed observable without creating a dependency + * Returns the current value of the computed observable without creating a dependency. */ peek(): T; valueHasMutated?: { (): void; }; @@ -294,6 +308,10 @@ interface KnockoutObservable extends KnockoutReadonlyObservable { (value: T): void; // Since .extend does arbitrary thing to an observable, it's not safe to do on a readonly observable + /** + * Customizes observables basic functionality. + * @param requestedExtenders Name of the extender feature and it's value, e.g. { notify: 'always' }, { rateLimit: 50 } + */ extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable; } @@ -301,7 +319,7 @@ interface KnockoutComputedOptions { /** * Makes the computed observable writable. This is a function that receives values that other code is trying to write to your computed observable. * It’s up to you to supply custom logic to handle the incoming values, typically by writing the values to some underlying observable(s). - * @param value + * @param value Value being written to the computer observable. */ write?(value: T): void; /** @@ -347,8 +365,19 @@ interface KnockoutBindingContext { $component: any; $componentTemplateNodes: Node[]; - extend(properties: any): any; - createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any; + /** + * Clones the current Binding Context, adding extra properties to it. + * @param properties object with properties to be added in the binding context. + */ + extend(properties: { [key: string]: any; } | (() => { [key: string]: any; })): KnockoutBindingContext; + /** + * This returns a new binding context whose viewmodel is the first parameter and whose $parentContext is the current bindingContext. + * @param dataItemOrAccessor The binding context of the children. + * @param dataItemAlias An alias for the data item in descendant contexts. + * @param extendCallback Function to be called. + * @param options Further options. + */ + createChildContext(dataItemOrAccessor: any, dataItemAlias?: string, extendCallback?: Function, options?: { "exportDependencies": boolean }): any; } interface KnockoutAllBindingsAccessor { @@ -405,7 +434,7 @@ interface KnockoutBindingHandlers { } interface KnockoutMemoization { - memoize(callback: () => string): string; + memoize(callback: Function): string; unmemoize(memoId: string, callbackParams: any[]): boolean; unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: any[]): boolean; parseMemoText(memoText: string): string; @@ -640,63 +669,100 @@ interface KnockoutStatic { computed: KnockoutComputedStatic; /** - * Creates a pure computed observable - * @param evaluatorFunction Function that computes the observable value - * @param context Defines the value of 'this' when evaluating the computed observable + * Creates a pure computed observable. + * @param evaluatorFunction Function that computes the observable value. + * @param context Defines the value of 'this' when evaluating the computed observable. */ pureComputed(evaluatorFunction: () => T, context?: any): KnockoutComputed; /** - * Creates a pure computed observable - * @param options An object that defines the computed observable options and behavior - * @param context Defines the value of 'this' when evaluating the computed observable + * Creates a pure computed observable. + * @param options An object that defines the computed observable options and behavior. + * @param context Defines the value of 'this' when evaluating the computed observable. */ pureComputed(options: KnockoutComputedDefine, context?: any): KnockoutComputed; observableArray: KnockoutObservableArrayStatic; - contextFor(node: any): any; + /** + * Evaluates if instance is a KnockoutSubscribable. + * @param instance Instance to be evaluated. + */ isSubscribable(instance: any): instance is KnockoutSubscribable; - toJSON(viewModel: any, replacer?: Function, space?: any): string; - + /** + * Clones object substituting each observable for it's underlying value. Uses browser JSON.stringify internally to stringify the result. + * @param viewModel Object with observables to be converted. + * @param replacer A Function or array of names that alters the behavior of the stringification process. + * @param space Used to insert white space into the output JSON string for readability purposes. + */ + toJSON(viewModel: any, replacer?: Function | [string | number], space?: string | number): string; + /** + * Clones object substituting for each observable the current value of that observable. + * @param viewModel Object with observables to be converted. + */ toJS(viewModel: any): any; /** * Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isObservable(instance: any): instance is KnockoutObservable; /** * Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isObservable(instance: KnockoutObservable | T): instance is KnockoutObservable; /** * Determine if argument is a writable observable. Returns true for observables, observable arrays, and writable computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isWriteableObservable(instance: any): instance is KnockoutObservable; /** * Determine if argument is a writable observable. Returns true for observables, observable arrays, and writable computed observables. - * @param instance Object to be checked + * @param instance Object to be checked. */ isWriteableObservable(instance: KnockoutObservable | T): instance is KnockoutObservable; /** - * Determine if argument is a computed observable - * @param instance Object to be checked + * Determine if argument is a computed observable. + * @param instance Object to be checked. */ isComputed(instance: any): instance is KnockoutComputed; /** - * Determine if argument is a computed observable - * @param instance Object to be checked + * Determine if argument is a computed observable. + * @param instance Object to be checked. */ isComputed(instance: KnockoutObservable | T): instance is KnockoutComputed; - dataFor(node: any): any; + /** + * Returns the data that was available for binding against the element. + * @param node Html node that contains the binding context. + */ + dataFor(node: Node): any; + /** + * Returns the entire binding context that was available to the DOM element. + * @param node Html node that contains the binding context. + */ + contextFor(node: Node): any; + /** + * Removes a node from the DOM. + * @param node Node to be removed. + */ removeNode(node: Node): void; + /** + * Used internally by Knockout to clean up data/computeds that it created related to the element. It does not remove any event handlers added by bindings. + * @param node Node to be cleaned. + */ cleanNode(node: Node): Node; renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any; renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any; - unwrap(value: KnockoutObservable | T): T; - unwrap(value: KnockoutObservableArray | T[]): T[]; + /** + * Returns the underlying value of the Knockout Observable or in case of plain js object, return the object. Use this to easily accept both observable and plain values. + * @param instance observable to be unwraped if it's an Observable. + */ + unwrap(instance: KnockoutObservable | T): T; + /** + * Gets the array inside the KnockoutObservableArray. + * @param instance observable to be unwraped. + */ + unwrap(instance: KnockoutObservableArray | T[]): T[]; /** * Get information about the current computed property during the execution of a computed observable’s evaluator function. @@ -783,10 +849,10 @@ interface KnockoutStatic { renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; /** - * Executes a callback function inside a computed observable, without creating a dependecy between it and the observables inside the function + * Executes a callback function inside a computed observable, without creating a dependecy between it and the observables inside the function. * @param callback Function to be called. - * @param callbackTarget Defines the value of 'this' in the callback function - * @param callbackArgs Arguments for the callback Function + * @param callbackTarget Defines the value of 'this' in the callback function. + * @param callbackArgs Arguments for the callback Function. */ ignoreDependencies(callback: () => T, callbackTarget?: any, callbackArgs?: any): T; @@ -924,9 +990,25 @@ declare namespace KnockoutComponentTypes { } interface Loader { + /** + * Define this if: you want to supply configurations programmatically based on names, e.g., to implement a naming convention. + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ getConfig?(componentName: string, callback: (result: ComponentConfig | null) => void): void; + /** + * Define this if: you want to take control over how component configurations are interpreted, e.g., if you do not want to use the standard 'viewModel/template' pair format. + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ loadComponent?(componentName: string, config: ComponentConfig, callback: (result: Definition | null) => void): void; + /** + * Define this if: you want to use custom logic to supply DOM nodes for a given template configuration (e.g., using an ajax request to fetch a template by URL). + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ loadTemplate?(componentName: string, templateConfig: any, callback: (result: Node[] | null) => void): void; + /** + * Define this if: you want to use custom logic to supply a viewmodel factory for a given viewmodel configuration (e.g., integrating with a third-party module loader or dependency injection system). + * @see {@link https://knockoutjs.com/documentation/component-loaders.html} + */ loadViewModel?(componentName: string, viewModelConfig: any, callback: (result: any) => void): void; suppressLoaderExceptions?: boolean; } @@ -941,7 +1023,7 @@ interface KnockoutComponents { /** * Registers a component, in the default component loader, to be used by name in the component binding. - * @param componentName Component name. + * @param componentName Component name. Will be used for your custom HTML tag name. * @param config Component configuration. */ register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void; @@ -956,7 +1038,7 @@ interface KnockoutComponents { */ unregister(componentName: string): void; /** - * Searchs each registered component loader by component name, and returns the viewmodel/template declaration via callback parameter + * Searchs each registered component loader by component name, and returns the viewmodel/template declaration via callback parameter. * @param componentName Component name. * @param callback Function to be called with the viewmodel/template declaration parameter. */ @@ -968,6 +1050,10 @@ interface KnockoutComponents { clearCachedDefinition(componentName: string): void defaultLoader: KnockoutComponentTypes.Loader; loaders: KnockoutComponentTypes.Loader[]; + /** + * Returns the registered component name for a HTML element. Can be overwriten to to control dynamically which HTML element map to which component name. + * @param node html element that corresponds to a custom component. + */ getComponentNameForNode(node: Node): string; } diff --git a/types/koa-bouncer/index.d.ts b/types/koa-bouncer/index.d.ts index af3a8b6693..91b4973893 100644 --- a/types/koa-bouncer/index.d.ts +++ b/types/koa-bouncer/index.d.ts @@ -30,10 +30,10 @@ declare namespace KoaBouncer { isNotIn(arr: any[], tip?: string): Validator isArray(tip?: string): Validator eq(otherVal: string, tip?: string): Validator - gt(otherVal: string, tip?: string): Validator - gte(otherVal: string, tip?: string): Validator - lt(otherVal: string, tip?: string): Validator - lte(otherVal: string, tip?: string): Validator + gt(otherVal: number, tip?: string): Validator + gte(otherVal: number, tip?: string): Validator + lt(otherVal: number, tip?: string): Validator + lte(otherVal: number, tip?: string): Validator isLength(min: number, max: number, tip?: string): Validator defaultTo(valueOrFunction: any): Validator isString(tip?: string): Validator diff --git a/types/koa-bouncer/koa-bouncer-tests.ts b/types/koa-bouncer/koa-bouncer-tests.ts index 0f91658a85..05f84e1b21 100644 --- a/types/koa-bouncer/koa-bouncer-tests.ts +++ b/types/koa-bouncer/koa-bouncer-tests.ts @@ -29,6 +29,9 @@ router.post('/users', async (ctx) => { .isString() .eq(ctx.vals.password1, 'Passwords must match') + ctx.validateBody('age') + .gte(18, 'Must be 18 or older') + console.log(ctx.vals) }) diff --git a/types/koa-hbs/package.json b/types/koa-hbs/package.json new file mode 100644 index 0000000000..77c0c562ac --- /dev/null +++ b/types/koa-hbs/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "handlebars": "^4.1.0" + } +} diff --git a/types/koa-mount/koa-mount-tests.ts b/types/koa-mount/koa-mount-tests.ts index 139e08a3d8..00ff57986d 100644 --- a/types/koa-mount/koa-mount-tests.ts +++ b/types/koa-mount/koa-mount-tests.ts @@ -3,13 +3,13 @@ import mount = require("koa-mount"); const a = new Koa(); -a.use((next) => { +a.use(function(next) { this.body = "Hello"; }); const b = new Koa(); -b.use((next) => { +b.use(function(next) { this.body = "World"; }); diff --git a/types/koa-router/index.d.ts b/types/koa-router/index.d.ts index 4df53d0e8b..823cc48059 100644 --- a/types/koa-router/index.d.ts +++ b/types/koa-router/index.d.ts @@ -193,6 +193,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + get( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + get( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP post method @@ -206,6 +217,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + post( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + post( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP put method @@ -219,6 +241,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + put( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + put( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP link method @@ -232,6 +265,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + link( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + link( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP unlink method @@ -245,6 +289,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + unlink( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + unlink( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP delete method @@ -258,6 +313,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + delete( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + delete( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * Alias for `router.delete()` because delete is a reserved word @@ -271,6 +337,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + del( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + del( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP head method @@ -284,6 +361,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + head( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + head( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP options method @@ -297,6 +385,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + options( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + options( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * HTTP path method @@ -310,6 +409,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + patch( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + patch( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * Register route with all methods. @@ -323,6 +433,17 @@ declare class Router { path: string | RegExp | (string | RegExp)[], ...middleware: Array> ): Router; + all( + name: string, + path: string | RegExp, + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; + all( + path: string | RegExp | (string | RegExp)[], + middleware: Koa.Middleware, + routeHandler: Router.IMiddleware + ): Router; /** * Set the path prefix for a Router instance that was already initialized. diff --git a/types/koa-router/koa-router-tests.ts b/types/koa-router/koa-router-tests.ts index 96fa0d1751..1759504f7b 100644 --- a/types/koa-router/koa-router-tests.ts +++ b/types/koa-router/koa-router-tests.ts @@ -125,3 +125,66 @@ app2.use((ctx: Context, next: any) => { }); app2.listen(8000); + +// Prepending middlewares tests + +type IBlah = { blah: string; } +type IWooh = { wooh: string; } + +const router4 = new Router({prefix: "/users"}); + +router4.get('/', + (ctx: Koa.ParameterizedContext, next) => { + ctx.state.blah = "blah"; + ctx.state.wooh = "wooh"; + return next(); + }, + (ctx, next) => { + console.log(ctx.state.blah); + console.log(ctx.state.wooh); + console.log(ctx.state.foo); + ctx.body = 'Hello World!'; + return next(); + }) + +const middleware1: Koa.Middleware = (ctx, next) => { + ctx.state.blah = "blah"; +} + +const middleware2: Koa.Middleware = (ctx, next) => { + ctx.state.wooh = "blah"; +} + +const emptyMiddleware: Koa.Middleware<{}> = (ctx, next) => { +} + +function routeHandler1(ctx: Koa.ParameterizedContext): void { + ctx.body = "234"; +} + +function routeHandler2(ctx: Koa.ParameterizedContext): void { + ctx.body = "234"; +} + +function routeHandler3(ctx: Koa.ParameterizedContext<{}>): void { + ctx.body = "234"; +} + +function routeHandler4(ctx: Router.RouterContext): void { + ctx.body = "234"; +} + +const middleware3 = compose([middleware1, middleware2]); + +router4.get('/foo', middleware3, routeHandler1); +router4.post('/foo', middleware1, routeHandler2); +router4.put('/foo', middleware2, routeHandler3); + +router4.patch("foo", '/foo', middleware3, routeHandler1); +router4.delete('/foo', middleware1, routeHandler2); +router4.head('/foo', middleware2, routeHandler3); + +router4.post('/foo', emptyMiddleware, emptyMiddleware, routeHandler4); +router4.post('/foo', emptyMiddleware, emptyMiddleware, emptyMiddleware, routeHandler4); +router4.get('name', '/foo', emptyMiddleware, emptyMiddleware, routeHandler4); +router4.get('name', '/foo', emptyMiddleware, emptyMiddleware, emptyMiddleware, routeHandler4); \ No newline at end of file diff --git a/types/koa-send/index.d.ts b/types/koa-send/index.d.ts index a4b090e1ea..bf6ddae297 100644 --- a/types/koa-send/index.d.ts +++ b/types/koa-send/index.d.ts @@ -6,17 +6,17 @@ // TypeScript Version: 2.3 import { - Context, + ParameterizedContext, } from "koa"; import { Stats, } from "fs"; -declare function send(ctx: Context, path: string, opts?: send.SendOptions): Promise; +declare function send(ctx: ParameterizedContext, path: string, opts?: send.SendOptions): Promise; declare namespace send { - type SetHeaders = (res: Context["res"], path: string, stats: Stats) => any; + type SetHeaders = (res: ParameterizedContext["res"], path: string, stats: Stats) => any; interface SendOptions { /** Browser cache max-age in milliseconds. (defaults to 0) */ diff --git a/types/koa-sslify/index.d.ts b/types/koa-sslify/index.d.ts index 0bf6c0a1ff..418b330586 100644 --- a/types/koa-sslify/index.d.ts +++ b/types/koa-sslify/index.d.ts @@ -1,25 +1,80 @@ -// Type definitions for koa-sslify 2.1 +// Type definitions for koa-sslify 4.0 // Project: https://github.com/turboMaCk/koa-sslify#readme // Definitions by: Matthew Bull +// Mihkel Sokk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as koa from 'koa'; +import * as koa from "koa"; declare namespace sslify { - interface Options { - trustProtoHeader?: boolean; - trustAzureHeader?: boolean; - port?: number; - hostname?: string; - ignoreUrl?: boolean; - temporary?: boolean; - redirectMethods?: string[]; - internalRedirectMethods?: string[]; - specCompliantDisallow?: boolean; - } + interface Options { + /** + * Function used to test if request is secure + */ + resolver?: (ctx: koa.Context) => boolean; + /** + * Hostname for redirect (uses request host if not set) + */ + hostname?: string; + /** + * Port of HTTPS server + */ + port?: number; + /** + * Avoid :443 port in redirect url + */ + skipDefaultPort?: boolean; + /** + * Ignore url path (redirect to domain) + */ + ignoreUrl?: boolean; + /** + * Temporary mode (use 307 Temporary Redirect) + */ + temporary?: boolean; + /** + * Whitelist methods that should be redirected + */ + redirectMethods?: string[]; + /** + * Status returned for disallowed methods + */ + disallowStatus?: number; + } + + /** + * Default HTTPS resolver + * This works when using node.js TLS support + */ + function httpsResolver(ctx: koa.Context): boolean; + + /** + * x-forwarded-proto header resolver + * common for heroku gcp (ingress) etc + */ + function xForwardedProtoResolver(ctx: koa.Context): boolean; + + /** + * Azure resolver + * Azure is using `x-att-ssl` header + */ + function azureResolver(ctx: koa.Context): boolean; + + /** + * Custom proto header factory + */ + function customProtoHeaderResolver( + header: string + ): (ctx: koa.Context) => boolean; + + /** + * Resolver for `Forwarded` header + * see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded + */ + function forwardedResolver(ctx: koa.Context): boolean; } -declare function sslify(options: sslify.Options): koa.Middleware; +declare function sslify(options?: sslify.Options): koa.Middleware; export = sslify; diff --git a/types/koa-sslify/koa-sslify-tests.ts b/types/koa-sslify/koa-sslify-tests.ts index c8dae23bb4..7c87c7c705 100644 --- a/types/koa-sslify/koa-sslify-tests.ts +++ b/types/koa-sslify/koa-sslify-tests.ts @@ -1,40 +1,50 @@ import Koa = require('koa'); import sslify = require('koa-sslify'); +new Koa().use(sslify()); + new Koa().use(sslify({})); new Koa().use(sslify({ - trustAzureHeader: true, + resolver: sslify.xForwardedProtoResolver, })); new Koa().use(sslify({ - trustProtoHeader: true, + resolver: sslify.azureResolver, })); new Koa().use(sslify({ - specCompliantDisallow: true, + resolver: sslify.customProtoHeaderResolver('x-protocol'), })); new Koa().use(sslify({ - port: 1234, + resolver: sslify.forwardedResolver, })); new Koa().use(sslify({ - hostname: 'my-host', + disallowStatus: 405, })); new Koa().use(sslify({ - temporary: false, + port: 1234, })); new Koa().use(sslify({ - internalRedirectMethods: ['GET'], + hostname: 'my-host', })); new Koa().use(sslify({ - redirectMethods: ['GET'], + temporary: false, })); new Koa().use(sslify({ - ignoreUrl: true, + redirectMethods: ['GET'], +})); + +new Koa().use(sslify({ + skipDefaultPort: false, +})); + +new Koa().use(sslify({ + ignoreUrl: true, })); diff --git a/types/koa-sslify/tsconfig.json b/types/koa-sslify/tsconfig.json index 775b453de9..8c1672161b 100644 --- a/types/koa-sslify/tsconfig.json +++ b/types/koa-sslify/tsconfig.json @@ -1,23 +1,16 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6" - ], + "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": [ - "index.d.ts", - "koa-sslify-tests.ts" - ] -} \ No newline at end of file + "files": ["index.d.ts", "koa-sslify-tests.ts"] +} diff --git a/types/lodash-es/index.d.ts b/types/lodash-es/index.d.ts index 61eb6016ee..3e9fcfa69c 100644 --- a/types/lodash-es/index.d.ts +++ b/types/lodash-es/index.d.ts @@ -2,7 +2,7 @@ // Project: http://lodash.com/, https://lodash.com/custom-builds // Definitions by: Stephen Lautier , e-cloud // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 export { default as add } from "./add"; export { default as after } from "./after"; diff --git a/types/lodash.add/index.d.ts b/types/lodash.add/index.d.ts index 742a2fc000..baddebd61a 100644 --- a/types/lodash.add/index.d.ts +++ b/types/lodash.add/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.after/index.d.ts b/types/lodash.after/index.d.ts index 48adaf8994..fc56217da5 100644 --- a/types/lodash.after/index.d.ts +++ b/types/lodash.after/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.ary/index.d.ts b/types/lodash.ary/index.d.ts index d442d3ad4d..1d44bac65a 100644 --- a/types/lodash.ary/index.d.ts +++ b/types/lodash.ary/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.assign/index.d.ts b/types/lodash.assign/index.d.ts index 549fb7af74..439ca018b5 100644 --- a/types/lodash.assign/index.d.ts +++ b/types/lodash.assign/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.assignin/index.d.ts b/types/lodash.assignin/index.d.ts index 34e644c6b9..33c31dbc31 100644 --- a/types/lodash.assignin/index.d.ts +++ b/types/lodash.assignin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.assigninwith/index.d.ts b/types/lodash.assigninwith/index.d.ts index ba48574c0d..17d76a4304 100644 --- a/types/lodash.assigninwith/index.d.ts +++ b/types/lodash.assigninwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.assignwith/index.d.ts b/types/lodash.assignwith/index.d.ts index b88032631e..d95702fd18 100644 --- a/types/lodash.assignwith/index.d.ts +++ b/types/lodash.assignwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.at/index.d.ts b/types/lodash.at/index.d.ts index a307f84553..278854bab6 100644 --- a/types/lodash.at/index.d.ts +++ b/types/lodash.at/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.attempt/index.d.ts b/types/lodash.attempt/index.d.ts index 71b89a092f..9db30b6fd0 100644 --- a/types/lodash.attempt/index.d.ts +++ b/types/lodash.attempt/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.before/index.d.ts b/types/lodash.before/index.d.ts index f19139a5ee..482c458fd4 100644 --- a/types/lodash.before/index.d.ts +++ b/types/lodash.before/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.bind/index.d.ts b/types/lodash.bind/index.d.ts index e90ebaa4c1..bf22c45a09 100644 --- a/types/lodash.bind/index.d.ts +++ b/types/lodash.bind/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.bindall/index.d.ts b/types/lodash.bindall/index.d.ts index 4a4cb0de76..135c532028 100644 --- a/types/lodash.bindall/index.d.ts +++ b/types/lodash.bindall/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.bindkey/index.d.ts b/types/lodash.bindkey/index.d.ts index 86c9c13672..12553e21b8 100644 --- a/types/lodash.bindkey/index.d.ts +++ b/types/lodash.bindkey/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.camelcase/index.d.ts b/types/lodash.camelcase/index.d.ts index 6fbedc08d6..8f01a3bf38 100644 --- a/types/lodash.camelcase/index.d.ts +++ b/types/lodash.camelcase/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.capitalize/index.d.ts b/types/lodash.capitalize/index.d.ts index fbe1b177ee..5e0ffdced3 100644 --- a/types/lodash.capitalize/index.d.ts +++ b/types/lodash.capitalize/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.castarray/index.d.ts b/types/lodash.castarray/index.d.ts index 41e53aecff..f27ca127a6 100644 --- a/types/lodash.castarray/index.d.ts +++ b/types/lodash.castarray/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.ceil/index.d.ts b/types/lodash.ceil/index.d.ts index d6e055af91..f49a415e20 100644 --- a/types/lodash.ceil/index.d.ts +++ b/types/lodash.ceil/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.chunk/index.d.ts b/types/lodash.chunk/index.d.ts index c85c5c988c..0591152d32 100644 --- a/types/lodash.chunk/index.d.ts +++ b/types/lodash.chunk/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.clamp/index.d.ts b/types/lodash.clamp/index.d.ts index 7bc75b42e9..38624c2214 100644 --- a/types/lodash.clamp/index.d.ts +++ b/types/lodash.clamp/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.clone/index.d.ts b/types/lodash.clone/index.d.ts index 62da74b22d..333915a404 100644 --- a/types/lodash.clone/index.d.ts +++ b/types/lodash.clone/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.clonedeep/index.d.ts b/types/lodash.clonedeep/index.d.ts index 5f25f0cfa7..369942bf05 100644 --- a/types/lodash.clonedeep/index.d.ts +++ b/types/lodash.clonedeep/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.clonedeepwith/index.d.ts b/types/lodash.clonedeepwith/index.d.ts index 9725303ac2..9d37cbea6d 100644 --- a/types/lodash.clonedeepwith/index.d.ts +++ b/types/lodash.clonedeepwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.clonewith/index.d.ts b/types/lodash.clonewith/index.d.ts index b02127620c..0a099fd494 100644 --- a/types/lodash.clonewith/index.d.ts +++ b/types/lodash.clonewith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.compact/index.d.ts b/types/lodash.compact/index.d.ts index 48b4bbd7e1..553668fcb3 100644 --- a/types/lodash.compact/index.d.ts +++ b/types/lodash.compact/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.concat/index.d.ts b/types/lodash.concat/index.d.ts index 576dd6aa6b..f96ec742b9 100644 --- a/types/lodash.concat/index.d.ts +++ b/types/lodash.concat/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.cond/index.d.ts b/types/lodash.cond/index.d.ts index 633e40809e..83fa5ef27a 100644 --- a/types/lodash.cond/index.d.ts +++ b/types/lodash.cond/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.constant/index.d.ts b/types/lodash.constant/index.d.ts index 5122739117..03c2713bdf 100644 --- a/types/lodash.constant/index.d.ts +++ b/types/lodash.constant/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.countby/index.d.ts b/types/lodash.countby/index.d.ts index 1f569be971..24b895f079 100644 --- a/types/lodash.countby/index.d.ts +++ b/types/lodash.countby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.create/index.d.ts b/types/lodash.create/index.d.ts index 173f439a2f..dca4287417 100644 --- a/types/lodash.create/index.d.ts +++ b/types/lodash.create/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.curry/index.d.ts b/types/lodash.curry/index.d.ts index d569ccb852..f24b40caed 100644 --- a/types/lodash.curry/index.d.ts +++ b/types/lodash.curry/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.curryright/index.d.ts b/types/lodash.curryright/index.d.ts index 0d13c7d705..b10ea20902 100644 --- a/types/lodash.curryright/index.d.ts +++ b/types/lodash.curryright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.debounce/index.d.ts b/types/lodash.debounce/index.d.ts index 4babb92e45..02f0bfc874 100644 --- a/types/lodash.debounce/index.d.ts +++ b/types/lodash.debounce/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.deburr/index.d.ts b/types/lodash.deburr/index.d.ts index 103ae6f0b9..f1c22579cc 100644 --- a/types/lodash.deburr/index.d.ts +++ b/types/lodash.deburr/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.defaults/index.d.ts b/types/lodash.defaults/index.d.ts index 9d92dd3021..b369cbbed2 100644 --- a/types/lodash.defaults/index.d.ts +++ b/types/lodash.defaults/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.defaultsdeep/index.d.ts b/types/lodash.defaultsdeep/index.d.ts index d1f1e1aa4e..4cafcffe76 100644 --- a/types/lodash.defaultsdeep/index.d.ts +++ b/types/lodash.defaultsdeep/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.defer/index.d.ts b/types/lodash.defer/index.d.ts index 12247d6273..9a015ee473 100644 --- a/types/lodash.defer/index.d.ts +++ b/types/lodash.defer/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.delay/index.d.ts b/types/lodash.delay/index.d.ts index 2ad1ff79d3..9fb968dc1f 100644 --- a/types/lodash.delay/index.d.ts +++ b/types/lodash.delay/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.difference/index.d.ts b/types/lodash.difference/index.d.ts index 9843b97496..53d2f688e0 100644 --- a/types/lodash.difference/index.d.ts +++ b/types/lodash.difference/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.differenceby/index.d.ts b/types/lodash.differenceby/index.d.ts index 24d95da85a..11b877c8bd 100644 --- a/types/lodash.differenceby/index.d.ts +++ b/types/lodash.differenceby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.differencewith/index.d.ts b/types/lodash.differencewith/index.d.ts index 32f51678ab..7bcaf0e374 100644 --- a/types/lodash.differencewith/index.d.ts +++ b/types/lodash.differencewith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.divide/index.d.ts b/types/lodash.divide/index.d.ts index 7abbafd7bd..87b705f72b 100644 --- a/types/lodash.divide/index.d.ts +++ b/types/lodash.divide/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.drop/index.d.ts b/types/lodash.drop/index.d.ts index 9eaf528d73..0bdebee18c 100644 --- a/types/lodash.drop/index.d.ts +++ b/types/lodash.drop/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.dropright/index.d.ts b/types/lodash.dropright/index.d.ts index 73056b73a4..305d9185ad 100644 --- a/types/lodash.dropright/index.d.ts +++ b/types/lodash.dropright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.droprightwhile/index.d.ts b/types/lodash.droprightwhile/index.d.ts index a145e956ee..f93a0e2bf8 100644 --- a/types/lodash.droprightwhile/index.d.ts +++ b/types/lodash.droprightwhile/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.dropwhile/index.d.ts b/types/lodash.dropwhile/index.d.ts index 7be29abfc4..c319c28cad 100644 --- a/types/lodash.dropwhile/index.d.ts +++ b/types/lodash.dropwhile/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.endswith/index.d.ts b/types/lodash.endswith/index.d.ts index d27aea64c5..08da3f984e 100644 --- a/types/lodash.endswith/index.d.ts +++ b/types/lodash.endswith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.eq/index.d.ts b/types/lodash.eq/index.d.ts index 1e577a2dac..2108d43241 100644 --- a/types/lodash.eq/index.d.ts +++ b/types/lodash.eq/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.escape/index.d.ts b/types/lodash.escape/index.d.ts index 3b9b0845ad..7fc4195d57 100644 --- a/types/lodash.escape/index.d.ts +++ b/types/lodash.escape/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.escaperegexp/index.d.ts b/types/lodash.escaperegexp/index.d.ts index 5d508bf40f..790be82ef5 100644 --- a/types/lodash.escaperegexp/index.d.ts +++ b/types/lodash.escaperegexp/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.every/index.d.ts b/types/lodash.every/index.d.ts index d4443355a4..c1daeeaf8b 100644 --- a/types/lodash.every/index.d.ts +++ b/types/lodash.every/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.fill/index.d.ts b/types/lodash.fill/index.d.ts index 21eca6cb70..b80b6f3766 100644 --- a/types/lodash.fill/index.d.ts +++ b/types/lodash.fill/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.filter/index.d.ts b/types/lodash.filter/index.d.ts index b7eaf4d001..620b5afa5f 100644 --- a/types/lodash.filter/index.d.ts +++ b/types/lodash.filter/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.find/index.d.ts b/types/lodash.find/index.d.ts index a4723afa63..2e872ac18f 100644 --- a/types/lodash.find/index.d.ts +++ b/types/lodash.find/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.findindex/index.d.ts b/types/lodash.findindex/index.d.ts index 04045617e0..d809dc25c1 100644 --- a/types/lodash.findindex/index.d.ts +++ b/types/lodash.findindex/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.findkey/index.d.ts b/types/lodash.findkey/index.d.ts index 151b5e28d8..d3d190c961 100644 --- a/types/lodash.findkey/index.d.ts +++ b/types/lodash.findkey/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.findlast/index.d.ts b/types/lodash.findlast/index.d.ts index e06477e488..82c796b516 100644 --- a/types/lodash.findlast/index.d.ts +++ b/types/lodash.findlast/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.findlastindex/index.d.ts b/types/lodash.findlastindex/index.d.ts index 982b1d3880..07fcecb2aa 100644 --- a/types/lodash.findlastindex/index.d.ts +++ b/types/lodash.findlastindex/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.findlastkey/index.d.ts b/types/lodash.findlastkey/index.d.ts index 7ce6837eb7..538349029a 100644 --- a/types/lodash.findlastkey/index.d.ts +++ b/types/lodash.findlastkey/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.first/index.d.ts b/types/lodash.first/index.d.ts index cd48bdc4bf..c4e173b32e 100644 --- a/types/lodash.first/index.d.ts +++ b/types/lodash.first/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flatmap/index.d.ts b/types/lodash.flatmap/index.d.ts index 11cd11337b..376fa4dde5 100644 --- a/types/lodash.flatmap/index.d.ts +++ b/types/lodash.flatmap/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flatmapdeep/index.d.ts b/types/lodash.flatmapdeep/index.d.ts index d4f10edf3e..b6173e3aa4 100644 --- a/types/lodash.flatmapdeep/index.d.ts +++ b/types/lodash.flatmapdeep/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flatmapdepth/index.d.ts b/types/lodash.flatmapdepth/index.d.ts index 91fb6bd576..748e76f598 100644 --- a/types/lodash.flatmapdepth/index.d.ts +++ b/types/lodash.flatmapdepth/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flatten/index.d.ts b/types/lodash.flatten/index.d.ts index 3689f19e15..7ce8c0b8b6 100644 --- a/types/lodash.flatten/index.d.ts +++ b/types/lodash.flatten/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flattendeep/index.d.ts b/types/lodash.flattendeep/index.d.ts index 791f2b384f..aeff806101 100644 --- a/types/lodash.flattendeep/index.d.ts +++ b/types/lodash.flattendeep/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flattendepth/index.d.ts b/types/lodash.flattendepth/index.d.ts index 443cdc0cd0..439b417f7d 100644 --- a/types/lodash.flattendepth/index.d.ts +++ b/types/lodash.flattendepth/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flip/index.d.ts b/types/lodash.flip/index.d.ts index 6adfc21057..bd2c9ab212 100644 --- a/types/lodash.flip/index.d.ts +++ b/types/lodash.flip/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.floor/index.d.ts b/types/lodash.floor/index.d.ts index 27cfda6f21..1824957522 100644 --- a/types/lodash.floor/index.d.ts +++ b/types/lodash.floor/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flow/index.d.ts b/types/lodash.flow/index.d.ts index e6be4df9cc..7423e07409 100644 --- a/types/lodash.flow/index.d.ts +++ b/types/lodash.flow/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.flowright/index.d.ts b/types/lodash.flowright/index.d.ts index aa53e08fff..b81ad62b46 100644 --- a/types/lodash.flowright/index.d.ts +++ b/types/lodash.flowright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.foreach/index.d.ts b/types/lodash.foreach/index.d.ts index 464cb0e867..cc2b19c167 100644 --- a/types/lodash.foreach/index.d.ts +++ b/types/lodash.foreach/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.foreachright/index.d.ts b/types/lodash.foreachright/index.d.ts index 9ad225ae54..7508ed4471 100644 --- a/types/lodash.foreachright/index.d.ts +++ b/types/lodash.foreachright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.forin/index.d.ts b/types/lodash.forin/index.d.ts index 54669de7f9..c84824f65b 100644 --- a/types/lodash.forin/index.d.ts +++ b/types/lodash.forin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.forinright/index.d.ts b/types/lodash.forinright/index.d.ts index cfa0a1843a..62ff91a3e4 100644 --- a/types/lodash.forinright/index.d.ts +++ b/types/lodash.forinright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.forown/index.d.ts b/types/lodash.forown/index.d.ts index e1df00c22a..15623c7360 100644 --- a/types/lodash.forown/index.d.ts +++ b/types/lodash.forown/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.forownright/index.d.ts b/types/lodash.forownright/index.d.ts index 1a349592fd..13e34be0dd 100644 --- a/types/lodash.forownright/index.d.ts +++ b/types/lodash.forownright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.frompairs/index.d.ts b/types/lodash.frompairs/index.d.ts index f73cb2b9dd..580e3182a8 100644 --- a/types/lodash.frompairs/index.d.ts +++ b/types/lodash.frompairs/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.functions/index.d.ts b/types/lodash.functions/index.d.ts index 40abae2872..cf107f3212 100644 --- a/types/lodash.functions/index.d.ts +++ b/types/lodash.functions/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.functionsin/index.d.ts b/types/lodash.functionsin/index.d.ts index 17cca60180..c3cb89d7cd 100644 --- a/types/lodash.functionsin/index.d.ts +++ b/types/lodash.functionsin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.get/index.d.ts b/types/lodash.get/index.d.ts index 7ad640da93..991f9fee99 100644 --- a/types/lodash.get/index.d.ts +++ b/types/lodash.get/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.groupby/index.d.ts b/types/lodash.groupby/index.d.ts index 9363e47b41..1e784cc320 100644 --- a/types/lodash.groupby/index.d.ts +++ b/types/lodash.groupby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.gt/index.d.ts b/types/lodash.gt/index.d.ts index 6a973547b0..ca969f2462 100644 --- a/types/lodash.gt/index.d.ts +++ b/types/lodash.gt/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.gte/index.d.ts b/types/lodash.gte/index.d.ts index f968e8bb20..2f6a589c46 100644 --- a/types/lodash.gte/index.d.ts +++ b/types/lodash.gte/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.has/index.d.ts b/types/lodash.has/index.d.ts index 4f917d5187..4fc7c51bec 100644 --- a/types/lodash.has/index.d.ts +++ b/types/lodash.has/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.hasin/index.d.ts b/types/lodash.hasin/index.d.ts index ca286c6cd9..3789cda6fa 100644 --- a/types/lodash.hasin/index.d.ts +++ b/types/lodash.hasin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.head/index.d.ts b/types/lodash.head/index.d.ts index e26f114bf0..3a9f3883c1 100644 --- a/types/lodash.head/index.d.ts +++ b/types/lodash.head/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.identity/index.d.ts b/types/lodash.identity/index.d.ts index 986c039d2e..66b66ab307 100644 --- a/types/lodash.identity/index.d.ts +++ b/types/lodash.identity/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.includes/index.d.ts b/types/lodash.includes/index.d.ts index 1b490f7aed..34096d9006 100644 --- a/types/lodash.includes/index.d.ts +++ b/types/lodash.includes/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.indexof/index.d.ts b/types/lodash.indexof/index.d.ts index 8102c6a697..64ac787a5d 100644 --- a/types/lodash.indexof/index.d.ts +++ b/types/lodash.indexof/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.initial/index.d.ts b/types/lodash.initial/index.d.ts index 9fa9218416..49c86bb7c9 100644 --- a/types/lodash.initial/index.d.ts +++ b/types/lodash.initial/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.inrange/index.d.ts b/types/lodash.inrange/index.d.ts index 3a817d9d2d..1f3c456d3a 100644 --- a/types/lodash.inrange/index.d.ts +++ b/types/lodash.inrange/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.intersection/index.d.ts b/types/lodash.intersection/index.d.ts index 044cd6949d..b79e8b9050 100644 --- a/types/lodash.intersection/index.d.ts +++ b/types/lodash.intersection/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.intersectionby/index.d.ts b/types/lodash.intersectionby/index.d.ts index a1d01a7c5d..e57c36bfa4 100644 --- a/types/lodash.intersectionby/index.d.ts +++ b/types/lodash.intersectionby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.intersectionwith/index.d.ts b/types/lodash.intersectionwith/index.d.ts index ff7cba542d..561a2ad538 100644 --- a/types/lodash.intersectionwith/index.d.ts +++ b/types/lodash.intersectionwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.invert/index.d.ts b/types/lodash.invert/index.d.ts index 112bbee8e6..905632930b 100644 --- a/types/lodash.invert/index.d.ts +++ b/types/lodash.invert/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.invertby/index.d.ts b/types/lodash.invertby/index.d.ts index f7c8ef8ee7..181970a286 100644 --- a/types/lodash.invertby/index.d.ts +++ b/types/lodash.invertby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.invoke/index.d.ts b/types/lodash.invoke/index.d.ts index fb979c2079..82ddb56083 100644 --- a/types/lodash.invoke/index.d.ts +++ b/types/lodash.invoke/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.invokemap/index.d.ts b/types/lodash.invokemap/index.d.ts index 7cefb18454..28ed42e42b 100644 --- a/types/lodash.invokemap/index.d.ts +++ b/types/lodash.invokemap/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isarguments/index.d.ts b/types/lodash.isarguments/index.d.ts index 9f8704e327..1f9b59f548 100644 --- a/types/lodash.isarguments/index.d.ts +++ b/types/lodash.isarguments/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isarray/index.d.ts b/types/lodash.isarray/index.d.ts index 60299a147c..96a64836d4 100644 --- a/types/lodash.isarray/index.d.ts +++ b/types/lodash.isarray/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isarraybuffer/index.d.ts b/types/lodash.isarraybuffer/index.d.ts index ddeee837b6..3c44819f19 100644 --- a/types/lodash.isarraybuffer/index.d.ts +++ b/types/lodash.isarraybuffer/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isarraylike/index.d.ts b/types/lodash.isarraylike/index.d.ts index 761e226f3d..a56d9bbfa6 100644 --- a/types/lodash.isarraylike/index.d.ts +++ b/types/lodash.isarraylike/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isarraylikeobject/index.d.ts b/types/lodash.isarraylikeobject/index.d.ts index 8a3562ef04..545d6a3519 100644 --- a/types/lodash.isarraylikeobject/index.d.ts +++ b/types/lodash.isarraylikeobject/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isboolean/index.d.ts b/types/lodash.isboolean/index.d.ts index 60d3b863a8..cf84173cd1 100644 --- a/types/lodash.isboolean/index.d.ts +++ b/types/lodash.isboolean/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isbuffer/index.d.ts b/types/lodash.isbuffer/index.d.ts index e39e927ff1..34b164cfa3 100644 --- a/types/lodash.isbuffer/index.d.ts +++ b/types/lodash.isbuffer/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isdate/index.d.ts b/types/lodash.isdate/index.d.ts index cba12e469a..3023be1957 100644 --- a/types/lodash.isdate/index.d.ts +++ b/types/lodash.isdate/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.iselement/index.d.ts b/types/lodash.iselement/index.d.ts index 751b675421..9e83bcacc3 100644 --- a/types/lodash.iselement/index.d.ts +++ b/types/lodash.iselement/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isempty/index.d.ts b/types/lodash.isempty/index.d.ts index 92bf9b2168..b0516dca34 100644 --- a/types/lodash.isempty/index.d.ts +++ b/types/lodash.isempty/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isequal/index.d.ts b/types/lodash.isequal/index.d.ts index 0a00fb83ce..0bae99d588 100644 --- a/types/lodash.isequal/index.d.ts +++ b/types/lodash.isequal/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isequalwith/index.d.ts b/types/lodash.isequalwith/index.d.ts index 05eaecdbd0..2c00d66f7c 100644 --- a/types/lodash.isequalwith/index.d.ts +++ b/types/lodash.isequalwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.iserror/index.d.ts b/types/lodash.iserror/index.d.ts index 5e31aa33de..ae18901b11 100644 --- a/types/lodash.iserror/index.d.ts +++ b/types/lodash.iserror/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isfinite/index.d.ts b/types/lodash.isfinite/index.d.ts index 7d4874cd4a..398f037e5b 100644 --- a/types/lodash.isfinite/index.d.ts +++ b/types/lodash.isfinite/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isfunction/index.d.ts b/types/lodash.isfunction/index.d.ts index b0876bfe82..4dd84dbde7 100644 --- a/types/lodash.isfunction/index.d.ts +++ b/types/lodash.isfunction/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isinteger/index.d.ts b/types/lodash.isinteger/index.d.ts index e42d7bb1ac..8ea23c1c00 100644 --- a/types/lodash.isinteger/index.d.ts +++ b/types/lodash.isinteger/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.islength/index.d.ts b/types/lodash.islength/index.d.ts index 86c63fd45b..1567bba3f5 100644 --- a/types/lodash.islength/index.d.ts +++ b/types/lodash.islength/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.ismap/index.d.ts b/types/lodash.ismap/index.d.ts index 10ebdf8fe4..bebdcf2c6b 100644 --- a/types/lodash.ismap/index.d.ts +++ b/types/lodash.ismap/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.ismatch/index.d.ts b/types/lodash.ismatch/index.d.ts index 6439efb285..64f40ce6a9 100644 --- a/types/lodash.ismatch/index.d.ts +++ b/types/lodash.ismatch/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.ismatchwith/index.d.ts b/types/lodash.ismatchwith/index.d.ts index 322b329308..382c6d6253 100644 --- a/types/lodash.ismatchwith/index.d.ts +++ b/types/lodash.ismatchwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isnan/index.d.ts b/types/lodash.isnan/index.d.ts index 3f2067314f..9e5c35cce4 100644 --- a/types/lodash.isnan/index.d.ts +++ b/types/lodash.isnan/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isnative/index.d.ts b/types/lodash.isnative/index.d.ts index eb00733bee..e374f644c2 100644 --- a/types/lodash.isnative/index.d.ts +++ b/types/lodash.isnative/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isnil/index.d.ts b/types/lodash.isnil/index.d.ts index fed4d9b833..6120f80ea6 100644 --- a/types/lodash.isnil/index.d.ts +++ b/types/lodash.isnil/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isnull/index.d.ts b/types/lodash.isnull/index.d.ts index 73ebb73e1b..4c42cf8e06 100644 --- a/types/lodash.isnull/index.d.ts +++ b/types/lodash.isnull/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isnumber/index.d.ts b/types/lodash.isnumber/index.d.ts index 28132eb6a9..722da3ade2 100644 --- a/types/lodash.isnumber/index.d.ts +++ b/types/lodash.isnumber/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isobject/index.d.ts b/types/lodash.isobject/index.d.ts index e1e05723b8..3490c30643 100644 --- a/types/lodash.isobject/index.d.ts +++ b/types/lodash.isobject/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isobjectlike/index.d.ts b/types/lodash.isobjectlike/index.d.ts index 6ad791127f..a475ce9b0e 100644 --- a/types/lodash.isobjectlike/index.d.ts +++ b/types/lodash.isobjectlike/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isplainobject/index.d.ts b/types/lodash.isplainobject/index.d.ts index c76bc92a64..087f9aeba9 100644 --- a/types/lodash.isplainobject/index.d.ts +++ b/types/lodash.isplainobject/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isregexp/index.d.ts b/types/lodash.isregexp/index.d.ts index 65669eed68..1ffd065e36 100644 --- a/types/lodash.isregexp/index.d.ts +++ b/types/lodash.isregexp/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.issafeinteger/index.d.ts b/types/lodash.issafeinteger/index.d.ts index 62bf5880c3..f3f5fe9c3a 100644 --- a/types/lodash.issafeinteger/index.d.ts +++ b/types/lodash.issafeinteger/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isset/index.d.ts b/types/lodash.isset/index.d.ts index 76a6789d52..a39e705480 100644 --- a/types/lodash.isset/index.d.ts +++ b/types/lodash.isset/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isstring/index.d.ts b/types/lodash.isstring/index.d.ts index 81bcc8236a..bc54bf85ea 100644 --- a/types/lodash.isstring/index.d.ts +++ b/types/lodash.isstring/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.issymbol/index.d.ts b/types/lodash.issymbol/index.d.ts index 51a1313671..b59db2a3ef 100644 --- a/types/lodash.issymbol/index.d.ts +++ b/types/lodash.issymbol/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.istypedarray/index.d.ts b/types/lodash.istypedarray/index.d.ts index 5721a94c58..76ca43e3b0 100644 --- a/types/lodash.istypedarray/index.d.ts +++ b/types/lodash.istypedarray/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isundefined/index.d.ts b/types/lodash.isundefined/index.d.ts index a0f2f068fc..e893f5c4da 100644 --- a/types/lodash.isundefined/index.d.ts +++ b/types/lodash.isundefined/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isweakmap/index.d.ts b/types/lodash.isweakmap/index.d.ts index 28dc1febf5..651c976447 100644 --- a/types/lodash.isweakmap/index.d.ts +++ b/types/lodash.isweakmap/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.isweakset/index.d.ts b/types/lodash.isweakset/index.d.ts index 72465044fd..bf5ed2716e 100644 --- a/types/lodash.isweakset/index.d.ts +++ b/types/lodash.isweakset/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.iteratee/index.d.ts b/types/lodash.iteratee/index.d.ts index 29e1cc29fd..cecd754bf7 100644 --- a/types/lodash.iteratee/index.d.ts +++ b/types/lodash.iteratee/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.join/index.d.ts b/types/lodash.join/index.d.ts index 7769af5a06..357d8d151c 100644 --- a/types/lodash.join/index.d.ts +++ b/types/lodash.join/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.kebabcase/index.d.ts b/types/lodash.kebabcase/index.d.ts index 70ca258fe0..307f821ce9 100644 --- a/types/lodash.kebabcase/index.d.ts +++ b/types/lodash.kebabcase/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.keyby/index.d.ts b/types/lodash.keyby/index.d.ts index e02a4dd3f5..93626ab4d2 100644 --- a/types/lodash.keyby/index.d.ts +++ b/types/lodash.keyby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.keys/index.d.ts b/types/lodash.keys/index.d.ts index 177620ea0c..3db0980f97 100644 --- a/types/lodash.keys/index.d.ts +++ b/types/lodash.keys/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.keysin/index.d.ts b/types/lodash.keysin/index.d.ts index 98dd57b500..1e3f0bbcfa 100644 --- a/types/lodash.keysin/index.d.ts +++ b/types/lodash.keysin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.last/index.d.ts b/types/lodash.last/index.d.ts index dc2fadedb3..8403d5af99 100644 --- a/types/lodash.last/index.d.ts +++ b/types/lodash.last/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.lastindexof/index.d.ts b/types/lodash.lastindexof/index.d.ts index 891d2ca084..e991ef92b6 100644 --- a/types/lodash.lastindexof/index.d.ts +++ b/types/lodash.lastindexof/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.lowercase/index.d.ts b/types/lodash.lowercase/index.d.ts index 05a5a0a20e..dc349eeb90 100644 --- a/types/lodash.lowercase/index.d.ts +++ b/types/lodash.lowercase/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.lowerfirst/index.d.ts b/types/lodash.lowerfirst/index.d.ts index 05f3e6d760..6bd7aa96ff 100644 --- a/types/lodash.lowerfirst/index.d.ts +++ b/types/lodash.lowerfirst/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.lt/index.d.ts b/types/lodash.lt/index.d.ts index c9ef9da1b9..b4ccae8b22 100644 --- a/types/lodash.lt/index.d.ts +++ b/types/lodash.lt/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.lte/index.d.ts b/types/lodash.lte/index.d.ts index 7361ef610e..e3a61cfaa0 100644 --- a/types/lodash.lte/index.d.ts +++ b/types/lodash.lte/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.mapkeys/index.d.ts b/types/lodash.mapkeys/index.d.ts index 145fe41b89..c5b4cae952 100644 --- a/types/lodash.mapkeys/index.d.ts +++ b/types/lodash.mapkeys/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.mapvalues/index.d.ts b/types/lodash.mapvalues/index.d.ts index 86fb63ed4d..a6c2eaac45 100644 --- a/types/lodash.mapvalues/index.d.ts +++ b/types/lodash.mapvalues/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.matches/index.d.ts b/types/lodash.matches/index.d.ts index ebdc90e017..415a6d2738 100644 --- a/types/lodash.matches/index.d.ts +++ b/types/lodash.matches/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.matchesproperty/index.d.ts b/types/lodash.matchesproperty/index.d.ts index 533656be56..3e84c8decb 100644 --- a/types/lodash.matchesproperty/index.d.ts +++ b/types/lodash.matchesproperty/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.max/index.d.ts b/types/lodash.max/index.d.ts index 99aa8e2ffc..5957bcde74 100644 --- a/types/lodash.max/index.d.ts +++ b/types/lodash.max/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.maxby/index.d.ts b/types/lodash.maxby/index.d.ts index 9362902bf4..a7a06208c4 100644 --- a/types/lodash.maxby/index.d.ts +++ b/types/lodash.maxby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.mean/index.d.ts b/types/lodash.mean/index.d.ts index 2edd6adb1b..59c53c0dde 100644 --- a/types/lodash.mean/index.d.ts +++ b/types/lodash.mean/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.meanby/index.d.ts b/types/lodash.meanby/index.d.ts index a4305a0560..b0374e7d20 100644 --- a/types/lodash.meanby/index.d.ts +++ b/types/lodash.meanby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.memoize/index.d.ts b/types/lodash.memoize/index.d.ts index 869ae4ba7d..efe1a8b04b 100644 --- a/types/lodash.memoize/index.d.ts +++ b/types/lodash.memoize/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.merge/index.d.ts b/types/lodash.merge/index.d.ts index a757f0694e..898750eb58 100644 --- a/types/lodash.merge/index.d.ts +++ b/types/lodash.merge/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.mergewith/index.d.ts b/types/lodash.mergewith/index.d.ts index ea3ceda237..e35006bc36 100644 --- a/types/lodash.mergewith/index.d.ts +++ b/types/lodash.mergewith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.method/index.d.ts b/types/lodash.method/index.d.ts index 6d36760961..8168f96211 100644 --- a/types/lodash.method/index.d.ts +++ b/types/lodash.method/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.methodof/index.d.ts b/types/lodash.methodof/index.d.ts index 057ef55108..ba2dfb7012 100644 --- a/types/lodash.methodof/index.d.ts +++ b/types/lodash.methodof/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.min/index.d.ts b/types/lodash.min/index.d.ts index e8a613f17f..b5b52fe095 100644 --- a/types/lodash.min/index.d.ts +++ b/types/lodash.min/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.minby/index.d.ts b/types/lodash.minby/index.d.ts index d9b6a58bfe..8c3d8dfcdb 100644 --- a/types/lodash.minby/index.d.ts +++ b/types/lodash.minby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.mixin/index.d.ts b/types/lodash.mixin/index.d.ts index ff0a8975da..fd9e480f31 100644 --- a/types/lodash.mixin/index.d.ts +++ b/types/lodash.mixin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.negate/index.d.ts b/types/lodash.negate/index.d.ts index 3043694532..d771f63eb4 100644 --- a/types/lodash.negate/index.d.ts +++ b/types/lodash.negate/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.noop/index.d.ts b/types/lodash.noop/index.d.ts index 30a76c63ce..963f951c93 100644 --- a/types/lodash.noop/index.d.ts +++ b/types/lodash.noop/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.now/index.d.ts b/types/lodash.now/index.d.ts index 1cb3ed1cea..508d07e777 100644 --- a/types/lodash.now/index.d.ts +++ b/types/lodash.now/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.nth/index.d.ts b/types/lodash.nth/index.d.ts index 5368fd7dee..66cda782a2 100644 --- a/types/lodash.nth/index.d.ts +++ b/types/lodash.nth/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.ntharg/index.d.ts b/types/lodash.ntharg/index.d.ts index d444e2cbee..e7bd831879 100644 --- a/types/lodash.ntharg/index.d.ts +++ b/types/lodash.ntharg/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.omit/index.d.ts b/types/lodash.omit/index.d.ts index 38d60f8538..7e15b2f9f9 100644 --- a/types/lodash.omit/index.d.ts +++ b/types/lodash.omit/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.omitby/index.d.ts b/types/lodash.omitby/index.d.ts index 5946e410ac..209ff398bf 100644 --- a/types/lodash.omitby/index.d.ts +++ b/types/lodash.omitby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.once/index.d.ts b/types/lodash.once/index.d.ts index fbe506150b..4dc4c566ae 100644 --- a/types/lodash.once/index.d.ts +++ b/types/lodash.once/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.orderby/index.d.ts b/types/lodash.orderby/index.d.ts index 2e8c5c5da4..485075ca90 100644 --- a/types/lodash.orderby/index.d.ts +++ b/types/lodash.orderby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.over/index.d.ts b/types/lodash.over/index.d.ts index 2d078c4853..0e4d238680 100644 --- a/types/lodash.over/index.d.ts +++ b/types/lodash.over/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.overargs/index.d.ts b/types/lodash.overargs/index.d.ts index 18b7024397..bcaa606780 100644 --- a/types/lodash.overargs/index.d.ts +++ b/types/lodash.overargs/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.overevery/index.d.ts b/types/lodash.overevery/index.d.ts index 7ca277f428..85c5b82167 100644 --- a/types/lodash.overevery/index.d.ts +++ b/types/lodash.overevery/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.oversome/index.d.ts b/types/lodash.oversome/index.d.ts index abf71cb967..b0ccb5950d 100644 --- a/types/lodash.oversome/index.d.ts +++ b/types/lodash.oversome/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pad/index.d.ts b/types/lodash.pad/index.d.ts index 516d851dec..cd276e2958 100644 --- a/types/lodash.pad/index.d.ts +++ b/types/lodash.pad/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.padend/index.d.ts b/types/lodash.padend/index.d.ts index fdaf51da25..d2729c4daf 100644 --- a/types/lodash.padend/index.d.ts +++ b/types/lodash.padend/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.padstart/index.d.ts b/types/lodash.padstart/index.d.ts index a91cd5339e..6a6d76247a 100644 --- a/types/lodash.padstart/index.d.ts +++ b/types/lodash.padstart/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.parseint/index.d.ts b/types/lodash.parseint/index.d.ts index 727c8d66c7..f47f64bf23 100644 --- a/types/lodash.parseint/index.d.ts +++ b/types/lodash.parseint/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.partial/index.d.ts b/types/lodash.partial/index.d.ts index 18d68aa00a..102f0e9f63 100644 --- a/types/lodash.partial/index.d.ts +++ b/types/lodash.partial/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.partialright/index.d.ts b/types/lodash.partialright/index.d.ts index b005408404..0c340fcd04 100644 --- a/types/lodash.partialright/index.d.ts +++ b/types/lodash.partialright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.partition/index.d.ts b/types/lodash.partition/index.d.ts index 8abce2b57f..6c825236ee 100644 --- a/types/lodash.partition/index.d.ts +++ b/types/lodash.partition/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pick/index.d.ts b/types/lodash.pick/index.d.ts index e2f2df3d30..50b68a2861 100644 --- a/types/lodash.pick/index.d.ts +++ b/types/lodash.pick/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pickby/index.d.ts b/types/lodash.pickby/index.d.ts index fdf61e9468..611f6236fc 100644 --- a/types/lodash.pickby/index.d.ts +++ b/types/lodash.pickby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.property/index.d.ts b/types/lodash.property/index.d.ts index 0701c0ef8b..f1a42f651b 100644 --- a/types/lodash.property/index.d.ts +++ b/types/lodash.property/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.propertyof/index.d.ts b/types/lodash.propertyof/index.d.ts index 5c22792ce8..2124d0d9a3 100644 --- a/types/lodash.propertyof/index.d.ts +++ b/types/lodash.propertyof/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pull/index.d.ts b/types/lodash.pull/index.d.ts index c9f543ff15..e39449666f 100644 --- a/types/lodash.pull/index.d.ts +++ b/types/lodash.pull/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pullall/index.d.ts b/types/lodash.pullall/index.d.ts index 7cce80257d..b7bff17877 100644 --- a/types/lodash.pullall/index.d.ts +++ b/types/lodash.pullall/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pullallby/index.d.ts b/types/lodash.pullallby/index.d.ts index 77adee2864..3a565c123a 100644 --- a/types/lodash.pullallby/index.d.ts +++ b/types/lodash.pullallby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pullallwith/index.d.ts b/types/lodash.pullallwith/index.d.ts index f11192ffbe..8199b47fd9 100644 --- a/types/lodash.pullallwith/index.d.ts +++ b/types/lodash.pullallwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.pullat/index.d.ts b/types/lodash.pullat/index.d.ts index 4b04d54fac..de603648e1 100644 --- a/types/lodash.pullat/index.d.ts +++ b/types/lodash.pullat/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.random/index.d.ts b/types/lodash.random/index.d.ts index 48147b1b5a..f30cdd73cc 100644 --- a/types/lodash.random/index.d.ts +++ b/types/lodash.random/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.range/index.d.ts b/types/lodash.range/index.d.ts index 9ca85ee30c..2faa2e0de0 100644 --- a/types/lodash.range/index.d.ts +++ b/types/lodash.range/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.rangeright/index.d.ts b/types/lodash.rangeright/index.d.ts index f17168e479..eb21ac069a 100644 --- a/types/lodash.rangeright/index.d.ts +++ b/types/lodash.rangeright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.rearg/index.d.ts b/types/lodash.rearg/index.d.ts index bdde2bd4af..8c1c349117 100644 --- a/types/lodash.rearg/index.d.ts +++ b/types/lodash.rearg/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.reduce/index.d.ts b/types/lodash.reduce/index.d.ts index f7f58198eb..3e87301a13 100644 --- a/types/lodash.reduce/index.d.ts +++ b/types/lodash.reduce/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.reduceright/index.d.ts b/types/lodash.reduceright/index.d.ts index 4fc2a4d54a..7143b8545a 100644 --- a/types/lodash.reduceright/index.d.ts +++ b/types/lodash.reduceright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.reject/index.d.ts b/types/lodash.reject/index.d.ts index b183695eec..fcf24925ee 100644 --- a/types/lodash.reject/index.d.ts +++ b/types/lodash.reject/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.remove/index.d.ts b/types/lodash.remove/index.d.ts index 449e9d62de..9e1c0e7cff 100644 --- a/types/lodash.remove/index.d.ts +++ b/types/lodash.remove/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.repeat/index.d.ts b/types/lodash.repeat/index.d.ts index fcd29d00f0..c594a58bdf 100644 --- a/types/lodash.repeat/index.d.ts +++ b/types/lodash.repeat/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.replace/index.d.ts b/types/lodash.replace/index.d.ts index b3421ff41a..1a41363950 100644 --- a/types/lodash.replace/index.d.ts +++ b/types/lodash.replace/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.rest/index.d.ts b/types/lodash.rest/index.d.ts index bcc5c5e083..1313395b60 100644 --- a/types/lodash.rest/index.d.ts +++ b/types/lodash.rest/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.result/index.d.ts b/types/lodash.result/index.d.ts index 684c213eea..aba9c14ee5 100644 --- a/types/lodash.result/index.d.ts +++ b/types/lodash.result/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.reverse/index.d.ts b/types/lodash.reverse/index.d.ts index 72dbe9e2fe..738afb06bd 100644 --- a/types/lodash.reverse/index.d.ts +++ b/types/lodash.reverse/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.round/index.d.ts b/types/lodash.round/index.d.ts index 7311d157ce..d105a69013 100644 --- a/types/lodash.round/index.d.ts +++ b/types/lodash.round/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sample/index.d.ts b/types/lodash.sample/index.d.ts index 2eb8119f0e..9bd7983185 100644 --- a/types/lodash.sample/index.d.ts +++ b/types/lodash.sample/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.samplesize/index.d.ts b/types/lodash.samplesize/index.d.ts index 1df16efad5..8046278ed6 100644 --- a/types/lodash.samplesize/index.d.ts +++ b/types/lodash.samplesize/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.set/index.d.ts b/types/lodash.set/index.d.ts index 686e1588bc..d2628e2f35 100644 --- a/types/lodash.set/index.d.ts +++ b/types/lodash.set/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.setwith/index.d.ts b/types/lodash.setwith/index.d.ts index b61d8ae119..3c4aa25a69 100644 --- a/types/lodash.setwith/index.d.ts +++ b/types/lodash.setwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.shuffle/index.d.ts b/types/lodash.shuffle/index.d.ts index d9374b5072..1961d9f44c 100644 --- a/types/lodash.shuffle/index.d.ts +++ b/types/lodash.shuffle/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.size/index.d.ts b/types/lodash.size/index.d.ts index 18c18eeced..84aedf70cb 100644 --- a/types/lodash.size/index.d.ts +++ b/types/lodash.size/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.slice/index.d.ts b/types/lodash.slice/index.d.ts index c2381806b5..e17a0e5c62 100644 --- a/types/lodash.slice/index.d.ts +++ b/types/lodash.slice/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.snakecase/index.d.ts b/types/lodash.snakecase/index.d.ts index 7b468103ae..5276593906 100644 --- a/types/lodash.snakecase/index.d.ts +++ b/types/lodash.snakecase/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.some/index.d.ts b/types/lodash.some/index.d.ts index 9fb21515a8..cad1fb59df 100644 --- a/types/lodash.some/index.d.ts +++ b/types/lodash.some/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortby/index.d.ts b/types/lodash.sortby/index.d.ts index 14de9ae556..5cef6f1b8f 100644 --- a/types/lodash.sortby/index.d.ts +++ b/types/lodash.sortby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortedindex/index.d.ts b/types/lodash.sortedindex/index.d.ts index 23a331e64a..4ca2706774 100644 --- a/types/lodash.sortedindex/index.d.ts +++ b/types/lodash.sortedindex/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortedindexby/index.d.ts b/types/lodash.sortedindexby/index.d.ts index 6fa690eb63..42abb67d25 100644 --- a/types/lodash.sortedindexby/index.d.ts +++ b/types/lodash.sortedindexby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortedindexof/index.d.ts b/types/lodash.sortedindexof/index.d.ts index 1905dc923c..194731d861 100644 --- a/types/lodash.sortedindexof/index.d.ts +++ b/types/lodash.sortedindexof/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortedlastindex/index.d.ts b/types/lodash.sortedlastindex/index.d.ts index 8759590288..f7781aaa66 100644 --- a/types/lodash.sortedlastindex/index.d.ts +++ b/types/lodash.sortedlastindex/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortedlastindexby/index.d.ts b/types/lodash.sortedlastindexby/index.d.ts index d513d18674..08fdf6553b 100644 --- a/types/lodash.sortedlastindexby/index.d.ts +++ b/types/lodash.sortedlastindexby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sortedlastindexof/index.d.ts b/types/lodash.sortedlastindexof/index.d.ts index 14d5656d62..6032e69d64 100644 --- a/types/lodash.sortedlastindexof/index.d.ts +++ b/types/lodash.sortedlastindexof/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sorteduniq/index.d.ts b/types/lodash.sorteduniq/index.d.ts index 04af0325a0..692a046d7c 100644 --- a/types/lodash.sorteduniq/index.d.ts +++ b/types/lodash.sorteduniq/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sorteduniqby/index.d.ts b/types/lodash.sorteduniqby/index.d.ts index 26c838a01d..d986fe8827 100644 --- a/types/lodash.sorteduniqby/index.d.ts +++ b/types/lodash.sorteduniqby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.split/index.d.ts b/types/lodash.split/index.d.ts index 5400e2345a..361aa0e316 100644 --- a/types/lodash.split/index.d.ts +++ b/types/lodash.split/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.spread/index.d.ts b/types/lodash.spread/index.d.ts index d96b12d1ba..7cc9d2ca08 100644 --- a/types/lodash.spread/index.d.ts +++ b/types/lodash.spread/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.startcase/index.d.ts b/types/lodash.startcase/index.d.ts index 2c00230290..39c5dba0ba 100644 --- a/types/lodash.startcase/index.d.ts +++ b/types/lodash.startcase/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.startswith/index.d.ts b/types/lodash.startswith/index.d.ts index fbd92b4c40..8604081e3c 100644 --- a/types/lodash.startswith/index.d.ts +++ b/types/lodash.startswith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.subtract/index.d.ts b/types/lodash.subtract/index.d.ts index 676efb6f17..ca4600978b 100644 --- a/types/lodash.subtract/index.d.ts +++ b/types/lodash.subtract/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sum/index.d.ts b/types/lodash.sum/index.d.ts index b19d67a4ce..072c2250e3 100644 --- a/types/lodash.sum/index.d.ts +++ b/types/lodash.sum/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.sumby/index.d.ts b/types/lodash.sumby/index.d.ts index a5f6ac015a..d6acf8b452 100644 --- a/types/lodash.sumby/index.d.ts +++ b/types/lodash.sumby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tail/index.d.ts b/types/lodash.tail/index.d.ts index 51c89ef6b9..424d68fc32 100644 --- a/types/lodash.tail/index.d.ts +++ b/types/lodash.tail/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.take/index.d.ts b/types/lodash.take/index.d.ts index dffe621124..6b2449057e 100644 --- a/types/lodash.take/index.d.ts +++ b/types/lodash.take/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.takeright/index.d.ts b/types/lodash.takeright/index.d.ts index 637926a744..dffd09a240 100644 --- a/types/lodash.takeright/index.d.ts +++ b/types/lodash.takeright/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.takerightwhile/index.d.ts b/types/lodash.takerightwhile/index.d.ts index 376124310a..1cd4db0751 100644 --- a/types/lodash.takerightwhile/index.d.ts +++ b/types/lodash.takerightwhile/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.takewhile/index.d.ts b/types/lodash.takewhile/index.d.ts index 8e5e2958b5..ce92968a1d 100644 --- a/types/lodash.takewhile/index.d.ts +++ b/types/lodash.takewhile/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.template/index.d.ts b/types/lodash.template/index.d.ts index 9060d5e979..0506d0c968 100644 --- a/types/lodash.template/index.d.ts +++ b/types/lodash.template/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.throttle/index.d.ts b/types/lodash.throttle/index.d.ts index 0e5e2c3d79..260ec7a7c5 100644 --- a/types/lodash.throttle/index.d.ts +++ b/types/lodash.throttle/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.times/index.d.ts b/types/lodash.times/index.d.ts index dfbfcb0425..1811ac4ae2 100644 --- a/types/lodash.times/index.d.ts +++ b/types/lodash.times/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.toarray/index.d.ts b/types/lodash.toarray/index.d.ts index ea13431aa1..2f48f2ffde 100644 --- a/types/lodash.toarray/index.d.ts +++ b/types/lodash.toarray/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tofinite/index.d.ts b/types/lodash.tofinite/index.d.ts index 5639c9ba0f..86cbf6e544 100644 --- a/types/lodash.tofinite/index.d.ts +++ b/types/lodash.tofinite/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tointeger/index.d.ts b/types/lodash.tointeger/index.d.ts index d662ff0695..b1cabaecdd 100644 --- a/types/lodash.tointeger/index.d.ts +++ b/types/lodash.tointeger/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tolength/index.d.ts b/types/lodash.tolength/index.d.ts index a198d6cb5f..5e6277f4f2 100644 --- a/types/lodash.tolength/index.d.ts +++ b/types/lodash.tolength/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tolower/index.d.ts b/types/lodash.tolower/index.d.ts index a056bef4ae..d31706fdc7 100644 --- a/types/lodash.tolower/index.d.ts +++ b/types/lodash.tolower/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tonumber/index.d.ts b/types/lodash.tonumber/index.d.ts index 85587a3563..5898db9932 100644 --- a/types/lodash.tonumber/index.d.ts +++ b/types/lodash.tonumber/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.topairs/index.d.ts b/types/lodash.topairs/index.d.ts index dec1a83e18..940e3107ca 100644 --- a/types/lodash.topairs/index.d.ts +++ b/types/lodash.topairs/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.topairsin/index.d.ts b/types/lodash.topairsin/index.d.ts index 580cd15f14..f5a79e3da6 100644 --- a/types/lodash.topairsin/index.d.ts +++ b/types/lodash.topairsin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.topath/index.d.ts b/types/lodash.topath/index.d.ts index 5778b4a5a8..c66f4ed4aa 100644 --- a/types/lodash.topath/index.d.ts +++ b/types/lodash.topath/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.toplainobject/index.d.ts b/types/lodash.toplainobject/index.d.ts index 26f7eb62b3..b716e2cfa4 100644 --- a/types/lodash.toplainobject/index.d.ts +++ b/types/lodash.toplainobject/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tosafeinteger/index.d.ts b/types/lodash.tosafeinteger/index.d.ts index 5429fe3a24..7f8fb0b640 100644 --- a/types/lodash.tosafeinteger/index.d.ts +++ b/types/lodash.tosafeinteger/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.tostring/index.d.ts b/types/lodash.tostring/index.d.ts index d7aec37cf9..0bb36b6600 100644 --- a/types/lodash.tostring/index.d.ts +++ b/types/lodash.tostring/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.toupper/index.d.ts b/types/lodash.toupper/index.d.ts index a19a7f2293..46bc736e52 100644 --- a/types/lodash.toupper/index.d.ts +++ b/types/lodash.toupper/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.transform/index.d.ts b/types/lodash.transform/index.d.ts index 524dcce29d..0a0cfbfb55 100644 --- a/types/lodash.transform/index.d.ts +++ b/types/lodash.transform/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.trim/index.d.ts b/types/lodash.trim/index.d.ts index 634b4f5843..84c1772922 100644 --- a/types/lodash.trim/index.d.ts +++ b/types/lodash.trim/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.trimend/index.d.ts b/types/lodash.trimend/index.d.ts index 5931c425c1..f788678328 100644 --- a/types/lodash.trimend/index.d.ts +++ b/types/lodash.trimend/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.trimstart/index.d.ts b/types/lodash.trimstart/index.d.ts index 6e9ff19aae..d80dfde5ee 100644 --- a/types/lodash.trimstart/index.d.ts +++ b/types/lodash.trimstart/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.truncate/index.d.ts b/types/lodash.truncate/index.d.ts index 640143ae7d..49ed223a34 100644 --- a/types/lodash.truncate/index.d.ts +++ b/types/lodash.truncate/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unary/index.d.ts b/types/lodash.unary/index.d.ts index c1cab16bf4..2b5956b22f 100644 --- a/types/lodash.unary/index.d.ts +++ b/types/lodash.unary/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unescape/index.d.ts b/types/lodash.unescape/index.d.ts index 1a6c126529..9dd615040f 100644 --- a/types/lodash.unescape/index.d.ts +++ b/types/lodash.unescape/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.union/index.d.ts b/types/lodash.union/index.d.ts index f8e1c3982b..1e5de3029e 100644 --- a/types/lodash.union/index.d.ts +++ b/types/lodash.union/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unionby/index.d.ts b/types/lodash.unionby/index.d.ts index ec59f1b5c6..97c57d7820 100644 --- a/types/lodash.unionby/index.d.ts +++ b/types/lodash.unionby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unionwith/index.d.ts b/types/lodash.unionwith/index.d.ts index a724b6ed00..0951988b75 100644 --- a/types/lodash.unionwith/index.d.ts +++ b/types/lodash.unionwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.uniq/index.d.ts b/types/lodash.uniq/index.d.ts index d3fcc99bf8..a000cdc57e 100644 --- a/types/lodash.uniq/index.d.ts +++ b/types/lodash.uniq/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.uniqby/index.d.ts b/types/lodash.uniqby/index.d.ts index fdf318f2cc..430cc78f6b 100644 --- a/types/lodash.uniqby/index.d.ts +++ b/types/lodash.uniqby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.uniqueid/index.d.ts b/types/lodash.uniqueid/index.d.ts index f0b38f23ed..13ce1ddaf5 100644 --- a/types/lodash.uniqueid/index.d.ts +++ b/types/lodash.uniqueid/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.uniqwith/index.d.ts b/types/lodash.uniqwith/index.d.ts index 65f00cc772..852bd06e8e 100644 --- a/types/lodash.uniqwith/index.d.ts +++ b/types/lodash.uniqwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unset/index.d.ts b/types/lodash.unset/index.d.ts index 4308337560..778cba5f35 100644 --- a/types/lodash.unset/index.d.ts +++ b/types/lodash.unset/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unzip/index.d.ts b/types/lodash.unzip/index.d.ts index a0d6e933c1..c82e6e4240 100644 --- a/types/lodash.unzip/index.d.ts +++ b/types/lodash.unzip/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.unzipwith/index.d.ts b/types/lodash.unzipwith/index.d.ts index 0f95c0377f..de997d4c80 100644 --- a/types/lodash.unzipwith/index.d.ts +++ b/types/lodash.unzipwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.update/index.d.ts b/types/lodash.update/index.d.ts index 165804f25f..a9dc9ae88e 100644 --- a/types/lodash.update/index.d.ts +++ b/types/lodash.update/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.updatewith/index.d.ts b/types/lodash.updatewith/index.d.ts index 3ae0594188..578de0a19b 100644 --- a/types/lodash.updatewith/index.d.ts +++ b/types/lodash.updatewith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.uppercase/index.d.ts b/types/lodash.uppercase/index.d.ts index fb25f87be6..0433e10190 100644 --- a/types/lodash.uppercase/index.d.ts +++ b/types/lodash.uppercase/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.upperfirst/index.d.ts b/types/lodash.upperfirst/index.d.ts index f58a6853f3..a95e6a2325 100644 --- a/types/lodash.upperfirst/index.d.ts +++ b/types/lodash.upperfirst/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.values/index.d.ts b/types/lodash.values/index.d.ts index 9bba06f1a2..5712010b17 100644 --- a/types/lodash.values/index.d.ts +++ b/types/lodash.values/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.valuesin/index.d.ts b/types/lodash.valuesin/index.d.ts index 3da65eabb7..0168a046d0 100644 --- a/types/lodash.valuesin/index.d.ts +++ b/types/lodash.valuesin/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.without/index.d.ts b/types/lodash.without/index.d.ts index 624fdd8918..72cb11a8d8 100644 --- a/types/lodash.without/index.d.ts +++ b/types/lodash.without/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.words/index.d.ts b/types/lodash.words/index.d.ts index 304f7c3145..d635b02bbe 100644 --- a/types/lodash.words/index.d.ts +++ b/types/lodash.words/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.wrap/index.d.ts b/types/lodash.wrap/index.d.ts index 410c955027..52d0eb754e 100644 --- a/types/lodash.wrap/index.d.ts +++ b/types/lodash.wrap/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.xor/index.d.ts b/types/lodash.xor/index.d.ts index 0426670d24..ce8257b1be 100644 --- a/types/lodash.xor/index.d.ts +++ b/types/lodash.xor/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.xorby/index.d.ts b/types/lodash.xorby/index.d.ts index d1ebbbd9fa..3d15668d8a 100644 --- a/types/lodash.xorby/index.d.ts +++ b/types/lodash.xorby/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.xorwith/index.d.ts b/types/lodash.xorwith/index.d.ts index 6adaa16d35..8120a73dea 100644 --- a/types/lodash.xorwith/index.d.ts +++ b/types/lodash.xorwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.zip/index.d.ts b/types/lodash.zip/index.d.ts index 3ad6804c4f..3aca9880f9 100644 --- a/types/lodash.zip/index.d.ts +++ b/types/lodash.zip/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.zipobject/index.d.ts b/types/lodash.zipobject/index.d.ts index a4c0d0e444..b76f341e3e 100644 --- a/types/lodash.zipobject/index.d.ts +++ b/types/lodash.zipobject/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.zipobjectdeep/index.d.ts b/types/lodash.zipobjectdeep/index.d.ts index b942a3e4c6..b2b3a82dd2 100644 --- a/types/lodash.zipobjectdeep/index.d.ts +++ b/types/lodash.zipobjectdeep/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash.zipwith/index.d.ts b/types/lodash.zipwith/index.d.ts index 39c39005d7..fe58ffb360 100644 --- a/types/lodash.zipwith/index.d.ts +++ b/types/lodash.zipwith/index.d.ts @@ -2,7 +2,7 @@ // Project: https://lodash.com // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lodash/common/object.d.ts b/types/lodash/common/object.d.ts index b136e9469b..2342a18a06 100644 --- a/types/lodash/common/object.d.ts +++ b/types/lodash/common/object.d.ts @@ -1686,7 +1686,7 @@ declare module "../index" { object: TObject | null | undefined, path: TKey | [TKey], defaultValue: TDefault - ): TObject[TKey] | TDefault; + ): Exclude | TDefault; /** * @see _.get @@ -1763,7 +1763,7 @@ declare module "../index" { this: LoDashImplicitWrapper, path: TKey | [TKey], defaultValue: TDefault - ): TObject[TKey] | TDefault; + ): Exclude | TDefault; /** * @see _.get @@ -1839,7 +1839,7 @@ declare module "../index" { this: LoDashExplicitWrapper, path: TKey | [TKey], defaultValue: TDefault - ): LoDashExplicitWrapper; + ): LoDashExplicitWrapper | TDefault>; /** * @see _.get diff --git a/types/lodash/fp.d.ts b/types/lodash/fp.d.ts index 68084f1c8d..c26cedeb10 100644 --- a/types/lodash/fp.d.ts +++ b/types/lodash/fp.d.ts @@ -1494,7 +1494,7 @@ declare namespace _ { (defaultValue: lodash.__, path: lodash.__, object: TObject | null | undefined): LodashGetOr1x4; (defaultValue: TDefault, path: lodash.__, object: TObject | null | undefined): LodashGetOr1x5; (defaultValue: lodash.__, path: TKey | [TKey], object: TObject | null | undefined): LodashGetOr1x6; - (defaultValue: TDefault, path: TKey | [TKey], object: TObject | null | undefined): TObject[TKey] | TDefault; + (defaultValue: TDefault, path: TKey | [TKey], object: TObject | null | undefined): Exclude | TDefault; (defaultValue: lodash.__, path: number): LodashGetOr2x2; (defaultValue: TDefault, path: number): LodashGetOr2x3; (defaultValue: lodash.__, path: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashGetOr2x4; @@ -1517,7 +1517,7 @@ declare namespace _ { interface LodashGetOr1x1 { (path: TKey | [TKey]): LodashGetOr1x3; (path: lodash.__, object: TObject | null | undefined): LodashGetOr1x5; - (path: TKey | [TKey], object: TObject | null | undefined): TObject[TKey] | TDefault; + (path: TKey | [TKey], object: TObject | null | undefined): Exclude | TDefault; (path: number): LodashGetOr2x3; (path: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashGetOr2x5; (path: number, object: lodash.NumericDictionary | null | undefined): T | TDefault; @@ -1528,16 +1528,16 @@ declare namespace _ { interface LodashGetOr1x2 { (defaultValue: TDefault): LodashGetOr1x3; (defaultValue: lodash.__, object: TObject | null | undefined): LodashGetOr1x6; - (defaultValue: TDefault, object: TObject | null | undefined): TObject[TKey] | TDefault; + (defaultValue: TDefault, object: TObject | null | undefined): Exclude | TDefault; } - type LodashGetOr1x3 = (object: TObject | null | undefined) => TObject[TKey] | TDefault; + type LodashGetOr1x3 = (object: TObject | null | undefined) => Exclude | TDefault; interface LodashGetOr1x4 { (defaultValue: TDefault): LodashGetOr1x5; (defaultValue: lodash.__, path: TKey | [TKey]): LodashGetOr1x6; - (defaultValue: TDefault, path: TKey | [TKey]): TObject[TKey] | TDefault; + (defaultValue: TDefault, path: TKey | [TKey]): Exclude | TDefault; } - type LodashGetOr1x5 = (path: TKey | [TKey]) => TObject[TKey] | TDefault; - type LodashGetOr1x6 = (defaultValue: TDefault) => TObject[TKey] | TDefault; + type LodashGetOr1x5 = (path: TKey | [TKey]) => Exclude | TDefault; + type LodashGetOr1x6 = (defaultValue: TDefault) => Exclude | TDefault; interface LodashGetOr2x2 { (defaultValue: TDefault): LodashGetOr2x3; (defaultValue: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashGetOr2x6; @@ -2756,7 +2756,7 @@ declare namespace _ { (defaultValue: lodash.__, path: lodash.__, object: TObject | null | undefined): LodashPathOr1x4; (defaultValue: TDefault, path: lodash.__, object: TObject | null | undefined): LodashPathOr1x5; (defaultValue: lodash.__, path: TKey | [TKey], object: TObject | null | undefined): LodashPathOr1x6; - (defaultValue: TDefault, path: TKey | [TKey], object: TObject | null | undefined): TObject[TKey] | TDefault; + (defaultValue: TDefault, path: TKey | [TKey], object: TObject | null | undefined): Exclude | TDefault; (defaultValue: lodash.__, path: number): LodashPathOr2x2; (defaultValue: TDefault, path: number): LodashPathOr2x3; (defaultValue: lodash.__, path: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPathOr2x4; @@ -2779,7 +2779,7 @@ declare namespace _ { interface LodashPathOr1x1 { (path: TKey | [TKey]): LodashPathOr1x3; (path: lodash.__, object: TObject | null | undefined): LodashPathOr1x5; - (path: TKey | [TKey], object: TObject | null | undefined): TObject[TKey] | TDefault; + (path: TKey | [TKey], object: TObject | null | undefined): Exclude | TDefault; (path: number): LodashPathOr2x3; (path: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPathOr2x5; (path: number, object: lodash.NumericDictionary | null | undefined): T | TDefault; @@ -2790,16 +2790,16 @@ declare namespace _ { interface LodashPathOr1x2 { (defaultValue: TDefault): LodashPathOr1x3; (defaultValue: lodash.__, object: TObject | null | undefined): LodashPathOr1x6; - (defaultValue: TDefault, object: TObject | null | undefined): TObject[TKey] | TDefault; + (defaultValue: TDefault, object: TObject | null | undefined): Exclude | TDefault; } - type LodashPathOr1x3 = (object: TObject | null | undefined) => TObject[TKey] | TDefault; + type LodashPathOr1x3 = (object: TObject | null | undefined) => Exclude | TDefault; interface LodashPathOr1x4 { (defaultValue: TDefault): LodashPathOr1x5; (defaultValue: lodash.__, path: TKey | [TKey]): LodashPathOr1x6; - (defaultValue: TDefault, path: TKey | [TKey]): TObject[TKey] | TDefault; + (defaultValue: TDefault, path: TKey | [TKey]): Exclude | TDefault; } - type LodashPathOr1x5 = (path: TKey | [TKey]) => TObject[TKey] | TDefault; - type LodashPathOr1x6 = (defaultValue: TDefault) => TObject[TKey] | TDefault; + type LodashPathOr1x5 = (path: TKey | [TKey]) => Exclude | TDefault; + type LodashPathOr1x6 = (defaultValue: TDefault) => Exclude | TDefault; interface LodashPathOr2x2 { (defaultValue: TDefault): LodashPathOr2x3; (defaultValue: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPathOr2x6; @@ -2996,7 +2996,7 @@ declare namespace _ { (defaultValue: lodash.__, path: lodash.__, object: TObject | null | undefined): LodashPropOr1x4; (defaultValue: TDefault, path: lodash.__, object: TObject | null | undefined): LodashPropOr1x5; (defaultValue: lodash.__, path: TKey | [TKey], object: TObject | null | undefined): LodashPropOr1x6; - (defaultValue: TDefault, path: TKey | [TKey], object: TObject | null | undefined): TObject[TKey] | TDefault; + (defaultValue: TDefault, path: TKey | [TKey], object: TObject | null | undefined): Exclude | TDefault; (defaultValue: lodash.__, path: number): LodashPropOr2x2; (defaultValue: TDefault, path: number): LodashPropOr2x3; (defaultValue: lodash.__, path: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPropOr2x4; @@ -3019,7 +3019,7 @@ declare namespace _ { interface LodashPropOr1x1 { (path: TKey | [TKey]): LodashPropOr1x3; (path: lodash.__, object: TObject | null | undefined): LodashPropOr1x5; - (path: TKey | [TKey], object: TObject | null | undefined): TObject[TKey] | TDefault; + (path: TKey | [TKey], object: TObject | null | undefined): Exclude | TDefault; (path: number): LodashPropOr2x3; (path: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPropOr2x5; (path: number, object: lodash.NumericDictionary | null | undefined): T | TDefault; @@ -3030,16 +3030,16 @@ declare namespace _ { interface LodashPropOr1x2 { (defaultValue: TDefault): LodashPropOr1x3; (defaultValue: lodash.__, object: TObject | null | undefined): LodashPropOr1x6; - (defaultValue: TDefault, object: TObject | null | undefined): TObject[TKey] | TDefault; + (defaultValue: TDefault, object: TObject | null | undefined): Exclude | TDefault; } - type LodashPropOr1x3 = (object: TObject | null | undefined) => TObject[TKey] | TDefault; + type LodashPropOr1x3 = (object: TObject | null | undefined) => Exclude | TDefault; interface LodashPropOr1x4 { (defaultValue: TDefault): LodashPropOr1x5; (defaultValue: lodash.__, path: TKey | [TKey]): LodashPropOr1x6; - (defaultValue: TDefault, path: TKey | [TKey]): TObject[TKey] | TDefault; + (defaultValue: TDefault, path: TKey | [TKey]): Exclude | TDefault; } - type LodashPropOr1x5 = (path: TKey | [TKey]) => TObject[TKey] | TDefault; - type LodashPropOr1x6 = (defaultValue: TDefault) => TObject[TKey] | TDefault; + type LodashPropOr1x5 = (path: TKey | [TKey]) => Exclude | TDefault; + type LodashPropOr1x6 = (defaultValue: TDefault) => Exclude | TDefault; interface LodashPropOr2x2 { (defaultValue: TDefault): LodashPropOr2x3; (defaultValue: lodash.__, object: lodash.NumericDictionary | null | undefined): LodashPropOr2x6; diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 94cabd0f37..45fb97d010 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -10,7 +10,7 @@ // Jack Moore , // Dominique Rau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 /// /// diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 64d445c65a..befe845f94 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -5142,6 +5142,9 @@ fp.now(); // $ExpectType number // _.get { + const value: string | undefined = anything; + const defaultValue: boolean = anything; + _.get([], Symbol.iterator); _.get([], [Symbol.iterator]); @@ -5151,6 +5154,9 @@ fp.now(); // $ExpectType number _.get({ a: { b: true } }, "a"); // $ExpectType { b: boolean; } _.get({ a: { b: true } }, ["a"]); // $ExpectType { b: boolean; } _.get({ a: { b: true } }, ["a", "b"]); // $ExpectType any + _.get({ a: undefined }, "a"); // $ExpectType undefined + _.get({ a: value }, "a", defaultValue); // $ExpectType string | boolean + _.get({ a: undefined }, "a", defaultValue); // $ExpectType boolean _("abc").get(1); // $ExpectType string _("abc").get(["0"], "_"); @@ -5158,6 +5164,9 @@ fp.now(); // $ExpectType number _({ a: { b: true } }).get("a"); // $ExpectType { b: boolean; } _({ a: { b: true } }).get(["a"]); // $ExpectType { b: boolean; } _({ a: { b: true } }).get(["a", "b"]); // $ExpectType any + _({ a: undefined }).get("a"); // $ExpectType undefined + _({ a: value }).get("a", defaultValue); // $ExpectType string | boolean + _({ a: undefined }).get("a", defaultValue); // $ExpectType boolean _.chain("abc").get(1); // $ExpectType LoDashExplicitWrapper _.chain("abc").get(["0"], "_"); @@ -5165,6 +5174,9 @@ fp.now(); // $ExpectType number _.chain({ a: { b: true } }).get("a"); // $ExpectType LoDashExplicitWrapper<{ b: boolean; }> _.chain({ a: { b: true } }).get(["a"]); // $ExpectType LoDashExplicitWrapper<{ b: boolean; }> _.chain({ a: { b: true } }).get(["a", "b"]); // $ExpectType LoDashExplicitWrapper + _.chain({ a: undefined }).get("a"); // $ExpectType LoDashExplicitWrapper + _.chain({ a: value }).get("a", defaultValue); // $ExpectType LoDashExplicitWrapper + _.chain({ a: undefined }).get("a", defaultValue); // $ExpectType LoDashExplicitWrapper fp.get(Symbol.iterator, []); // $ExpectType any fp.get(Symbol.iterator)([]); // $ExpectType any diff --git a/types/lodash/scripts/generate-modules.ts b/types/lodash/scripts/generate-modules.ts index 28d5e585c3..6965242937 100644 --- a/types/lodash/scripts/generate-modules.ts +++ b/types/lodash/scripts/generate-modules.ts @@ -56,7 +56,7 @@ async function globalDefinitionText(moduleName: string): Promise { // Project: http://lodash.com/ // Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 // Generated from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/scripts/generate-modules.ts diff --git a/types/lowdb/_lodash.d.ts b/types/lowdb/_lodash.d.ts index 7267aab0d9..c24e2f1c08 100644 --- a/types/lowdb/_lodash.d.ts +++ b/types/lowdb/_lodash.d.ts @@ -1132,7 +1132,7 @@ declare module "./index" { this: LoDashExplicitSyncWrapper, path: TKey | [TKey], defaultValue: TDefault - ): LoDashExplicitSyncWrapper; + ): LoDashExplicitSyncWrapper | TDefault>; get( this: LoDashExplicitSyncWrapper<_.NumericDictionary>, path: number @@ -2728,7 +2728,7 @@ declare module "./index" { this: LoDashExplicitAsyncWrapper, path: TKey | [TKey], defaultValue: TDefault - ): LoDashExplicitAsyncWrapper; + ): LoDashExplicitAsyncWrapper | TDefault>; get( this: LoDashExplicitAsyncWrapper<_.NumericDictionary>, path: number diff --git a/types/lowdb/index.d.ts b/types/lowdb/index.d.ts index a8146ef8a2..3663b35823 100644 --- a/types/lowdb/index.d.ts +++ b/types/lowdb/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: typicode // Bazyli Brzóska // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.6 +// TypeScript Version: 2.8 /// diff --git a/types/mailparser/index.d.ts b/types/mailparser/index.d.ts index 181bb452a0..0b6e040af5 100644 --- a/types/mailparser/index.d.ts +++ b/types/mailparser/index.d.ts @@ -1,7 +1,7 @@ -// Type definitions for mailparser v2.0.0 -// Project: https://www.npmjs.com/package/mailparser +// Type definitions for mailparser 2.4 +// Project: https://github.com/nodemailer/mailparser // Definitions by: Peter Snider -// Andrey Volynkin +// Andrey Volynkin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -289,6 +289,13 @@ export class MailParser extends StreamModule.Transform { */ export type Source = Buffer | Stream | string; +/** + * Options object for simpleParser. + */ +export interface SimpleParserOptions extends StreamModule.TransformOptions { + keepCidLinks?: boolean; +} + /** * Parse email message to structure object. * @@ -301,5 +308,16 @@ export function simpleParser(source: Source, callback: (err: any, mail: ParsedMa * Parse email message to structure object. * * @param source A message source. + * @param options Transform options passed to MailParser's constructor + * @param callback Function to get a structured email object. */ -export function simpleParser(source: Source): Promise; +export function simpleParser(source: Source, options: SimpleParserOptions, callback: (err: any, mail: ParsedMail) => void): void; + + +/** + * Parse email message to structure object. + * + * @param source A message source. + * @param options Transform options passed to MailParser's constructor + */ +export function simpleParser(source: Source, options?: SimpleParserOptions): Promise; diff --git a/types/mailparser/mailparser-tests.ts b/types/mailparser/mailparser-tests.ts index 19c92814aa..cda949a213 100644 --- a/types/mailparser/mailparser-tests.ts +++ b/types/mailparser/mailparser-tests.ts @@ -36,10 +36,16 @@ var sourceStream = fs.createReadStream('foo.eml'); simpleParser(sourceString, (err, mail) => err ? err : mail.html); simpleParser(sourceBuffer, (err, mail) => err ? err : mail.html); simpleParser(sourceStream, (err, mail) => err ? err : mail.html); +simpleParser(sourceString, { keepCidLinks: true }, (err, mail) => err ? err : mail.html); +simpleParser(sourceBuffer, { keepCidLinks: true }, (err, mail) => err ? err : mail.html); +simpleParser(sourceStream, { keepCidLinks: true }, (err, mail) => err ? err : mail.html); simpleParser(sourceString).then(mail => mail.html).catch(err => err); simpleParser(sourceBuffer).then(mail => mail.html).catch(err => err); simpleParser(sourceStream).then(mail => mail.html).catch(err => err); +simpleParser(sourceString, { keepCidLinks: true }).then(mail => mail.html).catch(err => err); +simpleParser(sourceBuffer, { keepCidLinks: true }).then(mail => mail.html).catch(err => err); +simpleParser(sourceStream, { keepCidLinks: true }).then(mail => mail.html).catch(err => err); simpleParser(sourceString, (err, mail) => { console.log(mail.headers.get('subject')); diff --git a/types/mailparser/tslint.json b/types/mailparser/tslint.json index a41bf5d19a..4cfa77fc40 100644 --- a/types/mailparser/tslint.json +++ b/types/mailparser/tslint.json @@ -7,7 +7,7 @@ "ban-types": false, "callable-types": false, "comment-format": false, - "dt-header": false, + "dt-header": true, "eofline": false, "export-just-namespace": false, "import-spacing": false, diff --git a/types/mangopay2-nodejs-sdk/index.d.ts b/types/mangopay2-nodejs-sdk/index.d.ts index 516f1c44f9..78629b7232 100644 --- a/types/mangopay2-nodejs-sdk/index.d.ts +++ b/types/mangopay2-nodejs-sdk/index.d.ts @@ -1774,7 +1774,7 @@ declare namespace MangoPay { /** * This is the URL where to redirect users to proceed to 3D secure validation */ - SecureModeRedirectUrl: string; + SecureModeRedirectURL: string; /** * This is the URL where users are automatically redirected after 3D secure validation (if activated) @@ -2596,7 +2596,7 @@ declare namespace MangoPay { /** * This is the URL where to redirect users to proceed to 3D secure validation */ - SecureModeRedirectUrl: string; + SecureModeRedirectURL: string; } interface CreateCardDirectPayIn { diff --git a/types/marked/index.d.ts b/types/marked/index.d.ts index 78a45b052c..818620bb5e 100644 --- a/types/marked/index.d.ts +++ b/types/marked/index.d.ts @@ -4,6 +4,7 @@ // BendingBender // CrossR // Mike Wickett +// Hitomi Hatsukaze // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace marked; @@ -102,6 +103,17 @@ declare namespace marked { text(text: string): string; } + class TextRenderer { + strong(text: string): string; + em(text: string): string; + codespan(text: string): string; + del(text: string): string; + text(text: string): string; + link(href: string, title: string, text: string): string; + image(href: string, title: string, text: string): string; + br(): string; + } + class Lexer { rules: Rules; tokens: TokensList; diff --git a/types/marked/marked-tests.ts b/types/marked/marked-tests.ts index 0edc376e43..0abfb48efb 100644 --- a/types/marked/marked-tests.ts +++ b/types/marked/marked-tests.ts @@ -48,3 +48,6 @@ const slugger = new marked.Slugger(); renderer.heading = (text, level, raw, slugger) => { return text + level.toString() + slugger.slug(raw); }; + +const textRenderer = new marked.TextRenderer(); +console.log(textRenderer.strong(text)); diff --git a/types/massive/index.d.ts b/types/massive/index.d.ts index 72ef7c117b..4e6a7abc26 100644 --- a/types/massive/index.d.ts +++ b/types/massive/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for massive 5.4 -// Project: https://github.com/dmfay/massive-js.git, https://dmfay.github.io/massive-js +// Project: https://massivejs.org, https://github.com/dmfay/massive-js.git, https://dmfay.github.io/massive-js // Definitions by: Pascal Birchler // Clarence Ho // Felix Faust diff --git a/types/material-ui/material-ui-tests.tsx b/types/material-ui/material-ui-tests.tsx index 9cc7143d9b..ac32788c4b 100644 --- a/types/material-ui/material-ui-tests.tsx +++ b/types/material-ui/material-ui-tests.tsx @@ -4227,7 +4227,7 @@ function wrapState(ComposedComponent: ComponentClass<__MaterialUI.List.Selectabl }; } -const SelectableList = wrapState(makeSelectable(List)); +const SelectableList = wrapState(makeSelectable<{}>(List)); const ListExampleSelectable = () => ( diff --git a/types/mathjs/index.d.ts b/types/mathjs/index.d.ts index 20fb7154cb..285aed9e56 100644 --- a/types/mathjs/index.d.ts +++ b/types/mathjs/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for mathjs 5.0 -// Project: http://mathjs.org/ +// Project: https://mathjs.org/ // Definitions by: Ilya Shestakov , // Andy Patterson , // Brad Besserman diff --git a/types/meteor-universe-i18n/index.d.ts b/types/meteor-universe-i18n/index.d.ts index a577b0185e..1596ceef81 100644 --- a/types/meteor-universe-i18n/index.d.ts +++ b/types/meteor-universe-i18n/index.d.ts @@ -65,6 +65,7 @@ declare module "meteor/universe:i18n" { // events function onChangeLocale(callback: (locale: string) => void): void; + function offChangeLocale(callback: (locale: string) => void): void; } interface ReactComponentProps { diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index a3725382e4..79da3d5ead 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -1,5 +1,6 @@ -// Type definitions for MongoDB v3.1 -// Project: https://github.com/mongodb/node-mongodb-native/tree/3.0.0 +// Type definitions for MongoDB 3.1 +// Project: https://github.com/mongodb/node-mongodb-native +// https://github.com/mongodb/node-mongodb-native/tree/3.1 // Definitions by: Federico Caselli // Alan Marcell // Jason Dreyzehner @@ -20,17 +21,18 @@ // Hector Ribes // Florian Richter // Erik Christensen +// Nick Zahn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// Documentation : http://mongodb.github.io/node-mongodb-native/3.1/api/ +// Documentation: https://mongodb.github.io/node-mongodb-native/3.1/api/ /// -/// import { ObjectID, Timestamp } from 'bson'; import { EventEmitter } from 'events'; import { Readable, Writable } from "stream"; +import { checkServerIdentity } from "tls"; export function connect(uri: string, options?: MongoClientOptions): Promise; export function connect(uri: string, callback: MongoCallback): void; @@ -53,7 +55,7 @@ export class MongoClient extends EventEmitter { close(force?: boolean): Promise; close(force: boolean, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#db */ - db(dbName?: string, options?: MongoClientCommonOption): Db + db(dbName?: string, options?: MongoClientCommonOption): Db; /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#isConnected */ isConnected(options?: MongoClientCommonOption): boolean; /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#logout */ @@ -63,7 +65,7 @@ export class MongoClient extends EventEmitter { /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#startSession */ startSession(options?: SessionOptions): ClientSession; /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#watch */ - watch(pipeline?: Object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream; + watch(pipeline?: object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream; /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#withSession */ withSession(operation: (session: ClientSession) => Promise): Promise; /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#withSession */ @@ -78,37 +80,36 @@ export interface ClientSession extends EventEmitter { id: any; /** * Aborts the currently active transaction in this session. - * @param {MongoCallback} [cb] Optional callback for completion of this operation + * @param cb Optional callback for completion of this operation */ abortTransaction(cb?: MongoCallback): Promise; /** * Advances the operationTime for a ClientSession. - * @param {mongodb.Timestamp} operationTime */ advanceOperationTime(operamtionTime: Timestamp): void; /** * Commits the currently active transaction in this session. - * @param {MongoCallback} [cb] Optional callback for completion of this operation + * @param cb Optional callback for completion of this operation */ commitTransaction(cb?: MongoCallback): Promise; /** * Ends this session on the server - * @param {MongoCallback} [cb] Optional callback for completion of this operation + * @param cb Optional callback for completion of this operation */ endSession(cb?: MongoCallback): void; /** * Ends this session on the server - * @param {*} [options] Optional settings. Currently reserved for future use - * @param {MongoCallback} [cb] Optional callback for completion of this operation + * @param options Optional settings. Currently reserved for future use + * @param cb Optional callback for completion of this operation */ - endSession(options: any, cb?: MongoCallback): void + endSession(options: any, cb?: MongoCallback): void; /** * Used to determine if this session equals another * - * @param {ClientSession} session A class representing a client session on the server - * @returns {boolean} if the sessions are equal + * @param session A class representing a client session on the server + * @returns Whether the sessions are equal */ equals(session: ClientSession): boolean; @@ -116,14 +117,12 @@ export interface ClientSession extends EventEmitter { incrementTransactionNumber(): void; /** - * @returns {boolean} this session is currently in a transaction or not + * @returns Whether this session is currently in a transaction or not */ inTransaction(): boolean; /** * Starts a new transaction with the given options. - * @param {TransactionOptions} options - * @memberof ClientSession */ startTransaction(options?: TransactionOptions): void; @@ -150,19 +149,17 @@ interface WriteConcern { /** * requests acknowledgement that the write operation has * propagated to a specified number of mongod hosts - * @type {(number | 'majority' | string)} default 1 + * @default 1 */ w?: number | 'majority' | string; /** * requests acknowledgement from MongoDB that the write operation has * been written to the journal - * @type {boolean} default false + * @default false */ j?: boolean; /** * a time limit, in milliseconds, for the write concern - * @type {number} - * @memberof WriteConcern */ wtimeout?: number; } @@ -174,7 +171,7 @@ interface WriteConcern { export interface SessionOptions { /** * Whether causal consistency should be enabled on this session - * @type {boolean} default true + * @default true */ causalConsistency?: boolean; /** @@ -207,7 +204,7 @@ export interface MongoCallback { /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoError.html */ export class MongoError extends Error { constructor(message: string); - static create(options: Object): MongoError; + static create(options: object): MongoError; code?: number; /** * While not documented, the 'errmsg' prop is AFAIK the only way to find out @@ -248,13 +245,13 @@ export interface MongoClientOptions extends /** * Custom logger object */ - logger?: Object | log; + logger?: object | log; /** * Validate MongoClient passed in options for correctness. * Default: false */ - validateOptions?: Object; + validateOptions?: object; /** * The name of the application that created this MongoClient instance. @@ -314,7 +311,7 @@ export interface SSLOptions { /** * Default: true; Server identity checking during SSL */ - checkServerIdentity?: boolean | Function; + checkServerIdentity?: boolean | typeof checkServerIdentity; /** * Array of valid certificates either as Buffers or Strings */ @@ -358,7 +355,7 @@ export interface HighAvailabilityOptions { // See http://mongodb.github.io/node-mongodb-native/3.1/api/ReadPreference.html export class ReadPreference { - constructor(mode: string, tags: Object); + constructor(mode: string, tags: object); mode: string; tags: any; options: { @@ -417,18 +414,18 @@ export interface DbCreateOptions extends CommonOptions { /** * Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types. */ - promoteValues?: Object; + promoteValues?: boolean; /** * Custom primary key factory to generate _id values (see Custom primary keys). */ - pkFactory?: Object; + pkFactory?: object; /** * ES6 compatible promise constructor */ - promiseLibrary?: Object; + promiseLibrary?: object; /** * https://docs.mongodb.com/manual/reference/read-concern/#read-concern - **/ + */ readConcern?: ReadConcern; /** * Sets a cap on how many operations the driver will buffer up before giving up on getting a @@ -485,7 +482,7 @@ export interface ServerOptions extends SSLOptions { /** * Default: true; */ - monitoring?: boolean + monitoring?: boolean; /** * Socket Options @@ -558,20 +555,20 @@ export class Db extends EventEmitter { collection(name: string, callback: MongoCallback>): Collection; collection(name: string, options: DbCollectionOptions, callback: MongoCallback>): Collection; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#collections */ - collections(): Promise[]>; - collections(callback: MongoCallback[]>): void; + collections(): Promise>>; + collections(callback: MongoCallback>>): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#command */ - command(command: Object, callback: MongoCallback): void; - command(command: Object, options?: { readPreference: ReadPreference | string }): Promise; - command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void; + command(command: object, callback: MongoCallback): void; + command(command: object, options?: { readPreference: ReadPreference | string, session?: ClientSession }): Promise; + command(command: object, options: { readPreference: ReadPreference | string, session?: ClientSession }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createCollection */ createCollection(name: string, callback: MongoCallback>): void; createCollection(name: string, options?: CollectionCreateOptions): Promise>; createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback>): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createIndex */ - createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void; - createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise; - createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void; + createIndex(name: string, fieldOrSpec: string | object, callback: MongoCallback): void; + createIndex(name: string, fieldOrSpec: string | object, options?: IndexOptions): Promise; + createIndex(name: string, fieldOrSpec: string | object, options: IndexOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#dropCollection */ dropCollection(name: string): Promise; dropCollection(name: string, callback: MongoCallback): void; @@ -579,15 +576,15 @@ export class Db extends EventEmitter { dropDatabase(): Promise; dropDatabase(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#executeDbAdminCommand */ - executeDbAdminCommand(command: Object, callback: MongoCallback): void; - executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; - executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; + executeDbAdminCommand(command: object, callback: MongoCallback): void; + executeDbAdminCommand(command: object, options?: { readPreference?: ReadPreference | string, session?: ClientSession }): Promise; + executeDbAdminCommand(command: object, options: { readPreference?: ReadPreference | string, session?: ClientSession }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#indexInformation */ indexInformation(name: string, callback: MongoCallback): void; indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise; indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#listCollections */ - listCollections(filter?: Object, options?: { nameOnly?: boolean, batchSize?: number, readPreference?: ReadPreference | string, session?: ClientSession }): CommandCursor; + listCollections(filter?: object, options?: { nameOnly?: boolean, batchSize?: number, readPreference?: ReadPreference | string, session?: ClientSession }): CommandCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#profilingInfo */ /** @deprecated Query the system.profile collection directly. */ profilingInfo(callback: MongoCallback): void; @@ -626,7 +623,7 @@ export interface CommonOptions extends WriteConcern { export class Server extends EventEmitter { constructor(host: string, port: number, options?: ServerOptions); - connections(): Array; + connections(): any[]; } /** @@ -634,9 +631,9 @@ export class Server extends EventEmitter { * @see http://mongodb.github.io/node-mongodb-native/3.1/api/ReplSet.html */ export class ReplSet extends EventEmitter { - constructor(servers: Array, options?: ReplSetOptions); + constructor(servers: Server[], options?: ReplSetOptions); - connections(): Array; + connections(): any[]; } /** @@ -644,9 +641,9 @@ export class ReplSet extends EventEmitter { * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Mongos.html */ export class Mongos extends EventEmitter { - constructor(servers: Array, options?: MongosOptions); + constructor(servers: Server[], options?: MongosOptions); - connections(): Array; + connections(): any[]; } /** @@ -654,14 +651,14 @@ export class Mongos extends EventEmitter { * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#addUser */ export interface DbAddUserOptions extends CommonOptions { - customData?: Object; - roles?: Object[]; + customData?: object; + roles?: object[]; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createCollection */ export interface CollectionCreateOptions extends CommonOptions { raw?: boolean; - pkFactory?: Object; + pkFactory?: object; readPreference?: ReadPreference | string; serializeFunctions?: boolean; strict?: boolean; @@ -683,7 +680,7 @@ export interface CollectionCreateOptions extends CommonOptions { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#collection */ export interface DbCollectionOptions extends CommonOptions { raw?: boolean; - pkFactory?: Object; + pkFactory?: object; readPreference?: ReadPreference | string; serializeFunctions?: boolean; strict?: boolean; @@ -736,7 +733,7 @@ export interface IndexOptions extends CommonOptions { */ partialFilterExpression?: any; collation?: CollationDocument; - default_language?: string + default_language?: string; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html */ @@ -749,9 +746,9 @@ export interface Admin { buildInfo(): Promise; buildInfo(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#command */ - command(command: Object, callback: MongoCallback): void; - command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; - command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; + command(command: object, callback: MongoCallback): void; + command(command: object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; + command(command: object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#listDatabases */ listDatabases(): Promise; listDatabases(callback: MongoCallback): void; @@ -773,20 +770,20 @@ export interface Admin { serverStatus(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#validateCollection */ validateCollection(collectionNme: string, callback: MongoCallback): void; - validateCollection(collectionNme: string, options?: Object): Promise; - validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void; + validateCollection(collectionNme: string, options?: object): Promise; + validateCollection(collectionNme: string, options: object, callback: MongoCallback): void; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#addUser */ export interface AddUserOptions extends CommonOptions { fsync: boolean; - customData?: Object; - roles?: Object[] + customData?: object; + roles?: object[]; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Admin.html#removeUser */ export interface FSyncOptions extends CommonOptions { - fsync?: boolean + fsync?: boolean; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html */ @@ -813,12 +810,12 @@ export interface Collection { hint: any; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate */ aggregate(callback: MongoCallback>): AggregationCursor; - aggregate(pipeline: Object[], callback: MongoCallback>): AggregationCursor; - aggregate(pipeline?: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback>): AggregationCursor; + aggregate(pipeline: object[], callback: MongoCallback>): AggregationCursor; + aggregate(pipeline?: object[], options?: CollectionAggregationOptions, callback?: MongoCallback>): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#bulkWrite */ - bulkWrite(operations: Object[], callback: MongoCallback): void; - bulkWrite(operations: Object[], options?: CollectionBulkWriteOptions): Promise; - bulkWrite(operations: Object[], options: CollectionBulkWriteOptions, callback: MongoCallback): void; + bulkWrite(operations: object[], callback: MongoCallback): void; + bulkWrite(operations: object[], options?: CollectionBulkWriteOptions): Promise; + bulkWrite(operations: object[], options: CollectionBulkWriteOptions, callback: MongoCallback): void; /** * http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#count * @deprecated Use countDocuments or estimatedDocumentCount @@ -879,12 +876,21 @@ export interface Collection { findOne(filter: FilterQuery, options: FindOneOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndDelete */ findOneAndDelete(filter: FilterQuery, callback: MongoCallback>): void; - findOneAndDelete(filter: FilterQuery, options?: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }): Promise>; - findOneAndDelete(filter: FilterQuery, options: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback>): void; + findOneAndDelete(filter: FilterQuery, options?: { projection?: object, sort?: object, maxTimeMS?: number, session?: ClientSession }): Promise>; + findOneAndDelete( + filter: FilterQuery, + options: { + projection?: object, + sort?: object, + maxTimeMS?: number, + session?: ClientSession + }, + callback: MongoCallback> + ): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndReplace */ - findOneAndReplace(filter: FilterQuery, replacement: Object, callback: MongoCallback>): void; - findOneAndReplace(filter: FilterQuery, replacement: Object, options?: FindOneAndReplaceOption): Promise>; - findOneAndReplace(filter: FilterQuery, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + findOneAndReplace(filter: FilterQuery, replacement: object, callback: MongoCallback>): void; + findOneAndReplace(filter: FilterQuery, replacement: object, options?: FindOneAndReplaceOption): Promise>; + findOneAndReplace(filter: FilterQuery, replacement: object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndUpdate */ findOneAndUpdate(filter: FilterQuery, update: UpdateQuery | TSchema, callback: MongoCallback>): void; findOneAndUpdate(filter: FilterQuery, update: UpdateQuery | TSchema, options?: FindOneAndUpdateOption): Promise>; @@ -893,14 +899,33 @@ export interface Collection { geoHaystackSearch(x: number, y: number, callback: MongoCallback): void; geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise; geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void; - /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#geoNear */ - geoNear(x: number, y: number, callback: MongoCallback): void; - geoNear(x: number, y: number, options?: GeoNearOptions): Promise; - geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#group */ - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void; - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string }): Promise; - group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; + /** @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. */ + group(keys: object | any[] | Function | Code, condition: object, initial: object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void; + /** @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. */ + group( + keys: object | any[] | Function | Code, + condition: object, + initial: object, + reduce: Function | Code, + finalize: Function | Code, + command: boolean, + options?: { readPreference?: ReadPreference | string, session?: ClientSession } + ): Promise; + /** @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. */ + group( + keys: object | any[] | Function | Code, + condition: object, + initial: object, + reduce: Function | Code, + finalize: Function | Code, + command: boolean, + options: { + readPreference?: ReadPreference | string, + session?: ClientSession + }, + callback: MongoCallback + ): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#indexes */ indexes(options?: { session: ClientSession }): Promise; indexes(callback: MongoCallback): void; @@ -939,28 +964,28 @@ export interface Collection { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#listIndexes */ listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string, session?: ClientSession }): CommandCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#mapReduce */ - mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void; - mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise; - mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void; + mapReduce(map: CollectionMapFunction | string, reduce: CollectionReduceFunction | string, callback: MongoCallback): void; + mapReduce(map: CollectionMapFunction | string, reduce: CollectionReduceFunction | string, options?: MapReduceOptions): Promise; + mapReduce(map: CollectionMapFunction | string, reduce: CollectionReduceFunction | string, options: MapReduceOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#options */ options(options?: { session: ClientSession }): Promise; options(callback: MongoCallback): void; options(options: { session: ClientSession }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#parallelCollectionScan */ - parallelCollectionScan(callback: MongoCallback[]>): void; - parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise[]>; - parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback[]>): void; + parallelCollectionScan(callback: MongoCallback>>): void; + parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise>>; + parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback>>): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#reIndex */ reIndex(options?: { session: ClientSession }): Promise; reIndex(callback: MongoCallback): void; reIndex(options: { session: ClientSession }, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#remove */ /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, callback: MongoCallback): void; + remove(selector: object, callback: MongoCallback): void; /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, options?: CommonOptions & { single?: boolean }): Promise; + remove(selector: object, options?: CommonOptions & { single?: boolean }): Promise; /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, options?: CommonOptions & { single?: boolean }, callback?: MongoCallback): void; + remove(selector: object, options?: CommonOptions & { single?: boolean }, callback?: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#rename */ rename(newName: string, callback: MongoCallback>): void; rename(newName: string, options?: { dropTarget?: boolean, session?: ClientSession }): Promise>; @@ -996,21 +1021,21 @@ export interface Collection { updateOne(filter: FilterQuery, update: UpdateQuery | TSchema, options?: UpdateOneOptions): Promise; updateOne(filter: FilterQuery, update: UpdateQuery | TSchema, options: UpdateOneOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#watch */ - watch(pipeline?: Object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream; + watch(pipeline?: object[], options?: ChangeStreamOptions & { startAtClusterTime?: Timestamp, session?: ClientSession }): ChangeStream; } export type Condition = { $eq?: T[P]; $gt?: T[P]; $gte?: T[P]; - $in?: T[P][]; + $in?: Array; $lt?: T[P]; $lte?: T[P]; $ne?: T[P]; - $nin?: T[P][]; - $and?: (FilterQuery | T[P])[]; - $or?: (FilterQuery | T[P])[]; - $not?: (FilterQuery | T[P])[] | T[P]; + $nin?: Array; + $and?: Array | T[P]>; + $or?: Array | T[P]>; + $not?: Array | T[P]> | T[P]; $expr?: any; $jsonSchema?: any; $mod?: [number, number]; @@ -1022,17 +1047,17 @@ export type Condition = { $caseSensitive?: boolean; $diacraticSensitive?: boolean; }; - $where?: Object; - $geoIntersects?: Object; - $geoWithin?: Object; - $near?: Object; - $nearSphere?: Object; - $elemMatch?: Object; + $where?: object; + $geoIntersects?: object; + $geoWithin?: object; + $near?: object; + $nearSphere?: object; + $elemMatch?: object; $size?: number; - $bitsAllClear?: Object; - $bitsAllSet?: Object; - $bitsAnyClear?: Object; - $bitsAnySet?: Object; + $bitsAllClear?: object; + $bitsAllSet?: object; + $bitsAnyClear?: object; + $bitsAnySet?: object; [key: string]: any; }; @@ -1047,12 +1072,12 @@ export type UpdateQuery = { $unset?: { [P in keyof T]?: '' } | { [key: string]: '' }; $rename?: { [key: string]: keyof T } | { [key: string]: string }; $currentDate?: { [P in keyof T]?: (true | { $type: 'date' | 'timestamp' }) } | { [key: string]: (true | { $type: 'date' | 'timestamp' }) }; - $addToSet?: Partial | { [key: string]: any }; + $addToSet?: { [P in keyof T]?: any } | { [key: string]: any }; $pop?: { [P in keyof T]?: -1 | 1 } | { [key: string]: -1 | 1 }; - $pull?: Partial | { [key: string]: Condition }; + $pull?: { [P in keyof T]?: any } | { [key: string]: any }; $push?: Partial | { [key: string]: any }; - $pushAll?: Partial | { [key: string]: Array }; - $each?: Partial | { [key: string]: Array }; + $pushAll?: Partial | { [key: string]: any[] }; + $each?: Partial | { [key: string]: any[] }; $bit?: { [P in keyof T]?: any } | { [key: string]: any }; }; @@ -1298,7 +1323,7 @@ export interface CollectionAggregationOptions { promoteValues?: boolean; promoteBuffers?: boolean; collation?: CollationDocument; - comment?: string + comment?: string; session?: ClientSession; } @@ -1383,7 +1408,7 @@ export interface DeleteWriteOpResultObject { ok?: number; //The total count of documents deleted. n?: number; - } + }; //The connection object used for the operation. connection?: any; //The number of documents deleted. @@ -1402,8 +1427,8 @@ export interface FindAndModifyWriteOpResultObject { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndReplace */ export interface FindOneAndReplaceOption extends CommonOptions { - projection?: Object; - sort?: Object; + projection?: object; + sort?: object; maxTimeMS?: number; upsert?: boolean; returnOriginal?: boolean; @@ -1411,34 +1436,21 @@ export interface FindOneAndReplaceOption extends CommonOptions { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOneAndUpdate */ export interface FindOneAndUpdateOption extends FindOneAndReplaceOption { - arrayFilters?: Object[]; + arrayFilters?: object[]; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#geoHaystackSearch */ export interface GeoHaystackSearchOptions { readPreference?: ReadPreference | string; maxDistance?: number; - search?: Object; + search?: object; limit?: number; session?: ClientSession; } -/** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#geoNear */ -export interface GeoNearOptions { - readPreference?: ReadPreference | string; - num?: number; - minDistance?: number; - maxDistance?: number; - distanceMultiplier?: number; - query?: Object; - spherical?: boolean; - uniqueDocs?: boolean; - includeLocs?: boolean; -} - /** http://mongodb.github.io/node-mongodb-native/3.1/api/Code.html */ export class Code { - constructor(code: string | Function, scope?: Object) + constructor(code: string | Function, scope?: object) code: string | Function; scope: any; } @@ -1451,9 +1463,9 @@ export interface OrderedBulkOperation { execute(options?: FSyncOptions): Promise; execute(options: FSyncOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/OrderedBulkOperation.html#find */ - find(selector: Object): FindOperatorsOrdered; + find(selector: object): FindOperatorsOrdered; /** http://mongodb.github.io/node-mongodb-native/3.1/api/OrderedBulkOperation.html#insert */ - insert(doc: Object): OrderedBulkOperation; + insert(doc: object): OrderedBulkOperation; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/BulkWriteResult.html */ @@ -1465,15 +1477,15 @@ export interface BulkWriteResult { nModified: number; nRemoved: number; - getInsertedIds(): Array; - getLastOp(): Object; - getRawResponse(): Object; - getUpsertedIdAt(index: number): Object; - getUpsertedIds(): Array; + getInsertedIds(): object[]; + getLastOp(): object; + getRawResponse(): object; + getUpsertedIdAt(index: number): object; + getUpsertedIds(): object[]; getWriteConcernError(): WriteConcernError; getWriteErrorAt(index: number): WriteError; getWriteErrorCount(): number; - getWriteErrors(): Array; + getWriteErrors(): object[]; hasWriteErrors(): boolean; } @@ -1499,9 +1511,9 @@ export interface WriteConcernError { export interface FindOperatorsOrdered { delete(): OrderedBulkOperation; deleteOne(): OrderedBulkOperation; - replaceOne(doc: Object): OrderedBulkOperation; - update(doc: Object): OrderedBulkOperation; - updateOne(doc: Object): OrderedBulkOperation; + replaceOne(doc: object): OrderedBulkOperation; + update(doc: object): OrderedBulkOperation; + updateOne(doc: object): OrderedBulkOperation; upsert(): FindOperatorsOrdered; } @@ -1514,9 +1526,9 @@ export interface UnorderedBulkOperation { execute(options?: FSyncOptions): Promise; execute(options: FSyncOptions, callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/UnorderedBulkOperation.html#find */ - find(selector: Object): FindOperatorsUnordered; + find(selector: object): FindOperatorsUnordered; /** http://mongodb.github.io/node-mongodb-native/3.1/api/UnorderedBulkOperation.html#insert */ - insert(doc: Object): UnorderedBulkOperation; + insert(doc: object): UnorderedBulkOperation; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/FindOperatorsUnordered.html */ @@ -1524,23 +1536,23 @@ export interface FindOperatorsUnordered { length: number; remove(): UnorderedBulkOperation; removeOne(): UnorderedBulkOperation; - replaceOne(doc: Object): UnorderedBulkOperation; - update(doc: Object): UnorderedBulkOperation; - updateOne(doc: Object): UnorderedBulkOperation; + replaceOne(doc: object): UnorderedBulkOperation; + update(doc: object): UnorderedBulkOperation; + updateOne(doc: object): UnorderedBulkOperation; upsert(): FindOperatorsUnordered; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#findOne */ export interface FindOneOptions { limit?: number; - sort?: Array | Object; - projection?: Object; + sort?: any[] | object; + projection?: object; /** * @deprecated Use options.projection instead */ - fields?: Object; + fields?: object; skip?: number; - hint?: Object; + hint?: object; explain?: boolean; snapshot?: boolean; timeout?: boolean; @@ -1566,10 +1578,10 @@ export interface FindOneOptions { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~insertWriteOpResult */ export interface InsertWriteOpResult { insertedCount: number; - ops: Array; + ops: any[]; insertedIds: { [key: number]: ObjectID }; connection: any; - result: { ok: number, n: number } + result: { ok: number, n: number }; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#insertOne */ @@ -1581,16 +1593,16 @@ export interface CollectionInsertOneOptions extends CommonOptions { //Force server to assign _id values instead of driver. forceServerObjectId?: boolean; //Allow driver to bypass schema validation in MongoDB 3.2 or higher. - bypassDocumentValidation?: boolean + bypassDocumentValidation?: boolean; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~insertOneWriteOpResult */ export interface InsertOneWriteOpResult { insertedCount: number; - ops: Array; + ops: any[]; insertedId: ObjectID; connection: any; - result: { ok: number, n: number } + result: { ok: number, n: number }; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#parallelCollectionScan */ @@ -1610,13 +1622,13 @@ export interface ReplaceOneOptions extends CommonOptions { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#updateOne */ export interface UpdateOneOptions extends ReplaceOneOptions { - arrayFilters?: Object[]; + arrayFilters?: object[]; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#updateMany */ export interface UpdateManyOptions extends CommonOptions { upsert?: boolean; - arrayFilters?: Object[]; + arrayFilters?: object[]; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~updateWriteOpResult */ @@ -1631,34 +1643,38 @@ export interface UpdateWriteOpResult { /** https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/collection.js#L957 */ export interface ReplaceWriteOpResult extends UpdateWriteOpResult { - ops: Array + ops: any[]; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#mapReduce */ export interface MapReduceOptions { readPreference?: ReadPreference | string; - out?: Object; - query?: Object; - sort?: Object; + out?: object; + query?: object; + sort?: object; limit?: number; keeptemp?: boolean; finalize?: Function | string; - scope?: Object; + scope?: object; jsMode?: boolean; verbose?: boolean; bypassDocumentValidation?: boolean; session?: ClientSession; } +export type CollectionMapFunction = () => void; + +export type CollectionReduceFunction = (key: string, values: any) => any; + /** http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~WriteOpResult */ export interface WriteOpResult { - ops: Array; + ops: any[]; connection: any; result: any; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#~resultCallback */ -export type CursorResult = any | void | boolean; +export type CursorResult = object | null | boolean; type Default = any; @@ -1693,7 +1709,7 @@ export class Cursor extends Readable { explain(): Promise; explain(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#filter */ - filter(filter: Object): Cursor; + filter(filter: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#forEach */ forEach(iterator: IteratorCallback, callback: EndCallback): void; forEach(iterator: IteratorCallback): Promise; @@ -1701,7 +1717,7 @@ export class Cursor extends Readable { hasNext(): Promise; hasNext(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#hint */ - hint(hint: Object): Cursor; + hint(hint: string | object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#isClosed */ isClosed(): boolean; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#limit */ @@ -1713,7 +1729,7 @@ export class Cursor extends Readable { /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#maxAwaitTimeMS */ maxAwaitTimeMS(value: number): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#maxScan */ - maxScan(maxScan: Object): Cursor; + maxScan(maxScan: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#maxTimeMS */ maxTimeMS(value: number): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#min */ @@ -1722,27 +1738,27 @@ export class Cursor extends Readable { next(): Promise; next(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#project */ - project(value: Object): Cursor; + project(value: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#read */ read(size: number): string | Buffer | void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#next */ - returnKey(returnKey: Object): Cursor; + returnKey(returnKey: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#rewind */ rewind(): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#setCursorOption */ - setCursorOption(field: string, value: Object): Cursor; + setCursorOption(field: string, value: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#setReadPreference */ setReadPreference(readPreference: string | ReadPreference): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#showRecordId */ - showRecordId(showRecordId: Object): Cursor; + showRecordId(showRecordId: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#skip */ skip(value: number): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#snapshot */ - snapshot(snapshot: Object): Cursor; + snapshot(snapshot: object): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#sort */ - sort(keyOrList: string | Object[] | Object, direction?: number): Cursor; + sort(keyOrList: string | object[] | object, direction?: number): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#stream */ - stream(options?: { transform?: Function }): Cursor; + stream(options?: { transform?: (document: T) => any }): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#toArray */ toArray(): Promise; toArray(callback: MongoCallback): void; @@ -1770,7 +1786,7 @@ export interface EndCallback { } /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#~resultCallback */ -export type AggregationCursorResult = any | void; +export type AggregationCursorResult = object | null; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html */ export class AggregationCursor extends Readable { /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#batchSize */ @@ -1786,9 +1802,9 @@ export class AggregationCursor extends Readable { explain(): Promise; explain(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#geoNear */ - geoNear(document: Object): AggregationCursor; + geoNear(document: object): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#group */ - group(document: Object): AggregationCursor; + group(document: object): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#hasNext */ hasNext(): Promise; hasNext(callback: MongoCallback): void; @@ -1797,7 +1813,7 @@ export class AggregationCursor extends Readable { /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#limit */ limit(value: number): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#match */ - match(document: Object): AggregationCursor; + match(document: object): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#maxTimeMS */ maxTimeMS(value: number): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#next */ @@ -1806,17 +1822,17 @@ export class AggregationCursor extends Readable { /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#out */ out(destination: string): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#project */ - project(document: Object): AggregationCursor; + project(document: object): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#read */ read(size: number): string | Buffer | void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#redact */ - redact(document: Object): AggregationCursor; + redact(document: object): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#rewind */ rewind(): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#setEncoding */ skip(value: number): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#sort */ - sort(document: Object): AggregationCursor; + sort(document: object): AggregationCursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#toArray */ toArray(): Promise; toArray(callback: MongoCallback): void; @@ -1827,7 +1843,7 @@ export class AggregationCursor extends Readable { } /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#~resultCallback */ -export type CommandCursorResult = any | void; +export type CommandCursorResult = object | null; /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html */ export class CommandCursor extends Readable { /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#hasNext */ @@ -1871,7 +1887,7 @@ export class GridFSBucket { /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#drop */ drop(callback?: GridFSBucketErrorCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#find */ - find(filter?: Object, options?: GridFSBucketFindOptions): Cursor; + find(filter?: object, options?: GridFSBucketFindOptions): Cursor; /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openDownloadStream */ openDownloadStream(id: ObjectID, options?: { start: number, end: number }): GridFSBucketReadStream; /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openDownloadStreamByName */ @@ -1888,8 +1904,8 @@ export class GridFSBucket { export interface GridFSBucketOptions { bucketName?: string; chunkSizeBytes?: number; - writeConcern?: Object; - ReadPreference?: Object; + writeConcern?: object; + ReadPreference?: object; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#~errorCallback */ @@ -1904,29 +1920,29 @@ export interface GridFSBucketFindOptions { maxTimeMS?: number; noCursorTimeout?: boolean; skip?: number; - sort?: Object; + sort?: object; } /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openUploadStream */ export interface GridFSBucketOpenUploadStreamOptions { - chunkSizeBytes?: number, - metadata?: Object, - contentType?: string, - aliases?: Array + chunkSizeBytes?: number; + metadata?: object; + contentType?: string; + aliases?: string[]; } /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketReadStream.html */ export class GridFSBucketReadStream extends Readable { id: ObjectID; - constructor(chunks: Collection, files: Collection, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions); + constructor(chunks: Collection, files: Collection, readPreference: object, filter: object, options?: GridFSBucketReadStreamOptions); } /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketReadStream.html */ export interface GridFSBucketReadStreamOptions { - sort?: number, - skip?: number, - start?: number, - end?: number + sort?: number; + skip?: number; + start?: number; + end?: number; } /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketWriteStream.html */ @@ -1939,33 +1955,33 @@ export class GridFSBucketWriteStream extends Writable { export interface GridFSBucketWriteStreamOptions { /** * Custom file id for the GridFS file. - **/ - id?: GridFSBucketWriteStreamId, + */ + id?: GridFSBucketWriteStreamId; /** * The chunk size to use, in bytes */ - chunkSizeBytes?: number, + chunkSizeBytes?: number; /** * The write concern */ - w?: number, + w?: number; /** * The write concern timeout */ - wtimeout?: number, + wtimeout?: number; /** * The journal write concern */ - j?: number + j?: number; /** * Default false; If true, disables adding an md5 field to file data */ - disableMD5?: boolean + disableMD5?: boolean; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html */ export class ChangeStream extends Readable { - constructor(changeDomain: Db | Collection, pipeline: Object[], options?: ChangeStreamOptions); + constructor(changeDomain: Db | Collection, pipeline: object[], options?: ChangeStreamOptions); /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#close */ close(): Promise; @@ -1983,94 +1999,94 @@ export class ChangeStream extends Readable { next(callback: MongoCallback): void; /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#stream */ - stream(options?: { transform: Function }): Cursor; + stream(options?: { transform?: Function }): Cursor; } export interface ChangeStreamOptions { fullDocument?: string; maxAwaitTimeMS?: number; - resumeAfter?: Object; + resumeAfter?: object; batchSize?: number; collation?: CollationDocument; readPreference?: ReadPreference; } -type GridFSBucketWriteStreamId = string | number | Object | ObjectID; +type GridFSBucketWriteStreamId = string | number | object | ObjectID; export interface LoggerOptions { /** * Custom logger function */ - loggerLevel?: string + loggerLevel?: string; /** * Override default global log level. */ - logger?: log + logger?: log; } -export type log = (message?: string, state?: LoggerState) => void +export type log = (message?: string, state?: LoggerState) => void; export interface LoggerState { - type: string - message: string - className: string - pid: number - date: number + type: string; + message: string; + className: string; + pid: number; + date: number; } /** http://mongodb.github.io/node-mongodb-native/3.1/api/Logger.html */ export class Logger { - constructor(className: string, options?: LoggerOptions) + constructor(className: string, options?: LoggerOptions); /** * Log a message at the debug level */ - debug(message: string, state: LoggerState): void + debug(message: string, state: LoggerState): void; /** * Log a message at the warn level */ - warn(message: string, state: LoggerState): void + warn(message: string, state: LoggerState): void; /** * Log a message at the info level */ - info(message: string, state: LoggerState): void + info(message: string, state: LoggerState): void; /** * Log a message at the error level */ - error(message: string, state: LoggerState): void + error(message: string, state: LoggerState): void; /** * Is the logger set at info level */ - isInfo(): boolean + isInfo(): boolean; /** * Is the logger set at error level */ - isError(): boolean + isError(): boolean; /** * Is the logger set at error level */ - isWarn(): boolean + isWarn(): boolean; /** * Is the logger set at debug level */ - isDebug(): boolean + isDebug(): boolean; /** * Resets the logger to default settings, error and no filtered classes */ - static reset(): void + static reset(): void; /** * Get the current logger function */ - static currentLogger(): log + static currentLogger(): log; //Set the current logger function - static setCurrentLogger(log: log): void + static setCurrentLogger(log: log): void; /** * Set what classes to log. */ - static filter(type: string, values: string[]): void + static filter(type: string, values: string[]): void; /** * Set the current log level */ - static setLevel(level: string): void + static setLevel(level: string): void; } /** https://docs.mongodb.com/manual/reference/collation/#collation-document-fields */ diff --git a/types/mongodb/mongodb-tests.ts b/types/mongodb/mongodb-tests.ts index ea755a8eb1..d8eb287964 100644 --- a/types/mongodb/mongodb-tests.ts +++ b/types/mongodb/mongodb-tests.ts @@ -1,19 +1,19 @@ // Test source : https://github.com/mongodb/node-mongodb-native -import mongodb = require('mongodb'); -var MongoClient = mongodb.MongoClient; + +import { format } from 'util'; +import * as mongodb from 'mongodb'; const connectionString = 'mongodb://127.0.0.1:27017/test'; -var format = require('util').format; -let options: mongodb.MongoClientOptions = { +const options: mongodb.MongoClientOptions = { authSource: ' ', loggerLevel: 'debug', w: 1, wtimeout: 300, j: true, bufferMaxEntries: 1000, - readPreference: 'ReadPreference | string', - promoteValues: {}, + readPreference: true ? mongodb.ReadPreference.NEAREST : 'string', + promoteValues: true, pkFactory: {}, poolSize: 1, @@ -24,7 +24,7 @@ let options: mongodb.MongoClientOptions = { reconnectInterval: 123456, ssl: true, sslValidate: false, - checkServerIdentity: function () { }, + checkServerIdentity: true ? true : (host, cert) => { return undefined; }, sslCA: ['str'], sslCRL: ['str'], sslCert: new Buffer(999), @@ -34,58 +34,63 @@ let options: mongodb.MongoClientOptions = { useNewUrlParser: false, authMechanism: 'SCRAM-SHA-1', forceServerObjectId: false -} -MongoClient.connect(connectionString, options, function (err: mongodb.MongoError, client: mongodb.MongoClient) { +}; + +mongodb.MongoClient.connect(connectionString, options, (err: mongodb.MongoError, client: mongodb.MongoClient) => { if (err) throw err; const db = client.db('test'); - var collection = db.collection('test_insert'); - collection.insertOne({ a: 2 }, function (err: mongodb.MongoError, docs: any) { + const collection = db.collection('test_insert'); + collection.insertOne({ a: 2 }, (err: mongodb.MongoError, result) => { + result.insertedCount; // $ExpectType number + result.insertedId; // $ExpectType ObjectId + result.result.n; // $ExpectType number + result.result.ok; // $ExpectType number // Intentionally omitted type annotation from 'count'. // This way it requires a more accurate typedef which allows inferring that it's a number. - collection.countDocuments(function (err: mongodb.MongoError, count) { + collection.countDocuments((err: mongodb.MongoError, count) => { console.log(format("count = %s", count)); }); - collection.countDocuments().then(function (count: number) { + collection.countDocuments().then((count: number) => { console.log(format("count = %s", count)); }); - collection.countDocuments({ foo: 1 }, function (err: mongodb.MongoError, count: number) { + collection.countDocuments({ foo: 1 }, (err: mongodb.MongoError, count: number) => { console.log(format("count = %s", count)); }); - collection.countDocuments({ foo: 1 }).then(function (count: number) { + collection.countDocuments({ foo: 1 }).then((count: number) => { console.log(format("count = %s", count)); }); - collection.countDocuments({ foo: 1 }, { limit: 10 }, function (err: mongodb.MongoError, count: number) { + collection.countDocuments({ foo: 1 }, { limit: 10 }, (err: mongodb.MongoError, count: number) => { console.log(format("count = %s", count)); }); - collection.countDocuments({ foo: 1 }, { limit: 10 }).then(function (count: number) { + collection.countDocuments({ foo: 1 }, { limit: 10 }).then((count: number) => { console.log(format("count = %s", count)); }); // Locate all the entries using find - collection.find({}).toArray(function (err: mongodb.MongoError, results: any) { + collection.find({}).toArray((err: mongodb.MongoError, results: any) => { console.dir(results); // Let's close the db client.close(); }); // Get some statistics - collection.stats(function (err: mongodb.MongoError, stats: any) { + collection.stats((err: mongodb.MongoError, stats: any) => { console.log(stats.count + " documents"); }); // - collection.stats().then(function (stats) { + collection.stats().then((stats) => { console.log(stats.wiredTiger.cache['bytes currently in the cache']); - }) + }); - collection.createIndex({}, { partialFilterExpression: { rating: { $exists: 1 } } }) + collection.createIndex({}, { partialFilterExpression: { rating: { $exists: 1 } } }); }); { @@ -95,10 +100,11 @@ MongoClient.connect(connectionString, options, function (err: mongodb.MongoError cursor = cursor.addQueryModifier('', true); cursor = cursor.batchSize(1); cursor = cursor.comment(''); - cursor = cursor.filter(1); - cursor = cursor.hint({}); + cursor = cursor.filter({a: 1}); + cursor = cursor.hint({ age: 1 }); + cursor = cursor.hint('age_1'); cursor = cursor.limit(1); - cursor = cursor.map(function (result) { }); + cursor = cursor.map((result) => {}); cursor = cursor.max(1); cursor = cursor.min(1); cursor = cursor.maxAwaitTimeMS(1); @@ -116,54 +122,64 @@ MongoClient.connect(connectionString, options, function (err: mongodb.MongoError } // Collection .findM() & .agggregate() generic tests { - let bag: { cost: number, color: string }; - type bag = typeof bag; - let cursor: mongodb.Cursor = collection.find({ color: 'black' }) - cursor.toArray(function (err, r) { r[0].cost }); - cursor.forEach(function (bag) { bag.color }, () => { }); - collection.findOne({ color: 'white' }).then(b => { let _b: bag = b; }) - collection.findOne({ color: 'white' }).then(b => { b.cost; }) + interface Bag { + cost: number; + color: string; + } + const cursor: mongodb.Cursor = collection.find({ color: 'black' }); + cursor.toArray((err, r) => { r[0].cost; }); + cursor.forEach((bag) => { bag.color; }, () => {}); + collection.findOne({ color: 'white' }).then(b => { const _b: Bag = b; }); + collection.findOne({ color: 'white' }).then(b => { b.cost; }); } { - let payment: { total: number }; - type payment = typeof payment; - let cursor: mongodb.AggregationCursor = collection.aggregate([{}]) + interface Payment { + total: number; + } + const cursor: mongodb.AggregationCursor = collection.aggregate([{}]); - collection.aggregate([{ $match: { bar: 1 } }, { $limit: 10 }]) - collection.aggregate([{ $match: { bar: 1 } }]).limit(10) - collection.aggregate([]).match({ bar: 1 }).limit(10) - collection.aggregate().match({ bar: 1 }).limit(10) + collection.aggregate([{ $match: { bar: 1 } }, { $limit: 10 }]); + collection.aggregate([{ $match: { bar: 1 } }]).limit(10); + collection.aggregate([]).match({ bar: 1 }).limit(10); + collection.aggregate().match({ bar: 1 }).limit(10); - collection.aggregate( + collection.aggregate( [{ $match: { bar: 1 } }], - function (err: mongodb.MongoError, cursor: mongodb.AggregationCursor) { - cursor.limit(10) + (err: mongodb.MongoError, cursor: mongodb.AggregationCursor) => { + cursor.limit(10); } - ) + ); - collection.aggregate( + collection.aggregate( [], - function (err: mongodb.MongoError, cursor: mongodb.AggregationCursor) { - cursor.match({ bar: 1 }).limit(10) + (err: mongodb.MongoError, cursor: mongodb.AggregationCursor) => { + cursor.match({ bar: 1 }).limit(10); } - ) + ); - collection.aggregate( - function (err: mongodb.MongoError, cursor: mongodb.AggregationCursor) { - cursor.match({ bar: 1 }).limit(10) + collection.aggregate( + (err: mongodb.MongoError, cursor: mongodb.AggregationCursor) => { + cursor.match({ bar: 1 }).limit(10); } - ) + ); } // test for new typings { - type TestCollection = { + interface TestCollection { stringField: string; numberField?: number; - }; - let testCollection = db.collection('testCollection'); - testCollection.insertOne({stringField:'hola'}) - testCollection.insertMany([{stringField:'hola'},{stringField:'hola', numberField: 1}]) + fruitTags: string[]; + } + const testCollection = db.collection('testCollection'); + testCollection.insertOne({ + stringField: 'hola', + fruitTags: ['Strawberry'], + }); + testCollection.insertMany([ + { stringField: 'hola', fruitTags: ['Apple', 'Lemon'] }, + { stringField: 'hola', numberField: 1, fruitTags: [] }, + ]); testCollection.find({ numberField: { $and: [{ $gt: 0, $lt: 100 }] @@ -171,16 +187,28 @@ MongoClient.connect(connectionString, options, function (err: mongodb.MongoError }); const res: mongodb.Cursor = testCollection.find({ _id: 123 }); + + testCollection.updateOne( + { stringField: 'hola' }, + { + $addToSet: { + fruitTags: 'Orange', + }, + $pull: { + fruitTags: 'Lemon', + } + } + ); } -}) +}); -let testFunc = async () => { - let testClient: mongodb.MongoClient; - testClient = await mongodb.connect(connectionString); -}; +async function testFunc(): Promise { + const testClient: mongodb.MongoClient = await mongodb.connect(connectionString); + return testClient; +} -mongodb.connect(connectionString, (err: mongodb.MongoError, client: mongodb.MongoClient) => { }); -mongodb.connect(connectionString, options, (err: mongodb.MongoError, client: mongodb.MongoClient) => { }); +mongodb.connect(connectionString, (err: mongodb.MongoError, client: mongodb.MongoClient) => {}); +mongodb.connect(connectionString, options, (err: mongodb.MongoError, client: mongodb.MongoClient) => {}); // https://docs.mongodb.com/manual/core/transactions/ @@ -193,10 +221,10 @@ async function commitWithRetry(session: mongodb.ClientSession) { error.errorLabels && error.errorLabels.indexOf('UnknownTransactionCommitResult') < 0 ) { - console.log('UnknownTransactionCommitResult, retrying commit operation ...'); + console.log('UnknownTransactionCommitResult, retrying commit operation...'); await commitWithRetry(session); } else { - console.log('Error during commit ...'); + console.log('Error during commit...'); throw error; } } @@ -205,7 +233,8 @@ async function commitWithRetry(session: mongodb.ClientSession) { async function runTransactionWithRetry( txnFunc: (client: mongodb.MongoClient, session: mongodb.ClientSession) => Promise, client: mongodb.MongoClient, - session: mongodb.ClientSession) { + session: mongodb.ClientSession +) { try { await txnFunc(client, session); } catch (error) { @@ -256,31 +285,31 @@ async function transfer(client: mongodb.MongoClient, from: any, to: any, amount: const session = client.startSession(); session.startTransaction(); try { - const opts = { session, returnOriginal: false }; - const A = await db.collection('Account'). + const opts = { session, returnOriginal: false }; + const A = await db.collection('Account'). findOneAndUpdate({ name: from }, { $inc: { balance: -amount } }, opts). then(res => res.value); - if (A.balance < 0) { - // If A would have negative balance, fail and abort the transaction - // `session.abortTransaction()` will undo the above `findOneAndUpdate()` - throw new Error('Insufficient funds: ' + (A.balance + amount)); - } + if (A.balance < 0) { + // If A would have negative balance, fail and abort the transaction + // `session.abortTransaction()` will undo the above `findOneAndUpdate()` + throw new Error('Insufficient funds: ' + (A.balance + amount)); + } - const B = await db.collection('Account'). - findOneAndUpdate({ name: to }, { $inc: { balance: amount } }, opts). - then(res => res.value); + const B = await db.collection('Account') + .findOneAndUpdate({ name: to }, { $inc: { balance: amount } }, opts) + .then(res => res.value); - await session.commitTransaction(); - session.endSession(); - return { from: A, to: B }; + await session.commitTransaction(); + session.endSession(); + return { from: A, to: B }; } catch (error) { - // If an error occurred, abort the whole transaction and - // undo any changes that might have happened - await session.abortTransaction(); - session.endSession(); - throw error; // Rethrow so calling function sees error + // If an error occurred, abort the whole transaction and + // undo any changes that might have happened + await session.abortTransaction(); + session.endSession(); + throw error; // Rethrow so calling function sees error } - } +} mongodb.connect(connectionString).then((client) => { client.startSession(); @@ -288,5 +317,3 @@ mongodb.connect(connectionString).then((client) => { runTransactionWithRetry(updateEmployeeInfo, client, session) ); }); - - diff --git a/types/mongodb/tslint.json b/types/mongodb/tslint.json index e3610fefae..f46f693285 100644 --- a/types/mongodb/tslint.json +++ b/types/mongodb/tslint.json @@ -2,79 +2,50 @@ "extends": "dtslint/dt.json", "rules": { "adjacent-overload-signatures": false, - "array-type": false, "arrow-return-shorthand": false, - "ban-types": false, + "ban-types": { + "options": [ + ["Object", "Avoid using the `Object` type. Did you mean `object`?"], + ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"], + ["Number", "Avoid using the `Number` type. Did you mean `number`?"], + ["String", "Avoid using the `String` type. Did you mean `string`?"], + ["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"] + ] + }, "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, - "use-default-type-parameter": false, - "void-return": false, - "whitespace": false + "use-default-type-parameter": false } } diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index df4c1f7419..43848598b2 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for mongoose-paginate-v2 1.0 -// Project: https://github.com/aravindnc/mongoose-paginate-v2 +// Project: https://github.com/webgangster/mongoose-paginate-v2 // Definitions by: Linus Brolin // simonxca // woutgg diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index fde5e91372..7b02fb96d6 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -18,6 +18,7 @@ // Emmanuel Gautier // Frontend Monster // Ming Chen +// Olga Isakova // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1060,12 +1061,25 @@ declare module "mongoose" { validateBeforeSave?: boolean; /** defaults to "__v" */ versionKey?: string | boolean; + /** + * By default, Mongoose will automatically + * select() any populated paths. + * To opt out, set selectPopulatedPaths to false. + */ + selectPopulatedPaths?: boolean; /** * skipVersioning allows excluding paths from * versioning (the internal revision will not be * incremented even if these paths are updated). */ skipVersioning?: any; + /** + * Validation errors in a single nested schema are reported + * both on the child and on the parent schema. + * Set storeSubdocValidationError to false on the child schema + * to make Mongoose only report the parent error. + */ + storeSubdocValidationError?: boolean; /** * If set timestamps, mongoose assigns createdAt * and updatedAt fields to your schema, the type @@ -2409,6 +2423,13 @@ declare module "mongoose" { */ discriminator(name: string, schema: Schema): Model; + /** + * Adds a discriminator type. + * @param name discriminator model name + * @param schema discriminator model schema + */ + discriminator>(name: string, schema: Schema): M; + } /* diff --git a/types/mui-datatables/index.d.ts b/types/mui-datatables/index.d.ts index 2dffabbc53..1bdf9fc07f 100644 --- a/types/mui-datatables/index.d.ts +++ b/types/mui-datatables/index.d.ts @@ -105,7 +105,7 @@ export interface MUIDataTableColumnOptions { hint?: string; customHeadRender?: (columnMeta: MUIDataTableCustomHeadRenderer, updateDirection: (params: any) => any) => string; customBodyRender?: (value: any, tableMeta: MUIDataTableMeta, updateValue: (s: any, c: any, p: any) => any) => string | React.ReactNode; - setCellProps?: (cellValue: string, rowIndex: number, columnIndex: number) => string; + setCellProps?: (cellValue: string, rowIndex: number, columnIndex: number) => object; } export interface MUIDataTableOptions { @@ -117,7 +117,7 @@ export interface MUIDataTableOptions { textLabels?: MUIDataTableTextLabels; pagination?: boolean; selectableRows?: boolean; - IsRowSelectable?: (dataIndex: any) => boolean; + IsRowSelectable?: (dataIndex: number) => boolean; resizableColumns?: boolean; expandableRows?: boolean; renderExpandableRow?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => React.ReactNode; @@ -143,7 +143,7 @@ export interface MUIDataTableOptions { onRowsSelect?: (currentRowsSelected: any[], rowsSelected: any[]) => void; onRowsDelete?: (rowsDeleted: any[]) => void; onRowClick?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => void; - onCellClick?: (colIndex: number, rowIndex: number) => void; + onCellClick?: (colData: any, cellMeta: { colIndex: number, rowIndex: number, dataIndex: number }) => void; onChangePage?: (currentPage: number) => void; onChangeRowsPerPage?: (numberOfRows: number) => void; onSearchChange?: (searchText: string) => void; @@ -151,7 +151,7 @@ export interface MUIDataTableOptions { onColumnSortChange?: (changedColumn: string, direction: string) => void; onColumnViewChange?: (changedColumn: string, action: string) => void; onTableChange?: (action: string, tableState: object) => void; - setRowProps?: (row: any[], rowIndex: number) => any; + setRowProps?: (row: any[], rowIndex: number) => object; } export type MUIDataTableColumnDef = string | MUIDataTableColumn; diff --git a/types/nock/nock-tests.ts b/types/nock/nock-tests.ts index 06f8458bcb..76f1e0762c 100644 --- a/types/nock/nock-tests.ts +++ b/types/nock/nock-tests.ts @@ -311,7 +311,7 @@ var scope = nock('http://www.google.com') /// Access original request and headers var scope = nock('http://www.google.com') .get('/cat-poems') - .reply((uri, requestBody) => { + .reply(function (uri, requestBody) { console.log('path:', this.req.path); console.log('headers:', this.req.headers); // ... diff --git a/types/node-dogstatsd/index.d.ts b/types/node-dogstatsd/index.d.ts index 36f8145202..8e818f7cb6 100644 --- a/types/node-dogstatsd/index.d.ts +++ b/types/node-dogstatsd/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Datadog's nodejs metrics client node-dogstatsd // Project: https://github.com/joybro/node-dogstatsd // Definitions by: Chris Bobo +// Michael Mifsud // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "node-dogstatsd" { @@ -9,7 +10,21 @@ declare module "node-dogstatsd" { global_tags?: string[]; } - export class StatsD { + export interface StatsDClient { + timing(stat: string, time: number, sample_rate?: number, tags?: string[]): void; + + increment(stat: string, sample_rate?: number, tags?: string[]): void; + incrementBy(stat: string, value: number, tags?: string[]): void; + + decrement(stat: string, sample_rate?: number, tags?: string[]): void; + decrementBy(stat: string, value: number, tags?: string[]): void; + + gauge(stat: string, value: number, sample_rate?: number, tags?: string[]): void; + + histogram(stat: string, time: number, sample_rate?: number, tags?: string[]): void; + } + + export class StatsD implements StatsDClient { constructor(host: string, port?: number, socket?: string, options?: StatsDOptions); timing(stat: string, time: number, sample_rate?: number, tags?: string[]): void; diff --git a/types/node-gettext/index.d.ts b/types/node-gettext/index.d.ts index 3d17f9be16..f0ecee8b41 100644 --- a/types/node-gettext/index.d.ts +++ b/types/node-gettext/index.d.ts @@ -16,8 +16,8 @@ declare class GetText { gettext(msgid: string): string; ngettext(msgid: string, msgidPlural: string, count: number): string; npgettext(msgctxt: string, msgid: string, msgidPlural: string, count: number): string; - off(eventName: string, callback: (params: any) => void): string; - on(eventName: string, callback: (params: any) => void): void; + off(eventName: 'error', callback: (error: string) => void): void; + on(eventName: 'error', callback: (error: string) => void): void; pgettext(msgctxt: string, msgid: string): string; setLocale(locale: string): void; setTextDomain(domain: string): void; diff --git a/types/node-xlsx/index.d.ts b/types/node-xlsx/index.d.ts index bd500d8a4e..4b9432da76 100644 --- a/types/node-xlsx/index.d.ts +++ b/types/node-xlsx/index.d.ts @@ -10,7 +10,7 @@ * @param options options is for xlsx * @returns worksheets data, like: { name: 'worksheets', data: [[1,2,3],['1', '2','word']] } */ -export declare function parse( +export function parse( mixed: string | ArrayBuffer, options?: {} ): Array<{ @@ -24,7 +24,7 @@ export declare function parse( * @param options spannig multiple rows A1:A4 * @returns returns a buffer of worksheets */ -export declare function build( +export function build( worksheets: Array<{ name: string; data: any[][] }>, options?: {} ): ArrayBuffer; diff --git a/types/node/buffer.d.ts b/types/node/buffer.d.ts index 1d618f2c4b..0fe668b17d 100644 --- a/types/node/buffer.d.ts +++ b/types/node/buffer.d.ts @@ -2,6 +2,10 @@ declare module "buffer" { export const INSPECT_MAX_BYTES: number; const BuffType: typeof Buffer; + export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"; + + export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; + export const SlowBuffer: { /** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */ new(size: number): Buffer; diff --git a/types/node/child_process.d.ts b/types/node/child_process.d.ts index 8e10d4e0c7..4e9c882e1b 100644 --- a/types/node/child_process.d.ts +++ b/types/node/child_process.d.ts @@ -1,20 +1,27 @@ declare module "child_process" { import * as events from "events"; - import * as stream from "stream"; import * as net from "net"; + import { Writable, Readable, Stream, Pipe } from "stream"; interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: [stream.Writable, stream.Readable, stream.Readable]; - killed: boolean; - pid: number; + stdin: Writable | null; + stdout: Readable | null; + stderr: Readable | null; + readonly channel?: Pipe | null; + readonly stdio: [ + Writable | null, // stdin + Readable | null, // stdout + Readable | null, // stderr + Readable | Writable | null | undefined, // extra + Readable | Writable | null | undefined // extra + ]; + readonly killed: boolean; + readonly pid: number; + readonly connected: boolean; kill(signal?: string): void; send(message: any, callback?: (error: Error) => void): boolean; send(message: any, sendHandle?: net.Socket | net.Server, callback?: (error: Error) => void): boolean; send(message: any, sendHandle?: net.Socket | net.Server, options?: MessageOptions, callback?: (error: Error) => void): boolean; - connected: boolean; disconnect(): void; unref(): void; ref(): void; @@ -75,17 +82,20 @@ declare module "child_process" { keepOpen?: boolean; } - type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | stream.Stream | number | null | undefined)>; + type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | Stream | number | null | undefined)>; - interface CommonOptions { - /** - * @default true - */ - windowsHide?: boolean; + interface ProcessEnvOptions { uid?: number; gid?: number; cwd?: string; env?: NodeJS.ProcessEnv; + } + + interface CommonOptions extends ProcessEnvOptions { + /** + * @default true + */ + windowsHide?: boolean; /** * @default 0 */ @@ -249,16 +259,12 @@ declare module "child_process" { ): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>; } - interface ForkOptions { - cwd?: string; - env?: NodeJS.ProcessEnv; + interface ForkOptions extends ProcessEnvOptions { execPath?: string; execArgv?: string[]; silent?: boolean; stdio?: StdioOptions; windowsVerbatimArguments?: boolean; - uid?: number; - gid?: number; } function fork(modulePath: string, args?: ReadonlyArray, options?: ForkOptions): ChildProcess; @@ -285,7 +291,7 @@ declare module "child_process" { stderr: T; status: number; signal: string; - error: Error; + error?: Error; } function spawnSync(command: string): SpawnSyncReturns; function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; diff --git a/types/node/crypto.d.ts b/types/node/crypto.d.ts index 27bf801c9f..99c6e236f5 100644 --- a/types/node/crypto.d.ts +++ b/types/node/crypto.d.ts @@ -169,17 +169,17 @@ declare module "crypto" { function createCipheriv( algorithm: CipherCCMTypes, key: CipherKey, - iv: BinaryLike, + iv: BinaryLike | null, options: CipherCCMOptions ): CipherCCM; function createCipheriv( algorithm: CipherGCMTypes, key: CipherKey, - iv: BinaryLike, + iv: BinaryLike | null, options?: CipherGCMOptions ): CipherGCM; function createCipheriv( - algorithm: string, key: CipherKey, iv: BinaryLike, options?: stream.TransformOptions + algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: stream.TransformOptions ): Cipher; interface Cipher extends NodeJS.ReadWriteStream { @@ -213,16 +213,16 @@ declare module "crypto" { function createDecipheriv( algorithm: CipherCCMTypes, key: BinaryLike, - iv: BinaryLike, + iv: BinaryLike | null, options: CipherCCMOptions, ): DecipherCCM; function createDecipheriv( algorithm: CipherGCMTypes, key: BinaryLike, - iv: BinaryLike, + iv: BinaryLike | null, options?: CipherGCMOptions, ): DecipherGCM; - function createDecipheriv(algorithm: string, key: BinaryLike, iv: BinaryLike, options?: stream.TransformOptions): Decipher; + function createDecipheriv(algorithm: string, key: BinaryLike, iv: BinaryLike | null, options?: stream.TransformOptions): Decipher; interface Decipher extends NodeJS.ReadWriteStream { update(data: Binary): Buffer; @@ -405,6 +405,42 @@ declare module "crypto" { passphrase: string; } + interface KeyPairKeyObjectResult { + publicKey: KeyObject; + privateKey: KeyObject; + } + + interface ECKeyPairKeyObjectOptions { + /** + * Name of the curve to use. + */ + namedCurve: string; + } + + interface RSAKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + + /** + * @default 0x10001 + */ + publicExponent?: number; + } + + interface DSAKeyPairKeyObjectOptions { + /** + * Key size in bits + */ + modulusLength: number; + + /** + * Size of q in bits + */ + divisorLength: number; + } + interface RSAKeyPairOptions { /** * Key size in bits @@ -467,46 +503,55 @@ declare module "crypto" { function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult; function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult; function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult; + function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult; function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult; function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult; function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult; function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult; + function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult; function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult; function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult; function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult; function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult; + function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult; function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void; function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void; function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void; function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void; + function generateKeyPair(type: 'rsa', options: RSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void; function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void; function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void; function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void; function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void; + function generateKeyPair(type: 'dsa', options: DSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void; function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void; function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void; function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void; function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void; + function generateKeyPair(type: 'ec', options: ECKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void; namespace generateKeyPair { function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>; function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>; function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>; function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>; + function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise; function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>; function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>; function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>; function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>; + function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise; function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>; function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>; function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>; function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>; + function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise; } } diff --git a/types/node/globals.d.ts b/types/node/globals.d.ts index cd7d67bbdf..210830f7e8 100644 --- a/types/node/globals.d.ts +++ b/types/node/globals.d.ts @@ -245,6 +245,7 @@ interface Buffer extends Uint8Array { compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): Buffer; + subarray(begin: number, end?: number): Buffer; writeUIntLE(value: number, offset: number, byteLength: number): number; writeUIntBE(value: number, offset: number, byteLength: number): number; writeIntLE(value: number, offset: number, byteLength: number): number; @@ -267,6 +268,7 @@ interface Buffer extends Uint8Array { readFloatBE(offset: number): number; readDoubleLE(offset: number): number; readDoubleBE(offset: number): number; + reverse(): this; swap16(): Buffer; swap32(): Buffer; swap64(): Buffer; @@ -679,7 +681,7 @@ declare namespace NodeJS { type ExitListener = (code: number) => void; type RejectionHandledListener = (promise: Promise) => void; type UncaughtExceptionListener = (error: Error) => void; - type UnhandledRejectionListener = (reason: any, promise: Promise) => void; + type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise) => void; type WarningListener = (warning: Error) => void; type MessageListener = (message: any, sendHandle: any) => void; type SignalsListener = (signal: Signals) => void; @@ -719,6 +721,10 @@ declare namespace NodeJS { destroy(error?: Error): void; } + interface HRTime { + (time?: [number, number]): [number, number]; + } + interface Process extends EventEmitter { /** * Can also be a tty.WriteStream, not typed due to limitation.s @@ -793,12 +799,22 @@ declare namespace NodeJS { cpuUsage(previousValue?: CpuUsage): CpuUsage; nextTick(callback: Function, ...args: any[]): void; release: ProcessRelease; + features: { + inspector: boolean; + debug: boolean; + uv: boolean; + ipv6: boolean; + tls_alpn: boolean; + tls_sni: boolean; + tls_ocsp: boolean; + tls: boolean; + }; /** * Can only be set if not in worker thread. */ umask(mask?: number): number; uptime(): number; - hrtime(time?: [number, number]): [number, number]; + hrtime: HRTime; domain: Domain; // Worker diff --git a/types/node/http.d.ts b/types/node/http.d.ts index b2557963a0..913cf98a37 100644 --- a/types/node/http.d.ts +++ b/types/node/http.d.ts @@ -147,8 +147,8 @@ declare module "http" { // https://github.com/nodejs/node/blob/master/test/parallel/test-http-write-callbacks.js#L53 // no args in writeContinue callback writeContinue(callback?: () => void): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void; - writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): this; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this; } // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L77 @@ -159,6 +159,7 @@ declare module "http" { constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); + readonly path: string; abort(): void; onSocket(socket: net.Socket): void; setTimeout(timeout: number, callback?: () => void): this; diff --git a/types/node/http2.d.ts b/types/node/http2.d.ts index aecbca783f..48e35190d4 100644 --- a/types/node/http2.d.ts +++ b/types/node/http2.d.ts @@ -582,8 +582,8 @@ declare module "http2" { write(chunk: string | Buffer, callback?: (err: Error) => void): boolean; write(chunk: string | Buffer, encoding?: string, callback?: (err: Error) => void): boolean; writeContinue(): void; - writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; - writeHead(statusCode: number, statusMessage?: string, headers?: OutgoingHttpHeaders): void; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this; + writeHead(statusCode: number, statusMessage?: string, headers?: OutgoingHttpHeaders): this; createPushResponse(headers: OutgoingHttpHeaders, callback: (err: Error | null, res: Http2ServerResponse) => void): void; addListener(event: string, listener: (...args: any[]) => void): this; diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 39db1d52fa..23b53a5f0d 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package Node.js 11.9 +// Type definitions for non-npm package Node.js 11.10 // Project: http://nodejs.org/ // Definitions by: Microsoft TypeScript // DefinitelyTyped @@ -35,18 +35,20 @@ // Jeremie Rodriguez // Samuel Ainsworth // Kyle Uehlein +// Jordi Oliveras Rovira +// Thanik Bhongbhibhat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// NOTE: These definitions support NodeJS and TypeScript 3.1. +// NOTE: These definitions support NodeJS and TypeScript 3.2. // NOTE: TypeScript version-specific augmentations can be found in the following paths: // - ~/base.d.ts - Shared definitions common to all TypeScript versions // - ~/index.d.ts - Definitions specific to TypeScript 2.1 -// - ~/ts3.1/index.d.ts - Definitions specific to TypeScript 3.1 +// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 -// NOTE: Augmentations for TypeScript 3.1 and later should use individual files for overrides -// within the respective ~/ts3.1 (or later) folder. However, this is disallowed for versions -// prior to TypeScript 3.1, so the older definitions will be found here. +// NOTE: Augmentations for TypeScript 3.2 and later should use individual files for overrides +// within the respective ~/ts3.2 (or later) folder. However, this is disallowed for versions +// prior to TypeScript 3.2, so the older definitions will be found here. // Base definitions for all NodeJS modules that are not specific to any version of TypeScript: /// @@ -54,6 +56,9 @@ // TypeScript 2.1-specific augmentations: // Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`) +// Empty interfaces are used here which merge fine with the real declarations in the lib XXX files +// just to ensure the names are known and node typings can be sued without importing these libs. +// if someone really needs these types the libs need to be added via --lib or in tsconfig.json interface MapConstructor { } interface WeakMapConstructor { } interface SetConstructor { } @@ -72,8 +77,9 @@ interface SymbolConstructor { readonly asyncIterator: symbol; } declare var Symbol: SymbolConstructor; -declare class SharedArrayBuffer { - constructor(byteSize: number); +// even this is just a forward declaration some properties are added otherwise +// it would be allowed to pass anything to e.g. Buffer.from() +interface SharedArrayBuffer { readonly byteLength: number; slice(begin?: number, end?: number): SharedArrayBuffer; } diff --git a/types/node/net.d.ts b/types/node/net.d.ts index 33858de8df..d011f6297c 100644 --- a/types/node/net.d.ts +++ b/types/node/net.d.ts @@ -178,7 +178,7 @@ declare module "net" { listen(options: ListenOptions, listeningListener?: Function): this; listen(handle: any, backlog?: number, listeningListener?: Function): this; listen(handle: any, listeningListener?: Function): this; - close(callback?: Function): this; + close(callback?: (err?: Error) => void): this; address(): AddressInfo | string | null; getConnections(cb: (error: Error | null, count: number) => void): void; ref(): this; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 089ca86307..900a8fa21a 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -8,24 +8,18 @@ import * as util from "util"; import * as tls from "tls"; import * as http from "http"; import * as https from "https"; -import * as net from "net"; import * as querystring from "querystring"; import * as path from "path"; -import * as childProcess from "child_process"; import * as cluster from "cluster"; import * as os from "os"; import * as vm from "vm"; import * as console2 from "console"; import * as string_decoder from "string_decoder"; -import * as stream from "stream"; import * as timers from "timers"; -import * as repl from "repl"; import * as v8 from "v8"; import * as dns from "dns"; import * as async_hooks from "async_hooks"; -import * as http2 from "http2"; import * as inspector from "inspector"; -import * as perf_hooks from "perf_hooks"; import * as trace_events from "trace_events"; import Module = require("module"); @@ -563,468 +557,6 @@ import Module = require("module"); } } -//////////////////////////////////////////////////// -/// Stream tests : http://nodejs.org/api/stream.html -//////////////////////////////////////////////////// - -// http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options -function stream_readable_pipe_test() { - const rs = fs.createReadStream(Buffer.from('file.txt')); - const r = fs.createReadStream('file.txt'); - const z = zlib.createGzip({ finishFlush: zlib.constants.Z_FINISH }); - const w = fs.createWriteStream('file.txt.gz'); - - assert(typeof z.bytesRead === 'number'); - assert(typeof r.bytesRead === 'number'); - assert(typeof r.path === 'string'); - assert(rs.path instanceof Buffer); - - r.pipe(z).pipe(w); - - z.flush(); - r.close(); - z.close(); - rs.close(); -} - -// helpers -const compressMe = new Buffer("some data"); -const compressMeString = "compress me!"; - -zlib.deflate(compressMe, (err: Error | null, result: Buffer) => zlib.inflate(result, (err: Error | null, result: Buffer) => result)); -zlib.deflate( - compressMe, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => zlib.inflate( - result, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => result - ) -); -zlib.deflate(compressMeString, (err: Error | null, result: Buffer) => zlib.inflate(result, (err: Error | null, result: Buffer) => result)); -zlib.deflate( - compressMeString, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => zlib.inflate( - result, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => result - ) -); -const inflated = zlib.inflateSync(zlib.deflateSync(compressMe)); -const inflatedString = zlib.inflateSync(zlib.deflateSync(compressMeString)); - -zlib.deflateRaw(compressMe, (err: Error | null, result: Buffer) => zlib.inflateRaw(result, (err: Error | null, result: Buffer) => result)); -zlib.deflateRaw( - compressMe, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => zlib.inflateRaw( - result, { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => result - ) -); -zlib.deflateRaw(compressMeString, (err: Error | null, result: Buffer) => zlib.inflateRaw(result, (err: Error | null, result: Buffer) => result)); -zlib.deflateRaw( - compressMeString, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => zlib.inflateRaw(result, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error | null, result: Buffer) => result), -); -const inflatedRaw: Buffer = zlib.inflateRawSync(zlib.deflateRawSync(compressMe)); -const inflatedRawString: Buffer = zlib.inflateRawSync(zlib.deflateRawSync(compressMeString)); - -zlib.gzip(compressMe, (err: Error | null, result: Buffer) => zlib.gunzip(result, (err: Error | null, result: Buffer) => result)); -zlib.gzip( - compressMe, - { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => zlib.gunzip( - result, { finishFlush: zlib.Z_SYNC_FLUSH }, - (err: Error | null, result: Buffer) => result - ) -); -const gunzipped: Buffer = zlib.gunzipSync(zlib.gzipSync(compressMe)); - -zlib.unzip(compressMe, (err: Error | null, result: Buffer) => result); -zlib.unzip(compressMe, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error | null, result: Buffer) => result); -const unzipped: Buffer = zlib.unzipSync(compressMe); - -// Simplified constructors -function simplified_stream_ctor_test() { - new stream.Readable({ - read(size) { - // $ExpectType Readable - this; - // $ExpectType number - size; - }, - destroy(error, cb) { - // $ExpectType Error | null - error; - // $ExpectType (error: Error | null) => void - cb; - } - }); - - new stream.Writable({ - write(chunk, enc, cb) { - // $ExpectType Writable - this; - // $ExpectType any - chunk; - // $ExpectType string - enc; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - writev(chunks, cb) { - // $ExpectType Writable - this; - // $ExpectType { chunk: any; encoding: string; }[] - chunks; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - destroy(error, cb) { - // $ExpectType Writable - this; - // $ExpectType Error | null - error; - // $ExpectType (error: Error | null) => void - cb; - }, - final(cb) { - // $ExpectType Writable - this; - // $ExpectType (error?: Error | null | undefined) => void - cb; - } - }); - - new stream.Duplex({ - read(size) { - // $ExpectType Duplex - this; - // $ExpectType number - size; - }, - write(chunk, enc, cb) { - // $ExpectType Duplex - this; - // $ExpectType any - chunk; - // $ExpectType string - enc; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - writev(chunks, cb) { - // $ExpectType Duplex - this; - // $ExpectType { chunk: any; encoding: string; }[] - chunks; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - destroy(error, cb) { - // $ExpectType Duplex - this; - // $ExpectType Error | null - error; - // $ExpectType (error: Error | null) => void - cb; - }, - final(cb) { - // $ExpectType Duplex - this; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - readableObjectMode: true, - writableObjectMode: true - }); - - new stream.Transform({ - read(size) { - // $ExpectType Transform - this; - // $ExpectType number - size; - }, - write(chunk, enc, cb) { - // $ExpectType Transform - this; - // $ExpectType any - chunk; - // $ExpectType string - enc; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - writev(chunks, cb) { - // $ExpectType Transform - this; - // $ExpectType { chunk: any; encoding: string; }[] - chunks; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - destroy(error, cb) { - // $ExpectType Transform - this; - // $ExpectType Error | null - error; - // $ExpectType (error: Error | null) => void - cb; - }, - final(cb) { - // $ExpectType Transform - this; - // $ExpectType (error?: Error | null | undefined) => void - cb; - }, - transform(chunk, enc, cb) { - // $ExpectType Transform - this; - // $ExpectType any - chunk; - // $ExpectType string - enc; - // $ExpectType TransformCallback - cb; - }, - flush(cb) { - // $ExpectType TransformCallback - cb; - }, - allowHalfOpen: true, - readableObjectMode: true, - writableObjectMode: true - }); -} - -function streamPipelineFinished() { - const cancel = stream.finished(process.stdin, (err?: Error) => {}); - cancel(); - - stream.pipeline(process.stdin, process.stdout, (err?: Error) => {}); -} - -async function asyncStreamPipelineFinished() { - const finished = util.promisify(stream.finished); - await finished(process.stdin); - - const pipeline = util.promisify(stream.pipeline); - await pipeline(process.stdin, process.stdout); -} - -////////////////////////////////////////////////// -/// TLS tests : http://nodejs.org/api/tls.html /// -////////////////////////////////////////////////// - -{ - { - const ctx: tls.SecureContext = tls.createSecureContext({ - key: "NOT REALLY A KEY", - cert: "SOME CERTIFICATE", - }); - const blah = ctx.context; - - const connOpts: tls.ConnectionOptions = { - host: "127.0.0.1", - port: 55 - }; - const tlsSocket = tls.connect(connOpts); - - const ciphers: string[] = tls.getCiphers(); - const curve: string = tls.DEFAULT_ECDH_CURVE; - } - - { - let _server = tls.createServer({}); - let _boolean: boolean; - const _func1 = (err: Error, resp: Buffer) => { }; - const _func2 = (err: Error, sessionData: any) => { }; - /** - * events.EventEmitter - * 1. tlsClientError - * 2. newSession - * 3. OCSPRequest - * 4. resumeSession - * 5. secureConnection - */ - - _server = _server.addListener("tlsClientError", (err, tlsSocket) => { - const _err: Error = err; - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - _server = _server.addListener("newSession", (sessionId, sessionData, callback) => { - const _sessionId: any = sessionId; - const _sessionData: any = sessionData; - const _func1 = callback; - }); - _server = _server.addListener("OCSPRequest", (certificate, issuer, callback) => { - const _certificate: Buffer = certificate; - const _issuer: Buffer = issuer; - const _callback: Function = callback; - }); - _server = _server.addListener("resumeSession", (sessionId, callback) => { - const _sessionId: any = sessionId; - const _func2 = callback; - }); - _server = _server.addListener("secureConnection", (tlsSocket) => { - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - - const _err: Error = new Error(); - const _tlsSocket: tls.TLSSocket = tls.connect(1); - const _any: any = 1; - const _func: Function = () => {}; - const _buffer: Buffer = Buffer.from('a'); - _boolean = _server.emit("tlsClientError", _err, _tlsSocket); - _boolean = _server.emit("newSession", _any, _any, _func1); - _boolean = _server.emit("OCSPRequest", _buffer, _buffer, _func); - _boolean = _server.emit("resumeSession", _any, _func2); - _boolean = _server.emit("secureConnection", _tlsSocket); - - _server = _server.on("tlsClientError", (err, tlsSocket) => { - const _err: Error = err; - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - _server = _server.on("newSession", (sessionId, sessionData, callback) => { - const _sessionId: any = sessionId; - const _sessionData: any = sessionData; - const _func1 = callback; - }); - _server = _server.on("OCSPRequest", (certificate, issuer, callback) => { - const _certificate: Buffer = certificate; - const _issuer: Buffer = issuer; - const _callback: Function = callback; - }); - _server = _server.on("resumeSession", (sessionId, callback) => { - const _sessionId: any = sessionId; - const _func2 = callback; - }); - _server = _server.on("secureConnection", (tlsSocket) => { - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - - _server = _server.once("tlsClientError", (err, tlsSocket) => { - const _err: Error = err; - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - _server = _server.once("newSession", (sessionId, sessionData, callback) => { - const _sessionId: any = sessionId; - const _sessionData: any = sessionData; - const _func1 = callback; - }); - _server = _server.once("OCSPRequest", (certificate, issuer, callback) => { - const _certificate: Buffer = certificate; - const _issuer: Buffer = issuer; - const _callback: Function = callback; - }); - _server = _server.once("resumeSession", (sessionId, callback) => { - const _sessionId: any = sessionId; - const _func2 = callback; - }); - _server = _server.once("secureConnection", (tlsSocket) => { - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - - _server = _server.prependListener("tlsClientError", (err, tlsSocket) => { - const _err: Error = err; - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - _server = _server.prependListener("newSession", (sessionId, sessionData, callback) => { - const _sessionId: any = sessionId; - const _sessionData: any = sessionData; - const _func1 = callback; - }); - _server = _server.prependListener("OCSPRequest", (certificate, issuer, callback) => { - const _certificate: Buffer = certificate; - const _issuer: Buffer = issuer; - const _callback: Function = callback; - }); - _server = _server.prependListener("resumeSession", (sessionId, callback) => { - const _sessionId: any = sessionId; - const _func2 = callback; - }); - _server = _server.prependListener("secureConnection", (tlsSocket) => { - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - - _server = _server.prependOnceListener("tlsClientError", (err, tlsSocket) => { - const _err: Error = err; - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - _server = _server.prependOnceListener("newSession", (sessionId, sessionData, callback) => { - const _sessionId: any = sessionId; - const _sessionData: any = sessionData; - const _func1 = callback; - }); - _server = _server.prependOnceListener("OCSPRequest", (certificate, issuer, callback) => { - const _certificate: Buffer = certificate; - const _issuer: Buffer = issuer; - const _callback: Function = callback; - }); - _server = _server.prependOnceListener("resumeSession", (sessionId, callback) => { - const _sessionId: any = sessionId; - const _func2 = callback; - }); - _server = _server.prependOnceListener("secureConnection", (tlsSocket) => { - const _tlsSocket: tls.TLSSocket = tlsSocket; - }); - - // close callback parameter is optional - _server = _server.close(); - - // close callback parameter doesn't specify any arguments, so any - // function is acceptable - _server = _server.close(() => { }); - _server = _server.close((...args: any[]) => { }); - } - - { - let _TLSSocket = tls.connect({ - }); - let _boolean: boolean; - /** - * events.EventEmitter - * 1. close - * 2. error - * 3. listening - * 4. message - */ - - _TLSSocket = _TLSSocket.addListener("OCSPResponse", (response) => { - const _response: Buffer = response; - }); - _TLSSocket = _TLSSocket.addListener("secureConnect", () => { }); - - const _buffer: Buffer = Buffer.from(""); - _boolean = _TLSSocket.emit("OCSPResponse", _buffer); - _boolean = _TLSSocket.emit("secureConnect"); - - _TLSSocket = _TLSSocket.on("OCSPResponse", (response) => { - const _response: Buffer = response; - }); - _TLSSocket = _TLSSocket.on("secureConnect", () => { }); - - _TLSSocket = _TLSSocket.once("OCSPResponse", (response) => { - const _response: Buffer = response; - }); - _TLSSocket = _TLSSocket.once("secureConnect", () => { }); - - _TLSSocket = _TLSSocket.prependListener("OCSPResponse", (response) => { - const _response: Buffer = response; - }); - _TLSSocket = _TLSSocket.prependListener("secureConnect", () => { }); - - _TLSSocket = _TLSSocket.prependOnceListener("OCSPResponse", (response) => { - const _response: Buffer = response; - }); - _TLSSocket = _TLSSocket.prependOnceListener("secureConnect", () => { }); - } -} - ////////////////////////////////////////////////////// /// Https tests : http://nodejs.org/api/https.html /// ////////////////////////////////////////////////////// @@ -1331,294 +863,6 @@ async function asyncStreamPipelineFinished() { const end2: string = decoder1.end(new Buffer('test')); } -////////////////////////////////////////////////////////////////////// -/// Child Process tests: https://nodejs.org/api/child_process.html /// -////////////////////////////////////////////////////////////////////// - -{ - { - childProcess.exec("echo test"); - childProcess.exec("echo test", { windowsHide: true }); - childProcess.spawn("echo"); - childProcess.spawn("echo", { windowsHide: true }); - childProcess.spawn("echo", ["test"], { windowsHide: true }); - childProcess.spawn("echo", ["test"], { windowsHide: true, argv0: "echo-test" }); - childProcess.spawn("echo", ["test"], { stdio: [0xdeadbeef, "inherit", undefined, "pipe"] }); - childProcess.spawnSync("echo test"); - childProcess.spawnSync("echo test", {windowsVerbatimArguments: false}); - childProcess.spawnSync("echo test", {windowsVerbatimArguments: false, argv0: "echo-test"}); - childProcess.spawnSync("echo test", {input: new Uint8Array([])}); - childProcess.spawnSync("echo test", {input: new DataView(new ArrayBuffer(1))}); - } - - { - childProcess.execFile("npm", () => {}); - childProcess.execFile("npm", { windowsHide: true }, () => {}); - childProcess.execFile("npm", ["-v"], () => {}); - childProcess.execFile("npm", ["-v"], { windowsHide: true, encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); - childProcess.execFile("npm", ["-v"], { windowsHide: true, encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); - childProcess.execFile("npm", { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); - childProcess.execFile("npm", { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); - } - - { - childProcess.execFileSync("echo test", {input: new Uint8Array([])}); - childProcess.execFileSync("echo test", {input: new DataView(new ArrayBuffer(1))}); - } - - async function testPromisify() { - const execFile = util.promisify(childProcess.execFile); - let r: { stdout: string | Buffer, stderr: string | Buffer } = await execFile("npm"); - r = await execFile("npm", ["-v"]); - r = await execFile("npm", ["-v"], { encoding: 'utf-8' }); - r = await execFile("npm", ["-v"], { encoding: 'buffer' }); - r = await execFile("npm", { encoding: 'utf-8' }); - r = await execFile("npm", { encoding: 'buffer' }); - } - - { - let _cp = childProcess.spawn('asd'); - const _socket: net.Socket = net.createConnection(1); - const _server: net.Server = net.createServer(); - let _boolean: boolean; - - _boolean = _cp.send(1); - _boolean = _cp.send('one'); - _boolean = _cp.send({ - type: 'test' - }); - - _boolean = _cp.send(1, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send('one', (error) => { - const _err: Error = error; - }); - _boolean = _cp.send({ - type: 'test' - }, (error) => { - const _err: Error = error; - }); - - _boolean = _cp.send(1, _socket); - _boolean = _cp.send('one', _socket); - _boolean = _cp.send({ - type: 'test' - }, _socket); - - _boolean = _cp.send(1, _socket, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send('one', _socket, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send({ - type: 'test' - }, _socket, (error) => { - const _err: Error = error; - }); - - _boolean = _cp.send(1, _socket, { - keepOpen: true - }); - _boolean = _cp.send('one', _socket, { - keepOpen: true - }); - _boolean = _cp.send({ - type: 'test' - }, _socket, { - keepOpen: true - }); - - _boolean = _cp.send(1, _socket, { - keepOpen: true - }, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send('one', _socket, { - keepOpen: true - }, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send({ - type: 'test' - }, _socket, { - keepOpen: true - }, (error) => { - const _err: Error = error; - }); - - _boolean = _cp.send(1, _server); - _boolean = _cp.send('one', _server); - _boolean = _cp.send({ - type: 'test' - }, _server); - - _boolean = _cp.send(1, _server, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send('one', _server, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send({ - type: 'test' - }, _server, (error) => { - const _err: Error = error; - }); - - _boolean = _cp.send(1, _server, { - keepOpen: true - }); - _boolean = _cp.send('one', _server, { - keepOpen: true - }); - _boolean = _cp.send({ - type: 'test' - }, _server, { - keepOpen: true - }); - - _boolean = _cp.send(1, _server, { - keepOpen: true - }, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send('one', _server, { - keepOpen: true - }, (error) => { - const _err: Error = error; - }); - _boolean = _cp.send({ - type: 'test' - }, _server, { - keepOpen: true - }, (error) => { - const _err: Error = error; - }); - - _cp = _cp.addListener("close", (code, signal) => { - const _code: number = code; - const _signal: string = signal; - }); - _cp = _cp.addListener("disconnect", () => { }); - _cp = _cp.addListener("error", (err) => { - const _err: Error = err; - }); - _cp = _cp.addListener("exit", (code, signal) => { - const _code: number | null = code; - const _signal: string | null = signal; - }); - _cp = _cp.addListener("message", (message, sendHandle) => { - const _message: any = message; - const _sendHandle: net.Socket | net.Server = sendHandle; - }); - - _boolean = _cp.emit("close", () => { }); - _boolean = _cp.emit("disconnect", () => { }); - _boolean = _cp.emit("error", () => { }); - _boolean = _cp.emit("exit", () => { }); - _boolean = _cp.emit("message", () => { }); - - _cp = _cp.on("close", (code, signal) => { - const _code: number = code; - const _signal: string = signal; - }); - _cp = _cp.on("disconnect", () => { }); - _cp = _cp.on("error", (err) => { - const _err: Error = err; - }); - _cp = _cp.on("exit", (code, signal) => { - const _code: number | null = code; - const _signal: string | null = signal; - }); - _cp = _cp.on("message", (message, sendHandle) => { - const _message: any = message; - const _sendHandle: net.Socket | net.Server = sendHandle; - }); - - _cp = _cp.once("close", (code, signal) => { - const _code: number = code; - const _signal: string = signal; - }); - _cp = _cp.once("disconnect", () => { }); - _cp = _cp.once("error", (err) => { - const _err: Error = err; - }); - _cp = _cp.once("exit", (code, signal) => { - const _code: number | null = code; - const _signal: string | null = signal; - }); - _cp = _cp.once("message", (message, sendHandle) => { - const _message: any = message; - const _sendHandle: net.Socket | net.Server = sendHandle; - }); - - _cp = _cp.prependListener("close", (code, signal) => { - const _code: number = code; - const _signal: string = signal; - }); - _cp = _cp.prependListener("disconnect", () => { }); - _cp = _cp.prependListener("error", (err) => { - const _err: Error = err; - }); - _cp = _cp.prependListener("exit", (code, signal) => { - const _code: number | null = code; - const _signal: string | null = signal; - }); - _cp = _cp.prependListener("message", (message, sendHandle) => { - const _message: any = message; - const _sendHandle: net.Socket | net.Server = sendHandle; - }); - - _cp = _cp.prependOnceListener("close", (code, signal) => { - const _code: number = code; - const _signal: string = signal; - }); - _cp = _cp.prependOnceListener("disconnect", () => { }); - _cp = _cp.prependOnceListener("error", (err) => { - const _err: Error = err; - }); - _cp = _cp.prependOnceListener("exit", (code, signal) => { - const _code: number | null = code; - const _signal: string | null = signal; - }); - _cp = _cp.prependOnceListener("message", (message, sendHandle) => { - const _message: any = message; - const _sendHandle: net.Socket | net.Server = sendHandle; - }); - } - { - process.stdin.setEncoding('utf8'); - - process.stdin.on('readable', () => { - const chunk = process.stdin.read(); - if (chunk !== null) { - process.stdout.write(`data: ${chunk}`); - } - }); - - process.stdin.on('end', () => { - process.stdout.write('end'); - }); - - process.stdin.pipe(process.stdout); - - console.log(process.stdin.isTTY); - console.log(process.stdout.isTTY); - - console.log(process.stdin instanceof net.Socket); - console.log(process.stdout instanceof fs.ReadStream); - - const stdin: stream.Readable = process.stdin; - console.log(stdin instanceof net.Socket); - console.log(stdin instanceof fs.ReadStream); - - const stdout: stream.Writable = process.stdout; - console.log(stdout instanceof net.Socket); - console.log(stdout instanceof fs.WriteStream); - } -} - ////////////////////////////////////////////////////////////////////// /// cluster tests: https://nodejs.org/api/cluster.html /// ////////////////////////////////////////////////////////////////////// @@ -1967,7 +1211,7 @@ import * as p from "process"; process.prependListener("exit", (code: number) => { }); process.prependOnceListener("rejectionHandled", (promise: Promise) => { }); process.on("uncaughtException", (error: Error) => { }); - process.addListener("unhandledRejection", (reason: any, promise: Promise) => { }); + process.addListener("unhandledRejection", (reason: {} | null | undefined, promise: Promise) => { }); process.once("warning", (warning: Error) => { }); process.prependListener("message", (message: any, sendHandle: any) => { }); process.prependOnceListener("SIGBREAK", () => { }); @@ -2081,80 +1325,6 @@ import * as p from "process"; } } -///////////////////////////////////////////////////// -/// repl Tests : https://nodejs.org/api/repl.html /// -///////////////////////////////////////////////////// - -{ - { - let _server = repl.start(); - let _boolean: boolean; - const _ctx: vm.Context = {}; - - _server = _server.addListener("exit", () => { }); - _server = _server.addListener("reset", () => { }); - - _boolean = _server.emit("exit", () => { }); - _boolean = _server.emit("reset", _ctx); - - _server = _server.on("exit", () => { }); - _server = _server.on("reset", () => { }); - - _server = _server.once("exit", () => { }); - _server = _server.once("reset", () => { }); - - _server = _server.prependListener("exit", () => { }); - _server = _server.prependListener("reset", () => { }); - - _server = _server.prependOnceListener("exit", () => { }); - _server = _server.prependOnceListener("reset", () => { }); - - _server.outputStream.write("test"); - const line = _server.inputStream.read(); - - _server.clearBufferedCommand(); - _server.displayPrompt(); - _server.displayPrompt(true); - _server.defineCommand("cmd", function(text) { - // $ExpectType string - text; - // $ExpectType REPLServer - this; - }); - _server.defineCommand("cmd", { - help: "", - action(text) { - // $ExpectType string - text; - // $ExpectType REPLServer - this; - } - }); - - repl.start({ - eval() { - // $ExpectType REPLServer - this; - }, - writer() { - // $ExpectType REPLServer - this; - return ""; - } - }); - - function test() { - throw new repl.Recoverable(new Error("test")); - } - - _server.context['key0'] = 1; - _server.context['key1'] = ""; - _server.context['key2'] = true; - _server.context['key3'] = []; - _server.context['key4'] = {}; - } -} - /////////////////////////////////////////////////// /// DNS Tests : https://nodejs.org/api/dns.html /// /////////////////////////////////////////////////// @@ -2434,36 +1604,6 @@ import * as constants from 'constants'; v8.setFlagsFromString('--collect_maps'); } -//////////////////////////////////////////////////// -/// PerfHooks tests : https://nodejs.org/api/perf_hooks.html -//////////////////////////////////////////////////// -{ - perf_hooks.performance.mark('start'); - ( - () => {} - )(); - perf_hooks.performance.mark('end'); - - const { duration } = perf_hooks.performance.getEntriesByName('discover')[0]; - const timeOrigin = perf_hooks.performance.timeOrigin; - - const performanceObserverCallback: perf_hooks.PerformanceObserverCallback = (list, obs) => { - const { - duration, - entryType, - name, - startTime, - } = list.getEntries()[0]; - obs.disconnect(); - perf_hooks.performance.clearFunctions(); - }; - const obs = new perf_hooks.PerformanceObserver(performanceObserverCallback); - obs.observe({ - entryTypes: ['function'], - buffered: true, - }); -} - //////////////////////////////////////////////////// /// AsyncHooks tests : https://nodejs.org/api/async_hooks.html //////////////////////////////////////////////////// @@ -2536,576 +1676,6 @@ import * as constants from 'constants'; } } -/////////////////////////////////////////////////////////// -/// HTTP/2 Tests /// -/////////////////////////////////////////////////////////// - -{ - // Headers & Settings - { - const headers: http2.OutgoingHttpHeaders = { - ':status': 200, - 'content-type': 'text-plain', - ABC: ['has', 'more', 'than', 'one', 'value'], - undef: undefined - }; - - const settings: http2.Settings = { - headerTableSize: 0, - enablePush: true, - initialWindowSize: 0, - maxFrameSize: 0, - maxConcurrentStreams: 0, - maxHeaderListSize: 0 - }; - } - - // Http2Session - { - const http2Session: http2.Http2Session = {} as any; - const ee: events.EventEmitter = http2Session; - - http2Session.on('close', () => {}); - http2Session.on('connect', (session: http2.Http2Session, socket: net.Socket) => {}); - http2Session.on('error', (err: Error) => {}); - http2Session.on('frameError', (frameType: number, errorCode: number, streamID: number) => {}); - http2Session.on('goaway', (errorCode: number, lastStreamID: number, opaqueData: Buffer) => {}); - http2Session.on('localSettings', (settings: http2.Settings) => {}); - http2Session.on('remoteSettings', (settings: http2.Settings) => {}); - http2Session.on('stream', (stream: http2.Http2Stream, headers: http2.IncomingHttpHeaders, flags: number) => {}); - http2Session.on('timeout', () => {}); - http2Session.on('ping', () => {}); - - http2Session.destroy(); - - const alpnProtocol: string | undefined = http2Session.alpnProtocol; - const destroyed: boolean | undefined = http2Session.destroyed; - const encrypted: boolean | undefined = http2Session.encrypted; - const originSet: string[] | undefined = http2Session.originSet; - const pendingSettingsAck: boolean = http2Session.pendingSettingsAck; - let settings: http2.Settings = http2Session.localSettings; - const closed: boolean = http2Session.closed; - const connecting: boolean = http2Session.connecting; - settings = http2Session.remoteSettings; - - http2Session.ref(); - http2Session.unref(); - - const headers: http2.OutgoingHttpHeaders = {}; - const options: http2.ClientSessionRequestOptions = { - endStream: true, - exclusive: true, - parent: 0, - weight: 0, - getTrailers: (trailers: http2.OutgoingHttpHeaders) => {} - }; - (http2Session as http2.ClientHttp2Session).request(); - (http2Session as http2.ClientHttp2Session).request(headers); - (http2Session as http2.ClientHttp2Session).request(headers, options); - - const stream: http2.Http2Stream = {} as any; - http2Session.rstStream(stream); - http2Session.rstStream(stream, 0); - - http2Session.setTimeout(100, () => {}); - http2Session.close(() => {}); - - const socket: net.Socket | tls.TLSSocket = http2Session.socket; - let state: http2.SessionState = http2Session.state; - state = { - effectiveLocalWindowSize: 0, - effectiveRecvDataLength: 0, - nextStreamID: 0, - localWindowSize: 0, - lastProcStreamID: 0, - remoteWindowSize: 0, - outboundQueueSize: 0, - deflateDynamicTableSize: 0, - inflateDynamicTableSize: 0 - }; - - http2Session.priority(stream, { - exclusive: true, - parent: 0, - weight: 0, - silent: true - }); - - http2Session.settings(settings); - - http2Session.ping((err: Error | null, duration: number, payload: Buffer) => {}); - http2Session.ping(Buffer.from(''), (err: Error | null, duration: number, payload: Buffer) => {}); - http2Session.ping(new DataView(new Int8Array(1).buffer), (err: Error | null, duration: number, payload: Buffer) => {}); - } - - // Http2Stream - { - const http2Stream: http2.Http2Stream = {} as any; - const duplex: stream.Duplex = http2Stream; - - http2Stream.on('aborted', () => {}); - http2Stream.on('error', (err: Error) => {}); - http2Stream.on('frameError', (frameType: number, errorCode: number, streamID: number) => {}); - http2Stream.on('streamClosed', (code: number) => {}); - http2Stream.on('timeout', () => {}); - http2Stream.on('trailers', (trailers: http2.IncomingHttpHeaders, flags: number) => {}); - http2Stream.on('wantTrailers', () => {}); - - const aborted: boolean = http2Stream.aborted; - const closed: boolean = http2Stream.closed; - const destroyed: boolean = http2Stream.destroyed; - const pending: boolean = http2Stream.pending; - - http2Stream.priority({ - exclusive: true, - parent: 0, - weight: 0, - silent: true - }); - - const sesh: http2.Http2Session = http2Stream.session; - - http2Stream.setTimeout(100, () => {}); - - let state: http2.StreamState = http2Stream.state; - state = { - localWindowSize: 0, - state: 0, - streamLocalClose: 0, - streamRemoteClose: 0, - sumDependencyWeight: 0, - weight: 0 - }; - - http2Stream.close(); - http2Stream.close(0); - http2Stream.close(0, () => {}); - http2Stream.close(undefined, () => {}); - - // ClientHttp2Stream - const clientHttp2Stream: http2.ClientHttp2Stream = {} as any; - clientHttp2Stream.on('headers', (headers: http2.IncomingHttpHeaders, flags: number) => {}); - clientHttp2Stream.on('push', (headers: http2.IncomingHttpHeaders, flags: number) => {}); - clientHttp2Stream.on('response', (headers: http2.IncomingHttpHeaders & http2.IncomingHttpStatusHeader, flags: number) => { - const s: number = headers[':status']!; - }); - - // ServerHttp2Stream - const serverHttp2Stream: http2.ServerHttp2Stream = {} as any; - const headers: http2.OutgoingHttpHeaders = {}; - - serverHttp2Stream.additionalHeaders(headers); - const headerSent: boolean = serverHttp2Stream.headersSent; - const pushAllowed: boolean = serverHttp2Stream.pushAllowed; - serverHttp2Stream.pushStream(headers, (err: Error | null, pushStream: http2.ServerHttp2Stream, headers: http2.OutgoingHttpHeaders) => {}); - - const options: http2.ServerStreamResponseOptions = { - endStream: true, - waitForTrailers: true, - }; - serverHttp2Stream.respond(); - serverHttp2Stream.respond(headers); - serverHttp2Stream.respond(headers, options); - - const options2: http2.ServerStreamFileResponseOptions = { - statCheck: (stats: fs.Stats, headers: http2.OutgoingHttpHeaders, statOptions: http2.StatOptions) => {}, - getTrailers: (trailers: http2.OutgoingHttpHeaders) => {}, - offset: 0, - length: 0 - }; - serverHttp2Stream.respondWithFD(0); - serverHttp2Stream.respondWithFD(0, headers); - serverHttp2Stream.respondWithFD(0, headers, options2); - serverHttp2Stream.respondWithFD(0, headers, {statCheck: () => false}); - const options3: http2.ServerStreamFileResponseOptionsWithError = { - onError: (err: NodeJS.ErrnoException) => {}, - statCheck: (stats: fs.Stats, headers: http2.OutgoingHttpHeaders, statOptions: http2.StatOptions) => {}, - getTrailers: (trailers: http2.OutgoingHttpHeaders) => {}, - offset: 0, - length: 0 - }; - serverHttp2Stream.respondWithFile(''); - serverHttp2Stream.respondWithFile('', headers); - serverHttp2Stream.respondWithFile('', headers, options3); - serverHttp2Stream.respondWithFile('', headers, {statCheck: () => false}); - } - - // Http2Server / Http2SecureServer - { - const http2Server: http2.Http2Server = http2.createServer(); - const http2SecureServer: http2.Http2SecureServer = http2.createSecureServer(); - const s1: net.Server = http2Server; - const s2: tls.Server = http2SecureServer; - [http2Server, http2SecureServer].forEach((server) => { - server.on('sessionError', (err: Error) => {}); - server.on('checkContinue', (stream: http2.ServerHttp2Stream, headers: http2.IncomingHttpHeaders, flags: number) => {}); - server.on('stream', (stream: http2.ServerHttp2Stream, headers: http2.IncomingHttpHeaders, flags: number) => {}); - server.on('request', (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => {}); - server.on('timeout', () => {}); - }); - - http2SecureServer.on('unknownProtocol', (socket: tls.TLSSocket) => {}); - } - - // Public API (except constants) - { - let settings: http2.Settings = { - }; - const serverOptions: http2.ServerOptions = { - maxDeflateDynamicTableSize: 0, - maxReservedRemoteStreams: 0, - maxSendHeaderBlockLength: 0, - paddingStrategy: 0, - peerMaxConcurrentStreams: 0, - selectPadding: (frameLen: number, maxFrameLen: number) => 0, - settings, - allowHTTP1: true - }; - // tslint:disable-next-line prefer-object-spread (ts2.1 feature) - const secureServerOptions: http2.SecureServerOptions = Object.assign({}, serverOptions); - secureServerOptions.ca = ''; - const onRequestHandler = (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => { - // Http2ServerRequest - - const readable: stream.Readable = request; - let incomingHeaders: http2.IncomingHttpHeaders = request.headers; - incomingHeaders = request.trailers; - const httpVersion: string = request.httpVersion; - let method: string = request.method; - let rawHeaders: string[] = request.rawHeaders; - rawHeaders = request.rawTrailers; - let socket: net.Socket | tls.TLSSocket = request.socket; - let stream: http2.ServerHttp2Stream = request.stream; - const url: string = request.url; - - request.setTimeout(0, () => {}); - request.on('aborted', (hadError: boolean, code: number) => {}); - - // Http2ServerResponse - - let outgoingHeaders: http2.OutgoingHttpHeaders = { - }; - response.addTrailers(outgoingHeaders); - socket = response.connection; - const finished: boolean = response.finished; - response.sendDate = true; - response.statusCode = 200; - response.statusMessage = ''; - socket = response.socket; - stream = response.stream; - - method = response.getHeader(':method'); - const headers: string[] = response.getHeaderNames(); - outgoingHeaders = response.getHeaders(); - const hasMethod = response.hasHeader(':method'); - response.removeHeader(':method'); - response.setHeader(':method', 'GET'); - response.setHeader(':status', 200); - response.setHeader('some-list', ['', '']); - const headersSent: boolean = response.headersSent; - - response.setTimeout(0, () => {}); - response.createPushResponse(outgoingHeaders, (err: Error | null, res: http2.Http2ServerResponse) => {}); - - response.writeContinue(); - response.writeHead(200); - response.writeHead(200, outgoingHeaders); - response.writeHead(200, 'OK', outgoingHeaders); - response.writeHead(200, 'OK'); - response.write(''); - response.write('', (err: Error) => {}); - response.write('', 'utf8'); - response.write('', 'utf8', (err: Error) => {}); - response.write(Buffer.from([])); - response.write(Buffer.from([]), (err: Error) => {}); - response.write(Buffer.from([]), 'utf8'); - response.write(Buffer.from([]), 'utf8', (err: Error) => {}); - response.end(); - response.end(() => {}); - response.end(''); - response.end('', () => {}); - response.end('', 'utf8'); - response.end('', 'utf8', () => {}); - response.end(Buffer.from([])); - response.end(Buffer.from([]), () => {}); - response.end(Buffer.from([]), 'utf8'); - response.end(Buffer.from([]), 'utf8', () => {}); - - request.on('aborted', (hadError: boolean, code: number) => {}); - request.on('close', () => {}); - request.on('drain', () => {}); - request.on('error', (error: Error) => {}); - request.on('finish', () => {}); - }; - - let http2Server: http2.Http2Server; - let http2SecureServer: http2.Http2SecureServer; - - http2Server = http2.createServer(); - http2Server = http2.createServer(serverOptions); - http2Server = http2.createServer(onRequestHandler); - http2Server = http2.createServer(serverOptions, onRequestHandler); - - http2SecureServer = http2.createSecureServer(); - http2SecureServer = http2.createSecureServer(secureServerOptions); - http2SecureServer = http2.createSecureServer(onRequestHandler); - http2SecureServer = http2.createSecureServer(secureServerOptions, onRequestHandler); - - const clientSessionOptions: http2.ClientSessionOptions = { - maxDeflateDynamicTableSize: 0, - maxReservedRemoteStreams: 0, - maxSendHeaderBlockLength: 0, - paddingStrategy: 0, - peerMaxConcurrentStreams: 0, - selectPadding: (frameLen: number, maxFrameLen: number) => 0, - settings - }; - // tslint:disable-next-line prefer-object-spread (ts2.1 feature) - const secureClientSessionOptions: http2.SecureClientSessionOptions = Object.assign({}, clientSessionOptions); - secureClientSessionOptions.ca = ''; - const onConnectHandler = (session: http2.Http2Session, socket: net.Socket) => {}; - - const serverHttp2Session: http2.ServerHttp2Session = {} as any; - - serverHttp2Session.altsvc('', ''); - serverHttp2Session.altsvc('', 0); - serverHttp2Session.altsvc('', new url.URL('')); - serverHttp2Session.altsvc('', { origin: '' }); - serverHttp2Session.altsvc('', { origin: 0 }); - serverHttp2Session.altsvc('', { origin: new url.URL('') }); - - let clientHttp2Session: http2.ClientHttp2Session; - - clientHttp2Session = http2.connect(''); - clientHttp2Session = http2.connect('', onConnectHandler); - clientHttp2Session = http2.connect('', clientSessionOptions); - clientHttp2Session = http2.connect('', clientSessionOptions, onConnectHandler); - clientHttp2Session = http2.connect('', secureClientSessionOptions); - clientHttp2Session = http2.connect('', secureClientSessionOptions, onConnectHandler); - clientHttp2Session.on('altsvc', (alt: string, origin: string, number: number) => {}); - - settings = http2.getDefaultSettings(); - settings = http2.getPackedSettings(settings); - settings = http2.getUnpackedSettings(Buffer.from([])); - settings = http2.getUnpackedSettings(Uint8Array.from([])); - } - - // constants - { - const constants = http2.constants; - let num: number; - let str: string; - num = constants.NGHTTP2_SESSION_SERVER; - num = constants.NGHTTP2_SESSION_CLIENT; - num = constants.NGHTTP2_STREAM_STATE_IDLE; - num = constants.NGHTTP2_STREAM_STATE_OPEN; - num = constants.NGHTTP2_STREAM_STATE_RESERVED_LOCAL; - num = constants.NGHTTP2_STREAM_STATE_RESERVED_REMOTE; - num = constants.NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL; - num = constants.NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE; - num = constants.NGHTTP2_STREAM_STATE_CLOSED; - num = constants.NGHTTP2_NO_ERROR; - num = constants.NGHTTP2_PROTOCOL_ERROR; - num = constants.NGHTTP2_INTERNAL_ERROR; - num = constants.NGHTTP2_FLOW_CONTROL_ERROR; - num = constants.NGHTTP2_SETTINGS_TIMEOUT; - num = constants.NGHTTP2_STREAM_CLOSED; - num = constants.NGHTTP2_FRAME_SIZE_ERROR; - num = constants.NGHTTP2_REFUSED_STREAM; - num = constants.NGHTTP2_CANCEL; - num = constants.NGHTTP2_COMPRESSION_ERROR; - num = constants.NGHTTP2_CONNECT_ERROR; - num = constants.NGHTTP2_ENHANCE_YOUR_CALM; - num = constants.NGHTTP2_INADEQUATE_SECURITY; - num = constants.NGHTTP2_HTTP_1_1_REQUIRED; - num = constants.NGHTTP2_ERR_FRAME_SIZE_ERROR; - num = constants.NGHTTP2_FLAG_NONE; - num = constants.NGHTTP2_FLAG_END_STREAM; - num = constants.NGHTTP2_FLAG_END_HEADERS; - num = constants.NGHTTP2_FLAG_ACK; - num = constants.NGHTTP2_FLAG_PADDED; - num = constants.NGHTTP2_FLAG_PRIORITY; - num = constants.DEFAULT_SETTINGS_HEADER_TABLE_SIZE; - num = constants.DEFAULT_SETTINGS_ENABLE_PUSH; - num = constants.DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE; - num = constants.DEFAULT_SETTINGS_MAX_FRAME_SIZE; - num = constants.MAX_MAX_FRAME_SIZE; - num = constants.MIN_MAX_FRAME_SIZE; - num = constants.MAX_INITIAL_WINDOW_SIZE; - num = constants.NGHTTP2_DEFAULT_WEIGHT; - num = constants.NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; - num = constants.NGHTTP2_SETTINGS_ENABLE_PUSH; - num = constants.NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; - num = constants.NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; - num = constants.NGHTTP2_SETTINGS_MAX_FRAME_SIZE; - num = constants.NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE; - num = constants.PADDING_STRATEGY_NONE; - num = constants.PADDING_STRATEGY_MAX; - num = constants.PADDING_STRATEGY_CALLBACK; - num = constants.HTTP_STATUS_CONTINUE; - num = constants.HTTP_STATUS_SWITCHING_PROTOCOLS; - num = constants.HTTP_STATUS_PROCESSING; - num = constants.HTTP_STATUS_OK; - num = constants.HTTP_STATUS_CREATED; - num = constants.HTTP_STATUS_ACCEPTED; - num = constants.HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION; - num = constants.HTTP_STATUS_NO_CONTENT; - num = constants.HTTP_STATUS_RESET_CONTENT; - num = constants.HTTP_STATUS_PARTIAL_CONTENT; - num = constants.HTTP_STATUS_MULTI_STATUS; - num = constants.HTTP_STATUS_ALREADY_REPORTED; - num = constants.HTTP_STATUS_IM_USED; - num = constants.HTTP_STATUS_MULTIPLE_CHOICES; - num = constants.HTTP_STATUS_MOVED_PERMANENTLY; - num = constants.HTTP_STATUS_FOUND; - num = constants.HTTP_STATUS_SEE_OTHER; - num = constants.HTTP_STATUS_NOT_MODIFIED; - num = constants.HTTP_STATUS_USE_PROXY; - num = constants.HTTP_STATUS_TEMPORARY_REDIRECT; - num = constants.HTTP_STATUS_PERMANENT_REDIRECT; - num = constants.HTTP_STATUS_BAD_REQUEST; - num = constants.HTTP_STATUS_UNAUTHORIZED; - num = constants.HTTP_STATUS_PAYMENT_REQUIRED; - num = constants.HTTP_STATUS_FORBIDDEN; - num = constants.HTTP_STATUS_NOT_FOUND; - num = constants.HTTP_STATUS_METHOD_NOT_ALLOWED; - num = constants.HTTP_STATUS_NOT_ACCEPTABLE; - num = constants.HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED; - num = constants.HTTP_STATUS_REQUEST_TIMEOUT; - num = constants.HTTP_STATUS_CONFLICT; - num = constants.HTTP_STATUS_GONE; - num = constants.HTTP_STATUS_LENGTH_REQUIRED; - num = constants.HTTP_STATUS_PRECONDITION_FAILED; - num = constants.HTTP_STATUS_PAYLOAD_TOO_LARGE; - num = constants.HTTP_STATUS_URI_TOO_LONG; - num = constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE; - num = constants.HTTP_STATUS_RANGE_NOT_SATISFIABLE; - num = constants.HTTP_STATUS_EXPECTATION_FAILED; - num = constants.HTTP_STATUS_TEAPOT; - num = constants.HTTP_STATUS_MISDIRECTED_REQUEST; - num = constants.HTTP_STATUS_UNPROCESSABLE_ENTITY; - num = constants.HTTP_STATUS_LOCKED; - num = constants.HTTP_STATUS_FAILED_DEPENDENCY; - num = constants.HTTP_STATUS_UNORDERED_COLLECTION; - num = constants.HTTP_STATUS_UPGRADE_REQUIRED; - num = constants.HTTP_STATUS_PRECONDITION_REQUIRED; - num = constants.HTTP_STATUS_TOO_MANY_REQUESTS; - num = constants.HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE; - num = constants.HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS; - num = constants.HTTP_STATUS_INTERNAL_SERVER_ERROR; - num = constants.HTTP_STATUS_NOT_IMPLEMENTED; - num = constants.HTTP_STATUS_BAD_GATEWAY; - num = constants.HTTP_STATUS_SERVICE_UNAVAILABLE; - num = constants.HTTP_STATUS_GATEWAY_TIMEOUT; - num = constants.HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED; - num = constants.HTTP_STATUS_VARIANT_ALSO_NEGOTIATES; - num = constants.HTTP_STATUS_INSUFFICIENT_STORAGE; - num = constants.HTTP_STATUS_LOOP_DETECTED; - num = constants.HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED; - num = constants.HTTP_STATUS_NOT_EXTENDED; - num = constants.HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED; - str = constants.HTTP2_HEADER_STATUS; - str = constants.HTTP2_HEADER_METHOD; - str = constants.HTTP2_HEADER_AUTHORITY; - str = constants.HTTP2_HEADER_SCHEME; - str = constants.HTTP2_HEADER_PATH; - str = constants.HTTP2_HEADER_ACCEPT_CHARSET; - str = constants.HTTP2_HEADER_ACCEPT_ENCODING; - str = constants.HTTP2_HEADER_ACCEPT_LANGUAGE; - str = constants.HTTP2_HEADER_ACCEPT_RANGES; - str = constants.HTTP2_HEADER_ACCEPT; - str = constants.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN; - str = constants.HTTP2_HEADER_AGE; - str = constants.HTTP2_HEADER_ALLOW; - str = constants.HTTP2_HEADER_AUTHORIZATION; - str = constants.HTTP2_HEADER_CACHE_CONTROL; - str = constants.HTTP2_HEADER_CONNECTION; - str = constants.HTTP2_HEADER_CONTENT_DISPOSITION; - str = constants.HTTP2_HEADER_CONTENT_ENCODING; - str = constants.HTTP2_HEADER_CONTENT_LANGUAGE; - str = constants.HTTP2_HEADER_CONTENT_LENGTH; - str = constants.HTTP2_HEADER_CONTENT_LOCATION; - str = constants.HTTP2_HEADER_CONTENT_MD5; - str = constants.HTTP2_HEADER_CONTENT_RANGE; - str = constants.HTTP2_HEADER_CONTENT_TYPE; - str = constants.HTTP2_HEADER_COOKIE; - str = constants.HTTP2_HEADER_DATE; - str = constants.HTTP2_HEADER_ETAG; - str = constants.HTTP2_HEADER_EXPECT; - str = constants.HTTP2_HEADER_EXPIRES; - str = constants.HTTP2_HEADER_FROM; - str = constants.HTTP2_HEADER_HOST; - str = constants.HTTP2_HEADER_IF_MATCH; - str = constants.HTTP2_HEADER_IF_MODIFIED_SINCE; - str = constants.HTTP2_HEADER_IF_NONE_MATCH; - str = constants.HTTP2_HEADER_IF_RANGE; - str = constants.HTTP2_HEADER_IF_UNMODIFIED_SINCE; - str = constants.HTTP2_HEADER_LAST_MODIFIED; - str = constants.HTTP2_HEADER_LINK; - str = constants.HTTP2_HEADER_LOCATION; - str = constants.HTTP2_HEADER_MAX_FORWARDS; - str = constants.HTTP2_HEADER_PREFER; - str = constants.HTTP2_HEADER_PROXY_AUTHENTICATE; - str = constants.HTTP2_HEADER_PROXY_AUTHORIZATION; - str = constants.HTTP2_HEADER_RANGE; - str = constants.HTTP2_HEADER_REFERER; - str = constants.HTTP2_HEADER_REFRESH; - str = constants.HTTP2_HEADER_RETRY_AFTER; - str = constants.HTTP2_HEADER_SERVER; - str = constants.HTTP2_HEADER_SET_COOKIE; - str = constants.HTTP2_HEADER_STRICT_TRANSPORT_SECURITY; - str = constants.HTTP2_HEADER_TRANSFER_ENCODING; - str = constants.HTTP2_HEADER_TE; - str = constants.HTTP2_HEADER_UPGRADE; - str = constants.HTTP2_HEADER_USER_AGENT; - str = constants.HTTP2_HEADER_VARY; - str = constants.HTTP2_HEADER_VIA; - str = constants.HTTP2_HEADER_WWW_AUTHENTICATE; - str = constants.HTTP2_HEADER_HTTP2_SETTINGS; - str = constants.HTTP2_HEADER_KEEP_ALIVE; - str = constants.HTTP2_HEADER_PROXY_CONNECTION; - str = constants.HTTP2_METHOD_ACL; - str = constants.HTTP2_METHOD_BASELINE_CONTROL; - str = constants.HTTP2_METHOD_BIND; - str = constants.HTTP2_METHOD_CHECKIN; - str = constants.HTTP2_METHOD_CHECKOUT; - str = constants.HTTP2_METHOD_CONNECT; - str = constants.HTTP2_METHOD_COPY; - str = constants.HTTP2_METHOD_DELETE; - str = constants.HTTP2_METHOD_GET; - str = constants.HTTP2_METHOD_HEAD; - str = constants.HTTP2_METHOD_LABEL; - str = constants.HTTP2_METHOD_LINK; - str = constants.HTTP2_METHOD_LOCK; - str = constants.HTTP2_METHOD_MERGE; - str = constants.HTTP2_METHOD_MKACTIVITY; - str = constants.HTTP2_METHOD_MKCALENDAR; - str = constants.HTTP2_METHOD_MKCOL; - str = constants.HTTP2_METHOD_MKREDIRECTREF; - str = constants.HTTP2_METHOD_MKWORKSPACE; - str = constants.HTTP2_METHOD_MOVE; - str = constants.HTTP2_METHOD_OPTIONS; - str = constants.HTTP2_METHOD_ORDERPATCH; - str = constants.HTTP2_METHOD_PATCH; - str = constants.HTTP2_METHOD_POST; - str = constants.HTTP2_METHOD_PRI; - str = constants.HTTP2_METHOD_PROPFIND; - str = constants.HTTP2_METHOD_PROPPATCH; - str = constants.HTTP2_METHOD_PUT; - str = constants.HTTP2_METHOD_REBIND; - str = constants.HTTP2_METHOD_REPORT; - str = constants.HTTP2_METHOD_SEARCH; - str = constants.HTTP2_METHOD_TRACE; - str = constants.HTTP2_METHOD_UNBIND; - str = constants.HTTP2_METHOD_UNCHECKOUT; - str = constants.HTTP2_METHOD_UNLINK; - str = constants.HTTP2_METHOD_UNLOCK; - str = constants.HTTP2_METHOD_UPDATE; - str = constants.HTTP2_METHOD_UPDATEREDIRECTREF; - str = constants.HTTP2_METHOD_VERSION_CONTROL; - } -} - /////////////////////////////////////////////////////////// /// Inspector Tests /// /////////////////////////////////////////////////////////// diff --git a/types/node/package.json b/types/node/package.json index c1f0c68752..cda6cc6dc8 100644 --- a/types/node/package.json +++ b/types/node/package.json @@ -2,10 +2,10 @@ "private": true, "types": "index", "typesVersions": { - ">=3.1.0-0": { + ">=3.2.0-0": { "*": [ - "ts3.1/*" + "ts3.2/*" ] } } -} \ No newline at end of file +} diff --git a/types/node/perf_hooks.d.ts b/types/node/perf_hooks.d.ts index 4f68895ce6..bf44d446eb 100644 --- a/types/node/perf_hooks.d.ts +++ b/types/node/perf_hooks.d.ts @@ -238,4 +238,67 @@ declare module "perf_hooks" { } const performance: Performance; + + interface EventLoopMonitorOptions { + /** + * The sampling rate in milliseconds. + * Must be greater than zero. + * @default 10 + */ + resolution?: number; + } + + interface EventLoopDelayMonitor { + /** + * Enables the event loop delay sample timer. Returns `true` if the timer was started, `false` if it was already started. + */ + enable(): boolean; + /** + * Disables the event loop delay sample timer. Returns `true` if the timer was stopped, `false` if it was already stopped. + */ + disable(): boolean; + + /** + * Resets the collected histogram data. + */ + reset(): void; + + /** + * Returns the value at the given percentile. + * @param percentile A percentile value between 1 and 100. + */ + percentile(percentile: number): number; + + /** + * A `Map` object detailing the accumulated percentile distribution. + */ + readonly percentiles: Map; + + /** + * The number of times the event loop delay exceeded the maximum 1 hour eventloop delay threshold. + */ + readonly exceeds: number; + + /** + * The minimum recorded event loop delay. + */ + readonly min: number; + + /** + * The maximum recorded event loop delay. + */ + readonly max: number; + + /** + * The mean of the recorded event loop delays. + */ + readonly mean: number; + + /** + * The standard deviation of the recorded event loop delays. + */ + readonly stddev: number; + } + + function monitorEventLoopDelay(options?: EventLoopMonitorOptions): EventLoopDelayMonitor; } diff --git a/types/node/repl.d.ts b/types/node/repl.d.ts index cb5a3d037b..71f490443d 100644 --- a/types/node/repl.d.ts +++ b/types/node/repl.d.ts @@ -260,6 +260,16 @@ declare module "repl" { */ clearBufferedCommand(): void; + /** + * Initializes a history log file for the REPL instance. When executing the + * Node.js binary and using the command line REPL, a history file is initialized + * by default. However, this is not the case when creating a REPL + * programmatically. Use this method to initialize a history log file when working + * with REPL instances programmatically. + * @param path The path to the history file + */ + setupHistory(path: string, cb: (err: Error | null, repl: this) => void): void; + /** * events.EventEmitter * 1. close - inherited from `readline.Interface` diff --git a/types/node/stream.d.ts b/types/node/stream.d.ts index 122ae563c7..2b0e1c72ac 100644 --- a/types/node/stream.d.ts +++ b/types/node/stream.d.ts @@ -288,6 +288,8 @@ declare module "stream" { ...streams: Array, ): Promise; } + + interface Pipe { } } export = internal; diff --git a/types/node/test/buffer.ts b/types/node/test/buffer.ts index 37b02ef708..dd3329ba24 100644 --- a/types/node/test/buffer.ts +++ b/types/node/test/buffer.ts @@ -1,5 +1,5 @@ // Specifically test buffer module regression. -import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer"; +import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer, transcode, TranscodeEncoding } from "buffer"; const utf8Buffer = new Buffer('test'); const base64Buffer = new Buffer('', 'base64'); @@ -38,7 +38,8 @@ const result2 = Buffer.concat([utf8Buffer, base64Buffer], 9999999); const arrUint8: Uint8Array = new Uint8Array(2); const buf5: Buffer = Buffer.from(arrUint8); const buf6: Buffer = Buffer.from(buf1); - const buf7: Buffer = Buffer.from(new SharedArrayBuffer(123)); + const sb: SharedArrayBuffer = {} as any; + const buf7: Buffer = Buffer.from(sb); } // Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]]) @@ -201,3 +202,19 @@ b.fill('a').fill('b'); const buffer = new Buffer('123'); const octets = new Uint8Array(buffer.buffer); } + +// Inherited from Uint8Array but return buffer +{ + const b = Buffer.from('asd'); + let res: Buffer = b.reverse(); + res = b.subarray(1); +} + +// Buffer module, transcode function +{ + transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer + + const source: TranscodeEncoding = 'utf8'; + const target: TranscodeEncoding = 'ascii'; + transcode(Buffer.from('€'), source, target); // $ExpectType Buffer +} diff --git a/types/node/test/child_process.ts b/types/node/test/child_process.ts new file mode 100644 index 0000000000..cf5b3e4656 --- /dev/null +++ b/types/node/test/child_process.ts @@ -0,0 +1,305 @@ +import * as childProcess from 'child_process'; +import * as net from 'net'; +import * as fs from 'fs'; +import * as assert from 'assert'; +import { promisify } from 'util'; +import { Writable, Readable, Pipe } from 'stream'; + +{ + childProcess.exec("echo test"); + childProcess.exec("echo test", { windowsHide: true }); + childProcess.spawn("echo"); + childProcess.spawn("echo", { windowsHide: true }); + childProcess.spawn("echo", ["test"], { windowsHide: true }); + childProcess.spawn("echo", ["test"], { windowsHide: true, argv0: "echo-test" }); + childProcess.spawn("echo", ["test"], { stdio: [0xdeadbeef, "inherit", undefined, "pipe"] }); + childProcess.spawnSync("echo test"); + childProcess.spawnSync("echo test", {windowsVerbatimArguments: false}); + childProcess.spawnSync("echo test", {windowsVerbatimArguments: false, argv0: "echo-test"}); + childProcess.spawnSync("echo test", {input: new Uint8Array([])}); + childProcess.spawnSync("echo test", {input: new DataView(new ArrayBuffer(1))}); +} + +{ + childProcess.execFile("npm", () => {}); + childProcess.execFile("npm", { windowsHide: true }, () => {}); + childProcess.execFile("npm", ["-v"], () => {}); + childProcess.execFile("npm", ["-v"], { windowsHide: true, encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); + childProcess.execFile("npm", ["-v"], { windowsHide: true, encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); + childProcess.execFile("npm", { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); }); + childProcess.execFile("npm", { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); }); +} + +{ + childProcess.execFileSync("echo test", {input: new Uint8Array([])}); + childProcess.execFileSync("echo test", {input: new DataView(new ArrayBuffer(1))}); +} + +{ + const forked = childProcess.fork('./', ['asd'], { + windowsVerbatimArguments: true, + silent: false, + stdio: "inherit", + execPath: '', + execArgv: ['asda'] + }); + const ipc: Pipe = forked.channel!; +} + +async function testPromisify() { + const execFile = promisify(childProcess.execFile); + let r: { stdout: string | Buffer, stderr: string | Buffer } = await execFile("npm"); + r = await execFile("npm", ["-v"]); + r = await execFile("npm", ["-v"], { encoding: 'utf-8' }); + r = await execFile("npm", ["-v"], { encoding: 'buffer' }); + r = await execFile("npm", { encoding: 'utf-8' }); + r = await execFile("npm", { encoding: 'buffer' }); +} + +{ + let cp = childProcess.spawn('asd'); + const _socket: net.Socket = net.createConnection(1); + const _server: net.Server = net.createServer(); + let _boolean: boolean; + + _boolean = cp.send(1); + _boolean = cp.send('one'); + _boolean = cp.send({ + type: 'test' + }); + + _boolean = cp.send(1, (error) => { + const _err: Error = error; + }); + _boolean = cp.send('one', (error) => { + const _err: Error = error; + }); + _boolean = cp.send({ + type: 'test' + }, (error) => { + const _err: Error = error; + }); + + _boolean = cp.send(1, _socket); + _boolean = cp.send('one', _socket); + _boolean = cp.send({ + type: 'test' + }, _socket); + + _boolean = cp.send(1, _socket, (error) => { + const _err: Error = error; + }); + _boolean = cp.send('one', _socket, (error) => { + const _err: Error = error; + }); + _boolean = cp.send({ + type: 'test' + }, _socket, (error) => { + const _err: Error = error; + }); + + _boolean = cp.send(1, _socket, { + keepOpen: true + }); + _boolean = cp.send('one', _socket, { + keepOpen: true + }); + _boolean = cp.send({ + type: 'test' + }, _socket, { + keepOpen: true + }); + + _boolean = cp.send(1, _socket, { + keepOpen: true + }, (error) => { + const _err: Error = error; + }); + _boolean = cp.send('one', _socket, { + keepOpen: true + }, (error) => { + const _err: Error = error; + }); + _boolean = cp.send({ + type: 'test' + }, _socket, { + keepOpen: true + }, (error) => { + const _err: Error = error; + }); + + _boolean = cp.send(1, _server); + _boolean = cp.send('one', _server); + _boolean = cp.send({ + type: 'test' + }, _server); + + _boolean = cp.send(1, _server, (error) => { + const _err: Error = error; + }); + _boolean = cp.send('one', _server, (error) => { + const _err: Error = error; + }); + _boolean = cp.send({ + type: 'test' + }, _server, (error) => { + const _err: Error = error; + }); + + _boolean = cp.send(1, _server, { + keepOpen: true + }); + _boolean = cp.send('one', _server, { + keepOpen: true + }); + _boolean = cp.send({ + type: 'test' + }, _server, { + keepOpen: true + }); + + _boolean = cp.send(1, _server, { + keepOpen: true + }, (error) => { + const _err: Error = error; + }); + _boolean = cp.send('one', _server, { + keepOpen: true + }, (error) => { + const _err: Error = error; + }); + _boolean = cp.send({ + type: 'test' + }, _server, { + keepOpen: true + }, (error) => { + const _err: Error = error; + }); + + const stdin: Writable | null = cp.stdio[0]; + const stdout: Readable | null = cp.stdio[1]; + const stderr: Readable | null = cp.stdio[2]; + const fd4: Readable | Writable | null = cp.stdio[3]!; + const fd5: Readable | Writable | null = cp.stdio[4]!; + + cp = cp.addListener("close", (code, signal) => { + const _code: number = code; + const _signal: string = signal; + }); + cp = cp.addListener("disconnect", () => { }); + cp = cp.addListener("error", (err) => { + const _err: Error = err; + }); + cp = cp.addListener("exit", (code, signal) => { + const _code: number | null = code; + const _signal: string | null = signal; + }); + cp = cp.addListener("message", (message, sendHandle) => { + const _message: any = message; + const _sendHandle: net.Socket | net.Server = sendHandle; + }); + + _boolean = cp.emit("close", () => { }); + _boolean = cp.emit("disconnect", () => { }); + _boolean = cp.emit("error", () => { }); + _boolean = cp.emit("exit", () => { }); + _boolean = cp.emit("message", () => { }); + + cp = cp.on("close", (code, signal) => { + const _code: number = code; + const _signal: string = signal; + }); + cp = cp.on("disconnect", () => { }); + cp = cp.on("error", (err) => { + const _err: Error = err; + }); + cp = cp.on("exit", (code, signal) => { + const _code: number | null = code; + const _signal: string | null = signal; + }); + cp = cp.on("message", (message, sendHandle) => { + const _message: any = message; + const _sendHandle: net.Socket | net.Server = sendHandle; + }); + + cp = cp.once("close", (code, signal) => { + const _code: number = code; + const _signal: string = signal; + }); + cp = cp.once("disconnect", () => { }); + cp = cp.once("error", (err) => { + const _err: Error = err; + }); + cp = cp.once("exit", (code, signal) => { + const _code: number | null = code; + const _signal: string | null = signal; + }); + cp = cp.once("message", (message, sendHandle) => { + const _message: any = message; + const _sendHandle: net.Socket | net.Server = sendHandle; + }); + + cp = cp.prependListener("close", (code, signal) => { + const _code: number = code; + const _signal: string = signal; + }); + cp = cp.prependListener("disconnect", () => { }); + cp = cp.prependListener("error", (err) => { + const _err: Error = err; + }); + cp = cp.prependListener("exit", (code, signal) => { + const _code: number | null = code; + const _signal: string | null = signal; + }); + cp = cp.prependListener("message", (message, sendHandle) => { + const _message: any = message; + const _sendHandle: net.Socket | net.Server = sendHandle; + }); + + cp = cp.prependOnceListener("close", (code, signal) => { + const _code: number = code; + const _signal: string = signal; + }); + cp = cp.prependOnceListener("disconnect", () => { }); + cp = cp.prependOnceListener("error", (err) => { + const _err: Error = err; + }); + cp = cp.prependOnceListener("exit", (code, signal) => { + const _code: number | null = code; + const _signal: string | null = signal; + }); + cp = cp.prependOnceListener("message", (message, sendHandle) => { + const _message: any = message; + const _sendHandle: net.Socket | net.Server = sendHandle; + }); +} +{ + process.stdin.setEncoding('utf8'); + + process.stdin.on('readable', () => { + const chunk = process.stdin.read(); + if (chunk !== null) { + process.stdout.write(`data: ${chunk}`); + } + }); + + process.stdin.on('end', () => { + process.stdout.write('end'); + }); + + process.stdin.pipe(process.stdout); + + console.log(process.stdin.isTTY); + console.log(process.stdout.isTTY); + + console.log(process.stdin instanceof net.Socket); + console.log(process.stdout instanceof fs.ReadStream); + + const stdin: Readable = process.stdin; + console.log(stdin instanceof net.Socket); + console.log(stdin instanceof fs.ReadStream); + + const stdout: Writable = process.stdout; + console.log(stdout instanceof net.Socket); + console.log(stdout instanceof fs.WriteStream); +} diff --git a/types/node/test/crypto.ts b/types/node/test/crypto.ts index 8238567557..4dbe6e06ff 100644 --- a/types/node/test/crypto.ts +++ b/types/node/test/crypto.ts @@ -113,7 +113,7 @@ import { promisify } from 'util'; } { - const key = 'keykeykeykeykeykeykeykey'; + const key: string | null = 'keykeykeykeykeykeykeykey'; const nonce = crypto.randomBytes(12); const aad = Buffer.from('0123456789', 'hex'); diff --git a/types/node/test/http.ts b/types/node/test/http.ts index 6e4db63a2c..462722a8ff 100644 --- a/types/node/test/http.ts +++ b/types/node/test/http.ts @@ -65,7 +65,7 @@ import * as net from 'net'; res.addTrailers({ 'x-foo': 'bar' }); // writeHead - res.writeHead(200, 'OK\r\nContent-Type: text/html\r\n'); + res.writeHead(200, 'OK\r\nContent-Type: text/html\r\n').end(); res.writeHead(200, { 'Transfer-Encoding': 'chunked' }); res.writeHead(200); @@ -112,6 +112,9 @@ import * as net from 'net'; // event req.on('data', () => { }); + + // path + const path: string = req.path; } { diff --git a/types/node/test/http2.ts b/types/node/test/http2.ts new file mode 100644 index 0000000000..0bada91a97 --- /dev/null +++ b/types/node/test/http2.ts @@ -0,0 +1,604 @@ +import { + Settings, + Http2Session, + Http2Stream, + ClientSessionRequestOptions, + ClientHttp2Session, + SessionState, + StreamState, + ClientHttp2Stream, + IncomingHttpStatusHeader, + ServerHttp2Stream, + ServerStreamResponseOptions, + ServerStreamFileResponseOptions, + StatOptions, + ServerStreamFileResponseOptionsWithError, + Http2Server, + Http2SecureServer, + createSecureServer, + Http2ServerRequest, + Http2ServerResponse, + SecureServerOptions, + ClientSessionOptions, + SecureClientSessionOptions, + ServerHttp2Session, + connect, + getDefaultSettings, + getPackedSettings, + getUnpackedSettings, + OutgoingHttpHeaders, + IncomingHttpHeaders, + createServer, + constants, + ServerOptions +} from "http2"; +import { EventEmitter } from "events"; +import { Stats } from "fs"; +import { Socket, Server } from "net"; +import { TLSSocket } from "tls"; +import { Duplex, Readable } from "stream"; +import { URL } from 'url'; + +// Headers & Settings +{ + const headers: OutgoingHttpHeaders = { + ':status': 200, + 'content-type': 'text-plain', + ABC: ['has', 'more', 'than', 'one', 'value'], + undef: undefined + }; + + const settings: Settings = { + headerTableSize: 0, + enablePush: true, + initialWindowSize: 0, + maxFrameSize: 0, + maxConcurrentStreams: 0, + maxHeaderListSize: 0 + }; +} + +// Http2Session +{ + const http2Session: Http2Session = {} as any; + const ee: EventEmitter = http2Session; + + http2Session.on('close', () => {}); + http2Session.on('connect', (session: Http2Session, socket: Socket) => {}); + http2Session.on('error', (err: Error) => {}); + http2Session.on('frameError', (frameType: number, errorCode: number, streamID: number) => {}); + http2Session.on('goaway', (errorCode: number, lastStreamID: number, opaqueData: Buffer) => {}); + http2Session.on('localSettings', (settings: Settings) => {}); + http2Session.on('remoteSettings', (settings: Settings) => {}); + http2Session.on('stream', (stream: Http2Stream, headers: IncomingHttpHeaders, flags: number) => {}); + http2Session.on('timeout', () => {}); + http2Session.on('ping', () => {}); + + http2Session.destroy(); + + const alpnProtocol: string | undefined = http2Session.alpnProtocol; + const destroyed: boolean | undefined = http2Session.destroyed; + const encrypted: boolean | undefined = http2Session.encrypted; + const originSet: string[] | undefined = http2Session.originSet; + const pendingSettingsAck: boolean = http2Session.pendingSettingsAck; + let settings: Settings = http2Session.localSettings; + const closed: boolean = http2Session.closed; + const connecting: boolean = http2Session.connecting; + settings = http2Session.remoteSettings; + + http2Session.ref(); + http2Session.unref(); + + const headers: OutgoingHttpHeaders = {}; + const options: ClientSessionRequestOptions = { + endStream: true, + exclusive: true, + parent: 0, + weight: 0, + getTrailers: (trailers: OutgoingHttpHeaders) => {} + }; + (http2Session as ClientHttp2Session).request(); + (http2Session as ClientHttp2Session).request(headers); + (http2Session as ClientHttp2Session).request(headers, options); + + const stream: Http2Stream = {} as any; + http2Session.rstStream(stream); + http2Session.rstStream(stream, 0); + + http2Session.setTimeout(100, () => {}); + http2Session.close(() => {}); + + const socket: Socket | TLSSocket = http2Session.socket; + let state: SessionState = http2Session.state; + state = { + effectiveLocalWindowSize: 0, + effectiveRecvDataLength: 0, + nextStreamID: 0, + localWindowSize: 0, + lastProcStreamID: 0, + remoteWindowSize: 0, + outboundQueueSize: 0, + deflateDynamicTableSize: 0, + inflateDynamicTableSize: 0 + }; + + http2Session.priority(stream, { + exclusive: true, + parent: 0, + weight: 0, + silent: true + }); + + http2Session.settings(settings); + + http2Session.ping((err: Error | null, duration: number, payload: Buffer) => {}); + http2Session.ping(Buffer.from(''), (err: Error | null, duration: number, payload: Buffer) => {}); + http2Session.ping(new DataView(new Int8Array(1).buffer), (err: Error | null, duration: number, payload: Buffer) => {}); +} + +// Http2Stream +{ + const http2Stream: Http2Stream = {} as any; + const duplex: Duplex = http2Stream; + + http2Stream.on('aborted', () => {}); + http2Stream.on('error', (err: Error) => {}); + http2Stream.on('frameError', (frameType: number, errorCode: number, streamID: number) => {}); + http2Stream.on('streamClosed', (code: number) => {}); + http2Stream.on('timeout', () => {}); + http2Stream.on('trailers', (trailers: IncomingHttpHeaders, flags: number) => {}); + http2Stream.on('wantTrailers', () => {}); + + const aborted: boolean = http2Stream.aborted; + const closed: boolean = http2Stream.closed; + const destroyed: boolean = http2Stream.destroyed; + const pending: boolean = http2Stream.pending; + + http2Stream.priority({ + exclusive: true, + parent: 0, + weight: 0, + silent: true + }); + + const sesh: Http2Session = http2Stream.session; + + http2Stream.setTimeout(100, () => {}); + + let state: StreamState = http2Stream.state; + state = { + localWindowSize: 0, + state: 0, + streamLocalClose: 0, + streamRemoteClose: 0, + sumDependencyWeight: 0, + weight: 0 + }; + + http2Stream.close(); + http2Stream.close(0); + http2Stream.close(0, () => {}); + http2Stream.close(undefined, () => {}); + + // ClientHttp2Stream + const clientHttp2Stream: ClientHttp2Stream = {} as any; + clientHttp2Stream.on('headers', (headers: IncomingHttpHeaders, flags: number) => {}); + clientHttp2Stream.on('push', (headers: IncomingHttpHeaders, flags: number) => {}); + clientHttp2Stream.on('response', (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => { + const s: number = headers[':status']!; + }); + + // ServerHttp2Stream + const serverHttp2Stream: ServerHttp2Stream = {} as any; + const headers: OutgoingHttpHeaders = {}; + + serverHttp2Stream.additionalHeaders(headers); + const headerSent: boolean = serverHttp2Stream.headersSent; + const pushAllowed: boolean = serverHttp2Stream.pushAllowed; + serverHttp2Stream.pushStream(headers, (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => {}); + + const options: ServerStreamResponseOptions = { + endStream: true, + waitForTrailers: true, + }; + serverHttp2Stream.respond(); + serverHttp2Stream.respond(headers); + serverHttp2Stream.respond(headers, options); + + const options2: ServerStreamFileResponseOptions = { + statCheck: (stats: Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => {}, + getTrailers: (trailers: OutgoingHttpHeaders) => {}, + offset: 0, + length: 0 + }; + serverHttp2Stream.respondWithFD(0); + serverHttp2Stream.respondWithFD(0, headers); + serverHttp2Stream.respondWithFD(0, headers, options2); + serverHttp2Stream.respondWithFD(0, headers, {statCheck: () => false}); + const options3: ServerStreamFileResponseOptionsWithError = { + onError: (err: NodeJS.ErrnoException) => {}, + statCheck: (stats: Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => {}, + getTrailers: (trailers: OutgoingHttpHeaders) => {}, + offset: 0, + length: 0 + }; + serverHttp2Stream.respondWithFile(''); + serverHttp2Stream.respondWithFile('', headers); + serverHttp2Stream.respondWithFile('', headers, options3); + serverHttp2Stream.respondWithFile('', headers, {statCheck: () => false}); +} + +// Http2Server / Http2SecureServer +{ + const http2Server: Http2Server = createServer(); + const http2SecureServer: Http2SecureServer = createSecureServer(); + const s1: Server = http2Server; + const s2: Server = http2SecureServer; + [http2Server, http2SecureServer].forEach((server) => { + server.on('sessionError', (err: Error) => {}); + server.on('checkContinue', (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => {}); + server.on('stream', (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => {}); + server.on('request', (request: Http2ServerRequest, response: Http2ServerResponse) => {}); + server.on('timeout', () => {}); + }); + + http2SecureServer.on('unknownProtocol', (socket: TLSSocket) => {}); +} + +// Public API (except constants) +{ + let settings: Settings = { + }; + const serverOptions: ServerOptions = { + maxDeflateDynamicTableSize: 0, + maxReservedRemoteStreams: 0, + maxSendHeaderBlockLength: 0, + paddingStrategy: 0, + peerMaxConcurrentStreams: 0, + selectPadding: (frameLen: number, maxFrameLen: number) => 0, + settings, + allowHTTP1: true + }; + // tslint:disable-next-line prefer-object-spread (ts2.1 feature) + const secureServerOptions: SecureServerOptions = Object.assign({}, serverOptions); + secureServerOptions.ca = ''; + const onRequestHandler = (request: Http2ServerRequest, response: Http2ServerResponse) => { + // Http2ServerRequest + + const readable: Readable = request; + let incomingHeaders: IncomingHttpHeaders = request.headers; + incomingHeaders = request.trailers; + const httpVersion: string = request.httpVersion; + let method: string = request.method; + let rawHeaders: string[] = request.rawHeaders; + rawHeaders = request.rawTrailers; + let socket: Socket | TLSSocket = request.socket; + let stream: ServerHttp2Stream = request.stream; + const url: string = request.url; + + request.setTimeout(0, () => {}); + request.on('aborted', (hadError: boolean, code: number) => {}); + + // Http2ServerResponse + + let outgoingHeaders: OutgoingHttpHeaders = { + }; + response.addTrailers(outgoingHeaders); + socket = response.connection; + const finished: boolean = response.finished; + response.sendDate = true; + response.statusCode = 200; + response.statusMessage = ''; + socket = response.socket; + stream = response.stream; + + method = response.getHeader(':method'); + const headers: string[] = response.getHeaderNames(); + outgoingHeaders = response.getHeaders(); + const hasMethod = response.hasHeader(':method'); + response.removeHeader(':method'); + response.setHeader(':method', 'GET'); + response.setHeader(':status', 200); + response.setHeader('some-list', ['', '']); + const headersSent: boolean = response.headersSent; + + response.setTimeout(0, () => {}); + response.createPushResponse(outgoingHeaders, (err: Error | null, res: Http2ServerResponse) => {}); + + response.writeContinue(); + response.writeHead(200).end(); + response.writeHead(200, outgoingHeaders); + response.writeHead(200, 'OK', outgoingHeaders); + response.writeHead(200, 'OK'); + response.write(''); + response.write('', (err: Error) => {}); + response.write('', 'utf8'); + response.write('', 'utf8', (err: Error) => {}); + response.write(Buffer.from([])); + response.write(Buffer.from([]), (err: Error) => {}); + response.write(Buffer.from([]), 'utf8'); + response.write(Buffer.from([]), 'utf8', (err: Error) => {}); + response.end(); + response.end(() => {}); + response.end(''); + response.end('', () => {}); + response.end('', 'utf8'); + response.end('', 'utf8', () => {}); + response.end(Buffer.from([])); + response.end(Buffer.from([]), () => {}); + response.end(Buffer.from([]), 'utf8'); + response.end(Buffer.from([]), 'utf8', () => {}); + + request.on('aborted', (hadError: boolean, code: number) => {}); + request.on('close', () => {}); + request.on('drain', () => {}); + request.on('error', (error: Error) => {}); + request.on('finish', () => {}); + }; + + let http2Server: Http2Server; + let http2SecureServer: Http2SecureServer; + + http2Server = createServer(); + http2Server = createServer(serverOptions); + http2Server = createServer(onRequestHandler); + http2Server = createServer(serverOptions, onRequestHandler); + + http2SecureServer = createSecureServer(); + http2SecureServer = createSecureServer(secureServerOptions); + http2SecureServer = createSecureServer(onRequestHandler); + http2SecureServer = createSecureServer(secureServerOptions, onRequestHandler); + + const clientSessionOptions: ClientSessionOptions = { + maxDeflateDynamicTableSize: 0, + maxReservedRemoteStreams: 0, + maxSendHeaderBlockLength: 0, + paddingStrategy: 0, + peerMaxConcurrentStreams: 0, + selectPadding: (frameLen: number, maxFrameLen: number) => 0, + settings + }; + // tslint:disable-next-line prefer-object-spread (ts2.1 feature) + const secureClientSessionOptions: SecureClientSessionOptions = Object.assign({}, clientSessionOptions); + secureClientSessionOptions.ca = ''; + const onConnectHandler = (session: Http2Session, socket: Socket) => {}; + + const serverHttp2Session: ServerHttp2Session = {} as any; + + serverHttp2Session.altsvc('', ''); + serverHttp2Session.altsvc('', 0); + serverHttp2Session.altsvc('', new URL('')); + serverHttp2Session.altsvc('', { origin: '' }); + serverHttp2Session.altsvc('', { origin: 0 }); + serverHttp2Session.altsvc('', { origin: new URL('') }); + + let clientHttp2Session: ClientHttp2Session; + + clientHttp2Session = connect(''); + clientHttp2Session = connect('', onConnectHandler); + clientHttp2Session = connect('', clientSessionOptions); + clientHttp2Session = connect('', clientSessionOptions, onConnectHandler); + clientHttp2Session = connect('', secureClientSessionOptions); + clientHttp2Session = connect('', secureClientSessionOptions, onConnectHandler); + clientHttp2Session.on('altsvc', (alt: string, origin: string, number: number) => {}); + + settings = getDefaultSettings(); + settings = getPackedSettings(settings); + settings = getUnpackedSettings(Buffer.from([])); + settings = getUnpackedSettings(Uint8Array.from([])); +} + +// constants +{ + const consts = constants; + let num: number; + let str: string; + num = consts.NGHTTP2_SESSION_SERVER; + num = consts.NGHTTP2_SESSION_CLIENT; + num = consts.NGHTTP2_STREAM_STATE_IDLE; + num = consts.NGHTTP2_STREAM_STATE_OPEN; + num = consts.NGHTTP2_STREAM_STATE_RESERVED_LOCAL; + num = consts.NGHTTP2_STREAM_STATE_RESERVED_REMOTE; + num = consts.NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL; + num = consts.NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE; + num = consts.NGHTTP2_STREAM_STATE_CLOSED; + num = consts.NGHTTP2_NO_ERROR; + num = consts.NGHTTP2_PROTOCOL_ERROR; + num = consts.NGHTTP2_INTERNAL_ERROR; + num = consts.NGHTTP2_FLOW_CONTROL_ERROR; + num = consts.NGHTTP2_SETTINGS_TIMEOUT; + num = consts.NGHTTP2_STREAM_CLOSED; + num = consts.NGHTTP2_FRAME_SIZE_ERROR; + num = consts.NGHTTP2_REFUSED_STREAM; + num = consts.NGHTTP2_CANCEL; + num = consts.NGHTTP2_COMPRESSION_ERROR; + num = consts.NGHTTP2_CONNECT_ERROR; + num = consts.NGHTTP2_ENHANCE_YOUR_CALM; + num = consts.NGHTTP2_INADEQUATE_SECURITY; + num = consts.NGHTTP2_HTTP_1_1_REQUIRED; + num = consts.NGHTTP2_ERR_FRAME_SIZE_ERROR; + num = consts.NGHTTP2_FLAG_NONE; + num = consts.NGHTTP2_FLAG_END_STREAM; + num = consts.NGHTTP2_FLAG_END_HEADERS; + num = consts.NGHTTP2_FLAG_ACK; + num = consts.NGHTTP2_FLAG_PADDED; + num = consts.NGHTTP2_FLAG_PRIORITY; + num = consts.DEFAULT_SETTINGS_HEADER_TABLE_SIZE; + num = consts.DEFAULT_SETTINGS_ENABLE_PUSH; + num = consts.DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE; + num = consts.DEFAULT_SETTINGS_MAX_FRAME_SIZE; + num = consts.MAX_MAX_FRAME_SIZE; + num = consts.MIN_MAX_FRAME_SIZE; + num = consts.MAX_INITIAL_WINDOW_SIZE; + num = consts.NGHTTP2_DEFAULT_WEIGHT; + num = consts.NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; + num = consts.NGHTTP2_SETTINGS_ENABLE_PUSH; + num = consts.NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; + num = consts.NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + num = consts.NGHTTP2_SETTINGS_MAX_FRAME_SIZE; + num = consts.NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE; + num = consts.PADDING_STRATEGY_NONE; + num = consts.PADDING_STRATEGY_MAX; + num = consts.PADDING_STRATEGY_CALLBACK; + num = consts.HTTP_STATUS_CONTINUE; + num = consts.HTTP_STATUS_SWITCHING_PROTOCOLS; + num = consts.HTTP_STATUS_PROCESSING; + num = consts.HTTP_STATUS_OK; + num = consts.HTTP_STATUS_CREATED; + num = consts.HTTP_STATUS_ACCEPTED; + num = consts.HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION; + num = consts.HTTP_STATUS_NO_CONTENT; + num = consts.HTTP_STATUS_RESET_CONTENT; + num = consts.HTTP_STATUS_PARTIAL_CONTENT; + num = consts.HTTP_STATUS_MULTI_STATUS; + num = consts.HTTP_STATUS_ALREADY_REPORTED; + num = consts.HTTP_STATUS_IM_USED; + num = consts.HTTP_STATUS_MULTIPLE_CHOICES; + num = consts.HTTP_STATUS_MOVED_PERMANENTLY; + num = consts.HTTP_STATUS_FOUND; + num = consts.HTTP_STATUS_SEE_OTHER; + num = consts.HTTP_STATUS_NOT_MODIFIED; + num = consts.HTTP_STATUS_USE_PROXY; + num = consts.HTTP_STATUS_TEMPORARY_REDIRECT; + num = consts.HTTP_STATUS_PERMANENT_REDIRECT; + num = consts.HTTP_STATUS_BAD_REQUEST; + num = consts.HTTP_STATUS_UNAUTHORIZED; + num = consts.HTTP_STATUS_PAYMENT_REQUIRED; + num = consts.HTTP_STATUS_FORBIDDEN; + num = consts.HTTP_STATUS_NOT_FOUND; + num = consts.HTTP_STATUS_METHOD_NOT_ALLOWED; + num = consts.HTTP_STATUS_NOT_ACCEPTABLE; + num = consts.HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED; + num = consts.HTTP_STATUS_REQUEST_TIMEOUT; + num = consts.HTTP_STATUS_CONFLICT; + num = consts.HTTP_STATUS_GONE; + num = consts.HTTP_STATUS_LENGTH_REQUIRED; + num = consts.HTTP_STATUS_PRECONDITION_FAILED; + num = consts.HTTP_STATUS_PAYLOAD_TOO_LARGE; + num = consts.HTTP_STATUS_URI_TOO_LONG; + num = consts.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE; + num = consts.HTTP_STATUS_RANGE_NOT_SATISFIABLE; + num = consts.HTTP_STATUS_EXPECTATION_FAILED; + num = consts.HTTP_STATUS_TEAPOT; + num = consts.HTTP_STATUS_MISDIRECTED_REQUEST; + num = consts.HTTP_STATUS_UNPROCESSABLE_ENTITY; + num = consts.HTTP_STATUS_LOCKED; + num = consts.HTTP_STATUS_FAILED_DEPENDENCY; + num = consts.HTTP_STATUS_UNORDERED_COLLECTION; + num = consts.HTTP_STATUS_UPGRADE_REQUIRED; + num = consts.HTTP_STATUS_PRECONDITION_REQUIRED; + num = consts.HTTP_STATUS_TOO_MANY_REQUESTS; + num = consts.HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE; + num = consts.HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS; + num = consts.HTTP_STATUS_INTERNAL_SERVER_ERROR; + num = consts.HTTP_STATUS_NOT_IMPLEMENTED; + num = consts.HTTP_STATUS_BAD_GATEWAY; + num = consts.HTTP_STATUS_SERVICE_UNAVAILABLE; + num = consts.HTTP_STATUS_GATEWAY_TIMEOUT; + num = consts.HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED; + num = consts.HTTP_STATUS_VARIANT_ALSO_NEGOTIATES; + num = consts.HTTP_STATUS_INSUFFICIENT_STORAGE; + num = consts.HTTP_STATUS_LOOP_DETECTED; + num = consts.HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED; + num = consts.HTTP_STATUS_NOT_EXTENDED; + num = consts.HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED; + str = consts.HTTP2_HEADER_STATUS; + str = consts.HTTP2_HEADER_METHOD; + str = consts.HTTP2_HEADER_AUTHORITY; + str = consts.HTTP2_HEADER_SCHEME; + str = consts.HTTP2_HEADER_PATH; + str = consts.HTTP2_HEADER_ACCEPT_CHARSET; + str = consts.HTTP2_HEADER_ACCEPT_ENCODING; + str = consts.HTTP2_HEADER_ACCEPT_LANGUAGE; + str = consts.HTTP2_HEADER_ACCEPT_RANGES; + str = consts.HTTP2_HEADER_ACCEPT; + str = consts.HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN; + str = consts.HTTP2_HEADER_AGE; + str = consts.HTTP2_HEADER_ALLOW; + str = consts.HTTP2_HEADER_AUTHORIZATION; + str = consts.HTTP2_HEADER_CACHE_CONTROL; + str = consts.HTTP2_HEADER_CONNECTION; + str = consts.HTTP2_HEADER_CONTENT_DISPOSITION; + str = consts.HTTP2_HEADER_CONTENT_ENCODING; + str = consts.HTTP2_HEADER_CONTENT_LANGUAGE; + str = consts.HTTP2_HEADER_CONTENT_LENGTH; + str = consts.HTTP2_HEADER_CONTENT_LOCATION; + str = consts.HTTP2_HEADER_CONTENT_MD5; + str = consts.HTTP2_HEADER_CONTENT_RANGE; + str = consts.HTTP2_HEADER_CONTENT_TYPE; + str = consts.HTTP2_HEADER_COOKIE; + str = consts.HTTP2_HEADER_DATE; + str = consts.HTTP2_HEADER_ETAG; + str = consts.HTTP2_HEADER_EXPECT; + str = consts.HTTP2_HEADER_EXPIRES; + str = consts.HTTP2_HEADER_FROM; + str = consts.HTTP2_HEADER_HOST; + str = consts.HTTP2_HEADER_IF_MATCH; + str = consts.HTTP2_HEADER_IF_MODIFIED_SINCE; + str = consts.HTTP2_HEADER_IF_NONE_MATCH; + str = consts.HTTP2_HEADER_IF_RANGE; + str = consts.HTTP2_HEADER_IF_UNMODIFIED_SINCE; + str = consts.HTTP2_HEADER_LAST_MODIFIED; + str = consts.HTTP2_HEADER_LINK; + str = consts.HTTP2_HEADER_LOCATION; + str = consts.HTTP2_HEADER_MAX_FORWARDS; + str = consts.HTTP2_HEADER_PREFER; + str = consts.HTTP2_HEADER_PROXY_AUTHENTICATE; + str = consts.HTTP2_HEADER_PROXY_AUTHORIZATION; + str = consts.HTTP2_HEADER_RANGE; + str = consts.HTTP2_HEADER_REFERER; + str = consts.HTTP2_HEADER_REFRESH; + str = consts.HTTP2_HEADER_RETRY_AFTER; + str = consts.HTTP2_HEADER_SERVER; + str = consts.HTTP2_HEADER_SET_COOKIE; + str = consts.HTTP2_HEADER_STRICT_TRANSPORT_SECURITY; + str = consts.HTTP2_HEADER_TRANSFER_ENCODING; + str = consts.HTTP2_HEADER_TE; + str = consts.HTTP2_HEADER_UPGRADE; + str = consts.HTTP2_HEADER_USER_AGENT; + str = consts.HTTP2_HEADER_VARY; + str = consts.HTTP2_HEADER_VIA; + str = consts.HTTP2_HEADER_WWW_AUTHENTICATE; + str = consts.HTTP2_HEADER_HTTP2_SETTINGS; + str = consts.HTTP2_HEADER_KEEP_ALIVE; + str = consts.HTTP2_HEADER_PROXY_CONNECTION; + str = consts.HTTP2_METHOD_ACL; + str = consts.HTTP2_METHOD_BASELINE_CONTROL; + str = consts.HTTP2_METHOD_BIND; + str = consts.HTTP2_METHOD_CHECKIN; + str = consts.HTTP2_METHOD_CHECKOUT; + str = consts.HTTP2_METHOD_CONNECT; + str = consts.HTTP2_METHOD_COPY; + str = consts.HTTP2_METHOD_DELETE; + str = consts.HTTP2_METHOD_GET; + str = consts.HTTP2_METHOD_HEAD; + str = consts.HTTP2_METHOD_LABEL; + str = consts.HTTP2_METHOD_LINK; + str = consts.HTTP2_METHOD_LOCK; + str = consts.HTTP2_METHOD_MERGE; + str = consts.HTTP2_METHOD_MKACTIVITY; + str = consts.HTTP2_METHOD_MKCALENDAR; + str = consts.HTTP2_METHOD_MKCOL; + str = consts.HTTP2_METHOD_MKREDIRECTREF; + str = consts.HTTP2_METHOD_MKWORKSPACE; + str = consts.HTTP2_METHOD_MOVE; + str = consts.HTTP2_METHOD_OPTIONS; + str = consts.HTTP2_METHOD_ORDERPATCH; + str = consts.HTTP2_METHOD_PATCH; + str = consts.HTTP2_METHOD_POST; + str = consts.HTTP2_METHOD_PRI; + str = consts.HTTP2_METHOD_PROPFIND; + str = consts.HTTP2_METHOD_PROPPATCH; + str = consts.HTTP2_METHOD_PUT; + str = consts.HTTP2_METHOD_REBIND; + str = consts.HTTP2_METHOD_REPORT; + str = consts.HTTP2_METHOD_SEARCH; + str = consts.HTTP2_METHOD_TRACE; + str = consts.HTTP2_METHOD_UNBIND; + str = consts.HTTP2_METHOD_UNCHECKOUT; + str = consts.HTTP2_METHOD_UNLINK; + str = consts.HTTP2_METHOD_UNLOCK; + str = consts.HTTP2_METHOD_UPDATE; + str = consts.HTTP2_METHOD_UPDATEREDIRECTREF; + str = consts.HTTP2_METHOD_VERSION_CONTROL; +} diff --git a/types/node/test/net.ts b/types/node/test/net.ts index a2276654c8..f2c212d1fc 100644 --- a/types/node/test/net.ts +++ b/types/node/test/net.ts @@ -26,9 +26,11 @@ import { LookupOneOptions } from 'dns'; ipv6Only: true, }); - // close has an optional callback function. No callback parameters are - // specified, so any callback function is permissible. - server = server.close((...args: any[]) => { }); + // close callback parameter can be either nothing (undefined) or an error + server = server.close(() => { }); + server = server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); // test the types of the address object fields const address: net.AddressInfo | string | null = server.address(); diff --git a/types/node/test/perf_hooks.ts b/types/node/test/perf_hooks.ts new file mode 100644 index 0000000000..8d4c4e23d2 --- /dev/null +++ b/types/node/test/perf_hooks.ts @@ -0,0 +1,42 @@ +import { performance, monitorEventLoopDelay, PerformanceObserverCallback, PerformanceObserver } from 'perf_hooks'; + +performance.mark('start'); +( + () => {} +)(); +performance.mark('end'); + +const { duration } = performance.getEntriesByName('discover')[0]; +const timeOrigin = performance.timeOrigin; + +const performanceObserverCallback: PerformanceObserverCallback = (list, obs) => { + const { + duration, + entryType, + name, + startTime, + } = list.getEntries()[0]; + obs.disconnect(); + performance.clearFunctions(); +}; +const obs = new PerformanceObserver(performanceObserverCallback); +obs.observe({ + entryTypes: ['function'], + buffered: true, +}); + +const monitor = monitorEventLoopDelay({ + resolution: 42, +}); + +monitor.enable(); +monitor.reset(); +monitor.disable(); +const perc: number = monitor.percentile(99); +const perc2: number | undefined = monitor.percentiles.get(42); + +const min: number = monitor.min; +const max: number = monitor.max; +const mean: number = monitor.mean; +const stddev: number = monitor.stddev; +const exceeds: number = monitor.exceeds; diff --git a/types/node/test/repl.ts b/types/node/test/repl.ts new file mode 100644 index 0000000000..b536cd4dc1 --- /dev/null +++ b/types/node/test/repl.ts @@ -0,0 +1,73 @@ +import { start, Recoverable } from "repl"; +import { Context } from "vm"; + +{ + let server = start(); + let _boolean: boolean; + const _ctx: Context = {}; + + server.setupHistory('hurr/durr', (err, repl) => { + }); + + server = server.addListener("exit", () => { }); + server = server.addListener("reset", () => { }); + + _boolean = server.emit("exit", () => { }); + _boolean = server.emit("reset", _ctx); + + server = server.on("exit", () => { }); + server = server.on("reset", () => { }); + + server = server.once("exit", () => { }); + server = server.once("reset", () => { }); + + server = server.prependListener("exit", () => { }); + server = server.prependListener("reset", () => { }); + + server = server.prependOnceListener("exit", () => { }); + server = server.prependOnceListener("reset", () => { }); + + server.outputStream.write("test"); + const line = server.inputStream.read(); + + server.clearBufferedCommand(); + server.displayPrompt(); + server.displayPrompt(true); + server.defineCommand("cmd", function(text) { + // $ExpectType string + text; + // $ExpectType REPLServer + this; + }); + server.defineCommand("cmd", { + help: "", + action(text) { + // $ExpectType string + text; + // $ExpectType REPLServer + this; + } + }); + + start({ + eval() { + // $ExpectType REPLServer + this; + }, + writer() { + // $ExpectType REPLServer + this; + return ""; + } + }); + + function test() { + throw new Recoverable(new Error("test")); + } + + server.context['key0'] = 1; + server.context['key1'] = ""; + server.context['key2'] = true; + server.context['key3'] = []; + server.context['key4'] = {}; +} diff --git a/types/node/test/stream.ts b/types/node/test/stream.ts new file mode 100644 index 0000000000..6fd656e61c --- /dev/null +++ b/types/node/test/stream.ts @@ -0,0 +1,194 @@ +import { Readable, Writable, Transform, finished, pipeline, Duplex } from "stream"; +import { promisify } from "util"; +import { createReadStream, createWriteStream } from "fs"; +import { createGzip, constants } from "zlib"; +import { ok as assert } from 'assert'; + +// Simplified constructors +function simplified_stream_ctor_test() { + new Readable({ + read(size) { + // $ExpectType Readable + this; + // $ExpectType number + size; + }, + destroy(error, cb) { + // $ExpectType Error | null + error; + // $ExpectType (error: Error | null) => void + cb; + } + }); + + new Writable({ + write(chunk, enc, cb) { + // $ExpectType Writable + this; + // $ExpectType any + chunk; + // $ExpectType string + enc; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + writev(chunks, cb) { + // $ExpectType Writable + this; + // $ExpectType { chunk: any; encoding: string; }[] + chunks; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + destroy(error, cb) { + // $ExpectType Writable + this; + // $ExpectType Error | null + error; + // $ExpectType (error: Error | null) => void + cb; + }, + final(cb) { + // $ExpectType Writable + this; + // $ExpectType (error?: Error | null | undefined) => void + cb; + } + }); + + new Duplex({ + read(size) { + // $ExpectType Duplex + this; + // $ExpectType number + size; + }, + write(chunk, enc, cb) { + // $ExpectType Duplex + this; + // $ExpectType any + chunk; + // $ExpectType string + enc; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + writev(chunks, cb) { + // $ExpectType Duplex + this; + // $ExpectType { chunk: any; encoding: string; }[] + chunks; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + destroy(error, cb) { + // $ExpectType Duplex + this; + // $ExpectType Error | null + error; + // $ExpectType (error: Error | null) => void + cb; + }, + final(cb) { + // $ExpectType Duplex + this; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + readableObjectMode: true, + writableObjectMode: true + }); + + new Transform({ + read(size) { + // $ExpectType Transform + this; + // $ExpectType number + size; + }, + write(chunk, enc, cb) { + // $ExpectType Transform + this; + // $ExpectType any + chunk; + // $ExpectType string + enc; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + writev(chunks, cb) { + // $ExpectType Transform + this; + // $ExpectType { chunk: any; encoding: string; }[] + chunks; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + destroy(error, cb) { + // $ExpectType Transform + this; + // $ExpectType Error | null + error; + // $ExpectType (error: Error | null) => void + cb; + }, + final(cb) { + // $ExpectType Transform + this; + // $ExpectType (error?: Error | null | undefined) => void + cb; + }, + transform(chunk, enc, cb) { + // $ExpectType Transform + this; + // $ExpectType any + chunk; + // $ExpectType string + enc; + // $ExpectType TransformCallback + cb; + }, + flush(cb) { + // $ExpectType TransformCallback + cb; + }, + allowHalfOpen: true, + readableObjectMode: true, + writableObjectMode: true + }); +} + +function streamPipelineFinished() { + const cancel = finished(process.stdin, (err?: Error) => {}); + cancel(); + + pipeline(process.stdin, process.stdout, (err?: Error) => {}); +} + +async function asyncStreamPipelineFinished() { + const fin = promisify(finished); + await fin(process.stdin); + + const pipe = promisify(pipeline); + await pipe(process.stdin, process.stdout); +} + +// http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options +function stream_readable_pipe_test() { + const rs = createReadStream(Buffer.from('file.txt')); + const r = createReadStream('file.txt'); + const z = createGzip({ finishFlush: constants.Z_FINISH }); + const w = createWriteStream('file.txt.gz'); + + assert(typeof z.bytesRead === 'number'); + assert(typeof r.bytesRead === 'number'); + assert(typeof r.path === 'string'); + assert(rs.path instanceof Buffer); + + r.pipe(z).pipe(w); + + z.flush(); + r.close(); + z.close(); + rs.close(); +} diff --git a/types/node/test/tls.ts b/types/node/test/tls.ts new file mode 100644 index 0000000000..807e41393f --- /dev/null +++ b/types/node/test/tls.ts @@ -0,0 +1,206 @@ +import { createSecureContext, SecureContext, ConnectionOptions, connect, getCiphers, DEFAULT_ECDH_CURVE, createServer, TLSSocket } from "tls"; + +{ + const ctx: SecureContext = createSecureContext({ + key: "NOT REALLY A KEY", + cert: "SOME CERTIFICATE", + }); + const blah = ctx.context; + + const connOpts: ConnectionOptions = { + host: "127.0.0.1", + port: 55 + }; + const tlsSocket = connect(connOpts); + + const ciphers: string[] = getCiphers(); + const curve: string = DEFAULT_ECDH_CURVE; +} + +{ + let _server = createServer({}); + let _boolean: boolean; + const _func1 = (err: Error, resp: Buffer) => { }; + const _func2 = (err: Error, sessionData: any) => { }; + /** + * events.EventEmitter + * 1. tlsClientError + * 2. newSession + * 3. OCSPRequest + * 4. resumeSession + * 5. secureConnection + */ + + _server = _server.addListener("tlsClientError", (err, tlsSocket) => { + const _err: Error = err; + const _tlsSocket: TLSSocket = tlsSocket; + }); + _server = _server.addListener("newSession", (sessionId, sessionData, callback) => { + const _sessionId: any = sessionId; + const _sessionData: any = sessionData; + const _func1 = callback; + }); + _server = _server.addListener("OCSPRequest", (certificate, issuer, callback) => { + const _certificate: Buffer = certificate; + const _issuer: Buffer = issuer; + const _callback: Function = callback; + }); + _server = _server.addListener("resumeSession", (sessionId, callback) => { + const _sessionId: any = sessionId; + const _func2 = callback; + }); + _server = _server.addListener("secureConnection", (tlsSocket) => { + const _tlsSocket: TLSSocket = tlsSocket; + }); + + const _err: Error = new Error(); + const _tlsSocket: TLSSocket = connect(1); + const _any: any = 1; + const _func: Function = () => {}; + const _buffer: Buffer = Buffer.from('a'); + _boolean = _server.emit("tlsClientError", _err, _tlsSocket); + _boolean = _server.emit("newSession", _any, _any, _func1); + _boolean = _server.emit("OCSPRequest", _buffer, _buffer, _func); + _boolean = _server.emit("resumeSession", _any, _func2); + _boolean = _server.emit("secureConnection", _tlsSocket); + + _server = _server.on("tlsClientError", (err, tlsSocket) => { + const _err: Error = err; + const _tlsSocket: TLSSocket = tlsSocket; + }); + _server = _server.on("newSession", (sessionId, sessionData, callback) => { + const _sessionId: any = sessionId; + const _sessionData: any = sessionData; + const _func1 = callback; + }); + _server = _server.on("OCSPRequest", (certificate, issuer, callback) => { + const _certificate: Buffer = certificate; + const _issuer: Buffer = issuer; + const _callback: Function = callback; + }); + _server = _server.on("resumeSession", (sessionId, callback) => { + const _sessionId: any = sessionId; + const _func2 = callback; + }); + _server = _server.on("secureConnection", (tlsSocket) => { + const _tlsSocket: TLSSocket = tlsSocket; + }); + + _server = _server.once("tlsClientError", (err, tlsSocket) => { + const _err: Error = err; + const _tlsSocket: TLSSocket = tlsSocket; + }); + _server = _server.once("newSession", (sessionId, sessionData, callback) => { + const _sessionId: any = sessionId; + const _sessionData: any = sessionData; + const _func1 = callback; + }); + _server = _server.once("OCSPRequest", (certificate, issuer, callback) => { + const _certificate: Buffer = certificate; + const _issuer: Buffer = issuer; + const _callback: Function = callback; + }); + _server = _server.once("resumeSession", (sessionId, callback) => { + const _sessionId: any = sessionId; + const _func2 = callback; + }); + _server = _server.once("secureConnection", (tlsSocket) => { + const _tlsSocket: TLSSocket = tlsSocket; + }); + + _server = _server.prependListener("tlsClientError", (err, tlsSocket) => { + const _err: Error = err; + const _tlsSocket: TLSSocket = tlsSocket; + }); + _server = _server.prependListener("newSession", (sessionId, sessionData, callback) => { + const _sessionId: any = sessionId; + const _sessionData: any = sessionData; + const _func1 = callback; + }); + _server = _server.prependListener("OCSPRequest", (certificate, issuer, callback) => { + const _certificate: Buffer = certificate; + const _issuer: Buffer = issuer; + const _callback: Function = callback; + }); + _server = _server.prependListener("resumeSession", (sessionId, callback) => { + const _sessionId: any = sessionId; + const _func2 = callback; + }); + _server = _server.prependListener("secureConnection", (tlsSocket) => { + const _tlsSocket: TLSSocket = tlsSocket; + }); + + _server = _server.prependOnceListener("tlsClientError", (err, tlsSocket) => { + const _err: Error = err; + const _tlsSocket: TLSSocket = tlsSocket; + }); + _server = _server.prependOnceListener("newSession", (sessionId, sessionData, callback) => { + const _sessionId: any = sessionId; + const _sessionData: any = sessionData; + const _func1 = callback; + }); + _server = _server.prependOnceListener("OCSPRequest", (certificate, issuer, callback) => { + const _certificate: Buffer = certificate; + const _issuer: Buffer = issuer; + const _callback: Function = callback; + }); + _server = _server.prependOnceListener("resumeSession", (sessionId, callback) => { + const _sessionId: any = sessionId; + const _func2 = callback; + }); + _server = _server.prependOnceListener("secureConnection", (tlsSocket) => { + const _tlsSocket: TLSSocket = tlsSocket; + }); + + // close callback parameter is optional + _server = _server.close(); + + // close callback parameter doesn't specify any arguments, so any + // function is acceptable + _server = _server.close(() => { }); + _server = _server.close((...args: any[]) => { }); +} + +{ + let socket = connect({ + }); + let _boolean: boolean; + /** + * events.EventEmitter + * 1. close + * 2. error + * 3. listening + * 4. message + */ + + socket = socket.addListener("OCSPResponse", (response) => { + const _response: Buffer = response; + }); + socket = socket.addListener("secureConnect", () => { }); + + const _buffer: Buffer = Buffer.from(""); + _boolean = socket.emit("OCSPResponse", _buffer); + _boolean = socket.emit("secureConnect"); + + socket = socket.on("OCSPResponse", (response) => { + const _response: Buffer = response; + }); + socket = socket.on("secureConnect", () => { }); + + socket = socket.once("OCSPResponse", (response) => { + const _response: Buffer = response; + }); + socket = socket.once("secureConnect", () => { }); + + socket = socket.prependListener("OCSPResponse", (response) => { + const _response: Buffer = response; + }); + socket = socket.prependListener("secureConnect", () => { }); + + socket = socket.prependOnceListener("OCSPResponse", (response) => { + const _response: Buffer = response; + }); + socket = socket.prependOnceListener("secureConnect", () => { }); + + socket.once('session', (buff: Buffer) => {}); +} diff --git a/types/node/test/zlib.ts b/types/node/test/zlib.ts new file mode 100644 index 0000000000..d76803a919 --- /dev/null +++ b/types/node/test/zlib.ts @@ -0,0 +1,120 @@ +import { + deflate, + inflate, + inflateSync, + deflateSync, + deflateRaw, + inflateRaw, + inflateRawSync, + deflateRawSync, + gunzip, + gzip, + gunzipSync, + gzipSync, + unzip, + unzipSync, + constants, + createBrotliCompress, + BrotliOptions, + createBrotliDecompress, + BrotliCompress, + BrotliDecompress, + brotliCompress, + brotliDecompressSync, + brotliDecompress, +} from "zlib"; + +const compressMe = new Buffer("some data"); +const compressMeString = "compress me!"; + +// Deflate / Inflate + +deflate(compressMe, (err: Error | null, result: Buffer) => inflate(result, (err: Error | null, result: Buffer) => result)); +deflate( + compressMe, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => inflate( + result, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => result + ) +); +deflate(compressMeString, (err: Error | null, result: Buffer) => inflate(result, (err: Error | null, result: Buffer) => result)); +deflate( + compressMeString, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => inflate( + result, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => result + ) +); +const inflated = inflateSync(deflateSync(compressMe)); +const inflatedString = inflateSync(deflateSync(compressMeString)); + +deflateRaw(compressMe, (err: Error | null, result: Buffer) => inflateRaw(result, (err: Error | null, result: Buffer) => result)); +deflateRaw( + compressMe, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => inflateRaw( + result, { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => result + ) +); +deflateRaw(compressMeString, (err: Error | null, result: Buffer) => inflateRaw(result, (err: Error | null, result: Buffer) => result)); +deflateRaw( + compressMeString, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => inflateRaw(result, { finishFlush: constants.Z_SYNC_FLUSH }, (err: Error | null, result: Buffer) => result), +); +const inflatedRaw: Buffer = inflateRawSync(deflateRawSync(compressMe)); +const inflatedRawString: Buffer = inflateRawSync(deflateRawSync(compressMeString)); + +// gzip + +gzip(compressMe, (err: Error | null, result: Buffer) => gunzip(result, (err: Error | null, result: Buffer) => result)); +gzip( + compressMe, + { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => gunzip( + result, { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => result + ) +); +const gunzipped: Buffer = gunzipSync(gzipSync(compressMe)); + +unzip(compressMe, (err: Error | null, result: Buffer) => result); +unzip(compressMe, { finishFlush: constants.Z_SYNC_FLUSH }, (err: Error | null, result: Buffer) => result); +const unzipped: Buffer = unzipSync(compressMe); + +const bOpts: BrotliOptions = { + chunkSize: 123, + flush: 123123, + params: { + [constants.BROTLI_PARAM_LARGE_WINDOW]: true, + [constants.BROTLI_PARAM_NPOSTFIX]: 123, + }, + finishFlush: 123123, +}; + +// brotli + +let bC: BrotliCompress = createBrotliCompress(); +bC = createBrotliCompress(bOpts); +let bD: BrotliDecompress = createBrotliDecompress(); +bD = createBrotliDecompress(bOpts); +// gzip + +brotliCompress(compressMe, (err: Error | null, result: Buffer) => gunzip(result, (err: Error | null, result: Buffer) => result)); +brotliCompress( + compressMe, + { finishFlush: constants.BROTLI_OPERATION_FINISH }, + (err: Error | null, result: Buffer) => gunzip( + result, { finishFlush: constants.Z_SYNC_FLUSH }, + (err: Error | null, result: Buffer) => result + ) +); +const brotlied: Buffer = brotliDecompressSync(brotliDecompressSync(compressMe)); + +brotliDecompress(compressMe, (err: Error | null, result: Buffer) => result); +brotliDecompress(compressMe, { finishFlush: constants.BROTLI_OPERATION_FINISH }, (err: Error | null, result: Buffer) => result); diff --git a/types/node/tls.d.ts b/types/node/tls.d.ts index e7222b5a5b..ef9a7bd4b0 100644 --- a/types/node/tls.d.ts +++ b/types/node/tls.d.ts @@ -218,26 +218,32 @@ declare module "tls" { addListener(event: string, listener: (...args: any[]) => void): this; addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; addListener(event: "secureConnect", listener: () => void): this; + addListener(event: "session", listener: (session: Buffer) => void): this; emit(event: string | symbol, ...args: any[]): boolean; emit(event: "OCSPResponse", response: Buffer): boolean; emit(event: "secureConnect"): boolean; + emit(event: "session", session: Buffer): boolean; on(event: string, listener: (...args: any[]) => void): this; on(event: "OCSPResponse", listener: (response: Buffer) => void): this; on(event: "secureConnect", listener: () => void): this; + on(event: "session", listener: (session: Buffer) => void): this; once(event: string, listener: (...args: any[]) => void): this; once(event: "OCSPResponse", listener: (response: Buffer) => void): this; once(event: "secureConnect", listener: () => void): this; + once(event: "session", listener: (session: Buffer) => void): this; prependListener(event: string, listener: (...args: any[]) => void): this; prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; prependListener(event: "secureConnect", listener: () => void): this; + prependListener(event: "session", listener: (session: Buffer) => void): this; prependOnceListener(event: string, listener: (...args: any[]) => void): this; prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; prependOnceListener(event: "secureConnect", listener: () => void): this; + prependOnceListener(event: "session", listener: (session: Buffer) => void): this; } interface TlsOptions extends SecureContextOptions { diff --git a/types/node/ts3.1/node-tests.ts b/types/node/ts3.1/node-tests.ts deleted file mode 100644 index 18db498871..0000000000 --- a/types/node/ts3.1/node-tests.ts +++ /dev/null @@ -1,2 +0,0 @@ -// tslint:disable-next-line:no-bad-reference -import "../node-tests"; diff --git a/types/node/ts3.2/globals.d.ts b/types/node/ts3.2/globals.d.ts new file mode 100644 index 0000000000..c14a1a36b1 --- /dev/null +++ b/types/node/ts3.2/globals.d.ts @@ -0,0 +1,8 @@ +// tslint:disable-next-line:no-bad-reference +/// + +declare namespace NodeJS { + interface HRTime { + bigint(): bigint; + } +} diff --git a/types/node/v10/ts3.1/index.d.ts b/types/node/ts3.2/index.d.ts similarity index 71% rename from types/node/v10/ts3.1/index.d.ts rename to types/node/ts3.2/index.d.ts index ee9f75cc5f..ce7709bc7c 100644 --- a/types/node/v10/ts3.1/index.d.ts +++ b/types/node/ts3.2/index.d.ts @@ -1,18 +1,20 @@ -// NOTE: These definitions support NodeJS and TypeScript 3.1. +// NOTE: These definitions support NodeJS and TypeScript 3.2. // NOTE: TypeScript version-specific augmentations can be found in the following paths: // - ~/base.d.ts - Shared definitions common to all TypeScript versions // - ~/index.d.ts - Definitions specific to TypeScript 2.1 -// - ~/ts3.1/index.d.ts - Definitions specific to TypeScript 3.1 +// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 // Reference required types from the default lib: /// /// /// +/// // Base definitions for all NodeJS modules that are not specific to any version of TypeScript: // tslint:disable-next-line:no-bad-reference /// -// TypeScript 3.1-specific augmentations: +// TypeScript 3.2-specific augmentations: /// +/// diff --git a/types/node/ts3.2/node-tests.ts b/types/node/ts3.2/node-tests.ts new file mode 100644 index 0000000000..3f64e22e81 --- /dev/null +++ b/types/node/ts3.2/node-tests.ts @@ -0,0 +1,11 @@ +// tslint:disable-next-line:no-bad-reference +import "../node-tests"; + +////////////////////////////////////////////////////////// +/// Global Tests : https://nodejs.org/api/global.html /// +////////////////////////////////////////////////////////// +{ + { + const hrtimeBigint: bigint = process.hrtime.bigint(); + } +} diff --git a/types/node/ts3.1/tsconfig.json b/types/node/ts3.2/tsconfig.json similarity index 100% rename from types/node/ts3.1/tsconfig.json rename to types/node/ts3.2/tsconfig.json diff --git a/types/node/ts3.1/tslint.json b/types/node/ts3.2/tslint.json similarity index 100% rename from types/node/ts3.1/tslint.json rename to types/node/ts3.2/tslint.json diff --git a/types/node/ts3.1/util.d.ts b/types/node/ts3.2/util.d.ts similarity index 100% rename from types/node/ts3.1/util.d.ts rename to types/node/ts3.2/util.d.ts diff --git a/types/node/tsconfig.json b/types/node/tsconfig.json index e16d482b6f..831c9861f0 100644 --- a/types/node/tsconfig.json +++ b/types/node/tsconfig.json @@ -43,16 +43,24 @@ "worker_threads.d.ts", "zlib.d.ts", "node-tests.ts", - "test/http.ts", - "test/readline.ts", - "test/global.ts", - "test/worker_threads.ts", - "test/util.ts", - "test/net.ts", - "test/dgram.ts", + "test/buffer.ts", + "test/child_process.ts", + "test/crypto.ts", + "test/dgram.ts", + "test/global.ts", + "test/http.ts", + "test/http2.ts", + "test/net.ts", + "test/perf_hooks.ts", + "test/readline.ts", + "test/stream.ts", "test/tty.ts", - "test/crypto.ts" + "test/util.ts", + "test/repl.ts", + "test/worker_threads.ts", + "test/zlib.ts", + "test/tls.ts" ], "compilerOptions": { "module": "commonjs", diff --git a/types/node/v0/index.d.ts b/types/node/v0/index.d.ts index 1f29bbcc10..2190660451 100644 --- a/types/node/v0/index.d.ts +++ b/types/node/v0/index.d.ts @@ -531,6 +531,7 @@ declare module "http" { write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; + readonly path: string; write(chunk: any, encoding?: string): void; abort(): void; setTimeout(timeout: number, callback?: Function): void; diff --git a/types/node/v10/buffer.d.ts b/types/node/v10/buffer.d.ts index 1d618f2c4b..0fe668b17d 100644 --- a/types/node/v10/buffer.d.ts +++ b/types/node/v10/buffer.d.ts @@ -2,6 +2,10 @@ declare module "buffer" { export const INSPECT_MAX_BYTES: number; const BuffType: typeof Buffer; + export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"; + + export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; + export const SlowBuffer: { /** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */ new(size: number): Buffer; diff --git a/types/node/v10/child_process.d.ts b/types/node/v10/child_process.d.ts index c8d20b8249..1114247bee 100644 --- a/types/node/v10/child_process.d.ts +++ b/types/node/v10/child_process.d.ts @@ -293,7 +293,7 @@ declare module "child_process" { stderr: T; status: number; signal: string; - error: Error; + error?: Error; } function spawnSync(command: string): SpawnSyncReturns; function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; diff --git a/types/node/v10/globals.d.ts b/types/node/v10/globals.d.ts index 23cab2f1f8..534c03240d 100644 --- a/types/node/v10/globals.d.ts +++ b/types/node/v10/globals.d.ts @@ -696,6 +696,10 @@ declare namespace NodeJS { destroy(error?: Error): void; } + interface HRTime { + (time?: [number, number]): [number, number]; + } + interface Process extends EventEmitter { stdout: WriteStream; stderr: WriteStream; @@ -766,7 +770,7 @@ declare namespace NodeJS { release: ProcessRelease; umask(mask?: number): number; uptime(): number; - hrtime(time?: [number, number]): [number, number]; + hrtime: HRTime; domain: Domain; // Worker diff --git a/types/node/v10/http.d.ts b/types/node/v10/http.d.ts index 5e1ebcc127..b55ab680cf 100644 --- a/types/node/v10/http.d.ts +++ b/types/node/v10/http.d.ts @@ -154,6 +154,7 @@ declare module "http" { constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); + readonly path: string; abort(): void; onSocket(socket: net.Socket): void; setTimeout(timeout: number, callback?: () => void): this; diff --git a/types/node/v10/index.d.ts b/types/node/v10/index.d.ts index a237502039..cf67202129 100644 --- a/types/node/v10/index.d.ts +++ b/types/node/v10/index.d.ts @@ -33,6 +33,8 @@ // Jeremie Rodriguez // Samuel Ainsworth // Kyle Uehlein +// Jordi Oliveras Rovira +// Thanik Bhongbhibhat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // NOTE: These definitions support NodeJS and TypeScript 3.1. diff --git a/types/node/v10/net.d.ts b/types/node/v10/net.d.ts index 27804375aa..056cdec17a 100644 --- a/types/node/v10/net.d.ts +++ b/types/node/v10/net.d.ts @@ -174,7 +174,7 @@ declare module "net" { listen(options: ListenOptions, listeningListener?: Function): this; listen(handle: any, backlog?: number, listeningListener?: Function): this; listen(handle: any, listeningListener?: Function): this; - close(callback?: Function): this; + close(callback?: (err?: Error) => void): this; address(): AddressInfo | string; getConnections(cb: (error: Error | null, count: number) => void): void; ref(): this; diff --git a/types/node/v10/node-tests.ts b/types/node/v10/node-tests.ts index 3614c30f97..6ae1c52bde 100644 --- a/types/node/v10/node-tests.ts +++ b/types/node/v10/node-tests.ts @@ -35,7 +35,7 @@ import * as trace_events from "trace_events"; import Module = require("module"); // Specifically test buffer module regression. -import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer"; +import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer, transcode, TranscodeEncoding } from "buffer"; ////////////////////////////////////////////////////////// /// Global Tests : https://nodejs.org/api/global.html /// @@ -47,6 +47,7 @@ import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buff x.children.push(y); x.parent = require.main; require.main = y; + const hrtimeArray: [number, number] = process.hrtime(); } } @@ -632,6 +633,15 @@ function bufferTests() { const buffer = new Buffer('123'); const octets = new Uint8Array(buffer.buffer); } + + // Buffer module, transcode function + { + transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer + + const source: TranscodeEncoding = 'utf8'; + const target: TranscodeEncoding = 'ascii'; + transcode(Buffer.from('€'), source, target); // $ExpectType Buffer + } } //////////////////////////////////////////////////// @@ -1816,10 +1826,11 @@ async function asyncStreamPipelineFinished() { // close callback parameter is optional _server = _server.close(); - // close callback parameter doesn't specify any arguments, so any - // function is acceptable + // close callback parameter can be either nothing (undefined) or an error _server = _server.close(() => { }); - _server = _server.close((...args: any[]) => { }); + _server = _server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); } { @@ -3492,9 +3503,11 @@ import * as p from "process"; .ref() .unref(); - // close has an optional callback function. No callback parameters are - // specified, so any callback function is permissible. - server = server.close((...args: any[]) => { }); + // close callback parameter can be either nothing (undefined) or an error + server = server.close(() => { }); + server = server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); // test the types of the address object fields const address: net.AddressInfo | string = server.address(); diff --git a/types/node/v10/package.json b/types/node/v10/package.json index c1f0c68752..cda6cc6dc8 100644 --- a/types/node/v10/package.json +++ b/types/node/v10/package.json @@ -2,10 +2,10 @@ "private": true, "types": "index", "typesVersions": { - ">=3.1.0-0": { + ">=3.2.0-0": { "*": [ - "ts3.1/*" + "ts3.2/*" ] } } -} \ No newline at end of file +} diff --git a/types/node/v10/ts3.1/node-tests.ts b/types/node/v10/ts3.1/node-tests.ts deleted file mode 100644 index 18db498871..0000000000 --- a/types/node/v10/ts3.1/node-tests.ts +++ /dev/null @@ -1,2 +0,0 @@ -// tslint:disable-next-line:no-bad-reference -import "../node-tests"; diff --git a/types/node/v10/ts3.2/globals.d.ts b/types/node/v10/ts3.2/globals.d.ts new file mode 100644 index 0000000000..c14a1a36b1 --- /dev/null +++ b/types/node/v10/ts3.2/globals.d.ts @@ -0,0 +1,8 @@ +// tslint:disable-next-line:no-bad-reference +/// + +declare namespace NodeJS { + interface HRTime { + bigint(): bigint; + } +} diff --git a/types/node/ts3.1/index.d.ts b/types/node/v10/ts3.2/index.d.ts similarity index 71% rename from types/node/ts3.1/index.d.ts rename to types/node/v10/ts3.2/index.d.ts index ee9f75cc5f..ce7709bc7c 100644 --- a/types/node/ts3.1/index.d.ts +++ b/types/node/v10/ts3.2/index.d.ts @@ -1,18 +1,20 @@ -// NOTE: These definitions support NodeJS and TypeScript 3.1. +// NOTE: These definitions support NodeJS and TypeScript 3.2. // NOTE: TypeScript version-specific augmentations can be found in the following paths: // - ~/base.d.ts - Shared definitions common to all TypeScript versions // - ~/index.d.ts - Definitions specific to TypeScript 2.1 -// - ~/ts3.1/index.d.ts - Definitions specific to TypeScript 3.1 +// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 // Reference required types from the default lib: /// /// /// +/// // Base definitions for all NodeJS modules that are not specific to any version of TypeScript: // tslint:disable-next-line:no-bad-reference /// -// TypeScript 3.1-specific augmentations: +// TypeScript 3.2-specific augmentations: /// +/// diff --git a/types/node/v10/ts3.2/node-tests.ts b/types/node/v10/ts3.2/node-tests.ts new file mode 100644 index 0000000000..3f64e22e81 --- /dev/null +++ b/types/node/v10/ts3.2/node-tests.ts @@ -0,0 +1,11 @@ +// tslint:disable-next-line:no-bad-reference +import "../node-tests"; + +////////////////////////////////////////////////////////// +/// Global Tests : https://nodejs.org/api/global.html /// +////////////////////////////////////////////////////////// +{ + { + const hrtimeBigint: bigint = process.hrtime.bigint(); + } +} diff --git a/types/node/v10/ts3.1/tsconfig.json b/types/node/v10/ts3.2/tsconfig.json similarity index 100% rename from types/node/v10/ts3.1/tsconfig.json rename to types/node/v10/ts3.2/tsconfig.json diff --git a/types/node/v10/ts3.1/tslint.json b/types/node/v10/ts3.2/tslint.json similarity index 100% rename from types/node/v10/ts3.1/tslint.json rename to types/node/v10/ts3.2/tslint.json diff --git a/types/node/v10/ts3.1/util.d.ts b/types/node/v10/ts3.2/util.d.ts similarity index 100% rename from types/node/v10/ts3.1/util.d.ts rename to types/node/v10/ts3.2/util.d.ts diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index f52a8d01f8..279c3cefbf 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -785,6 +785,7 @@ declare module "http" { write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; + readonly path: string; write(chunk: any, encoding?: string): void; abort(): void; setTimeout(timeout: number, callback?: Function): void; diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 6dd1ad1dc0..f4fa74291c 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -857,6 +857,7 @@ declare module "http" { write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; + readonly path: string; write(chunk: any, encoding?: string): void; abort(): void; setTimeout(timeout: number, callback?: Function): void; diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index a4fde30a97..611b9b7903 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -8,6 +8,7 @@ // Sebastian Silbermann // Hoàng Văn Khải // Sander Koenders +// Jordi Oliveras Rovira // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /************************************************ @@ -683,6 +684,8 @@ declare module "buffer" { export var INSPECT_MAX_BYTES: number; var BuffType: typeof Buffer; var SlowBuffType: typeof SlowBuffer; + export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"; + export function transcode(source: Buffer, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; export { BuffType as Buffer, SlowBuffType as SlowBuffer }; } @@ -854,6 +857,7 @@ declare module "http" { write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; + readonly path: string; write(chunk: any, encoding?: string): void; abort(): void; setTimeout(timeout: number, callback?: Function): void; diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index 764dc6e8d0..81c33d9658 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -28,7 +28,7 @@ import * as v8 from "v8"; import * as dns from "dns"; // Specifically test buffer module regression. -import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer"; +import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer, transcode, TranscodeEncoding } from "buffer"; ////////////////////////////////////////////////////////// /// Global Tests : https://nodejs.org/api/global.html /// @@ -448,6 +448,15 @@ function bufferTests() { let buffer = new Buffer('123'); let octets = new Uint8Array(buffer.buffer); } + + // Buffer module, transcode function + { + transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer + + const source: TranscodeEncoding = 'utf8'; + const target: TranscodeEncoding = 'ascii'; + transcode(Buffer.from('€'), source, target); // $ExpectType Buffer + } } diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index 1fac090367..83deb05d33 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -22,6 +22,8 @@ // Hoàng Văn Khải // Lishude // Andrew Makarov +// Jordi Oliveras Rovira +// Thanik Bhongbhibhat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -909,6 +911,8 @@ declare module "buffer" { export var INSPECT_MAX_BYTES: number; var BuffType: typeof Buffer; var SlowBuffType: typeof SlowBuffer; + export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"; + export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; export { BuffType as Buffer, SlowBuffType as SlowBuffer }; } @@ -1101,6 +1105,7 @@ declare module "http" { constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); + readonly path: string; abort(): void; onSocket(socket: net.Socket): void; setTimeout(timeout: number, callback?: () => void): this; @@ -2288,7 +2293,7 @@ declare module "child_process" { stderr: T; status: number; signal: string; - error: Error; + error?: Error; } export function spawnSync(command: string): SpawnSyncReturns; export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; @@ -2897,7 +2902,7 @@ declare module "net" { listen(options: ListenOptions, listeningListener?: Function): this; listen(handle: any, backlog?: number, listeningListener?: Function): this; listen(handle: any, listeningListener?: Function): this; - close(callback?: Function): this; + close(callback?: (err?: Error) => void): this; address(): { port: number; family: string; address: string; }; getConnections(cb: (error: Error | null, count: number) => void): void; ref(): this; diff --git a/types/node/v8/node-tests.ts b/types/node/v8/node-tests.ts index 76f2ef380e..0ca392ab33 100644 --- a/types/node/v8/node-tests.ts +++ b/types/node/v8/node-tests.ts @@ -33,7 +33,7 @@ import * as perf_hooks from "perf_hooks"; import Module = require("module"); // Specifically test buffer module regression. -import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer"; +import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer, transcode, TranscodeEncoding } from "buffer"; ////////////////////////////////////////////////////////// /// Global Tests : https://nodejs.org/api/global.html /// @@ -568,6 +568,15 @@ function bufferTests() { let buffer = new Buffer('123'); let octets = new Uint8Array(buffer.buffer); } + + // Buffer module, transcode function + { + transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer + + const source: TranscodeEncoding = 'utf8'; + const target: TranscodeEncoding = 'ascii'; + transcode(Buffer.from('€'), source, target); // $ExpectType Buffer + } } //////////////////////////////////////////////////// @@ -1290,10 +1299,11 @@ namespace tls_tests { // close callback parameter is optional _server = _server.close(); - // close callback parameter doesn't specify any arguments, so any - // function is acceptable + // close callback parameter can be either nothing (undefined) or an error _server = _server.close(() => { }); - _server = _server.close((...args: any[]) => { }); + _server = _server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); } { @@ -2779,9 +2789,11 @@ namespace net_tests { .ref() .unref(); - // close has an optional callback function. No callback parameters are - // specified, so any callback function is permissible. - server = server.close((...args: any[]) => { }); + // close callback parameter can be either nothing (undefined) or an error + server = server.close(() => { }); + server = server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); // test the types of the address object fields let address = server.address(); diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 220afd9e60..ce36ad42d0 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -26,6 +26,8 @@ // Lishude // Andrew Makarov // Eugene Y. Q. Shen +// Jordi Oliveras Rovira +// Thanik Bhongbhibhat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** inspector module types */ @@ -993,6 +995,8 @@ declare module "buffer" { export var INSPECT_MAX_BYTES: number; var BuffType: typeof Buffer; var SlowBuffType: typeof SlowBuffer; + export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"; + export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer; export { BuffType as Buffer, SlowBuffType as SlowBuffer }; } @@ -1186,6 +1190,7 @@ declare module "http" { constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void); + readonly path: string; abort(): void; onSocket(socket: net.Socket): void; setTimeout(timeout: number, callback?: () => void): this; @@ -3312,7 +3317,7 @@ declare module "net" { listen(options: ListenOptions, listeningListener?: Function): this; listen(handle: any, backlog?: number, listeningListener?: Function): this; listen(handle: any, listeningListener?: Function): this; - close(callback?: Function): this; + close(callback?: (err?: Error) => void): this; address(): AddressInfo | string; getConnections(cb: (error: Error | null, count: number) => void): void; ref(): this; diff --git a/types/node/v9/node-tests.ts b/types/node/v9/node-tests.ts index e9c4f70ebb..7d29ffbf95 100644 --- a/types/node/v9/node-tests.ts +++ b/types/node/v9/node-tests.ts @@ -33,7 +33,7 @@ import * as perf_hooks from "perf_hooks"; import Module = require("module"); // Specifically test buffer module regression. -import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer"; +import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer, transcode, TranscodeEncoding } from "buffer"; ////////////////////////////////////////////////////////// /// Global Tests : https://nodejs.org/api/global.html /// @@ -594,6 +594,15 @@ function bufferTests() { let buffer = new Buffer('123'); let octets = new Uint8Array(buffer.buffer); } + + // Buffer module, transcode function + { + transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer + + const source: TranscodeEncoding = 'utf8'; + const target: TranscodeEncoding = 'ascii'; + transcode(Buffer.from('€'), source, target); // $ExpectType Buffer + } } //////////////////////////////////////////////////// @@ -1318,10 +1327,11 @@ namespace tls_tests { // close callback parameter is optional _server = _server.close(); - // close callback parameter doesn't specify any arguments, so any - // function is acceptable + // close callback parameter can be either nothing (undefined) or an error _server = _server.close(() => { }); - _server = _server.close((...args: any[]) => { }); + _server = _server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); } { @@ -2817,9 +2827,11 @@ namespace net_tests { .ref() .unref(); - // close has an optional callback function. No callback parameters are - // specified, so any callback function is permissible. - server = server.close((...args: any[]) => { }); + // close callback parameter can be either nothing (undefined) or an error + server = server.close(() => { }); + server = server.close((err) => { + if (typeof err !== 'undefined') { const _err: Error = err; } + }); // test the types of the address object fields let address: net.AddressInfo | string = server.address(); diff --git a/types/node/zlib.d.ts b/types/node/zlib.d.ts index dff374b8f5..60983fee91 100644 --- a/types/node/zlib.d.ts +++ b/types/node/zlib.d.ts @@ -2,9 +2,18 @@ declare module "zlib" { import * as stream from "stream"; interface ZlibOptions { - flush?: number; // default: zlib.constants.Z_NO_FLUSH - finishFlush?: number; // default: zlib.constants.Z_FINISH - chunkSize?: number; // default: 16*1024 + /** + * @default constants.Z_NO_FLUSH + */ + flush?: number; + /** + * @default constants.Z_FINISH + */ + finishFlush?: number; + /** + * @default 16*1024 + */ + chunkSize?: number; windowBits?: number; level?: number; // compression only memLevel?: number; // compression only @@ -12,6 +21,27 @@ declare module "zlib" { dictionary?: Buffer | NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default } + interface BrotliOptions { + /** + * @default constants.BROTLI_OPERATION_PROCESS + */ + flush?: number; + /** + * @default constants.BROTLI_OPERATION_FINISH + */ + finishFlush?: number; + /** + * @default 16*1024 + */ + chunkSize?: number; + params?: { + /** + * Each key is a `constants.BROTLI_*` constant. + */ + [key: number]: boolean | number; + }; + } + interface Zlib { /** @deprecated Use bytesWritten instead. */ readonly bytesRead: number; @@ -29,6 +59,8 @@ declare module "zlib" { reset(): void; } + interface BrotliCompress extends stream.Transform, Zlib { } + interface BrotliDecompress extends stream.Transform, Zlib { } interface Gzip extends stream.Transform, Zlib { } interface Gunzip extends stream.Transform, Zlib { } interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams { } @@ -37,6 +69,8 @@ declare module "zlib" { interface InflateRaw extends stream.Transform, Zlib, ZlibReset { } interface Unzip extends stream.Transform, Zlib { } + function createBrotliCompress(options?: BrotliOptions): BrotliCompress; + function createBrotliDecompress(options?: BrotliOptions): BrotliDecompress; function createGzip(options?: ZlibOptions): Gzip; function createGunzip(options?: ZlibOptions): Gunzip; function createDeflate(options?: ZlibOptions): Deflate; @@ -46,96 +80,273 @@ declare module "zlib" { function createUnzip(options?: ZlibOptions): Unzip; type InputType = string | Buffer | DataView | ArrayBuffer | NodeJS.TypedArray; - function deflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function deflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + + type CompressCallback = (error: Error | null, result: Buffer) => void; + + function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void; + function brotliCompress(buf: InputType, callback: CompressCallback): void; + function brotliCompressSync(buf: InputType, options?: BrotliOptions): Buffer; + function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void; + function brotliDecompress(buf: InputType, callback: CompressCallback): void; + function brotliDecompressSync(buf: InputType, options?: BrotliOptions): Buffer; + function deflate(buf: InputType, callback: CompressCallback): void; + function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function deflateSync(buf: InputType, options?: ZlibOptions): Buffer; - function deflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function deflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + function deflateRaw(buf: InputType, callback: CompressCallback): void; + function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer; - function gzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function gzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + function gzip(buf: InputType, callback: CompressCallback): void; + function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function gzipSync(buf: InputType, options?: ZlibOptions): Buffer; - function gunzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function gunzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + function gunzip(buf: InputType, callback: CompressCallback): void; + function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer; - function inflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function inflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + function inflate(buf: InputType, callback: CompressCallback): void; + function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function inflateSync(buf: InputType, options?: ZlibOptions): Buffer; - function inflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function inflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + function inflateRaw(buf: InputType, callback: CompressCallback): void; + function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer; - function unzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void; - function unzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void; + function unzip(buf: InputType, callback: CompressCallback): void; + function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void; function unzipSync(buf: InputType, options?: ZlibOptions): Buffer; namespace constants { - // Allowed flush values. + const BROTLI_DECODE: number; + const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number; + const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: number; + const BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: number; + const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: number; + const BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number; + const BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: number; + const BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: number; + const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: number; + const BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: number; + const BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: number; + const BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: number; + const BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: number; + const BROTLI_DECODER_ERROR_FORMAT_DISTANCE: number; + const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: number; + const BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: number; + const BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: number; + const BROTLI_DECODER_ERROR_FORMAT_PADDING_1: number; + const BROTLI_DECODER_ERROR_FORMAT_PADDING_2: number; + const BROTLI_DECODER_ERROR_FORMAT_RESERVED: number; + const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: number; + const BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: number; + const BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: number; + const BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: number; + const BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: number; + const BROTLI_DECODER_ERROR_UNREACHABLE: number; + const BROTLI_DECODER_NEEDS_MORE_INPUT: number; + const BROTLI_DECODER_NEEDS_MORE_OUTPUT: number; + const BROTLI_DECODER_NO_ERROR: number; + const BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: number; + const BROTLI_DECODER_PARAM_LARGE_WINDOW: number; + const BROTLI_DECODER_RESULT_ERROR: number; + const BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: number; + const BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: number; + const BROTLI_DECODER_RESULT_SUCCESS: number; + const BROTLI_DECODER_SUCCESS: number; - const Z_NO_FLUSH: number; - const Z_PARTIAL_FLUSH: number; - const Z_SYNC_FLUSH: number; - const Z_FULL_FLUSH: number; - const Z_FINISH: number; - const Z_BLOCK: number; - const Z_TREES: number; + const BROTLI_DEFAULT_MODE: number; + const BROTLI_DEFAULT_QUALITY: number; + const BROTLI_DEFAULT_WINDOW: number; + const BROTLI_ENCODE: number; + const BROTLI_LARGE_MAX_WINDOW_BITS: number; + const BROTLI_MAX_INPUT_BLOCK_BITS: number; + const BROTLI_MAX_QUALITY: number; + const BROTLI_MAX_WINDOW_BITS: number; + const BROTLI_MIN_INPUT_BLOCK_BITS: number; + const BROTLI_MIN_QUALITY: number; + const BROTLI_MIN_WINDOW_BITS: number; - // Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events. + const BROTLI_MODE_FONT: number; + const BROTLI_MODE_GENERIC: number; + const BROTLI_MODE_TEXT: number; - const Z_OK: number; - const Z_STREAM_END: number; - const Z_NEED_DICT: number; - const Z_ERRNO: number; - const Z_STREAM_ERROR: number; - const Z_DATA_ERROR: number; - const Z_MEM_ERROR: number; - const Z_BUF_ERROR: number; - const Z_VERSION_ERROR: number; + const BROTLI_OPERATION_EMIT_METADATA: number; + const BROTLI_OPERATION_FINISH: number; + const BROTLI_OPERATION_FLUSH: number; + const BROTLI_OPERATION_PROCESS: number; - // Compression levels. + const BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: number; + const BROTLI_PARAM_LARGE_WINDOW: number; + const BROTLI_PARAM_LGBLOCK: number; + const BROTLI_PARAM_LGWIN: number; + const BROTLI_PARAM_MODE: number; + const BROTLI_PARAM_NDIRECT: number; + const BROTLI_PARAM_NPOSTFIX: number; + const BROTLI_PARAM_QUALITY: number; + const BROTLI_PARAM_SIZE_HINT: number; + + const DEFLATE: number; + const DEFLATERAW: number; + const GUNZIP: number; + const GZIP: number; + const INFLATE: number; + const INFLATERAW: number; + const UNZIP: number; - const Z_NO_COMPRESSION: number; - const Z_BEST_SPEED: number; const Z_BEST_COMPRESSION: number; + const Z_BEST_SPEED: number; + const Z_BLOCK: number; + const Z_BUF_ERROR: number; + const Z_DATA_ERROR: number; + + const Z_DEFAULT_CHUNK: number; const Z_DEFAULT_COMPRESSION: number; - - // Compression strategy. - - const Z_FILTERED: number; - const Z_HUFFMAN_ONLY: number; - const Z_RLE: number; - const Z_FIXED: number; + const Z_DEFAULT_LEVEL: number; + const Z_DEFAULT_MEMLEVEL: number; const Z_DEFAULT_STRATEGY: number; + const Z_DEFAULT_WINDOWBITS: number; + + const Z_ERRNO: number; + const Z_FILTERED: number; + const Z_FINISH: number; + const Z_FIXED: number; + const Z_FULL_FLUSH: number; + const Z_HUFFMAN_ONLY: number; + const Z_MAX_CHUNK: number; + const Z_MAX_LEVEL: number; + const Z_MAX_MEMLEVEL: number; + const Z_MAX_WINDOWBITS: number; + const Z_MEM_ERROR: number; + const Z_MIN_CHUNK: number; + const Z_MIN_LEVEL: number; + const Z_MIN_MEMLEVEL: number; + const Z_MIN_WINDOWBITS: number; + const Z_NEED_DICT: number; + const Z_NO_COMPRESSION: number; + const Z_NO_FLUSH: number; + const Z_OK: number; + const Z_PARTIAL_FLUSH: number; + const Z_RLE: number; + const Z_STREAM_END: number; + const Z_STREAM_ERROR: number; + const Z_SYNC_FLUSH: number; + const Z_VERSION_ERROR: number; + const ZLIB_VERNUM: number; } - // Constants + /** + * @deprecated + */ const Z_NO_FLUSH: number; + /** + * @deprecated + */ const Z_PARTIAL_FLUSH: number; + /** + * @deprecated + */ const Z_SYNC_FLUSH: number; + /** + * @deprecated + */ const Z_FULL_FLUSH: number; + /** + * @deprecated + */ const Z_FINISH: number; + /** + * @deprecated + */ const Z_BLOCK: number; + /** + * @deprecated + */ const Z_TREES: number; + /** + * @deprecated + */ const Z_OK: number; + /** + * @deprecated + */ const Z_STREAM_END: number; + /** + * @deprecated + */ const Z_NEED_DICT: number; + /** + * @deprecated + */ const Z_ERRNO: number; + /** + * @deprecated + */ const Z_STREAM_ERROR: number; + /** + * @deprecated + */ const Z_DATA_ERROR: number; + /** + * @deprecated + */ const Z_MEM_ERROR: number; + /** + * @deprecated + */ const Z_BUF_ERROR: number; + /** + * @deprecated + */ const Z_VERSION_ERROR: number; + /** + * @deprecated + */ const Z_NO_COMPRESSION: number; + /** + * @deprecated + */ const Z_BEST_SPEED: number; + /** + * @deprecated + */ const Z_BEST_COMPRESSION: number; + /** + * @deprecated + */ const Z_DEFAULT_COMPRESSION: number; + /** + * @deprecated + */ const Z_FILTERED: number; + /** + * @deprecated + */ const Z_HUFFMAN_ONLY: number; + /** + * @deprecated + */ const Z_RLE: number; + /** + * @deprecated + */ const Z_FIXED: number; + /** + * @deprecated + */ const Z_DEFAULT_STRATEGY: number; + /** + * @deprecated + */ const Z_BINARY: number; + /** + * @deprecated + */ const Z_TEXT: number; + /** + * @deprecated + */ const Z_ASCII: number; + /** + * @deprecated + */ const Z_UNKNOWN: number; + /** + * @deprecated + */ const Z_DEFLATED: number; } diff --git a/types/normalize-url/index.d.ts b/types/normalize-url/index.d.ts deleted file mode 100644 index fd76c4f72a..0000000000 --- a/types/normalize-url/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Type definitions for normalize-url 3.3 -// Project: https://github.com/sindresorhus/normalize-url -// Definitions by: odin3 -// BendingBender -// Mathieu M-Gosselin -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace normalizeUrl { - interface Options { - defaultProtocol?: string; - forceHttp?: boolean; - forceHttps?: boolean; - normalizeProtocol?: boolean; - normalizeHttps?: boolean; - sortQueryParameters?: boolean; - stripFragment?: boolean; - stripHash?: boolean; - stripWWW?: boolean; - removeQueryParameters?: Array; - removeTrailingSlash?: boolean; - removeDirectoryIndex?: Array; - } -} - -declare function normalizeUrl(url: string, options?: normalizeUrl.Options): string; - -export = normalizeUrl; diff --git a/types/normalize-url/normalize-url-tests.ts b/types/normalize-url/normalize-url-tests.ts deleted file mode 100644 index 961be30c0d..0000000000 --- a/types/normalize-url/normalize-url-tests.ts +++ /dev/null @@ -1,17 +0,0 @@ -import normalizeUrl = require('normalize-url'); - -let str: string; -str = normalizeUrl('sindresorhus.com'); -str = normalizeUrl('HTTP://xn--xample-hva.com:80/?b=bar&a=foo'); - -normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false}); -normalizeUrl('https://sindresorhus.com:80/', {normalizeHttps: true}); -normalizeUrl('sindresorhus.com/about.html#contact', {stripFragment: false}); -normalizeUrl('http://www.sindresorhus.com/about.html#contact', {stripWWW: false}); -normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', { - removeQueryParameters: ['ref', /test/] -}); -normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false}); -normalizeUrl('www.sindresorhus.com/foo/default.php', { - removeDirectoryIndex: [/^default\.[a-z]+$/, 'foo'] -}); diff --git a/types/normalize-url/tsconfig.json b/types/normalize-url/tsconfig.json deleted file mode 100644 index 1626fe81b7..0000000000 --- a/types/normalize-url/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "normalize-url-tests.ts" - ] -} \ No newline at end of file diff --git a/types/normalize-url/tslint.json b/types/normalize-url/tslint.json deleted file mode 100644 index 279473e356..0000000000 --- a/types/normalize-url/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - // This package uses the Function type, and it will take effort to fix. - "ban-types": false - } -} diff --git a/types/npm-list-author-packages/index.d.ts b/types/npm-list-author-packages/index.d.ts new file mode 100644 index 0000000000..d482c7f514 --- /dev/null +++ b/types/npm-list-author-packages/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for npm-list-author-packages 2.0 +// Project: https://github.com/kgryte/npm-list-author-packages#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace list { + interface Options { + /** registry port. Default: 443 (HTTPS) or 80 (HTTP). */ + port?: 443 | 80; + /** registry protocol. Default: 'https'. */ + protocol?: 'http' | 'https'; + /** registry. Default: 'registry.npmjs.org'. */ + registry?: string; + /** author username (required). */ + username: string; + } + + type Callback = (error: Error | null, data: string[]) => void; + + function factory(opts: Options, callback: Callback): () => void; +} + +declare function list(opts: list.Options, callback: list.Callback): void; + +export = list; diff --git a/types/npm-list-author-packages/npm-list-author-packages-tests.ts b/types/npm-list-author-packages/npm-list-author-packages-tests.ts new file mode 100644 index 0000000000..4f2d08d778 --- /dev/null +++ b/types/npm-list-author-packages/npm-list-author-packages-tests.ts @@ -0,0 +1,18 @@ +import list = require('npm-list-author-packages'); + +const opts: list.Options = { + port: 80, + protocol: 'http', + registry: 'my.favorite.npm/registry', + username: 'kgryte', +}; + +list(opts, (error, data) => { + data; // $ExpectType string[] +}); + +const get = list.factory({ username: 'kgryte' }, (error, data) => { + data; // $ExpectType string[] +}); + +get(); diff --git a/types/npm-list-author-packages/tsconfig.json b/types/npm-list-author-packages/tsconfig.json new file mode 100644 index 0000000000..e05e42ead0 --- /dev/null +++ b/types/npm-list-author-packages/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "npm-list-author-packages-tests.ts" + ] +} diff --git a/types/p-map/tslint.json b/types/npm-list-author-packages/tslint.json similarity index 100% rename from types/p-map/tslint.json rename to types/npm-list-author-packages/tslint.json diff --git a/types/office-js-preview/index.d.ts b/types/office-js-preview/index.d.ts index 42544390d9..c36864f3dd 100644 --- a/types/office-js-preview/index.d.ts +++ b/types/office-js-preview/index.d.ts @@ -962,11 +962,11 @@ declare namespace Office { * * *Supported hosts, by platform* *
- * - * - * - * - * + * + * + * + * + * *
Office for Windows desktop Office Online (in browser) Office for iPad
Excel Y Y Y
Outlook Y (Mailbox 1.3)
PowerPoint Y Y Y
Word Y Y Y
Office for Windows desktop Office Online (in browser) Office for iPad
Excel Y Y Y
Outlook Y (Mailbox 1.3: without options
Mailbox Preview: with options)
PowerPoint Y Y Y
Word Y Y Y
* * @param options Optional. An object literal that contains one or more of the following properties. @@ -974,7 +974,7 @@ declare namespace Office { * this value indicates of the handled event should continue execution or be canceled. * For example, an add-in that handles the ItemSend event can set allowEvent = false to cancel sending of the message. */ - completed(options?: any): void; + completed(options?: { allowEvent: boolean }): void; } /** @@ -1633,7 +1633,7 @@ declare namespace Office { */ controlBackgroundColor: string; /** - * Gets the Office theme body control color as a hexadecimal color triplet (e.g. "FFA500"). + * Gets the Office theme control foreground color as a hexadecimal color triplet (e.g. "FFA500"). */ controlForegroundColor: string; } @@ -2051,6 +2051,12 @@ declare namespace Office { * [Api set: Mailbox 1.5] */ ItemChanged, + /** + * Triggers when the appointment location is changed in Outlook. + * + * [Api set: Mailbox Preview] + */ + EnhancedLocationsChanged, /** * Triggers when a customXmlPart node is deleted. */ @@ -10745,6 +10751,12 @@ declare namespace Office { * Gets the size of the attachment in bytes. */ size: number; + /** + * Gets the url of the attachment if its type is `MailboxEnums.AttachmentType.Cloud`. + * + * [Api set: Mailbox Preview] + */ + url: string; } /** * The body object provides methods for adding and updating the content of the message or appointment. @@ -12092,7 +12104,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12111,12 +12124,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12440,7 +12454,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12457,12 +12472,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12566,7 +12582,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -12575,10 +12591,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -12598,10 +12614,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** @@ -12953,7 +12969,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12972,12 +12989,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13341,7 +13359,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13358,12 +13377,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13466,7 +13486,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13491,7 +13512,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13692,7 +13714,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13709,13 +13732,14 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14251,7 +14275,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -14260,10 +14284,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -14283,10 +14307,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The read mode of {@link Office.Item | Office.context.mailbox.item}. @@ -15062,7 +15086,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15081,12 +15106,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15419,7 +15445,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15436,12 +15463,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15548,7 +15576,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -15556,10 +15584,10 @@ declare namespace Office { * applied in Outlook. If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -15579,10 +15607,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The message read mode of {@link Office.Item | Office.context.mailbox.item}. @@ -15948,7 +15976,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15967,12 +15996,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16340,7 +16370,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16357,12 +16388,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16625,7 +16657,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -16647,7 +16680,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -17038,7 +17072,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -17058,7 +17093,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -19307,6 +19343,47 @@ declare namespace Excel { */ type: "WorkbookAutoSaveSettingChanged"; } + /** + * + * Provide information about the detail of WorksheetChangedEvent/TableChangedEvent + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + interface ChangedEventDetail { + /** + * + * Represents the value after changed. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueAfter: any; + /** + * + * Represents the value before changed. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueBefore: any; + /** + * + * Represents the type of value after changed + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueTypeAfter: Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue"; + /** + * + * Represents the type of value before changed + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + valueTypeBefore: Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue"; + } /** * * Provides information about the worksheet that raised the Changed event. @@ -19328,6 +19405,13 @@ declare namespace Excel { * [Api set: ExcelApi 1.7] */ changeType: Excel.DataChangeType | "Unknown" | "RangeEdited" | "RowInserted" | "RowDeleted" | "ColumnInserted" | "ColumnDeleted" | "CellInserted" | "CellDeleted"; + /** + * + * Represents the information about the change detail + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + */ + details: Excel.ChangedEventDetail; /** * * Gets the source of the event. See Excel.EventSource for details. @@ -19468,6 +19552,13 @@ declare namespace Excel { * [Api set: ExcelApi 1.7] */ worksheetId: string; + /** + * + * Represents the information about the change detail + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + */ + details: Excel.ChangedEventDetail; /** * * Gets the range that represents the changed area of a table on a specific worksheet. @@ -21878,7 +21969,28 @@ declare namespace Excel { set(properties: Interfaces.RangeUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ set(properties: Excel.Range): void; + /** + * + * Fills range from the current range to the destination range. + The destination range must extend the source either horizontally or vertically. Discontiguous ranges are not supported. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param destinationRange The destination range to autofill. + * @param autoFillType The type of autofill. Specifies how the destination range is to be filled, based on the contents of the current range. Default is "FillDefault". + */ autoFill(destinationRange: Range | string, autoFillType?: Excel.AutoFillType): void; + /** + * + * Fills range from the current range to the destination range. + The destination range must extend the source either horizontally or vertically. Discontiguous ranges are not supported. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * + * @param destinationRange The destination range to autofill. + * @param autoFillType The type of autofill. Specifies how the destination range is to be filled, based on the contents of the current range. Default is "FillDefault". + */ autoFill(destinationRange: Range | string, autoFillType?: "FillDefault" | "FillCopy" | "FillSeries" | "FillFormats" | "FillValues" | "FillDays" | "FillWeekdays" | "FillMonths" | "FillYears" | "LinearTrend" | "GrowthTrend" | "FlashFill"): void; /** * @@ -21996,6 +22108,14 @@ declare namespace Excel { * @returns The Range which matched the search criteria. */ findOrNullObject(text: string, criteria: Excel.SearchCriteria): Excel.Range; + /** + * + * Does FlashFill to current range. Flash Fill will automatically fills data when it senses a pattern, so the range must be single column range and have data around in order to find pattern. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + flashFill(): void; /** * * Gets a Range object with the same top-left cell as the current Range object, but with the specified numbers of rows and columns. @@ -22205,7 +22325,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Gets the RangeAreas object, comprising one or more ranges, that represents all the cells that match the specified type and value. @@ -22228,7 +22348,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Gets the range object containing the anchor cell for a cell getting spilled into. Fails if applied to a range with more than one cell. Read only. @@ -22743,7 +22863,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCells(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Returns a RangeAreas object that represents all the cells that match the specified type and value. Returns a null object if no special cells are found that match the criteria. @@ -22765,7 +22885,7 @@ declare namespace Excel { * @param cellType The type of cells to include. * @param cellValueType If cellType is either Constants or Formulas, this argument is used to determine which types of cells to include in the result. These values can be combined together to return more than one type. The default is to select all constants or formulas, no matter what the type. */ - getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Comments" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; + getSpecialCellsOrNullObject(cellType: "ConditionalFormats" | "DataValidations" | "Blanks" | "Constants" | "Formulas" | "SameConditionalFormat" | "SameDataValidation" | "Visible", cellValueType?: "All" | "Errors" | "ErrorsLogical" | "ErrorsNumbers" | "ErrorsText" | "ErrorsLogicalNumber" | "ErrorsLogicalText" | "ErrorsNumberText" | "Logical" | "LogicalNumbers" | "LogicalText" | "LogicalNumbersText" | "Numbers" | "NumbersText" | "Text"): Excel.RangeAreas; /** * * Returns a scoped collection of tables that overlap with any range in this RangeAreas object. @@ -35177,7 +35297,7 @@ declare namespace Excel { * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta * - * @param index Index value of the object to be retrieved. Zero-indexed. + * @param index Index value of the style object to be retrieved. Zero-indexed. */ getItemAt(index: number): Excel.Style; /** @@ -36414,12 +36534,8 @@ declare namespace Excel { * @beta * * @param geometricShapeType Represents the geometric type of the shape. See Excel.GeometricShapeType for details. - * @param left The distance, in points, from the left side of the shape to the left side of the worksheet. - * @param top The distance, in points, from the top edge of the shape to the top of the worksheet. - * @param width The width, in points, of the shape. - * @param height The height, in points, of the shape. */ - addGeometricShape(geometricShapeType: Excel.GeometricShapeType, left: number, top: number, width: number, height: number): Excel.Shape; + addGeometricShape(geometricShapeType: Excel.GeometricShapeType): Excel.Shape; /** * * Adds a geometric shape to worksheet. Returns a Shape object that represents the new shape. @@ -36428,12 +36544,8 @@ declare namespace Excel { * @beta * * @param geometricShapeType Represents the geometric type of the shape. See Excel.GeometricShapeType for details. - * @param left The distance, in points, from the left side of the shape to the left side of the worksheet. - * @param top The distance, in points, from the top edge of the shape to the top of the worksheet. - * @param width The width, in points, of the shape. - * @param height The height, in points, of the shape. */ - addGeometricShape(geometricShapeType: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus", left: number, top: number, width: number, height: number): Excel.Shape; + addGeometricShape(geometricShapeType: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus"): Excel.Shape; /** * * Group a subset of shapes in a worksheet. Returns a Shape object that represents the new group of shapes. @@ -36644,6 +36756,14 @@ declare namespace Excel { * @beta */ altTextTitle: string; + /** + * + * Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly connectionSiteCount: number; /** * * Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -37201,6 +37321,22 @@ declare namespace Excel { class Line extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; + /** + * + * Represents the shape object that the beginning of the specified line is attached to. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly beginConnectedShape: Excel.Shape; + /** + * + * Represents the shape object that the end of the specified line is attached to. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly endConnectedShape: Excel.Shape; /** * * Returns the shape object for the line. Read-only. @@ -37209,6 +37345,70 @@ declare namespace Excel { * @beta */ readonly shape: Excel.Shape; + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the beginning of a connector is connected to. Read-only. Returns null when the beginning of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly beginConnectedSite: number; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the end of a connector is connected to. Read-only. Returns null when the end of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly endConnectedSite: number; /** * * Represents the shape identifier. Read-only. @@ -37217,6 +37417,22 @@ declare namespace Excel { * @beta */ readonly id: string; + /** + * + * Represents whether the beginning of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly isBeginConnected: boolean; + /** + * + * Represents whether the end of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + readonly isEndConnected: boolean; /** * * Represents the connector type for the line. @@ -37239,6 +37455,44 @@ declare namespace Excel { set(properties: Interfaces.LineUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ set(properties: Excel.Line): void; + /** + * + * Attaches the beginning of the specified connector to a specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param shape The shape to attach the beginning of the connector to. + * @param connectionSite The connection site on the shape which the beginning of the connector attach to. Must be an integer between 0 and the connection site count(not included) of the specified shape. + */ + beginConnect(shape: Excel.Shape, connectionSite: number): void; + /** + * + * Detaches the beginning of the specified connector from the shape it's attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginDisconnect(): void; + /** + * + * Attaches the end of the specified connector to a specified shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + * + * @param shape The shape to attach the end of the connector to. + * @param connectionSite The connection site on the shape which the end of the connector attach to. Must be an integer between 0 and the connection site count(not included) of the specified shape. + */ + endConnect(shape: Excel.Shape, connectionSite: number): void; + /** + * + * Detaches the end of the specified connector from the shape it's attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endDisconnect(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. * @@ -37468,6 +37722,13 @@ declare namespace Excel { class TextFrame extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; + /** + * + * Represents the text range in the text frame. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ readonly textRange: Excel.TextRange; /** * @@ -37874,7 +38135,7 @@ declare namespace Excel { nameInFormula: string; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -37890,7 +38151,7 @@ declare namespace Excel { style: string; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -37938,7 +38199,7 @@ declare namespace Excel { delete(): void; /** * - * Returns an array of selected items' names. Read-only. + * Returns an array of selected items' keys. Read-only. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -37946,8 +38207,8 @@ declare namespace Excel { getSelectedItems(): OfficeExtension.ClientResult; /** * - * Select slicer items based on their names. Previous selection will be cleared. - All items will be deselected if the array is empty. + * Select slicer items based on their keys. Previous selection will be cleared. + All items will be selected by default if the array is empty. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -38089,7 +38350,9 @@ declare namespace Excel { readonly hasData: boolean; /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -38934,6 +39197,36 @@ declare namespace Excel { systemDot = "SystemDot", systemDashDot = "SystemDashDot" } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ArrowHeadLength { + short = "Short", + medium = "Medium", + long = "Long" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ArrowHeadStyle { + none = "None", + triangle = "Triangle", + stealth = "Stealth", + diamond = "Diamond", + oval = "Oval", + open = "Open" + } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum ArrowHeadWidth { + narrow = "Narrow", + medium = "Medium", + wide = "Wide" + } /** * [Api set: ExcelApi 1.1] */ @@ -39846,7 +40139,13 @@ declare namespace Excel { * */ worksheetFormatChanged = "WorksheetFormatChanged", - wacoperationEvent = "WACOperationEvent" + wacoperationEvent = "WACOperationEvent", + /** + * + * RibbonCommandExecuted represents the type of event registered on ribbon, and occurs when user click on ribbon + * + */ + ribbonCommandExecuted = "RibbonCommandExecuted" } /** * [Api set: ExcelApi 1.7] @@ -40456,12 +40755,6 @@ declare namespace Excel { * */ blanks = "Blanks", - /** - * - * Cells containing comments. - * - */ - comments = "Comments", /** * * Cells containing constants. @@ -40755,6 +41048,24 @@ declare namespace Excel { ascending = "Ascending", descending = "Descending" } + /** + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + enum RibbonTab { + others = "Others", + home = "Home", + insert = "Insert", + draw = "Draw", + pageLayout = "PageLayout", + formulas = "Formulas", + data = "Data", + review = "Review", + view = "View", + developer = "Developer", + addIns = "AddIns", + help = "Help" + } /** * * An object containing the result of a function-evaluation operation @@ -48918,6 +49229,54 @@ declare namespace Excel { } /** An interface for updating data on the Line object, for use in "line.set({ ... })". */ interface LineUpdateData { + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; /** * * Represents the connector type for the line. @@ -49212,7 +49571,7 @@ declare namespace Excel { nameInFormula?: string; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -49228,7 +49587,7 @@ declare namespace Excel { style?: string; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -49253,7 +49612,9 @@ declare namespace Excel { interface SlicerItemUpdateData { /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -54636,6 +54997,14 @@ declare namespace Excel { * @beta */ altTextTitle?: string; + /** + * + * Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: number; /** * * Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -54808,6 +55177,70 @@ declare namespace Excel { } /** An interface describing the data returned by calling "line.toJSON()". */ interface LineData { + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the beginning of a connector is connected to. Read-only. Returns null when the beginning of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginConnectedSite?: number; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength?: Excel.ArrowHeadLength | "Short" | "Medium" | "Long"; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle?: Excel.ArrowHeadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth?: Excel.ArrowHeadWidth | "Narrow" | "Medium" | "Wide"; + /** + * + * Represents an integer that specifies the connection site that the end of a connector is connected to. Read-only. Returns null when the end of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endConnectedSite?: number; /** * * Represents the shape identifier. Read-only. @@ -54816,6 +55249,22 @@ declare namespace Excel { * @beta */ id?: string; + /** + * + * Represents whether the beginning of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isBeginConnected?: boolean; + /** + * + * Represents whether the end of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isEndConnected?: boolean; /** * * Represents the connector type for the line. @@ -55150,7 +55599,7 @@ declare namespace Excel { nameInFormula?: string; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -55166,7 +55615,7 @@ declare namespace Excel { style?: string; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -55199,7 +55648,9 @@ declare namespace Excel { hasData?: boolean; /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -63416,6 +63867,14 @@ declare namespace Excel { * @beta */ altTextTitle?: boolean; + /** + * + * For EACH ITEM in the collection: Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: boolean; /** * * For EACH ITEM in the collection: Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -63622,6 +64081,14 @@ declare namespace Excel { * @beta */ altTextTitle?: boolean; + /** + * + * Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: boolean; /** * * Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -63914,6 +64381,14 @@ declare namespace Excel { * @beta */ altTextTitle?: boolean; + /** + * + * For EACH ITEM in the collection: Returns the number of connection sites on the specified shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + connectionSiteCount?: boolean; /** * * For EACH ITEM in the collection: Represents the geometric shape type of the specified shape. See Excel.GeometricShapeType for detail. Returns null if the shape is not geometric, for example, get GeometricShapeType of a line or a chart will return null. @@ -64042,12 +64517,92 @@ declare namespace Excel { $all?: boolean; /** * + * Represents the shape object that the beginning of the specified line is attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginConnectedShape?: Excel.Interfaces.ShapeLoadOptions; + /** + * + * Represents the shape object that the end of the specified line is attached to. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endConnectedShape?: Excel.Interfaces.ShapeLoadOptions; + /** + * * Returns the shape object for the line. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta */ shape?: Excel.Interfaces.ShapeLoadOptions; + /** + * + * Represents the length of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadLength?: boolean; + /** + * + * Represents the style of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadStyle?: boolean; + /** + * + * Represents the width of the arrowhead at the beginning of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginArrowHeadWidth?: boolean; + /** + * + * Represents an integer that specifies the connection site that the beginning of a connector is connected to. Read-only. Returns null when the beginning of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + beginConnectedSite?: boolean; + /** + * + * Represents the length of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadLength?: boolean; + /** + * + * Represents the style of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadStyle?: boolean; + /** + * + * Represents the width of the arrowhead at the end of the specified line. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endArrowHeadWidth?: boolean; + /** + * + * Represents an integer that specifies the connection site that the end of a connector is connected to. Read-only. Returns null when the end of the line is not attached to any shape. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + endConnectedSite?: boolean; /** * * Represents the shape identifier. Read-only. @@ -64056,6 +64611,22 @@ declare namespace Excel { * @beta */ id?: boolean; + /** + * + * Represents whether the beginning of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isBeginConnected?: boolean; + /** + * + * Represents whether the end of the specified line is connected to a shape. Read-only. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ + isEndConnected?: boolean; /** * * Represents the connector type for the line. @@ -64166,6 +64737,13 @@ declare namespace Excel { */ interface TextFrameLoadOptions { $all?: boolean; + /** + * + * Represents the text range in the text frame. + * + * [Api set: ExcelApi BETA (PREVIEW ONLY)] + * @beta + */ textRange?: Excel.Interfaces.TextRangeLoadOptions; /** * @@ -64422,7 +65000,7 @@ declare namespace Excel { nameInFormula?: boolean; /** * - * Represents the sort order of the items in the slicer. + * Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64438,7 +65016,7 @@ declare namespace Excel { style?: boolean; /** * - * Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -64532,7 +65110,7 @@ declare namespace Excel { nameInFormula?: boolean; /** * - * For EACH ITEM in the collection: Represents the sort order of the items in the slicer. + * For EACH ITEM in the collection: Represents the sort order of the items in the slicer. Possible values are: DataSourceOrder, Ascending, Descending. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64548,7 +65126,7 @@ declare namespace Excel { style?: boolean; /** * - * For EACH ITEM in the collection: Represents the distance, in points, from the top edge of the slicer to the right of the worksheet. + * For EACH ITEM in the collection: Represents the distance, in points, from the top edge of the slicer to the top of the worksheet. Throws an invalid argument exception when set with negative value as input. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] @@ -64584,7 +65162,9 @@ declare namespace Excel { hasData?: boolean; /** * - * True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64626,7 +65206,9 @@ declare namespace Excel { hasData?: boolean; /** * - * For EACH ITEM in the collection: True if the slicer item is selected. Setting this value will not clear other SlicerItems' selected state. + * For EACH ITEM in the collection: True if the slicer item is selected. + Setting this value will not clear other SlicerItems' selected state. + By default, if the slicer item is the only one selected, when it is deselected, all items will be selected. * * [Api set: ExcelApi BETA (PREVIEW ONLY)] * @beta @@ -64675,6 +65257,7 @@ declare namespace Excel { } } + //////////////////////////////////////////////////////////////// //////////////////////// End Excel APIs //////////////////////// //////////////////////////////////////////////////////////////// diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index c207b00668..a9ad9e3de3 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -962,11 +962,11 @@ declare namespace Office { * * *Supported hosts, by platform* * - * - * - * - * - * + * + * + * + * + * *
Office for Windows desktop Office Online (in browser) Office for iPad
Excel Y Y Y
Outlook Y (Mailbox 1.3)
PowerPoint Y Y Y
Word Y Y Y
Office for Windows desktop Office Online (in browser) Office for iPad
Excel Y Y Y
Outlook Y (Mailbox 1.3: without options
Mailbox Preview: with options)
PowerPoint Y Y Y
Word Y Y Y
* * @param options Optional. An object literal that contains one or more of the following properties. @@ -974,7 +974,7 @@ declare namespace Office { * this value indicates of the handled event should continue execution or be canceled. * For example, an add-in that handles the ItemSend event can set allowEvent = false to cancel sending of the message. */ - completed(options?: any): void; + completed(options?: { allowEvent: boolean }): void; } /** @@ -1633,7 +1633,7 @@ declare namespace Office { */ controlBackgroundColor: string; /** - * Gets the Office theme body control color as a hexadecimal color triplet (e.g. "FFA500"). + * Gets the Office theme control foreground color as a hexadecimal color triplet (e.g. "FFA500"). */ controlForegroundColor: string; } @@ -2051,6 +2051,12 @@ declare namespace Office { * [Api set: Mailbox 1.5] */ ItemChanged, + /** + * Triggers when the appointment location is changed in Outlook. + * + * [Api set: Mailbox Preview] + */ + EnhancedLocationsChanged, /** * Triggers when a customXmlPart node is deleted. */ @@ -10745,6 +10751,12 @@ declare namespace Office { * Gets the size of the attachment in bytes. */ size: number; + /** + * Gets the url of the attachment if its type is `MailboxEnums.AttachmentType.Cloud`. + * + * [Api set: Mailbox Preview] + */ + url: string; } /** * The body object provides methods for adding and updating the content of the message or appointment. @@ -12091,8 +12103,9 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12111,12 +12124,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12440,7 +12454,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12457,12 +12472,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12566,7 +12582,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -12575,10 +12591,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -12598,10 +12614,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** @@ -12953,7 +12969,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -12972,12 +12989,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13341,7 +13359,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13358,12 +13377,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13466,7 +13486,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13491,7 +13512,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13692,7 +13714,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -13709,13 +13732,14 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -14251,7 +14275,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -14260,10 +14284,10 @@ declare namespace Office { * If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -14283,10 +14307,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The read mode of {@link Office.Item | Office.context.mailbox.item}. @@ -15062,7 +15086,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15081,12 +15106,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15419,7 +15445,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15436,12 +15463,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15548,7 +15576,7 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param options - An object literal that contains one or more of the following properties. + * @param options - Optional. An object literal that contains one or more of the following properties. * asyncContext: Developers can provide any object they wish to access in the callback method. * coercionType: If text, the current style is applied in Outlook Web App and Outlook. * If the field is an HTML editor, only the text data is inserted, even if the data is HTML. @@ -15556,10 +15584,10 @@ declare namespace Office { * applied in Outlook. If the field is a text field, an InvalidDataFormat error is returned. * If coercionType is not set, the result depends on the field: if the field is HTML then HTML is used; * if the field is text, then plain text is used. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, options: Office.AsyncContextOptions & CoercionTypeOptions, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, options?: Office.AsyncContextOptions & CoercionTypeOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Asynchronously inserts data into the body or subject of a message. * @@ -15579,10 +15607,10 @@ declare namespace Office { * * @param data - The data to be inserted. Data is not to exceed 1,000,000 characters. * If more than 1,000,000 characters are passed in, an ArgumentOutOfRange exception is thrown. - * @param callback - When the method completes, the function passed in the callback parameter is called with a single parameter of + * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of * type Office.AsyncResult. */ - setSelectedDataAsync(data: string, callback: (asyncResult: Office.AsyncResult) => void): void; + setSelectedDataAsync(data: string, callback?: (asyncResult: Office.AsyncResult) => void): void; } /** * The message read mode of {@link Office.Item | Office.context.mailbox.item}. @@ -15948,7 +15976,8 @@ declare namespace Office { * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -15967,12 +15996,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - addHandlerAsync(eventType: Office.EventType, handler: any, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Adds an event handler for a supported event. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16340,7 +16370,8 @@ declare namespace Office { * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16357,12 +16388,13 @@ declare namespace Office { * @param callback - Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, * asyncResult, which is an Office.AsyncResult object. */ - removeHandlerAsync(eventType: Office.EventType, options?: any, callback?: (asyncResult: Office.AsyncResult) => void): void; + removeHandlerAsync(eventType: Office.EventType, options?: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult) => void): void; /** * Removes the event handlers for a supported event type. * * Currently the supported event types are `Office.EventType.AppointmentTimeChanged`, `Office.EventType.RecipientsChanged`, and - * `Office.EventType.RecurrenceChanged`. In Preview, `Office.EventType.AttachmentsChanged` is also supported. + * `Office.EventType.RecurrenceChanged`. + * In Preview, `Office.EventType.AttachmentsChanged` and `Office.EventType.EnhancedLocationsChanged` are also supported. * * [Api set: Mailbox 1.7] * @@ -16625,7 +16657,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -16647,7 +16680,8 @@ declare namespace Office { /** * Adds an event handler for a supported event. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -17038,7 +17072,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -17058,7 +17093,8 @@ declare namespace Office { /** * Removes the event handlers for a supported event type. * - * Currently, the only supported event type is `Office.EventType.ItemChanged`. In Preview, `Office.EventType.OfficeThemeChanged` is also supported. + * Currently, the only supported event type is `Office.EventType.ItemChanged`. + * In Preview, `Office.EventType.OfficeThemeChanged` is also supported. * * [Api set: Mailbox 1.5] * @@ -32055,15 +32091,19 @@ declare namespace Excel { } /** * - * Represents a collection of all the styles. WARNING: The StyleCollection items array has a known issue when loading items from the collection. Do not use `StyleCollection.items`, any `load()` method, and the `toJSON()` method. - * + * Represents a collection of all the styles. + * WARNING: There's currently a known issue with the StyleCollection.items array when loading items from the collection. + * Until this issue is resolved, do not use the StyleCollection.items property, the StyleCollection.load() method, + * or the StyleCollection.toJSON() method. * [Api set: ExcelApi 1.7] */ class StyleCollection extends OfficeExtension.ClientObject { /** The request context associated with the object. This connects the add-in's process to the Office host application's process. */ context: RequestContext; - /** - * WARNING: The StyleCollection items array has a known issue when loading items from the collection. Do not use `StyleCollection.items`, any `load()` method, and the `toJSON()` method. + /** + * WARNING: There's currently a known issue with the `StyleCollection.items` array when loading items from the collection. + * Until this issue is resolved, do not use the `StyleCollection.items` property, the `StyleCollection.load()` method, + * or the `StyleCollection.toJSON()` method. */ readonly items: Excel.Style[]; /** @@ -32085,13 +32125,17 @@ declare namespace Excel { */ getItem(name: string): Excel.Style; /** - * WARNING: The StyleCollection items array has a known issue when loading items from the collection. Do not use `StyleCollection.items`, any `load()` method, and the `toJSON()` method. + * WARNING: There's currently a known issue with the `StyleCollection.items` array when loading items from the collection. + * Until this issue is resolved, do not use the `StyleCollection.items` property, the `StyleCollection.load()` method, + * or the `StyleCollection.toJSON()` method. */ load(option?: Excel.Interfaces.StyleCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.StyleCollection; load(option?: string | string[]): Excel.StyleCollection; load(option?: OfficeExtension.LoadOption): Excel.StyleCollection; /** - * WARNING: The StyleCollection items array has a known issue when loading items from the collection. Do not use `StyleCollection.items`, any `load()` method, and the `toJSON()` method. + * WARNING: There's currently a known issue with the `StyleCollection.items` array when loading items from the collection. + * Until this issue is resolved, do not use the `StyleCollection.items` property, the `StyleCollection.load()` method, + * or the `StyleCollection.toJSON()` method. */ toJSON(): Excel.Interfaces.StyleCollectionData; } diff --git a/types/ol/assertionerror/index.d.ts b/types/ol/AssertionError/index.d.ts similarity index 100% rename from types/ol/assertionerror/index.d.ts rename to types/ol/AssertionError/index.d.ts diff --git a/types/ol/attribution/index.d.ts b/types/ol/Attribution/index.d.ts similarity index 100% rename from types/ol/attribution/index.d.ts rename to types/ol/Attribution/index.d.ts diff --git a/types/ol/collection/index.d.ts b/types/ol/Collection/index.d.ts similarity index 100% rename from types/ol/collection/index.d.ts rename to types/ol/Collection/index.d.ts diff --git a/types/ol/disposable/index.d.ts b/types/ol/Disposable/index.d.ts similarity index 100% rename from types/ol/disposable/index.d.ts rename to types/ol/Disposable/index.d.ts diff --git a/types/ol/feature/index.d.ts b/types/ol/Feature/index.d.ts similarity index 100% rename from types/ol/feature/index.d.ts rename to types/ol/Feature/index.d.ts diff --git a/types/ol/geolocation/index.d.ts b/types/ol/Geolocation/index.d.ts similarity index 100% rename from types/ol/geolocation/index.d.ts rename to types/ol/Geolocation/index.d.ts diff --git a/types/ol/graticule/index.d.ts b/types/ol/Graticule/index.d.ts similarity index 100% rename from types/ol/graticule/index.d.ts rename to types/ol/Graticule/index.d.ts diff --git a/types/ol/image/index.d.ts b/types/ol/Image/index.d.ts similarity index 100% rename from types/ol/image/index.d.ts rename to types/ol/Image/index.d.ts diff --git a/types/ol/imagebase/index.d.ts b/types/ol/ImageBase/index.d.ts similarity index 100% rename from types/ol/imagebase/index.d.ts rename to types/ol/ImageBase/index.d.ts diff --git a/types/ol/imagetile/index.d.ts b/types/ol/ImageTile/index.d.ts similarity index 100% rename from types/ol/imagetile/index.d.ts rename to types/ol/ImageTile/index.d.ts diff --git a/types/ol/kinetic/index.d.ts b/types/ol/Kinetic/index.d.ts similarity index 100% rename from types/ol/kinetic/index.d.ts rename to types/ol/Kinetic/index.d.ts diff --git a/types/ol/map/index.d.ts b/types/ol/Map/index.d.ts similarity index 100% rename from types/ol/map/index.d.ts rename to types/ol/Map/index.d.ts diff --git a/types/ol/mapbrowserevent/index.d.ts b/types/ol/MapBrowserEvent/index.d.ts similarity index 100% rename from types/ol/mapbrowserevent/index.d.ts rename to types/ol/MapBrowserEvent/index.d.ts diff --git a/types/ol/mapbrowserpointerevent/index.d.ts b/types/ol/MapBrowserPointerEvent/index.d.ts similarity index 100% rename from types/ol/mapbrowserpointerevent/index.d.ts rename to types/ol/MapBrowserPointerEvent/index.d.ts diff --git a/types/ol/mapevent/index.d.ts b/types/ol/MapEvent/index.d.ts similarity index 100% rename from types/ol/mapevent/index.d.ts rename to types/ol/MapEvent/index.d.ts diff --git a/types/ol/object/index.d.ts b/types/ol/Object/index.d.ts similarity index 100% rename from types/ol/object/index.d.ts rename to types/ol/Object/index.d.ts diff --git a/types/ol/observable/index.d.ts b/types/ol/Observable/index.d.ts similarity index 100% rename from types/ol/observable/index.d.ts rename to types/ol/Observable/index.d.ts diff --git a/types/ol/overlay/index.d.ts b/types/ol/Overlay/index.d.ts similarity index 100% rename from types/ol/overlay/index.d.ts rename to types/ol/Overlay/index.d.ts diff --git a/types/ol/tile/index.d.ts b/types/ol/Tile/index.d.ts similarity index 100% rename from types/ol/tile/index.d.ts rename to types/ol/Tile/index.d.ts diff --git a/types/ol/vectortile/index.d.ts b/types/ol/VectorTile/index.d.ts similarity index 100% rename from types/ol/vectortile/index.d.ts rename to types/ol/VectorTile/index.d.ts diff --git a/types/ol/view/index.d.ts b/types/ol/View/index.d.ts similarity index 100% rename from types/ol/view/index.d.ts rename to types/ol/View/index.d.ts diff --git a/types/ol/control/attribution.d.ts b/types/ol/control/Attribution.d.ts similarity index 100% rename from types/ol/control/attribution.d.ts rename to types/ol/control/Attribution.d.ts diff --git a/types/ol/control/control.d.ts b/types/ol/control/Control.d.ts similarity index 100% rename from types/ol/control/control.d.ts rename to types/ol/control/Control.d.ts diff --git a/types/ol/control/fullscreen.d.ts b/types/ol/control/Fullscreen.d.ts similarity index 100% rename from types/ol/control/fullscreen.d.ts rename to types/ol/control/Fullscreen.d.ts diff --git a/types/ol/control/mouseposition.d.ts b/types/ol/control/MousePosition.d.ts similarity index 100% rename from types/ol/control/mouseposition.d.ts rename to types/ol/control/MousePosition.d.ts diff --git a/types/ol/control/overviewmap.d.ts b/types/ol/control/OverviewMap.d.ts similarity index 100% rename from types/ol/control/overviewmap.d.ts rename to types/ol/control/OverviewMap.d.ts diff --git a/types/ol/control/rotate.d.ts b/types/ol/control/Rotate.d.ts similarity index 100% rename from types/ol/control/rotate.d.ts rename to types/ol/control/Rotate.d.ts diff --git a/types/ol/control/scaleline.d.ts b/types/ol/control/ScaleLine.d.ts similarity index 100% rename from types/ol/control/scaleline.d.ts rename to types/ol/control/ScaleLine.d.ts diff --git a/types/ol/control/zoom.d.ts b/types/ol/control/Zoom.d.ts similarity index 100% rename from types/ol/control/zoom.d.ts rename to types/ol/control/Zoom.d.ts diff --git a/types/ol/control/zoomslider.d.ts b/types/ol/control/ZoomSlider.d.ts similarity index 100% rename from types/ol/control/zoomslider.d.ts rename to types/ol/control/ZoomSlider.d.ts diff --git a/types/ol/control/zoomtoextent.d.ts b/types/ol/control/ZoomToExtent.d.ts similarity index 100% rename from types/ol/control/zoomtoextent.d.ts rename to types/ol/control/ZoomToExtent.d.ts diff --git a/types/ol/events/event.d.ts b/types/ol/events/Event.d.ts similarity index 100% rename from types/ol/events/event.d.ts rename to types/ol/events/Event.d.ts diff --git a/types/ol/events/eventtarget.d.ts b/types/ol/events/EventTarget.d.ts similarity index 100% rename from types/ol/events/eventtarget.d.ts rename to types/ol/events/EventTarget.d.ts diff --git a/types/ol/format/esrijson.d.ts b/types/ol/format/EsriJSON.d.ts similarity index 100% rename from types/ol/format/esrijson.d.ts rename to types/ol/format/EsriJSON.d.ts diff --git a/types/ol/format/feature.d.ts b/types/ol/format/Feature.d.ts similarity index 100% rename from types/ol/format/feature.d.ts rename to types/ol/format/Feature.d.ts diff --git a/types/ol/format/gml2.d.ts b/types/ol/format/GML2.d.ts similarity index 100% rename from types/ol/format/gml2.d.ts rename to types/ol/format/GML2.d.ts diff --git a/types/ol/format/gml3.d.ts b/types/ol/format/GML3.d.ts similarity index 100% rename from types/ol/format/gml3.d.ts rename to types/ol/format/GML3.d.ts diff --git a/types/ol/format/gmlbase.d.ts b/types/ol/format/GMLBase.d.ts similarity index 100% rename from types/ol/format/gmlbase.d.ts rename to types/ol/format/GMLBase.d.ts diff --git a/types/ol/format/gpx.d.ts b/types/ol/format/GPX.d.ts similarity index 100% rename from types/ol/format/gpx.d.ts rename to types/ol/format/GPX.d.ts diff --git a/types/ol/format/geojson.d.ts b/types/ol/format/GeoJSON.d.ts similarity index 100% rename from types/ol/format/geojson.d.ts rename to types/ol/format/GeoJSON.d.ts diff --git a/types/ol/format/igc.d.ts b/types/ol/format/IGC.d.ts similarity index 100% rename from types/ol/format/igc.d.ts rename to types/ol/format/IGC.d.ts diff --git a/types/ol/format/jsonfeature.d.ts b/types/ol/format/JSONFeature.d.ts similarity index 100% rename from types/ol/format/jsonfeature.d.ts rename to types/ol/format/JSONFeature.d.ts diff --git a/types/ol/format/kml.d.ts b/types/ol/format/KML.d.ts similarity index 100% rename from types/ol/format/kml.d.ts rename to types/ol/format/KML.d.ts diff --git a/types/ol/format/mvt.d.ts b/types/ol/format/MVT.d.ts similarity index 100% rename from types/ol/format/mvt.d.ts rename to types/ol/format/MVT.d.ts diff --git a/types/ol/format/osmxml.d.ts b/types/ol/format/OSMXML.d.ts similarity index 100% rename from types/ol/format/osmxml.d.ts rename to types/ol/format/OSMXML.d.ts diff --git a/types/ol/format/polyline.d.ts b/types/ol/format/Polyline.d.ts similarity index 100% rename from types/ol/format/polyline.d.ts rename to types/ol/format/Polyline.d.ts diff --git a/types/ol/format/textfeature.d.ts b/types/ol/format/TextFeature.d.ts similarity index 100% rename from types/ol/format/textfeature.d.ts rename to types/ol/format/TextFeature.d.ts diff --git a/types/ol/format/topojson.d.ts b/types/ol/format/TopoJSON.d.ts similarity index 100% rename from types/ol/format/topojson.d.ts rename to types/ol/format/TopoJSON.d.ts diff --git a/types/ol/format/wfs.d.ts b/types/ol/format/WFS.d.ts similarity index 100% rename from types/ol/format/wfs.d.ts rename to types/ol/format/WFS.d.ts diff --git a/types/ol/format/wkt.d.ts b/types/ol/format/WKT.d.ts similarity index 100% rename from types/ol/format/wkt.d.ts rename to types/ol/format/WKT.d.ts diff --git a/types/ol/format/wmscapabilities.d.ts b/types/ol/format/WMSCapabilities.d.ts similarity index 100% rename from types/ol/format/wmscapabilities.d.ts rename to types/ol/format/WMSCapabilities.d.ts diff --git a/types/ol/format/wmsgetfeatureinfo.d.ts b/types/ol/format/WMSGetFeatureInfo.d.ts similarity index 100% rename from types/ol/format/wmsgetfeatureinfo.d.ts rename to types/ol/format/WMSGetFeatureInfo.d.ts diff --git a/types/ol/format/wmtscapabilities.d.ts b/types/ol/format/WMTSCapabilities.d.ts similarity index 100% rename from types/ol/format/wmtscapabilities.d.ts rename to types/ol/format/WMTSCapabilities.d.ts diff --git a/types/ol/format/xml.d.ts b/types/ol/format/XML.d.ts similarity index 100% rename from types/ol/format/xml.d.ts rename to types/ol/format/XML.d.ts diff --git a/types/ol/format/xmlfeature.d.ts b/types/ol/format/XMLFeature.d.ts similarity index 100% rename from types/ol/format/xmlfeature.d.ts rename to types/ol/format/XMLFeature.d.ts diff --git a/types/ol/geom/circle.d.ts b/types/ol/geom/Circle.d.ts similarity index 100% rename from types/ol/geom/circle.d.ts rename to types/ol/geom/Circle.d.ts diff --git a/types/ol/geom/geometry.d.ts b/types/ol/geom/Geometry.d.ts similarity index 100% rename from types/ol/geom/geometry.d.ts rename to types/ol/geom/Geometry.d.ts diff --git a/types/ol/geom/geometrycollection.d.ts b/types/ol/geom/GeometryCollection.d.ts similarity index 100% rename from types/ol/geom/geometrycollection.d.ts rename to types/ol/geom/GeometryCollection.d.ts diff --git a/types/ol/geom/linestring.d.ts b/types/ol/geom/LineString.d.ts similarity index 100% rename from types/ol/geom/linestring.d.ts rename to types/ol/geom/LineString.d.ts diff --git a/types/ol/geom/linearring.d.ts b/types/ol/geom/LinearRing.d.ts similarity index 100% rename from types/ol/geom/linearring.d.ts rename to types/ol/geom/LinearRing.d.ts diff --git a/types/ol/geom/multipoint.d.ts b/types/ol/geom/MultiPoint.d.ts similarity index 100% rename from types/ol/geom/multipoint.d.ts rename to types/ol/geom/MultiPoint.d.ts diff --git a/types/ol/geom/multipolygon.d.ts b/types/ol/geom/MultiPolygon.d.ts similarity index 100% rename from types/ol/geom/multipolygon.d.ts rename to types/ol/geom/MultiPolygon.d.ts diff --git a/types/ol/geom/multilinestring.d.ts b/types/ol/geom/MultilineString.d.ts similarity index 100% rename from types/ol/geom/multilinestring.d.ts rename to types/ol/geom/MultilineString.d.ts diff --git a/types/ol/geom/point.d.ts b/types/ol/geom/Point.d.ts similarity index 100% rename from types/ol/geom/point.d.ts rename to types/ol/geom/Point.d.ts diff --git a/types/ol/geom/polygon.d.ts b/types/ol/geom/Polygon.d.ts similarity index 100% rename from types/ol/geom/polygon.d.ts rename to types/ol/geom/Polygon.d.ts diff --git a/types/ol/geom/simplegeometry.d.ts b/types/ol/geom/SimpleGeometry.d.ts similarity index 100% rename from types/ol/geom/simplegeometry.d.ts rename to types/ol/geom/SimpleGeometry.d.ts diff --git a/types/ol/interaction/doubleclickzoom.d.ts b/types/ol/interaction/DoubleClickZoom.d.ts similarity index 100% rename from types/ol/interaction/doubleclickzoom.d.ts rename to types/ol/interaction/DoubleClickZoom.d.ts diff --git a/types/ol/interaction/draganddrop.d.ts b/types/ol/interaction/DragAndDrop.d.ts similarity index 100% rename from types/ol/interaction/draganddrop.d.ts rename to types/ol/interaction/DragAndDrop.d.ts diff --git a/types/ol/interaction/dragbox.d.ts b/types/ol/interaction/DragBox.d.ts similarity index 100% rename from types/ol/interaction/dragbox.d.ts rename to types/ol/interaction/DragBox.d.ts diff --git a/types/ol/interaction/dragpan.d.ts b/types/ol/interaction/DragPan.d.ts similarity index 100% rename from types/ol/interaction/dragpan.d.ts rename to types/ol/interaction/DragPan.d.ts diff --git a/types/ol/interaction/dragrotate.d.ts b/types/ol/interaction/DragRotate.d.ts similarity index 100% rename from types/ol/interaction/dragrotate.d.ts rename to types/ol/interaction/DragRotate.d.ts diff --git a/types/ol/interaction/dragrotateandzoom.d.ts b/types/ol/interaction/DragRotateAndZoom.d.ts similarity index 100% rename from types/ol/interaction/dragrotateandzoom.d.ts rename to types/ol/interaction/DragRotateAndZoom.d.ts diff --git a/types/ol/interaction/dragzoom.d.ts b/types/ol/interaction/DragZoom.d.ts similarity index 100% rename from types/ol/interaction/dragzoom.d.ts rename to types/ol/interaction/DragZoom.d.ts diff --git a/types/ol/interaction/draw.d.ts b/types/ol/interaction/Draw.d.ts similarity index 100% rename from types/ol/interaction/draw.d.ts rename to types/ol/interaction/Draw.d.ts diff --git a/types/ol/interaction/extent.d.ts b/types/ol/interaction/Extent.d.ts similarity index 100% rename from types/ol/interaction/extent.d.ts rename to types/ol/interaction/Extent.d.ts diff --git a/types/ol/interaction/interaction.d.ts b/types/ol/interaction/Interaction.d.ts similarity index 100% rename from types/ol/interaction/interaction.d.ts rename to types/ol/interaction/Interaction.d.ts diff --git a/types/ol/interaction/keyboardpan.d.ts b/types/ol/interaction/KeyboardPan.d.ts similarity index 100% rename from types/ol/interaction/keyboardpan.d.ts rename to types/ol/interaction/KeyboardPan.d.ts diff --git a/types/ol/interaction/keyboardzoom.d.ts b/types/ol/interaction/KeyboardZoom.d.ts similarity index 100% rename from types/ol/interaction/keyboardzoom.d.ts rename to types/ol/interaction/KeyboardZoom.d.ts diff --git a/types/ol/interaction/modify.d.ts b/types/ol/interaction/Modify.d.ts similarity index 100% rename from types/ol/interaction/modify.d.ts rename to types/ol/interaction/Modify.d.ts diff --git a/types/ol/interaction/mousewheelzoom.d.ts b/types/ol/interaction/MouseWheelZoom.d.ts similarity index 100% rename from types/ol/interaction/mousewheelzoom.d.ts rename to types/ol/interaction/MouseWheelZoom.d.ts diff --git a/types/ol/interaction/pinchrotate.d.ts b/types/ol/interaction/PinchRotate.d.ts similarity index 100% rename from types/ol/interaction/pinchrotate.d.ts rename to types/ol/interaction/PinchRotate.d.ts diff --git a/types/ol/interaction/pinchzoom.d.ts b/types/ol/interaction/PinchZoom.d.ts similarity index 100% rename from types/ol/interaction/pinchzoom.d.ts rename to types/ol/interaction/PinchZoom.d.ts diff --git a/types/ol/interaction/pointer.d.ts b/types/ol/interaction/Pointer.d.ts similarity index 100% rename from types/ol/interaction/pointer.d.ts rename to types/ol/interaction/Pointer.d.ts diff --git a/types/ol/interaction/select.d.ts b/types/ol/interaction/Select.d.ts similarity index 100% rename from types/ol/interaction/select.d.ts rename to types/ol/interaction/Select.d.ts diff --git a/types/ol/interaction/snap.d.ts b/types/ol/interaction/Snap.d.ts similarity index 100% rename from types/ol/interaction/snap.d.ts rename to types/ol/interaction/Snap.d.ts diff --git a/types/ol/interaction/translate.d.ts b/types/ol/interaction/Translate.d.ts similarity index 100% rename from types/ol/interaction/translate.d.ts rename to types/ol/interaction/Translate.d.ts diff --git a/types/ol/layer/base.d.ts b/types/ol/layer/Base.d.ts similarity index 100% rename from types/ol/layer/base.d.ts rename to types/ol/layer/Base.d.ts diff --git a/types/ol/layer/group.d.ts b/types/ol/layer/Group.d.ts similarity index 100% rename from types/ol/layer/group.d.ts rename to types/ol/layer/Group.d.ts diff --git a/types/ol/layer/heatmap.d.ts b/types/ol/layer/Heatmap.d.ts similarity index 100% rename from types/ol/layer/heatmap.d.ts rename to types/ol/layer/Heatmap.d.ts diff --git a/types/ol/layer/image.d.ts b/types/ol/layer/Image.d.ts similarity index 100% rename from types/ol/layer/image.d.ts rename to types/ol/layer/Image.d.ts diff --git a/types/ol/layer/layer.d.ts b/types/ol/layer/Layer.d.ts similarity index 100% rename from types/ol/layer/layer.d.ts rename to types/ol/layer/Layer.d.ts diff --git a/types/ol/layer/tile.d.ts b/types/ol/layer/Tile.d.ts similarity index 100% rename from types/ol/layer/tile.d.ts rename to types/ol/layer/Tile.d.ts diff --git a/types/ol/layer/vector.d.ts b/types/ol/layer/Vector.d.ts similarity index 100% rename from types/ol/layer/vector.d.ts rename to types/ol/layer/Vector.d.ts diff --git a/types/ol/layer/vectortile.d.ts b/types/ol/layer/VectorTile.d.ts similarity index 100% rename from types/ol/layer/vectortile.d.ts rename to types/ol/layer/VectorTile.d.ts diff --git a/types/ol/ol-tests.ts b/types/ol/ol-tests.ts index be19e61a2b..f8117f43ac 100644 --- a/types/ol/ol-tests.ts +++ b/types/ol/ol-tests.ts @@ -1,317 +1,163 @@ -import ControlAttribution from 'ol/control/attribution'; - -import ControlControl from 'ol/control/control'; - -import ControlFullScreen from 'ol/control/fullscreen'; - -import ControlMousePosition from 'ol/control/mouseposition'; - -import ControlOverviewMap from 'ol/control/overviewmap'; - -import ControlRotate from 'ol/control/rotate'; - -import ControlScaleLine from 'ol/control/scaleline'; - -import ControlZoom from 'ol/control/zoom'; - -import ControlZoomSlider from 'ol/control/zoomslider'; - -import ControlZoomToExtent from 'ol/control/zoomtoextent'; - -import Eventscondition from 'ol/events/condition'; - -import EventsEvent from 'ol/events/event'; - -import EventsEventTarget from 'ol/events/eventtarget'; - -import FormatEsriJSON from 'ol/format/esrijson'; - -import FormatFeature from 'ol/format/feature'; - -import Formatfilter from 'ol/format/filter'; - -import FormatGeoJSON from 'ol/format/geojson'; - -import FormatGML2 from 'ol/format/gml2'; - -import FormatGML3 from 'ol/format/gml3'; - -import FormatGMLBase from 'ol/format/gmlbase'; - -import FormatGPX from 'ol/format/gpx'; - -import FormatIGC from 'ol/format/igc'; - -import FormatJSONFeature from 'ol/format/jsonfeature'; - -import FormatKML from 'ol/format/kml'; - -import FormatMVT from 'ol/format/mvt'; - -import FormatOSMXML from 'ol/format/osmxml'; - -import FormatPolyline from 'ol/format/polyline'; - -import FormatTextFeature from 'ol/format/textfeature'; - -import FormatTopoJSON from 'ol/format/topojson'; - -import FormatWFS from 'ol/format/wfs'; - -import FormatWKT from 'ol/format/wkt'; - -import FormatWMSCapabilities from 'ol/format/wmscapabilities'; - -import FormatWMSGetFeatureInfo from 'ol/format/wmsgetfeatureinfo'; - -import FormatWMTSCapabilities from 'ol/format/wmtscapabilities'; - -import FormatXML from 'ol/format/xml'; - -import FormatXMLFeature from 'ol/format/xmlfeature'; - -import GeomCircle from 'ol/geom/circle'; - -import GeomGeometry from 'ol/geom/geometry'; - -import GeomGeometryCollection from 'ol/geom/geometrycollection'; - -import GeomLinearRing from 'ol/geom/linearring'; - -import GeomLineString from 'ol/geom/linestring'; - -import GeomMultiLineString from 'ol/geom/multilinestring'; - -import GeomMultiPoint from 'ol/geom/multipoint'; - -import GeomMultiPolygon from 'ol/geom/multipolygon'; - -import GeomPoint from 'ol/geom/point'; - -import GeomPolygon from 'ol/geom/polygon'; - -import GeomSimpleGeometry from 'ol/geom/simplegeometry'; - -import InteractionDoubleClickZoom from 'ol/interaction/doubleclickzoom'; - -import InteractionDragAndDrop from 'ol/interaction/draganddrop'; - -import InteractionDragBox from 'ol/interaction/dragbox'; - -import InteractionDragPan from 'ol/interaction/dragpan'; - -import InteractionDragRotate from 'ol/interaction/dragrotate'; - -import InteractionDragRotateAndZoom from 'ol/interaction/dragrotateandzoom'; - -import InteractionDragZoom from 'ol/interaction/dragzoom'; - -import InteractionDraw from 'ol/interaction/draw'; - -import InteractionInteraction from 'ol/interaction/interaction'; - -import InteractionKeyboardPan from 'ol/interaction/keyboardpan'; - -import InteractionKeyboardZoom from 'ol/interaction/keyboardzoom'; - -import InteractionModify from 'ol/interaction/modify'; - -import InteractionMouseWheelZoom from 'ol/interaction/mousewheelzoom'; - -import InteractionPinchRotate from 'ol/interaction/pinchrotate'; - -import InteractionPinchZoom from 'ol/interaction/pinchzoom'; - -import InteractionPointer from 'ol/interaction/pointer'; - -import InteractionSelect from 'ol/interaction/select'; - -import InteractionSnap from 'ol/interaction/snap'; - -import InteractionTranslate from 'ol/interaction/translate'; - -import LayerBase from 'ol/layer/base'; - -import LayerGroup from 'ol/layer/group'; - -import LayerHeatmap from 'ol/layer/heatmap'; - -import LayerImage from 'ol/layer/image'; - -import LayerLayer from 'ol/layer/layer'; - -import LayerTile from 'ol/layer/tile'; - -import LayerVector from 'ol/layer/vector'; - -import LayerVectorTile from 'ol/layer/vectortile'; - -import PointerPointerEvent from 'ol/pointer/pointerevent'; - -import Proj from 'ol/proj'; - -import ProjProjection from 'ol/proj/projection'; - -import Rendercanvas from 'ol/render/canvas'; - -import RenderEvent from 'ol/render/event'; - -import RenderFeature from 'ol/render/feature'; - -import RenderVectorContext from 'ol/render/vectorcontext'; - -import SourceBingMaps from 'ol/source/bingmaps'; - -import SourceCartoDB from 'ol/source/cartodb'; - -import SourceCluster from 'ol/source/cluster'; - -import SourceImage from 'ol/source/image'; - -import SourceImageArcGISRest from 'ol/source/imagearcgisrest'; - -import SourceImageCanvas from 'ol/source/imagecanvas'; - -import SourceImageMapGuide from 'ol/source/imagemapguide'; - -import SourceImageStatic from 'ol/source/imagestatic'; - -import SourceImageVector from 'ol/source/imagevector'; - -import SourceImageWMS from 'ol/source/imagewms'; - -import SourceOSM from 'ol/source/osm'; - -import SourceRaster from 'ol/source/raster'; - -import SourceSource from 'ol/source/source'; - -import SourceStamen from 'ol/source/stamen'; - -import SourceTile from 'ol/source/tile'; - -import SourceTileArcGISRest from 'ol/source/tilearcgisrest'; - -import SourceTileDebug from 'ol/source/tiledebug'; - -import SourceTileImage from 'ol/source/tileimage'; - -import SourceTileJSON from 'ol/source/tilejson'; - -import SourceTileUTFGrid from 'ol/source/tileutfgrid'; - -import SourceTileWMS from 'ol/source/tilewms'; - -import SourceUrlTile from 'ol/source/urltile'; - -import SourceVector from 'ol/source/vector'; - -import SourceVectorTile from 'ol/source/vectortile'; - -import SourceWMTS from 'ol/source/wmts'; - -import SourceXYZ from 'ol/source/xyz'; - -import SourceZoomify from 'ol/source/zoomify'; - -import StyleAtlasManager from 'ol/style/atlasmanager'; - -import StyleCircle from 'ol/style/circle'; - -import StyleFill from 'ol/style/fill'; - -import StyleIcon from 'ol/style/icon'; - -import StyleImage from 'ol/style/image'; - -import StyleRegularShape from 'ol/style/regularshape'; - -import StyleStroke from 'ol/style/stroke'; - -import StyleStyle from 'ol/style/style'; - -import StyleText from 'ol/style/text'; - -import TilegridTileGrid from 'ol/tilegrid/tilegrid'; - -import TilegridWMTS from 'ol/tilegrid/wmts'; - -import AssertionError from 'ol/assertionerror'; - -import Attribution from 'ol/attribution'; - -import Collection from 'ol/collection'; - -import Color from 'ol/color'; - -import Colorlike from 'ol/colorlike'; - -import Control from 'ol/control'; - +import AssertionError from 'ol/AssertionError'; +import AtlasManager from 'ol/style/AtlasManager'; +// import Attribution from 'ol/Attribution'; +import Attribution from 'ol/control/Attribution'; +import Base from 'ol/layer/Base'; +import BingMaps from 'ol/source/BingMaps'; +import canvas from 'ol/render/canvas'; +import CartoDB from 'ol/source/CartoDB'; +import Circle from 'ol/geom/Circle'; +// import Circle from 'ol/style/Circle'; +import Cluster from 'ol/source/Cluster'; +import Collection from 'ol/Collection'; +import color from 'ol/color'; +import colorlike from 'ol/colorlike'; +import condition from 'ol/events/condition'; +import control from 'ol/control'; +import Control from 'ol/control/Control'; +// import coordinate from 'ol/coordinate'; import DeviceOrientation from 'ol/deviceorientation'; - -import Disposable from 'ol/disposable'; - -import Easing from 'ol/easing'; - -import Events from 'ol/events'; - -import Extent from 'ol/extent'; - -import Feature from 'ol/feature'; - -import FeatureLoader from 'ol/featureloader'; - -import Geolocation from 'ol/geolocation'; - -import Graticule from 'ol/graticule'; - -import Image from 'ol/image'; - -import ImageBase from 'ol/imagebase'; - -import ImageTile from 'ol/imagetile'; - -import Interaction from 'ol/interaction'; - -import Kinetic from 'ol/kinetic'; - -import Loadingstrategy from 'ol/loadingstrategy'; - -import Map from 'ol/map'; - -import MapBrowserEvent from 'ol/mapbrowserevent'; - -import MapBrowserPointerEvent from 'ol/mapbrowserpointerevent'; - -import MapEvent from 'ol/mapevent'; - -import Object from 'ol/object'; - -import Observable from 'ol/observable'; - -import Overlay from 'ol/overlay'; - +import Disposable from 'ol/Disposable'; +import DoubleClickZoom from 'ol/interaction/DoubleClickZoom'; +import DragAndDrop from 'ol/interaction/DragAndDrop'; +import DragBox from 'ol/interaction/DragBox'; +import DragPan from 'ol/interaction/DragPan'; +import DragRotateAndZoom from 'ol/interaction/DragRotateAndZoom'; +import DragRotate from 'ol/interaction/DragRotate'; +import DragZoom from 'ol/interaction/DragZoom'; +import Draw from 'ol/interaction/Draw'; +import easing from 'ol/easing'; +import EsriJSON from 'ol/format/EsriJSON'; +// import Event from 'ol/events/Event'; +import Event from 'ol/render/Event'; +import events from 'ol/events'; +import EventTarget from 'ol/events/EventTarget'; +import extent from 'ol/extent'; +import Extent from 'ol/interaction/Extent'; +// import Feature from 'ol/Feature'; +import Feature from 'ol/format/Feature'; +// import Feature from 'ol/render/Feature'; +import featureloader from 'ol/featureloader'; +import Fill from 'ol/style/Fill'; +import filter from 'ol/format/filter'; +import FullScreen from 'ol/control/Fullscreen'; +import GeoJSON from 'ol/format/GeoJSON'; +import Geolocation from 'ol/Geolocation'; +import GeometryCollection from 'ol/geom/GeometryCollection'; +import Geometry from 'ol/geom/Geometry'; +import GML2 from 'ol/format/GML2'; +import GML3 from 'ol/format/GML3'; +import GMLBase from 'ol/format/GMLBase'; +import GPX from 'ol/format/GPX'; +import Graticule from 'ol/Graticule'; +import Group from 'ol/layer/Group'; +import Heatmap from 'ol/layer/Heatmap'; +import Icon from 'ol/style/Icon'; +import IGC from 'ol/format/IGC'; +import ImageArcGISRest from 'ol/source/ImageArcGISRest'; +import ImageBase from 'ol/ImageBase'; +import ImageCanvas from 'ol/source/ImageCanvas'; +// import Image from 'ol/Image'; +import Image from 'ol/layer/Image'; +// import Image from 'ol/source/Image'; +// import Image from 'ol/style/Image'; +import ImageMapGuide from 'ol/source/ImageMapGuide'; +import ImageStatic from 'ol/source/ImageStatic'; +import ImageTile from 'ol/ImageTile'; +import ImageVector from 'ol/source/ImageVector'; +import ImageWMS from 'ol/source/ImageWMS'; +import interaction from 'ol/interaction'; +import Interaction from 'ol/interaction/Interaction'; +import JSONFeature from 'ol/format/JSONFeature'; +import KeyboardPan from 'ol/interaction/KeyboardPan'; +import KeyboardZoom from 'ol/interaction/KeyboardZoom'; +import Kinetic from 'ol/Kinetic'; +import KML from 'ol/format/KML'; +import Layer from 'ol/layer/Layer'; +import LinearRing from 'ol/geom/LinearRing'; +import LineString from 'ol/geom/LineString'; +import loadingstrategy from 'ol/loadingstrategy'; +import MapBrowserEvent from 'ol/MapBrowserEvent'; +import MapBrowserPointerEvent from 'ol/MapBrowserPointerEvent'; +import MapEvent from 'ol/MapEvent'; +import Map from 'ol/Map'; +import Modify from 'ol/interaction/Modify'; +import MousePosition from 'ol/control/MousePosition'; +import MouseWheelZoom from 'ol/interaction/MouseWheelZoom'; +import MultiLineString from 'ol/geom/MultilineString'; +import MultiPoint from 'ol/geom/MultiPoint'; +import MultiPolygon from 'ol/geom/MultiPolygon'; +import MVT from 'ol/format/MVT'; +import Object from 'ol/Object'; +import Observable from 'ol/Observable'; +import ol from 'ol'; +import OSM from 'ol/source/OSM'; +import OSMXML from 'ol/format/OSMXML'; +import Overlay from 'ol/Overlay'; +import OverviewMap from 'ol/control/OverviewMap'; +import PinchRotate from 'ol/interaction/PinchRotate'; +import PinchZoom from 'ol/interaction/PinchZoom'; +import PointerEvent from 'ol/pointer/PointerEvent'; +import Pointer from 'ol/interaction/Pointer'; +import Point from 'ol/geom/Point'; +import Polygon from 'ol/geom/Polygon'; +import Polyline from 'ol/format/Polyline'; +import Projection from 'ol/proj/Projection'; +import proj from 'ol/proj'; +import Raster from 'ol/source/Raster'; +import RegularShape from 'ol/style/RegularShape'; +import Rotate from 'ol/control/Rotate'; +import ScaleLine from 'ol/control/ScaleLine'; +import Select from 'ol/interaction/Select'; +import SimpleGeometry from 'ol/geom/SimpleGeometry'; +import Snap from 'ol/interaction/Snap'; +import Source from 'ol/source/Source'; import Sphere from 'ol/sphere'; - -import Tile from 'ol/tile'; - -import Tilegrid from 'ol/tilegrid'; - -import VectorTile from 'ol/vectortile'; - -import View from 'ol/view'; +import Stamen from 'ol/source/Stamen'; +import Stroke from 'ol/style/Stroke'; +import Style from 'ol/style/Style'; +import TextFeature from 'ol/format/TextFeature'; +import Text from 'ol/style/Text'; +import TileArcGISRest from 'ol/source/TileArcGISRest'; +import TileDebug from 'ol/source/TileDebug'; +import Tile from 'ol/layer/Tile'; +// import Tile from 'ol/source/Tile'; +// import Tile from 'ol/Tile'; +import tilegrid from 'ol/tilegrid'; +import TileGrid from 'ol/tilegrid/TileGrid'; +import TileImage from 'ol/source/TileImage'; +import TileJSON from 'ol/source/TileJSON'; +import TileUTFGrid from 'ol/source/TileUTFGrid'; +import TileWMS from 'ol/source/TileWMS'; +import TopoJSON from 'ol/format/TopoJSON'; +import Translate from 'ol/interaction/Translate'; +import UrlTile from 'ol/source/UrlTile'; +import VectorContext from 'ol/render/VectorContext'; +import Vector from 'ol/layer/Vector'; +// import Vector from 'ol/source/Vector'; +// import VectorTile from 'ol/layer/VectorTile'; +// import VectorTile from 'ol/source/VectorTile'; +import VectorTile from 'ol/VectorTile'; +import View from 'ol/View'; +import WFS from 'ol/format/WFS'; +import WKT from 'ol/format/WKT'; +import WMSCapabilities from 'ol/format/WMSCapabilities'; +import WMSGetFeatureInfo from 'ol/format/WMSGetFeatureInfo'; +import WMTSCapabilities from 'ol/format/WMTSCapabilities'; +import WMTS from 'ol/source/WMTS'; +// import WMTS from 'ol/tilegrid/WMTS'; +import XMLFeature from 'ol/format/XMLFeature'; +import XML from 'ol/format/XML'; +import XYZ from 'ol/source/XYZ'; +import Zoom from 'ol/control/Zoom'; +import Zoomify from 'ol/source/Zoomify'; +import ZoomSlider from 'ol/control/ZoomSlider'; +import ZoomToExtent from 'ol/control/ZoomToExtent'; // Map const map: ol.Map = new Map({} as any); declare const mapView: View; -declare const layerBase: LayerBase; -declare const control: ControlControl; -declare const interaction: InteractionInteraction; map.setView(mapView); -map.addLayer(layerBase); -map.addControl(control); -map.addInteraction(interaction); // View let view: View; diff --git a/types/ol/pointer/pointerevent.d.ts b/types/ol/pointer/PointerEvent.d.ts similarity index 100% rename from types/ol/pointer/pointerevent.d.ts rename to types/ol/pointer/PointerEvent.d.ts diff --git a/types/ol/proj/projection.d.ts b/types/ol/proj/Projection.d.ts similarity index 100% rename from types/ol/proj/projection.d.ts rename to types/ol/proj/Projection.d.ts diff --git a/types/ol/render/event.d.ts b/types/ol/render/Event.d.ts similarity index 100% rename from types/ol/render/event.d.ts rename to types/ol/render/Event.d.ts diff --git a/types/ol/render/feature.d.ts b/types/ol/render/Feature.d.ts similarity index 100% rename from types/ol/render/feature.d.ts rename to types/ol/render/Feature.d.ts diff --git a/types/ol/render/vectorcontext.d.ts b/types/ol/render/VectorContext.d.ts similarity index 100% rename from types/ol/render/vectorcontext.d.ts rename to types/ol/render/VectorContext.d.ts diff --git a/types/ol/source/bingmaps.d.ts b/types/ol/source/BingMaps.d.ts similarity index 100% rename from types/ol/source/bingmaps.d.ts rename to types/ol/source/BingMaps.d.ts diff --git a/types/ol/source/cartodb.d.ts b/types/ol/source/CartoDB.d.ts similarity index 100% rename from types/ol/source/cartodb.d.ts rename to types/ol/source/CartoDB.d.ts diff --git a/types/ol/source/cluster.d.ts b/types/ol/source/Cluster.d.ts similarity index 100% rename from types/ol/source/cluster.d.ts rename to types/ol/source/Cluster.d.ts diff --git a/types/ol/source/image.d.ts b/types/ol/source/Image.d.ts similarity index 100% rename from types/ol/source/image.d.ts rename to types/ol/source/Image.d.ts diff --git a/types/ol/source/imagearcgisrest.d.ts b/types/ol/source/ImageArcGISRest.d.ts similarity index 100% rename from types/ol/source/imagearcgisrest.d.ts rename to types/ol/source/ImageArcGISRest.d.ts diff --git a/types/ol/source/imagecanvas.d.ts b/types/ol/source/ImageCanvas.d.ts similarity index 100% rename from types/ol/source/imagecanvas.d.ts rename to types/ol/source/ImageCanvas.d.ts diff --git a/types/ol/source/imagemapguide.d.ts b/types/ol/source/ImageMapGuide.d.ts similarity index 100% rename from types/ol/source/imagemapguide.d.ts rename to types/ol/source/ImageMapGuide.d.ts diff --git a/types/ol/source/imagestatic.d.ts b/types/ol/source/ImageStatic.d.ts similarity index 100% rename from types/ol/source/imagestatic.d.ts rename to types/ol/source/ImageStatic.d.ts diff --git a/types/ol/source/imagevector.d.ts b/types/ol/source/ImageVector.d.ts similarity index 100% rename from types/ol/source/imagevector.d.ts rename to types/ol/source/ImageVector.d.ts diff --git a/types/ol/source/imagewms.d.ts b/types/ol/source/ImageWMS.d.ts similarity index 100% rename from types/ol/source/imagewms.d.ts rename to types/ol/source/ImageWMS.d.ts diff --git a/types/ol/source/osm.d.ts b/types/ol/source/OSM.d.ts similarity index 100% rename from types/ol/source/osm.d.ts rename to types/ol/source/OSM.d.ts diff --git a/types/ol/source/raster.d.ts b/types/ol/source/Raster.d.ts similarity index 100% rename from types/ol/source/raster.d.ts rename to types/ol/source/Raster.d.ts diff --git a/types/ol/source/source.d.ts b/types/ol/source/Source.d.ts similarity index 100% rename from types/ol/source/source.d.ts rename to types/ol/source/Source.d.ts diff --git a/types/ol/source/stamen.d.ts b/types/ol/source/Stamen.d.ts similarity index 100% rename from types/ol/source/stamen.d.ts rename to types/ol/source/Stamen.d.ts diff --git a/types/ol/source/tile.d.ts b/types/ol/source/Tile.d.ts similarity index 100% rename from types/ol/source/tile.d.ts rename to types/ol/source/Tile.d.ts diff --git a/types/ol/source/tilearcgisrest.d.ts b/types/ol/source/TileArcGISRest.d.ts similarity index 100% rename from types/ol/source/tilearcgisrest.d.ts rename to types/ol/source/TileArcGISRest.d.ts diff --git a/types/ol/source/tiledebug.d.ts b/types/ol/source/TileDebug.d.ts similarity index 100% rename from types/ol/source/tiledebug.d.ts rename to types/ol/source/TileDebug.d.ts diff --git a/types/ol/source/tileimage.d.ts b/types/ol/source/TileImage.d.ts similarity index 100% rename from types/ol/source/tileimage.d.ts rename to types/ol/source/TileImage.d.ts diff --git a/types/ol/source/tilejson.d.ts b/types/ol/source/TileJSON.d.ts similarity index 100% rename from types/ol/source/tilejson.d.ts rename to types/ol/source/TileJSON.d.ts diff --git a/types/ol/source/tileutfgrid.d.ts b/types/ol/source/TileUTFGrid.d.ts similarity index 100% rename from types/ol/source/tileutfgrid.d.ts rename to types/ol/source/TileUTFGrid.d.ts diff --git a/types/ol/source/tilewms.d.ts b/types/ol/source/TileWMS.d.ts similarity index 100% rename from types/ol/source/tilewms.d.ts rename to types/ol/source/TileWMS.d.ts diff --git a/types/ol/source/urltile.d.ts b/types/ol/source/UrlTile.d.ts similarity index 100% rename from types/ol/source/urltile.d.ts rename to types/ol/source/UrlTile.d.ts diff --git a/types/ol/source/vector.d.ts b/types/ol/source/Vector.d.ts similarity index 100% rename from types/ol/source/vector.d.ts rename to types/ol/source/Vector.d.ts diff --git a/types/ol/source/vectortile.d.ts b/types/ol/source/VectorTile.d.ts similarity index 100% rename from types/ol/source/vectortile.d.ts rename to types/ol/source/VectorTile.d.ts diff --git a/types/ol/source/wmts.d.ts b/types/ol/source/WMTS.d.ts similarity index 100% rename from types/ol/source/wmts.d.ts rename to types/ol/source/WMTS.d.ts diff --git a/types/ol/source/xyz.d.ts b/types/ol/source/XYZ.d.ts similarity index 100% rename from types/ol/source/xyz.d.ts rename to types/ol/source/XYZ.d.ts diff --git a/types/ol/source/zoomify.d.ts b/types/ol/source/Zoomify.d.ts similarity index 100% rename from types/ol/source/zoomify.d.ts rename to types/ol/source/Zoomify.d.ts diff --git a/types/ol/style/atlasmanager.d.ts b/types/ol/style/AtlasManager.d.ts similarity index 100% rename from types/ol/style/atlasmanager.d.ts rename to types/ol/style/AtlasManager.d.ts diff --git a/types/ol/style/circle.d.ts b/types/ol/style/Circle.d.ts similarity index 100% rename from types/ol/style/circle.d.ts rename to types/ol/style/Circle.d.ts diff --git a/types/ol/style/fill.d.ts b/types/ol/style/Fill.d.ts similarity index 100% rename from types/ol/style/fill.d.ts rename to types/ol/style/Fill.d.ts diff --git a/types/ol/style/icon.d.ts b/types/ol/style/Icon.d.ts similarity index 100% rename from types/ol/style/icon.d.ts rename to types/ol/style/Icon.d.ts diff --git a/types/ol/style/image.d.ts b/types/ol/style/Image.d.ts similarity index 100% rename from types/ol/style/image.d.ts rename to types/ol/style/Image.d.ts diff --git a/types/ol/style/regularshape.d.ts b/types/ol/style/RegularShape.d.ts similarity index 100% rename from types/ol/style/regularshape.d.ts rename to types/ol/style/RegularShape.d.ts diff --git a/types/ol/style/stroke.d.ts b/types/ol/style/Stroke.d.ts similarity index 100% rename from types/ol/style/stroke.d.ts rename to types/ol/style/Stroke.d.ts diff --git a/types/ol/style/style.d.ts b/types/ol/style/Style.d.ts similarity index 100% rename from types/ol/style/style.d.ts rename to types/ol/style/Style.d.ts diff --git a/types/ol/style/text.d.ts b/types/ol/style/Text.d.ts similarity index 100% rename from types/ol/style/text.d.ts rename to types/ol/style/Text.d.ts diff --git a/types/ol/tilegrid/tilegrid.d.ts b/types/ol/tilegrid/TileGrid.d.ts similarity index 100% rename from types/ol/tilegrid/tilegrid.d.ts rename to types/ol/tilegrid/TileGrid.d.ts diff --git a/types/ol/tilegrid/wmts.d.ts b/types/ol/tilegrid/WMTS.d.ts similarity index 100% rename from types/ol/tilegrid/wmts.d.ts rename to types/ol/tilegrid/WMTS.d.ts diff --git a/types/ol/tsconfig.json b/types/ol/tsconfig.json index 186bb605e0..8751d240da 100644 --- a/types/ol/tsconfig.json +++ b/types/ol/tsconfig.json @@ -20,159 +20,159 @@ "files": [ "index.d.ts", "ol-tests.ts", - "control/attribution.d.ts", - "control/control.d.ts", - "control/fullscreen.d.ts", - "control/mouseposition.d.ts", - "control/overviewmap.d.ts", - "control/rotate.d.ts", - "control/scaleline.d.ts", - "control/zoom.d.ts", - "control/zoomslider.d.ts", - "control/zoomtoextent.d.ts", + "control/Attribution.d.ts", + "control/Control.d.ts", + "control/Fullscreen.d.ts", + "control/MousePosition.d.ts", + "control/OverviewMap.d.ts", + "control/Rotate.d.ts", + "control/ScaleLine.d.ts", + "control/Zoom.d.ts", + "control/ZoomSlider.d.ts", + "control/ZoomToExtent.d.ts", "events/condition.d.ts", - "events/event.d.ts", - "events/eventtarget.d.ts", - "format/esrijson.d.ts", - "format/feature.d.ts", + "events/Event.d.ts", + "events/EventTarget.d.ts", + "format/EsriJSON.d.ts", + "format/Feature.d.ts", "format/filter.d.ts", - "format/geojson.d.ts", - "format/gml2.d.ts", - "format/gml3.d.ts", - "format/gmlbase.d.ts", - "format/gpx.d.ts", - "format/igc.d.ts", - "format/jsonfeature.d.ts", - "format/kml.d.ts", - "format/mvt.d.ts", - "format/osmxml.d.ts", - "format/polyline.d.ts", - "format/textfeature.d.ts", - "format/topojson.d.ts", - "format/wfs.d.ts", - "format/wkt.d.ts", - "format/wmscapabilities.d.ts", - "format/wmsgetfeatureinfo.d.ts", - "format/wmtscapabilities.d.ts", - "format/xml.d.ts", - "format/xmlfeature.d.ts", - "geom/circle.d.ts", - "geom/geometry.d.ts", - "geom/geometrycollection.d.ts", - "geom/linearring.d.ts", - "geom/linestring.d.ts", - "geom/multilinestring.d.ts", - "geom/multipoint.d.ts", - "geom/multipolygon.d.ts", - "geom/point.d.ts", - "geom/polygon.d.ts", - "geom/simplegeometry.d.ts", - "interaction/doubleclickzoom.d.ts", - "interaction/draganddrop.d.ts", - "interaction/dragbox.d.ts", - "interaction/dragpan.d.ts", - "interaction/dragrotate.d.ts", - "interaction/dragrotateandzoom.d.ts", - "interaction/dragzoom.d.ts", - "interaction/draw.d.ts", - "interaction/extent.d.ts", - "interaction/interaction.d.ts", - "interaction/keyboardpan.d.ts", - "interaction/keyboardzoom.d.ts", - "interaction/modify.d.ts", - "interaction/mousewheelzoom.d.ts", - "interaction/pinchrotate.d.ts", - "interaction/pinchzoom.d.ts", - "interaction/pointer.d.ts", - "interaction/select.d.ts", - "interaction/snap.d.ts", - "interaction/translate.d.ts", - "layer/base.d.ts", - "layer/group.d.ts", - "layer/heatmap.d.ts", - "layer/image.d.ts", - "layer/layer.d.ts", - "layer/tile.d.ts", - "layer/vector.d.ts", - "layer/vectortile.d.ts", - "pointer/pointerevent.d.ts", + "format/GeoJSON.d.ts", + "format/GML2.d.ts", + "format/GML3.d.ts", + "format/GMLBase.d.ts", + "format/GPX.d.ts", + "format/IGC.d.ts", + "format/JSONFeature.d.ts", + "format/KML.d.ts", + "format/MVT.d.ts", + "format/OSMXML.d.ts", + "format/Polyline.d.ts", + "format/TextFeature.d.ts", + "format/TopoJSON.d.ts", + "format/WFS.d.ts", + "format/WKT.d.ts", + "format/WMSCapabilities.d.ts", + "format/WMSGetFeatureInfo.d.ts", + "format/WMTSCapabilities.d.ts", + "format/XML.d.ts", + "format/XMLFeature.d.ts", + "geom/Circle.d.ts", + "geom/GeometryCollection.d.ts", + "geom/Geometry.d.ts", + "geom/LinearRing.d.ts", + "geom/LineString.d.ts", + "geom/MultilineString.d.ts", + "geom/MultiPoint.d.ts", + "geom/MultiPolygon.d.ts", + "geom/Point.d.ts", + "geom/Polygon.d.ts", + "geom/SimpleGeometry.d.ts", + "interaction/DoubleClickZoom.d.ts", + "interaction/DragAndDrop.d.ts", + "interaction/DragBox.d.ts", + "interaction/DragPan.d.ts", + "interaction/DragRotateAndZoom.d.ts", + "interaction/DragRotate.d.ts", + "interaction/DragZoom.d.ts", + "interaction/Draw.d.ts", + "interaction/Extent.d.ts", + "interaction/Interaction.d.ts", + "interaction/KeyboardPan.d.ts", + "interaction/KeyboardZoom.d.ts", + "interaction/Modify.d.ts", + "interaction/MouseWheelZoom.d.ts", + "interaction/PinchRotate.d.ts", + "interaction/PinchZoom.d.ts", + "interaction/Pointer.d.ts", + "interaction/Select.d.ts", + "interaction/Snap.d.ts", + "interaction/Translate.d.ts", + "layer/Base.d.ts", + "layer/Group.d.ts", + "layer/Heatmap.d.ts", + "layer/Image.d.ts", + "layer/Layer.d.ts", + "layer/Tile.d.ts", + "layer/Vector.d.ts", + "layer/VectorTile.d.ts", + "pointer/PointerEvent.d.ts", "proj/index.d.ts", - "proj/projection.d.ts", + "proj/Projection.d.ts", "render/canvas.d.ts", - "render/event.d.ts", - "render/feature.d.ts", - "render/vectorcontext.d.ts", - "source/bingmaps.d.ts", - "source/cartodb.d.ts", - "source/cluster.d.ts", - "source/image.d.ts", - "source/imagearcgisrest.d.ts", - "source/imagecanvas.d.ts", - "source/imagemapguide.d.ts", - "source/imagestatic.d.ts", - "source/imagevector.d.ts", - "source/imagewms.d.ts", - "source/osm.d.ts", - "source/raster.d.ts", - "source/source.d.ts", - "source/stamen.d.ts", - "source/tile.d.ts", - "source/tilearcgisrest.d.ts", - "source/tiledebug.d.ts", - "source/tileimage.d.ts", - "source/tilejson.d.ts", - "source/tileutfgrid.d.ts", - "source/tilewms.d.ts", - "source/urltile.d.ts", - "source/vector.d.ts", - "source/vectortile.d.ts", - "source/wmts.d.ts", - "source/xyz.d.ts", - "source/zoomify.d.ts", - "style/atlasmanager.d.ts", - "style/circle.d.ts", - "style/fill.d.ts", - "style/icon.d.ts", - "style/image.d.ts", - "style/regularshape.d.ts", - "style/stroke.d.ts", - "style/style.d.ts", - "style/text.d.ts", - "tilegrid/tilegrid.d.ts", - "tilegrid/wmts.d.ts", - "assertionerror/index.d.ts", - "attribution/index.d.ts", - "collection/index.d.ts", + "render/Event.d.ts", + "render/Feature.d.ts", + "render/VectorContext.d.ts", + "source/BingMaps.d.ts", + "source/CartoDB.d.ts", + "source/Cluster.d.ts", + "source/ImageArcGISRest.d.ts", + "source/ImageCanvas.d.ts", + "source/Image.d.ts", + "source/ImageMapGuide.d.ts", + "source/ImageStatic.d.ts", + "source/ImageVector.d.ts", + "source/ImageWMS.d.ts", + "source/OSM.d.ts", + "source/Raster.d.ts", + "source/Source.d.ts", + "source/Stamen.d.ts", + "source/TileArcGISRest.d.ts", + "source/TileDebug.d.ts", + "source/Tile.d.ts", + "source/TileImage.d.ts", + "source/TileJSON.d.ts", + "source/TileUTFGrid.d.ts", + "source/TileWMS.d.ts", + "source/UrlTile.d.ts", + "source/Vector.d.ts", + "source/VectorTile.d.ts", + "source/WMTS.d.ts", + "source/XYZ.d.ts", + "source/Zoomify.d.ts", + "style/AtlasManager.d.ts", + "style/Circle.d.ts", + "style/Fill.d.ts", + "style/Icon.d.ts", + "style/Image.d.ts", + "style/RegularShape.d.ts", + "style/Stroke.d.ts", + "style/Style.d.ts", + "style/Text.d.ts", + "tilegrid/TileGrid.d.ts", + "tilegrid/WMTS.d.ts", + "AssertionError/index.d.ts", + "Attribution/index.d.ts", + "Collection/index.d.ts", "color/index.d.ts", "colorlike/index.d.ts", "control/index.d.ts", "coordinate/index.d.ts", "deviceorientation/index.d.ts", - "disposable/index.d.ts", + "Disposable/index.d.ts", "easing/index.d.ts", "events/index.d.ts", "extent/index.d.ts", - "feature/index.d.ts", + "Feature/index.d.ts", "featureloader/index.d.ts", - "geolocation/index.d.ts", - "graticule/index.d.ts", - "image/index.d.ts", - "imagebase/index.d.ts", - "imagetile/index.d.ts", + "Geolocation/index.d.ts", + "Graticule/index.d.ts", + "ImageBase/index.d.ts", + "Image/index.d.ts", + "ImageTile/index.d.ts", "interaction/index.d.ts", - "kinetic/index.d.ts", + "Kinetic/index.d.ts", "loadingstrategy/index.d.ts", - "map/index.d.ts", - "mapbrowserevent/index.d.ts", - "mapbrowserpointerevent/index.d.ts", - "mapevent/index.d.ts", - "object/index.d.ts", - "observable/index.d.ts", - "overlay/index.d.ts", + "MapBrowserEvent/index.d.ts", + "MapBrowserPointerEvent/index.d.ts", + "MapEvent/index.d.ts", + "Map/index.d.ts", + "Object/index.d.ts", + "Observable/index.d.ts", + "Overlay/index.d.ts", "sphere/index.d.ts", - "tile/index.d.ts", + "Tile/index.d.ts", "tilegrid/index.d.ts", - "vectortile/index.d.ts", - "view/index.d.ts" + "VectorTile/index.d.ts", + "View/index.d.ts" ] -} \ No newline at end of file +} diff --git a/types/onetime/index.d.ts b/types/onetime/index.d.ts index c7406307bc..f1c6b56ad0 100644 --- a/types/onetime/index.d.ts +++ b/types/onetime/index.d.ts @@ -1,36 +1,45 @@ -// Type definitions for onetime 2.0 +// Type definitions for onetime 3.0 // Project: https://github.com/sindresorhus/onetime#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 export = oneTime; -declare function oneTime(fn: () => R, options?: oneTime.Options): () => R; -declare function oneTime(fn: (t1: T1) => R, options?: oneTime.Options): (t1: T1) => R; -declare function oneTime(fn: (t1: T1, t2: T2) => R, options?: oneTime.Options): (t1: T1, t2: T2) => R; -declare function oneTime(fn: (t1: T1, t2: T2, t3: T3) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7) => R, - options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8) => R, - options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9) => R, - options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9) => R; -declare function oneTime( - fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10) => R, - options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10) => R; -declare function oneTime(fn: (...args: any[]) => R, options?: oneTime.Options): (...args: any[]) => R; +/** + * Ensure a function is only called once. When called multiple times it will return the return value from the first call. + * + * @param fn Function that should only be called once. + * @returns A function that only calls `fn` once. + */ +declare function oneTime( + fn: (...args: T) => R, + options?: oneTime.Options +): (...args: T) => R; declare namespace oneTime { + /** + * Get the number of times `fn` has been called. + * + * @param fn Function to get call count from. + * @returns A number representing how many times `fn` has been called. + * + * @example + * const foo = onetime(() => {}); + * foo(); + * foo(); + * foo(); + * + * console.log(onetime.callCount(foo)); + * //=> 3 + */ + function callCount(fn: (...args: any[]) => any): number | undefined; + interface Options { + /** + * Throw an error when called more than once. + * @default false + */ throw?: boolean; } } diff --git a/types/onetime/onetime-tests.ts b/types/onetime/onetime-tests.ts index 840edb6cc2..4678eb45db 100644 --- a/types/onetime/onetime-tests.ts +++ b/types/onetime/onetime-tests.ts @@ -3,29 +3,10 @@ import onetime = require('onetime'); const foo = onetime(() => 5); foo(); // $ExpectType number -const foo2 = onetime(() => true, {throw: true}); +const foo2 = onetime(() => true, { throw: true }); foo2(); // $ExpectType boolean onetime((t1: boolean) => 5)(true); // $ExpectType number onetime((t1: boolean, t2: string) => 5)(true, ''); // $ExpectType number -onetime((t1: boolean, t2: string, t3: number) => 5)(true, '', 5); // $ExpectType number -onetime((t1: boolean, t2: string, t3: number, t4: undefined) => 5)(true, '', 5, undefined); // $ExpectType number -onetime((t1: boolean, t2: string, t3: number, t4: undefined, t5: string) => 5)(true, '', 5, undefined, ''); // $ExpectType number -onetime((t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number) => 5)(true, '', 5, undefined, '', 6); // $ExpectType number -onetime((t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean) => 5)(true, '', 5, undefined, '', 6, false); // $ExpectType number -const t8 = onetime( - (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string) => 5); -t8(true, '', 5, undefined, '', 6, false, ''); // $ExpectType number - -const t9 = onetime( - (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string, t9: number) => 5); -t9(true, '', 5, undefined, '', 6, false, '', 1); // $ExpectType number - -const t10 = onetime( - (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string, t9: number, t10: boolean) => 5); -t10(true, '', 5, undefined, '', 6, false, '', 1, true); // $ExpectType number - -const t11 = onetime( - (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string, t9: number, t10: boolean, t11: string) => 5); -t11(true, '', 5, undefined, '', 6, false, '', 1, true, 5); // $ExpectType number +onetime.callCount((t1: boolean, t2: string) => 5); // $ExpectType number | undefined diff --git a/types/onetime/tsconfig.json b/types/onetime/tsconfig.json index 84d3da86b8..39df78e5bc 100644 --- a/types/onetime/tsconfig.json +++ b/types/onetime/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "onetime-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/onetime/v2/index.d.ts b/types/onetime/v2/index.d.ts new file mode 100644 index 0000000000..c7406307bc --- /dev/null +++ b/types/onetime/v2/index.d.ts @@ -0,0 +1,36 @@ +// Type definitions for onetime 2.0 +// Project: https://github.com/sindresorhus/onetime#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = oneTime; + +declare function oneTime(fn: () => R, options?: oneTime.Options): () => R; +declare function oneTime(fn: (t1: T1) => R, options?: oneTime.Options): (t1: T1) => R; +declare function oneTime(fn: (t1: T1, t2: T2) => R, options?: oneTime.Options): (t1: T1, t2: T2) => R; +declare function oneTime(fn: (t1: T1, t2: T2, t3: T3) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6) => R, options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7) => R, + options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8) => R, + options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9) => R, + options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9) => R; +declare function oneTime( + fn: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10) => R, + options?: oneTime.Options): (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10) => R; +declare function oneTime(fn: (...args: any[]) => R, options?: oneTime.Options): (...args: any[]) => R; + +declare namespace oneTime { + interface Options { + throw?: boolean; + } +} diff --git a/types/onetime/v2/onetime-tests.ts b/types/onetime/v2/onetime-tests.ts new file mode 100644 index 0000000000..840edb6cc2 --- /dev/null +++ b/types/onetime/v2/onetime-tests.ts @@ -0,0 +1,31 @@ +import onetime = require('onetime'); + +const foo = onetime(() => 5); +foo(); // $ExpectType number + +const foo2 = onetime(() => true, {throw: true}); +foo2(); // $ExpectType boolean + +onetime((t1: boolean) => 5)(true); // $ExpectType number +onetime((t1: boolean, t2: string) => 5)(true, ''); // $ExpectType number +onetime((t1: boolean, t2: string, t3: number) => 5)(true, '', 5); // $ExpectType number +onetime((t1: boolean, t2: string, t3: number, t4: undefined) => 5)(true, '', 5, undefined); // $ExpectType number +onetime((t1: boolean, t2: string, t3: number, t4: undefined, t5: string) => 5)(true, '', 5, undefined, ''); // $ExpectType number +onetime((t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number) => 5)(true, '', 5, undefined, '', 6); // $ExpectType number +onetime((t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean) => 5)(true, '', 5, undefined, '', 6, false); // $ExpectType number + +const t8 = onetime( + (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string) => 5); +t8(true, '', 5, undefined, '', 6, false, ''); // $ExpectType number + +const t9 = onetime( + (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string, t9: number) => 5); +t9(true, '', 5, undefined, '', 6, false, '', 1); // $ExpectType number + +const t10 = onetime( + (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string, t9: number, t10: boolean) => 5); +t10(true, '', 5, undefined, '', 6, false, '', 1, true); // $ExpectType number + +const t11 = onetime( + (t1: boolean, t2: string, t3: number, t4: undefined, t5: string, t6: number, t7: boolean, t8: string, t9: number, t10: boolean, t11: string) => 5); +t11(true, '', 5, undefined, '', 6, false, '', 1, true, 5); // $ExpectType number diff --git a/types/del/v2/tsconfig.json b/types/onetime/v2/tsconfig.json similarity index 85% rename from types/del/v2/tsconfig.json rename to types/onetime/v2/tsconfig.json index 568d1a8a21..bda103d103 100644 --- a/types/del/v2/tsconfig.json +++ b/types/onetime/v2/tsconfig.json @@ -13,8 +13,8 @@ "../../" ], "paths": { - "del": [ - "del/v2" + "onetime": [ + "onetime/v2" ] }, "types": [], @@ -23,6 +23,6 @@ }, "files": [ "index.d.ts", - "del-tests.ts" + "onetime-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/p-pipe/tslint.json b/types/onetime/v2/tslint.json similarity index 100% rename from types/p-pipe/tslint.json rename to types/onetime/v2/tslint.json diff --git a/types/open-graph/index.d.ts b/types/open-graph/index.d.ts new file mode 100644 index 0000000000..14a3fe3ce6 --- /dev/null +++ b/types/open-graph/index.d.ts @@ -0,0 +1,74 @@ +// Type definitions for open-graph 0.2 +// Project: https://github.com/samholmes/node-open-graph +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +declare namespace og { + interface Metadata { + [key: string]: string | string[] | undefined; + /** An alternate url to use if the webpage requires HTTPS. */ + secure_url?: string | string[]; + /** A MIME type for this image. */ + type?: string | string[]; + } + + interface ImageVideoMetadata extends Metadata { + /** A description of what is in the image (not a caption). If the page specifies an `og:image` it should specify `og:image:alt`. */ + alt?: string | string[]; + /** The number of pixels high. */ + height?: string | string[]; + /** The */ + url?: string | string[]; + /** The number of pixels wide. */ + width?: string | string[]; + } + + interface Data { + [key: string]: string | string[] | ImageVideoMetadata | Metadata | undefined; + /** A URL to an audio file to accompany this object. */ + audio?: string | string[] | Metadata; + /** A one to two sentence description of your object. */ + description?: string | string[]; + /** + * The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). + * If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank). + */ + determiner?: string | string[]; + /** An image URL which should represent your object within the graph. */ + image?: string | string[] | ImageVideoMetadata; + /** The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. */ + locale?: + | string | string[] + | { + /** An array of other locales this page is available in. */ + alternate?: string | string[]; + }; + /** If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb". */ + site_name?: string | string[]; + /** The title of your object as it should appear within the graph, e.g., "The Rock". */ + title: string | string[]; + /** The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required. */ + type?: string | string[]; + /** The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "http://www.imdb.com/title/tt0117500/". */ + url?: string | string[]; + /** A URL to a video file that complements this object. */ + video?: string | string[] | ImageVideoMetadata; + } + + type DataCallback = (err: Error | null, data: Data | undefined) => void; + type RequestCallback = (err: Error | null, data: string | undefined) => void; + + interface Options { + strict?: boolean; + } + + function parse(websiteContent: string, options?: Options): Data; + function getHTML(url: string | Cheerio, callback: RequestCallback): void; +} + +declare function og(url: string, callback: og.DataCallback, options?: og.Options): void; + +export = og; diff --git a/types/open-graph/open-graph-tests.ts b/types/open-graph/open-graph-tests.ts new file mode 100644 index 0000000000..4e3db10438 --- /dev/null +++ b/types/open-graph/open-graph-tests.ts @@ -0,0 +1,18 @@ +import og = require('open-graph'); + +const url = 'http://github.com/samholmes/node-open-graph/raw/master/test.html'; + +og(url, (err, meta) => { + if (meta) { + meta.custom; + meta.description; // $ExpectType string | string[] | undefined + } +}); + +og.parse('content', { + strict: true, +}); + +og.getHTML('http://github.com/samholmes/node-open-graph/raw/master/test.html', (err, data) => { + data; // $ExpectType string | undefined +}); diff --git a/types/internal-ip/tsconfig.json b/types/open-graph/tsconfig.json similarity index 93% rename from types/internal-ip/tsconfig.json rename to types/open-graph/tsconfig.json index 99d54932e0..72fa10a12d 100644 --- a/types/internal-ip/tsconfig.json +++ b/types/open-graph/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "internal-ip-tests.ts" + "open-graph-tests.ts" ] } diff --git a/types/p-queue/tslint.json b/types/open-graph/tslint.json similarity index 100% rename from types/p-queue/tslint.json rename to types/open-graph/tslint.json diff --git a/types/openpgp/common/index.d.ts b/types/openpgp/common/index.d.ts new file mode 100644 index 0000000000..88796dea9d --- /dev/null +++ b/types/openpgp/common/index.d.ts @@ -0,0 +1,5 @@ +export class HKP { + constructor(keyServerUrl?: string); + lookup(options: {keyId?: string, query?: string }): Promise; + upload(publicKeyArmored: string): Promise; +} diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index d564c6df6d..628663a9ec 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for openpgp 4.0.1 +// Type definitions for openpgp 4.4.8 // Project: http://openpgpjs.org/ // Definitions by: Guillaume Lacasa // Errietta Kostala @@ -10,6 +10,8 @@ export as namespace openpgp; +export * from './common'; + export interface UserId { name?: string, email?: string, diff --git a/types/openpgp/openpgp-tests.ts b/types/openpgp/openpgp-tests.ts index 19e305cb26..100941074a 100644 --- a/types/openpgp/openpgp-tests.ts +++ b/types/openpgp/openpgp-tests.ts @@ -135,6 +135,23 @@ openpgp.initWorker({ path:'openpgp.worker.js' }); return verified.signatures[0].valid; })(); +async () => { + let hkp = new openpgp.HKP(); + + const hkpOptions = { + query: 'alice@example.com' + }; + + const armoredPubkey = await hkp.lookup(hkpOptions); + await openpgp.key.readArmored(armoredPubkey); + + hkp = new openpgp.HKP('https://pgp.mit.edu'); + + const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----'; + + await hkp.upload(pubkey); +} + // Open PGP Tests diff --git a/types/openpgp/ts3.2/index.d.ts b/types/openpgp/ts3.2/index.d.ts index 428f785dbe..e7f8cdd714 100644 --- a/types/openpgp/ts3.2/index.d.ts +++ b/types/openpgp/ts3.2/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for openpgp 4.0.1 +// Type definitions for openpgp 4.4.8 // Project: http://openpgpjs.org/ // Definitions by: Guillaume Lacasa // Errietta Kostala @@ -9,6 +9,8 @@ export as namespace openpgp; +export * from '../common'; + export interface UserId { name?: string, email?: string, diff --git a/types/ora/index.d.ts b/types/ora/index.d.ts index 08a1946c5d..13104b0b5c 100644 --- a/types/ora/index.d.ts +++ b/types/ora/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ora 3.0 +// Type definitions for ora 3.1 // Project: https://github.com/sindresorhus/ora // Definitions by: Basarat Ali Syed // Christian Rackerseder @@ -45,6 +45,16 @@ declare namespace ora { */ color: Color; + /** + * Change the spinner. + */ + spinner: SpinnerName | Spinner; + + /** + * Change the spinner indent. + */ + indent: number; + /** * Start the spinner. * @@ -149,6 +159,11 @@ declare namespace ora { * @default true */ hideCursor?: boolean; + /** + * Indent the spinner with the given number of spaces. + * @default 0 + */ + indent?: number; /** * Interval between each frame. * diff --git a/types/ora/ora-tests.ts b/types/ora/ora-tests.ts index 2c1b8ee82d..4e06c11248 100644 --- a/types/ora/ora-tests.ts +++ b/types/ora/ora-tests.ts @@ -9,6 +9,7 @@ ora({ spinner: { interval: 80, frames: ['-', '+', '-'] } }); ora({ color: 'cyan' }); ora({ color: 'foo' }); // $ExpectError ora({ hideCursor: true }); +ora({ indent: 1 }); ora({ interval: 80 }); ora({ stream: new PassThrough() }); ora({ isEnabled: true }); @@ -17,6 +18,8 @@ spinner.color = 'yellow'; spinner.text = 'Loading rainbows'; spinner.isSpinning; // $ExpectType boolean spinner.isSpinning = true; // $ExpectError +spinner.spinner = 'dots'; +spinner.indent = 5; spinner.start(); spinner.start('Test text'); diff --git a/types/p-event/index.d.ts b/types/p-event/index.d.ts deleted file mode 100644 index 0fde40d140..0000000000 --- a/types/p-event/index.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Type definitions for p-event 1.3 -// Project: https://github.com/sindresorhus/p-event#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -export = pEvent; - -declare function pEvent(emitter: pEvent.Emitter, event: string | symbol, options: MultiArgsOptions): Promise>; -declare function pEvent(emitter: pEvent.Emitter, event: string | symbol, filter: FilterFn): Promise; -declare function pEvent(emitter: pEvent.Emitter, event: string | symbol, options?: pEvent.Options): Promise; - -declare namespace pEvent { - interface Emitter { - on?: AddRmListenerFn; - addListener?: AddRmListenerFn; - addEventListener?: AddRmListenerFn; - off?: AddRmListenerFn; - removeListener?: AddRmListenerFn; - removeEventListener?: AddRmListenerFn; - } - - interface Options { - rejectionEvents?: string[]; - multiArgs?: boolean; - timeout?: number; - filter?: FilterFn; - } -} - -type AddRmListenerFn = (event: string | symbol, listener: (arg1: T, ...args: TRest[]) => void) => void; -type FilterFn = (el: T) => boolean; - -interface MultiArgsOptions extends pEvent.Options { - multiArgs: true; -} diff --git a/types/p-event/p-event-tests.ts b/types/p-event/p-event-tests.ts deleted file mode 100644 index 0295cdb34b..0000000000 --- a/types/p-event/p-event-tests.ts +++ /dev/null @@ -1,61 +0,0 @@ -/// - -import pEvent = require('p-event'); -import * as events from 'events'; -import * as fs from 'fs'; - -class MyEmitter extends events.EventEmitter { -} - -class MyDomEmitter implements EventTarget { - addEventListener(type: 'foo', listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void { - } - - dispatchEvent(event: Event): boolean { - return false; - } - - removeEventListener(type: 'foo', listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void { - } -} - -pEvent(new MyEmitter(), 'finish') - .then(result => { - console.log(result); - }) - .catch(error => { - console.error(error); - }); - -pEvent(new MyEmitter(), 'finish').then(result => { - const str: string = result; -}); - -pEvent(new MyDomEmitter(), 'finish').then(result => { - const e: Event | undefined = result; -}); - -pEvent(document, 'DOMContentLoaded').then(() => { - console.log('😎'); -}); - -pEvent(new MyEmitter(), 'finish', {multiArgs: true}).then(result => { - const strArr: string[] = result; -}); - -pEvent(new MyEmitter(), '🦄', value => value > 3).then(result => { - const num: number = result; -}); - -async function getOpenReadStream(file: string) { - const stream = fs.createReadStream(file); - await pEvent(stream, 'open'); - return stream; -} - -getOpenReadStream('unicorn.txt') - .then(stream => { - console.log('Is readable:', stream.readable); - stream.pipe(process.stdout); - }) - .catch(console.error); diff --git a/types/p-limit/index.d.ts b/types/p-limit/index.d.ts deleted file mode 100644 index af0306cdd9..0000000000 --- a/types/p-limit/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for p-limit 2.0 -// Project: https://github.com/sindresorhus/p-limit#readme -// Definitions by: BendingBender -// Linus Unnebäck -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export = pLimit; - -declare function limit(cb: (a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]) => PromiseLike | T, a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]): Promise; -declare function limit(cb: (a: A, b: B, c: C, d: D, e: E, f: F) => PromiseLike | T, a: A, b: B, c: C, d: D, e: E, f: F): Promise; -declare function limit(cb: (a: A, b: B, c: C, d: D, e: E) => PromiseLike | T, a: A, b: B, c: C, d: D, e: E): Promise; -declare function limit(cb: (a: A, b: B, c: C, d: D) => PromiseLike | T, a: A, b: B, c: C, d: D): Promise; -declare function limit(cb: (a: A, b: B, c: C) => PromiseLike | T, a: A, b: B, c: C): Promise; -declare function limit(cb: (a: A, b: B) => PromiseLike | T, a: A, b: B): Promise; -declare function limit(cb: (a: A) => PromiseLike | T, a: A): Promise; -declare function limit(cb: () => PromiseLike | T): Promise; - -declare function pLimit(concurrency: number): typeof limit; diff --git a/types/p-limit/p-limit-tests.ts b/types/p-limit/p-limit-tests.ts deleted file mode 100644 index 51dcb394fe..0000000000 --- a/types/p-limit/p-limit-tests.ts +++ /dev/null @@ -1,35 +0,0 @@ -import pLimit = require('p-limit'); - -const limit = pLimit(1); - -const input = [ - limit(() => Promise.resolve('foo')), - limit(() => Promise.resolve('bar')), - limit(() => Promise.resolve(undefined)), -]; - -Promise.all(input).then(result => { - const str: string | undefined = result[0]; -}); - -let str: string; - -declare function a(a: string): string; -declare function b(a: string, b: number): string; -declare function c(a: string, b: number, c: boolean): string; -declare function d(a: string, b: number, c: boolean, d: symbol): string; -declare function e(a: string, b: number, c: boolean, d: symbol, e: 'yes' | 'no'): string; -declare function f(a: string, b: number, c: boolean, d: symbol, e: 'yes' | 'no', f: 1 | 2): string; -declare function g(a: string, b: number, c: boolean, d: symbol, e: 'yes' | 'no', f: 1 | 2, g: true): string; - -limit(a, 'test').then(v => { str = v; }); -limit(b, 'test', 1).then(v => { str = v; }); -limit(c, 'test', 1, false).then(v => { str = v; }); -limit(d, 'test', 1, false, Symbol('test')).then(v => { str = v; }); -limit(e, 'test', 1, false, Symbol('test'), 'no').then(v => { str = v; }); -limit(f, 'test', 1, false, Symbol('test'), 'no', 2).then(v => { str = v; }); -limit(g, 'test', 1, false, Symbol('test'), 'no', 2, true).then(v => { str = v; }); - -declare function add(...args: number[]): number; - -limit(add, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).then(v => (v === 91)); diff --git a/types/p-map/index.d.ts b/types/p-map/index.d.ts deleted file mode 100644 index ccaf32e711..0000000000 --- a/types/p-map/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for p-map 1.1 -// Project: https://github.com/sindresorhus/p-map#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -export = pMap; - -declare function pMap(input: Iterable>, mapper: Mapper, options?: pMap.Options): Promise; - -type Input = Promise | PromiseLike | T; -type Mapper = (el: T, index: number) => Promise | R; - -declare namespace pMap { - interface Options { - concurrency?: number; - } -} diff --git a/types/p-map/p-map-tests.ts b/types/p-map/p-map-tests.ts deleted file mode 100644 index 48d4ed5e5a..0000000000 --- a/types/p-map/p-map-tests.ts +++ /dev/null @@ -1,18 +0,0 @@ -import pMap = require('p-map'); - -const sites = [ - Promise.resolve('sindresorhus'), - true, - 1 -]; - -const mapper = (el: number | string | boolean) => Promise.resolve(1); - -let num: number; -pMap(sites, mapper, {concurrency: 2}).then(result => { - num = result[3]; -}); - -pMap(sites, mapper).then(result => { - num = result[3]; -}); diff --git a/types/p-map/tsconfig.json b/types/p-map/tsconfig.json deleted file mode 100644 index ed62309b29..0000000000 --- a/types/p-map/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "p-map-tests.ts" - ] -} \ No newline at end of file diff --git a/types/p-pipe/index.d.ts b/types/p-pipe/index.d.ts deleted file mode 100644 index 2c58bd8f01..0000000000 --- a/types/p-pipe/index.d.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Type definitions for p-pipe 1.2 -// Project: https://github.com/sindresorhus/p-pipe#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0 - -export = pPipe; - -// tslint:disable:no-unnecessary-generics -declare function pPipe(...args: Tasks1): PromiseTask; -declare function pPipe(...args: Tasks2): PromiseTask; -declare function pPipe(...args: Tasks3): PromiseTask; -declare function pPipe(...args: Tasks4): PromiseTask; -declare function pPipe( - ...args: Tasks5 -): PromiseTask; -declare function pPipe( - ...args: Tasks6 -): PromiseTask; -declare function pPipe( - ...args: Tasks7 -): PromiseTask; -declare function pPipe( - ...args: Tasks8 -): PromiseTask; -declare function pPipe(...args: Array>): PromiseTask; - -declare function pPipe(tasks: Tasks1): PromiseTask; -declare function pPipe(tasks: Tasks2): PromiseTask; -declare function pPipe(tasks: Tasks3): PromiseTask; -declare function pPipe(tasks: Tasks4): PromiseTask; -declare function pPipe( - tasks: Tasks5 -): PromiseTask; -declare function pPipe( - tasks: Tasks6 -): PromiseTask; -declare function pPipe( - tasks: Tasks7 -): PromiseTask; -declare function pPipe( - tasks: Tasks8 -): PromiseTask; -declare function pPipe(tasks: Array>): PromiseTask; - -type Tasks1 = [PromiseTask]; -type Tasks2 = [Task, Task]; -type Tasks3 = [Task, Task, Task]; -type Tasks4 = [Task, Task, Task, Task]; -type Tasks5 = [ - Task, - Task, - Task, - Task, - Task -]; -type Tasks6 = [ - Task, - Task, - Task, - Task, - Task, - Task -]; -type Tasks7 = [ - Task, - Task, - Task, - Task, - Task, - Task, - Task -]; -type Tasks8 = [ - Task, - Task, - Task, - Task, - Task, - Task, - Task, - Task -]; - -type Task = (input: T) => PromiseLike | R; -type PromiseTask = (input: T) => Promise; diff --git a/types/p-pipe/p-pipe-tests.ts b/types/p-pipe/p-pipe-tests.ts deleted file mode 100644 index 8901637430..0000000000 --- a/types/p-pipe/p-pipe-tests.ts +++ /dev/null @@ -1,57 +0,0 @@ -import pPipe = require('p-pipe'); - -const addUnicorn = (str: string) => Promise.resolve(`${str} Unicorn`); -const addRainbow = (str: string) => Promise.resolve(`${str} Rainbow`); - -const pipeline = pPipe(addUnicorn, addRainbow); - -pipeline('❤️'); // $ExpectType Promise - -const strToInt = (s: string) => Promise.resolve(1); -const intToBool = (i: number) => Promise.resolve(true); -const boolToObj = (b: boolean) => Promise.resolve({}); -const objToNull = (o: object) => Promise.resolve(null); -const nullToVoid = (n: null) => Promise.resolve(undefined); -const voidToStr = (u: undefined) => Promise.resolve(''); - -pPipe(strToInt); // $ExpectType PromiseTask -pPipe(strToInt, intToBool); // $ExpectType PromiseTask -pPipe(strToInt, intToBool, boolToObj); // $ExpectType PromiseTask -pPipe(strToInt, intToBool, boolToObj, objToNull); // $ExpectType PromiseTask -pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid); // $ExpectType PromiseTask -pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr); // $ExpectType PromiseTask -pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt); // $ExpectType PromiseTask -pPipe(strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt, intToBool); // $ExpectType PromiseTask -// $ExpectType PromiseTask -pPipe( - strToInt, - intToBool, - boolToObj, - objToNull, - nullToVoid, - voidToStr, - strToInt, - intToBool, - boolToObj -); - -pPipe([strToInt]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool, boolToObj]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool, boolToObj, objToNull]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt]); // $ExpectType PromiseTask -pPipe([strToInt, intToBool, boolToObj, objToNull, nullToVoid, voidToStr, strToInt, intToBool]); // $ExpectType PromiseTask -// $ExpectType PromiseTask -pPipe([ - strToInt, - intToBool, - boolToObj, - objToNull, - nullToVoid, - voidToStr, - strToInt, - intToBool, - boolToObj, -]); diff --git a/types/p-queue/index.d.ts b/types/p-queue/index.d.ts deleted file mode 100644 index 10c1179815..0000000000 --- a/types/p-queue/index.d.ts +++ /dev/null @@ -1,106 +0,0 @@ -// Type definitions for p-queue 3.0 -// Project: https://github.com/sindresorhus/p-queue#readme -// Definitions by: BendingBender -// Evan Shortiss -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -export = PQueue; - -declare class PQueue { - /** - * Size of the queue. - */ - size: number; - - /** - * Number of pending promises. - */ - pending: number; - - /** - * Whether the queue is currently paused. - */ - isPaused: boolean; - - constructor(opts?: PQueue.Options); - - /** - * Returns the promise returned by calling fn. - * @param fn Promise-returning/async function. - */ - add(fn: PQueue.Task, opts?: O): Promise; - - /** - * Same as .add(), but accepts an array of async functions and - * returns a promise that resolves when all async functions are resolved. - * @param fn Array of Promise-returning/async functions. - */ - addAll(fns: Array>, opts?: O): Promise; - - /** - * Returns a promise that settles when the queue becomes empty. - * Can be called multiple times. Useful if you for example add - * additional items at a later time. - */ - onEmpty(): Promise; - - /** - * Returns a promise that settles when the queue becomes empty, and all - * promises have completed; queue.size === 0 && queue.pending === 0. - * The difference with .onEmpty is that .onIdle guarantees that all work - * from the queue has finished. .onEmpty merely signals that the queue is - * empty, but it could mean that some promises haven't completed yet. - */ - onIdle(): Promise; - - /** - * Start (or resume) executing enqueued tasks within concurrency limit. - * No need to call this if queue is not paused (via options.autoStart = false - * or by .pause() method.) - */ - start(): void; - - /** - * Clear the queue. - */ - clear(): void; - - /** - * Put queue execution on hold. - */ - pause(): void; -} - -declare namespace PQueue { - interface QueueAddOptions { - [key: string]: any; - } - - interface QueueClassConstructor { - new(): QueueClass; - } - - interface QueueClass { - size: number; - - enqueue(run: () => void, options?: O): void; - - dequeue(): (() => void) | undefined; - } - - interface Options { - concurrency?: number; - autoStart?: boolean; - queueClass?: QueueClassConstructor; - intervalCap?: number; - interval?: number; - carryoverConcurrencyCount?: boolean; - } - - interface DefaultAddOptions { - priority?: number; - } - - type Task = () => Promise; -} diff --git a/types/p-queue/p-queue-tests.ts b/types/p-queue/p-queue-tests.ts deleted file mode 100644 index e12723a7d4..0000000000 --- a/types/p-queue/p-queue-tests.ts +++ /dev/null @@ -1,49 +0,0 @@ -import PQueue = require('p-queue'); - -const queue = new PQueue({concurrency: 1}); - -queue.add(() => Promise.resolve('sindresorhus.com')).then((sindre) => { - const str: string = sindre; -}); - -queue.addAll([() => Promise.resolve('oh'), () => Promise.resolve('hi')]).then(r => { - r.indexOf('h'); -}); - -Promise.resolve((): Promise => Promise.resolve('unicorn')) - .then(task => queue.add(task, {priority: 5})) - .then(unicorn => { - const str: string = unicorn; - }); - -queue.onEmpty().then(() => {}); -queue.onIdle().then(() => {}); -queue.start(); -queue.pause(); -queue.clear(); - -let num: number; -num = queue.size; -num = queue.pending; -const paused = queue.isPaused; - -class QueueClass implements PQueue.QueueClass<{ any: string }> { - private readonly queue: Array<() => void>; - - size = 0; - - constructor() { - this.queue = []; - } - - enqueue(run: () => void, options: { any: string }) { - this.queue.push(run); - } - - dequeue() { - return this.queue.shift(); - } -} - -const queue2 = new PQueue({queueClass: QueueClass}); -queue2.add(() => Promise.resolve(), {any: 'hi'}); diff --git a/types/p-queue/v2/index.d.ts b/types/p-queue/v2/index.d.ts deleted file mode 100644 index 568de0ca1d..0000000000 --- a/types/p-queue/v2/index.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -// Type definitions for p-queue 2.3 -// Project: https://github.com/sindresorhus/p-queue#readme -// Definitions by: BendingBender -// Evan Shortiss -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -export = PQueue; - -declare class PQueue { - /** - * Size of the queue. - */ - size: number; - - /** - * Number of pending promises. - */ - pending: number; - - /** - * Whether the queue is currently paused. - */ - isPaused: boolean; - - constructor(opts?: PQueue.Options); - - /** - * Returns the promise returned by calling fn. - * @param fn Promise-returning/async function. - */ - add(fn: PQueue.Task, opts?: O): Promise; - - /** - * Same as .add(), but accepts an array of async functions and - * returns a promise that resolves when all async functions are resolved. - * @param fn Array of Promise-returning/async functions. - */ - addAll(fns: Array>, opts?: O): Promise; - - /** - * Returns a promise that settles when the queue becomes empty. - * Can be called multiple times. Useful if you for example add - * additional items at a later time. - */ - onEmpty(): Promise; - - /** - * Returns a promise that settles when the queue becomes empty, and all - * promises have completed; queue.size === 0 && queue.pending === 0. - * The difference with .onEmpty is that .onIdle guarantees that all work - * from the queue has finished. .onEmpty merely signals that the queue is - * empty, but it could mean that some promises haven't completed yet. - */ - onIdle(): Promise; - - /** - * Start (or resume) executing enqueued tasks within concurrency limit. - * No need to call this if queue is not paused (via options.autoStart = false - * or by .pause() method.) - */ - start(): void; - - /** - * Clear the queue. - */ - clear(): void; - - /** - * Put queue execution on hold. - */ - pause(): void; -} - -declare namespace PQueue { - interface QueueAddOptions { - [key: string]: any; - } - - interface QueueClassConstructor { - new(): QueueClass; - } - - interface QueueClass { - size: number; - - enqueue(run: () => void, options?: O): void; - - dequeue(): (() => void) | undefined; - } - - interface Options { - concurrency?: number; - autoStart?: boolean; - queueClass?: QueueClassConstructor; - } - - interface DefaultAddOptions { - priority?: number; - } - - type Task = () => Promise; -} diff --git a/types/p-queue/v2/p-queue-tests.ts b/types/p-queue/v2/p-queue-tests.ts deleted file mode 100644 index fcd48c852d..0000000000 --- a/types/p-queue/v2/p-queue-tests.ts +++ /dev/null @@ -1,51 +0,0 @@ -import PQueue = require("p-queue"); - -const queue = new PQueue({ concurrency: 1 }); - -queue - .add(() => Promise.resolve("sindresorhus.com")) - .then(sindre => { - const str: string = sindre; - }); - -queue.addAll([() => Promise.resolve("oh"), () => Promise.resolve("hi")]).then(r => { - r.indexOf("h"); -}); - -Promise.resolve((): Promise => Promise.resolve("unicorn")) - .then(task => queue.add(task, { priority: 5 })) - .then(unicorn => { - const str: string = unicorn; - }); - -queue.onEmpty().then(() => {}); -queue.onIdle().then(() => {}); -queue.start(); -queue.pause(); -queue.clear(); - -let num: number; -num = queue.size; -num = queue.pending; -const paused = queue.isPaused; - -class QueueClass implements PQueue.QueueClass<{ any: string }> { - private readonly queue: Array<() => void>; - - size = 0; - - constructor() { - this.queue = []; - } - - enqueue(run: () => void, options: { any: string }) { - this.queue.push(run); - } - - dequeue() { - return this.queue.shift(); - } -} - -const queue2 = new PQueue({ queueClass: QueueClass }); -queue2.add(() => Promise.resolve(), { any: "hi" }); diff --git a/types/papaparse/index.d.ts b/types/papaparse/index.d.ts index 300e33b4a5..372df6a737 100644 --- a/types/papaparse/index.d.ts +++ b/types/papaparse/index.d.ts @@ -11,7 +11,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import "node"; +/// export as namespace Papa; diff --git a/types/parcel-bundler/index.d.ts b/types/parcel-bundler/index.d.ts index c661d105cd..230d928db1 100644 --- a/types/parcel-bundler/index.d.ts +++ b/types/parcel-bundler/index.d.ts @@ -2,7 +2,9 @@ // Project: https://github.com/parcel-bundler/parcel#readme // Definitions by: pinage404 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 + +import * as express from "express-serve-static-core"; declare namespace ParcelBundler { interface ParcelOptions { @@ -173,6 +175,8 @@ declare class ParcelBundler { addPackager(type: string, packager: string): void; bundle(): Promise; + + middleware(): (req: express.Request, res: express.Response, next: express.NextFunction) => any; } export = ParcelBundler; diff --git a/types/parcel-bundler/parcel-bundler-tests.ts b/types/parcel-bundler/parcel-bundler-tests.ts index 5833b8527b..0623056c89 100644 --- a/types/parcel-bundler/parcel-bundler-tests.ts +++ b/types/parcel-bundler/parcel-bundler-tests.ts @@ -10,4 +10,6 @@ bundler.addAssetType('md', 'markdown-asset'); bundler.addPackager('md', 'markdown-packager'); +bundler.middleware(); + bundler.bundle().then(bundle => bundle.name); diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index bf89204b04..b87a9f5f56 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -7,6 +7,7 @@ // Wes Grimes // Otherwise SAS // Andrew Goldis +// Alexandre Hétu Rivard // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -490,7 +491,7 @@ declare namespace Parse { /** * Represents a LiveQuery Subscription. - * + * * @see https://docs.parseplatform.org/js/guide/#live-queries * @see NodeJS.EventEmitter * @@ -556,7 +557,7 @@ subscription.on('close', () => {}); class LiveQuerySubscription extends NodeJS.EventEmitter { /** * Creates an instance of LiveQuerySubscription. - * + * * @param {string} id * @param {string} query * @param {string} [sessionToken] @@ -692,12 +693,7 @@ subscription.on('close', () => {}); interface JobRequest { params: any; - } - - interface JobStatus { - error?: (response: any) => void; - message?: (response: any) => void; - success?: (response: any) => void; + message: (response: any) => void; } interface FunctionRequest { @@ -707,12 +703,6 @@ subscription.on('close', () => {}); user?: User; } - interface FunctionResponse { - success: (response: any) => void; - error (code: number, response: any): void; - error (response: any): void; - } - interface Cookie { name?: string; options?: CookieOptions; @@ -734,11 +724,7 @@ subscription.on('close', () => {}); interface AfterSaveRequest extends TriggerRequest { } interface AfterDeleteRequest extends TriggerRequest { } interface BeforeDeleteRequest extends TriggerRequest { } - interface BeforeDeleteResponse extends FunctionResponse { } interface BeforeSaveRequest extends TriggerRequest { } - interface BeforeSaveResponse extends FunctionResponse { - success: () => void; - } // Read preference describes how MongoDB driver route read operations to the members of a replica set. enum ReadPreferenceOption { @@ -760,19 +746,16 @@ subscription.on('close', () => {}); objects: Object[] } - interface AfterFindResponse extends FunctionResponse { - success: (objects: Object[]) => void; - } - - function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void; - function afterSave(arg1: any, func?: (request: AfterSaveRequest) => void): void; - function beforeDelete(arg1: any, func?: (request: BeforeDeleteRequest, response: BeforeDeleteResponse) => void): void; - function beforeSave(arg1: any, func?: (request: BeforeSaveRequest, response: BeforeSaveResponse) => void): void; - function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => void): void; - function afterFind(arg1: any, func?: (request: AfterFindRequest, response: AfterFindResponse) => void): void; - function define(name: string, func?: (request: FunctionRequest, response: FunctionResponse) => void): void; + function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => Promise | void): void; + function afterSave(arg1: any, func?: (request: AfterSaveRequest) => Promise | void): void; + function beforeDelete(arg1: any, func?: (request: BeforeDeleteRequest) => Promise | void): void; + function beforeSave(arg1: any, func?: (request: BeforeSaveRequest) => Promise | void): void; + function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => Promise | void): void; + function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => Promise | Query): void; + function afterFind(arg1: any, func?: (request: AfterFindRequest) => Promise | any): void; + function define(name: string, func?: (request: FunctionRequest) => Promise | any): void; function httpRequest(options: HTTPOptions): Promise; - function job(name: string, func?: (request: JobRequest, status: JobStatus) => void): HttpResponse; + function job(name: string, func?: (request: JobRequest) => Promise | void): HttpResponse; function run(name: string, data?: any, options?: RunOptions): Promise; function useMasterKey(): void; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 8a2064e968..cb80764cd4 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -126,7 +126,7 @@ function test_query() { // Find objects with distinct key query.distinct('name'); - const testQuery = Parse.Query.or(query, query); + const testQuery = Parse.Query.or(query, query); } async function test_query_promise() { @@ -348,30 +348,30 @@ function test_cloud_functions() { // result }); - Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest, - response: Parse.Cloud.BeforeDeleteResponse) => { + Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest) => { + // result + }); + + Parse.Cloud.beforeDelete('MyCustomClass', async (request: Parse.Cloud.BeforeDeleteRequest) => { // result }); const CUSTOM_ERROR_INVALID_CONDITION = 1001 const CUSTOM_ERROR_IMMUTABLE_FIELD = 1002 - Parse.Cloud.beforeSave('MyCustomClass', (request: Parse.Cloud.BeforeSaveRequest, - response: Parse.Cloud.BeforeSaveResponse) => { - + Parse.Cloud.beforeSave('MyCustomClass', async (request: Parse.Cloud.BeforeSaveRequest) => { if (request.object.isNew()) { - if (!request.object.has('immutable')) return response.error('Field immutable is required') + if (!request.object.has('immutable')) throw new Error('Field immutable is required') } else { const original = request.original; if (original == null) { // When the object is not new, request.original must be defined - return response.error(CUSTOM_ERROR_INVALID_CONDITION, 'Original must me defined for an existing object') + throw new Parse.Error(CUSTOM_ERROR_INVALID_CONDITION, 'Original must me defined for an existing object') } if (original.get('immutable') !== request.object.get('immutable')) { - return response.error(CUSTOM_ERROR_IMMUTABLE_FIELD, 'This field cannot be changed') + throw new Parse.Error(CUSTOM_ERROR_IMMUTABLE_FIELD, 'This field cannot be changed') } } - response.success() }); Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { @@ -388,6 +388,30 @@ function test_cloud_functions() { request.readPreference = Parse.Cloud.ReadPreferenceOption.SecondaryPreferred request.readPreference = Parse.Cloud.ReadPreferenceOption.Nearest }); + + Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => { + let query = request.query; // the Parse.Query + + return new Parse.Query("QueryMe!"); + }); + + Parse.Cloud.beforeFind('MyCustomClass', async (request: Parse.Cloud.BeforeFindRequest) => { + let query = request.query; // the Parse.Query + + return new Parse.Query("QueryMe, IN THE FUTURE!"); + }); + + Parse.Cloud.afterFind('MyCustomClass', async (request: Parse.Cloud.AfterFindRequest) => { + return new Parse.Object('MyCustomClass'); + }); + + Parse.Cloud.define('AFunc', (request: Parse.Cloud.FunctionRequest) => { + return 'Some result'; + }); + + Parse.Cloud.job('AJob', (request: Parse.Cloud.JobRequest) => { + request.message('Message to associate with this job run'); + }); } class PlaceObject extends Parse.Object { } diff --git a/types/phantom/phantom-tests.ts b/types/phantom/phantom-tests.ts index b83ac3cc02..a611f195be 100644 --- a/types/phantom/phantom-tests.ts +++ b/types/phantom/phantom-tests.ts @@ -96,7 +96,7 @@ phantom.create(["--web-security=no", "--ignore-ssl-errors=yes"]).then((ph) => { phantom.create().then((ph) => { return ph.createPage().then((page) => { page.open("http://localhost:9901/cookie").then((status) => { - var someFunc = (aaa: string, my_obj: Object) => { + var someFunc = function (aaa: string, my_obj: Object) { var attribute_to_want = aaa; var h2Arr: string[] = []; var results = document.querySelectorAll(attribute_to_want); diff --git a/types/phoenix/index.d.ts b/types/phoenix/index.d.ts index 8b0e6574d8..daff513651 100644 --- a/types/phoenix/index.d.ts +++ b/types/phoenix/index.d.ts @@ -1,22 +1,26 @@ -// Type definitions for phoenix +// Type definitions for phoenix 1.4 // Project: https://github.com/phoenixframework/phoenix -// Definitions by: Mirosław Ciastek , John Goff +// Definitions by: Mirosław Ciastek , John Goff , Po Chen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 -declare module "phoenix" { +declare module 'phoenix' { class Push { - constructor(channel: Channel, event: string, payload: any, timeout: number); + constructor( + channel: Channel, + event: string, + payload: object, + timeout: number, + ); - resend(timeout: number): void; send(): void; + resend(timeout: number): void; - receive(status: string, callback: (response?: any) => void): Push; + receive(status: string, callback: (response?: any) => any): this; } - export class Channel { - constructor(topic: string, params?: Object, socket?: Socket); - - rejoinUntilConnected(): void; + class Channel { + constructor(topic: string, params?: object | Function, socket?: Socket); join(timeout?: number): Push; leave(timeout?: number): Push; @@ -28,50 +32,50 @@ declare module "phoenix" { on(event: string, callback: (response?: any) => void): void; off(event: string): void; - canPush(): boolean; - - push(event: string, payload: Object, timeout?: number): Push; + push(event: string, payload: object, timeout?: number): Push; } - export class Socket { - constructor(endPoint: string, opts?: Object); + type ConnectionState = 'connecting' | 'open' | 'closing' | 'closed'; + + interface SocketConnectOption { + params: object | Function; + transport: any; + timeout: number; + heartbeatIntervalMs: number; + reconnectAfterMs: number; + longpollernumber: number; + encode: (payload: object, callback: Function) => any; + decode: (payload: string, callback: Function) => any; + logger: (kind: string, message: string, data: any) => void; + } + + class Socket { + constructor(endPoint: string, opts?: Partial); protocol(): string; endPointURL(): string; - disconnect(callback?: Function, code?: string, reason?: any): void; connect(params?: any): void; + disconnect(callback?: Function, code?: number, reason?: string): void; + connectionState(): ConnectionState; + isConnected(): boolean; - log(kind: string, msg: string, data: any): void; + remove(channel: Channel): void; + channel(topic: string, chanParams?: object): Channel; + push(data: object): void; + + log(kind: string, message: string, data: object): void; + hasLogger(): boolean; onOpen(callback: Function): void; onClose(callback: Function): void; onError(callback: Function): void; onMessage(callback: Function): void; - onConnOpen(): void; - onConnClose(event: any): void; - onConnError(error: any): void; - - triggerChanError(): void; - - connectionState(): string; - - isConnected(): boolean; - - remove(channel: Channel): void; - channel(topic: string, chanParams?: Object): Channel; - - push(data: any): void; - makeRef(): string; - sendHeartbeat(): void; - flushSendBuffer(): void; - - onConnMessage(rawMessage: any): void; } - export class LongPoll { + class LongPoll { constructor(endPoint: string); normalizeEndpoint(endPoint: string): string; @@ -86,8 +90,10 @@ declare module "phoenix" { close(code?: any, reason?: any): void; } - export class Ajax { - request( + class Ajax { + static states: {[state: string]: number}; + + static request( method: string, endPoint: string, accept: string, @@ -97,7 +103,7 @@ declare module "phoenix" { callback?: (response?: any) => void ): void; - xdomainRequest( + static xdomainRequest( req: any, method: string, endPoint: string, @@ -107,7 +113,7 @@ declare module "phoenix" { callback?: (response?: any) => void ): void; - xhrRequest( + static xhrRequest( req: any, method: string, endPoint: string, @@ -118,28 +124,37 @@ declare module "phoenix" { callback?: (response?: any) => void ): void; - parseJSON(resp: string): JSON; - serialize(obj: any, parentKey: string): string; - appendParams(url: string, params: any): string; + static parseJSON(resp: string): JSON; + static serialize(obj: any, parentKey: string): string; + static appendParams(url: string, params: any): string; } - export class Presence { - constructor(channel: Channel, opts?: Object); + class Presence { + constructor(channel: Channel, opts?: object); + + onJoin(callback: Function): void; + onLeave(callback: Function): void; + onSync(callback: Function): void; + list(chooser?: (key: string, presence: any) => T): T[]; + inPendingSyncState(): boolean; static syncState( - currentState: any, - newState: any, + currentState: object, + newState: object, onJoin?: (key?: string, currentPresence?: any, newPresence?: any) => void, onLeave?: (key?: string, currentPresence?: any, newPresence?: any) => void ): any; static syncDiff( - currentState: any, - newState: any, + currentState: object, + diff: {joins: object; leaves: object}, onJoin?: (key?: string, currentPresence?: any, newPresence?: any) => void, onLeave?: (key?: string, currentPresence?: any, newPresence?: any) => void ): any; - static list(presences: Object, chooser?: Function): any; + static list( + presences: object, + chooser?: (key: string, presence: any) => T, + ): T[]; } } diff --git a/types/phoenix/phoenix-tests.ts b/types/phoenix/phoenix-tests.ts index 1e7641fc91..6e34b5c50c 100644 --- a/types/phoenix/phoenix-tests.ts +++ b/types/phoenix/phoenix-tests.ts @@ -1,46 +1,46 @@ import { Socket, Channel, Presence } from 'phoenix'; function test_socket() { - const socket = new Socket("/ws", {params: {userToken: "123"}}); + const socket = new Socket('/ws', {params: {userToken: '123'}}); socket.connect(); } function test_channel() { - const socket = new Socket("/ws", {params: {userToken: "123"}}); + const socket = new Socket('/ws', {params: {userToken: '123'}}); socket.connect(); - const channel = socket.channel("room:123", {token: '123'}); + const channel = socket.channel('room:123', {token: '123'}); - channel.on("new_msg", msg => console.log("Got message", msg)); + channel.on('new_msg', msg => console.log('Got message', msg)); - channel.push("new_msg", {body: 'some value'}, 10000) - .receive("ok", (msg) => console.log("created message", msg)) - .receive("error", (reasons) => console.log("create failed", reasons)) - .receive("timeout", () => console.log("Networking issue...")); + channel.push('new_msg', {body: 'some value'}, 10000) + .receive('ok', (msg) => console.log('created message', msg)) + .receive('error', (reasons) => console.log('create failed', reasons)) + .receive('timeout', () => console.log('Networking issue...')); channel.join() - .receive("ok", ({messages}) => console.log("catching up", messages)) - .receive("error", ({reason}) => console.log("failed join", reason)) - .receive("timeout", () => console.log("Networking issue. Still waiting...")); + .receive('ok', ({messages}) => console.log('catching up', messages)) + .receive('error', ({reason}) => console.log('failed join', reason)) + .receive('timeout', () => console.log('Networking issue. Still waiting...')); } function test_hooks() { - const socket = new Socket("/ws", {params: {userToken: "123"}}); + const socket = new Socket('/ws', {params: {userToken: '123'}}); socket.connect(); - socket.onError(() => console.log("there was an error with the connection!")); - socket.onClose(() => console.log("the connection dropped")); + socket.onError(() => console.log('there was an error with the connection!')); + socket.onClose(() => console.log('the connection dropped')); - const channel = socket.channel("room:123", {token: '123'}); + const channel = socket.channel('room:123', {token: '123'}); - channel.onError(() => console.log("there was an error!")); - channel.onClose(() => console.log("the channel has gone away gracefully")) + channel.onError(() => console.log('there was an error!')); + channel.onClose(() => console.log('the channel has gone away gracefully')); } function test_presence() { - const socket = new Socket("/ws", {params: {userToken: "123"}}); + const socket = new Socket('/ws', {params: {userToken: '123'}}); - const channel = socket.channel("room:123", {token: '123'}); + const channel = socket.channel('room:123', {token: '123'}); const presence = new Presence(channel); let presenceState = {}; @@ -49,12 +49,12 @@ function test_presence() { Presence.list(state, (id: string) => id).forEach(console.log); }; - channel.on("presence_state", (state) => { + channel.on('presence_state', (state) => { presenceState = Presence.syncState(presenceState, state); logState(presenceState); }); - channel.on("presence_diff", (diff) => { + channel.on('presence_diff', (diff) => { presenceState = Presence.syncState(presenceState, diff); logState(presenceState); }); diff --git a/types/phoenix/tslint.json b/types/phoenix/tslint.json index a41bf5d19a..6fca40ff8d 100644 --- a/types/phoenix/tslint.json +++ b/types/phoenix/tslint.json @@ -1,79 +1,117 @@ { - "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", + "rules": { + "arrow-return-shorthand": true, + "ban-types": false, + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "deprecation": { + "severity": "warn" + }, + "eofline": true, + "forin": true, + "import-spacing": false, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": false, + "member-access": false, + "member-ordering": false, + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-declare-current-package": false, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-redundant-jsdoc": true, + "no-single-declare-module": false, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unnecessary-class": false, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "no-output-on-prefix": true, + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true + } } + diff --git a/types/pikaday/index.d.ts b/types/pikaday/index.d.ts index 2233fa9b4c..3061cd67e7 100644 --- a/types/pikaday/index.d.ts +++ b/types/pikaday/index.d.ts @@ -36,7 +36,7 @@ declare class Pikaday { * Returns a JavaScript Date object for the selected day, or null if * no date is selected. */ - getDate(): Date; + getDate(): Date | null; /** * Set the current selection. This will be restricted within the bounds @@ -50,7 +50,7 @@ declare class Pikaday { * Returns a Moment.js object for the selected date (Moment must be * loaded before Pikaday). */ - getMoment(): moment.Moment; + getMoment(): moment.Moment | null; /** * Set the current selection with a Moment.js object (see setDate). @@ -159,7 +159,7 @@ declare namespace Pikaday { /** * Bind the datepicker to a form field. */ - field?: HTMLElement; + field?: HTMLElement | null; /** * The default output format for toString() and field value. @@ -171,7 +171,7 @@ declare namespace Pikaday { * Use a different element to trigger opening the datepicker. * Default: field element. */ - trigger?: HTMLElement; + trigger?: HTMLElement | null; /** * Automatically show/hide the datepicker on field focus. @@ -201,7 +201,7 @@ declare namespace Pikaday { * DOM node to render calendar into, see container example. * Default: undefined. */ - container?: HTMLElement; + container?: HTMLElement | null; /** * The initial date to view when first opened. @@ -330,12 +330,12 @@ declare namespace Pikaday { * Function which will be used for parsing input string and getting a date object from it. * This function will take precedence over moment. */ - parse?(date: string, format: string): Date; + parse?(date: string, format: string): Date | null; /** * Callback function for when a date is selected. */ - onSelect?(date: Date): void; + onSelect?(this: Pikaday, date: Date): void; /** * Callback function for when the picker becomes visible. diff --git a/types/pikaday/pikaday-tests.ts b/types/pikaday/pikaday-tests.ts index 230104daf7..83790b70ec 100644 --- a/types/pikaday/pikaday-tests.ts +++ b/types/pikaday/pikaday-tests.ts @@ -14,15 +14,15 @@ new Pikaday({field: $('#datepicker')[0]}); console.log(date.toISOString()); } }); - field.parentNode.insertBefore(picker.el, field.nextSibling); + field.parentNode!.insertBefore(picker.el, field.nextSibling); })(); (() => { const picker = new Pikaday({ field: document.getElementById('datepicker'), format: 'D MMM YYYY', - onSelect: () => { - console.log(this.getMoment().format('Do MMMM YYYY')); + onSelect() { + console.log(this.getMoment()!.format('Do MMMM YYYY')); } }); @@ -116,3 +116,7 @@ new Pikaday({field: $('#datepicker')[0]}); toString: (date, format) => '2017-08-23' }); })(); + +new Pikaday({ + parse: (date) => null +}); diff --git a/types/pikaday/tsconfig.json b/types/pikaday/tsconfig.json index 3c936ab905..0c18391e53 100644 --- a/types/pikaday/tsconfig.json +++ b/types/pikaday/tsconfig.json @@ -6,8 +6,8 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -21,4 +21,4 @@ "index.d.ts", "pikaday-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/pino-http/index.d.ts b/types/pino-http/index.d.ts index 54ac4e9149..86fae78a3e 100644 --- a/types/pino-http/index.d.ts +++ b/types/pino-http/index.d.ts @@ -20,6 +20,7 @@ declare namespace PinoHttp { genReqId?: GenReqId; useLevel?: Level; stream?: DestinationStream; + customLogLevel?: (res: ServerResponse, error: Error) => Level; } interface GenReqId { diff --git a/types/pino-http/pino-http-tests.ts b/types/pino-http/pino-http-tests.ts index 8a86bf08e8..013e23ae10 100644 --- a/types/pino-http/pino-http-tests.ts +++ b/types/pino-http/pino-http-tests.ts @@ -18,3 +18,4 @@ pinoHttp({ genReqId: (req) => Buffer.allocUnsafe(16) }); pinoHttp({ useLevel: 'error' }); pinoHttp({ prettyPrint: true }); pinoHttp(new Writable()); +pinoHttp({ customLogLevel(req, res) { return 'info'; } }); diff --git a/types/pkijs/index.d.ts b/types/pkijs/index.d.ts index 106dfa2405..63cbee5207 100644 --- a/types/pkijs/index.d.ts +++ b/types/pkijs/index.d.ts @@ -1908,6 +1908,12 @@ declare module "pkijs/src/RelativeDistinguishedNames" { fromSchema(schema: any): void; toSchema(): any; toJSON(): any; + /** + * Compare two RDN values, or RDN with ArrayBuffer value + * @param {(RelativeDistinguishedNames|ArrayBuffer)} compareTo The value compare to current + * @returns {boolean} + */ + isEqual(compareTo: RelativeDistinguishedNames|ArrayBuffer): boolean; } } diff --git a/types/pkijs/pkijs-tests.ts b/types/pkijs/pkijs-tests.ts index 6b7b73bb00..f2c9a88990 100644 --- a/types/pkijs/pkijs-tests.ts +++ b/types/pkijs/pkijs-tests.ts @@ -12,6 +12,8 @@ import SignerInfo from "pkijs/src/SignerInfo"; import IssuerAndSerialNumber from "pkijs/src/IssuerAndSerialNumber"; import SignedAndUnsignedAttributes from "pkijs/src/SignedAndUnsignedAttributes"; import ContentInfo from "pkijs/src/ContentInfo"; +import RelativeDistinguishedNames from "pkijs/src/RelativeDistinguishedNames"; + // ********************************************************************************* let cmsSignedBuffer = new ArrayBuffer(0); // ArrayBuffer with loaded or created CMS_Signed const trustedCertificates: Certificate[] = []; // Array of root certificates from "CA Bundle" @@ -657,4 +659,14 @@ function handleCABundle(evt: Event) { event => parseCAbundle((event.target as any).result); tempReader.readAsArrayBuffer(currentFiles[0]); -} \ No newline at end of file +} + +function typetest_RelativeDN_isEqual() { + + const rdn1 = new RelativeDistinguishedNames(); + const rdn2 = new RelativeDistinguishedNames(); + const arraybuf = new ArrayBuffer(1); + + rdn1.isEqual(rdn2); // $ExpectType boolean + rdn1.isEqual(arraybuf); // $ExpectType boolean +} diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index af90a6f6a0..8e5622bdef 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for plotly.js 1.43 +// Type definitions for plotly.js 1.44 // Project: https://plot.ly/javascript/, https://github.com/plotly/plotly.js // Definitions by: Chris Gervang // Martin Duparc @@ -10,6 +10,7 @@ // Sooraj Pudiyadath // Jon Freedman // Megan Riel-Mehan +// Takafumi Yamaguchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -205,7 +206,17 @@ export function deleteFrames(root: Root, frames: number[]): Promise; + xref: 'container' | 'paper'; + yref: 'container' | 'paper'; + x: number; + y: number; + xanchor: 'auto' | 'left' | 'center' | 'right'; + yanchor: 'auto' | 'top' | 'middle' | 'bottom'; + pad: Partial + }>; titlefont: Partial; autosize: boolean; showlegend: boolean; diff --git a/types/plotly.js/test/index-tests.ts b/types/plotly.js/test/index-tests.ts index 79343f43f7..828f2870a3 100644 --- a/types/plotly.js/test/index-tests.ts +++ b/types/plotly.js/test/index-tests.ts @@ -251,6 +251,24 @@ const graphDiv = '#test'; }; Plotly.update(graphDiv, data_update, layout_update); })(); + +(() => { + const update = { + title: { + text: 'some new title', + font: { + size: 1.2, + }, + x: 0.9, + pad: { + t: 20 + }, + }, // updates the title + 'xaxis.range': [0, 5], // updates the xaxis range + 'yaxis.range[1]': 15 // updates the end of the yaxis range + } as Layout; + Plotly.relayout(graphDiv, update); +})(); ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// diff --git a/types/png-async/index.d.ts b/types/png-async/index.d.ts deleted file mode 100644 index cef8207ae2..0000000000 --- a/types/png-async/index.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Type definitions for png-async -// Project: https://github.com/kanreisa/node-png-async -// Definitions by: Yuki KAN -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - - -import stream = require('stream'); - -export interface IImageOptions { - width?: number; - height?: number; - fill?: boolean; - checkCRC?: boolean; - deflateChunkSize?: number; - deflateLevel?: number; - deflateStrategy?: EDeflateStrategy; - filterType?: EFilterType; -} - -export declare enum EDeflateStrategy { - DEFAULT_STRATEGY = 0, - FILTERED = 1, - HUFFMAN_ONLY = 2, - RLE = 3, - FIXED = 4, -} - -export declare enum EFilterType { - Auto = -1, - None = 0, - Sub = 1, - Up = 2, - Average = 3, - Paeth = 4, -} - -export declare function createImage(option?: IImageOptions): Image; - -export declare class Image extends stream.Duplex { - width: number; - height: number; - gamma: number; - data: Buffer; - constructor(option?: IImageOptions); - pack(): Image; - parse(data: Buffer, callback?: (err: Error, image: Image) => void): Image; - write(data: any, cb?: any): boolean; - end(data?: any): void; - bitblt(dst: Image, sx: number, sy: number, w: number, h: number, dx: number, dy: number): Image; -} diff --git a/types/png-async/png-async-tests.ts b/types/png-async/png-async-tests.ts deleted file mode 100644 index f108fe66b8..0000000000 --- a/types/png-async/png-async-tests.ts +++ /dev/null @@ -1,31 +0,0 @@ - -import fs = require('fs'); -import png = require('png-async'); - -var devnull = process.platform === 'win32' ? 'nul' : '/dev/null'; - -// stream test -var img = new png.Image({ - width: 1, - height: 1, - fill: true -}) - .pack() - .pipe(png.createImage({ - deflateStrategy: png.EDeflateStrategy.FIXED, - filterType: png.EFilterType.Auto - }) - .on('parsed', function () { - - if (this.data[0] !== 0) { - throw new Error('invalid data'); - } - - this.data[0] = 255; - this.data[3] = 255; - - this.pack().pipe(fs.createWriteStream(devnull)).on('finish', () => { - console.log('done'); - }); - }) - ); diff --git a/types/png-async/tsconfig.json b/types/png-async/tsconfig.json deleted file mode 100644 index 181b899496..0000000000 --- a/types/png-async/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "png-async-tests.ts" - ] -} \ No newline at end of file diff --git a/types/png-async/tslint.json b/types/png-async/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/png-async/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "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 - } -} diff --git a/types/pollyjs__core/index.d.ts b/types/pollyjs__core/index.d.ts index 38cd511408..7ad3c2a82f 100644 --- a/types/pollyjs__core/index.d.ts +++ b/types/pollyjs__core/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for @pollyjs/core 2.2 +// Type definitions for @pollyjs/core 2.3 // Project: https://github.com/netflix/pollyjs/tree/master/packages/@pollyjs/core // Definitions by: feinoujc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -129,12 +129,12 @@ export class RouteHandler { once(event: RecordingRouteEvent, listener: RecordingEventListener): RouteHandler; once(event: ResponseRouteEvent, listener: ResponseEventListener): RouteHandler; once(event: ErrorRouteEvent, listener: ErrorEventListener): RouteHandler; - + filter: (callback: (req: Request) => boolean) => RouteHandler; passthrough(value?: boolean): RouteHandler; intercept( fn: (req: Request, res: Response, intercept: Intercept) => EventListenerResponse ): RouteHandler; - recordingName(recordingName: string): RouteHandler; + recordingName(recordingName?: string): RouteHandler; configure(config: PollyConfig): RouteHandler; } export class PollyServer { diff --git a/types/pollyjs__core/pollyjs__core-tests.ts b/types/pollyjs__core/pollyjs__core-tests.ts index bccd074bcf..cfe9047ccd 100644 --- a/types/pollyjs__core/pollyjs__core-tests.ts +++ b/types/pollyjs__core/pollyjs__core-tests.ts @@ -113,6 +113,16 @@ async function test() { /* Do something else */ }); + server + .get('/users/:id') + .filter(req => req.params.id === '1') + .filter(req => req.params.id !== '2') + .recordingName('test') + .recordingName() + .intercept((_req, res) => { + res.status(200).json({ email: 'user1@test.com' }); + }); + /* Intercept all Google Analytic requests and respond with a 200 */ server.get('/google-analytics/*path').intercept((req, res, intercept) => { if (req.pathname === 'test') { diff --git a/types/postcss-url/index.d.ts b/types/postcss-url/index.d.ts index 361b69f1c7..472fccc21b 100644 --- a/types/postcss-url/index.d.ts +++ b/types/postcss-url/index.d.ts @@ -84,6 +84,13 @@ declare namespace url { */ ignoreFragmentWarning?: boolean; + /** + * Reduce size of inlined svg (IE9+, Android 3+) + * + * @default false + */ + optimizeSvgEncode?: boolean; + /** * Determine wether a file should be inlined. */ diff --git a/types/postcss-url/postcss-url-tests.ts b/types/postcss-url/postcss-url-tests.ts index a258b49be4..70086036ab 100644 --- a/types/postcss-url/postcss-url-tests.ts +++ b/types/postcss-url/postcss-url-tests.ts @@ -7,7 +7,7 @@ const single: postcss.Transformer = url({ url: 'copy', assetsPath: 'img', useHas const multiple: postcss.Transformer = url([ { filter: '**/assets/copy/*.png', url: 'copy', assetsPath: 'img', useHash: true }, - { filter: '**/assets/inline/*.svg', url: 'inline' }, + { filter: '**/assets/inline/*.svg', url: 'inline', optimizeSvgEncode: true }, { filter: '**/assets/**/*.gif', url: 'rebase' }, { filter: 'cdn/**/*', url: (asset) => `https://cdn.url/${asset.url}` }, ]); diff --git a/types/pretty-time/index.d.ts b/types/pretty-time/index.d.ts new file mode 100644 index 0000000000..0dadc88091 --- /dev/null +++ b/types/pretty-time/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for pretty-time 1.1 +// Project: https://github.com/jonschlinkert/pretty-time +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.3 + +type Increment = + | 'ns' + | 'nano' + | 'nanosecond' + | 'nanoseconds' + | 'μs' + | 'micro' + | 'microsecond' + | 'microseconds' + | 'ms' + | 'milli' + | 'millisecond' + | 'milliseconds' + | 's' + | 'sec' + | 'second' + | 'seconds' + | 'm' + | 'min' + | 'minute' + | 'minutes' + | 'h' + | 'hr' + | 'hour' + | 'hours' + | 'd' + | 'day' + | 'days' + | 'w' + | 'wk' + | 'week' + | 'weeks'; + +declare function prettyTime(time: number[], smallest?: Increment, digits?: number): string; + +export = prettyTime; diff --git a/types/pretty-time/pretty-time-tests.ts b/types/pretty-time/pretty-time-tests.ts new file mode 100644 index 0000000000..895042ecd1 --- /dev/null +++ b/types/pretty-time/pretty-time-tests.ts @@ -0,0 +1,13 @@ +import DateTime = require("pretty-time"); + +DateTime([1200708, 795428088]); + +DateTime([0, 795428088]); + +DateTime([0, 795428088], 'h'); + +DateTime([0, 795428088], 'm'); + +DateTime([0, 795428088], 'μs', 2); + +DateTime([0, 795428088], 'ms', 1); diff --git a/types/pretty-time/tsconfig.json b/types/pretty-time/tsconfig.json new file mode 100644 index 0000000000..d18e4b1fa1 --- /dev/null +++ b/types/pretty-time/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pretty-time-tests.ts" + ] +} diff --git a/types/pretty-time/tslint.json b/types/pretty-time/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/pretty-time/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/progress-stream/index.d.ts b/types/progress-stream/index.d.ts new file mode 100644 index 0000000000..17410ea177 --- /dev/null +++ b/types/progress-stream/index.d.ts @@ -0,0 +1,102 @@ +// Type definitions for progress-stream 2.0 +// Project: https://github.com/freeall/progress-stream +// Definitions by: Mick Dekkers +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// + +import stream = require("stream"); +export = progress_stream; + +declare function progress_stream( + options: progress_stream.Options, + progressListener: progress_stream.ProgressListener, +): progress_stream.ProgressStream; + +declare function progress_stream( + optionsOrProgressListener?: + | progress_stream.Options + | progress_stream.ProgressListener, +): progress_stream.ProgressStream; + +declare namespace progress_stream { + interface Options { + time?: number; + speed?: number; + length?: number; + drain?: boolean; + transferred?: number; + } + + type ProgressListener = (progress: Progress) => void; + + interface ProgressStream extends stream.Transform { + on(event: "progress", listener: ProgressListener): this; + on(event: "length", listener: (length: number) => void): this; + once(event: "progress", listener: ProgressListener): this; + once(event: "length", listener: (length: number) => void): this; + setLength(length: number): void; + progress(): Progress; + + // We have to redeclare all on/once overloads from stream.Transform in + // order for this ProgressStream interface to extend stream.Transform + // correctly. Using an intersection type instead may be an option once + // https://github.com/Microsoft/TypeScript/issues/30031 is resolved. + + // stream.Readable events + + /* tslint:disable-next-line adjacent-overload-signatures */ + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: any) => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "end", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "readable", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + /* tslint:disable-next-line adjacent-overload-signatures */ + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: any) => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "end", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "readable", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + + // stream.Writable events + + /* tslint:disable-next-line adjacent-overload-signatures unified-signatures */ + on(event: "drain", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: stream.Readable) => void): this; + /* tslint:disable-next-line unified-signatures */ + on(event: "unpipe", listener: (src: stream.Readable) => void): this; + /* tslint:disable-next-line adjacent-overload-signatures unified-signatures */ + once(event: "drain", listener: () => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: stream.Readable) => void): this; + /* tslint:disable-next-line unified-signatures */ + once(event: "unpipe", listener: (src: stream.Readable) => void): this; + + // events shared by stream.Readable and stream.Writable + + /* tslint:disable-next-line adjacent-overload-signatures */ + on(event: string | symbol, listener: (...args: any[]) => void): this; + /* tslint:disable-next-line adjacent-overload-signatures */ + once(event: string | symbol, listener: (...args: any[]) => void): this; + /* tslint:enable adjacent-overload-signatures unified-signatures */ + } + + interface Progress { + percentage: number; + transferred: number; + length: number; + remaining: number; + eta: number; + runtime: number; + delta: number; + speed: number; + } +} diff --git a/types/progress-stream/progress-stream-tests.ts b/types/progress-stream/progress-stream-tests.ts new file mode 100644 index 0000000000..e10ab0f925 --- /dev/null +++ b/types/progress-stream/progress-stream-tests.ts @@ -0,0 +1,71 @@ +import progress = require("progress-stream"); +import stream = require("stream"); + +const options: progress.Options = { + time: 100, + speed: 100, + length: 100, + drain: true, + transferred: 0, +}; + +const progressListener = (progress: progress.Progress) => { + // $ExpectType number + progress.percentage; + // $ExpectType number + progress.transferred; + // $ExpectType number + progress.length; + // $ExpectType number + progress.remaining; + // $ExpectType number + progress.eta; + // $ExpectType number + progress.runtime; + // $ExpectType number + progress.delta; + // $ExpectType number + progress.speed; +}; + +// $ExpectType ProgressStream +const p = progress(); + +// $ExpectType ProgressStream +progress(options); + +// $ExpectType ProgressStream +progress(options, progressListener); + +// $ExpectType ProgressStream +progress(progressListener); + +// $ExpectType ProgressStream +p.on("progress", progressListener); + +// $ExpectType ProgressStream +p.on("length", (length: number) => {}); + +p.setLength(200); // $ExpectType void + +p.progress(); // $ExpectType Progress + +// Check if ProgressStream extends stream.Transform correctly + +// $ExpectType ProgressStream +p.on("close", () => {}); +// $ExpectType ProgressStream +p.on("data", (chunk: any) => {}); +// $ExpectType ProgressStream +p.on("end", () => {}); +// $ExpectType ProgressStream +p.on("error", (err: Error) => {}); +// $ExpectType ProgressStream +p.on("readable", () => {}); +// $ExpectType ProgressStream +p.pause(); + +const writable = new stream.Writable(); + +// $ExpectType Writable +p.pipe(writable); diff --git a/types/progress-stream/tsconfig.json b/types/progress-stream/tsconfig.json new file mode 100644 index 0000000000..0dfc8b25fc --- /dev/null +++ b/types/progress-stream/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": ["index.d.ts", "progress-stream-tests.ts"] +} diff --git a/types/p-queue/v2/tslint.json b/types/progress-stream/tslint.json similarity index 100% rename from types/p-queue/v2/tslint.json rename to types/progress-stream/tslint.json diff --git a/types/prop-types/index.d.ts b/types/prop-types/index.d.ts index 75461dc372..ddb8c64947 100644 --- a/types/prop-types/index.d.ts +++ b/types/prop-types/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for prop-types 15.5 +// Type definitions for prop-types 15.7 // Project: https://github.com/reactjs/prop-types, https://facebook.github.io/react // Definitions by: DovydasNavickas // Ferdy Budhidharma +// Sebastian Silbermann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -62,6 +63,7 @@ export const string: Requireable; export const node: Requireable; export const element: Requireable; export const symbol: Requireable; +export const elementType: Requireable; export function instanceOf(expectedClass: new (...args: any[]) => T): Requireable; export function oneOf(types: T[]): Requireable; export function oneOfType>(types: T[]): Requireable>>; @@ -81,3 +83,8 @@ export function exact

>(type: P): Requireable any): void; + +/** + * Only available if NODE_ENV=production + */ +export function resetWarningCache(): void; diff --git a/types/prop-types/prop-types-tests.ts b/types/prop-types/prop-types-tests.ts index 5973e6a7ca..e6067ee740 100644 --- a/types/prop-types/prop-types-tests.ts +++ b/types/prop-types/prop-types-tests.ts @@ -34,6 +34,7 @@ interface Props { }; optionalNumber?: number | null; customProp?: typeof uniqueType; + component: PropTypes.ReactComponentLike; } const innerProps = { @@ -74,7 +75,8 @@ const propTypes: PropTypesMap = { objectOf: PropTypes.objectOf(PropTypes.number.isRequired).isRequired, shape: PropTypes.shape(innerProps).isRequired, optionalNumber: PropTypes.number, - customProp: (() => null) as PropTypes.Validator + customProp: (() => null) as PropTypes.Validator, + component: PropTypes.elementType.isRequired }; // JS checking @@ -100,7 +102,8 @@ const propTypesWithoutAnnotation = { objectOf: PropTypes.objectOf(PropTypes.number.isRequired).isRequired, shape: PropTypes.shape(innerProps).isRequired, optionalNumber: PropTypes.number, - customProp: (() => null) as PropTypes.Validator + customProp: (() => null) as PropTypes.Validator, + component: PropTypes.elementType.isRequired }; const partialPropTypes = { @@ -150,6 +153,7 @@ type ExtractFromOuterPropsMatch4 = Props extends ExtractedPropsFromOuterPropsWit type ExtractPropsMismatch = ExtractedPartialProps extends Props ? true : false; PropTypes.checkPropTypes({ xs: PropTypes.array }, { xs: [] }, 'location', 'componentName'); +PropTypes.resetWarningCache(); // This would be the type that JSX sees type Defaultize = diff --git a/types/proper-lockfile/index.d.ts b/types/proper-lockfile/index.d.ts index 885e63808b..3e49e79fe3 100644 --- a/types/proper-lockfile/index.d.ts +++ b/types/proper-lockfile/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for proper-lockfile 3.0 // Project: https://github.com/moxystudio/node-proper-lockfile // Definitions by: Nikita Volodin +// Linus Unnebäck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface LockOptions { @@ -10,17 +11,20 @@ export interface LockOptions { realpath?: boolean; // default: true fs?: any; // default: graceful-fs onCompromised?: (err: Error) => any; // default: (err) => throw err + lockfilePath?: string; // default: `${file}.lock` } export interface UnlockOptions { realpath?: boolean; // default: true fs?: any; // default: graceful-fs + lockfilePath?: string; // default: `${file}.lock` } export interface CheckOptions { stale?: number; // default: 10000 realpath?: boolean; // default: true fs?: any; // default: graceful-fs + lockfilePath?: string; // default: `${file}.lock` } export function lock(file: string, options?: LockOptions): Promise<() => Promise>; diff --git a/types/proper-lockfile/proper-lockfile-tests.ts b/types/proper-lockfile/proper-lockfile-tests.ts index 7555fd5116..344e7be3f8 100644 --- a/types/proper-lockfile/proper-lockfile-tests.ts +++ b/types/proper-lockfile/proper-lockfile-tests.ts @@ -39,7 +39,12 @@ check('some/file') // isLocked will be true if 'some/file' is locked, false otherwise }); +lock('', { lockfilePath: 'some/file-lock' }) + .then((release) => release()); + const release = lockSync('some/file'); // $ExpectType () => void release(); // $ExpectType void unlockSync('some/file'); // $ExpectType void +unlockSync('', { lockfilePath: 'some/file-lock' }); // $ExpectType void checkSync('some/file'); // $ExpectType boolean +checkSync('', { lockfilePath: 'some/file-lock' }); // $ExpectType boolean diff --git a/types/prosemirror-state/index.d.ts b/types/prosemirror-state/index.d.ts index a0c2b6ae69..0fc8950838 100644 --- a/types/prosemirror-state/index.d.ts +++ b/types/prosemirror-state/index.d.ts @@ -22,7 +22,7 @@ import { EditorProps, EditorView } from 'prosemirror-view'; * This is the type passed to the [`Plugin`](#state.Plugin) * constructor. It provides a definition for a plugin. */ -export interface PluginSpec { +export interface PluginSpec { /** * The [view props](#view.EditorProps) added by this plugin. Props * that are functions will be bound to have the plugin instance as @@ -33,14 +33,14 @@ export interface PluginSpec { * Allows a plugin to define a [state field](#state.StateField), an * extra slot in the state object in which it can keep its own data. */ - state?: StateField | null; + state?: StateField | null; /** * Can be used to make this a keyed plugin. You can have only one * plugin with a given key in a given state, but it is possible to * access the plugin's configuration and state through the key, * without having access to the plugin instance object. */ - key?: PluginKey | null; + key?: PluginKey | null; /** * When the plugin needs to interact with the editor view, or * set something up in the DOM, use this field. The function @@ -82,11 +82,11 @@ export interface PluginSpec { * They are part of the [editor state](#state.EditorState) and * may influence that state and the view that contains it. */ -export class Plugin { +export class Plugin { /** * Create a plugin. */ - constructor(spec: PluginSpec); + constructor(spec: PluginSpec); /** * The [props](#view.EditorProps) exported by this plugin. */ @@ -94,11 +94,11 @@ export class Plugin { /** * The plugin's [spec object](#state.PluginSpec). */ - spec: { [key: string]: any }; + spec: PluginSpec; /** * Extract the plugin's state field from an editor state. */ - getState(state: EditorState): any; + getState(state: EditorState): T; } /** * A plugin spec may provide a state field (under its @@ -106,7 +106,7 @@ export class Plugin { * describes the state it wants to keep. Functions provided here are * always called with the plugin instance as their `this` binding. */ -export interface StateField { +export interface StateField { /** * Initialize the value of the field. `config` will be the object * passed to [`EditorState.create`](#state.EditorState^create). Note @@ -138,7 +138,7 @@ export interface StateField { * editor state. Assigning a key does mean only one plugin of that * type can be active in a state. */ -export class PluginKey { +export class PluginKey { /** * Create a plugin key. */ @@ -147,7 +147,7 @@ export class PluginKey { * Get the active plugin with this key, if any, from an editor * state. */ - get(state: EditorState): Plugin | null | undefined; + get(state: EditorState): Plugin | null | undefined; /** * Get the plugin's state from an editor state. */ @@ -440,7 +440,7 @@ export class EditorState { /** * The plugins that are active in this state. */ - plugins: Array>; + plugins: Array>; /** * Apply the given transaction to produce a new state. */ @@ -465,13 +465,13 @@ export class EditorState { * [`init`](#state.StateField.init) method, passing in the new * configuration object.. */ - reconfigure(config: { schema?: S | null; plugins?: Array> | null }): EditorState; + reconfigure(config: { schema?: S | null; plugins?: Array> | null }): EditorState; /** * Serialize this state to JSON. If you want to serialize the state * of plugins, pass an object mapping property names to use in the * resulting JSON object to plugin objects. */ - toJSON(pluginFields?: { [name: string]: Plugin } | string | number): { [key: string]: any }; + toJSON(pluginFields?: { [name: string]: Plugin } | string | number): { [key: string]: any }; /** * Create a new state. */ @@ -480,7 +480,7 @@ export class EditorState { doc?: ProsemirrorNode | null; selection?: Selection | null; storedMarks?: Mark[] | null; - plugins?: Array> | null; + plugins?: Array> | null; }): EditorState; /** * Deserialize a JSON representation of a state. `config` should @@ -490,9 +490,9 @@ export class EditorState { * instances with the property names they use in the JSON object. */ static fromJSON( - config: { schema: S; plugins?: Array> | null }, + config: { schema: S; plugins?: Array> | null }, json: { [key: string]: any }, - pluginFields?: { [name: string]: Plugin } + pluginFields?: { [name: string]: Plugin } ): EditorState; } /** @@ -589,11 +589,11 @@ export class Transaction extends Transform { * Store a metadata property in this transaction, keyed either by * name or by plugin. */ - setMeta(key: string | Plugin | PluginKey, value: any): Transaction; + setMeta(key: string | Plugin | PluginKey, value: any): Transaction; /** * Retrieve a metadata property for a given name or plugin. */ - getMeta(key: string | Plugin | PluginKey): any; + getMeta(key: string | Plugin | PluginKey): any; /** * Returns true if this transaction doesn't contain any metadata, * and can thus safely be extended. diff --git a/types/prosemirror-view/index.d.ts b/types/prosemirror-view/index.d.ts index a539be4593..da83390c40 100644 --- a/types/prosemirror-view/index.d.ts +++ b/types/prosemirror-view/index.d.ts @@ -79,6 +79,7 @@ export class Decoration { pos: number, toDOM: ((view: EditorView, getPos: () => number) => Node) | Node, spec?: { + [key: string]: any; side?: number | null; marks?: Mark[] | null; stopEvent?: ((event: Event) => boolean) | null; diff --git a/types/qs/index.d.ts b/types/qs/index.d.ts index 2a3b10a273..aead3eb442 100644 --- a/types/qs/index.d.ts +++ b/types/qs/index.d.ts @@ -19,7 +19,7 @@ declare namespace QueryString { encode?: boolean; encoder?: (str: string) => any; filter?: Array | ((prefix: string, value: any) => any); - arrayFormat?: 'indices' | 'brackets' | 'repeat'; + arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma'; indices?: boolean; sort?: (a: any, b: any) => number; serializeDate?: (d: Date) => string; diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 2c21363b1a..e1b1f21334 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -473,8 +473,8 @@ declare namespace R { * Applies a function to the value at the given index of an array, returning a new copy of the array with the * element at the given index replaced with the result of the function application. */ - adjust(fn: (a: T) => T, index: number, list: ReadonlyArray): T[]; - adjust(fn: (a: T) => T, index: number): (list: ReadonlyArray) => T[]; + adjust(index: number, fn: (a: T) => T, list: ReadonlyArray): T[]; + adjust(index: number, fn: (a: T) => T): (list: ReadonlyArray) => T[]; /** * Returns true if all elements of the list match the predicate, false if there are any that don't. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 6a03cbc3f0..16ba23d85b 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -299,7 +299,7 @@ class F2 { const capitalize = (str: string) => R.pipe( R.split(""), - R.adjust(R.toUpper, 0), + R.adjust(0, R.toUpper), R.join("") )(str); @@ -2180,7 +2180,7 @@ class Rectangle { this.colors = Array.prototype.slice.call(arguments, 1); } - Circle.prototype.area = () => Math.PI * Math.pow(this.r, 2); + Circle.prototype.area = function() { return Math.PI * Math.pow(this.r, 2); }; const circleN = R.constructN(2, Circle); let c1 = circleN(1, "red"); @@ -2623,7 +2623,7 @@ class Rectangle { const Why: any = ((val: boolean) => { const why = {} as any; why.val = val; - why.and = (x: boolean) => this.val && x; + why.and = function(x: boolean) { return this.val && x; }; return Why; })(true); const why = new Why(true); diff --git a/types/rc-slider/index.d.ts b/types/rc-slider/index.d.ts index ba40bc0d7d..1f16fbe267 100644 --- a/types/rc-slider/index.d.ts +++ b/types/rc-slider/index.d.ts @@ -6,6 +6,7 @@ // Jacob Froman // Deanna Veale // Nick Maddren +// Roman Nevolin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -204,6 +205,11 @@ export interface HandleProps extends CommonApiProps { * Styling option offset */ offset: number; + /** + * Set the tabIndex of the slider handle. + * @default 0 + */ + tabIndex?: number; } export interface WithTooltipProps { diff --git a/types/rc-slider/rc-slider-tests.tsx b/types/rc-slider/rc-slider-tests.tsx index 5b246dd7ab..15aea1ff4c 100644 --- a/types/rc-slider/rc-slider-tests.tsx +++ b/types/rc-slider/rc-slider-tests.tsx @@ -15,6 +15,7 @@ ReactDOM.render( className="bottom" vertical={true} offset={10} + tabIndex={-1} />, document.querySelector('.another-app') ); diff --git a/types/react-avatar-editor/index.d.ts b/types/react-avatar-editor/index.d.ts index 3d4135120c..00603c898e 100644 --- a/types/react-avatar-editor/index.d.ts +++ b/types/react-avatar-editor/index.d.ts @@ -3,26 +3,26 @@ // Definitions by: Diogo Corrêa // Gabriel Prates // Laurent Senta +// David Spiess // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; -export interface ImageState { - height: number; - width: number; +export interface Position { x: number; y: number; - resource: ImageData; } -export interface CroppedRect { - x: number; - y: number; +export interface CroppedRect extends Position { width: number; height: number; } +export interface ImageState extends CroppedRect { + resource: ImageData; +} + export interface AvatarEditorProps { className?: string; image: string | File; @@ -33,7 +33,7 @@ export interface AvatarEditorProps { color?: number[]; style?: object; scale?: number; - position?: object; + position?: Position; rotate?: number; crossOrigin?: string; disableDrop?: boolean; @@ -44,7 +44,7 @@ export interface AvatarEditorProps { onMouseUp?(): void; onMouseMove?(event: Event): void; onImageChange?(): void; - onPositionChange?(): void; + onPositionChange?(position: Position): void; } export default class AvatarEditor extends React.Component { diff --git a/types/react-avatar-editor/react-avatar-editor-tests.tsx b/types/react-avatar-editor/react-avatar-editor-tests.tsx index bee4ff6a56..5942f55a7e 100644 --- a/types/react-avatar-editor/react-avatar-editor-tests.tsx +++ b/types/react-avatar-editor/react-avatar-editor-tests.tsx @@ -1,8 +1,16 @@ import * as React from "react"; -import AvatarEditor, { ImageState, CroppedRect } from "react-avatar-editor"; +import AvatarEditor, { + ImageState, + CroppedRect, + Position +} from "react-avatar-editor"; const file: File = new File(["str"], "image.jpg"); const image: ImageData = new ImageData(1, 2); +const position: Position = { + x: 1, + y: 1 +}; const imageState: ImageState = { height: 1, width: 1, @@ -34,7 +42,7 @@ class AvatarEditorTest extends React.Component { - + @@ -45,7 +53,7 @@ class AvatarEditorTest extends React.Component { {}} /> {}} /> {}} /> - {}} /> + {}} /> { diff --git a/types/react-big-calendar/lib/addons/dragAndDrop.d.ts b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts new file mode 100644 index 0000000000..a1b7d01dad --- /dev/null +++ b/types/react-big-calendar/lib/addons/dragAndDrop.d.ts @@ -0,0 +1,14 @@ +import BigCalendar, { BigCalendarProps, Event, stringOrDate } from '../../index'; +import * as React from 'react'; + +interface withDragAndDropProps { + onEventDrop?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; + onEventResize?: (args: { event: TEvent, start: stringOrDate, end: stringOrDate, allDay: boolean }) => void; + resizable?: boolean; +} + +declare class DragAndDropCalendar + extends React.Component & withDragAndDropProps> {} + +declare function withDragAndDrop(calendar: typeof BigCalendar): typeof DragAndDropCalendar; +export default withDragAndDrop; diff --git a/types/react-big-calendar/react-big-calendar-tests.tsx b/types/react-big-calendar/react-big-calendar-tests.tsx index 4bb6f23943..6b7c252f97 100644 --- a/types/react-big-calendar/react-big-calendar-tests.tsx +++ b/types/react-big-calendar/react-big-calendar-tests.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import BigCalendar, { BigCalendarProps, Navigate, View, DateRange, DateLocalizer, ToolbarProps, EventWrapperProps } from "react-big-calendar"; +import withDragAndDrop from "react-big-calendar/lib/addons/dragAndDrop"; // Don't want to add this as a dependency, because it is only used for tests. declare const globalize: any; @@ -60,6 +61,30 @@ class CalendarResource { ReactDOM.render(, document.body); } +// Drag and Drop Example Test +{ + interface Props { + localizer: DateLocalizer; + } + const DragAndDropCalendar = withDragAndDrop(BigCalendar); + const DnD = ({ localizer }: Props) => ( + + ); + + const localizer = BigCalendar.momentLocalizer(moment); + + ReactDOM.render(, document.body); +} + { class MyCalendar extends BigCalendar {} @@ -203,7 +228,7 @@ function Event(event: any) { class EventWrapper extends React.Component { render() { - const { continuesEarlier, label, accessors = {}, style } = this.props; + const { continuesEarlier, event, label, accessors = {}, style } = this.props; return (

{continuesEarlier}-{label}-{accessors.title && event && accessors.title(event)}}
diff --git a/types/react-big-calendar/tsconfig.json b/types/react-big-calendar/tsconfig.json index eddf55cc13..8722501ef7 100644 --- a/types/react-big-calendar/tsconfig.json +++ b/types/react-big-calendar/tsconfig.json @@ -20,6 +20,7 @@ }, "files": [ "index.d.ts", - "react-big-calendar-tests.tsx" + "react-big-calendar-tests.tsx", + "lib/addons/dragAndDrop.d.ts" ] -} \ No newline at end of file +} diff --git a/types/react-click-outside/index.d.ts b/types/react-click-outside/index.d.ts index c09dccb155..3684c87484 100644 --- a/types/react-click-outside/index.d.ts +++ b/types/react-click-outside/index.d.ts @@ -1,11 +1,12 @@ // Type definitions for react-click-outside 3.0 // Project: https://github.com/kentor/react-click-outside // Definitions by: Christian Rackerseder +// Roman Nuritdinov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; -declare function enhanceWithClickOutside

(wrappedComponent: React.ComponentClass

): React.ComponentClass

; +declare function enhanceWithClickOutside>(wrappedComponent: C): C; declare namespace enhanceWithClickOutside { } export = enhanceWithClickOutside; diff --git a/types/react-click-outside/react-click-outside-tests.tsx b/types/react-click-outside/react-click-outside-tests.tsx index d51516281e..fe8e7af110 100644 --- a/types/react-click-outside/react-click-outside-tests.tsx +++ b/types/react-click-outside/react-click-outside-tests.tsx @@ -22,6 +22,20 @@ class StatefulComponent extends React.Component { } } +@enhanceWithClickOutside +class ComponentWithDecorator extends React.Component { + state = { isOpened: true }; + + handleClickOutside() { + this.setState({ isOpened: false }); + } + + render() { + return

{this.props.text}
; + } +} + const ClickOutsideStatefulComponent = enhanceWithClickOutside(StatefulComponent); render(, document.getElementById('test')); +render(, document.getElementById('test')); diff --git a/types/react-click-outside/tsconfig.json b/types/react-click-outside/tsconfig.json index caf91fdc1d..68d52cdab4 100644 --- a/types/react-click-outside/tsconfig.json +++ b/types/react-click-outside/tsconfig.json @@ -16,10 +16,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "experimentalDecorators": true }, "files": [ "index.d.ts", "react-click-outside-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/react-image-crop/index.d.ts b/types/react-image-crop/index.d.ts index 9cb750dbd2..877966b00e 100644 --- a/types/react-image-crop/index.d.ts +++ b/types/react-image-crop/index.d.ts @@ -51,7 +51,7 @@ declare namespace ReactCrop { function getPixelCrop(image: HTMLImageElement, percentCrop: Crop): Crop; function makeAspectCrop(crop: Crop, imageAspect: number): Crop; - function containCrop(crop: Crop, imageAspect: number): Crop; + function containCrop(previousCrop: Crop, crop: Crop, imageAspect: number): Crop; } declare class ReactCrop extends Component { diff --git a/types/react-instantsearch-core/index.d.ts b/types/react-instantsearch-core/index.d.ts index 5743c07a36..0092feb370 100644 --- a/types/react-instantsearch-core/index.d.ts +++ b/types/react-instantsearch-core/index.d.ts @@ -3,10 +3,13 @@ // Definitions by: Gordon Burgett // Justin Powell // David Furlong +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 import * as React from 'react'; +import { SearchParameters } from 'algoliasearch-helper'; // Core /** @@ -29,7 +32,15 @@ export function createInstantSearch( */ export function createIndex(defaultRoot: object): React.ComponentClass; -export interface ConnectorDescription { +export interface ConnectorSearchResults { + results: AllSearchResults; + searching: boolean; + searchingForFacetValues: boolean; + isSearchStalled: boolean; + error: any; +} + +export interface ConnectorDescription { displayName: string; propTypes?: any; defaultProps?: any; @@ -43,14 +54,26 @@ export interface ConnectorDescription { * meta is the list of metadata from all widgets whose connector defines a getMetadata method. * searchForFacetValuesResults holds the search for facet values results. */ - getProvidedProps?(...args: any[]): any; + getProvidedProps( + this: React.Component, + props: TExposed, + searchState: SearchState, + searchResults: ConnectorSearchResults, + metadata: any, + resultsFacetValues: any, + ): TProvided; /** * This method defines exactly how the refine prop of widgets affects the search state. * It takes in the current props of the higher-order component, the search state of all widgets, as well as all arguments passed * to the refine and createURL props of stateful widgets, and returns a new state. */ - refine?(...args: any[]): any; + refine?( + this: React.Component, + props: TExposed, + searchState: SearchState, + ...args: any[], + ): SearchState; /** * This method applies the current props and state to the provided SearchParameters, and returns a new SearchParameters. The SearchParameters @@ -59,7 +82,12 @@ export interface ConnectorDescription { * to produce a new SearchParameters. Then, if the output SearchParameters differs from the previous one, a new search is triggered. * As such, the getSearchParameters method allows you to describe how the state and props of a widget should affect the search parameters. */ - getSearchParameters?(...args: any[]): any; + getSearchParameters?( + this: React.Component, + searchParameters: SearchParameters, + props: TExposed, + searchState: SearchState, + ): SearchParameters; /** * This method allows the widget to register a custom metadata object for any props and state combination. @@ -70,7 +98,11 @@ export interface ConnectorDescription { * The CurrentRefinements widget leverages this mechanism in order to allow any widget to declare the filters it has applied. If you want to add * your own filter, declare a filters property on your widget’s metadata */ - getMetadata?(...args: any[]): any; + getMetadata?( + this: React.Component, + props: TExposed, + searchState: SearchState, + ...args: any[]): any; /** * This method needs to be implemented if you want to have the ability to perform a search for facet values inside your widget. @@ -78,7 +110,11 @@ export interface ConnectorDescription { * props of stateful widgets, and returns an object of the shape: {facetName: string, query: string, maxFacetHits?: number}. The default value for the * maxFacetHits is the one set by the API which is 10. */ - searchForFacetValues?(...args: any[]): any; + searchForFacetValues?( + this: React.Component, + searchState: SearchState, + nextRefinement?: any, + ): any; /** * This method is called when a widget is about to unmount in order to clean the searchState. @@ -87,9 +123,13 @@ export interface ConnectorDescription { * searchState holds the searchState of all widgets, with the shape {[widgetId]: widgetState}. Stateful widgets describe the format of their searchState * in their respective documentation entry. */ - cleanUp?(...args: any[]): any; + cleanUp?(this: React.Component, props: TExposed, searchState: SearchState): SearchState; } +export type ConnectorProvided = TProvided & + { refine: (...args: any[]) => any, createURL: (...args: any[]) => string } & + { searchForItems: (...args: any[]) => any }; + /** * Connectors are the HOC used to transform React components * into InstantSearch widgets. @@ -100,7 +140,14 @@ export interface ConnectorDescription { * @return a function that wraps a component into * an instantsearch connected one. */ -export function createConnector(connectorDesc: ConnectorDescription): (Composed: React.ComponentType) => React.ComponentClass; +export function createConnector( + connectorDesc: ConnectorDescription, +): ( + (stateless: React.StatelessComponent>) => React.ComponentClass + ) & ( + >>(Composed: React.ComponentType) => + ConnectedComponentClass, TExposed> + ); // Utils export const HIGHLIGHT_TAGS: { @@ -108,7 +155,17 @@ export const HIGHLIGHT_TAGS: { highlightPostTag: string, }; export const version: string; -export function translatable(defaultTranslations: any): (Composed: React.ComponentType) => React.ComponentClass; + +export interface TranslatableProvided { + translate(key: string, ...params: any[]): string; +} +export interface TranslatableExposed { + translations?: { [key: string]: string | ((...args: any[]) => string) }; +} + +export function translatable(defaultTranslations: { [key: string]: string | ((...args: any[]) => string) }): + (ctor: React.ComponentType) => + ConnectedComponentClass; // Widgets /** @@ -125,7 +182,21 @@ export function translatable(defaultTranslations: any): (Composed: React.Compone export class Configure extends React.Component {} // Connectors -export function connectAutoComplete(Composed: React.ComponentType): React.ComponentClass; +export interface AutocompleteProvided { + hits: Array>; + currentRefinement: string; + refine(value?: string): void; +} + +export interface AutocompleteExposed { + defaultRefinement?: string; +} + +// tslint:disable-next-line:no-unnecessary-generics +export function connectAutoComplete(stateless: React.StatelessComponent>): React.ComponentClass; +export function connectAutoComplete, TDoc = BasicDoc>(Composed: React.ComponentType): + ConnectedComponentClass, AutocompleteExposed>; + export function connectBreadcrumb(Composed: React.ComponentType): React.ComponentClass; export function connectConfigure(Composed: React.ComponentType): React.ComponentClass; @@ -208,7 +279,51 @@ export function connectGeoSearch(stateless: React.StatelessComponent>, THit>(ctor: React.ComponentType): ConnectedComponentClass, GeoSearchExposed>; export function connectHierarchicalMenu(Composed: React.ComponentType): React.ComponentClass; -export function connectHighlight(Composed: React.ComponentType): React.ComponentClass; + +export interface HighlightProvided { + /** + * function to retrieve and parse an attribute from a hit. It takes a configuration object with 3 attributes: + * * highlightProperty which is the property that contains the highlight structure from the records, + * * attribute which is the name of the attribute (it can be either a string or an array of strings) to look for, + * * hit which is the hit from Algolia. + * It returns an array of objects {value: string, isHighlighted: boolean}. + * If the element that corresponds to the attribute is an array of strings, it will return a nested array of objects. + * In this case you should cast the result: + * ```ts + * highlight({ + * attribute: 'my_string_array', + * hit, + * highlightProperty: '_highlightResult' + * }) as Array> + * ``` + */ + highlight(configuration: { + attribute: string; + hit: Hit; + highlightProperty: string; + preTag?: string; + postTag?: string; + }): Array<{value: string, isHighlighted: boolean}>; +} + +interface HighlightPassedThru { + hit: Hit; + attribute: string; + highlightProperty?: string; +} + +export type HighlightProps = HighlightProvided & HighlightPassedThru; + +/** + * connectHighlight connector provides the logic to create an highlighter component that will retrieve, parse and render an highlighted attribute from an Algolia hit. + */ +export function connectHighlight(stateless: React.StatelessComponent>): React.ComponentClass>; +export function connectHighlight>, TDoc>(ctor: React.ComponentType): ConnectedComponentClass>; + +interface HitsProvided { + /** the records that matched the search state */ + hits: Array>; +} /** * connectHits connector provides the logic to create connected components that will render the results retrieved from Algolia. @@ -217,7 +332,9 @@ export function connectHighlight(Composed: React.ComponentType): React.Comp * * https://community.algolia.com/react-instantsearch/connectors/connectHits.html */ -export function connectHits(ctor: React.ComponentType): ConnectedComponentClass; +// tslint:disable-next-line:no-unnecessary-generics +export function connectHits(stateless: React.StatelessComponent>): React.ComponentClass; +export function connectHits, THit>(ctor: React.ComponentType): ConnectedComponentClass>; export function connectHitsPerPage(Composed: React.ComponentType): React.ComponentClass; @@ -386,7 +503,7 @@ export interface StateResultsProvided { */ searchResults: SearchResults; /** In case of multiple indices you can retrieve all the results */ - allSearchResults: { [index: string]: SearchResults }; + allSearchResults: AllSearchResults; /** If there is a search in progress. */ searching: boolean; /** Flag that indicates if React InstantSearch has detected that searches are stalled. */ @@ -402,10 +519,20 @@ export interface StateResultsProvided { * * https://community.algolia.com/react-instantsearch/connectors/connectStateResults.html */ -export function connectStateResults(stateless: React.StatelessComponent): React.ComponentClass; -export function connectStateResults(ctor: React.ComponentType): ConnectedComponentClass>; +export function connectStateResults( + stateless: React.StatelessComponent): React.ComponentClass; +export function connectStateResults>>( + ctor: React.ComponentType): ConnectedComponentClass; + +interface StatsProvided { + nbHits: number; + processingTimeMS: number; +} + +export function connectStats(stateless: React.StatelessComponent): React.ComponentClass; +export function connectStats>(ctor: React.ComponentType): + ConnectedComponentClass; -export function connectStats(Composed: React.ComponentType): React.ComponentClass; export function connectToggleRefinement(Composed: React.ComponentType): React.ComponentClass; export interface AlgoliaError { @@ -428,6 +555,8 @@ export type ConnectedComponentClass * https://community.algolia.com/react-instantsearch/guide/Search_state.html */ export interface SearchState { + [widgetId: string]: any; + range?: { [key: string]: { min: number; @@ -487,7 +616,7 @@ export interface SearchResults { nbPages: number; page: number; processingTimeMS: number; - exhaustiveNbHits: true; + exhaustiveNbHits: boolean; disjunctiveFacets: any[]; hierarchicalFacets: any[]; facets: any[]; @@ -495,6 +624,14 @@ export interface SearchResults { automaticRadius?: string; } +/** + * The shape of the searchResults object when used in a multi-index search + * https://community.algolia.com/react-instantsearch/connectors/connectStateResults.html#default-props-entry-connectStateResults-searchResults + */ +export type AllSearchResults = { + [index: string]: SearchResults; +} & SearchResults; + /** * All the records that match the search parameters. * Each record is augmented with a new attribute `_highlightResult` which is an diff --git a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx index e39a9f53e6..76cc26f2a4 100644 --- a/types/react-instantsearch-core/react-instantsearch-core-tests.tsx +++ b/types/react-instantsearch-core/react-instantsearch-core-tests.tsx @@ -11,7 +11,21 @@ import { CurrentRefinementsProvided, connectCurrentRefinements, RefinementListProvided, - Refinement + Refinement, + connectHighlight, + connectHits, + HighlightProvided, + HighlightProps, + AutocompleteProvided, + connectAutoComplete, + Hit, + TranslatableProvided, + translatable, + ConnectorProvided, + StateResultsProvided, + ConnectorSearchResults, + BasicDoc, + AllSearchResults } from 'react-instantsearch-core'; () => { @@ -58,9 +72,12 @@ import { queryAndPage: [newQuery, newPage], }; }, - })(props => + })((props) =>
The query is {props.query}, the page is {props.page}. + This is an error: { + props.somethingElse // $ExpectError + } {/* Clicking on this button will update the searchState to: { @@ -88,18 +105,143 @@ import { }; () => { + interface Provided { + query: string; + page: number; + } + + interface Exposed { + defaultRefinement: string; + startAtPage: number; + } + + const typedCoolConnector = createConnector({ + displayName: 'CoolWidget', + + getProvidedProps(props, searchState) { + // Since the `queryAndPage` searchState entry isn't necessarily defined, we need + // to default its value. + const [query, page] = searchState.queryAndPage || + [props.defaultRefinement, props.startAtPage]; + + // Connect the underlying component to the `queryAndPage` searchState entry. + return { + query, + page, + }; + }, + + refine(props, searchState, newQuery, newPage) { + // When the underlying component calls its `refine` prop, update the searchState + // with the new query and page. + return { + // `searchState` represents the search state of *all* widgets. We need to extend it + // instead of replacing it, otherwise other widgets will lose their + // respective state. + ...searchState, + queryAndPage: [newQuery, newPage], + }; + }, + }); + + const TypedCoolWidgetStateless = typedCoolConnector((props) => +
+ The query is {props.query}, the page is {props.page}. + This is an error: { + props.somethingElse // $ExpectError + } + {/* + Clicking on this button will update the searchState to: + { + ...otherSearchState, + query: 'algolia', + page: 20, + } + */} +
+ ); + + ; + + const TypedCoolWidget = typedCoolConnector( + class extends React.Component & { passThruName: string }> { + render() { + const props = this.props; + return
+ The query is {props.query}, the page is {props.page}. + The name is {props.passThruName} + {/* + Clicking on this button will update the searchState to: + { + ...otherSearchState, + query: 'algolia', + page: 20, + } + */} +
; + } + } + ); + + ; +}; + +() => { + interface MyDoc { + field1: string; + field2: number; + field3: { compound: string }; + } + interface StateResultsProps { - searchResults: SearchResults<{ - field1: string - field2: number - field3: { compound: string } - }>; + searchResults: SearchResults; // partial of StateResultsProvided additionalProp: string; } - const Stateless = ({ additionalProp, searchResults }: StateResultsProps) => + const Stateless = connectStateResults( + ({ + searchResults, + additionalProp, // $ExpectError + }) => (
+

{additionalProp}

+ {searchResults.hits.map((h) => { + return {h._highlightResult.field1!.value}; + })} +
) + ); + + ; + ; // $ExpectError + + const StatelessWithType = ({ additionalProp, searchResults }: StateResultsProps) =>

{additionalProp}

{searchResults.hits.map((h) => { @@ -108,11 +250,11 @@ import { return {compound}; })}
; - const ComposedStateless = connectStateResults(Stateless); + const ComposedStatelessWithType = connectStateResults(StatelessWithType); - ; // $ExpectError + ; // $ExpectError - ; + ; class MyComponent extends React.Component { render() { @@ -219,3 +361,348 @@ import { ; }; + +() => { + interface MyDoc { + a: 1; + b: { + c: '2' + }; + } + + const CustomHighlight = connectHighlight( + ({ highlight, attribute, hit }) => { + const highlights = highlight({ + highlightProperty: '_highlightResult', + attribute, + hit + }); + + return <> + {highlights.map(part => part.isHighlighted ? ( + {part.value} + ) : ( + {part.value} + )) + }; + } + ); + + class CustomHighlight2 extends React.Component { + render() { + const {highlight, attribute, hit, limit} = this.props; + const highlights = highlight({ + highlightProperty: '_highlightResult', + attribute, + hit + }); + + return <> + {highlights.slice(0, limit).map(part => part.isHighlighted ? ( + {part.value} + ) : ( + {part.value} + )) + }; + } + } + const ConnectedCustomHighlight2 = connectHighlight(CustomHighlight2); + + connectHits(({ hits }) => ( +

+ + +

+ )); +}; + +// https://github.com/algolia/react-instantsearch/blob/master/examples/autocomplete/src/App-Mentions.js +() => { + const Mention: any = null; // import Mention from 'antd/lib/mention'; + + const AsyncMention = ({ hits, refine }: AutocompleteProvided) => ( + hit.name)} + onSearchChange={refine} + /> + ); + + const ConnectedAsyncMention = connectAutoComplete(AsyncMention); + + ; +}; + +// https://github.com/algolia/react-instantsearch/blob/master/examples/autocomplete/src/App-Multi-Index.js +import * as Autosuggest from 'react-autosuggest'; +() => { + class Example extends React.Component { + state = { + value: this.props.currentRefinement, + }; + + onChange = (_event: any, { newValue }: { newValue: string }) => { + this.setState({ + value: newValue, + }); + } + + onSuggestionsFetchRequested = ({ value }: { value: string }) => { + this.props.refine(value); + } + + onSuggestionsClearRequested = () => { + this.props.refine(); + } + + getSuggestionValue(hit: Hit) { + return hit.name; + } + + renderSuggestion(hit: Hit) { + const Highlight: any = null; // import {Highlight} from 'react-instantsearch-dom' + return ; + } + + renderSectionTitle(section: any) { + return section.index; + } + + getSectionSuggestions(section: any) { + return section.hits; + } + + render() { + const { hits } = this.props; + const { value } = this.state; + + const inputProps = { + placeholder: 'Search for a product...', + onChange: this.onChange, + value, + }; + + return ( + + ); + } + } + + const AutoComplete = connectAutoComplete(Example); + + ; +}; + +() => { + type Props = SearchBoxProvided & TranslatableProvided & { + className?: string + showLoadingIndicator?: boolean + + submit?: JSX.Element; + reset?: JSX.Element; + loadingIndicator?: JSX.Element; + + onSubmit?: (event: React.SyntheticEvent) => any; + onReset?: (event: React.SyntheticEvent) => any; + onChange?: (event: React.SyntheticEvent) => any; + }; + interface State { + query: string | null; + } + + class SearchBox extends React.Component { + static defaultProps = { + currentRefinement: '', + className: 'ais-SearchBox', + focusShortcuts: ['s', '/'], + autoFocus: false, + searchAsYouType: true, + showLoadingIndicator: false, + isSearchStalled: false, + reset: clear, + submit: search, + }; + + constructor(props: SearchBox['props']) { + super(props); + + this.state = { + query: null, + }; + } + + getQuery = () => this.props.currentRefinement; + + onSubmit = (e: React.SyntheticEvent) => { + e.preventDefault(); + e.stopPropagation(); + + const { refine, onSubmit } = this.props; + + if (onSubmit) { + onSubmit(e); + } + return false; + } + + onChange = (event: React.ChangeEvent) => { + const { onChange } = this.props; + const value = event.target.value; + + this.setState({ query: value }); + + if (onChange) { + onChange(event); + } + } + + onReset = (event: React.FormEvent) => { + const { refine, onReset } = this.props; + + refine(''); + + this.setState({ query: '' }); + + if (onReset) { + onReset(event); + } + } + + render() { + const { + className, + translate, + loadingIndicator, + submit, + reset, + } = this.props; + const query = this.getQuery(); + + const isSearchStalled = + this.props.showLoadingIndicator && this.props.isSearchStalled; + + const isCurrentQuerySubmitted = + query && query === this.props.currentRefinement; + + const button = + isSearchStalled ? 'loading' : + isCurrentQuerySubmitted ? 'reset' : 'submit'; + + return ( +
+
+ + + + +
+
+ ); + } + } + + const TranslatableSearchBox = translatable({ + resetTitle: 'Clear the search query.', + submitTitle: 'Submit your search query.', + placeholder: 'Search here…', + })(SearchBox); + + const ConnectedSearchBox = connectSearchBox(TranslatableSearchBox); + + search} + onSubmit={(evt) => { console.log('submitted', evt); }} + />; +}; + +// can we recreate connectStateResults from source using the createConnector typedef? +() => { + function getIndexId(context: any): string { + return context && context.multiIndexContext + ? context.multiIndexContext.targetedIndex + : context.ais.mainTargetedIndex; + } + + function getResults(searchResults: { results: AllSearchResults }, context: any): SearchResults | null | undefined { + const {results} = searchResults; + if (results && !results.hits) { + return results[getIndexId(context)] + ? results[getIndexId(context)] + : null; + } else { + return results ? results : null; + } + } + + const csr = createConnector({ + displayName: 'AlgoliaStateResults', + + getProvidedProps(props, searchState, searchResults) { + const results = getResults(searchResults, this.context); + + return { + searchState, + searchResults: results, + allSearchResults: searchResults.results, + searching: searchResults.searching, + isSearchStalled: searchResults.isSearchStalled, + error: searchResults.error, + searchingForFacetValues: searchResults.searchingForFacetValues, + props, + }; + }, + }); + + const asConnectStateResults: typeof connectStateResults = csr; +}; diff --git a/types/react-instantsearch-dom/index.d.ts b/types/react-instantsearch-dom/index.d.ts index 6ecb03c981..6f270485b3 100644 --- a/types/react-instantsearch-dom/index.d.ts +++ b/types/react-instantsearch-dom/index.d.ts @@ -2,6 +2,8 @@ // Project: https://community.algolia.com/react-instantsearch/ // Definitions by: Gordon Burgett // Justin Powell +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 diff --git a/types/react-instantsearch-native/index.d.ts b/types/react-instantsearch-native/index.d.ts index 6b328de132..74933ebabf 100644 --- a/types/react-instantsearch-native/index.d.ts +++ b/types/react-instantsearch-native/index.d.ts @@ -2,6 +2,8 @@ // Project: https://community.algolia.com/react-instantsearch // Definitions by: Gordon Burgett // Justin Powell +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 diff --git a/types/react-instantsearch/index.d.ts b/types/react-instantsearch/index.d.ts index 3f80cf4aa3..64a415e6ba 100644 --- a/types/react-instantsearch/index.d.ts +++ b/types/react-instantsearch/index.d.ts @@ -2,6 +2,8 @@ // Project: https://community.algolia.com/react-instantsearch/ // Definitions by: Gordon Burgett // Justin Powell +// Haroen Viaene +// Samuel Vaillant // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 diff --git a/types/react-lazyload/index.d.ts b/types/react-lazyload/index.d.ts index 3fd9b075e4..9d7453188a 100644 --- a/types/react-lazyload/index.d.ts +++ b/types/react-lazyload/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Component } from "react"; +import { Component, ReactNode } from "react"; export interface LazyLoadProps { once?: boolean; @@ -13,10 +13,10 @@ export interface LazyLoadProps { overflow?: boolean; resize?: boolean; scroll?: boolean; - children?: JSX.Element; + children?: ReactNode; throttle?: number | boolean; debounce?: number | boolean; - placeholder?: any; + placeholder?: ReactNode; unmountIfInvisible?: boolean; } diff --git a/types/react-leaflet/index.d.ts b/types/react-leaflet/index.d.ts index c362a1f23c..04fe17a04f 100644 --- a/types/react-leaflet/index.d.ts +++ b/types/react-leaflet/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-leaflet 1.1 +// Type definitions for react-leaflet 2.2 // Project: https://github.com/PaulLeCam/react-leaflet // Definitions by: Dave Leaver , David Schneider , Yui T. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -118,12 +118,20 @@ export type LeafletEvents = MapEvents // These type parameters aren't needed for instantiating a component, but they are useful for // extending react-leaflet classes. -export class MapComponent extends React.Component

{ +export interface MapComponentProps { + leaflet?: LeafletContext; + pane?: string; +} + +export class MapEvented extends React.Component

{ _leafletEvents: LeafletEvents; leafletElement: E; extractLeafletEvents(props: P): LeafletEvents; bindLeafletEvents(next: LeafletEvents, prev: LeafletEvents): LeafletEvents; fireLeafletEvent(type: string, data: any): void; +} + +export class MapComponent

extends MapEvented { getOptions(props: P): P; } @@ -131,221 +139,313 @@ export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateO animate?: boolean; bounds?: Leaflet.LatLngBoundsExpression; boundsOptions?: Leaflet.FitBoundsOptions; - center?: Leaflet.LatLngExpression; - children?: Children; + children: Children; className?: string; id?: string; - maxBounds?: Leaflet.LatLngBoundsExpression; - maxZoom?: number; - minZoom?: number; style?: React.CSSProperties; useFlyTo?: boolean; - zoom?: number; + viewport?: Viewport; + whenReady?: () => void; } -export class Map

extends MapComponent { - className?: string; - container: HTMLDivElement; - getChildContext(): { layerContainer: E, map: E }; +export class Map

extends MapEvented { + className: string | null | undefined; + contextValue: LeafletContext | null | undefined; + container: HTMLDivElement | null | undefined; + viewport: Viewport; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; - bindContainer(container: HTMLDivElement): void; + onViewportChange: (viewport: Viewport | null) => void; + onViewportChanged: (viewport: Viewport | null) => void; + bindContainer(container: HTMLDivElement | null | undefined): void; shouldUpdateCenter(next: Leaflet.LatLngExpression, prev: Leaflet.LatLngExpression): boolean; shouldUpdateBounds(next: Leaflet.LatLngBoundsExpression, prev: Leaflet.LatLngBoundsExpression): boolean; } +export interface DivOverlayProps extends MapComponentProps, Leaflet.DivOverlayOptions { + children: Children; + onClose?: () => void; + onOpen?: () => void; +} + +export interface DivOverlayTypes extends Leaflet.Evented { + isOpen: () => boolean; + update: () => void; +} + +export class DivOverlay

extends MapComponent { + createLeafletElement(_props: P): void; + updateLeafletElement(_prevProps: P, _props: P): void; + onClose: () => void; + onOpen: () => void; + onRender: () => void; +} + export interface PaneProps { - name?: string; children?: Children; - map?: Leaflet.Map; className?: string; + leaflet?: LeafletContext; + name?: string; style?: React.CSSProperties; pane?: string; } export interface PaneState { - name?: string; + name: string | null | undefined; + context: LeafletContext | null | undefined; } export class Pane

extends React.Component { - getChildContext(): { pane: string }; createPane(props: P): void; removePane(): void; setStyle(arg: { style?: string, className?: string }): void; - getParentPane(): HTMLElement | undefined; - getPane(name: string): HTMLElement | undefined; + getParentPane(): HTMLElement | null | undefined; + getPane(name: string | null | undefined): HTMLElement | null | undefined; } -export interface MapLayerProps { +export interface MapLayerProps extends MapComponentProps { + attribution?: string; children?: Children; } + +export type AddLayerHandler = (layer: Leaflet.Layer, name: string, checked?: boolean) => void; + +export type RemoveLayerHandler = (layer: Leaflet.Layer) => void; + export interface LayerContainer { - addLayer(layer: Leaflet.Layer): this; - removeLayer(layer: number | Leaflet.Layer): this; + addLayer: AddLayerHandler; + removeLayer: RemoveLayerHandler; } -export class MapLayer

extends MapComponent { + +export interface LeafletContext { + map?: Leaflet.Map; + pane?: string; + layerContainer?: LayerContainer; + popupContainer?: Leaflet.Layer; +} + +export type LatLng = Leaflet.LatLng | number[] | object; + +export type LatLngBounds = Leaflet.LatLngBounds | LatLng[]; + +export type Point = [number, number] | Leaflet.Point; + +export interface Viewport { + center: [number, number] | null | undefined; + zoom: number | null | undefined; +} + +export class MapLayer

extends MapComponent { + contextValue: LeafletContext | null | undefined; + leafletElement: E; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; readonly layerContainer: LayerContainer | Leaflet.Map; } -export interface GridLayerProps extends Leaflet.GridLayerOptions { - children?: Children; +export interface GridLayerProps extends MapLayerProps, Leaflet.GridLayerOptions { } +export class GridLayer

extends MapLayer { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + getOptions(props: P): P; } -export class GridLayer

extends MapLayer {} -export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOptions { +export interface TileLayerProps extends GridLayerProps, TileLayerEvents, Leaflet.TileLayerOptions { + url: string; +} +export class TileLayer

extends GridLayer { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} + +export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions, GridLayerProps { children?: Children; url: string; } -export class TileLayer

extends GridLayer { } - -export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { - children?: Children; - url: string; +export class WMSTileLayer

extends GridLayer { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + getOptions(params: P): P; } -export class WMSTileLayer

extends GridLayer { } -export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { - bounds: Leaflet.LatLngBoundsExpression; - children?: Children; - url: string; +export interface ImageOverlayProps extends MapLayerProps, Leaflet.ImageOverlayOptions { + bounds?: Leaflet.LatLngBoundsExpression; + url: string | HTMLImageElement; + zIndex?: number; } export class ImageOverlay

extends MapLayer { - getChildContext(): { popupContainer: E }; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; } -export interface LayerGroupProps { - children?: Children; -} -export class LayerGroup

extends MapLayer { - getChildContext(): { layerContainer: E }; +export class LayerGroup

extends MapLayer { + createLeafletElement(props: P): E; } -export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions { - children?: Children; +export interface MarkerProps extends MapLayerProps, MarkerEvents, Leaflet.MarkerOptions { position: Leaflet.LatLngExpression; } export class Marker

extends MapLayer { - getChildContext(): { popupContainer: E }; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; } export interface PathProps extends PathEvents, Leaflet.PathOptions, MapLayerProps { } -export abstract class Path

extends MapLayer { +export abstract class Path

extends MapLayer { getChildContext(): { popupContainer: E }; getPathOptions(props: P): Leaflet.PathOptions; setStyle(options: Leaflet.PathOptions): void; setStyleIfChanged(fromProps: P, toProps: P): void; } -export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions { +export interface CircleProps extends MapLayerProps, PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; - children?: Children; radius: number; } -export class Circle

extends Path { } +export class Circle

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} -export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions { +export interface CircleMarkerProps extends PathProps, PathEvents, Leaflet.CircleMarkerOptions { center: Leaflet.LatLngExpression; - children?: Children; radius: number; } -export class CircleMarker

extends Path { } - -export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions { - children?: Children; -} -export class FeatureGroup

extends Path { - getChildContext(): { layerContainer: E, popupContainer: E }; +export class CircleMarker

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; } -export interface GeoJSONProps extends FeatureGroupEvents, Leaflet.GeoJSONOptions { - children?: Children; +export interface FeatureGroupProps extends MapLayerProps, FeatureGroupEvents, Leaflet.PathOptions { } +export class FeatureGroup

extends LayerGroup { + createLeafletElement(props: P): E; +} + +export interface GeoJSONProps extends PathProps, FeatureGroupEvents, Leaflet.GeoJSONOptions { data: GeoJSON.GeoJsonObject; - style?: Leaflet.StyleFunction; } -export class GeoJSON

extends Path { } +export class GeoJSON

extends FeatureGroup { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} -export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { - children?: Children; +export interface PolylineProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; } -export class Polyline

extends Path { } +export class Polyline

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} -export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions { - children?: Children; - popupContainer?: Leaflet.FeatureGroup; +export interface PolygonProps extends PathProps, PathEvents, Leaflet.PolylineOptions { positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; } -export class Polygon

extends Path { } - -export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { - children?: Children; - bounds: Leaflet.LatLngBoundsExpression; - popupContainer?: Leaflet.FeatureGroup; +export class Polygon

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; } -export class Rectangle

extends Path { } -export interface PopupProps extends Leaflet.PopupOptions { - children?: Children; +export interface RectangleProps extends PathProps, PathEvents, Leaflet.PolylineOptions { + bounds: Leaflet.LatLngBoundsExpression; +} +export class Rectangle

extends Path { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} + +export interface PopupProps extends Leaflet.PopupOptions, DivOverlayProps { position?: Leaflet.LatLngExpression; } -export class Popup

extends MapComponent { +export class Popup

extends DivOverlay { + getOptions(props: P): P; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; onPopupOpen(arg: { popup: E }): void; onPopupClose(arg: { popup: E }): void; - renderPopupContent(): void; - removePopupContent(): void; + onRender: () => void; } -export interface TooltipProps extends Leaflet.TooltipOptions { - children?: Children; -} -export class Tooltip

extends MapComponent { +export interface TooltipProps extends Leaflet.TooltipOptions, DivOverlayProps { } +export class Tooltip

extends DivOverlay { onTooltipOpen(arg: { tooltip: E }): void; onTooltipClose(arg: { tooltip: E }): void; - renderTooltipContent(): void; - removeTooltipContent(): void; } -export type MapControlProps = Leaflet.ControlOptions; +export type MapControlProps = { + leaflet?: LeafletContext +} & Leaflet.ControlOptions; + export class MapControl

extends React.Component

{ leafletElement: E; createLeafletElement(props: P): E; updateLeafletElement(fromProps: P, toProps: P): void; } -export type AttributionControlProps = Leaflet.Control.AttributionOptions; -export class AttributionControl

extends MapControl { } - -export interface LayersControlProps extends LayersControlEvents, Leaflet.Control.LayersOptions { - baseLayers?: Leaflet.Control.LayersObject; - children?: Children; - overlays?: Leaflet.Control.LayersObject; +export type AttributionControlProps = Leaflet.Control.AttributionOptions & MapControlProps; +export class AttributionControl

extends MapControl { + createLeafletElement(props: P): E; +} + +export interface LayersControlProps extends MapControlProps, LayersControlEvents, Leaflet.Control.LayersOptions { + children: Children; + collapsed?: boolean; +} +export class LayersControl

extends MapControl { + controlProps: { + addBaseLayer: AddLayerHandler, + addOverlay: AddLayerHandler, + removeLayer: RemoveLayerHandler, + removeLayerControl: RemoveLayerHandler + }; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + addBaseLayer(layer: Leaflet.Layer, name: string, checked: boolean): void; + addOverlay(layer: Leaflet.Layer, name: string, checked: boolean): void; + removeLayer(layer: Leaflet.Layer): void; + removeLayerControl(layer: Leaflet.Layer): void; } -export class LayersControl

extends MapControl { } export namespace LayersControl { - interface BaseControlledLayerProps { + interface ControlledLayerProps { + addBaseLayer?: AddLayerHandler; + addOverlay?: AddLayerHandler; checked?: boolean; - children?: Children; - removeLayer?(layer: Leaflet.Layer): void; - removeLayerControl?(layer: Leaflet.Layer): void; - } - interface ControlledLayerProps extends BaseControlledLayerProps { - addBaseLayer?(layer: Leaflet.Layer, name: string, checked: boolean): void; - addOverlay?(layer: Leaflet.Layer, name: string, checked: boolean): void; + children: Children; + leaflet?: LeafletContext; name: string; + removeLayer?: RemoveLayerHandler; + removeLayerControl?: RemoveLayerHandler; } - class ControlledLayer

extends React.Component

{ - layer?: Leaflet.Layer; - getChildContext(): { layerContainer: LayerContainer }; - addLayer(): void; + class ControlledLayer

extends React.Component

{ + contextValue: LeafletContext; + layer: Leaflet.Layer | null | undefined; removeLayer(layer: Leaflet.Layer): void; } - class BaseLayer

extends ControlledLayer

{ } - class Overlay

extends ControlledLayer

{ } + class BaseLayer

extends ControlledLayer

{ + constructor(props: ControlledLayerProps); + addLayer: (layer: Leaflet.Layer) => void; + } + class Overlay

extends ControlledLayer

{ + constructor(props: ControlledLayerProps); + addLayer: (layer: Leaflet.Layer) => void; + } } -export type ScaleControlProps = Leaflet.Control.ScaleOptions; -export class ScaleControl

extends MapControl { } +export type ScaleControlProps = Leaflet.Control.ScaleOptions & MapControlProps; +export class ScaleControl

extends MapControl { + createLeafletElement(props: P): E; +} -export type ZoomControlProps = Leaflet.Control.ZoomOptions; -export class ZoomControl

extends MapControl { } +export type ZoomControlProps = Leaflet.Control.ZoomOptions & MapControlProps; +export class ZoomControl

extends MapControl { + createLeafletElement(props: P): E; +} + +// context.js +export const LeafletProvider: React.Provider; +export const LeafletConsumer: React.Consumer; + +export interface ContextProps { + leaflet?: LeafletContext; +} +export type Omit = Pick>; + +export function withLeaflet(WrappedComponent: React.ComponentType): React.ComponentType>; diff --git a/types/react-leaflet/react-leaflet-tests.tsx b/types/react-leaflet/react-leaflet-tests.tsx index fe9825c465..5d1fc2ce7e 100644 --- a/types/react-leaflet/react-leaflet-tests.tsx +++ b/types/react-leaflet/react-leaflet-tests.tsx @@ -16,8 +16,10 @@ import { MapProps, Marker, MarkerProps, + Path, Pane, Polygon, + PolygonProps, Polyline, Popup, PopupProps, @@ -25,7 +27,10 @@ import { TileLayer, Tooltip, WMSTileLayer, - ZoomControl + ZoomControl, + LeafletProvider, + withLeaflet, + Viewport } from 'react-leaflet'; const { BaseLayer, Overlay } = LayersControl; @@ -207,7 +212,7 @@ export class CustomComponent extends Component } } -// SOURCE ??? +// Similar to custom-icons.js export class MarkerWithDivIconExample extends Component { render() { return ( @@ -628,6 +633,43 @@ export class VectorLayersExample extends Component { } } +// viewport.js + +const viewportCenter: [number, number] = [51.505, -0.09]; + +const DEFAULT_VIEWPORT = { + center: viewportCenter, + zoom: 13 +}; + +export class ViewportExample extends Component { + state = { + viewport: DEFAULT_VIEWPORT + }; + + onClickReset = () => { + this.setState({ viewport: DEFAULT_VIEWPORT }); + } + + onViewportChanged = (viewport: Viewport) => { + this.setState({ viewport }); + } + + render() { + return ( + + + + ); + } +} + // wms-tile-layer.js interface WMSTileLayerExampleState { lat: number; @@ -729,6 +771,8 @@ class LegendControl extends MapControl } } +const legendControlComponent = withLeaflet(LegendControl); + const LegendControlExample = () => ( ( ); + +class CustomPolygon extends Path { + createLeafletElement(props: PolygonProps) { + const el = new L.Polygon(props.positions, this.getOptions(props)); + this.contextValue = { ...props.leaflet, popupContainer: el }; + return el; + } + + updateLeafletElement(fromProps: PolygonProps, toProps: PolygonProps) { + if (toProps.positions !== fromProps.positions) { + this.leafletElement.setLatLngs(toProps.positions); + } + this.setStyleIfChanged(fromProps, toProps); + } + + render() { + const { children } = this.props; + return children == null || this.contextValue == null ? null : ( + {children} + ); + } +} +const leafletComponent = withLeaflet(CustomPolygon); diff --git a/types/react-leaflet/v1/index.d.ts b/types/react-leaflet/v1/index.d.ts new file mode 100644 index 0000000000..c362a1f23c --- /dev/null +++ b/types/react-leaflet/v1/index.d.ts @@ -0,0 +1,351 @@ +// Type definitions for react-leaflet 1.1 +// Project: https://github.com/PaulLeCam/react-leaflet +// Definitions by: Dave Leaver , David Schneider , Yui T. +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as Leaflet from 'leaflet'; +import * as React from 'react'; + +// All events need to be lowercase so they don't collide with React.DOMAttributes +// which already declares things with some of the same names + +export type Children = React.ReactNode | React.ReactNode[]; + +export interface MapEvents { + onclick?(event: Leaflet.LeafletMouseEvent): void; + ondblclick?(event: Leaflet.LeafletMouseEvent): void; + onmousedown?(event: Leaflet.LeafletMouseEvent): void; + onmouseup?(event: Leaflet.LeafletMouseEvent): void; + onmouseover?(event: Leaflet.LeafletMouseEvent): void; + onmouseout?(event: Leaflet.LeafletMouseEvent): void; + onmousemove?(event: Leaflet.LeafletMouseEvent): void; + oncontextmenu?(event: Leaflet.LeafletMouseEvent): void; + onfocus?(event: Leaflet.LeafletEvent): void; + onblur?(event: Leaflet.LeafletEvent): void; + onpreclick?(event: Leaflet.LeafletMouseEvent): void; + onload?(event: Leaflet.LeafletEvent): void; + onunload?(event: Leaflet.LeafletEvent): void; + onviewreset?(event: Leaflet.LeafletEvent): void; + onmove?(event: Leaflet.LeafletEvent): void; + onmovestart?(event: Leaflet.LeafletEvent): void; + onmoveend?(event: Leaflet.LeafletEvent): void; + ondragstart?(event: Leaflet.LeafletEvent): void; + ondrag?(event: Leaflet.LeafletEvent): void; + ondragend?(event: Leaflet.DragEndEvent): void; + onzoomstart?(event: Leaflet.LeafletEvent): void; + onzoomend?(event: Leaflet.LeafletEvent): void; + onzoomlevelschange?(event: Leaflet.LeafletEvent): void; + onresize?(event: Leaflet.ResizeEvent): void; + onautopanstart?(event: Leaflet.LeafletEvent): void; + onlayeradd?(event: Leaflet.LayerEvent): void; + onlayerremove?(event: Leaflet.LayerEvent): void; + onbaselayerchange?(event: Leaflet.LayersControlEvent): void; + onoverlayadd?(event: Leaflet.LayersControlEvent): void; + onoverlayremove?(event: Leaflet.LayersControlEvent): void; + onlocationfound?(event: Leaflet.LocationEvent): void; + onlocationerror?(event: Leaflet.ErrorEvent): void; + onpopupopen?(event: Leaflet.PopupEvent): void; + onpopupclose?(event: Leaflet.PopupEvent): void; +} + +export interface MarkerEvents { + onclick?(event: Leaflet.LeafletMouseEvent): void; + ondblclick?(event: Leaflet.LeafletMouseEvent): void; + onmousedown?(event: Leaflet.LeafletMouseEvent): void; + onmouseover?(event: Leaflet.LeafletMouseEvent): void; + onmouseout?(event: Leaflet.LeafletMouseEvent): void; + oncontextmenu?(event: Leaflet.LeafletMouseEvent): void; + ondragstart?(event: Leaflet.LeafletEvent): void; + ondrag?(event: Leaflet.LeafletEvent): void; + ondragend?(event: Leaflet.DragEndEvent): void; + onmove?(event: Leaflet.LeafletEvent): void; + onadd?(event: Leaflet.LeafletEvent): void; + onremove?(event: Leaflet.LeafletEvent): void; + onpopupopen?(event: Leaflet.PopupEvent): void; + onpopupclose?(event: Leaflet.PopupEvent): void; +} + +export interface TileLayerEvents { + onloading?(event: Leaflet.LeafletEvent): void; + onload?(event: Leaflet.LeafletEvent): void; + ontileloadstart?(event: Leaflet.TileEvent): void; + ontileload?(event: Leaflet.TileEvent): void; + ontileunload?(event: Leaflet.TileEvent): void; + ontileerror?(event: Leaflet.TileEvent): void; +} + +export interface PathEvents { + onclick?(event: Leaflet.LeafletMouseEvent): void; + ondblclick?(event: Leaflet.LeafletMouseEvent): void; + onmousedown?(event: Leaflet.LeafletMouseEvent): void; + onmouseover?(event: Leaflet.LeafletMouseEvent): void; + onmouseout?(event: Leaflet.LeafletMouseEvent): void; + oncontextmenu?(event: Leaflet.LeafletMouseEvent): void; + onadd?(event: Leaflet.LeafletEvent): void; + onremove?(event: Leaflet.LeafletEvent): void; + onpopupopen?(event: Leaflet.PopupEvent): void; + onpopupclose?(event: Leaflet.PopupEvent): void; +} + +export interface FeatureGroupEvents { + onclick?(event: Leaflet.LeafletMouseEvent): void; + ondblclick?(event: Leaflet.LeafletMouseEvent): void; + onmouseover?(event: Leaflet.LeafletMouseEvent): void; + onmouseout?(event: Leaflet.LeafletMouseEvent): void; + oncontextmenu?(event: Leaflet.LeafletMouseEvent): void; + onlayeradd?(event: Leaflet.LayerEvent): void; + onlayerremove?(event: Leaflet.LayerEvent): void; +} + +export interface LayersControlEvents { + onbaselayerchange?(event: Leaflet.LayersControlEvent): void; + onoverlayadd?(event: Leaflet.LayersControlEvent): void; + onoverlayremove?(event: Leaflet.LayersControlEvent): void; +} + +export type LeafletEvents = MapEvents + & MarkerEvents + & TileLayerEvents + & PathEvents + & FeatureGroupEvents + & LayersControlEvents; + +// Most react-leaflet components take two type parameters: +// - P : the component's props object +// - E : the corresponding Leaflet element + +// These type parameters aren't needed for instantiating a component, but they are useful for +// extending react-leaflet classes. + +export class MapComponent extends React.Component

{ + _leafletEvents: LeafletEvents; + leafletElement: E; + extractLeafletEvents(props: P): LeafletEvents; + bindLeafletEvents(next: LeafletEvents, prev: LeafletEvents): LeafletEvents; + fireLeafletEvent(type: string, data: any): void; + getOptions(props: P): P; +} + +export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateOptions, Leaflet.FitBoundsOptions { + animate?: boolean; + bounds?: Leaflet.LatLngBoundsExpression; + boundsOptions?: Leaflet.FitBoundsOptions; + center?: Leaflet.LatLngExpression; + children?: Children; + className?: string; + id?: string; + maxBounds?: Leaflet.LatLngBoundsExpression; + maxZoom?: number; + minZoom?: number; + style?: React.CSSProperties; + useFlyTo?: boolean; + zoom?: number; +} + +export class Map

extends MapComponent { + className?: string; + container: HTMLDivElement; + getChildContext(): { layerContainer: E, map: E }; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + bindContainer(container: HTMLDivElement): void; + shouldUpdateCenter(next: Leaflet.LatLngExpression, prev: Leaflet.LatLngExpression): boolean; + shouldUpdateBounds(next: Leaflet.LatLngBoundsExpression, prev: Leaflet.LatLngBoundsExpression): boolean; +} + +export interface PaneProps { + name?: string; + children?: Children; + map?: Leaflet.Map; + className?: string; + style?: React.CSSProperties; + pane?: string; +} +export interface PaneState { + name?: string; +} +export class Pane

extends React.Component { + getChildContext(): { pane: string }; + createPane(props: P): void; + removePane(): void; + setStyle(arg: { style?: string, className?: string }): void; + getParentPane(): HTMLElement | undefined; + getPane(name: string): HTMLElement | undefined; +} + +export interface MapLayerProps { + children?: Children; +} +export interface LayerContainer { + addLayer(layer: Leaflet.Layer): this; + removeLayer(layer: number | Leaflet.Layer): this; +} +export class MapLayer

extends MapComponent { + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; + readonly layerContainer: LayerContainer | Leaflet.Map; +} + +export interface GridLayerProps extends Leaflet.GridLayerOptions { + children?: Children; +} +export class GridLayer

extends MapLayer {} + +export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOptions { + children?: Children; + url: string; +} +export class TileLayer

extends GridLayer { } + +export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions { + children?: Children; + url: string; +} +export class WMSTileLayer

extends GridLayer { } + +export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions { + bounds: Leaflet.LatLngBoundsExpression; + children?: Children; + url: string; +} +export class ImageOverlay

extends MapLayer { + getChildContext(): { popupContainer: E }; +} + +export interface LayerGroupProps { + children?: Children; +} +export class LayerGroup

extends MapLayer { + getChildContext(): { layerContainer: E }; +} + +export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions { + children?: Children; + position: Leaflet.LatLngExpression; +} +export class Marker

extends MapLayer { + getChildContext(): { popupContainer: E }; +} + +export interface PathProps extends PathEvents, Leaflet.PathOptions, MapLayerProps { } +export abstract class Path

extends MapLayer { + getChildContext(): { popupContainer: E }; + getPathOptions(props: P): Leaflet.PathOptions; + setStyle(options: Leaflet.PathOptions): void; + setStyleIfChanged(fromProps: P, toProps: P): void; +} + +export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions { + center: Leaflet.LatLngExpression; + children?: Children; + radius: number; +} +export class Circle

extends Path { } + +export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions { + center: Leaflet.LatLngExpression; + children?: Children; + radius: number; +} +export class CircleMarker

extends Path { } + +export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions { + children?: Children; +} +export class FeatureGroup

extends Path { + getChildContext(): { layerContainer: E, popupContainer: E }; +} + +export interface GeoJSONProps extends FeatureGroupEvents, Leaflet.GeoJSONOptions { + children?: Children; + data: GeoJSON.GeoJsonObject; + style?: Leaflet.StyleFunction; +} +export class GeoJSON

extends Path { } + +export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions { + children?: Children; + positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][]; +} +export class Polyline

extends Path { } + +export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions { + children?: Children; + popupContainer?: Leaflet.FeatureGroup; + positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][]; +} +export class Polygon

extends Path { } + +export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions { + children?: Children; + bounds: Leaflet.LatLngBoundsExpression; + popupContainer?: Leaflet.FeatureGroup; +} +export class Rectangle

extends Path { } + +export interface PopupProps extends Leaflet.PopupOptions { + children?: Children; + position?: Leaflet.LatLngExpression; +} +export class Popup

extends MapComponent { + onPopupOpen(arg: { popup: E }): void; + onPopupClose(arg: { popup: E }): void; + renderPopupContent(): void; + removePopupContent(): void; +} + +export interface TooltipProps extends Leaflet.TooltipOptions { + children?: Children; +} +export class Tooltip

extends MapComponent { + onTooltipOpen(arg: { tooltip: E }): void; + onTooltipClose(arg: { tooltip: E }): void; + renderTooltipContent(): void; + removeTooltipContent(): void; +} + +export type MapControlProps = Leaflet.ControlOptions; +export class MapControl

extends React.Component

{ + leafletElement: E; + createLeafletElement(props: P): E; + updateLeafletElement(fromProps: P, toProps: P): void; +} + +export type AttributionControlProps = Leaflet.Control.AttributionOptions; +export class AttributionControl

extends MapControl { } + +export interface LayersControlProps extends LayersControlEvents, Leaflet.Control.LayersOptions { + baseLayers?: Leaflet.Control.LayersObject; + children?: Children; + overlays?: Leaflet.Control.LayersObject; +} +export class LayersControl

extends MapControl { } + +export namespace LayersControl { + interface BaseControlledLayerProps { + checked?: boolean; + children?: Children; + removeLayer?(layer: Leaflet.Layer): void; + removeLayerControl?(layer: Leaflet.Layer): void; + } + interface ControlledLayerProps extends BaseControlledLayerProps { + addBaseLayer?(layer: Leaflet.Layer, name: string, checked: boolean): void; + addOverlay?(layer: Leaflet.Layer, name: string, checked: boolean): void; + name: string; + } + class ControlledLayer

extends React.Component

{ + layer?: Leaflet.Layer; + getChildContext(): { layerContainer: LayerContainer }; + addLayer(): void; + removeLayer(layer: Leaflet.Layer): void; + } + class BaseLayer

extends ControlledLayer

{ } + class Overlay

extends ControlledLayer

{ } +} + +export type ScaleControlProps = Leaflet.Control.ScaleOptions; +export class ScaleControl

extends MapControl { } + +export type ZoomControlProps = Leaflet.Control.ZoomOptions; +export class ZoomControl

extends MapControl { } diff --git a/types/react-leaflet/v1/react-leaflet-tests.tsx b/types/react-leaflet/v1/react-leaflet-tests.tsx new file mode 100644 index 0000000000..fe9825c465 --- /dev/null +++ b/types/react-leaflet/v1/react-leaflet-tests.tsx @@ -0,0 +1,747 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import * as PropTypes from 'prop-types'; +import * as L from 'leaflet'; +import { Component } from 'react'; +import { + Children, + Circle, + CircleMarker, + FeatureGroup, + LayerGroup, + LayersControl, + Map, + MapControl, + MapControlProps, + MapProps, + Marker, + MarkerProps, + Pane, + Polygon, + Polyline, + Popup, + PopupProps, + Rectangle, + TileLayer, + Tooltip, + WMSTileLayer, + ZoomControl +} from 'react-leaflet'; +const { BaseLayer, Overlay } = LayersControl; + +/// animate.js +interface AnimateExampleState { + animate: boolean; + hasLocation: boolean; + latlng: L.LatLngExpression; +} + +export class AnimateExample extends Component { + state = { + animate: false, + hasLocation: false, + latlng: { + lat: 51.505, + lng: -0.09, + }, + }; + + handleClick = (e: L.LeafletMouseEvent) => { + this.setState({ + latlng: e.latlng, + }); + } + + toggleAnimate = () => { + this.setState({ + animate: !this.state.animate, + }); + } + + render() { + const marker = this.state.hasLocation ? ( + + + You are here + + + ) : null; + + return ( +

+ + + + {marker} + +
+ ); + } +} + +// bounds.js +const outer: L.LatLngBoundsLiteral = [ + [50.505, -29.09], + [52.505, 29.09], +]; +const inner: L.LatLngBoundsLiteral = [ + [49.505, -2.09], + [53.505, 2.09], +]; + +interface BoundsExampleState { + bounds: L.LatLngBoundsLiteral; +} + +export class BoundsExample extends Component { + state = { + bounds: outer, + }; + + onClickInner = () => { + this.setState({ bounds: inner }); + } + + onClickOuter = () => { + this.setState({ bounds: outer }); + } + + render() { + return ( + + + + + + ); + } +} + +// custom-component.js +interface MyPopupMarkerProps { + children: Children; + position: L.LatLngExpression; +} + +interface MyMarker extends MyPopupMarkerProps { + key: string; +} + +const MyPopupMarker = ({ children, position }: MyPopupMarkerProps) => ( + + + {children} + + +); + +interface MyMarkersListProps { + markers: MyMarker[]; +} + +const MyMarkersList = ({ markers }: MyMarkersListProps) => { + const items = markers.map(({ key, ...props }) => ( + + )); + return
{items}
; +}; + +interface CustomComponentState { + lat: number; + lng: number; + zoom: number; +} + +export class CustomComponent extends Component { + state = { + lat: 51.505, + lng: -0.09, + zoom: 13, + }; + + render() { + const center: L.LatLngExpression = [this.state.lat, this.state.lng]; + + const markers: MyMarker[] = [ + { key: 'marker1', position: [51.5, -0.1], children: 'My first popup' }, + { key: 'marker2', position: [51.51, -0.1], children: 'My second popup' }, + { key: 'marker3', position: [51.49, -0.05], children: 'My third popup' }, + ]; + return ( + + + + + ); + } +} + +// SOURCE ??? +export class MarkerWithDivIconExample extends Component { + render() { + return ( + + + + ); + } +} + +// draggable-marker.js +interface DraggableExampleState { + center: L.LatLngLiteral; + marker: L.LatLngLiteral; + zoom: number; + draggable: boolean; +} + +export class DraggableExample extends Component { + state = { + center: { + lat: 51.505, + lng: -0.09, + }, + marker: { + lat: 51.505, + lng: -0.09, + }, + zoom: 13, + draggable: true, + }; + + toggleDraggable = () => { + this.setState({ draggable: !this.state.draggable }); + } + + updatePosition = () => { + const { + lat, + lng, + } = (this.refs.marker as Marker).leafletElement.getLatLng(); + this.setState({ + marker: { lat, lng }, + }); + } + + render() { + const position: L.LatLngExpression = [this.state.center.lat, this.state.center.lng]; + const markerPosition: L.LatLngExpression = [this.state.marker.lat, this.state.marker.lng]; + + return ( + + + + + + {this.state.draggable ? 'DRAG MARKER' : 'MARKER FIXED'} + + + + + ); + } +} + +// events.js +interface EventsExampleState { + hasLocation: boolean; + latlng: L.LatLngLiteral; +} + +export class EventsExample extends Component { + state = { + hasLocation: false, + latlng: { + lat: 51.505, + lng: -0.09, + }, + }; + + handleClick = () => { + (this.refs.map as Map).leafletElement.locate(); + } + + handleLocationFound = (e: L.LocationEvent) => { + this.setState({ + hasLocation: true, + latlng: e.latlng, + }); + } + + render() { + const marker = this.state.hasLocation ? ( + + + You are here + + + ) : null; + + return ( + + + {marker} + + ); + } +} + +// layers-control.js +export class LayersControlExample extends Component { + render() { + const center: L.LatLngExpression = [51.505, -0.09]; + const rectangle: L.LatLngBoundsExpression = [ + [51.49, -0.08], + [51.5, -0.06], + ]; + + return ( + + + + + + + + + + + + A pretty CSS3 popup.
Easily customizable.
+
+
+
+ + + + + + + + + + + + + Popup in FeatureGroup + + + + + +
+
+ ); + } +} + +// other-layers.js +export class OtherLayersExample extends Component { + render() { + const center: L.LatLngExpression = [51.505, -0.09]; + const rectangle: L.LatLngBoundsExpression = [ + [51.49, -0.08], + [51.5, -0.06], + ]; + + return ( + + + + + + + + + + + + Popup in FeatureGroup + + + + + + ); + } +} + +// pane.js +interface PaneExampleState { + render: boolean; +} + +export class PaneExample extends Component { + state = { + render: true, + }; + + componentDidMount() { + setInterval(() => { + this.setState({ + render: !this.state.render, + }); + }, 5000); + } + + render() { + return ( + + + {this.state.render ? ( + + + + ) : null} + + + + + + + + ); + } +} + +// simple.js +interface SimpleExampleState { + lat: number; + lng: number; + zoom: number; +} + +export class SimpleExample extends Component { + state = { + lat: 51.505, + lng: -0.09, + zoom: 13, + }; + + render() { + const position: L.LatLngExpression = [this.state.lat, this.state.lng]; + return ( + + + + + A pretty CSS3 popup.
Easily customizable.
+
+
+
+ ); + } +} + +// tooltip.js +interface TooltipExampleState { + clicked: number; +} + +export class TooltipExample extends Component { + state = { + clicked: 0, + }; + + onClickCircle = () => { + this.setState({ clicked: this.state.clicked + 1 }); + } + + render() { + const center: L.LatLngExpression = [51.505, -0.09]; + + const multiPolygon: L.LatLngExpression[][] = [ + [[51.51, -0.12], [51.51, -0.13], [51.53, -0.13]], + [[51.51, -0.05], [51.51, -0.07], [51.53, -0.07]], + ]; + + const rectangle: L.LatLngBoundsExpression = [ + [51.49, -0.08], + [51.5, -0.06], + ]; + + const clickedText = this.state.clicked === 0 + ? 'Click this Circle to change the Tooltip text' + : `Circle click: ${this.state.clicked}`; + + return ( + + + + + {clickedText} + + + + + Tooltip for CircleMarker + + + + + Popup for Marker + + + Tooltip for Marker + + + + + sticky Tooltip for Polygon + + + + + permanent Tooltip for Rectangle + + + + ); + } +} + +// vector-layers.js +export class VectorLayersExample extends Component { + render() { + const center: L.LatLngExpression = [51.505, -0.09]; + + const polyline: L.LatLngExpression[] = [ + [51.505, -0.09], + [51.51, -0.1], + [51.51, -0.12], + ]; + + const multiPolyline: L.LatLngExpression[][] = [ + [[51.5, -0.1], [51.5, -0.12], [51.52, -0.12]], + [[51.5, -0.05], [51.5, -0.06], [51.52, -0.06]], + ]; + + const polygon: L.LatLngExpression[] = [ + [51.515, -0.09], + [51.52, -0.1], + [51.52, -0.12], + ]; + + const multiPolygon: L.LatLngExpression[][] = [ + [[51.51, -0.12], [51.51, -0.13], [51.53, -0.13]], + [[51.51, -0.05], [51.51, -0.07], [51.53, -0.07]], + ]; + + const rectangle: L.LatLngBoundsExpression = [ + [51.49, -0.08], + [51.5, -0.06], + ]; + + return ( + + + + + + Popup in CircleMarker + + + + + + + + + ); + } +} + +// wms-tile-layer.js +interface WMSTileLayerExampleState { + lat: number; + lng: number; + zoom: number; + bluemarble: boolean; +} + +export class WMSTileLayerExample extends Component { + state = { + lat: 51.505, + lng: -0.09, + zoom: 5, + bluemarble: false, + }; + + onClick = () => { + this.setState({ + bluemarble: !this.state.bluemarble, + }); + } + + render() { + return ( + + + + + ); + } +} + +// zoom-control.js +const ZoomControlExample = () => ( + + + + +); + +// MapControl https://github.com/PaulLeCam/react-leaflet/issues/130 +class CenterControl extends MapControl { // note we're extending MapControl from react-leaflet, not Component from react + componentWillMount() { + const centerControl = new L.Control({ position: 'bottomright' }); // see http://leafletjs.com/reference.html#control-positions for other positions + const jsx = ( + // PUT YOUR JSX FOR THE COMPONENT HERE: +
+ {/* add your JSX */} +
+ ); + + centerControl.onAdd = (map) => { + const div = L.DomUtil.create('div', ''); + ReactDOM.render(jsx, div); + return div; + }; + + this.leafletElement = centerControl; + } +} + +const mapControlCenter: L.LatLngExpression = [51.505, -0.09]; + +const CenterControlExample = () => ( + + + +); + +class LegendControl extends MapControl { + componentWillMount() { + const legend = new L.Control({ position: 'bottomright' }); + const jsx = ( +
+ {this.props.children} +
+ ); + + legend.onAdd = (map) => { + const div = L.DomUtil.create('div', ''); + ReactDOM.render(jsx, div); + return div; + }; + + this.leafletElement = legend; + } +} + +const LegendControlExample = () => ( + + + +
    +
  • Strong Support
  • +
  • Weak Support
  • +
  • Weak Oppose
  • +
  • Strong Oppose
  • +
+
+
+); diff --git a/types/p-queue/v2/tsconfig.json b/types/react-leaflet/v1/tsconfig.json similarity index 64% rename from types/p-queue/v2/tsconfig.json rename to types/react-leaflet/v1/tsconfig.json index 49d979aa06..bb2d85cfe8 100644 --- a/types/p-queue/v2/tsconfig.json +++ b/types/react-leaflet/v1/tsconfig.json @@ -2,25 +2,32 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../../", + "jsx": "react", "typeRoots": [ "../../" ], - "paths": { - "p-queue": [ "p-queue/v2" ] - }, "types": [], + "paths": { + "react-leaflet": [ + "react-leaflet/v1" + ], + "react-leaflet/*": [ + "react-leaflet/v1/*" + ] + }, "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", - "p-queue-tests.ts" + "react-leaflet-tests.tsx" ] -} +} \ No newline at end of file diff --git a/types/del/tslint.json b/types/react-leaflet/v1/tslint.json similarity index 54% rename from types/del/tslint.json rename to types/react-leaflet/v1/tslint.json index 26bcea6634..440efbd687 100644 --- a/types/del/tslint.json +++ b/types/react-leaflet/v1/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false + // TODO + "no-duplicate-imports": false } } diff --git a/types/react-measure/index.d.ts b/types/react-measure/index.d.ts index 9cd5853948..3236dc2a4c 100644 --- a/types/react-measure/index.d.ts +++ b/types/react-measure/index.d.ts @@ -57,7 +57,7 @@ export interface MeasureProps { children?: React.SFC; } -export declare function withContentRect(types: ReadonlyArray | MeasurementType): +export function withContentRect(types: ReadonlyArray | MeasurementType): (fn: MeasuredComponent) => React.ComponentType; declare class Measure extends React.Component {} diff --git a/types/react-native-dialog/index.d.ts b/types/react-native-dialog/index.d.ts index 14d7458140..50866d6d0c 100644 --- a/types/react-native-dialog/index.d.ts +++ b/types/react-native-dialog/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native-dialog 4.0 +// Type definitions for react-native-dialog 5.5 // Project: https://github.com/mmazzarolo/react-native-dialog // Definitions by: MrLuje // Stack Builders @@ -39,6 +39,10 @@ interface ContainerProps { * default: false */ visible?: boolean; + buttonSeparatorStyle?: ViewStyle; + contentStyle?: ViewStyle; + footerStyle?: ViewStyle; + headerStyle?: ViewStyle; } interface TitleProps { diff --git a/types/react-native-fetch-blob/index.d.ts b/types/react-native-fetch-blob/index.d.ts index 910fa4dba9..38b59bee28 100644 --- a/types/react-native-fetch-blob/index.d.ts +++ b/types/react-native-fetch-blob/index.d.ts @@ -33,11 +33,11 @@ export interface Polyfill { Fetch: PolyfillFetch; } -export declare class PolyfillFetch extends RNFetchBlobFetchPolyfill { +export class PolyfillFetch extends RNFetchBlobFetchPolyfill { constructor(config: RNFetchBlobConfig); } -export declare class RNFetchBlobFetchPolyfill { +export class RNFetchBlobFetchPolyfill { constructor(config: RNFetchBlobConfig); build(): (url: string, options: RNFetchBlobConfig) => StatefulPromise; @@ -129,13 +129,13 @@ export interface PolyfillFileReader extends EventTarget { result: number; } -export declare namespace PolyfillFileReader { +export namespace PolyfillFileReader { const EMPTY: number; const LOADING: number; const DONE: number; } -export declare class PolyfillEvent { +export class PolyfillEvent { } export interface PolyfillProgressEvent extends EventTarget { @@ -144,7 +144,7 @@ export interface PolyfillProgressEvent extends EventTarget { total: number; } -export declare class PolyfillBlob extends EventTarget { +export class PolyfillBlob extends EventTarget { /** * RNFetchBlob Blob polyfill, create a Blob directly from file path, BASE64 * encoded data, and string. The conversion is done implicitly according to @@ -194,7 +194,7 @@ export declare class PolyfillBlob extends EventTarget { close(): Promise; } -export declare namespace PolyfillBlob { +export namespace PolyfillBlob { function clearCache(): void; function build(data: any, cType: any): Promise; @@ -202,7 +202,7 @@ export declare namespace PolyfillBlob { function setLog(level: number): void; } -export declare class PolyfillFile extends PolyfillBlob { +export class PolyfillFile extends PolyfillBlob { } export interface PolyfillXMLHttpRequest extends PolyfillXMLHttpRequestEventTarget { @@ -252,7 +252,7 @@ export interface PolyfillXMLHttpRequest extends PolyfillXMLHttpRequestEventTarge responseType: string; } -export declare namespace PolyfillXMLHttpRequest { +export namespace PolyfillXMLHttpRequest { const binaryContentTypes: string[]; const UNSENT: number; const OPENED: number; @@ -490,7 +490,7 @@ export interface StatefulPromise extends Promise { expire(callback: () => void): StatefulPromise; } -export declare class RNFetchBlobSession { +export class RNFetchBlobSession { constructor(name: string, list: string[]); add(path: string): RNFetchBlobSession; @@ -609,10 +609,10 @@ export interface RNFetchBlobStream { onEnd(): void; } -export declare class RNFetchBlobFile { +export class RNFetchBlobFile { } -export declare class RNFetchBlobStat { +export class RNFetchBlobStat { lastModified: string; size: string; type: "directory" | "file"; diff --git a/types/react-native-percentage-circle/index.d.ts b/types/react-native-percentage-circle/index.d.ts new file mode 100644 index 0000000000..a1762ab962 --- /dev/null +++ b/types/react-native-percentage-circle/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for react-native-percentage-circle 1.0 +// Project: https://github.com/JackPu/react-native-percentage-circle +// Definitions by: Haseeb Majid +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import { TextStyle } from 'react-native'; + +export interface PercentageCircleProps { + color?: string; + bgcolor?: string; + innerColor?: string; + radius?: number; + percent?: number; + borderWidth?: number; + textStyle?: TextStyle[]; + disabled?: boolean; +} + +export default class PercentageCircle extends React.Component {} diff --git a/types/react-native-percentage-circle/react-native-percentage-circle-tests.tsx b/types/react-native-percentage-circle/react-native-percentage-circle-tests.tsx new file mode 100644 index 0000000000..7c016122d9 --- /dev/null +++ b/types/react-native-percentage-circle/react-native-percentage-circle-tests.tsx @@ -0,0 +1,20 @@ +import * as React from "react"; +import { View } from "react-native"; +import PercentageCircle from "react-native-percentage-circle"; + +class PercentageCircleTest extends React.Component { + render() { + return ( + + + + ); + } +} diff --git a/types/react-native-percentage-circle/tsconfig.json b/types/react-native-percentage-circle/tsconfig.json new file mode 100644 index 0000000000..77789ef23c --- /dev/null +++ b/types/react-native-percentage-circle/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react-native" + }, + "files": [ + "index.d.ts", + "react-native-percentage-circle-tests.tsx" + ] +} diff --git a/types/wait-for-localhost/tslint.json b/types/react-native-percentage-circle/tslint.json similarity index 100% rename from types/wait-for-localhost/tslint.json rename to types/react-native-percentage-circle/tslint.json diff --git a/types/react-native-snackbar-component/index.d.ts b/types/react-native-snackbar-component/index.d.ts new file mode 100644 index 0000000000..dfa31773e4 --- /dev/null +++ b/types/react-native-snackbar-component/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for react-native-snackbar-components 1.1 +// Project: https://github.com/sidevesh/react-native-snackbar +// Definitions by: Haseeb Majid +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import { TextStyle } from 'react-native'; + +export interface SnackbarComponentProps { + accentColor?: string; + actionText?: string; + messageColor?: string; + backgroundColor?: string; + distanceCallback?: () => void; + actionHandler?: () => void; + left?: number; + right?: number; + bottom?: number; + position?: string; + textMessage?: string; + autoHidingTime?: number; + visible?: boolean; +} + +export default class SnackbarComponent extends React.Component {} diff --git a/types/react-native-snackbar-component/react-native-snackbar-component-tests.tsx b/types/react-native-snackbar-component/react-native-snackbar-component-tests.tsx new file mode 100644 index 0000000000..1795cce93a --- /dev/null +++ b/types/react-native-snackbar-component/react-native-snackbar-component-tests.tsx @@ -0,0 +1,18 @@ +import * as React from "react"; +import { View } from "react-native"; +import SnackbarComponent from "react-native-snackbar-component"; + +class SnackbarComponentTest extends React.Component { + render() { + return ( + + + + ); + } +} diff --git a/types/react-native-snackbar-component/tsconfig.json b/types/react-native-snackbar-component/tsconfig.json new file mode 100644 index 0000000000..7205073e63 --- /dev/null +++ b/types/react-native-snackbar-component/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react-native" + }, + "files": [ + "index.d.ts", + "react-native-snackbar-component-tests.tsx" + ] +} diff --git a/types/react-native-snackbar-component/tslint.json b/types/react-native-snackbar-component/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-snackbar-component/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native-tab-view/index.d.ts b/types/react-native-tab-view/index.d.ts index a6e6b27735..43517fa20b 100644 --- a/types/react-native-tab-view/index.d.ts +++ b/types/react-native-tab-view/index.d.ts @@ -212,6 +212,8 @@ export type TabBarProps = SceneRendererProps< renderBadge?: (scene: Scene) => ReactNode onTabPress?: (scene: Scene) => void onTabLongPress?: (scene: Scene) => void + activeColor?: string + inactiveColor?: string pressColor?: string pressOpacity?: number scrollEnabled?: boolean diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 860d54523e..f2b0b968fb 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -32,6 +32,7 @@ // Deniss Borisovs // Kenneth Skovhus // Aaron Rosen +// Haseeb Majid // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -922,6 +923,7 @@ export interface DrawerItemsProps { inactiveLabelStyle?: StyleProp; iconContainerStyle?: StyleProp; drawerPosition: 'left' | 'right'; + screenProps?: any; } export interface DrawerScene { route: NavigationRoute; diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 5adeb43612..624bc0b680 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -44,6 +44,8 @@ import { Store } from 'redux'; +import { NonReactStatics } from 'hoist-non-react-statics'; + // Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html export type Omit = Pick>; @@ -96,7 +98,10 @@ export type GetProps = C extends ComponentType ? P : never; // Applies LibraryManagedAttributes (proper handling of defaultProps // and propTypes), as well as defines WrappedComponent. -export type ConnectedComponentClass = ComponentClass> & { +export type ConnectedComponentClass< + C extends ComponentType, + P +> = ComponentClass> & NonReactStatics & { WrappedComponent: C; }; diff --git a/types/react-redux/react-redux-tests.tsx b/types/react-redux/react-redux-tests.tsx index ee5b9c1d94..085874a523 100644 --- a/types/react-redux/react-redux-tests.tsx +++ b/types/react-redux/react-redux-tests.tsx @@ -1167,6 +1167,48 @@ function TestLibraryManagedAttributes() { { }} />; } +function TestNonReactStatics() { + interface OwnProps { + bar: number; + } + + interface MapStateProps { + foo: string; + } + + class Component extends React.Component { + static defaultProps = { + bar: 0, + }; + + static meaningOfLife = 42; + + render() { + return
; + } + } + + function mapStateToProps(state: any): MapStateProps { + return { + foo: 'foo', + }; + } + + Component.meaningOfLife; + Component.defaultProps.bar; + + const ConnectedComponent = connect(mapStateToProps)(Component); + + // This is a non-React static and should be hoisted as-is. + ConnectedComponent.meaningOfLife; + + // This is a React static, so it's not hoisted. + // However, ConnectedComponent is still a ComponentClass, which specifies `defaultProps` + // as an optional static member. We can force an error (and assert that `defaultProps` + // wasn't hoisted) by reaching into the `defaultProps` object without a null check. + ConnectedComponent.defaultProps.bar; // $ExpectError +} + function TestProviderContext() { const store: Store = createStore((state = {}) => state); const nullContext = React.createContext(null); diff --git a/types/react-request/index.d.ts b/types/react-request/index.d.ts index 0806dda260..3134825fbe 100644 --- a/types/react-request/index.d.ts +++ b/types/react-request/index.d.ts @@ -15,6 +15,7 @@ export interface RenderProps { response: Response | null; url: string; data: T | null; + doFetch: (options?: FetchRequestProps) => Promise; } export interface FetchRequestProps extends RequestInit { diff --git a/types/react-request/react-request-tests.tsx b/types/react-request/react-request-tests.tsx index 6a4ff71212..5e5edf31d2 100644 --- a/types/react-request/react-request-tests.tsx +++ b/types/react-request/react-request-tests.tsx @@ -8,13 +8,16 @@ interface ServerResponse { export default class BasicReactRequest extends React.Component { render() { return url='/api/server'> - {({ fetching, failed, data, response }) => { + {({ fetching, failed, data, response, doFetch }) => { if (fetching || !response) { return

Loading...

; } if (failed) { return

Failed to load

; } + if (!data) { + doFetch(); + } return

{data ? data.foo : 'data was null'}

; }} ; diff --git a/types/react-resize-detector/index.d.ts b/types/react-resize-detector/index.d.ts index 68f0382dba..25e06d7bb8 100755 --- a/types/react-resize-detector/index.d.ts +++ b/types/react-resize-detector/index.d.ts @@ -29,7 +29,7 @@ interface ReactResizeDetectorProps extends React.Props { declare class ReactResizeDetector extends React.PureComponent { } -export declare function withResizeDetector( +export function withResizeDetector( WrappedComponent: React.ReactNode, props?: ReactResizeDetectorProps ): React.Component; diff --git a/types/react-scroll-into-view-if-needed/index.d.ts b/types/react-scroll-into-view-if-needed/index.d.ts new file mode 100644 index 0000000000..2522833fbd --- /dev/null +++ b/types/react-scroll-into-view-if-needed/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for react-scroll-into-view-if-needed 2.1 +// Project: https://github.com/icd2k3/react-scroll-into-view-if-needed#readme +// Definitions by: Angus Fretwell +// Allan Pope +// Jonathan Ly +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +import * as React from 'react'; +import * as ScrollIntoViewIfNeeded from 'scroll-into-view-if-needed'; + +export interface ReactScrollIntoViewIfNeededProps + extends React.HTMLProps { + options?: ScrollIntoViewIfNeeded.Options; + active?: boolean; + elementType?: keyof JSX.IntrinsicElements; +} + +export default class ReactScrollIntoViewIfNeeded extends React.Component< + ReactScrollIntoViewIfNeededProps +> {} diff --git a/types/react-scroll-into-view-if-needed/package.json b/types/react-scroll-into-view-if-needed/package.json new file mode 100644 index 0000000000..bc0a926e27 --- /dev/null +++ b/types/react-scroll-into-view-if-needed/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "scroll-into-view-if-needed": "*" + } +} diff --git a/types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx b/types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx new file mode 100644 index 0000000000..562615e74c --- /dev/null +++ b/types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx @@ -0,0 +1,52 @@ +import * as React from 'react'; +import ReactScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed'; + +const validOptions = { + block: 'start', + scrollMode: 'if-needed', + skipOverflowHiddenElements: true +}; + +const invalidOptions = { + invalidOption: 'foobar' +}; + +() => ( + + Children + +); + +() => ( + + Children + +); + +() => ( + + Children + +); + +() => ( + + Children + +); diff --git a/types/react-scroll-into-view-if-needed/tsconfig.json b/types/react-scroll-into-view-if-needed/tsconfig.json new file mode 100644 index 0000000000..cfa539dc78 --- /dev/null +++ b/types/react-scroll-into-view-if-needed/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-scroll-into-view-if-needed-tests.tsx"] +} diff --git a/types/react-scroll-into-view-if-needed/tslint.json b/types/react-scroll-into-view-if-needed/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-scroll-into-view-if-needed/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-swipeable-views/index.d.ts b/types/react-swipeable-views/index.d.ts index 68545673e6..24fbaf618d 100644 --- a/types/react-swipeable-views/index.d.ts +++ b/types/react-swipeable-views/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-swipeable-views 0.12 +// Type definitions for react-swipeable-views 0.13 // Project: https://github.com/oliviertassinari/react-swipeable-views // Definitions by: Michael Ledin // Deividas Bakanas @@ -29,6 +29,10 @@ export interface SwipeableViewsProps extends React.HTMLProps { axis?: AxisType; containerStyle?: React.CSSProperties; disabled?: boolean; + /* + * This is the config used to disable lazy loading, if true it will render all the views in first rendering. + */ + disableLazyLoading?: boolean; enableMouseEvents?: boolean; hysteresis?: number; ignoreNativeScroll?: boolean; diff --git a/types/react-swipeable-views/react-swipeable-views-tests.ts b/types/react-swipeable-views/react-swipeable-views-tests.ts index e35be787fb..0bdc2fabfd 100644 --- a/types/react-swipeable-views/react-swipeable-views-tests.ts +++ b/types/react-swipeable-views/react-swipeable-views-tests.ts @@ -44,7 +44,8 @@ React.createElement(SwipeableViews, { title: "Carousel", onTransitionEnd, axis: "x-reverse", - springConfig + springConfig, + disableLazyLoading: false }); React.createElement(SwipeableViews, {}); diff --git a/types/react-tooltip/index.d.ts b/types/react-tooltip/index.d.ts index 9030a2c1f4..aba9cdf734 100644 --- a/types/react-tooltip/index.d.ts +++ b/types/react-tooltip/index.d.ts @@ -79,6 +79,7 @@ declare namespace ReactTooltip { } interface Props { + children?: React.ReactNode; id?: string; place?: Place; type?: Type; diff --git a/types/react-widgets/index.d.ts b/types/react-widgets/index.d.ts index 61eaa78829..ac6b47b90c 100644 --- a/types/react-widgets/index.d.ts +++ b/types/react-widgets/index.d.ts @@ -7,6 +7,7 @@ // Maxime Billemaz // Georg Steinmetz // Troy Zarger +// Siya Mzam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/react-widgets/lib/DropdownList.d.ts b/types/react-widgets/lib/DropdownList.d.ts index f5aa5846e6..04683b6b62 100644 --- a/types/react-widgets/lib/DropdownList.d.ts +++ b/types/react-widgets/lib/DropdownList.d.ts @@ -166,6 +166,11 @@ interface DropdownListProps extends ReactWidgetsCommonDropdownProps> { name="list" multiple={false} /> + // Paul Sherman // Sunil Pai +// Saransh Kataria // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -51,11 +52,15 @@ declare namespace React { // React Elements // ---------------------------------------------------------------------- - type ReactType

= + type ElementType

= { [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never }[keyof JSX.IntrinsicElements] | ComponentType

; + /** + * @deprecated Please use `ElementType` + */ + type ReactType

= ElementType

; type ComponentType

= ComponentClass

| FunctionComponent

; type JSXElementConstructor

= @@ -422,7 +427,7 @@ declare namespace React { // always pass children as variadic arguments to `createElement`. // In the future, if we can define its call signature conditionally // on the existence of `children` in `P`, then we should remove this. - readonly props: Readonly<{ children?: ReactNode }> & Readonly

; + readonly props: Readonly

& Readonly<{ children?: ReactNode }>; state: Readonly; /** * @deprecated @@ -468,7 +473,7 @@ declare namespace React { type FC

= FunctionComponent

; interface FunctionComponent

{ - (props: P & { children?: ReactNode }, context?: any): ReactElement | null; + (props: PropsWithChildren

, context?: any): ReactElement | null; propTypes?: WeakValidationMap

; contextTypes?: ValidationMap; defaultProps?: Partial

; @@ -476,7 +481,7 @@ declare namespace React { } interface RefForwardingComponent { - (props: P & { children?: ReactNode }, ref: Ref): ReactElement | null; + (props: PropsWithChildren

, ref: Ref): ReactElement | null; propTypes?: WeakValidationMap

; contextTypes?: ValidationMap; defaultProps?: Partial

; @@ -722,6 +727,8 @@ declare namespace React { : P : P; + type PropsWithChildren

= P & { children?: ReactNode }; + /** * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded, * or ComponentPropsWithoutRef when refs are not supported. @@ -732,11 +739,11 @@ declare namespace React { : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : {}; - type ComponentPropsWithRef = + type ComponentPropsWithRef = T extends ComponentClass ? PropsWithoutRef

& RefAttributes> : PropsWithRef>; - type ComponentPropsWithoutRef = + type ComponentPropsWithoutRef = PropsWithoutRef>; // will show `Memo(${Component.displayName || Component.name})` in devtools by default, @@ -747,7 +754,7 @@ declare namespace React { function memo

( Component: SFC

, - propsAreEqual?: (prevProps: Readonly

, nextProps: Readonly

) => boolean + propsAreEqual?: (prevProps: Readonly>, nextProps: Readonly>) => boolean ): NamedExoticComponent

; function memo>( Component: T, @@ -1771,6 +1778,7 @@ declare namespace React { rel?: string; target?: string; type?: string; + referrerPolicy?: string; } // tslint:disable-next-line:no-empty-interface diff --git a/types/react/test/index.ts b/types/react/test/index.ts index d4fee49d30..7f8b13a437 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -803,3 +803,9 @@ const sfc: React.SFC = Memoized2; // this $ExpectError is failing on TypeScript@next // // $ExpectError Property '$$typeof' is missing in type // const specialSfc2: React.SpecialSFC = props => null; + +const propsWithChildren: React.PropsWithChildren = { + hello: "world", + foo: 42, + children: functionComponent, +}; diff --git a/types/readable-stream/package.json b/types/readable-stream/package.json new file mode 100644 index 0000000000..6eaa7476e4 --- /dev/null +++ b/types/readable-stream/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "safe-buffer": "*" + } +} diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index 44f97c933b..56ffd20265 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -13,6 +13,7 @@ // Andrew Palugniok // Robert Stigsson // Kosaku Kurino +// Leon Ng // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -219,7 +220,7 @@ export interface BarProps extends EventAttributes, Partial | object; // see label section at http://recharts.org/#/en-US/api/Bar - label?: boolean | Label | React.SFC | React.ReactElement | ContentRenderer; + label?: boolean | Label | LabelProps | React.SFC | React.ReactElement | ContentRenderer; } export class Bar extends React.Component { } diff --git a/types/recharts/recharts-tests.tsx b/types/recharts/recharts-tests.tsx index f8215739ed..8c3b10997b 100644 --- a/types/recharts/recharts-tests.tsx +++ b/types/recharts/recharts-tests.tsx @@ -161,7 +161,7 @@ class Component extends React.Component<{}, ComponentState> { } + label={(props: {name: string}) => } dataKey="value" activeIndex={this.state.activeIndex} activeShape={renderActiveShape} diff --git a/types/recompose/index.d.ts b/types/recompose/index.d.ts index 540e1128dd..c2a0b22d73 100644 --- a/types/recompose/index.d.ts +++ b/types/recompose/index.d.ts @@ -46,7 +46,7 @@ declare module 'recompose' { export interface InferableComponentEnhancerWithProps {

( component: Component

- ): React.ComponentType & TNeedsProps> + ): React.ComponentClass & TNeedsProps> } // Injects props and removes them from the prop requirements. @@ -283,7 +283,7 @@ declare module 'recompose' { // setStatic: https://github.com/acdlite/recompose/blob/master/docs/API.md#setStatic export function setStatic( key: string, value: any - ): (component: T) => T; + ): >(component: T) => T; // setPropTypes: https://github.com/acdlite/recompose/blob/master/docs/API.md#setPropTypes export function setPropTypes

( @@ -293,7 +293,7 @@ declare module 'recompose' { // setDisplayName: https://github.com/acdlite/recompose/blob/master/docs/API.md#setDisplayName export function setDisplayName( displayName: string - ): (component: T) => T; + ): >(component: T) => T; // Utilities: https://github.com/acdlite/recompose/blob/master/docs/API.md#utilities diff --git a/types/reduce-reducers/index.d.ts b/types/reduce-reducers/index.d.ts index 9f787df032..89f98aa2b3 100644 --- a/types/reduce-reducers/index.d.ts +++ b/types/reduce-reducers/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for reduce-reducers 0.2 +// Type definitions for reduce-reducers 0.3 // Project: https://github.com/redux-utilities/reduce-reducers // Definitions by: Huy Nguyen // Dalius Dobravolskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import { Reducer } from 'redux'; export default function reduceReducer(r0: Reducer, s: S | null): Reducer; diff --git a/types/reduce-reducers/package.json b/types/reduce-reducers/package.json index 6d68bf2f9b..7f5b19d45b 100644 --- a/types/reduce-reducers/package.json +++ b/types/reduce-reducers/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "redux": "^3.6.0" + "redux": "^4.0.0" } } diff --git a/types/reduce-reducers/reduce-reducers-tests.ts b/types/reduce-reducers/reduce-reducers-tests.ts index f4fdd8fff3..6d14449814 100644 --- a/types/reduce-reducers/reduce-reducers-tests.ts +++ b/types/reduce-reducers/reduce-reducers-tests.ts @@ -8,8 +8,8 @@ interface TestStore { a: number; b: string; } -const firstReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const secondReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a; +const firstReducer: Reducer = (store, action) => ({a: 0, b: ''}); +const secondReducer: Reducer = (store, action) => ({a: 0, b: ''}); const finalReducer: (state: TestStore, action: Action) => TestStore = reduceReducers(firstReducer, secondReducer); const finalReducerWithState: (state: TestStore, action: Action) => TestStore = reduceReducers(firstReducer, secondReducer, null); @@ -23,14 +23,14 @@ const finalReducerWithInitialState: (state: TestStore, action: Action) => TestSt secondReducer, initialState); -const reducer02: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer03: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer04: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer05: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer06: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer07: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer08: (state: TestStore, action: Action) => TestStore = (a, b) => a; -const reducer09: (state: TestStore, action: Action) => TestStore = (a, b) => a; +const reducer02: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer03: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer04: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer05: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer06: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer07: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer08: Reducer = (store, action) => ({a: 0, b: ''}); +const reducer09: Reducer = (store, action) => ({a: 0, b: ''}); const finalReducerWithInitialState02: (state: TestStore, action: Action) => TestStore = reduceReducers( firstReducer, diff --git a/types/redux-form/index.d.ts b/types/redux-form/index.d.ts index 08d077875a..752dccd876 100644 --- a/types/redux-form/index.d.ts +++ b/types/redux-form/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for redux-form 7.5 +// Type definitions for redux-form 8.1 // Project: https://github.com/erikras/redux-form, https://redux-form.com // Definitions by: Carson Full // Daniel Lytkin @@ -13,6 +13,7 @@ // Kamil Wojcik // Mohamed Shaaban // Ethan Setnik +// Walter Barbagallo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 import { diff --git a/types/redux-form/lib/Field.d.ts b/types/redux-form/lib/Field.d.ts index 194a322408..f0e1c0a6cc 100644 --- a/types/redux-form/lib/Field.d.ts +++ b/types/redux-form/lib/Field.d.ts @@ -44,7 +44,7 @@ export interface BaseFieldProps

extends Partial { parse?: Parser; validate?: Validator | Validator[]; warn?: Validator | Validator[]; - withRef?: boolean; + forwardRef?: boolean; immutableProps?: string[]; } diff --git a/types/redux-form/lib/FieldArray.d.ts b/types/redux-form/lib/FieldArray.d.ts index a4599b5e97..b84d04ad5a 100644 --- a/types/redux-form/lib/FieldArray.d.ts +++ b/types/redux-form/lib/FieldArray.d.ts @@ -6,7 +6,7 @@ export interface BaseFieldArrayProps

{ component: ComponentType

; validate?: Validator | Validator[]; warn?: Validator | Validator[]; - withRef?: boolean; + forwardRef?: boolean; props?: P; rerenderOnEveryChange?: boolean; } diff --git a/types/redux-form/lib/Fields.d.ts b/types/redux-form/lib/Fields.d.ts index f5ec106852..93b7fbcc74 100644 --- a/types/redux-form/lib/Fields.d.ts +++ b/types/redux-form/lib/Fields.d.ts @@ -1,5 +1,10 @@ import { Component, ComponentType } from "react"; -import { Formatter, Parser, WrappedFieldProps } from "../index"; +import { Formatter, Parser, WrappedFieldProps, Validator } from "../index"; + +export type FieldsWarnerOrValidator = + | Validator + | Validator[] + | { [name: string]: Validator | Validator[] }; interface BaseFieldsProps

{ names: string[]; @@ -7,7 +12,9 @@ interface BaseFieldsProps

{ format?: Formatter | null; props?: P; parse?: Parser; - withRef?: boolean; + forwardRef?: boolean; + validate?: FieldsWarnerOrValidator; + warn?: FieldsWarnerOrValidator; } export interface GenericFields

extends Component & P> { diff --git a/types/redux-form/lib/FormName.d.ts b/types/redux-form/lib/FormName.d.ts index 6cfc6f3708..501035fdf4 100644 --- a/types/redux-form/lib/FormName.d.ts +++ b/types/redux-form/lib/FormName.d.ts @@ -1,7 +1,7 @@ import { ReactNode, StatelessComponent } from "react"; export interface FormNameProps { - children: (props: { form: string }) => ReactNode; + children: (props: { form: string, sectionPrefix?: string }) => ReactNode; } export const FormName: StatelessComponent; diff --git a/types/redux-form/lib/actions.d.ts b/types/redux-form/lib/actions.d.ts index 955d3d3f5e..85fec56908 100644 --- a/types/redux-form/lib/actions.d.ts +++ b/types/redux-form/lib/actions.d.ts @@ -36,11 +36,11 @@ export declare function registerField(form: string, name: string, type: FieldTyp export declare function reset(form: string): FormAction; export declare function resetSection(form: string, ...sections: string[]): FormAction; export declare function startAsyncValidation(form: string): FormAction; -export declare function stopAsyncValidation(form: string, errors?: FormErrors): FormAction; +export declare function stopAsyncValidation(form: string, errors?: FormErrors): FormAction; export declare function setSubmitFailed(form: string, ...fields: string[]): FormAction; export declare function setSubmitSucceeded(form: string, ...fields: string[]): FormAction; export declare function startSubmit(form: string): FormAction; -export declare function stopSubmit(form: string, errors?: FormErrors): FormAction; +export declare function stopSubmit(form: string, errors?: FormErrors): FormAction; export declare function submit(form: string): FormAction; export declare function clearSubmit(form: string): FormAction; export declare function clearSubmitErrors(form: string): FormAction; @@ -49,8 +49,8 @@ export declare function clearFields(form: string, keepTouched: boolean, persiste export declare function touch(form: string, ...fields: string[]): FormAction; export declare function unregisterField(form: string, name: string): FormAction; export declare function untouch(form: string, ...fields: string[]): FormAction; -export declare function updateSyncErrors(from: string, syncErrors: FormErrors, error: T): FormAction; -export declare function updateSyncWarnings(form: string, syncWarnings: FormWarnings, warning: T): FormAction; +export declare function updateSyncErrors(from: string, syncErrors: FormErrors, error: T): FormAction; +export declare function updateSyncWarnings(form: string, syncWarnings: FormWarnings, warning: T): FormAction; declare const actions: { arrayInsert: typeof arrayInsert, diff --git a/types/redux-form/redux-form-tests.tsx b/types/redux-form/redux-form-tests.tsx index 8ad71bbc42..2fa2e8efa1 100644 --- a/types/redux-form/redux-form-tests.tsx +++ b/types/redux-form/redux-form-tests.tsx @@ -422,7 +422,11 @@ class FormNameTest extends React.Component { render() { return ( - {({ form }) => Form Name is: {form}} + {({ form, sectionPrefix }) => ( + + Form name is {form} and section prefix is {sectionPrefix} + + )} ); } diff --git a/types/redux-form/tsconfig.json b/types/redux-form/tsconfig.json index ea57d2a38a..a7c3f2ede4 100644 --- a/types/redux-form/tsconfig.json +++ b/types/redux-form/tsconfig.json @@ -29,6 +29,7 @@ "lib/Fields.d.ts", "lib/FieldArray.d.ts", "lib/Form.d.ts", + "lib/FormName.d.ts", "lib/FormSection.d.ts", "lib/formValues.d.ts", "lib/formValueSelector.d.ts", @@ -37,4 +38,4 @@ "lib/selectors.d.ts", "lib/SubmissionError.d.ts" ] -} \ No newline at end of file +} diff --git a/types/redux-form/v7/immutable/index.d.ts b/types/redux-form/v7/immutable/index.d.ts new file mode 100644 index 0000000000..2ce6164232 --- /dev/null +++ b/types/redux-form/v7/immutable/index.d.ts @@ -0,0 +1,30 @@ +export { + Field, + FieldArray, + Fields, + Form, + FormName, + FormSection, + reduxForm, + reducer, + formValueSelector, + getFormAsyncErrors, + getFormInitialValues, + getFormMeta, + getFormNames, + getFormSubmitErrors, + getFormSyncErrors, + getFormSyncWarnings, + getFormValues, + hasSubmitFailed, + hasSubmitSucceeded, + isDirty, + isInvalid, + isPristine, + isSubmitting, + isAsyncValidating, + isValid, + SubmissionError, + startSubmit, + stopSubmit, +} from '../'; diff --git a/types/redux-form/v7/index.d.ts b/types/redux-form/v7/index.d.ts new file mode 100644 index 0000000000..08d077875a --- /dev/null +++ b/types/redux-form/v7/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for redux-form 7.5 +// Project: https://github.com/erikras/redux-form, https://redux-form.com +// Definitions by: Carson Full +// Daniel Lytkin +// Karol Janyst +// Luka Zakrajsek +// Alex Young +// Anton Novik +// Huw Martin +// Ethan Resnick +// Tim de Koning +// Maddi Joyce +// Kamil Wojcik +// Mohamed Shaaban +// Ethan Setnik +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 +import { + ComponentClass, + StatelessComponent, + ReactElement +} from "react"; + +export type FieldType = "Field" | "FieldArray"; + +export interface ErrorOther { + _error?: T; +} + +export type FormErrors = { + [P in keyof FormData]?: ReactElement | T; +} & ErrorOther; + +export interface WarningOther { + _warning?: T; +} + +export type FormWarnings = { + [P in keyof FormData]?: ReactElement | string | WarningOther; +}; + +export interface RegisteredFieldState { + name: string; + type: FieldType; +} + +export type Omit = Pick; + +export * from "./lib/reduxForm"; +export * from "./lib/Field"; +export * from "./lib/Fields"; +export * from "./lib/FieldArray"; +export * from "./lib/Form"; +export * from "./lib/FormName"; +export * from "./lib/FormSection"; +export * from "./lib/formValues"; +export * from "./lib/formValueSelector"; +export * from "./lib/reducer"; +export * from "./lib/SubmissionError"; +export * from "./lib/actions"; +export * from "./lib/actionTypes"; +export * from "./lib/selectors"; diff --git a/types/redux-form/v7/lib/Field.d.ts b/types/redux-form/v7/lib/Field.d.ts new file mode 100644 index 0000000000..194a322408 --- /dev/null +++ b/types/redux-form/v7/lib/Field.d.ts @@ -0,0 +1,103 @@ +import { + Component, + ComponentType, + ReactElement, + ChangeEvent, + DragEvent, + FocusEvent, + InputHTMLAttributes, + SelectHTMLAttributes, + TextareaHTMLAttributes +} from "react"; +import { Dispatch } from "redux"; + +export type Normalizer = (value: any, previousValue?: any, allValues?: any, previousAllValues?: any) => any; +export type Formatter = (value: any, name: string) => any; +export type Parser = (value: any, name: string) => any; +export type Validator = (value: any, allValues?: any, props?: any, name?: any) => any; + +export type EventHandler = (event: Event, name?: string) => void; +export type EventWithDataHandler = (event?: Event, newValue?: any, previousValue?: any, name?: string) => void; + +export interface EventOrValueHandler extends EventHandler { + (value: any): void; +} + +export interface CommonFieldInputProps { + name: string; + onDragStart: EventHandler>; + onDrop: EventHandler>; + onFocus: EventHandler>; +} + +export interface CommonFieldProps extends CommonFieldInputProps { + onBlur: EventWithDataHandler>; + onChange: EventWithDataHandler>; +} + +export interface BaseFieldProps

extends Partial { + name: string; + component?: ComponentType | "input" | "select" | "textarea"; + format?: Formatter | null; + normalize?: Normalizer; + props?: P; + parse?: Parser; + validate?: Validator | Validator[]; + warn?: Validator | Validator[]; + withRef?: boolean; + immutableProps?: string[]; +} + +export interface GenericField

extends Component & P> { + dirty: boolean; + name: string; + pristine: boolean; + value: any; + getRenderedComponent(): Component; +} + +export type GenericFieldHTMLAttributes = + InputHTMLAttributes | + SelectHTMLAttributes | + TextareaHTMLAttributes; + +export class Field

extends Component

{ + dirty: boolean; + name: string; + pristine: boolean; + value: any; + getRenderedComponent(): Component; +} + +export interface WrappedFieldProps { + input: WrappedFieldInputProps; + meta: WrappedFieldMetaProps; +} + +export interface WrappedFieldInputProps extends CommonFieldInputProps { + checked?: boolean; + value: any; + onBlur: EventOrValueHandler>; + onChange: EventOrValueHandler>; +} + +export interface WrappedFieldMetaProps { + active?: boolean; + autofilled: boolean; + asyncValidating: boolean; + dirty: boolean; + dispatch: Dispatch; + error?: any; + form: string; + initial: any; + invalid: boolean; + pristine: boolean; + submitting: boolean; + submitFailed: boolean; + touched: boolean; + valid: boolean; + visited: boolean; + warning?: any; +} + +export default Field; diff --git a/types/redux-form/v7/lib/FieldArray.d.ts b/types/redux-form/v7/lib/FieldArray.d.ts new file mode 100644 index 0000000000..a4599b5e97 --- /dev/null +++ b/types/redux-form/v7/lib/FieldArray.d.ts @@ -0,0 +1,61 @@ +import { Component, ComponentType } from "react"; +import { Validator } from "../index"; + +export interface BaseFieldArrayProps

{ + name: string; + component: ComponentType

; + validate?: Validator | Validator[]; + warn?: Validator | Validator[]; + withRef?: boolean; + props?: P; + rerenderOnEveryChange?: boolean; +} + +export interface GenericFieldArray extends Component & Partial

> { + name: string; + valid: boolean; + getRenderedComponent(): Component & P>; +} + +export class FieldArray

extends Component & Partial

> implements GenericFieldArray { + name: string; + valid: boolean; + getRenderedComponent(): Component & P>; +} + +export interface WrappedFieldArrayProps { + fields: FieldArrayFieldsProps; + meta: FieldArrayMetaProps; +} + +export type FieldIterate = (name: string, index: number, fields: FieldArrayFieldsProps) => R; + +export interface FieldArrayFieldsProps { + forEach(callback: FieldIterate): void; + get(index: number): FieldValue; + getAll(): FieldValue[]; + removeAll(): void; + insert(index: number, value: FieldValue): void; + name: string; + length: number; + map(callback: FieldIterate): R[]; + pop(): FieldValue; + push(value: FieldValue): void; + remove(index: number): void; + shift(): FieldValue; + swap(indexA: number, indexB: number): void; + move(from: number, to: number): void; + unshift(value: FieldValue): void; +} + +export interface FieldArrayMetaProps { + dirty: boolean; + error?: any; + form: string; + invalid: boolean; + pristine: boolean; + submitFailed: boolean; + submitting: boolean; + valid: boolean; + warning?: any; +} diff --git a/types/redux-form/v7/lib/Fields.d.ts b/types/redux-form/v7/lib/Fields.d.ts new file mode 100644 index 0000000000..f5ec106852 --- /dev/null +++ b/types/redux-form/v7/lib/Fields.d.ts @@ -0,0 +1,31 @@ +import { Component, ComponentType } from "react"; +import { Formatter, Parser, WrappedFieldProps } from "../index"; + +interface BaseFieldsProps

{ + names: string[]; + component?: ComponentType; + format?: Formatter | null; + props?: P; + parse?: Parser; + withRef?: boolean; +} + +export interface GenericFields

extends Component & P> { + dirty: boolean; + names: string[]; + pristine: boolean; + values: { [name: string]: any }; + getRenderedComponent(): Component; +} + +export class Fields

extends Component & P> implements GenericFields

{ + dirty: boolean; + names: string[]; + pristine: boolean; + values: { [name: string]: any }; + getRenderedComponent(): Component; +} + +interface WrappedFieldsProps { + [name: string]: WrappedFieldsProps & WrappedFieldProps; +} diff --git a/types/redux-form/v7/lib/Form.d.ts b/types/redux-form/v7/lib/Form.d.ts new file mode 100644 index 0000000000..0eee944be5 --- /dev/null +++ b/types/redux-form/v7/lib/Form.d.ts @@ -0,0 +1,12 @@ +import { Component, FormHTMLAttributes, FormEvent, FormEventHandler } from "react"; +import { FormProps, FormErrors, FormSubmitHandler, Omit } from "../index"; + +interface FormSubmitProp { + onSubmit?: FormSubmitHandler; +} + +export type FormProps = Omit, "onSubmit"> & FormSubmitProp; + +export class GenericForm extends Component> {} + +export class Form extends Component> implements GenericForm {} diff --git a/types/redux-form/v7/lib/FormName.d.ts b/types/redux-form/v7/lib/FormName.d.ts new file mode 100644 index 0000000000..6cfc6f3708 --- /dev/null +++ b/types/redux-form/v7/lib/FormName.d.ts @@ -0,0 +1,9 @@ +import { ReactNode, StatelessComponent } from "react"; + +export interface FormNameProps { + children: (props: { form: string }) => ReactNode; +} + +export const FormName: StatelessComponent; + +export default FormName; diff --git a/types/redux-form/v7/lib/FormSection.d.ts b/types/redux-form/v7/lib/FormSection.d.ts new file mode 100644 index 0000000000..bed9ba765b --- /dev/null +++ b/types/redux-form/v7/lib/FormSection.d.ts @@ -0,0 +1,10 @@ +import { Component, ComponentType } from "react"; + +export interface FormSectionProps

{ + name: string; + component?: ComponentType

; +} + +export declare class FormSection

extends Component & P> {} + +export default FormSection; diff --git a/types/redux-form/v7/lib/SubmissionError.d.ts b/types/redux-form/v7/lib/SubmissionError.d.ts new file mode 100644 index 0000000000..50695f34d0 --- /dev/null +++ b/types/redux-form/v7/lib/SubmissionError.d.ts @@ -0,0 +1,7 @@ +import { FormErrors } from "../index"; + +export declare class SubmissionError extends Error { + constructor(errors?: FormErrors); +} + +export default SubmissionError; diff --git a/types/redux-form/v7/lib/actionTypes.d.ts b/types/redux-form/v7/lib/actionTypes.d.ts new file mode 100644 index 0000000000..7718ba74ab --- /dev/null +++ b/types/redux-form/v7/lib/actionTypes.d.ts @@ -0,0 +1,39 @@ +export interface ActionTypes { + ARRAY_INSERT: string; + ARRAY_MOVE: string; + ARRAY_POP: string; + ARRAY_PUSH: string; + ARRAY_REMOVE: string; + ARRAY_REMOVE_ALL: string; + ARRAY_SHIFT: string; + ARRAY_SPLICE: string; + ARRAY_UNSHIFT: string; + ARRAY_SWAP: string; + AUTOFILL: string; + BLUR: string; + CHANGE: string; + CLEAR_SUBMIT: string; + CLEAR_SUBMIT_ERRORS: string; + CLEAR_ASYNC_ERROR: string; + CLEAR_FIELDS: string; + DESTROY: string; + FOCUS: string; + INITIALIZE: string; + REGISTER_FIELD: string; + RESET: string; + RESET_SECTION: string; + SET_SUBMIT_FAILED: string; + SET_SUBMIT_SUCCEEDED: string; + START_ASYNC_VALIDATION: string; + START_SUBMIT: string; + STOP_ASYNC_VALIDATION: string; + STOP_SUBMIT: string; + SUBMIT: string; + TOUCH: string; + UNREGISTER_FIELD: string; + UNTOUCH: string; + UPDATE_SYNC_ERRORS: string; + UPDATE_SYNC_WARNINGS: string; +} + +export const actionTypes: ActionTypes; diff --git a/types/redux-form/v7/lib/actions.d.ts b/types/redux-form/v7/lib/actions.d.ts new file mode 100644 index 0000000000..955d3d3f5e --- /dev/null +++ b/types/redux-form/v7/lib/actions.d.ts @@ -0,0 +1,92 @@ +import { Action } from "redux"; +import { FormErrors, FormWarnings, FieldType } from "../index"; + +export interface FormAction extends Action { + meta?: any; + payload?: any; + error?: any; +} + +export declare function arrayInsert(form: string, field: string, index: number, value: any): FormAction; +export declare function arrayMove(form: string, field: string, from: number, to: number): FormAction; +export declare function arrayPop(form: string, field: string): FormAction; +export declare function arrayPush(form: string, field: string, value: any): FormAction; +export declare function arrayRemove(form: string, field: string, index: number): FormAction; +export declare function arrayRemoveAll(form: string, field: string): FormAction; +export declare function arrayShift(form: string, field: string): FormAction; +export declare function arraySplice(form: string, field: string, index: number, removeNum: number, value: any): FormAction; +export declare function arraySwap(form: string, field: string, indexA: number, indexB: number): FormAction; +export declare function arrayUnshift(form: string, field: string, value: any): FormAction; +export declare function autofill(form: string, field: string, value: any): FormAction; +export declare function blur(form: string, field: string, value: any, touch?: boolean): FormAction; +export declare function change(form: string, field: string, value: any, touch?: boolean, persistentSubmitErrors?: boolean): FormAction; +export declare function destroy(...form: string[]): FormAction; +export declare function focus(form: string, field: string): FormAction; + +export interface InitializeOptions { + keepDirty: boolean; + keepSubmitSucceeded: boolean; + updateUnregisteredFields: boolean; + keepValues: boolean; +} + +export declare function initialize(form: string, data: any, keepDirty?: boolean, options?: Partial): FormAction; +export declare function initialize(form: string, data: any, options?: Partial): FormAction; +export declare function registerField(form: string, name: string, type: FieldType): FormAction; +export declare function reset(form: string): FormAction; +export declare function resetSection(form: string, ...sections: string[]): FormAction; +export declare function startAsyncValidation(form: string): FormAction; +export declare function stopAsyncValidation(form: string, errors?: FormErrors): FormAction; +export declare function setSubmitFailed(form: string, ...fields: string[]): FormAction; +export declare function setSubmitSucceeded(form: string, ...fields: string[]): FormAction; +export declare function startSubmit(form: string): FormAction; +export declare function stopSubmit(form: string, errors?: FormErrors): FormAction; +export declare function submit(form: string): FormAction; +export declare function clearSubmit(form: string): FormAction; +export declare function clearSubmitErrors(form: string): FormAction; +export declare function clearAsyncError(form: string, field: string): FormAction; +export declare function clearFields(form: string, keepTouched: boolean, persistentSubmitErrors: boolean, ...fields: string[]): FormAction; +export declare function touch(form: string, ...fields: string[]): FormAction; +export declare function unregisterField(form: string, name: string): FormAction; +export declare function untouch(form: string, ...fields: string[]): FormAction; +export declare function updateSyncErrors(from: string, syncErrors: FormErrors, error: T): FormAction; +export declare function updateSyncWarnings(form: string, syncWarnings: FormWarnings, warning: T): FormAction; + +declare const actions: { + arrayInsert: typeof arrayInsert, + arrayMove: typeof arrayMove, + arrayPop: typeof arrayPop, + arrayPush: typeof arrayPush, + arrayRemove: typeof arrayRemove, + arrayRemoveAll: typeof arrayRemoveAll, + arrayShift: typeof arrayShift, + arraySplice: typeof arraySplice, + arraySwap: typeof arraySwap, + arrayUnshift: typeof arrayUnshift, + autofill: typeof autofill, + blur: typeof blur, + change: typeof change, + clearSubmit: typeof clearSubmit, + clearSubmitErrors: typeof clearSubmitErrors, + clearAsyncError: typeof clearAsyncError, + clearFields: typeof clearFields, + destroy: typeof destroy, + focus: typeof focus, + initialize: typeof initialize, + registerField: typeof registerField, + reset: typeof reset, + startAsyncValidation: typeof startAsyncValidation, + startSubmit: typeof startSubmit, + stopAsyncValidation: typeof stopAsyncValidation, + stopSubmit: typeof stopSubmit, + submit: typeof submit, + setSubmitFailed: typeof setSubmitFailed, + setSubmitSucceeded: typeof setSubmitSucceeded, + touch: typeof touch, + unregisterField: typeof unregisterField, + untouch: typeof untouch, + updateSyncErrors: typeof updateSyncErrors, + updateSyncWarnings: typeof updateSyncWarnings +}; + +export default actions; diff --git a/types/redux-form/v7/lib/formValueSelector.d.ts b/types/redux-form/v7/lib/formValueSelector.d.ts new file mode 100644 index 0000000000..e13ffd3c5d --- /dev/null +++ b/types/redux-form/v7/lib/formValueSelector.d.ts @@ -0,0 +1,8 @@ +import { FormStateMap } from "../index"; + +export function formValueSelector( + form: string, + getFormState?: (state: State) => FormStateMap +): (state: State, ...field: string[]) => any; + +export default formValueSelector; diff --git a/types/redux-form/v7/lib/formValues.d.ts b/types/redux-form/v7/lib/formValues.d.ts new file mode 100644 index 0000000000..1052f8533e --- /dev/null +++ b/types/redux-form/v7/lib/formValues.d.ts @@ -0,0 +1,13 @@ +import { ComponentClass, ComponentType } from "react"; +import { InjectedFormProps } from "../index"; + +export function formValues< + Values, + P = {} +>(obj: Values): (component: ComponentType

) => ComponentClass

; + +export function formValues< + FormData = {}, + K extends keyof FormData = keyof FormData, + P = {} +>(...names: K[]): (component: ComponentType

>) => ComponentClass

>; diff --git a/types/redux-form/v7/lib/reducer.d.ts b/types/redux-form/v7/lib/reducer.d.ts new file mode 100644 index 0000000000..f2ee374cf2 --- /dev/null +++ b/types/redux-form/v7/lib/reducer.d.ts @@ -0,0 +1,42 @@ +import { Reducer } from "redux"; +import { FieldType } from "../index"; + +export interface FormReducer extends Reducer { + plugin(reducers: FormReducerMapObject): Reducer; +} + +export const reducer: FormReducer; + +export interface FormReducerMapObject { + // and `` to make it compatible with redux@3 + // tslint:disable-next-line use-default-type-parameter + [formName: string]: Reducer; +} + +export interface FormStateMap { + [formName: string]: FormState; +} + +export interface FormState { + registeredFields: RegisteredFieldState[]; + fields?: {[name: string]: FieldState}; + values?: { [fieldName: string]: any }; + active?: string; + anyTouched?: boolean; + submitting?: boolean; + submitErrors?: { [fieldName: string]: string }; + submitFailed?: boolean; +} + +export interface RegisteredFieldState { + name: string; + type: FieldType; +} + +export interface FieldState { + active?: boolean; + touched?: boolean; + visited?: boolean; +} + +export default reducer; diff --git a/types/redux-form/v7/lib/reduxForm.d.ts b/types/redux-form/v7/lib/reduxForm.d.ts new file mode 100644 index 0000000000..e37214f5d0 --- /dev/null +++ b/types/redux-form/v7/lib/reduxForm.d.ts @@ -0,0 +1,164 @@ +import { + Component, + ComponentClass, + ComponentType, + ReactElement, + SyntheticEvent, + StatelessComponent, + FormEventHandler +} from "react"; +import { Dispatch } from "redux"; +import { + FormErrors, + ErrorOther, + FormWarnings, + WarningOther, + RegisteredFieldState, + FormStateMap +} from "../index"; + +export type FormSubmitHandler = + (values: FormData, dispatch: Dispatch, props: P) => void | FormErrors | Promise; + +export type GetFormState = (state: any) => FormStateMap; +export interface SubmitHandler { + ( + submit: FormSubmitHandler, + props?: InjectedFormProps, + valid?: boolean, + asyncValidate?: any, + fields?: string[] + ): any; + (event: SyntheticEvent): void; +} + +export interface ValidateCallback { + values: FormData; + nextProps: P & InjectedFormProps; + props: P & InjectedFormProps; + initialRender: boolean; + structure: any; +} + +export interface AsyncValidateCallback { + asyncErrors?: FormErrors; + initialized: boolean; + trigger: "blur" | "submit"; + blurredField?: string; + pristine: boolean; + syncValidationPasses: boolean; +} + +export interface InjectedArrayProps { + insert(field: string, index: number, value: any): void; + move(field: string, from: number, to: number): void; + pop(field: string): void; + push(field: string, value: any): void; + remove(field: string, index: number): void; + removeAll(field: string): void; + shift(field: string): void; + splice(field: string, index: number, removeNum: number, value: any): void; + swap(field: string, indexA: number, indexB: number): void; + unshift(field: string, value: any): void; +} + +export interface RegisteredField { + count: number; + name: string; + type: "Field" | "FieldArray"; +} + +export interface InjectedFormProps { + anyTouched: boolean; + array: InjectedArrayProps; + asyncValidate(): void; + asyncValidating: string | boolean; + autofill(field: string, value: any): void; + blur(field: string, value: any): void; + change(field: string, value: any): void; + clearAsyncError(field: string): void; + destroy(): void; + dirty: boolean; + error: ErrorType; + form: string; + handleSubmit: SubmitHandler; + initialize(data: Partial): void; + initialized: boolean; + initialValues: Partial; + invalid: boolean; + pristine: boolean; + reset(): void; + submitFailed: boolean; + submitSucceeded: boolean; + submitting: boolean; + touch(...field: string[]): void; + untouch(...field: string[]): void; + valid: boolean; + warning: any; + registeredFields: { [name: string]: RegisteredField }; +} + +export interface ConfigProps { + form: string; + asyncBlurFields?: string[]; + asyncChangeFields?: string[]; + asyncValidate?(values: FormData, dispatch: Dispatch, props: P & InjectedFormProps, blurredField: string): Promise; + destroyOnUnmount?: boolean; + enableReinitialize?: boolean; + forceUnregisterOnUnmount?: boolean; + getFormState?: GetFormState; + immutableProps?: string[]; + initialValues?: Partial; + keepDirtyOnReinitialize?: boolean; + updateUnregisteredFields?: boolean; + onChange?(values: Partial, dispatch: Dispatch, props: P & InjectedFormProps, previousValues: Partial): void; + onSubmit?: FormSubmitHandler, ErrorType> | SubmitHandler, ErrorType>; + onSubmitFail?( + errors: FormErrors | undefined, + dispatch: Dispatch, + submitError: any, + props: P & InjectedFormProps + ): void; + onSubmitSuccess?(result: any, dispatch: Dispatch, props: P & InjectedFormProps): void; + propNamespace?: string; + pure?: boolean; + shouldValidate?(params: ValidateCallback): boolean; + shouldError?(params: ValidateCallback): boolean; + shouldWarn?(params: ValidateCallback): boolean; + shouldAsyncValidate?(params: AsyncValidateCallback): boolean; + touchOnBlur?: boolean; + touchOnChange?: boolean; + persistentSubmitErrors?: boolean; + validate?(values: FormData, props: P & InjectedFormProps): FormErrors; + warn?(values: FormData, props: P & InjectedFormProps): FormWarnings; +} + +export interface FormInstance extends Component

{ + dirty: boolean; + invalid: boolean; + pristine: boolean; + registeredFields: RegisteredFieldState[]; + reset(): void; + resetSection(...sections: string[]): void; + submit(): Promise; + valid: boolean; + values: Partial; + wrappedInstance: ReactElement

>; +} + +export interface DecoratedComponentClass { + new(props?: P, context?: any): FormInstance; +} + +export type FormDecorator = + (component: ComponentType

>) => DecoratedComponentClass; + +export declare function reduxForm( + config: ConfigProps +): FormDecorator>, ErrorType>; + +export declare function reduxForm( + config: Partial> +): FormDecorator, ErrorType>; + +export default reduxForm; diff --git a/types/redux-form/v7/lib/selectors.d.ts b/types/redux-form/v7/lib/selectors.d.ts new file mode 100644 index 0000000000..c97d99859b --- /dev/null +++ b/types/redux-form/v7/lib/selectors.d.ts @@ -0,0 +1,25 @@ +import { FormErrors, GetFormState } from "../index"; + +export type DataSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormData; +export type ErrorSelector = (formName: string, getFormState?: GetFormState) => (state: State) => FormErrors; +export type BooleanSelector = (formName: string, getFormState?: GetFormState) => (state: State) => boolean; +export type NamesSelector = (getFormState?: GetFormState) => (state: State) => string[]; +export type FormOrFieldsBooleanSelector = (formName: string, getFormState?: GetFormState) => (state: State, ...fields: string[]) => boolean; + +export const getFormValues: DataSelector; +export const getFormInitialValues: DataSelector; +export const getFormSyncErrors: ErrorSelector; +export const getFormMeta: DataSelector; +export const getFormAsyncErrors: ErrorSelector; +export const getFormSyncWarnings: ErrorSelector; +export const getFormSubmitErrors: ErrorSelector; +export const getFormError: ErrorSelector; +export const getFormNames: NamesSelector; +export const isDirty: FormOrFieldsBooleanSelector; +export const isPristine: FormOrFieldsBooleanSelector; +export const isValid: BooleanSelector; +export const isInvalid: BooleanSelector; +export const isSubmitting: BooleanSelector; +export const isAsyncValidating: BooleanSelector; +export const hasSubmitSucceeded: BooleanSelector; +export const hasSubmitFailed: BooleanSelector; diff --git a/types/redux-form/v7/package.json b/types/redux-form/v7/package.json new file mode 100644 index 0000000000..998f8e9b38 --- /dev/null +++ b/types/redux-form/v7/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "redux": "^3.6.0 || ^4.0.0" + } +} diff --git a/types/redux-form/v7/redux-form-tests.tsx b/types/redux-form/v7/redux-form-tests.tsx new file mode 100644 index 0000000000..8ad71bbc42 --- /dev/null +++ b/types/redux-form/v7/redux-form-tests.tsx @@ -0,0 +1,464 @@ +import * as React from 'react'; +import { Action, Dispatch } from "redux"; +import { + reduxForm, + InjectedFormProps, + Form, + FormName, + GenericForm, + FormSection, + formValues, + formValueSelector, + Field, + GenericField, + WrappedFieldProps, + Fields, + GenericFields, + WrappedFieldsProps, + FieldArray, + GenericFieldArray, + WrappedFieldArrayProps, + BaseFieldProps, + reducer, + FormAction, + actionTypes, + submit, + SubmissionError, + FieldArrayFieldsProps +} from "redux-form"; + +import { + Field as ImmutableField, + reduxForm as immutableReduxForm, + startSubmit as immutableStartSubmit, + stopSubmit as immutableStopSubmit +} from "redux-form/immutable"; + +import LibField, { + WrappedFieldProps as LibWrappedFieldProps +} from "redux-form/lib/Field"; +import libReducer from "redux-form/lib/reducer"; +import LibFormSection from "redux-form/lib/FormSection"; +import libFormValueSelector from "redux-form/lib/formValueSelector"; +import libReduxForm from "redux-form/lib/reduxForm"; +import libActions from "redux-form/lib/actions"; +import LibSubmissionError from "redux-form/lib/SubmissionError"; + +/* Decorated components */ +interface TestFormData { + foo: string; +} + +/* Some tests only make sense with multiple values */ +interface MultivalueFormData { + foo: string; + bar?: string; + fizz: string; +} + +interface TestFormComponentProps { + baz: string; +} + +type InjectedProps = InjectedFormProps; + +class TestFormComponent extends React.Component { + render() { + const { form, initialValues, error } = this.props; + const foo = initialValues.foo; + const errorIsString = error + 'test'; + return null; + } +} + +const TestFormRequired = reduxForm({})(TestFormComponent); +const TestForm = reduxForm({ form : "test" })(TestFormComponent); +const TestFormImmRequired = immutableReduxForm({})(TestFormComponent); +const TestFormImm = immutableReduxForm({ form : "test" })(TestFormComponent); + +const TestFormStatelessComponent: React.StatelessComponent = ({ form, initialValues }) => { + const foo = initialValues.foo; + return null; +}; + +const TestFormStatelessRequired = reduxForm({})(TestFormStatelessComponent); +const TestFormStateless = reduxForm({ form : "test" })(TestFormStatelessComponent); + +/* formValues decorator */ + +const ItemList = formValues("foo")( + ({ foo }) => { + return null; + } +); + +const ItemListObj = formValues({ fooBar : "foo" })( + ({ fooBar }) => { + return null; + } +); + +/* Custom FormSection */ + +interface MyFormSectionProps { + foo: string; +} + +const MyFormSection: React.StatelessComponent = ({ children, foo }) => null; + +/* Custom Field */ + +interface MyFieldCustomProps { + foo: string; +} +type MyFieldProps = MyFieldCustomProps & WrappedFieldProps; +const MyField: React.StatelessComponent = ({ + children, + input, + meta, + foo +}) => { + input.onBlur("value"); + input.onBlur({} as React.SyntheticEvent); + + input.onChange("value"); + input.onChange({} as React.SyntheticEvent); + + input.onDragStart({} as React.DragEvent); + + input.onDrop({} as React.DragEvent); + + input.onFocus({} as React.FocusEvent); + return null; +}; +const FieldCustom = Field as new () => GenericField; + +type FieldProps = BaseFieldProps & MyFieldCustomProps; +const FieldCustomComp: React.StatelessComponent = props => ( + +); + +const MyFieldImm: React.StatelessComponent = ({ + children, + input, + meta, + foo +}) => null; +const FieldImmutableCustom = ImmutableField as new () => GenericField; + +/* Custom Fields */ + +interface MyFieldsCustomProps { + foo: string; +} +type MyFieldsProps = MyFieldsCustomProps & WrappedFieldsProps; +const MyFields: React.StatelessComponent = ({ + children, + foo +}) => null; +const FieldsCustom = Fields as new () => GenericFields; + +/* FieldArray */ + +const MyArrayField: React.StatelessComponent = ({ + children +}) => null; + +/* Custom FieldArray */ + +interface MyFieldValue { + num: number; +} +interface MyFieldArrayCustomProps { + foo: string; +} + +const MyCustomArrayField: React.StatelessComponent = ({ + children, + foo +}) => null; + +type MyFieldArrayProps = MyFieldArrayCustomProps & WrappedFieldArrayProps; +const MyFieldArray: React.StatelessComponent = ({ + children, + fields +}) => null; +const FieldArrayCustom = FieldArray as new () => GenericFieldArray; + +/* Tests */ +const TestForms: React.StatelessComponent = () => { + return ( +

+ + + + + + + + +
+ ); +}; + +// Specifying form data type is not required here, but is recommended to avoid confusion +const testFormWithValidationDecorator = reduxForm({ + form: "testWithValidation", + validate: (values, props) => { + return { + foo: "Bad foo" + }; + } +}); + +// Specifying form data type is not required here, but is recommended to avoid confusion +const testFormWithInitialValuesDecorator = reduxForm({ + form: "testWithValidation", + initialValues: { + foo: "A Foo is here" + } +}); + +// Specifying form data type *is* required here, because type inference will guess the type of +// the form data type parameter to be {foo: string}. The result of validate does not contain "foo" +const testFormWithInitialValuesAndValidationDecorator = reduxForm({ + form: "testWithValidation", + initialValues: { + foo: "A Foo is here" + }, + validate: (values, props) => { + return { + bar: "Bad foo" + }; + } +}); + +const testFormWithChangeFunctionDecorator = reduxForm({ + form: "testWithValidation", + onChange: (values: Partial, + dispatch: Dispatch, + props: TestFormComponentProps & InjectedFormProps, + previousValues: Partial) => {} +}); + +type TestProps = {} & InjectedFormProps; +const Test = reduxForm({ + form : "test" +})( + class Test extends React.Component { + handleSubmitForm = (values: Partial, dispatch: Dispatch, props: {}) => {}; + + render() { + const { handleSubmit } = this.props; + const FormCustom = Form as new () => GenericForm; + + return ( +
+ + + name="my-section" + component={MyFormSection} + foo="hello" + /> + + + + + + + + + {}} + onBlur={(event, newValue, previousValue, fieldName) => {}} + /> + + + + + + + + + + + + null } + /> + + null } + foo="bar" + /> + + + name="field9" + component={ MyArrayField } + /> + + + + +
+ ); + } + } +); + +reducer({}, { + type: "ACTION" +}); + +reducer.plugin({ + myForm: (state: any, action: FormAction) => { + if (action.type === actionTypes.CHANGE && action.meta.form === "securitySettings") { + return { + ...state, + values: { + ...state.values, + downloadLinkAutoPassword: true, + }, + }; + } else { + return state; + } + } +}); + +try { + throw new SubmissionError({_error: "Submission failed."}); +} catch (error) { + if (!(error instanceof SubmissionError)) { + throw new Error("SubmissionError not imported correctly"); + } +} + +/* Test using versions imported directly/as defaults from lib */ +const DefaultField = ( + +); + +libReducer({}, { + type: "ACTION" +}); + +const DefaultFormSection = ( + +); + +const TestLibFormRequired = libReduxForm({})(TestFormComponent); +const TestLibForm = libReduxForm({ form : "test" })(TestFormComponent); + +const testSubmit = submit("test"); +const testLibSubmit = libActions.submit("test"); + +try { + throw new LibSubmissionError({_error: "Submission failed."}); +} catch (error) { + if (!(error instanceof LibSubmissionError)) { + throw new Error("SubmissionError from lib not imported correctly"); + } +} + +/* Test handleSubmit prop using as onSubmit handler */ +type HandleSubmitTestProps = {} & InjectedFormProps; +const HandleSubmitTestForm = reduxForm({ + form : "test" +})( + (props: HandleSubmitTestProps) =>
+); + +class HandleSubmitTest extends React.Component { + handleSubmit = (values: Partial, dispatch: Dispatch, props: {}) => {}; + render() { + return ; + } +} + +class FormNameTest extends React.Component { + render() { + return ( + + {({ form }) => Form Name is: {form}} + + ); + } +} + +// Test SubmissionError with custom error format +// See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26494 +// Note: explicit parameters not needed in TS 2.7 +new LibSubmissionError<{ myField: any }, string[]>({ + _error: ["First form-level error", "Second form-level error"], + myField: ["Field-level error"] +}); + +new SubmissionError({ + _error: ["First form-level error", "Second form-level error"] +}); + +// Test forms with custom error format. +const HandleSubmitTestForm2 = reduxForm({ form : "test" })( + (props: InjectedFormProps) => +); + +class HandleSubmitTest2 extends React.Component { + handleSubmit = (values: Partial, dispatch: Dispatch, props: {}) => {}; + render() { + return ; + } +} + +type InjectedProps2 = InjectedFormProps; +class TestFormComponent2 extends React.Component { + render() { + const { error, initialValues, handleSubmit } = this.props; + error.concat(['error is a string array']); + + handleSubmit((values) => ({ foo: ['string'], _error: [] })); + return null; + } +} diff --git a/types/redux-form/v7/tsconfig.json b/types/redux-form/v7/tsconfig.json new file mode 100644 index 0000000000..19b1709823 --- /dev/null +++ b/types/redux-form/v7/tsconfig.json @@ -0,0 +1,48 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "experimentalDecorators": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "jsx": "react", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "redux-form": [ + "redux-form/v7" + ], + "redux-form/*": [ + "redux-form/v7/*" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redux-form-tests.tsx", + "immutable/index.d.ts", + "lib/actions.d.ts", + "lib/actionTypes.d.ts", + "lib/Field.d.ts", + "lib/Fields.d.ts", + "lib/FieldArray.d.ts", + "lib/Form.d.ts", + "lib/FormSection.d.ts", + "lib/formValues.d.ts", + "lib/formValueSelector.d.ts", + "lib/reducer.d.ts", + "lib/reduxForm.d.ts", + "lib/selectors.d.ts", + "lib/SubmissionError.d.ts" + ] +} diff --git a/types/tabris-plugin-firebase/tslint.json b/types/redux-form/v7/tslint.json similarity index 67% rename from types/tabris-plugin-firebase/tslint.json rename to types/redux-form/v7/tslint.json index 4c4fc86ace..f3568a0139 100644 --- a/types/tabris-plugin-firebase/tslint.json +++ b/types/redux-form/v7/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { + "no-object-literal-type-assertion": false, "strict-export-declare-modifiers": false } } diff --git a/types/reflux/index.d.ts b/types/reflux/index.d.ts index dcfa795e73..a00dffb7db 100644 --- a/types/reflux/index.d.ts +++ b/types/reflux/index.d.ts @@ -51,8 +51,6 @@ export class Component any): void; } diff --git a/types/repeat-element/index.d.ts b/types/repeat-element/index.d.ts new file mode 100644 index 0000000000..2c3cd5d633 --- /dev/null +++ b/types/repeat-element/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for repeat-element 1.1 +// Project: https://github.com/jonschlinkert/repeat-element +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +/** + * Create an array by repeating the given value n times. + */ +declare function repeat(element: unknown, num: number): unknown[]; + +export = repeat; diff --git a/types/repeat-element/repeat-element-tests.ts b/types/repeat-element/repeat-element-tests.ts new file mode 100644 index 0000000000..b76b7b4b7e --- /dev/null +++ b/types/repeat-element/repeat-element-tests.ts @@ -0,0 +1,9 @@ +import repeat = require("repeat-element"); + +repeat(5, 5); + +repeat({some: 'object'}, 5); + +repeat('a', 5); + +repeat(null, 5); diff --git a/types/repeat-element/tsconfig.json b/types/repeat-element/tsconfig.json new file mode 100644 index 0000000000..6e7674eafd --- /dev/null +++ b/types/repeat-element/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "repeat-element-tests.ts" + ] +} diff --git a/types/repeat-element/tslint.json b/types/repeat-element/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/repeat-element/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/resize-observer-browser/index.d.ts b/types/resize-observer-browser/index.d.ts new file mode 100644 index 0000000000..83291fe4a0 --- /dev/null +++ b/types/resize-observer-browser/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for non-npm package resize-observer-browser 0.1 +// Project: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver, https://developers.google.com/web/updates/2016/10/resizeobserver, https://wicg.github.io/ResizeObserver/ +// Definitions by: Chives +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 + +export class ResizeObserver { + constructor(callback: ResizeObserverCallback); + disconnect(): void; + observe(target: Element): void; + unobserve(target: Element): void; +} + +export type ResizeObserverCallback = (entries: ResizeObserverEntry[]) => void; + +export interface ResizeObserverEntry { + readonly target: Element; + readonly contentRect: DOMRectReadOnly; +} diff --git a/types/resize-observer-browser/resize-observer-browser-tests.ts b/types/resize-observer-browser/resize-observer-browser-tests.ts new file mode 100644 index 0000000000..5596f13870 --- /dev/null +++ b/types/resize-observer-browser/resize-observer-browser-tests.ts @@ -0,0 +1,13 @@ +import { ResizeObserver } from "resize-observer-browser"; + +function resizeObserverCreates(): void { + const resizeObserver: ResizeObserver = new ResizeObserver((entries) => { + const div = document.getElementById('display-div')!; + const rect = entries[0].contentRect; + div.textContent = `${rect.left} ${rect.right}`; + }); + const div = document.getElementById('resized-div')!; + resizeObserver.observe(div); + resizeObserver.unobserve(div); + resizeObserver.disconnect(); +} diff --git a/types/resize-observer-browser/tsconfig.json b/types/resize-observer-browser/tsconfig.json new file mode 100644 index 0000000000..849758c836 --- /dev/null +++ b/types/resize-observer-browser/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "resize-observer-browser-tests.ts" + ] +} diff --git a/types/resize-observer-browser/tslint.json b/types/resize-observer-browser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/resize-observer-browser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/rivets/rivets-tests.ts b/types/rivets/rivets-tests.ts index 81c97e7d9e..67beebdc13 100644 --- a/types/rivets/rivets-tests.ts +++ b/types/rivets/rivets-tests.ts @@ -10,7 +10,7 @@ Rivets.configure({ // Template delimiters for text bindings templateDelimiters: ['[[', ']]'], // Augment the event handler of the on-* binder - handler: (target: any, event: any, binding: any) => { + handler(target: any, event: any, binding: any) { this.call(target, event, binding.view.models); } }); diff --git a/types/rn-fetch-blob/index.d.ts b/types/rn-fetch-blob/index.d.ts index 79758b4511..2ff48bc108 100644 --- a/types/rn-fetch-blob/index.d.ts +++ b/types/rn-fetch-blob/index.d.ts @@ -33,11 +33,11 @@ export interface Polyfill { Fetch: PolyfillFetch; } -export declare class PolyfillFetch extends RNFetchBlobFetchPolyfill { +export class PolyfillFetch extends RNFetchBlobFetchPolyfill { constructor(config: RNFetchBlobConfig); } -export declare class RNFetchBlobFetchPolyfill { +export class RNFetchBlobFetchPolyfill { constructor(config: RNFetchBlobConfig); build(): (url: string, options: RNFetchBlobConfig) => StatefulPromise; @@ -129,13 +129,13 @@ export interface PolyfillFileReader extends EventTarget { result: number; } -export declare namespace PolyfillFileReader { +export namespace PolyfillFileReader { const EMPTY: number; const LOADING: number; const DONE: number; } -export declare class PolyfillEvent { +export class PolyfillEvent { } export interface PolyfillProgressEvent extends EventTarget { @@ -144,7 +144,7 @@ export interface PolyfillProgressEvent extends EventTarget { total: number; } -export declare class PolyfillBlob extends EventTarget { +export class PolyfillBlob extends EventTarget { /** * RNFetchBlob Blob polyfill, create a Blob directly from file path, BASE64 * encoded data, and string. The conversion is done implicitly according to @@ -194,7 +194,7 @@ export declare class PolyfillBlob extends EventTarget { close(): Promise; } -export declare namespace PolyfillBlob { +export namespace PolyfillBlob { function clearCache(): void; function build(data: any, cType: any): Promise; @@ -202,7 +202,7 @@ export declare namespace PolyfillBlob { function setLog(level: number): void; } -export declare class PolyfillFile extends PolyfillBlob { +export class PolyfillFile extends PolyfillBlob { } export interface PolyfillXMLHttpRequest extends PolyfillXMLHttpRequestEventTarget { @@ -252,7 +252,7 @@ export interface PolyfillXMLHttpRequest extends PolyfillXMLHttpRequestEventTarge responseType: string; } -export declare namespace PolyfillXMLHttpRequest { +export namespace PolyfillXMLHttpRequest { const binaryContentTypes: string[]; const UNSENT: number; const OPENED: number; @@ -490,7 +490,7 @@ export interface StatefulPromise extends Promise { expire(callback: () => void): StatefulPromise; } -export declare class RNFetchBlobSession { +export class RNFetchBlobSession { constructor(name: string, list: string[]); add(path: string): RNFetchBlobSession; @@ -609,10 +609,10 @@ export interface RNFetchBlobStream { onEnd(): void; } -export declare class RNFetchBlobFile { +export class RNFetchBlobFile { } -export declare class RNFetchBlobStat { +export class RNFetchBlobStat { lastModified: string; size: string; type: "directory" | "file"; diff --git a/types/rollup-plugin-delete/package.json b/types/rollup-plugin-delete/package.json index 272f65edde..8971fd5346 100644 --- a/types/rollup-plugin-delete/package.json +++ b/types/rollup-plugin-delete/package.json @@ -1,6 +1,7 @@ { "private": true, "dependencies": { - "rollup": ">=0.60.0" + "del": "*", + "rollup": ">=0.60.0 <1.2.0" } } diff --git a/types/rtlcss/index.d.ts b/types/rtlcss/index.d.ts new file mode 100644 index 0000000000..3e2dcb1711 --- /dev/null +++ b/types/rtlcss/index.d.ts @@ -0,0 +1,80 @@ +// Type definitions for rtlcss 2.4 +// Project: http://rtlcss.com +// Definitions by: Adam Zerella +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.3 + +export interface MapOptions { + scope: string; + ignoreCase: boolean; + greedy?: boolean; +} + +export interface StringMap { + name: string; + priority: number; + exclusive?: boolean; + search: string|string[]; + replace: string|string[]; + options: MapOptions; +} + +export interface ConfigOptions { + /** + * Applies to CSS rules containing no directional properties, + * it will update the selector by applying String Map. + */ + autoRename: boolean; + /** + * Ensures autoRename is applied only if pair exists. + */ + autoRenameStrict: boolean; + /** + * An object map of disabled plugins directives, + * where keys are plugin names and value are object + * hash of disabled directives. e.g. {'rtlcss':{'config':true}}. + */ + blacklist: object; + /** + * Removes directives comments from output CSS. + */ + clean: boolean; + /** + * Fallback value for String Map options. + */ + greedy: boolean; + /** + * Applies String Map to URLs. You can also target specific node types using an object literal. + * e.g. {'atrule': true, 'decl': false}. + */ + processUrls: boolean|object; + /** + * The default array of String Map. + */ + stringMap: StringMap[]; + /** + * When enabled, flips background-position expressed in length units using calc. + */ + useCalc: boolean; +} + +export interface HookOptions { + /** + * The function to be called before processing the CSS. + */ + pre: () => void; + /** + * The function to be called after processing the CSS. + */ + post: () => void; +} + +/** + * Creates a new RTLCSS instance, process the input and return its result. + */ +export function process(css: string, options?: object, plugins?: object|string[], hooks?: HookOptions): string; + +/** + * Creates a new instance of RTLCSS using the passed configuration object. + */ +export function configure(config: ConfigOptions): object; diff --git a/types/rtlcss/rtlcss-tests.ts b/types/rtlcss/rtlcss-tests.ts new file mode 100644 index 0000000000..1355074c56 --- /dev/null +++ b/types/rtlcss/rtlcss-tests.ts @@ -0,0 +1,27 @@ +import * as rtlcss from "rtlcss"; + +rtlcss.process("body { direction:ltr; }"); + +const config = { + autoRename: false, + autoRenameStrict: false, + blacklist: {}, + clean: true, + greedy: false, + processUrls: false, + stringMap: [ + { + name : 'left-right', + priority: 100, + search : ['left', 'Left', 'LEFT'], + replace : ['right', 'Right', 'RIGHT'], + options : { + scope : '*', + ignoreCase : false + } + } + ], + useCalc: false +}; + +rtlcss.configure(config); diff --git a/types/rtlcss/tsconfig.json b/types/rtlcss/tsconfig.json new file mode 100644 index 0000000000..94644d49ad --- /dev/null +++ b/types/rtlcss/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rtlcss-tests.ts" + ] +} diff --git a/types/rtlcss/tslint.json b/types/rtlcss/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/rtlcss/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/rx-angular/rx-angular-tests.ts b/types/rx-angular/rx-angular-tests.ts index f2413695af..25d0f1887b 100644 --- a/types/rx-angular/rx-angular-tests.ts +++ b/types/rx-angular/rx-angular-tests.ts @@ -8,7 +8,7 @@ var app = angular.module('testModule'); interface AppScope extends rx.angular.IRxScope { } -app.controller('Ctrl', ($scope: AppScope) => { +app.controller('Ctrl', function ($scope: AppScope) { this.inputObservable = $scope.$toObservable('term') .safeApply($scope, (results: any) => { diff --git a/types/sarif/index.d.ts b/types/sarif/index.d.ts index cc5a9899b5..56bcf3e8da 100644 --- a/types/sarif/index.d.ts +++ b/types/sarif/index.d.ts @@ -5,7 +5,7 @@ // TypeScript Version: 2.4 /** - * Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2019-01-09 JSON Schema: a standard format for the + * Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2019-01-24 JSON Schema: a standard format for the * output of static analysis tools. */ export interface Log { @@ -32,23 +32,174 @@ export interface Log { export namespace Log { type version = - "2.0.0-csd.2.beta.2019-01-09"; + "2.0.0-csd.2.beta.2019-01-24"; } /** - * A file relevant to a tool invocation or to a result. + * A single artifact. In some cases, this artifact might be nested within another artifact. + */ +export interface Artifact { + /** + * The contents of the artifact. + */ + contents?: ArtifactContent; + + /** + * Specifies the encoding for an artifact object that refers to a text file. + */ + encoding?: string; + + /** + * A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value of + * the artifact produced by the specified hash function. + */ + hashes?: { [key: string]: string }; + + /** + * The Coordinated Universal Time (UTC) date and time at which the artifact was most recently modified. See + * "Date/time properties" in the SARIF spec for the required format. + */ + lastModifiedTimeUtc?: string; + + /** + * The length of the artifact in bytes. + */ + length?: number; + + /** + * The location of the artifact. + */ + location?: ArtifactLocation; + + /** + * The MIME type (RFC 2045) of the artifact. + */ + mimeType?: string; + + /** + * The offset in bytes of the artifact within its containing artifact. + */ + offset?: number; + + /** + * Identifies the index of the immediate parent of the artifact, if this artifact is nested. + */ + parentIndex?: number; + + /** + * The role or roles played by the artifact in the analysis. + */ + roles?: Artifact.roles[]; + + /** + * Specifies the source language for any artifact object that refers to a text file that contains source code. + */ + sourceLanguage?: string; + + /** + * Key/value pairs that provide additional information about the artifact. + */ + properties?: PropertyBag; +} + +export namespace Artifact { + type roles = + "analysisTarget" | + "toolComponent" | + "attachment" | + "responseFile" | + "resultFile" | + "standardStream" | + "traceFile" | + "unmodifiedFile" | + "modifiedFile" | + "addedFile" | + "deletedFile" | + "renamedFile" | + "uncontrolledFile"; +} + +/** + * A change to a single artifact. + */ +export interface ArtifactChange { + /** + * The location of the artifact to change. + */ + artifactLocation: ArtifactLocation; + + /** + * An array of replacement objects, each of which represents the replacement of a single region in a single + * artifact specified by 'artifactLocation'. + */ + replacements: Replacement[]; + + /** + * Key/value pairs that provide additional information about the change. + */ + properties?: PropertyBag; +} + +/** + * Represents the contents of an artifact. + */ +export interface ArtifactContent { + /** + * MIME Base64-encoded content from a binary artifact, or from a text artifact in its original encoding. + */ + binary?: string; + + /** + * UTF-8-encoded content from a text artifact. + */ + text?: string; + + /** + * Key/value pairs that provide additional information about the artifact content. + */ + properties?: PropertyBag; +} + +/** + * Specifies the location of an artifact. + */ +export interface ArtifactLocation { + /** + * The index within the run artifacts array of the artifact object associated with the artifact location. + */ + index?: number; + + /** + * A string containing a valid relative or absolute URI. + */ + uri: string; + + /** + * A string which indirectly specifies the absolute URI with respect to which a relative URI in the "uri" property + * is interpreted. + */ + uriBaseId?: string; + + /** + * Key/value pairs that provide additional information about the artifact location. + */ + properties?: PropertyBag; +} + +/** + * An artifact relevant to a tool invocation or to a result. */ export interface Attachment { + /** + * The location of the attachment. + */ + artifactLocation: ArtifactLocation; + /** * A message describing the role played by the attachment. */ description?: Message; - /** - * The location of the attachment. - */ - fileLocation: FileLocation; - /** * An array of rectangles specifying areas of interest within the image. */ @@ -75,8 +226,8 @@ export interface CodeFlow { message?: Message; /** - * An array of one or more unique threadFlow objects, each of which describes the progress of a program through - * a thread of execution. + * An array of one or more unique threadFlow objects, each of which describes the progress of a program through a + * thread of execution. */ threadFlows: ThreadFlow[]; @@ -94,7 +245,7 @@ export interface Conversion { /** * The locations of the analysis tool's per-run log files. */ - analysisToolLogFiles?: FileLocation[]; + analysisToolLogFiles?: ArtifactLocation[]; /** * An invocation object that describes the invocation of the converter. @@ -182,8 +333,8 @@ export interface Exception { innerExceptions?: Exception[]; /** - * A string that identifies the kind of exception, for example, the fully qualified type name of an object that - * was thrown, or the symbolic name of a signal. + * A string that identifies the kind of exception, for example, the fully qualified type name of an object that was + * thrown, or the symbolic name of a signal. */ kind?: string; @@ -210,7 +361,7 @@ export interface ExternalPropertyFile { /** * The location of the external property file. */ - fileLocation?: FileLocation; + artifactLocation?: ArtifactLocation; /** * A stable, unique identifer for the external property file in the form of a GUID. @@ -232,15 +383,20 @@ export interface ExternalPropertyFile { * References to external property files that should be inlined with the content of a root log file. */ export interface ExternalPropertyFiles { + /** + * An array of external property files containing run.artifacts arrays to be merged with the root log file. + */ + artifacts?: ExternalPropertyFile[]; + /** * An external property file containing a run.conversion object to be merged with the root log file. */ conversion?: ExternalPropertyFile; /** - * An array of external property files containing run.files arrays to be merged with the root log file. + * An external property file containing a run.properties object to be merged with the root log file. */ - files?: ExternalPropertyFile[]; + externalizedProperties?: ExternalPropertyFile; /** * An external property file containing a run.graphs object to be merged with the root log file. @@ -257,187 +413,32 @@ export interface ExternalPropertyFiles { */ logicalLocations?: ExternalPropertyFile[]; - /** - * An external property file containing a run.resources object to be merged with the root log file. - */ - resources?: ExternalPropertyFile; - /** * An array of external property files containing run.results arrays to be merged with the root log file. */ results?: ExternalPropertyFile[]; /** - * An external property file containing a run.properties object to be merged with the root log file. + * An external property file containing a run.tool object to be merged with the root log file. */ - properties?: ExternalPropertyFile; + tool?: ExternalPropertyFile; } /** - * A single file. In some cases, this file might be nested within another file. - */ -export interface File { - /** - * The contents of the file. - */ - contents?: FileContent; - - /** - * Specifies the encoding for a file object that refers to a text file. - */ - encoding?: string; - - /** - * The location of the file. - */ - fileLocation?: FileLocation; - - /** - * A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value - * of the file produced by the specified hash function. - */ - hashes?: { [key: string]: string }; - - /** - * The Coordinated Universal Time (UTC) date and time at which the file was most recently modified. See - * "Date/time properties" in the SARIF spec for the required format. - */ - lastModifiedTimeUtc?: string; - - /** - * The length of the file in bytes. - */ - length?: number; - - /** - * The MIME type (RFC 2045) of the file. - */ - mimeType?: string; - - /** - * The offset in bytes of the file within its containing file. - */ - offset?: number; - - /** - * Identifies the index of the immediate parent of the file, if this file is nested. - */ - parentIndex?: number; - - /** - * The role or roles played by the file in the analysis. - */ - roles?: File.roles[]; - - /** - * Specifies the source language for any file object that refers to a text file that contains source code. - */ - sourceLanguage?: string; - - /** - * Key/value pairs that provide additional information about the file. - */ - properties?: PropertyBag; -} - -export namespace File { - type roles = - "analysisTarget" | - "attachment" | - "responseFile" | - "resultFile" | - "standardStream" | - "traceFile" | - "unmodifiedFile" | - "modifiedFile" | - "addedFile" | - "deletedFile" | - "renamedFile" | - "uncontrolledFile"; -} - -/** - * A change to a single file. - */ -export interface FileChange { - /** - * The location of the file to change. - */ - fileLocation: FileLocation; - - /** - * An array of replacement objects, each of which represents the replacement of a single region in a single file - * specified by 'fileLocation'. - */ - replacements: Replacement[]; - - /** - * Key/value pairs that provide additional information about the file change. - */ - properties?: PropertyBag; -} - -/** - * Represents content from an external file. - */ -export interface FileContent { - /** - * MIME Base64-encoded content from a binary file, or from a text file in its original encoding. - */ - binary?: string; - - /** - * UTF-8-encoded content from a text file. - */ - text?: string; - - /** - * Key/value pairs that provide additional information about the external file. - */ - properties?: PropertyBag; -} - -/** - * Specifies the location of a file. - */ -export interface FileLocation { - /** - * The index within the run files array of the file object associated with the file location. - */ - fileIndex?: number; - - /** - * A string containing a valid relative or absolute URI. - */ - uri: string; - - /** - * A string which indirectly specifies the absolute URI with respect to which a relative URI in the "uri" - * property is interpreted. - */ - uriBaseId?: string; - - /** - * Key/value pairs that provide additional information about the file location. - */ - properties?: PropertyBag; -} - -/** - * A proposed fix for the problem represented by a result object. A fix specifies a set of file to modify. For each - * file, it specifies a set of bytes to remove, and provides a set of new bytes to replace them. + * A proposed fix for the problem represented by a result object. A fix specifies a set of artifacts to modify. For + * each artifact, it specifies a set of bytes to remove, and provides a set of new bytes to replace them. */ export interface Fix { + /** + * One or more artifact changes that comprise a fix for a result. + */ + changes: ArtifactChange[]; + /** * A message that describes the proposed fix, enabling viewers to present the proposed change to an end user. */ description?: Message; - /** - * One or more file changes that comprise a fix for a result. - */ - fileChanges: FileChange[]; - /** * Key/value pairs that provide additional information about the fix. */ @@ -445,8 +446,8 @@ export interface Fix { } /** - * A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a - * call graph). + * A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a call + * graph). */ export interface Graph { /** @@ -521,7 +522,7 @@ export interface Invocation { arguments?: string[]; /** - * A set of files relevant to the invocation of the tool. + * A set of artifacts relevant to the invocation of the tool. */ attachments?: Attachment[]; @@ -549,7 +550,7 @@ export interface Invocation { /** * An absolute URI specifying the location of the analysis tool's executable. */ - executableLocation?: FileLocation; + executableLocation?: ArtifactLocation; /** * The process exit code. @@ -587,36 +588,40 @@ export interface Invocation { processStartFailureMessage?: string; /** - * The locations of any response files specified on the tool's command line. + * An array of reportingConfigurationOverride objects that describe runtime reporting behavior. */ - responseFiles?: FileLocation[]; + reportingConfigurationOverrides?: ReportingConfigurationOverride[]; /** - * The Coordinated Universal Time (UTC) date and time at which the run started. See "Date/time properties" in - * the SARIF spec for the required format. + * The locations of any response files specified on the tool's command line. + */ + responseFiles?: ArtifactLocation[]; + + /** + * The Coordinated Universal Time (UTC) date and time at which the run started. See "Date/time properties" in the + * SARIF spec for the required format. */ startTimeUtc?: string; /** * A file containing the standard error stream from the process that was invoked. */ - stderr?: FileLocation; + stderr?: ArtifactLocation; /** * A file containing the standard input stream to the process that was invoked. */ - stdin?: FileLocation; + stdin?: ArtifactLocation; /** * A file containing the standard output stream from the process that was invoked. */ - stdout?: FileLocation; + stdout?: ArtifactLocation; /** - * A file containing the interleaved standard output and standard error stream from the process that was - * invoked. + * A file containing the interleaved standard output and standard error stream from the process that was invoked. */ - stdoutStderr?: FileLocation; + stdoutStderr?: ArtifactLocation; /** * A value indicating whether the tool's execution completed successfully. @@ -631,7 +636,7 @@ export interface Invocation { /** * The working directory for the analysis tool run. */ - workingDirectory?: FileLocation; + workingDirectory?: ArtifactLocation; /** * Key/value pairs that provide additional information about the invocation. @@ -649,9 +654,9 @@ export interface Location { annotations?: Region[]; /** - * The human-readable fully qualified name of the logical location. If run.logicalLocations is present, this - * value matches a property name within that object, from which further information about the logical location - * can be obtained. + * The human-readable fully qualified name of the logical location. If run.logicalLocations is present, this value + * matches a property name within that object, from which further information about the logical location can be + * obtained. */ fullyQualifiedLogicalName?: string; @@ -666,7 +671,7 @@ export interface Location { message?: Message; /** - * Identifies the file and region. + * Identifies the artifact and region. */ physicalLocation?: PhysicalLocation; @@ -681,8 +686,8 @@ export interface Location { */ export interface LogicalLocation { /** - * The machine-readable name for the logical location, such as a mangled function name provided by a C++ - * compiler that encodes calling convention, return type and other details along with the function name. + * The machine-readable name for the logical location, such as a mangled function name provided by a C++ compiler + * that encodes calling convention, return type and other details along with the function name. */ decoratedName?: string; @@ -693,8 +698,8 @@ export interface LogicalLocation { /** * The type of construct this logical location component refers to. Should be one of 'function', 'member', - * 'module', 'namespace', 'parameter', 'resource', 'returnType', 'type', or 'variable', if any of those - * accurately describe the construct. + * 'module', 'namespace', 'parameter', 'resource', 'returnType', 'type', or 'variable', if any of those accurately + * describe the construct. */ kind?: string; @@ -726,20 +731,15 @@ export interface Message { arguments?: string[]; /** - * The resource id for a plain text message string. + * A Markdown message string. + */ + markdown?: string; + + /** + * The resource id for a plain text or Markdown message string. */ messageId?: string; - /** - * The resource id for a rich text message string. - */ - richMessageId?: string; - - /** - * A rich text message string. - */ - richText?: string; - /** * A plain text message string. */ @@ -751,6 +751,26 @@ export interface Message { properties?: PropertyBag; } +/** + * A message string or message format string rendered in multiple formats. + */ +export interface MultiformatMessageString { + /** + * A Markdown message string or format string. + */ + markdown?: string; + + /** + * A plain text message string or format string. + */ + text?: string; + + /** + * Key/value pairs that provide additional information about the message. + */ + properties?: PropertyBag; +} + /** * Represents a node in a graph. */ @@ -807,7 +827,7 @@ export interface Notification { message: Message; /** - * The file and region relevant to this notification. + * The artifact and region relevant to this notification. */ physicalLocation?: PhysicalLocation; @@ -839,34 +859,35 @@ export interface Notification { export namespace Notification { type level = + "none" | "note" | "warning" | "error"; } /** - * A physical location relevant to a result. Specifies a reference to a programming artifact together with a range - * of bytes or characters within that artifact. + * A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of + * bytes or characters within that artifact. */ export interface PhysicalLocation { /** - * Specifies a portion of the file that encloses the region. Allows a viewer to display additional context + * The location of the artifact. + */ + artifactLocation: ArtifactLocation; + + /** + * Specifies a portion of the artifact that encloses the region. Allows a viewer to display additional context * around the region. */ contextRegion?: Region; - /** - * The location of the file. - */ - fileLocation: FileLocation; - /** * Value that distinguishes this physical location from all other physical locations in this run object. */ id?: number; /** - * Specifies a portion of the file. + * Specifies a portion of the artifact. */ region?: Region; @@ -927,7 +948,7 @@ export interface Rectangle { } /** - * A region within a file where a result was detected. + * A region within an artifact where a result was detected. */ export interface Region { /** @@ -936,7 +957,7 @@ export interface Region { byteLength?: number; /** - * The zero-based offset from the beginning of the file of the first byte in the region. + * The zero-based offset from the beginning of the artifact of the first byte in the region. */ byteOffset?: number; @@ -946,7 +967,7 @@ export interface Region { charLength?: number; /** - * The zero-based offset from the beginning of the file of the first character in the region. + * The zero-based offset from the beginning of the artifact of the first character in the region. */ charOffset?: number; @@ -966,12 +987,12 @@ export interface Region { message?: Message; /** - * The portion of the file contents within the specified region. + * The portion of the artifact contents within the specified region. */ - snippet?: FileContent; + snippet?: ArtifactContent; /** - * Specifies the source language, if any, of the portion of the file specified by the region object. + * Specifies the source language, if any, of the portion of the artifact specified by the region object. */ sourceLanguage?: string; @@ -992,18 +1013,18 @@ export interface Region { } /** - * The replacement of a single region of a file. + * The replacement of a single region of an artifact. */ export interface Replacement { /** - * The region of the file to delete. + * The region of the artifact to delete. */ deletedRegion: Region; /** * The content to insert at the location specified by the 'deletedRegion' property. */ - insertedContent?: FileContent; + insertedContent?: ArtifactContent; /** * Key/value pairs that provide additional information about the replacement. @@ -1012,21 +1033,133 @@ export interface Replacement { } /** - * Container for items that require localization. + * Information about a tool report that can be configured at runtime. */ -export interface Resources { +export interface ReportingConfiguration { /** - * A dictionary, each of whose keys is a resource identifier and each of whose values is a localized string. + * Specifies whether the report may be produced during the scan. */ - messageStrings?: { [key: string]: string }; + enabled?: boolean; /** - * An array of rule objects relevant to the run. + * Specifies the failure level for the report. */ - rules?: Rule[]; + level?: ReportingConfiguration.level; /** - * Key/value pairs that provide additional information about the resources. + * Contains configuration information specific to a report. + */ + parameters?: PropertyBag; + + /** + * Specifies the relative priority of the report. Used for analysis output only. + */ + rank?: number; + + /** + * Key/value pairs that provide additional information about the reporting configuration. + */ + properties?: PropertyBag; +} + +export namespace ReportingConfiguration { + type level = + "none" | + "note" | + "warning" | + "error"; +} + +/** + * Information about how a specific tool report was reconfigured at runtime. + */ +export interface ReportingConfigurationOverride { + /** + * Specifies how the report was configured during the scan. + */ + configuration?: ReportingConfiguration; + + /** + * The index within the run.tool.extensions array of the toolComponent object which describes the plug-in or tool + * extension that produced the report. + */ + extensionIndex?: number; + + /** + * The index within the toolComponent.notificationDescriptors array of the reportingDescriptor associated with this + * override. + */ + notificationIndex?: number; + + /** + * The index within the toolComponent.ruleDescriptors array of the reportingDescriptor associated with this + * override. + */ + ruleIndex?: number; + + /** + * Key/value pairs that provide additional information about the reporting configuration. + */ + properties?: PropertyBag; +} + +/** + * Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime + * reporting. + */ +export interface ReportingDescriptor { + /** + * Default reporting configuration information. + */ + defaultConfiguration?: ReportingConfiguration; + + /** + * An array of stable, opaque identifiers by which this report was known in some previous version of the analysis + * tool. + */ + deprecatedIds?: string[]; + + /** + * A description of the report. Should, as far as possible, provide details sufficient to enable resolution of any + * problem indicated by the result. + */ + fullDescription?: Message; + + /** + * Provides the primary documentation for the report, useful when there is no online documentation. + */ + help?: Message; + + /** + * A URI where the primary documentation for the report can be found. + */ + helpUri?: string; + + /** + * A stable, opaque identifier for the report. + */ + id?: string; + + /** + * A set of name/value pairs with arbitrary names. Each value is a multiformatMessageString object, which holds + * message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can + * be used to construct a message in combination with an arbitrary number of additional string arguments. + */ + messageStrings?: { [key: string]: MultiformatMessageString }; + + /** + * A report identifier that is understandable to an end user. + */ + name?: Message; + + /** + * A concise description of the report. Should be a single sentence that is understandable when visible space is + * limited to a single line of text. + */ + shortDescription?: Message; + + /** + * Key/value pairs that provide additional information about the report. */ properties?: PropertyBag; } @@ -1036,13 +1169,13 @@ export interface Resources { */ export interface Result { /** - * Identifies the file that the analysis tool was instructed to scan. This need not be the same as the file + * Identifies the artifact that the analysis tool was instructed to scan. This need not be the same as the artifact * where the result actually occurred. */ - analysisTarget?: FileLocation; + analysisTarget?: ArtifactLocation; /** - * A set of files relevant to the result. + * A set of artifacts relevant to the result. */ attachments?: Attachment[]; @@ -1073,8 +1206,7 @@ export interface Result { fixes?: Fix[]; /** - * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that - * id. + * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that id. */ graphs?: { [key: string]: Graph }; @@ -1093,6 +1225,11 @@ export interface Result { */ instanceGuid?: string; + /** + * A value that categorizes results by evaluation state. + */ + kind?: Result.kind; + /** * A value specifying the severity level of the result. */ @@ -1105,8 +1242,8 @@ export interface Result { locations?: Location[]; /** - * A message that describes the result. The first sentence of the message only will be displayed when visible - * space is limited. + * A message that describes the result. The first sentence of the message only will be displayed when visible space + * is limited. */ message: Message; @@ -1135,6 +1272,12 @@ export interface Result { */ relatedLocations?: Location[]; + /** + * The index within the run.tool.extensions array of the tool component object which describes the plug-in or tool + * extension that produced the result. + */ + ruleExtensionIndex?: number; + /** * The stable, unique identifier of the rule, if any, to which this notification is relevant. This member can be * used to retrieve rule metadata from the rules dictionary, if it exists. @@ -1168,13 +1311,19 @@ export interface Result { } export namespace Result { - type level = + type kind = + "none" | "notApplicable" | "pass" | + "fail" | + "review" | + "open"; + + type level = + "none" | "note" | "warning" | - "error" | - "open"; + "error"; type suppressionStates = "suppressedInSource" | @@ -1182,7 +1331,8 @@ export namespace Result { type baselineState = "new" | - "existing" | + "unchanged" | + "updated" | "absent"; } @@ -1191,14 +1341,13 @@ export namespace Result { */ export interface ResultProvenance { /** - * An array of physicalLocation objects which specify the portions of an analysis tool's output that a - * converter transformed into the result. + * An array of physicalLocation objects which specify the portions of an analysis tool's output that a converter + * transformed into the result. */ conversionSources?: PhysicalLocation[]; /** - * A GUID-valued string equal to the id.instanceGuid property of the run in which the result was first - * detected. + * A GUID-valued string equal to the id.instanceGuid property of the run in which the result was first detected. */ firstDetectionRunInstanceGuid?: string; @@ -1233,111 +1382,7 @@ export interface ResultProvenance { } /** - * Describes an analysis rule. - */ -export interface Rule { - /** - * Information about the rule that can be configured at runtime. - */ - configuration?: RuleConfiguration; - - /** - * An array of stable, opaque identifiers by which this rule was known in some previous version of the analysis - * tool. - */ - deprecatedIds?: string[]; - - /** - * A description of the rule. Should, as far as possible, provide details sufficient to enable resolution of any - * problem indicated by the result. - */ - fullDescription?: Message; - - /** - * Provides the primary documentation for the rule, useful when there is no online documentation. - */ - help?: Message; - - /** - * A URI where the primary documentation for the rule can be found. - */ - helpUri?: string; - - /** - * A stable, opaque identifier for the rule. - */ - id?: string; - - /** - * A set of name/value pairs with arbitrary names. The value within each name/value pair consists of plain text - * interspersed with placeholders, which can be used to construct a message in combination with an arbitrary - * number of additional string arguments. - */ - messageStrings?: { [key: string]: string }; - - /** - * A rule identifier that is understandable to an end user. - */ - name?: Message; - - /** - * A set of name/value pairs with arbitrary names. The value within each name/value pair consists of rich text - * interspersed with placeholders, which can be used to construct a message in combination with an arbitrary - * number of additional string arguments. - */ - richMessageStrings?: { [key: string]: string }; - - /** - * A concise description of the rule. Should be a single sentence that is understandable when visible space is - * limited to a single line of text. - */ - shortDescription?: Message; - - /** - * Key/value pairs that provide additional information about the rule. - */ - properties?: PropertyBag; -} - -/** - * Information about a rule that can be configured at runtime. - */ -export interface RuleConfiguration { - /** - * Specifies the default severity level for results generated by this rule. - */ - defaultLevel?: RuleConfiguration.defaultLevel; - - /** - * Specifies the default priority or importance for results generated by this rule. - */ - defaultRank?: number; - - /** - * Specifies whether the rule will be evaluated during the scan. - */ - enabled?: boolean; - - /** - * Contains configuration information specific to this rule. - */ - parameters?: PropertyBag; - - /** - * Key/value pairs that provide additional information about the rule configuration. - */ - properties?: PropertyBag; -} - -export namespace RuleConfiguration { - type defaultLevel = - "note" | - "warning" | - "error"; -} - -/** - * Describes a single run of an analysis tool, and contains the output of that run. + * Describes a single run of an analysis tool, and contains the reported output of that run. */ export interface Run { /** @@ -1345,6 +1390,11 @@ export interface Run { */ aggregateIds?: RunAutomationDetails[]; + /** + * An array of artifact objects relevant to the run. + */ + artifacts?: Artifact[]; + /** * The 'instanceGuid' property of a previous SARIF 'run' that comprises the baseline that was used to compute * result 'baselineState' properties for the run. @@ -1357,18 +1407,18 @@ export interface Run { columnKind?: Run.columnKind; /** - * A conversion object that describes how a converter transformed an analysis tool's native output format into + * A conversion object that describes how a converter transformed an analysis tool's native reporting format into * the SARIF format. */ conversion?: Conversion; /** - * Specifies the default encoding for any file object that refers to a text file. + * Specifies the default encoding for any artifact object that refers to a text file. */ defaultFileEncoding?: string; /** - * Specifies the default source language for any file object that refers to a text file that contains source + * Specifies the default source language for any artifact object that refers to a text file that contains source * code. */ defaultSourceLanguage?: string; @@ -1379,13 +1429,7 @@ export interface Run { externalPropertyFiles?: ExternalPropertyFiles; /** - * An array of file objects relevant to the run. - */ - files?: File[]; - - /** - * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that - * id. + * A dictionary, each of whose keys is the id of a graph and each of whose values is a 'graph' object with that id. */ graphs?: { [key: string]: Graph }; @@ -1405,47 +1449,41 @@ export interface Run { logicalLocations?: LogicalLocation[]; /** - * An ordered list of character sequences that were treated as line breaks when computing region information - * for the run. + * The MIME type of all Markdown text message properties in the run. Default: "text/markdown;variant=GFM" + */ + markdownMessageMimeType?: string; + + /** + * An ordered list of character sequences that were treated as line breaks when computing region information for + * the run. */ newlineSequences?: string[]; /** - * The file location specified by each uriBaseId symbol on the machine where the tool originally ran. + * The artifact location specified by each uriBaseId symbol on the machine where the tool originally ran. */ - originalUriBaseIds?: { [key: string]: FileLocation }; + originalUriBaseIds?: { [key: string]: ArtifactLocation }; /** * The string used to replace sensitive information in a redaction-aware property. */ redactionToken?: string; - /** - * Items that can be localized, such as message strings and rule metadata. - */ - resources?: Resources; - /** * The set of results contained in an SARIF log. The results array can be omitted when a run is solely exporting * rules metadata. It must be present (but may be empty) if a log file represents an actual scan. */ results?: Result[]; - /** - * The MIME type of all rich text message properties in the run. Default: "text/markdown;variant=GFM" - */ - richMessageMimeType?: string; - /** * Information about the tool or tool pipeline that generated the results in this run. A run can only contain - * results produced by a single tool or tool pipeline. A run can aggregate results from multiple log files, as - * long as context around the tool run (tool command-line arguments and the like) is identical for all - * aggregated files. + * results produced by a single tool or tool pipeline. A run can aggregate results from multiple log files, as long + * as context around the tool run (tool command-line arguments and the like) is identical for all aggregated files. */ tool: Tool; /** - * Specifies the revision in version control of the files that were scanned. + * Specifies the revision in version control of the artifacts that were scanned. */ versionControlProvenance?: VersionControlDetails[]; @@ -1595,15 +1633,17 @@ export interface ThreadFlowLocation { executionTimeUtc?: string; /** - * Specifies the importance of this location in understanding the code flow in which it occurs. The order from - * most to least important is "essential", "important", "unimportant". Default: "important". + * Specifies the importance of this location in understanding the code flow in which it occurs. The order from most + * to least important is "essential", "important", "unimportant". Default: "important". */ importance?: ThreadFlowLocation.importance; /** - * A string describing the type of this location. + * A set of distinct strings that categorize the thread flow location. Well-known kinds include acquire, release, + * enter, exit, call, return, branch, implicit, false, true, caution, danger, unknown, unreachable, taint, + * function, handler, lock, memory, resource, and scope. */ - kind?: string; + kinds?: string[]; /** * The code location. @@ -1627,8 +1667,8 @@ export interface ThreadFlowLocation { /** * A dictionary, each of whose keys specifies a variable or expression, the associated value of which represents - * the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary - * might hold the current assumed values of a set of global variables. + * the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary might + * hold the current assumed values of a set of global variables. */ state?: { [key: string]: string }; @@ -1650,20 +1690,14 @@ export namespace ThreadFlowLocation { */ export interface Tool { /** - * The binary version of the tool's primary executable file expressed as four non-negative integers separated - * by a period (for operating systems that express file versions in this way). + * The analysis tool that was run. */ - dottedQuadFileVersion?: string; + driver: ToolComponent; /** - * The absolute URI from which the tool can be downloaded. + * Tool extensions that contributed to or reconfigured the analysis tool that was run. */ - downloadUri?: string; - - /** - * The name of the tool along with its version and any other useful identifying information, such as its locale. - */ - fullName?: string; + extensions?: ToolComponent[]; /** * The tool language (expressed as an ISO 649 two-letter lowercase culture code) and region (expressed as an ISO @@ -1672,28 +1706,73 @@ export interface Tool { language?: string; /** - * The name of the tool. + * Key/value pairs that provide additional information about the tool. + */ + properties?: PropertyBag; +} + +/** + * A component, such as a plug-in or the default driver, of the analysis tool that was run. + */ +export interface ToolComponent { + /** + * The index within the run artifacts array of the artifact object associated with the component. + */ + artifactIndex?: number; + + /** + * The binary version of the component's primary executable file expressed as four non-negative integers separated + * by a period (for operating systems that express file versions in this way). + */ + dottedQuadFileVersion?: string; + + /** + * The absolute URI from which the component can be downloaded. + */ + downloadUri?: string; + + /** + * The name of the component along with its version and any other useful identifying information, such as its + * locale. + */ + fullName?: string; + + /** + * A dictionary, each of whose keys is a resource identifier and each of whose values is a multiformatMessageString + * object, which holds message strings in plain text and (optionally) Markdown format. The strings can include + * placeholders, which can be used to construct a message in combination with an arbitrary number of additional + * string arguments. + */ + globalMessageStrings?: { [key: string]: MultiformatMessageString }; + + /** + * The name of the component. */ name: string; /** - * A version that uniquely identifies the SARIF logging component that generated this file, if it is versioned - * separately from the tool. + * An array of reportDescriptor objects relevant to the notifications related to the configuration and runtime + * execution of the component. */ - sarifLoggerVersion?: string; + notificationDescriptors?: ReportingDescriptor[]; /** - * The tool version in the format specified by Semantic Versioning 2.0. + * An array of reportDescriptor objects relevant to the analysis performed by the component. + */ + ruleDescriptors?: ReportingDescriptor[]; + + /** + * The component version in the format specified by Semantic Versioning 2.0. */ semanticVersion?: string; /** - * The tool version, in whatever format the tool natively provides. + * The component version, in whatever format the component natively provides. */ version?: string; /** - * Key/value pairs that provide additional information about the tool. + * Key/value pairs that provide additional information about the component. */ properties?: PropertyBag; } @@ -1703,8 +1782,8 @@ export interface Tool { */ export interface VersionControlDetails { /** - * A Coordinated Universal Time (UTC) date and time that can be used to synchronize an enlistment to the state - * of the repository at that time. + * A Coordinated Universal Time (UTC) date and time that can be used to synchronize an enlistment to the state of + * the repository at that time. */ asOfTimeUtc?: string; @@ -1717,7 +1796,7 @@ export interface VersionControlDetails { * The location in the local file system to which the root of the repository was mapped at the time of the * analysis. */ - mappedTo?: FileLocation; + mappedTo?: ArtifactLocation; /** * The absolute URI of the repository. diff --git a/types/sarif/sarif-tests.ts b/types/sarif/sarif-tests.ts index 45b5bf922d..35d522b86b 100644 --- a/types/sarif/sarif-tests.ts +++ b/types/sarif/sarif-tests.ts @@ -4,8 +4,10 @@ const input = `{ "runs": [ { "tool": { - "name": "CodeScanner", - "semanticVersion": "2.1.0" + "driver": { + "name": "CodeScanner", + "semanticVersion": "2.1.0" + }, }, "results": [ ] @@ -13,6 +15,6 @@ const input = `{ ] }`; const log = JSON.parse("") as sarif.Log; -if (log.runs[0].tool.name !== "CodeScanner") { +if (log.runs[0].tool.driver.name !== "CodeScanner") { throw new Error("error: Tool name does not match"); } diff --git a/types/sc-hot-reboot/package.json b/types/sc-hot-reboot/package.json new file mode 100644 index 0000000000..a0e2ec3c5c --- /dev/null +++ b/types/sc-hot-reboot/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "chokidar": "^2.1.2" + } +} diff --git a/types/screenfull/index.d.ts b/types/screenfull/index.d.ts index 0ca3d642b9..2c7b93e453 100644 --- a/types/screenfull/index.d.ts +++ b/types/screenfull/index.d.ts @@ -1,36 +1,85 @@ -// Type definitions for screenfull.js 3.3.3 +// Type definitions for screenfull.js 4.0 // Project: https://github.com/sindresorhus/screenfull.js // Definitions by: Ilia Choly // lionelb // Joel Shepherd +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.5 -declare var screenfull: IScreenfull | false; - -interface IScreenfullRaw { - requestFullscreen?: string; - exitFullscreen?: string; - fullscreenElement?: string; - fullscreenEnabled?: string; - fullscreenchange?: string; - fullscreenerror?: string; -} - -interface IScreenfull { - isFullscreen: boolean; - element: Element; - enabled: boolean; - raw: IScreenfullRaw; - request(elem?: Element): void; - toggle(elem?: Element): void; - exit(): void; - onchange(handler: () => void): void; - onerror(handler: (event: Event) => void): void; - on(name: EventNameMap, handler: (event: Event) => void): void; - off(name: EventNameMap, handler: (event: Event) => void): void; -} - -type EventNameMap = 'change' | 'error'; - export = screenfull; +export as namespace screenfull; + +declare const screenfull: screenfull.Screenfull | false; + +declare namespace screenfull { + interface Screenfull { + /** + * Returns a boolean whether fullscreen is active. + */ + readonly isFullscreen: boolean; + /** + * Returns the element currently in fullscreen, otherwise `null`. + */ + readonly element: Element | null; + /** + * Returns a boolean whether you are allowed to enter fullscreen. If your page is inside an `